Extract updatePauseState from Game::run (#13893)

This commit is contained in:
JosiahWI 2023-10-18 13:17:30 -05:00 committed by GitHub
parent 6026003508
commit 62eb6cfed0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 16 deletions

View File

@ -788,6 +788,7 @@ protected:
void updateCameraDirection(CameraOrientation *cam, float dtime); void updateCameraDirection(CameraOrientation *cam, float dtime);
void updateCameraOrientation(CameraOrientation *cam, float dtime); void updateCameraOrientation(CameraOrientation *cam, float dtime);
void updatePlayerControl(const CameraOrientation &cam); void updatePlayerControl(const CameraOrientation &cam);
void updatePauseState();
void step(f32 dtime); void step(f32 dtime);
void processClientEvents(CameraOrientation *cam); void processClientEvents(CameraOrientation *cam);
void updateCamera(f32 dtime); void updateCamera(f32 dtime);
@ -1238,23 +1239,12 @@ void Game::run()
cam_view.camera_pitch) * m_cache_cam_smoothing; cam_view.camera_pitch) * m_cache_cam_smoothing;
updatePlayerControl(cam_view); updatePlayerControl(cam_view);
{ updatePauseState();
bool was_paused = m_is_paused; if (m_is_paused)
m_is_paused = simple_singleplayer_mode && g_menumgr.pausesGame(); dtime = 0.0f;
if (m_is_paused) else
dtime = 0.0f;
if (!was_paused && m_is_paused) {
pauseAnimation();
sound_manager->pauseAll();
} else if (was_paused && !m_is_paused) {
resumeAnimation();
sound_manager->resumeAll();
}
}
if (!m_is_paused)
step(dtime); step(dtime);
processClientEvents(&cam_view_target); processClientEvents(&cam_view_target);
updateDebugState(); updateDebugState();
updateCamera(dtime); updateCamera(dtime);
@ -2696,6 +2686,20 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
//tt.stop(); //tt.stop();
} }
void Game::updatePauseState()
{
bool was_paused = this->m_is_paused;
this->m_is_paused = this->simple_singleplayer_mode && g_menumgr.pausesGame();
if (!was_paused && this->m_is_paused) {
this->pauseAnimation();
this->sound_manager->pauseAll();
} else if (was_paused && !this->m_is_paused) {
this->resumeAnimation();
this->sound_manager->resumeAll();
}
}
inline void Game::step(f32 dtime) inline void Game::step(f32 dtime)
{ {