diff --git a/src/client/GameAtmosphere/Soundscape/SoundInstanceHandler.lua b/src/client/GameAtmosphere/Soundscape/SoundInstanceHandler.lua index 6cb6284..cb75d9c 100644 --- a/src/client/GameAtmosphere/Soundscape/SoundInstanceHandler.lua +++ b/src/client/GameAtmosphere/Soundscape/SoundInstanceHandler.lua @@ -52,7 +52,11 @@ for _, playlistFolder in playlists:GetChildren() do volumeKnobs.off[playlistFolder.Name] = createKnob(nextAudioInstance, false) switches.play[playlistFolder.Name] = function() - nextAudioInstance:Play() + if nextAudioInstance.IsPaused then + nextAudioInstance:Resume() + else + nextAudioInstance:Play() + end end switches.pause[playlistFolder.Name] = function() nextAudioInstance:Pause() @@ -73,6 +77,7 @@ for _, playlistFolder in playlists:GetChildren() do nextAudioInstance.Name = playlistFolder.Name nextAudioInstance.Parent = soundFolder nextAudioInstance.Ended:Wait() + print "ended" end end end) diff --git a/src/client/GameAtmosphere/Soundscape/SoundSystem.lua b/src/client/GameAtmosphere/Soundscape/SoundSystem.lua index bd7c01b..e015a8e 100644 --- a/src/client/GameAtmosphere/Soundscape/SoundSystem.lua +++ b/src/client/GameAtmosphere/Soundscape/SoundSystem.lua @@ -10,22 +10,36 @@ local volumeKnobs, switches = local player = Players.LocalPlayer store.changed:connect(function(newState, oldState) - local oldPrimarySoundRegion = selectors.getAudioData(oldState, player.Name).PrimarySoundRegion local newPrimarySoundRegion = selectors.getAudioData(newState, player.Name).PrimarySoundRegion + local newBackgroundMusicSetting = selectors.getSetting(newState, player.Name, "BackgroundMusic") local oldBackgroundMusicSetting = selectors.getSetting(oldState, player.Name, "BackgroundMusic") - if not selectors.getSetting(newState, player.Name, "BackgroundMusic") then - newPrimarySoundRegion = nil + if not newBackgroundMusicSetting then + volumeKnobs.on[newPrimarySoundRegion]:Cancel() + volumeKnobs.off[newPrimarySoundRegion]:Play() + return + end + + if oldBackgroundMusicSetting ~= newBackgroundMusicSetting then + volumeKnobs.off[newPrimarySoundRegion]:Cancel() + switches.play[newPrimarySoundRegion]() + volumeKnobs.on[newPrimarySoundRegion]:Play() + return end +end) + +store.changed:connect(function(newState, oldState) + local oldPrimarySoundRegion = selectors.getAudioData(oldState, player.Name).PrimarySoundRegion + local newPrimarySoundRegion = selectors.getAudioData(newState, player.Name).PrimarySoundRegion - if oldPrimarySoundRegion ~= newPrimarySoundRegion or not oldBackgroundMusicSetting then + if oldPrimarySoundRegion ~= newPrimarySoundRegion then if newPrimarySoundRegion then - if oldPrimarySoundRegion then + if oldPrimarySoundRegion and oldPrimarySoundRegion ~= newPrimarySoundRegion then volumeKnobs.off[oldPrimarySoundRegion]:Play() end switches.play[newPrimarySoundRegion]() volumeKnobs.on[newPrimarySoundRegion]:Play() - else + elseif oldPrimarySoundRegion then volumeKnobs.on[oldPrimarySoundRegion]:Cancel() volumeKnobs.off[oldPrimarySoundRegion]:Play() end