diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index ca624e7a1d..6fa63fa4b0 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -353,6 +353,11 @@ void ActorUtil::RunCommand( Actor& actor, const CString &sType, const CString &s 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 * All rights reserved. diff --git a/stepmania/src/ActorUtil.h b/stepmania/src/ActorUtil.h index bba4c4f890..39d007c3d8 100644 --- a/stepmania/src/ActorUtil.h +++ b/stepmania/src/ActorUtil.h @@ -34,6 +34,7 @@ namespace ActorUtil inline void SetXY( Actor* pActor, const CString &sType ) { SetXY( *pActor, sType ); } 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 OffCommand( Actor& actor, const CString &sType ) { RunCommand( actor, sType, "Off" ); } diff --git a/stepmania/src/DifficultyMeter.cpp b/stepmania/src/DifficultyMeter.cpp index b3cb411605..d2199266ad 100644 --- a/stepmania/src/DifficultyMeter.cpp +++ b/stepmania/src/DifficultyMeter.cpp @@ -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: * * Names of an actor, "Foo": @@ -45,20 +49,18 @@ DifficultyMeter::DifficultyMeter() void DifficultyMeter::Load( const CString &sType ) { - m_sType = sType; - /* We can't use global ThemeMetrics, because we can have multiple * DifficultyMeters on screen at once, with different names. */ - m_iNumFeetInMeter = THEME->GetMetricI(m_sType,"NumFeetInMeter"); - m_iMaxFeetInMeter = THEME->GetMetricI(m_sType,"MaxFeetInMeter"); - m_iGlowIfMeterGreaterThan = THEME->GetMetricI(m_sType,"GlowIfMeterGreaterThan"); - m_bShowFeet = THEME->GetMetricB(m_sType,"ShowFeet"); + m_iNumFeetInMeter = THEME->GetMetricI(sType,"NumFeetInMeter"); + m_iMaxFeetInMeter = THEME->GetMetricI(sType,"MaxFeetInMeter"); + m_iGlowIfMeterGreaterThan = THEME->GetMetricI(sType,"GlowIfMeterGreaterThan"); + m_bShowFeet = THEME->GetMetricB(sType,"ShowFeet"); /* "easy", "hard" */ - m_bShowDifficulty = THEME->GetMetricB(m_sType,"ShowDifficulty"); + m_bShowDifficulty = THEME->GetMetricB(sType,"ShowDifficulty"); /* 3, 9 */ - m_bShowMeter = THEME->GetMetricB(m_sType,"ShowMeter"); - m_bFeetIsDifficultyColor = THEME->GetMetricB(m_sType,"FeetIsDifficultyColor"); - m_bFeetPerDifficulty = THEME->GetMetricB(m_sType,"FeetPerDifficulty"); + m_bShowMeter = THEME->GetMetricB(sType,"ShowMeter"); + m_bFeetIsDifficultyColor = THEME->GetMetricB(sType,"FeetIsDifficultyColor"); + m_bFeetPerDifficulty = THEME->GetMetricB(sType,"FeetPerDifficulty"); if( m_bShowFeet ) { @@ -72,25 +74,37 @@ void DifficultyMeter::Load( const CString &sType ) } else Feet = "0X"; - m_textFeet.LoadFromTextureAndChars( THEME->GetPathG(m_sType,"bar"), Feet ); - ActorUtil::SetXYAndOnCommand( m_textFeet, m_sType ); + m_textFeet.LoadFromTextureAndChars( THEME->GetPathG(sType,"bar"), Feet ); + ActorUtil::SetXYAndOnCommand( m_textFeet, sType ); this->AddChild( &m_textFeet ); } if( m_bShowDifficulty ) { - m_Difficulty.Load( THEME->GetPathG(m_sType,"difficulty") ); + m_Difficulty.Load( THEME->GetPathG(sType,"difficulty") ); m_Difficulty->SetName( "Difficulty" ); - ActorUtil::SetXYAndOnCommand( m_Difficulty, m_sType ); + ActorUtil::SetXYAndOnCommand( m_Difficulty, sType ); 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 ) { m_textMeter.SetName( "Meter" ); - m_textMeter.LoadFromFont( THEME->GetPathF(m_sType,"meter") ); - ActorUtil::SetXYAndOnCommand( m_textMeter, m_sType ); + m_textMeter.LoadFromFont( THEME->GetPathF(sType,"meter") ); + ActorUtil::SetXYAndOnCommand( m_textMeter, sType ); 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(); @@ -125,7 +139,7 @@ void DifficultyMeter::SetFromSteps( const Steps* pSteps ) } SetFromMeterAndDifficulty( pSteps->GetMeter(), pSteps->GetDifficulty() ); - SetDifficulty( DifficultyToString( pSteps->GetDifficulty() ) ); + PlayDifficultyCommand( GetDifficultyCommandName( pSteps->GetDifficulty() ) ); } void DifficultyMeter::SetFromTrail( const Trail* pTrail ) @@ -137,25 +151,25 @@ void DifficultyMeter::SetFromTrail( const Trail* pTrail ) } SetFromMeterAndDifficulty( pTrail->GetMeter(), pTrail->m_CourseDifficulty ); - SetDifficulty( CourseDifficultyToString(pTrail->m_CourseDifficulty) + "Course" ); + PlayDifficultyCommand( GetCourseDifficultyCommandName( pTrail->m_CourseDifficulty ) ); } void DifficultyMeter::Unset() { SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); - SetDifficulty( "None" ); + PlayDifficultyCommand( DIFFICULTY_COMMAND_NAME_NONE ); } void DifficultyMeter::SetFromDifficulty( Difficulty dc ) { SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); - SetDifficulty( DifficultyToString( dc ) ); + PlayDifficultyCommand( GetDifficultyCommandName( dc ) ); } void DifficultyMeter::SetFromCourseDifficulty( CourseDifficulty cd ) { SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); - SetDifficulty( CourseDifficultyToString( cd ) + "Course" ); + PlayDifficultyCommand( GetCourseDifficultyCommandName( cd ) ); } 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; - m_CurDifficulty = diff; + m_sCurDifficultyCommand = sDifficultyCommand; if( m_bShowDifficulty ) - ActorUtil::RunCommand( m_Difficulty, m_sType, "Set" + Capitalize(diff) ); + m_Difficulty->PlayCommand( sDifficultyCommand ); if( m_bShowMeter ) - ActorUtil::RunCommand( m_textMeter, m_sType, "Set" + Capitalize(diff) ); + m_textMeter.PlayCommand( sDifficultyCommand ); } /* diff --git a/stepmania/src/DifficultyMeter.h b/stepmania/src/DifficultyMeter.h index 5eb40b0a3f..007fade1ed 100644 --- a/stepmania/src/DifficultyMeter.h +++ b/stepmania/src/DifficultyMeter.h @@ -62,12 +62,11 @@ private: void SetFromDifficulty( Difficulty dc ); void SetFromCourseDifficulty( CourseDifficulty cd ); - CString m_sType; + void PlayDifficultyCommand( CString diff ); - void SetDifficulty( CString diff ); BitmapText m_textFeet; - CString m_CurDifficulty; + CString m_sCurDifficultyCommand; AutoActor m_Difficulty; BitmapText m_textMeter;