diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 9b58a7103d..775d661988 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -62,6 +62,7 @@ Player::Player() m_pSecondaryScoreKeeper = NULL; m_pInventory = NULL; + m_bPaused = false; m_iOffsetSample = 0; this->AddChild( &m_Judgment ); @@ -280,6 +281,8 @@ void Player::Update( float fDeltaTime ) if( GAMESTATE->m_pCurSong==NULL ) return; + ActorFrame::Update( fDeltaTime ); + if( m_pPlayerState->m_bAttackBeganThisUpdate ) m_soundAttackLaunch.Play(); if( m_pPlayerState->m_bAttackEndedThisUpdate ) @@ -322,6 +325,11 @@ void Player::Update( float fDeltaTime ) m_pNoteField->SetZoom( fNoteFieldZoom ); m_Judgment.SetZoom( fJudgmentZoom ); + // If we're paused, don't update tap or hold note logic, so hold notes can be released + // during pause. + if( m_bPaused ) + return; + // // Check for TapNote misses // @@ -493,8 +501,6 @@ void Player::Update( float fDeltaTime ) // process transforms that are waiting to be applied ApplyWaitingTransforms(); - - ActorFrame::Update( fDeltaTime ); } void Player::ApplyWaitingTransforms() diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index f3b6ecc6ff..cbdb3ae740 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -51,6 +51,7 @@ public: void FadeToFail(); TapNoteScore GetLastTapNoteScore() const { return m_LastTapNoteScore; } void ApplyWaitingTransforms(); + void SetPaused( bool bPaused ) { m_bPaused = bPaused; } static float GetMaxStepDistanceSeconds(); @@ -75,6 +76,7 @@ protected: PlayerStageStats* m_pPlayerStageStats; float m_fNoteFieldHeight; + bool m_bPaused; float m_fOffset[SAMPLE_COUNT]; // for AutoSync int m_iOffsetSample; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index dd55d97873..81ab4d4a72 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -1147,6 +1147,9 @@ void ScreenGameplay::PauseGame( bool bPause ) this->PlayCommand( "Pause" ); else this->PlayCommand( "Unpause" ); + + FOREACH_EnabledPlayer(p) + m_Player[p].SetPaused( m_bPaused ); } // play assist ticks @@ -1320,6 +1323,10 @@ void ScreenGameplay::Update( float fDeltaTime ) if( SCREENMAN->GetTopScreen() != this ) return; + /* Update actors when paused, but never move on to another state. */ + if( m_bPaused ) + return; + if( GAMESTATE->m_MasterPlayerNumber != PLAYER_INVALID && !m_MaxCombo.GetHidden() ) m_MaxCombo.SetText( ssprintf("%d", STATSMAN->m_CurStageStats.m_player[GAMESTATE->m_MasterPlayerNumber].iMaxCombo) ); /* MAKE THIS WORK FOR BOTH PLAYERS! */ @@ -1732,6 +1739,14 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ if( type == IET_LEVEL_CHANGED ) return; + if( m_bPaused ) + { + /* If we're paused, only accept MENU_BUTTON_START to unpause. */ + if( MenuI.IsValid() && MenuI.button == MENU_BUTTON_START && type == IET_FIRST_PRESS ) + this->PauseGame( false ); + return; + } + if( MenuI.IsValid() && m_DancingState != STATE_OUTRO && !m_Back.IsTransitioning() ) @@ -2390,6 +2405,11 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) case SM_StopMusic: m_pSoundMusic->Stop(); break; + + case SM_Pause: + if( !m_bPaused ) + PauseGame( true ); + break; } } diff --git a/stepmania/src/ScreenMessage.h b/stepmania/src/ScreenMessage.h index 2a65146076..3c4d32a846 100644 --- a/stepmania/src/ScreenMessage.h +++ b/stepmania/src/ScreenMessage.h @@ -16,6 +16,7 @@ enum ScreenMessage { SM_GainFocus, SM_LoseFocus, SM_StopMusic, + SM_Pause, SM_User = 100 };