Improve DifficultyMeter abstraction, const fix

This commit is contained in:
Glenn Maynard
2003-11-13 23:50:52 +00:00
parent 4d503ffebc
commit 7998b340ce
2 changed files with 28 additions and 22 deletions
+22 -19
View File
@@ -32,12 +32,13 @@
DifficultyMeter::DifficultyMeter() DifficultyMeter::DifficultyMeter()
{ {
BitmapText::LoadFromTextureAndChars( THEME->GetPathToG("DifficultyMeter bar 2x1"), "10" ); m_Text.LoadFromTextureAndChars( THEME->GetPathToG("DifficultyMeter bar 2x1"), "10" );
this->AddChild( &m_Text );
Unset(); Unset();
} }
void DifficultyMeter::SetFromNotes( Steps* pNotes ) void DifficultyMeter::SetFromNotes( const Steps* pNotes )
{ {
if( pNotes == NULL ) if( pNotes == NULL )
{ {
@@ -46,10 +47,10 @@ void DifficultyMeter::SetFromNotes( Steps* pNotes )
} }
SetMeter( pNotes->GetMeter() ); SetMeter( pNotes->GetMeter() );
SetDiffuse( SONGMAN->GetDifficultyColor(pNotes->GetDifficulty()) ); m_Text.SetDiffuse( SONGMAN->GetDifficultyColor(pNotes->GetDifficulty()) );
} }
void DifficultyMeter::SetFromCourse( Course* pCourse ) void DifficultyMeter::SetFromCourse( const Course* pCourse )
{ {
if( pCourse == NULL ) if( pCourse == NULL )
{ {
@@ -57,26 +58,28 @@ void DifficultyMeter::SetFromCourse( Course* pCourse )
return; return;
} }
int meter = (int) roundf(pCourse->GetMeter()); const int meter = (int) roundf(pCourse->GetMeter());
SetMeter( meter ); SetMeter( meter );
// XXX // XXX
if(meter <= 1 ) RageColor c;
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_BEGINNER) ); if( meter <= 1 )
else if(meter <= 2 ) c = SONGMAN->GetDifficultyColor( DIFFICULTY_BEGINNER );
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_EASY) ); else if( meter <= 2 )
else if(meter <= 5 ) c = SONGMAN->GetDifficultyColor( DIFFICULTY_EASY );
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_MEDIUM) ); else if( meter <= 5 )
else if(meter <= 7 ) c = SONGMAN->GetDifficultyColor( DIFFICULTY_MEDIUM );
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_HARD) ); else if( meter <= 7 )
c = SONGMAN->GetDifficultyColor( DIFFICULTY_HARD );
else else
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_CHALLENGE) ); c = SONGMAN->GetDifficultyColor( DIFFICULTY_CHALLENGE );
m_Text.SetDiffuse( c );
} }
void DifficultyMeter::Unset() void DifficultyMeter::Unset()
{ {
this->SetEffectNone(); m_Text.SetEffectNone();
SetDiffuse( RageColor(0.8f,0.8f,0.8f,1) ); m_Text.SetDiffuse( RageColor(0.8f,0.8f,0.8f,1) );
SetMeter( 0 ); SetMeter( 0 );
} }
@@ -100,10 +103,10 @@ void DifficultyMeter::SetMeter( int iMeter )
if( f<iMeter ) if( f<iMeter )
sNewText += "1"; sNewText += "1";
SetText( sNewText ); m_Text.SetText( sNewText );
if( iMeter > GLOW_IF_METER_GREATER_THAN ) if( iMeter > GLOW_IF_METER_GREATER_THAN )
this->SetEffectGlowShift(); m_Text.SetEffectGlowShift();
else else
this->SetEffectNone(); m_Text.SetEffectNone();
} }
+6 -3
View File
@@ -13,22 +13,25 @@
#include "BitmapText.h" #include "BitmapText.h"
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include "ActorFrame.h"
class Steps; class Steps;
class Course; class Course;
class DifficultyMeter : public BitmapText class DifficultyMeter: public ActorFrame
{ {
public: public:
DifficultyMeter(); DifficultyMeter();
void SetFromGameState( PlayerNumber pn ); void SetFromGameState( PlayerNumber pn );
void SetFromNotes( Steps* pNotes ); void SetFromNotes( const Steps* pNotes );
void SetFromCourse( Course* pCourse ); void SetFromCourse( const Course* pCourse );
void Unset(); void Unset();
private: private:
void SetMeter( int iMeter ); void SetMeter( int iMeter );
BitmapText m_Text;
}; };
#endif #endif