mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 12:21:19 +00:00
Merge branch 'master' of git@git.magicalgirl.moe:KartKrew/Kart-Public.git into next
This commit is contained in:
commit
ca522b3702
9 changed files with 89 additions and 10 deletions
|
@ -821,6 +821,8 @@ void D_RegisterClientCommands(void)
|
|||
//CV_RegisterVar(&cv_alwaysfreelook2);
|
||||
//CV_RegisterVar(&cv_chasefreelook);
|
||||
//CV_RegisterVar(&cv_chasefreelook2);
|
||||
CV_RegisterVar(&cv_showfocuslost);
|
||||
CV_RegisterVar(&cv_pauseifunfocused);
|
||||
|
||||
// g_input.c
|
||||
CV_RegisterVar(&cv_turnaxis);
|
||||
|
|
|
@ -437,6 +437,9 @@ consvar_t cv_chatbacktint = {"chatbacktint", "On", CV_SAVE, CV_OnOff, NULL, 0, N
|
|||
static CV_PossibleValue_t consolechat_cons_t[] = {{0, "Window"}, {1, "Console"}, {2, "Window (Hidden)"}, {0, NULL}};
|
||||
consvar_t cv_consolechat = {"chatmode", "Window", CV_SAVE, consolechat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// Pause game upon window losing focus
|
||||
consvar_t cv_pauseifunfocused = {"pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// Display song credits
|
||||
consvar_t cv_songcredits = {"songcredits", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ extern INT16 rw_maximums[NUM_WEAPONS];
|
|||
// used in game menu
|
||||
extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection/*, cv_compactscoreboard*/;
|
||||
extern consvar_t cv_songcredits;
|
||||
extern consvar_t cv_pauseifunfocused;
|
||||
//extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4;
|
||||
extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove*/;
|
||||
extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/;
|
||||
|
|
|
@ -399,6 +399,8 @@ static void Dummystaff_OnChange(void);
|
|||
// CONSOLE VARIABLES AND THEIR POSSIBLE VALUES GO HERE.
|
||||
// ==========================================================================
|
||||
|
||||
consvar_t cv_showfocuslost = {"showfocuslost", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL };
|
||||
|
||||
static CV_PossibleValue_t map_cons_t[] = {
|
||||
{0,"MIN"},
|
||||
{NUMMAPS, "MAX"},
|
||||
|
@ -1317,6 +1319,9 @@ static menuitem_t OP_SoundOptionsMenu[] =
|
|||
{IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95},
|
||||
|
||||
{IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 110},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125},
|
||||
{IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135},
|
||||
};
|
||||
|
||||
/*static menuitem_t OP_DataOptionsMenu[] =
|
||||
|
@ -1403,6 +1408,8 @@ static menuitem_t OP_HUDOptionsMenu[] =
|
|||
// highlight info - (GOOD HIGHLIGHT, WARNING HIGHLIGHT) - 105 (see M_DrawHUDOptions)
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 135},
|
||||
};
|
||||
|
||||
// Ok it's still called chatoptions but we'll put ping display in here to be clean
|
||||
|
@ -2894,7 +2901,7 @@ void M_Drawer(void)
|
|||
}
|
||||
|
||||
// focus lost notification goes on top of everything, even the former everything
|
||||
if (window_notinfocus)
|
||||
if (window_notinfocus && cv_showfocuslost.value)
|
||||
{
|
||||
M_DrawTextBox((BASEVIDWIDTH/2) - (60), (BASEVIDHEIGHT/2) - (16), 13, 2);
|
||||
if (gamestate == GS_LEVEL && (P_AutoPause() || paused))
|
||||
|
|
|
@ -212,6 +212,7 @@ typedef struct
|
|||
|
||||
extern description_t description[32];
|
||||
|
||||
extern consvar_t cv_showfocuslost;
|
||||
extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort;
|
||||
extern CV_PossibleValue_t gametype_cons_t[];
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ boolean P_AutoPause(void)
|
|||
if (netgame || modeattacking)
|
||||
return false;
|
||||
|
||||
return (menuactive || window_notinfocus);
|
||||
return (menuactive || ( window_notinfocus && cv_pauseifunfocused.value ));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -57,6 +57,9 @@ 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);
|
||||
|
||||
// commands for music and sound servers
|
||||
#ifdef MUSSERV
|
||||
consvar_t musserver_cmd = {"musserver_cmd", "musserver", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
@ -110,6 +113,9 @@ consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_O
|
|||
#endif
|
||||
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};
|
||||
|
||||
#define S_MAX_VOLUME 127
|
||||
|
||||
// when to clip out sounds
|
||||
|
@ -270,6 +276,9 @@ void S_RegisterSoundStuff(void)
|
|||
CV_RegisterVar(&cv_gamemidimusic);
|
||||
#endif
|
||||
|
||||
CV_RegisterVar(&cv_playmusicifunfocused);
|
||||
CV_RegisterVar(&cv_playsoundifunfocused);
|
||||
|
||||
COM_AddCommand("tunes", Command_Tunes_f);
|
||||
COM_AddCommand("restartaudio", Command_RestartAudio_f);
|
||||
|
||||
|
@ -1897,6 +1906,10 @@ static boolean S_PlayMusic(boolean looping)
|
|||
}
|
||||
|
||||
S_InitMusicVolume(); // switch between digi and sequence volume
|
||||
|
||||
if (window_notinfocus && !cv_playmusicifunfocused.value)
|
||||
I_PauseSong();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1978,6 +1991,24 @@ void S_ResumeAudio(void)
|
|||
I_ResumeCD();
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -2156,15 +2187,11 @@ void GameSounds_OnChange(void)
|
|||
|
||||
if (sound_disabled)
|
||||
{
|
||||
sound_disabled = false;
|
||||
S_InitSfxChannels(cv_soundvolume.value);
|
||||
S_StartSound(NULL, sfx_strpst);
|
||||
if (!( cv_playsoundifunfocused.value && window_notinfocus ))
|
||||
S_EnableSound();
|
||||
}
|
||||
else
|
||||
{
|
||||
sound_disabled = true;
|
||||
S_StopSounds();
|
||||
}
|
||||
S_DisableSound();
|
||||
}
|
||||
|
||||
void GameDigiMusic_OnChange(void)
|
||||
|
@ -2251,3 +2278,28 @@ void GameMIDIMusic_OnChange(void)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void PlayMusicIfUnfocused_OnChange(void)
|
||||
{
|
||||
if (window_notinfocus)
|
||||
{
|
||||
if (cv_playmusicifunfocused.value)
|
||||
I_PauseSong();
|
||||
else
|
||||
I_ResumeSong();
|
||||
}
|
||||
}
|
||||
|
||||
static void PlaySoundIfUnfocused_OnChange(void)
|
||||
{
|
||||
if (!cv_gamesounds.value)
|
||||
return;
|
||||
|
||||
if (window_notinfocus)
|
||||
{
|
||||
if (cv_playsoundifunfocused.value)
|
||||
S_DisableSound();
|
||||
else
|
||||
S_EnableSound();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ extern consvar_t cv_gamedigimusic;
|
|||
extern consvar_t cv_gamemidimusic;
|
||||
#endif
|
||||
extern consvar_t cv_gamesounds;
|
||||
extern consvar_t cv_playmusicifunfocused;
|
||||
extern consvar_t cv_playsoundifunfocused;
|
||||
|
||||
#ifdef SNDSERV
|
||||
extern consvar_t sndserver_cmd, sndserver_arg;
|
||||
|
@ -169,6 +171,10 @@ 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);
|
||||
|
||||
//
|
||||
// Updates music & sounds
|
||||
//
|
||||
|
|
|
@ -616,7 +616,11 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
|||
// Tell game we got focus back, resume music if necessary
|
||||
window_notinfocus = false;
|
||||
if (!paused)
|
||||
{
|
||||
I_ResumeSong(); //resume it
|
||||
if (cv_gamesounds.value)
|
||||
S_EnableSound();
|
||||
}
|
||||
|
||||
if (!firsttimeonmouse)
|
||||
{
|
||||
|
@ -630,7 +634,10 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
|||
{
|
||||
// Tell game we lost focus, pause music
|
||||
window_notinfocus = true;
|
||||
I_PauseSong();
|
||||
if (!cv_playmusicifunfocused.value)
|
||||
I_PauseSong();
|
||||
if (!cv_playsoundifunfocused.value)
|
||||
S_DisableSound();
|
||||
|
||||
if (!disable_mouse)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue