preload commands

This commit is contained in:
Chris Danford
2005-02-23 23:04:06 +00:00
parent 2da21b16d4
commit f395d0a401
4 changed files with 48 additions and 29 deletions
+5
View File
@@ -353,6 +353,11 @@ void ActorUtil::RunCommand( Actor& actor, const CString &sType, const CString &s
actor.RunCommands( THEME->GetMetricA(sType,actor.GetID()+sCommandName+"Command") ); actor.RunCommands( THEME->GetMetricA(sType,actor.GetID()+sCommandName+"Command") );
} }
void ActorUtil::LoadCommand( Actor& actor, const CString &sType, const CString &sCommandName )
{
actor.AddCommand( sCommandName, THEME->GetMetricA(sType,actor.GetID()+sCommandName+"Command") );
}
/* /*
* (c) 2003-2004 Chris Danford * (c) 2003-2004 Chris Danford
* All rights reserved. * All rights reserved.
+1
View File
@@ -34,6 +34,7 @@ namespace ActorUtil
inline void SetXY( Actor* pActor, const CString &sType ) { SetXY( *pActor, sType ); } inline void SetXY( Actor* pActor, const CString &sType ) { SetXY( *pActor, sType ); }
void RunCommand( Actor& actor, const CString &sType, const CString &sCommandName ); void RunCommand( Actor& actor, const CString &sType, const CString &sCommandName );
void LoadCommand( Actor& actor, const CString &sType, const CString &sCommandName );
inline void OnCommand( Actor& actor, const CString &sType ) { RunCommand( actor, sType, "On" ); } inline void OnCommand( Actor& actor, const CString &sType ) { RunCommand( actor, sType, "On" ); }
inline void OffCommand( Actor& actor, const CString &sType ) { RunCommand( actor, sType, "Off" ); } inline void OffCommand( Actor& actor, const CString &sType ) { RunCommand( actor, sType, "Off" ); }
+40 -26
View File
@@ -21,6 +21,10 @@ DifficultyMeter::DifficultyMeter()
{ {
} }
static CString GetDifficultyCommandName( Difficulty d ) { return "Set"+DifficultyToString(d); }
static CString GetCourseDifficultyCommandName( CourseDifficulty d ) { return "Set"+CourseDifficultyToString(d)+"Course"; }
static const CString DIFFICULTY_COMMAND_NAME_NONE = "None";
/* sID experiment: /* sID experiment:
* *
* Names of an actor, "Foo": * Names of an actor, "Foo":
@@ -45,20 +49,18 @@ DifficultyMeter::DifficultyMeter()
void DifficultyMeter::Load( const CString &sType ) void DifficultyMeter::Load( const CString &sType )
{ {
m_sType = sType;
/* We can't use global ThemeMetric<CString>s, because we can have multiple /* We can't use global ThemeMetric<CString>s, because we can have multiple
* DifficultyMeters on screen at once, with different names. */ * DifficultyMeters on screen at once, with different names. */
m_iNumFeetInMeter = THEME->GetMetricI(m_sType,"NumFeetInMeter"); m_iNumFeetInMeter = THEME->GetMetricI(sType,"NumFeetInMeter");
m_iMaxFeetInMeter = THEME->GetMetricI(m_sType,"MaxFeetInMeter"); m_iMaxFeetInMeter = THEME->GetMetricI(sType,"MaxFeetInMeter");
m_iGlowIfMeterGreaterThan = THEME->GetMetricI(m_sType,"GlowIfMeterGreaterThan"); m_iGlowIfMeterGreaterThan = THEME->GetMetricI(sType,"GlowIfMeterGreaterThan");
m_bShowFeet = THEME->GetMetricB(m_sType,"ShowFeet"); m_bShowFeet = THEME->GetMetricB(sType,"ShowFeet");
/* "easy", "hard" */ /* "easy", "hard" */
m_bShowDifficulty = THEME->GetMetricB(m_sType,"ShowDifficulty"); m_bShowDifficulty = THEME->GetMetricB(sType,"ShowDifficulty");
/* 3, 9 */ /* 3, 9 */
m_bShowMeter = THEME->GetMetricB(m_sType,"ShowMeter"); m_bShowMeter = THEME->GetMetricB(sType,"ShowMeter");
m_bFeetIsDifficultyColor = THEME->GetMetricB(m_sType,"FeetIsDifficultyColor"); m_bFeetIsDifficultyColor = THEME->GetMetricB(sType,"FeetIsDifficultyColor");
m_bFeetPerDifficulty = THEME->GetMetricB(m_sType,"FeetPerDifficulty"); m_bFeetPerDifficulty = THEME->GetMetricB(sType,"FeetPerDifficulty");
if( m_bShowFeet ) if( m_bShowFeet )
{ {
@@ -72,25 +74,37 @@ void DifficultyMeter::Load( const CString &sType )
} }
else else
Feet = "0X"; Feet = "0X";
m_textFeet.LoadFromTextureAndChars( THEME->GetPathG(m_sType,"bar"), Feet ); m_textFeet.LoadFromTextureAndChars( THEME->GetPathG(sType,"bar"), Feet );
ActorUtil::SetXYAndOnCommand( m_textFeet, m_sType ); ActorUtil::SetXYAndOnCommand( m_textFeet, sType );
this->AddChild( &m_textFeet ); this->AddChild( &m_textFeet );
} }
if( m_bShowDifficulty ) if( m_bShowDifficulty )
{ {
m_Difficulty.Load( THEME->GetPathG(m_sType,"difficulty") ); m_Difficulty.Load( THEME->GetPathG(sType,"difficulty") );
m_Difficulty->SetName( "Difficulty" ); m_Difficulty->SetName( "Difficulty" );
ActorUtil::SetXYAndOnCommand( m_Difficulty, m_sType ); ActorUtil::SetXYAndOnCommand( m_Difficulty, sType );
this->AddChild( m_Difficulty ); this->AddChild( m_Difficulty );
FOREACH_Difficulty( d )
ActorUtil::LoadCommand( *m_Difficulty, sType, GetDifficultyCommandName(d) );
FOREACH_CourseDifficulty( d )
ActorUtil::LoadCommand( *m_Difficulty, sType, GetCourseDifficultyCommandName(d) );
ActorUtil::LoadCommand( *m_Difficulty, sType, DIFFICULTY_COMMAND_NAME_NONE );
} }
if( m_bShowMeter ) if( m_bShowMeter )
{ {
m_textMeter.SetName( "Meter" ); m_textMeter.SetName( "Meter" );
m_textMeter.LoadFromFont( THEME->GetPathF(m_sType,"meter") ); m_textMeter.LoadFromFont( THEME->GetPathF(sType,"meter") );
ActorUtil::SetXYAndOnCommand( m_textMeter, m_sType ); ActorUtil::SetXYAndOnCommand( m_textMeter, sType );
this->AddChild( &m_textMeter ); this->AddChild( &m_textMeter );
FOREACH_Difficulty( d )
ActorUtil::LoadCommand( m_textMeter, sType, GetDifficultyCommandName(d) );
FOREACH_CourseDifficulty( d )
ActorUtil::LoadCommand( m_textMeter, sType, GetCourseDifficultyCommandName(d) );
ActorUtil::LoadCommand( m_textMeter, sType, DIFFICULTY_COMMAND_NAME_NONE );
} }
Unset(); Unset();
@@ -125,7 +139,7 @@ void DifficultyMeter::SetFromSteps( const Steps* pSteps )
} }
SetFromMeterAndDifficulty( pSteps->GetMeter(), pSteps->GetDifficulty() ); SetFromMeterAndDifficulty( pSteps->GetMeter(), pSteps->GetDifficulty() );
SetDifficulty( DifficultyToString( pSteps->GetDifficulty() ) ); PlayDifficultyCommand( GetDifficultyCommandName( pSteps->GetDifficulty() ) );
} }
void DifficultyMeter::SetFromTrail( const Trail* pTrail ) void DifficultyMeter::SetFromTrail( const Trail* pTrail )
@@ -137,25 +151,25 @@ void DifficultyMeter::SetFromTrail( const Trail* pTrail )
} }
SetFromMeterAndDifficulty( pTrail->GetMeter(), pTrail->m_CourseDifficulty ); SetFromMeterAndDifficulty( pTrail->GetMeter(), pTrail->m_CourseDifficulty );
SetDifficulty( CourseDifficultyToString(pTrail->m_CourseDifficulty) + "Course" ); PlayDifficultyCommand( GetCourseDifficultyCommandName( pTrail->m_CourseDifficulty ) );
} }
void DifficultyMeter::Unset() void DifficultyMeter::Unset()
{ {
SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER );
SetDifficulty( "None" ); PlayDifficultyCommand( DIFFICULTY_COMMAND_NAME_NONE );
} }
void DifficultyMeter::SetFromDifficulty( Difficulty dc ) void DifficultyMeter::SetFromDifficulty( Difficulty dc )
{ {
SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER );
SetDifficulty( DifficultyToString( dc ) ); PlayDifficultyCommand( GetDifficultyCommandName( dc ) );
} }
void DifficultyMeter::SetFromCourseDifficulty( CourseDifficulty cd ) void DifficultyMeter::SetFromCourseDifficulty( CourseDifficulty cd )
{ {
SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER );
SetDifficulty( CourseDifficultyToString( cd ) + "Course" ); PlayDifficultyCommand( GetCourseDifficultyCommandName( cd ) );
} }
void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc ) void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc )
@@ -198,16 +212,16 @@ void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc )
} }
} }
void DifficultyMeter::SetDifficulty( CString diff ) void DifficultyMeter::PlayDifficultyCommand( CString sDifficultyCommand )
{ {
if( m_CurDifficulty == diff ) if( m_sCurDifficultyCommand == sDifficultyCommand )
return; return;
m_CurDifficulty = diff; m_sCurDifficultyCommand = sDifficultyCommand;
if( m_bShowDifficulty ) if( m_bShowDifficulty )
ActorUtil::RunCommand( m_Difficulty, m_sType, "Set" + Capitalize(diff) ); m_Difficulty->PlayCommand( sDifficultyCommand );
if( m_bShowMeter ) if( m_bShowMeter )
ActorUtil::RunCommand( m_textMeter, m_sType, "Set" + Capitalize(diff) ); m_textMeter.PlayCommand( sDifficultyCommand );
} }
/* /*
+2 -3
View File
@@ -62,12 +62,11 @@ private:
void SetFromDifficulty( Difficulty dc ); void SetFromDifficulty( Difficulty dc );
void SetFromCourseDifficulty( CourseDifficulty cd ); void SetFromCourseDifficulty( CourseDifficulty cd );
CString m_sType; void PlayDifficultyCommand( CString diff );
void SetDifficulty( CString diff );
BitmapText m_textFeet; BitmapText m_textFeet;
CString m_CurDifficulty; CString m_sCurDifficultyCommand;
AutoActor m_Difficulty; AutoActor m_Difficulty;
BitmapText m_textMeter; BitmapText m_textMeter;