Fix bug where new sounds didn't overplay old sounds
This commit is contained in:
+4
-4
@@ -39,7 +39,7 @@ New sounds with the same keys as
|
||||
already playing sounds are merged as follows:
|
||||
|
||||
* '_soundChannel' is set to the old value
|
||||
* if the old '_soundStatus' was 'FadingOut', it set to the new value (can restart playback with 'ToStart')
|
||||
* if the old '_soundStatus' was 'FadingOut', it is set to the new value (can restart playback with 'ToStart')
|
||||
* other fields are set to the new value.
|
||||
|
||||
In the update:
|
||||
@@ -57,8 +57,10 @@ mergeSound :: Sound -> Sound -> Sound
|
||||
mergeSound newS oldS
|
||||
| _soundStatus oldS == FadingOut
|
||||
= newS & soundChannel .~ _soundChannel oldS
|
||||
| otherwise = newS & soundChannel .~ _soundChannel oldS
|
||||
| _soundChunkID newS == _soundChunkID oldS
|
||||
= newS & soundChannel .~ _soundChannel oldS
|
||||
& soundStatus .~ _soundStatus oldS
|
||||
| otherwise = newS & soundChannel .~ _soundChannel oldS
|
||||
|
||||
updateSounds :: Ord a => IM.IntMap Mix.Chunk -> M.Map a Sound -> IO (M.Map a Sound)
|
||||
updateSounds sd ss = do
|
||||
@@ -156,8 +158,6 @@ setChannelPos :: Int16 -> Mix.Channel -> MaybeT IO Mix.Channel
|
||||
setChannelPos a i = do
|
||||
_ <- liftIO $ Mix.effectPosition i a 0
|
||||
return i
|
||||
|
||||
|
||||
-----------------------------------------------------------------
|
||||
{- | Set the volume for all sound channels.
|
||||
Behind the scenes, scales a float [0,1] to an Int [0..128].
|
||||
|
||||
Reference in New Issue
Block a user