mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Sound options: merge playmusicifunfocused/playsoundifunfocused into one cvar
This commit is contained in:
parent
0c251ee643
commit
79012d00e8
5 changed files with 33 additions and 37 deletions
|
|
@ -406,10 +406,14 @@ extern CV_PossibleValue_t perfstats_cons_t[];
|
||||||
consvar_t cv_perfstats = Player("perfstats", "Off").dont_save().values(perfstats_cons_t);
|
consvar_t cv_perfstats = Player("perfstats", "Off").dont_save().values(perfstats_cons_t);
|
||||||
|
|
||||||
// Window focus sound sytem toggles
|
// Window focus sound sytem toggles
|
||||||
void PlayMusicIfUnfocused_OnChange(void);
|
void BGAudio_OnChange(void);
|
||||||
void PlaySoundIfUnfocused_OnChange(void);
|
void BGAudio_OnChange(void);
|
||||||
consvar_t cv_playmusicifunfocused = Player("playmusicifunfocused", "No").yes_no().onchange_noinit(PlayMusicIfUnfocused_OnChange);
|
consvar_t cv_bgaudio = Player("bgaudio", "Nothing").onchange_noinit(BGAudio_OnChange).values({
|
||||||
consvar_t cv_playsoundifunfocused = Player("playsoundsifunfocused", "No").yes_no().onchange_noinit(PlaySoundIfUnfocused_OnChange);
|
{0, "Nothing"},
|
||||||
|
{1, "Music"},
|
||||||
|
{2, "Sounds"},
|
||||||
|
{3, "Music&Sounds"},
|
||||||
|
});
|
||||||
|
|
||||||
// Pause game upon window losing focus
|
// Pause game upon window losing focus
|
||||||
consvar_t cv_pauseifunfocused = Player("pauseifunfocused", "Yes").yes_no();
|
consvar_t cv_pauseifunfocused = Player("pauseifunfocused", "Yes").yes_no();
|
||||||
|
|
|
||||||
|
|
@ -238,11 +238,8 @@ menuitem_t OPTIONS_Sound[] =
|
||||||
{IT_SPACE | IT_NOTHING, NULL, NULL,
|
{IT_SPACE | IT_NOTHING, NULL, NULL,
|
||||||
NULL, {NULL}, 0, 0},
|
NULL, {NULL}, 0, 0},
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR, "Play Music While Unfocused", "Keeps playing music even if the game is not the active window.",
|
{IT_STRING | IT_CVAR, "Hear Tabbed-out", "Keep playing game audio when the window is out of focus (FOCUS LOST).",
|
||||||
NULL, {.cvar = &cv_playmusicifunfocused}, 0, 0},
|
NULL, {.cvar = &cv_bgaudio}, 0, 0},
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR, "Play SFX While Unfocused", "Keeps playing sound effects even if the game is not the active window.",
|
|
||||||
NULL, {.cvar = &cv_playsoundifunfocused}, 0, 0},
|
|
||||||
|
|
||||||
// @TODO: Sound test (there's currently no space on this menu, might be better to throw it in extras?)
|
// @TODO: Sound test (there's currently no space on this menu, might be better to throw it in extras?)
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ boolean S_SoundDisabled(void)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
sound_disabled ||
|
sound_disabled ||
|
||||||
( window_notinfocus && ! cv_playsoundifunfocused.value )
|
( window_notinfocus && ! (cv_bgaudio.value & 2) )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2168,7 +2168,7 @@ boolean S_MusicDisabled(void)
|
||||||
boolean S_MusicNotInFocus(void)
|
boolean S_MusicNotInFocus(void)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
( window_notinfocus && ! cv_playmusicifunfocused.value )
|
( window_notinfocus && ! (cv_bgaudio.value & 1) )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2521,28 +2521,6 @@ void GameDigiMusic_OnChange(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayMusicIfUnfocused_OnChange(void);
|
|
||||||
void PlayMusicIfUnfocused_OnChange(void)
|
|
||||||
{
|
|
||||||
if (window_notinfocus)
|
|
||||||
{
|
|
||||||
if (cv_playmusicifunfocused.value)
|
|
||||||
I_SetMusicVolume(0);
|
|
||||||
else
|
|
||||||
S_SetMusicVolume();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlaySoundIfUnfocused_OnChange(void);
|
|
||||||
void PlaySoundIfUnfocused_OnChange(void)
|
|
||||||
{
|
|
||||||
if (!cv_gamesounds.value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (window_notinfocus && !cv_playsoundifunfocused.value)
|
|
||||||
S_StopSounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MasterVolume_OnChange(void);
|
void MasterVolume_OnChange(void);
|
||||||
void MasterVolume_OnChange(void)
|
void MasterVolume_OnChange(void)
|
||||||
{
|
{
|
||||||
|
|
@ -2570,3 +2548,21 @@ void SoundVolume_OnChange(void)
|
||||||
}
|
}
|
||||||
CV_StealthSetValue(&cv_mastervolume, max(cv_digmusicvolume.value, cv_soundvolume.value));
|
CV_StealthSetValue(&cv_mastervolume, max(cv_digmusicvolume.value, cv_soundvolume.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BGAudio_OnChange(void);
|
||||||
|
void BGAudio_OnChange(void)
|
||||||
|
{
|
||||||
|
if (window_notinfocus)
|
||||||
|
{
|
||||||
|
if (cv_bgaudio.value & 1)
|
||||||
|
I_SetMusicVolume(0);
|
||||||
|
else
|
||||||
|
S_SetMusicVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cv_gamesounds.value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (window_notinfocus && !(cv_bgaudio.value & 2))
|
||||||
|
S_StopSounds();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,7 @@ extern consvar_t cv_numChannels;
|
||||||
extern consvar_t cv_gamedigimusic;
|
extern consvar_t cv_gamedigimusic;
|
||||||
|
|
||||||
extern consvar_t cv_gamesounds;
|
extern consvar_t cv_gamesounds;
|
||||||
extern consvar_t cv_playmusicifunfocused;
|
extern consvar_t cv_bgaudio;
|
||||||
extern consvar_t cv_playsoundifunfocused;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -538,9 +538,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
{
|
{
|
||||||
// Tell game we lost focus, pause music
|
// Tell game we lost focus, pause music
|
||||||
window_notinfocus = true;
|
window_notinfocus = true;
|
||||||
if (!cv_playmusicifunfocused.value)
|
if (!(cv_bgaudio.value & 1))
|
||||||
I_SetMusicVolume(0);
|
I_SetMusicVolume(0);
|
||||||
if (!cv_playsoundifunfocused.value)
|
if (!(cv_bgaudio.value & 2))
|
||||||
S_StopSounds();
|
S_StopSounds();
|
||||||
|
|
||||||
if (!disable_mouse)
|
if (!disable_mouse)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue