From 24f86b2532bacaac70a3f99c1868e775795bc331 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Thu, 5 Jan 2012 21:47:42 -0600 Subject: [PATCH] [PercentageDisplay] Remove unused ApplyScoreDisplayOptions metric, added PercentFormat and RemainderFormat metrics. --- Themes/_fallback/metrics.ini | 4 ++++ src/PercentageDisplay.cpp | 14 +++++++------- src/PercentageDisplay.h | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index ea50c5998b..5aabbd5498 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -634,6 +634,7 @@ PercentUseRemainder=false ApplyScoreDisplayOptions=true DancePointsDigits=5 # +PercentFormat="%2d" PercentP1X=0 PercentP1Y=0 PercentP1OnCommand=zoom,0.7;shadowlength,0;diffuse,PlayerColor(PLAYER_1) @@ -1172,6 +1173,7 @@ DeltaSecondsHeldCommand= DeltaSecondsGainLifeCommand= [ScoreDisplayPercentage Percent] +PercentFormat="%2d" PercentP1X=0 PercentP1Y=0 PercentP1OnCommand=shadowlength,0;diffuse,PlayerColor(PLAYER_1) @@ -1235,6 +1237,7 @@ LevelP2OffCommand= AttackDurationSeconds=3.0 [ScreenEvaluation Percent] +PercentFormat="%2d" PercentP1X=0 PercentP1Y=0 PercentP1OnCommand=horizalign,right;vertalign,bottom;glowshift;effectperiod,2;shadowlength,0 @@ -1243,6 +1246,7 @@ PercentP2X=0 PercentP2Y=0 PercentP2OnCommand=horizalign,right;vertalign,bottom;glowshift;effectperiod,2;shadowlength,0 PercentP2OffCommand= +RemainderFormat=".%02d%%" PercentRemainderP1X=0 PercentRemainderP1Y=0 PercentRemainderP1OnCommand=horizalign,left;vertalign,bottom;glowshift;effectperiod,2;shadowlength,0 diff --git a/src/PercentageDisplay.cpp b/src/PercentageDisplay.cpp index 503f153eb7..e932844e3f 100644 --- a/src/PercentageDisplay.cpp +++ b/src/PercentageDisplay.cpp @@ -23,7 +23,6 @@ PercentageDisplay::PercentageDisplay() m_LastMax = -1; m_iDancePointsDigits = 0; m_bUseRemainder = false; - m_bApplyScoreDisplayOptions = false; m_bAutoRefresh = false; m_FormatPercentScore.SetFromExpression( "FormatPercentScore" ); } @@ -31,7 +30,6 @@ PercentageDisplay::PercentageDisplay() void PercentageDisplay::LoadFromNode( const XNode* pNode ) { pNode->GetAttrValue( "DancePointsDigits", m_iDancePointsDigits ); - pNode->GetAttrValue( "ApplyScoreDisplayOptions", m_bApplyScoreDisplayOptions ); pNode->GetAttrValue( "AutoRefresh", m_bAutoRefresh ); { Lua *L = LUA->Get(); @@ -76,9 +74,11 @@ void PercentageDisplay::Load( const PlayerState *pPlayerState, const PlayerStage m_iDancePointsDigits = THEME->GetMetricI( sMetricsGroup, "DancePointsDigits" ); m_bUseRemainder = THEME->GetMetricB( sMetricsGroup, "PercentUseRemainder" ); - m_bApplyScoreDisplayOptions = THEME->GetMetricB( sMetricsGroup, "ApplyScoreDisplayOptions" ); m_FormatPercentScore = THEME->GetMetricR( sMetricsGroup, "Format" ); - + + m_sPercentFormat = THEME->GetMetric( sMetricsGroup, "PercentFormat" ); + m_sRemainderFormat = THEME->GetMetric( sMetricsGroup, "RemainderFormat" ); + if( m_FormatPercentScore.IsNil() ) { LOG->Trace( "Format is nil in [%s]. Defaulting to 'FormatPercentScore'.", sMetricsGroup.c_str() ); @@ -145,8 +145,8 @@ void PercentageDisplay::Refresh() { int iPercentWhole = int(fPercentDancePoints*100); int iPercentRemainder = int( (fPercentDancePoints*100 - int(fPercentDancePoints*100)) * 10 ); - sNumToDisplay = ssprintf( "%2d", iPercentWhole ); - m_textPercentRemainder.SetText( ssprintf(".%01d%%", iPercentRemainder) ); + sNumToDisplay = ssprintf( m_sPercentFormat, iPercentWhole ); + m_textPercentRemainder.SetText( ssprintf(m_sRemainderFormat, iPercentRemainder) ); } else { @@ -159,7 +159,7 @@ void PercentageDisplay::Refresh() LOG->Warn( "Error running FormatPercentScore: %s", sError.c_str() ); LuaHelpers::Pop( L, sNumToDisplay ); LUA->Release(L); - + // HACK: Use the last frame in the numbers texture as '-' sNumToDisplay.Replace('-','x'); } diff --git a/src/PercentageDisplay.h b/src/PercentageDisplay.h index 74888ae4e0..f21fe8aff0 100644 --- a/src/PercentageDisplay.h +++ b/src/PercentageDisplay.h @@ -28,7 +28,6 @@ public: private: int m_iDancePointsDigits; bool m_bUseRemainder; - bool m_bApplyScoreDisplayOptions; void Refresh(); const PlayerState *m_pPlayerState; @@ -38,6 +37,8 @@ private: int m_LastMax; BitmapText m_textPercent; BitmapText m_textPercentRemainder; + RString m_sPercentFormat; + RString m_sRemainderFormat; LuaReference m_FormatPercentScore; };