From b407588073c9254d6b6ceb00540b923dc705655c Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 23 Apr 2005 03:13:12 +0000 Subject: [PATCH] fix GainLife command playing on wrong element --- stepmania/src/ScoreDisplayLifeTime.cpp | 33 ++++++++++++++++++-------- stepmania/src/ScoreDisplayLifeTime.h | 2 ++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/stepmania/src/ScoreDisplayLifeTime.cpp b/stepmania/src/ScoreDisplayLifeTime.cpp index c334709f20..508d4ff3e1 100644 --- a/stepmania/src/ScoreDisplayLifeTime.cpp +++ b/stepmania/src/ScoreDisplayLifeTime.cpp @@ -9,6 +9,7 @@ #include "StatsManager.h" #include "CommonMetrics.h" #include "ActorUtil.h" +#include "Course.h" static const CString GAIN_LIFE_COMMAND_NAME = "GainLife"; @@ -73,7 +74,14 @@ void ScoreDisplayLifeTime::Update( float fDelta ) void ScoreDisplayLifeTime::OnLoadSong() { - m_textTimeRemaining.PlayCommand( GAIN_LIFE_COMMAND_NAME ); + if( STATSMAN->m_CurStageStats.m_player[m_pPlayerState->m_PlayerNumber].bFailedEarlier ) + return; + + Course* pCourse = GAMESTATE->m_pCurCourse; + ASSERT( pCourse ); + const CourseEntry *pEntry = &pCourse->m_entries[GAMESTATE->GetCourseSongIndex()]; + + PlayGainLoss( GAIN_LIFE_COMMAND_NAME, pEntry->fGainSeconds ); } void ScoreDisplayLifeTime::OnSongEnded() @@ -98,12 +106,7 @@ void ScoreDisplayLifeTime::OnJudgment( TapNoteScore tns ) default: ASSERT(0); } - if( fMeterChange != 0 ) - { - CString s = ssprintf( fMeterChange>0 ? "%.0fms" : "-%.0fms",fMeterChange*1000); - m_textDeltaSeconds.SetText( s ); - m_textDeltaSeconds.PlayCommand( TapNoteScoreToString(tns) ); - } + PlayGainLoss( TapNoteScoreToString(tns), fMeterChange ); } void ScoreDisplayLifeTime::OnJudgment( HoldNoteScore hns, TapNoteScore tns ) @@ -119,12 +122,22 @@ void ScoreDisplayLifeTime::OnJudgment( HoldNoteScore hns, TapNoteScore tns ) default: ASSERT(0); } - if( fMeterChange != 0 ) + PlayGainLoss( HoldNoteScoreToString(hns), fMeterChange ); +} + +void ScoreDisplayLifeTime::PlayGainLoss( const CString &sCommand, float fDeltaLifeSecs ) +{ + if( fDeltaLifeSecs != 0 ) { - CString s = ssprintf( fMeterChange>0 ? "%.0fms" : "-%.0fms",fMeterChange*1000); + CString s; + if( fabs(fDeltaLifeSecs) >= 1 ) + s = ssprintf( fDeltaLifeSecs>0 ? "+%.0fsecs" : "-%.0fs",fDeltaLifeSecs); + else + s = ssprintf( fDeltaLifeSecs>0 ? "+%.0fms" : "-%.0fms",fDeltaLifeSecs*1000); m_textDeltaSeconds.SetText( s ); - m_textDeltaSeconds.PlayCommand( HoldNoteScoreToString(hns) ); + m_textDeltaSeconds.PlayCommand( sCommand ); } + } diff --git a/stepmania/src/ScoreDisplayLifeTime.h b/stepmania/src/ScoreDisplayLifeTime.h index fc11c04f7e..e6ca84d563 100644 --- a/stepmania/src/ScoreDisplayLifeTime.h +++ b/stepmania/src/ScoreDisplayLifeTime.h @@ -22,6 +22,8 @@ public: virtual void OnJudgment( HoldNoteScore score, TapNoteScore tscore ); protected: + void PlayGainLoss( const CString &sCommand, float fDeltaLifeSecs ); + AutoActor m_sprFrame; BitmapText m_textTimeRemaining; BitmapText m_textDeltaSeconds;