From 00d42525bbf82890389c5159f5a4191a0ba41c2c Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 21 Jul 2003 22:38:41 +0000 Subject: [PATCH] add course meter --- stepmania/src/DifficultyMeter.cpp | 67 +++++++++++++++++++++++------ stepmania/src/DifficultyMeter.h | 7 ++- stepmania/src/ScreenSelectMusic.cpp | 2 +- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/stepmania/src/DifficultyMeter.cpp b/stepmania/src/DifficultyMeter.cpp index 3be0573792..ee363ed53f 100644 --- a/stepmania/src/DifficultyMeter.cpp +++ b/stepmania/src/DifficultyMeter.cpp @@ -13,9 +13,11 @@ #include "DifficultyMeter.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" +#include "GameState.h" #include "PrefsManager.h" #include "ThemeManager.h" #include "Notes.h" +#include "Course.h" #include "SongManager.h" @@ -28,28 +30,60 @@ DifficultyMeter::DifficultyMeter() { BitmapText::LoadFromTextureAndChars( THEME->GetPathToG("DifficultyMeter bar 2x1"), "10" ); - SetFromNotes( NULL ); + Unset(); } void DifficultyMeter::SetFromNotes( Notes* pNotes ) { - if( pNotes != NULL ) + if( pNotes == NULL ) { - SetDiffuse( RageColor(1,1,1,1) ); - SetMeter( pNotes->GetMeter() ); - if( pNotes->GetMeter() > GLOW_IF_METER_GREATER_THAN ) - this->SetEffectGlowShift(); - else - this->SetEffectNone(); + Unset(); + return; + } - SetDiffuse( SONGMAN->GetDifficultyColor(pNotes->GetDifficulty()) ); - } - else + SetMeter( pNotes->GetMeter() ); + SetDiffuse( SONGMAN->GetDifficultyColor(pNotes->GetDifficulty()) ); +} + +void DifficultyMeter::SetFromCourse( Course* pCourse ) +{ + if( pCourse == NULL ) { - this->SetEffectNone(); - SetDiffuse( RageColor(0.8f,0.8f,0.8f,1) ); - SetMeter( 0 ); + Unset(); + return; } + + int meter = pCourse->GetMeter(); + SetMeter( meter ); + + // XXX + if(meter <= 1 ) + SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_BEGINNER) ); + else if(meter <= 2 ) + SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_EASY) ); + else if(meter <= 5 ) + SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_MEDIUM) ); + else if(meter <= 7 ) + SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_HARD) ); + else + SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_CHALLENGE) ); +} + +void DifficultyMeter::Unset() +{ + this->SetEffectNone(); + SetDiffuse( RageColor(0.8f,0.8f,0.8f,1) ); + SetMeter( 0 ); +} + +void DifficultyMeter::SetFromGameState( PlayerNumber pn ) +{ + if( GAMESTATE->m_pCurNotes[pn] ) + SetFromNotes( GAMESTATE->m_pCurNotes[pn] ); + else if( GAMESTATE->m_pCurCourse ) + SetFromCourse( GAMESTATE->m_pCurCourse ); + else + Unset(); } void DifficultyMeter::SetMeter( int iMeter ) @@ -63,4 +97,9 @@ void DifficultyMeter::SetMeter( int iMeter ) sNewText += "1"; SetText( sNewText ); + + if( iMeter > GLOW_IF_METER_GREATER_THAN ) + this->SetEffectGlowShift(); + else + this->SetEffectNone(); } diff --git a/stepmania/src/DifficultyMeter.h b/stepmania/src/DifficultyMeter.h index 6e2a0e1acf..527224a06f 100644 --- a/stepmania/src/DifficultyMeter.h +++ b/stepmania/src/DifficultyMeter.h @@ -12,7 +12,9 @@ */ #include "BitmapText.h" +#include "PlayerNumber.h" class Notes; +class Course; class DifficultyMeter : public BitmapText @@ -20,10 +22,13 @@ class DifficultyMeter : public BitmapText public: DifficultyMeter(); + void SetFromGameState( PlayerNumber pn ); void SetFromNotes( Notes* pNotes ); - void SetMeter( int iMeter ); + void SetFromCourse( Course* pCourse ); + void Unset(); private: + void SetMeter( int iMeter ); }; #endif diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index b8f9c27efd..ae3665f101 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -908,7 +908,7 @@ void ScreenSelectMusic::AfterNotesChange( PlayerNumber pn ) m_AutoGenIcon[pn].SetEffectNone(); m_AutoGenIcon[pn].SetDiffuse( RageColor(1,1,1,0) ); } - m_DifficultyMeter[pn].SetFromNotes( pNotes ); + m_DifficultyMeter[pn].SetFromGameState( pn ); m_GrooveRadar.SetFromNotes( pn, pNotes ); m_MusicWheel.NotesChanged( pn ); }