From 133344a15f75ea70961f9b712ace7a7951c9cc70 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 9 Nov 2006 04:58:03 +0000 Subject: [PATCH] try to simplify this UpdateNonstopLifebar stuff (which seems to have nothing to do with Nonstop). This stuff is very tweaky and should probably be broken out into Lua or something. --- stepmania/src/LifeMeter.h | 2 +- stepmania/src/LifeMeterBar.cpp | 24 +++++++++++++++++++++++- stepmania/src/LifeMeterBar.h | 2 +- stepmania/src/LifeMeterBattery.h | 1 - stepmania/src/LifeMeterTime.h | 1 - stepmania/src/ScreenGameplay.cpp | 21 ++------------------- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/stepmania/src/LifeMeter.h b/stepmania/src/LifeMeter.h index 75bffd69db..c359d89e01 100644 --- a/stepmania/src/LifeMeter.h +++ b/stepmania/src/LifeMeter.h @@ -33,7 +33,7 @@ public: virtual bool IsHot() const = 0; virtual bool IsFailing() const = 0; virtual float GetLife() const { return 0; } // for cosmetic use only - virtual void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty) = 0; + virtual void UpdateNonstopLifebar() { } static LifeMeter *MakeLifeMeter( SongOptions::LifeType t ); diff --git a/stepmania/src/LifeMeterBar.cpp b/stepmania/src/LifeMeterBar.cpp index d900458a5f..c684db55c7 100644 --- a/stepmania/src/LifeMeterBar.cpp +++ b/stepmania/src/LifeMeterBar.cpp @@ -329,8 +329,30 @@ void LifeMeterBar::DrawPrimitives() ActorFrame::DrawPrimitives(); } #include "RageLog.h" -void LifeMeterBar::UpdateNonstopLifebar( const int cleared, const int total, int ProgressiveLifebarDifficulty ) +#include "Course.h" +void LifeMeterBar::UpdateNonstopLifebar() { + int cleared, total, ProgressiveLifebarDifficulty; + + switch( GAMESTATE->m_PlayMode ) + { + case PLAY_MODE_REGULAR: + if( GAMESTATE->IsEventMode() || GAMESTATE->m_bDemonstrationOrJukebox ) + return; + + cleared = GAMESTATE->GetStageIndex(); + total = PREFSMAN->m_iSongsPerPlay; + ProgressiveLifebarDifficulty = PREFSMAN->m_iProgressiveStageLifebar; + break; + case PLAY_MODE_NONSTOP: + cleared = GAMESTATE->GetCourseSongIndex(); + total = GAMESTATE->m_pCurCourse->GetEstimatedNumStages(); + ProgressiveLifebarDifficulty = PREFSMAN->m_iProgressiveNonstopLifebar; + break; + default: + return; + } + // if (cleared > total) cleared = total; // clear/total <= 1 // if (total == 0) total = 1; // no division by 0 diff --git a/stepmania/src/LifeMeterBar.h b/stepmania/src/LifeMeterBar.h index 3bf8fa640d..e3f05159c1 100644 --- a/stepmania/src/LifeMeterBar.h +++ b/stepmania/src/LifeMeterBar.h @@ -30,7 +30,7 @@ public: virtual bool IsFailing() const; virtual float GetLife() const { return m_fLifePercentage; } - void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty); + void UpdateNonstopLifebar(); void FillForHowToPlay(int NumT2s, int NumMisses); // this function is solely for HowToPlay diff --git a/stepmania/src/LifeMeterBattery.h b/stepmania/src/LifeMeterBattery.h index 750d6a52b8..edc1bdc960 100644 --- a/stepmania/src/LifeMeterBattery.h +++ b/stepmania/src/LifeMeterBattery.h @@ -28,7 +28,6 @@ public: virtual bool IsHot() const; virtual bool IsFailing() const; virtual float GetLife() const; - virtual void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty) { }; void Refresh(); diff --git a/stepmania/src/LifeMeterTime.h b/stepmania/src/LifeMeterTime.h index d4d3860ede..0706654212 100644 --- a/stepmania/src/LifeMeterTime.h +++ b/stepmania/src/LifeMeterTime.h @@ -30,7 +30,6 @@ public: virtual bool IsHot() const; virtual bool IsFailing() const; virtual float GetLife() const; - virtual void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty) { }; private: float GetLifeSeconds() const; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 34df374359..76c38a68d0 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -1086,25 +1086,8 @@ void ScreenGameplay::LoadNextSong() if( GAMESTATE->m_SongOptions.GetCurrent().m_LifeType==SongOptions::LIFE_BATTERY && pi->GetPlayerStageStats()->bFailed ) // already failed pi->ShowOniGameOver(); - if( GAMESTATE->m_SongOptions.GetCurrent().m_LifeType==SongOptions::LIFE_BAR && - GAMESTATE->m_PlayMode == PLAY_MODE_REGULAR && - !GAMESTATE->IsEventMode() && - !GAMESTATE->m_bDemonstrationOrJukebox ) - { - if( pi->m_pLifeMeter ) - pi->m_pLifeMeter->UpdateNonstopLifebar( - GAMESTATE->GetStageIndex(), - PREFSMAN->m_iSongsPerPlay, - PREFSMAN->m_iProgressiveStageLifebar); - } - if( GAMESTATE->m_SongOptions.GetCurrent().m_LifeType==SongOptions::LIFE_BAR && GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP ) - { - if( pi->m_pLifeMeter ) - pi->m_pLifeMeter->UpdateNonstopLifebar( - GAMESTATE->GetCourseSongIndex(), - GAMESTATE->m_pCurCourse->GetEstimatedNumStages(), - PREFSMAN->m_iProgressiveNonstopLifebar); - } + if( GAMESTATE->m_SongOptions.GetCurrent().m_LifeType==SongOptions::LIFE_BAR && pi->m_pLifeMeter ) + pi->m_pLifeMeter->UpdateNonstopLifebar(); if( pi->m_pDifficultyIcon ) pi->m_pDifficultyIcon->SetFromSteps( pi->GetStepsAndTrailIndex(), pSteps );