diff --git a/source/common/audio/music/music.cpp b/source/common/audio/music/music.cpp index 683a6a02b..90538ed2d 100644 --- a/source/common/audio/music/music.cpp +++ b/source/common/audio/music/music.cpp @@ -167,9 +167,9 @@ static bool S_StartMusicPlaying(ZMusic_MusicStream song, bool loop, float rel_vo //========================================================================== // -// S_PauseSound +// S_PauseMusic // -// Stop music and sound effects, during game PAUSE. +// Stop music, during game PAUSE. //========================================================================== void S_PauseMusic () @@ -184,9 +184,9 @@ void S_PauseMusic () //========================================================================== // -// S_ResumeSound +// S_ResumeMusic // -// Resume music and sound effects, after game PAUSE. +// Resume music, after game PAUSE. //========================================================================== void S_ResumeMusic () @@ -682,3 +682,5 @@ CCMD(currentmusic) Printf("Currently no music playing\n"); } } + +extern int paused; diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index ed18eca52..adbcacf85 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -114,6 +114,9 @@ CVAR(Bool, disableautoload, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALC extern int hud_size_max; +int paused; +bool pausedWithKey; + CUSTOM_CVAR(Int, cl_gender, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { if (self < 0 || self > 3) self = 0; @@ -826,6 +829,45 @@ CCMD(snd_reset) Mus_ResumeSaved(); } +//========================================================================== +// +// S_PauseSound +// +// Stop music and sound effects, during game PAUSE. +// +//========================================================================== + +void S_PauseSound (bool notmusic, bool notsfx) +{ + if (!notmusic) + { + S_PauseMusic(); + } + if (!notsfx) + { + soundEngine->SetPaused(true); + GSnd->SetSfxPaused (true, 0); + } +} + +//========================================================================== +// +// S_ResumeSound +// +// Resume music and sound effects, after game PAUSE. +// +//========================================================================== + +void S_ResumeSound (bool notsfx) +{ + S_ResumeMusic(); + if (!notsfx) + { + soundEngine->SetPaused(false); + GSnd->SetSfxPaused (false, 0); + } +} + //========================================================================== // // S_SetSoundPaused @@ -836,7 +878,6 @@ CCMD(snd_reset) void S_SetSoundPaused(int state) { -#if 0 if (state) { if (paused == 0) @@ -855,21 +896,10 @@ void S_SetSoundPaused(int state) S_PauseSound(false, true); if (GSnd != nullptr) { - GSnd->SetInactive(gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL ? - SoundRenderer::INACTIVE_Complete : - SoundRenderer::INACTIVE_Mute); + GSnd->SetInactive(SoundRenderer::INACTIVE_Complete); } } } - if (!netgame -#ifdef _DEBUG - && !demoplayback -#endif - ) - { - pauseext = !state; - } -#endif } int CalcSmoothRatio(const ClockTicks &totalclk, const ClockTicks &ototalclk, int realgameticspersec) @@ -940,3 +970,31 @@ bool CheckCheatmode(bool printmsg) return false; } +void updatePauseStatus() +{ + if (M_Active() || GUICapture) + { + paused = 1; + } + else if ((!M_Active() || !GUICapture) && !pausedWithKey) + { + paused = 0; + } + + if (inputState.GetKeyStatus(sc_Pause)) + { + inputState.ClearKeyStatus(sc_Pause); + paused = !paused; + + if (paused) + { + S_PauseSound(!paused, !paused); + } + else + { + S_ResumeSound(paused); + } + + pausedWithKey = paused; + } +} diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 71af02387..aa19191d8 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -154,6 +154,8 @@ const char* G_DefaultConFile(void); const char* G_ConFile(void); TArray GrpScan(); +void S_PauseSound(bool notmusic, bool notsfx); +void S_ResumeSound(bool notsfx); void S_SetSoundPaused(int state); void G_FatalEngineError(void); @@ -182,3 +184,5 @@ enum PAUSESFX_CONSOLE = 2 }; +void updatePauseStatus(); +extern int paused;