From 16c0cd58ab2805cb963dff0cea84c6020024f6e8 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 23 Aug 2024 00:01:39 +0200 Subject: [PATCH] fixed bugs with enabling/disabling sound/music in setup menu --- src/screens.c | 9 +++++++++ src/tools.c | 24 ++++++++++++++++++++++++ src/tools.h | 2 ++ 3 files changed, 35 insertions(+) diff --git a/src/screens.c b/src/screens.c index e52fbea6..bd5e166e 100644 --- a/src/screens.c +++ b/src/screens.c @@ -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) diff --git a/src/tools.c b/src/tools.c index 9422b837..c14085f5 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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 diff --git a/src/tools.h b/src/tools.h index 8774909b..fcb8aee8 100644 --- a/src/tools.h +++ b/src/tools.h @@ -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); -- 2.34.1