Revert sound and music window focus related toggles

This partially reverts commit 5ac8a26814.
This commit is contained in:
James R 2019-10-23 15:24:34 -07:00
parent 52c5d49215
commit 9162ba87cc
4 changed files with 31 additions and 86 deletions

View file

@ -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(
menu_t OP_SoundOptionsDef =
{
MN_OP_MAIN + (MN_OP_SOUND << 6),
"M_SOUND", OP_SoundOptionsMenu, &OP_MainDef, 30, 30);
"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

View file

@ -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();
}
}

View file

@ -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
//

View file

@ -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();
if (!disable_mouse)
{