From 9162ba87cc49db03f565be85fcece5c305cfb6e0 Mon Sep 17 00:00:00 2001 From: James R <justsomejames2@gmail.com> Date: Wed, 23 Oct 2019 15:24:34 -0700 Subject: [PATCH] Revert sound and music window focus related toggles This partially reverts commit 5ac8a26814bb43c5e91ab77af9a2e546b0ef50e4. --- src/m_menu.c | 40 +++++++++++++++++------------- src/s_sound.c | 62 ++++++----------------------------------------- src/s_sound.h | 6 ----- src/sdl/i_video.c | 9 +------ 4 files changed, 31 insertions(+), 86 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index cb33105d9e..42f92daeed 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1326,25 +1326,22 @@ static menuitem_t OP_OpenGLColorMenu[] = static menuitem_t OP_SoundOptionsMenu[] = { - {IT_HEADER, NULL, "Game Audio", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 6}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 11}, + {IT_HEADER, NULL, "Game Audio", NULL, 0}, // 0 // ScrollMenu offsets + {IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 13}, // 6 + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 23}, // 11 - {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 21}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 26}, + {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 43}, // 21 + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 53}, // 26 - {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 36}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 41}, + {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 73}, // 36 + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 83}, // 41 - {IT_HEADER, NULL, "Accessibility", NULL, 50}, - {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 56}, - {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 61}, - - {IT_STRING | IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 71}, - {IT_STRING | IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 76}, + {IT_HEADER, NULL, "Accessibility", NULL, 103}, // 50 + {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 115}, // 56 + {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 125}, // 62 #ifdef HAVE_MIXERX - {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 86}, + {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 143}, #endif }; @@ -1967,9 +1964,18 @@ menu_t OP_ColorOptionsDef = 0, NULL }; -menu_t OP_SoundOptionsDef = DEFAULTSCROLLMENUSTYLE( - MN_OP_MAIN + (MN_OP_SOUND << 6), - "M_SOUND", OP_SoundOptionsMenu, &OP_MainDef, 30, 30); +menu_t OP_SoundOptionsDef = +{ + MN_OP_MAIN + (MN_OP_SOUND << 6), + "M_SOUND", + sizeof (OP_SoundOptionsMenu)/sizeof (menuitem_t), + &OP_MainDef, + OP_SoundOptionsMenu, + M_DrawGenericMenu, + 30, 30, + 0, + NULL +}; #ifdef HAVE_MIXERX menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE(MN_OP_MAIN + (MN_OP_SOUND << 6), "M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); #endif diff --git a/src/s_sound.c b/src/s_sound.c index e68a25ec93..1a719d9725 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -60,9 +60,6 @@ static void GameMIDIMusic_OnChange(void); static void GameSounds_OnChange(void); static void GameDigiMusic_OnChange(void); -static void PlayMusicIfUnfocused_OnChange(void); -static void PlaySoundIfUnfocused_OnChange(void); - static void ModFilter_OnChange(void); static lumpnum_t S_GetMusicLumpNum(const char *mname); @@ -120,9 +117,6 @@ consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_O consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlayMusicIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playsoundifunfocused = {"playsoundsifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlaySoundIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; - #ifdef HAVE_OPENMPT static CV_PossibleValue_t interpolationfilter_cons_t[] = {{0, "Default"}, {1, "None"}, {2, "Linear"}, {4, "Cubic"}, {8, "Windowed sinc"}, {0, NULL}}; consvar_t cv_modfilter = {"modfilter", "0", CV_SAVE|CV_CALL, interpolationfilter_cons_t, ModFilter_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -296,9 +290,6 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_miditimiditypath); #endif - CV_RegisterVar(&cv_playmusicifunfocused); - CV_RegisterVar(&cv_playsoundifunfocused); - COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); @@ -2027,24 +2018,6 @@ void S_ResumeAudio(void) S_AdjustMusicStackTics(); } -void S_DisableSound(void) -{ - if (sound_started && !sound_disabled) - { - sound_disabled = true; - S_StopSounds(); - } -} - -void S_EnableSound(void) -{ - if (sound_started && sound_disabled) - { - sound_disabled = false; - S_InitSfxChannels(cv_soundvolume.value); - } -} - void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) { if (digvolume < 0) @@ -2234,11 +2207,15 @@ void GameSounds_OnChange(void) if (sound_disabled) { - if (!( cv_playsoundifunfocused.value && window_notinfocus )) - S_EnableSound(); + sound_disabled = false; + S_InitSfxChannels(cv_soundvolume.value); + S_StartSound(NULL, sfx_strpst); } else - S_DisableSound(); + { + sound_disabled = true; + S_StopSounds(); + } } void GameDigiMusic_OnChange(void) @@ -2331,28 +2308,3 @@ void ModFilter_OnChange(void) openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value); } #endif - -static void PlayMusicIfUnfocused_OnChange(void) -{ - if (window_notinfocus) - { - if (cv_playmusicifunfocused.value) - S_PauseAudio(); - else - S_ResumeAudio(); - } -} - -static void PlaySoundIfUnfocused_OnChange(void) -{ - if (!cv_gamesounds.value) - return; - - if (window_notinfocus) - { - if (cv_playsoundifunfocused.value) - S_DisableSound(); - else - S_EnableSound(); - } -} diff --git a/src/s_sound.h b/src/s_sound.h index f4a9865857..48128527ce 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -44,8 +44,6 @@ extern consvar_t cv_resetmusicbyheader; extern consvar_t cv_gamedigimusic; extern consvar_t cv_gamemidimusic; extern consvar_t cv_gamesounds; -extern consvar_t cv_playmusicifunfocused; -extern consvar_t cv_playsoundifunfocused; #ifdef HAVE_OPENMPT extern consvar_t cv_modfilter; @@ -246,10 +244,6 @@ void S_StopMusic(void); void S_PauseAudio(void); void S_ResumeAudio(void); -// Enable and disable sound effects -void S_EnableSound(void); -void S_DisableSound(void); - // // Music Fading // diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index ed371d3492..be6017aa92 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -580,11 +580,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) // Tell game we got focus back, resume music if necessary window_notinfocus = false; if (!paused) - { S_ResumeAudio(); //resume it - if (cv_gamesounds.value) - S_EnableSound(); - } if (!firsttimeonmouse) { @@ -599,10 +595,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { // Tell game we lost focus, pause music window_notinfocus = true; - if (!cv_playmusicifunfocused.value) - S_PauseAudio(); - if (!cv_playsoundifunfocused.value) - S_DisableSound(); + S_PauseAudio(); if (!disable_mouse) { -- GitLab