Don't set two different names for an element. Instead, pass the metrics group name as a parameter to Load()

This commit is contained in:
Chris Danford
2005-02-16 23:03:01 +00:00
parent 21e59e065e
commit 533e83ed00
8 changed files with 34 additions and 31 deletions
+6 -1
View File
@@ -110,7 +110,7 @@ void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
sCmdName="on"; sCmdName="on";
else else
sCmdName = sKeyName.Left( sKeyName.size()-7 ); sCmdName = sKeyName.Left( sKeyName.size()-7 );
m_mapNameToCommands[sCmdName] = apac; AddCommand( sCmdName, apac );
} }
} }
@@ -989,6 +989,11 @@ void Actor::QueueCommand( const CString& sCommandName )
DestTweenState().sCommandName = sCommandName; DestTweenState().sCommandName = sCommandName;
} }
void Actor::AddCommand( const CString &sCmdName, apActorCommands apac )
{
m_mapNameToCommands[sCmdName] = apac;
}
void Actor::PlayCommand( const CString &sCommandName ) void Actor::PlayCommand( const CString &sCommandName )
{ {
CString sKey = sCommandName; CString sKey = sCommandName;
+1
View File
@@ -308,6 +308,7 @@ public:
// Commands // Commands
// //
virtual void PushSelf( lua_State *L ); virtual void PushSelf( lua_State *L );
void AddCommand( const CString &sCmdName, apActorCommands apac );
virtual void PlayCommand( const CString &sCommandName ); virtual void PlayCommand( const CString &sCommandName );
virtual void RunCommands( const ActorCommands& cmds ); virtual void RunCommands( const ActorCommands& cmds );
void RunCommands( const apActorCommands& cmds ) { this->RunCommands( *cmds ); } // convenience void RunCommands( const apActorCommands& cmds ) { this->RunCommands( *cmds ); } // convenience
+1 -2
View File
@@ -53,8 +53,7 @@ void LifeMeterBattery::Load( PlayerNumber pn )
if( bPlayerEnabled ) if( bPlayerEnabled )
{ {
m_Percent.SetName( "LifeMeterBattery Percent" ); m_Percent.Load( pn, &STATSMAN->m_CurStageStats.m_player[pn], "LifeMeterBattery Percent", true );
m_Percent.Load( pn, &STATSMAN->m_CurStageStats.m_player[pn], true );
this->AddChild( &m_Percent ); this->AddChild( &m_Percent );
} }
+15 -18
View File
@@ -14,38 +14,35 @@ PercentageDisplay::PercentageDisplay()
m_pSource = NULL; m_pSource = NULL;
} }
void PercentageDisplay::SetName( const CString &sName, const CString &sID ) void PercentageDisplay::Load( PlayerNumber pn, PlayerStageStats* pSource, const CString &sMetricsGroup, bool bAutoRefresh )
{ {
ActorFrame::SetName( sName, sID );
DANCE_POINT_DIGITS.Load( m_sName, "DancePointsDigits" );
PERCENT_DECIMAL_PLACES.Load( m_sName, "PercentDecimalPlaces" );
PERCENT_TOTAL_SIZE.Load( m_sName, "PercentTotalSize" );
PERCENT_USE_REMAINDER.Load( m_sName, "PercentUseRemainder" );
}
void PercentageDisplay::Load( PlayerNumber pn, PlayerStageStats* pSource, bool bAutoRefresh )
{
ASSERT( m_sName != "" ); // set this!
m_PlayerNumber = pn; m_PlayerNumber = pn;
m_pSource = pSource; m_pSource = pSource;
m_bAutoRefresh = bAutoRefresh; m_bAutoRefresh = bAutoRefresh;
m_Last = -1; m_Last = -1;
DANCE_POINT_DIGITS.Load( sMetricsGroup, "DancePointsDigits" );
PERCENT_DECIMAL_PLACES.Load( sMetricsGroup, "PercentDecimalPlaces" );
PERCENT_TOTAL_SIZE.Load( sMetricsGroup, "PercentTotalSize" );
PERCENT_USE_REMAINDER.Load( sMetricsGroup, "PercentUseRemainder" );
if( PREFSMAN->m_bDancePointsForOni ) if( PREFSMAN->m_bDancePointsForOni )
m_textPercent.SetName( ssprintf("DancePointsP%i", pn+1) ); m_textPercent.SetName( ssprintf("DancePointsP%i", pn+1) );
else else
m_textPercent.SetName( ssprintf("PercentP%i", pn+1) ); m_textPercent.SetName( ssprintf("PercentP%i", pn+1) );
m_textPercent.LoadFromFont( THEME->GetPathF(m_sName,"text") ); m_textPercent.LoadFromFont( THEME->GetPathF(sMetricsGroup,"text") );
SET_XY_AND_ON_COMMAND( m_textPercent ); ActorUtil::SetXYAndOnCommand( m_textPercent, sMetricsGroup );
m_textPercent.AddCommand( "Off", THEME->GetMetricA(sMetricsGroup, m_textPercent.GetName()+"OffCommand") );
this->AddChild( &m_textPercent ); this->AddChild( &m_textPercent );
if( !PREFSMAN->m_bDancePointsForOni && (bool)PERCENT_USE_REMAINDER ) if( !PREFSMAN->m_bDancePointsForOni && (bool)PERCENT_USE_REMAINDER )
{ {
m_textPercentRemainder.SetName( ssprintf("PercentRemainderP%d",pn+1) ); m_textPercentRemainder.SetName( ssprintf("PercentRemainderP%d",pn+1) );
m_textPercentRemainder.LoadFromFont( THEME->GetPathF(m_sName,"remainder") ); m_textPercentRemainder.LoadFromFont( THEME->GetPathF(sMetricsGroup,"remainder") );
SET_XY_AND_ON_COMMAND( m_textPercentRemainder ); ActorUtil::SetXYAndOnCommand( m_textPercentRemainder, sMetricsGroup );
m_textPercentRemainder.AddCommand( "Off", THEME->GetMetricA(sMetricsGroup, m_textPercentRemainder.GetName()+"OffCommand") );
m_textPercentRemainder.SetText( "456" ); m_textPercentRemainder.SetText( "456" );
this->AddChild( &m_textPercentRemainder ); this->AddChild( &m_textPercentRemainder );
} }
@@ -55,9 +52,9 @@ void PercentageDisplay::Load( PlayerNumber pn, PlayerStageStats* pSource, bool b
void PercentageDisplay::TweenOffScreen() void PercentageDisplay::TweenOffScreen()
{ {
OFF_COMMAND( m_textPercent ); m_textPercent.PlayCommand( "Off" );
if( !PREFSMAN->m_bDancePointsForOni && (bool)PERCENT_USE_REMAINDER ) if( !PREFSMAN->m_bDancePointsForOni && (bool)PERCENT_USE_REMAINDER )
OFF_COMMAND( m_textPercentRemainder ); m_textPercentRemainder.PlayCommand( "Off" );
} }
void PercentageDisplay::Update( float fDeltaTime ) void PercentageDisplay::Update( float fDeltaTime )
+1 -2
View File
@@ -13,9 +13,8 @@ class PercentageDisplay: public ActorFrame
{ {
public: public:
PercentageDisplay(); PercentageDisplay();
void Load( PlayerNumber pn, PlayerStageStats *pSource, bool bAutoRefresh ); void Load( PlayerNumber pn, PlayerStageStats *pSource, const CString &sMetricsGroup, bool bAutoRefresh );
void Update( float fDeltaTime ); void Update( float fDeltaTime );
void SetName( const CString &sName, const CString &sID = "" );
void TweenOffScreen(); void TweenOffScreen();
private: private:
+5 -1
View File
@@ -16,7 +16,11 @@ ScoreDisplayPercentage::ScoreDisplayPercentage()
void ScoreDisplayPercentage::Init( const PlayerState* pPlayerState ) void ScoreDisplayPercentage::Init( const PlayerState* pPlayerState )
{ {
m_Percent.Load( pPlayerState->m_PlayerNumber, &STATSMAN->m_CurStageStats.m_player[pPlayerState->m_PlayerNumber], true ); m_Percent.Load(
pPlayerState->m_PlayerNumber,
&STATSMAN->m_CurStageStats.m_player[pPlayerState->m_PlayerNumber],
"ScoreDisplayPercentage Percent",
true );
} }
/* /*
+3 -5
View File
@@ -501,11 +501,9 @@ void ScreenEvaluation::Init()
/* Use "ScreenEvaluation Percent" for the [metric set], but position and /* Use "ScreenEvaluation Percent" for the [metric set], but position and
* tween it with "PercentP1X", etc. */ * tween it with "PercentP1X", etc. */
m_Percent[p].SetName( "ScreenEvaluation Percent" ); m_Percent[p].SetName( ssprintf("PercentP%d",p+1) );
m_Percent[p].Load( p, &STATSMAN->m_CurStageStats.m_player[p], true ); m_Percent[p].Load( p, &STATSMAN->m_CurStageStats.m_player[p], "ScreenEvaluation Percent", true );
m_Percent[p].SetXY( THEME->GetMetricF(m_sName, ssprintf("PercentP%dX",p+1)), SET_XY_AND_ON_COMMAND( m_Percent[p] );
THEME->GetMetricF(m_sName,ssprintf("PercentP%dY",p+1)) );
m_Percent[p].RunCommands( THEME->GetMetricA(m_sName,ssprintf("PercentP%dOnCommand",p+1)) );
this->AddChild( &m_Percent[p] ); this->AddChild( &m_Percent[p] );
} }
} }
+2 -2
View File
@@ -355,6 +355,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S
sBanner = pCourse->m_sBannerPath; sBanner = pCourse->m_sBannerPath;
else else
sBanner = pSong->GetBannerPath(); sBanner = pSong->GetBannerPath();
if( !sBanner.empty() ) if( !sBanner.empty() )
{ {
display.m_sprBanner.SetName( ssprintf("BannerP%i",p+1) ); display.m_sprBanner.SetName( ssprintf("BannerP%i",p+1) );
@@ -381,8 +382,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S
SET_ON( display.m_Difficulty ); SET_ON( display.m_Difficulty );
this->AddChild( &display.m_Difficulty ); this->AddChild( &display.m_Difficulty );
display.m_textScore.SetName( "ScreenNameEntryTraditional Percent" ); display.m_textScore.Load( p, &ss.m_player[p], "ScreenNameEntryTraditional Percent", false );
display.m_textScore.Load( p, &ss.m_player[p], false );
display.m_textScore.SetName( ssprintf("ScoreP%i",p+1) ); display.m_textScore.SetName( ssprintf("ScoreP%i",p+1) );
SET_ON( display.m_textScore ); SET_ON( display.m_textScore );
this->AddChild( &display.m_textScore ); this->AddChild( &display.m_textScore );