From: Holger Schemel Date: Thu, 22 Aug 2024 22:01:39 +0000 (+0200) Subject: fixed bugs with enabling/disabling sound/music in setup menu X-Git-Tag: 4.4.0.0-test-4~292 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=16c0cd58ab2805cb963dff0cea84c6020024f6e8;p=rocksndiamonds.git fixed bugs with enabling/disabling sound/music in setup menu --- 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);