From f182a04780647a89b7ef7d29c31ec6706d76063e Mon Sep 17 00:00:00 2001 From: Kyzentun Keeslala Date: Thu, 3 Sep 2015 14:39:57 -0600 Subject: [PATCH] Fixed pausing on ScreenGameplay by making GameState have a pause variable and not force the song position forward if the game is paused. Implementing a working pause button that the player can press is left as an exercise for the reader. --- src/GameState.cpp | 3 ++- src/GameState.h | 3 +++ src/ScreenGameplay.cpp | 9 +++++++-- src/ScreenGameplay.h | 7 ++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/GameState.cpp b/src/GameState.cpp index 6f39e47a39..545bd53324 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -331,6 +331,7 @@ void GameState::Reset() m_SongOptions.Init(); + m_paused= false; ResetMusicStatistics(); ResetStageStatistics(); AdjustSync::ResetOriginalSyncData(); @@ -1251,7 +1252,7 @@ void GameState::UpdateSongPosition( float fPositionSeconds, const TimingData &ti * driver, like so: 13.120953,13.130975,13.130975,13.130975,13.140998,... * This causes visual stuttering of the arrows. To compensate, keep a * RageTimer since the last change. */ - if (fPositionSeconds == m_LastPositionSeconds) + if(fPositionSeconds == m_LastPositionSeconds && !m_paused) fPositionSeconds += m_LastPositionTimer.Ago(); else { diff --git a/src/GameState.h b/src/GameState.h index 929822b625..b5fbf702dc 100644 --- a/src/GameState.h +++ b/src/GameState.h @@ -269,6 +269,8 @@ public: static const float MUSIC_SECONDS_INVALID; void ResetMusicStatistics(); // Call this when it's time to play a new song. Clears the values above. + void SetPaused(bool p) { m_paused= p; } + bool GetPaused() { return m_paused; } void UpdateSongPosition( float fPositionSeconds, const TimingData &timing, const RageTimer ×tamp = RageZeroTimer ); float GetSongPercent( float beat ) const; @@ -426,6 +428,7 @@ private: // Timing position corrections RageTimer m_LastPositionTimer; float m_LastPositionSeconds; + bool m_paused; GameState(const GameState& rhs); GameState& operator=(const GameState& rhs); diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index bb84302ec2..7f05cb3c1a 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -398,7 +398,7 @@ void ScreenGameplay::Init() MEMCARDMAN->PauseMountingThread(); m_pSoundMusic = NULL; - m_bPaused = false; + set_paused_internal(false); m_pCombinedLifeMeter = NULL; @@ -1499,6 +1499,11 @@ void ScreenGameplay::StartPlayingSong( float fMinTimeToNotes, float fMinTimeToMu } } +void ScreenGameplay::set_paused_internal(bool p) +{ + m_bPaused= p; + GAMESTATE->SetPaused(p); +} void ScreenGameplay::PauseGame( bool bPause, GameController gc ) { @@ -1514,7 +1519,7 @@ void ScreenGameplay::PauseGame( bool bPause, GameController gc ) ResetGiveUpTimers(false); - m_bPaused = bPause; + set_paused_internal(bPause); m_PauseController = gc; m_pSoundMusic->Pause( bPause ); diff --git a/src/ScreenGameplay.h b/src/ScreenGameplay.h index 5d4747f1c0..799d78786b 100644 --- a/src/ScreenGameplay.h +++ b/src/ScreenGameplay.h @@ -249,9 +249,14 @@ protected: STATE_DANCING, /**< The main state where notes have to be pressed. */ STATE_OUTRO, /**< The ending state, pressing Back isn't allowed here. */ NUM_DANCING_STATES - } + } /** @brief The specific point within ScreenGameplay. */ m_DancingState; + private: bool m_bPaused; + // set_paused_internal exists because GameState's pause variable needs to + // be kept in sync with ScreenGameplay's. + void set_paused_internal(bool p); + protected: GameController m_PauseController; /**