From 533e83ed00bc1aec784cd86fe1966f9be68b5ed1 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 16 Feb 2005 23:03:01 +0000 Subject: [PATCH] Don't set two different names for an element. Instead, pass the metrics group name as a parameter to Load() --- stepmania/src/Actor.cpp | 7 ++++- stepmania/src/Actor.h | 1 + stepmania/src/LifeMeterBattery.cpp | 3 +- stepmania/src/PercentageDisplay.cpp | 33 +++++++++----------- stepmania/src/PercentageDisplay.h | 3 +- stepmania/src/ScoreDisplayPercentage.cpp | 6 +++- stepmania/src/ScreenEvaluation.cpp | 8 ++--- stepmania/src/ScreenNameEntryTraditional.cpp | 4 +-- 8 files changed, 34 insertions(+), 31 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index b931c403cf..c7bb86aacb 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -110,7 +110,7 @@ void Actor::LoadFromNode( const CString& sDir, const XNode* pNode ) sCmdName="on"; else 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; } +void Actor::AddCommand( const CString &sCmdName, apActorCommands apac ) +{ + m_mapNameToCommands[sCmdName] = apac; +} + void Actor::PlayCommand( const CString &sCommandName ) { CString sKey = sCommandName; diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index a967a2c18d..87583e284a 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -308,6 +308,7 @@ public: // Commands // virtual void PushSelf( lua_State *L ); + void AddCommand( const CString &sCmdName, apActorCommands apac ); virtual void PlayCommand( const CString &sCommandName ); virtual void RunCommands( const ActorCommands& cmds ); void RunCommands( const apActorCommands& cmds ) { this->RunCommands( *cmds ); } // convenience diff --git a/stepmania/src/LifeMeterBattery.cpp b/stepmania/src/LifeMeterBattery.cpp index 9be6ed513b..758008eb26 100644 --- a/stepmania/src/LifeMeterBattery.cpp +++ b/stepmania/src/LifeMeterBattery.cpp @@ -53,8 +53,7 @@ void LifeMeterBattery::Load( PlayerNumber pn ) if( bPlayerEnabled ) { - m_Percent.SetName( "LifeMeterBattery Percent" ); - m_Percent.Load( pn, &STATSMAN->m_CurStageStats.m_player[pn], true ); + m_Percent.Load( pn, &STATSMAN->m_CurStageStats.m_player[pn], "LifeMeterBattery Percent", true ); this->AddChild( &m_Percent ); } diff --git a/stepmania/src/PercentageDisplay.cpp b/stepmania/src/PercentageDisplay.cpp index 287eabda9a..0b634420a6 100644 --- a/stepmania/src/PercentageDisplay.cpp +++ b/stepmania/src/PercentageDisplay.cpp @@ -14,38 +14,35 @@ PercentageDisplay::PercentageDisplay() 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_pSource = pSource; m_bAutoRefresh = bAutoRefresh; 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 ) m_textPercent.SetName( ssprintf("DancePointsP%i", pn+1) ); else m_textPercent.SetName( ssprintf("PercentP%i", pn+1) ); - m_textPercent.LoadFromFont( THEME->GetPathF(m_sName,"text") ); - SET_XY_AND_ON_COMMAND( m_textPercent ); + m_textPercent.LoadFromFont( THEME->GetPathF(sMetricsGroup,"text") ); + ActorUtil::SetXYAndOnCommand( m_textPercent, sMetricsGroup ); + m_textPercent.AddCommand( "Off", THEME->GetMetricA(sMetricsGroup, m_textPercent.GetName()+"OffCommand") ); this->AddChild( &m_textPercent ); if( !PREFSMAN->m_bDancePointsForOni && (bool)PERCENT_USE_REMAINDER ) { m_textPercentRemainder.SetName( ssprintf("PercentRemainderP%d",pn+1) ); - m_textPercentRemainder.LoadFromFont( THEME->GetPathF(m_sName,"remainder") ); - SET_XY_AND_ON_COMMAND( m_textPercentRemainder ); + m_textPercentRemainder.LoadFromFont( THEME->GetPathF(sMetricsGroup,"remainder") ); + ActorUtil::SetXYAndOnCommand( m_textPercentRemainder, sMetricsGroup ); + m_textPercentRemainder.AddCommand( "Off", THEME->GetMetricA(sMetricsGroup, m_textPercentRemainder.GetName()+"OffCommand") ); m_textPercentRemainder.SetText( "456" ); this->AddChild( &m_textPercentRemainder ); } @@ -55,9 +52,9 @@ void PercentageDisplay::Load( PlayerNumber pn, PlayerStageStats* pSource, bool b void PercentageDisplay::TweenOffScreen() { - OFF_COMMAND( m_textPercent ); + m_textPercent.PlayCommand( "Off" ); if( !PREFSMAN->m_bDancePointsForOni && (bool)PERCENT_USE_REMAINDER ) - OFF_COMMAND( m_textPercentRemainder ); + m_textPercentRemainder.PlayCommand( "Off" ); } void PercentageDisplay::Update( float fDeltaTime ) diff --git a/stepmania/src/PercentageDisplay.h b/stepmania/src/PercentageDisplay.h index 31486c437d..57aa2c6eda 100644 --- a/stepmania/src/PercentageDisplay.h +++ b/stepmania/src/PercentageDisplay.h @@ -13,9 +13,8 @@ class PercentageDisplay: public ActorFrame { public: 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 SetName( const CString &sName, const CString &sID = "" ); void TweenOffScreen(); private: diff --git a/stepmania/src/ScoreDisplayPercentage.cpp b/stepmania/src/ScoreDisplayPercentage.cpp index de158a54cc..ed8969fbae 100644 --- a/stepmania/src/ScoreDisplayPercentage.cpp +++ b/stepmania/src/ScoreDisplayPercentage.cpp @@ -16,7 +16,11 @@ ScoreDisplayPercentage::ScoreDisplayPercentage() 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 ); } /* diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index ab739cca86..9db421b1fc 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -501,11 +501,9 @@ void ScreenEvaluation::Init() /* Use "ScreenEvaluation Percent" for the [metric set], but position and * tween it with "PercentP1X", etc. */ - m_Percent[p].SetName( "ScreenEvaluation Percent" ); - m_Percent[p].Load( p, &STATSMAN->m_CurStageStats.m_player[p], true ); - m_Percent[p].SetXY( THEME->GetMetricF(m_sName, ssprintf("PercentP%dX",p+1)), - THEME->GetMetricF(m_sName,ssprintf("PercentP%dY",p+1)) ); - m_Percent[p].RunCommands( THEME->GetMetricA(m_sName,ssprintf("PercentP%dOnCommand",p+1)) ); + m_Percent[p].SetName( ssprintf("PercentP%d",p+1) ); + m_Percent[p].Load( p, &STATSMAN->m_CurStageStats.m_player[p], "ScreenEvaluation Percent", true ); + SET_XY_AND_ON_COMMAND( m_Percent[p] ); this->AddChild( &m_Percent[p] ); } } diff --git a/stepmania/src/ScreenNameEntryTraditional.cpp b/stepmania/src/ScreenNameEntryTraditional.cpp index 7cb09a7ec7..c267156349 100644 --- a/stepmania/src/ScreenNameEntryTraditional.cpp +++ b/stepmania/src/ScreenNameEntryTraditional.cpp @@ -355,6 +355,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S sBanner = pCourse->m_sBannerPath; else sBanner = pSong->GetBannerPath(); + if( !sBanner.empty() ) { display.m_sprBanner.SetName( ssprintf("BannerP%i",p+1) ); @@ -381,8 +382,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S SET_ON( display.m_Difficulty ); this->AddChild( &display.m_Difficulty ); - display.m_textScore.SetName( "ScreenNameEntryTraditional Percent" ); - display.m_textScore.Load( p, &ss.m_player[p], false ); + display.m_textScore.Load( p, &ss.m_player[p], "ScreenNameEntryTraditional Percent", false ); display.m_textScore.SetName( ssprintf("ScoreP%i",p+1) ); SET_ON( display.m_textScore ); this->AddChild( &display.m_textScore );