fixed bugs with enabling/disabling sound/music in setup menu
authorHolger Schemel <holger.schemel@virtion.de>
Thu, 22 Aug 2024 22:01:39 +0000 (00:01 +0200)
committerHolger Schemel <holger.schemel@virtion.de>
Thu, 22 Aug 2024 22:01:39 +0000 (00:01 +0200)
src/screens.c
src/tools.c
src/tools.h

index e52fbea6c2158130cd8b0d5e175db8284d4d17d0..bd5e166e7317a84f6340939c129170378256cc4e 100644 (file)
@@ -8595,6 +8595,15 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
   // game speed list may have changed at this point
   if (si->value == &setup.game_speed_extended)
     ToggleGameSpeedsListIfNeeded();
+
+  // music state may have changed at this point
+  if (si->value == &setup.sound_music)
+    ToggleMenuMusicIfNeeded();
+
+  // sound state may have changed at this point
+  if (si->value == &setup.sound_simple ||
+      si->value == &setup.sound_loops)
+    ToggleMenuSoundsIfNeeded();
 }
 
 static struct TokenInfo *getSetupInfoFinal(struct TokenInfo *setup_info_orig)
index 9422b837063980205dab7a451b35b3e69e3d2a7e..c14085f5594b8123b4cabcb31e2c8930b21fc20f 100644 (file)
@@ -11519,6 +11519,30 @@ void ToggleAudioSampleRateIfNeeded(void)
 #endif
 }
 
+void ToggleMenuMusicIfNeeded(void)
+{
+  setup.sound = (setup.sound_simple || setup.sound_loops || setup.sound_music);
+
+  SetAudioMode(setup.sound);
+
+  if (setup.sound_music)
+    PlayMenuMusic();
+  else
+    FadeMenuMusic();
+}
+
+void ToggleMenuSoundsIfNeeded(void)
+{
+  setup.sound = (setup.sound_simple || setup.sound_loops || setup.sound_music);
+
+  SetAudioMode(setup.sound);
+
+  if (setup.sound_loops)
+    PlayMenuSound();
+  else
+    FadeMenuSounds();
+}
+
 void ToggleFullscreenIfNeeded(void)
 {
   // if setup and video fullscreen state are already matching, nothing do do
index 8774909b256e98b29389f701ac006647915987dd..fcb8aee85929a24724fcc752d2ba12bac6eee35c 100644 (file)
@@ -306,6 +306,8 @@ void ResetFontStatus(void);
 void SetLevelSetInfo(char *, int);
 
 void ToggleAudioSampleRateIfNeeded(void);
+void ToggleMenuMusicIfNeeded(void);
+void ToggleMenuSoundsIfNeeded(void);
 void ToggleFullscreenIfNeeded(void);
 void ChangeWindowScalingIfNeeded(void);
 void ChangeVsyncModeIfNeeded(void);