diff --git a/stepmania/src/PaneDisplay.cpp b/stepmania/src/PaneDisplay.cpp index f66de3b49f..31e2c1c1b9 100644 --- a/stepmania/src/PaneDisplay.cpp +++ b/stepmania/src/PaneDisplay.cpp @@ -305,7 +305,7 @@ void PaneDisplay::SetContent( PaneContents c ) case COURSE_MACHINE_HIGH_SCORE: case SONG_PROFILE_HIGH_SCORE: case COURSE_PROFILE_HIGH_SCORE: - str = PercentageDisplay::FormatPercentScore( val, 5, 2 ); + str = PercentageDisplay::FormatPercentScore( val ); break; case SONG_NUM_STEPS: case SONG_JUMPS: diff --git a/stepmania/src/PercentageDisplay.cpp b/stepmania/src/PercentageDisplay.cpp index 1e77e90652..045db75f38 100644 --- a/stepmania/src/PercentageDisplay.cpp +++ b/stepmania/src/PercentageDisplay.cpp @@ -9,6 +9,8 @@ #include "StageStats.h" #include "PlayerState.h" +ThemeMetric PERCENT_DECIMAL_PLACES ( "PercentageDisplay", "PercentDecimalPlaces" ); +ThemeMetric PERCENT_TOTAL_SIZE ( "PercentageDisplay", "PercentTotalSize" ); PercentageDisplay::PercentageDisplay() { @@ -24,8 +26,6 @@ void PercentageDisplay::Load( PlayerNumber pn, PlayerStageStats* pSource, const m_LastMax = -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" ); APPLY_SCORE_DISPLAY_OPTIONS.Load( sMetricsGroup, "ApplyScoreDisplayOptions" ); @@ -121,7 +121,7 @@ void PercentageDisplay::Refresh() } else { - sNumToDisplay = FormatPercentScore( fPercentDancePoints, PERCENT_TOTAL_SIZE, PERCENT_DECIMAL_PLACES ); + sNumToDisplay = FormatPercentScore( fPercentDancePoints ); // HACK: Use the last frame in the numbers texture as '-' sNumToDisplay.Replace('-','x'); @@ -131,11 +131,11 @@ void PercentageDisplay::Refresh() m_textPercent.SetText( sNumToDisplay ); } -CString PercentageDisplay::FormatPercentScore( float fPercentDancePoints, int iTotalSize, int iDecimalPlaces ) +CString PercentageDisplay::FormatPercentScore( float fPercentDancePoints ) { // TRICKY: printf will round, but we want to truncate. Otherwise, we may display a percent // score that's too high and doesn't match up with the calculated grade. - float fTruncInterval = powf( 0.1f, (float)iTotalSize-1 ); + float fTruncInterval = powf( 0.1f, (float)PERCENT_TOTAL_SIZE-1 ); // TRICKY: ftruncf is rounding 1.0000000 to 0.99990004. Give a little boost to // fPercentDancePoints to correct for this. @@ -143,9 +143,13 @@ CString PercentageDisplay::FormatPercentScore( float fPercentDancePoints, int iT fPercentDancePoints = ftruncf( fPercentDancePoints, fTruncInterval ); - return ssprintf( "%*.*f%%", iTotalSize, iDecimalPlaces, fPercentDancePoints*100 ); + CString s = ssprintf( "%*.*f%%", (int)PERCENT_TOTAL_SIZE, (int)PERCENT_DECIMAL_PLACES, fPercentDancePoints*100 ); + return s; } +LuaFunction_Float( FormatPercentScore, PercentageDisplay::FormatPercentScore(a1) ) + + /* * (c) 2001-2003 Chris Danford * All rights reserved. diff --git a/stepmania/src/PercentageDisplay.h b/stepmania/src/PercentageDisplay.h index 58f5af78f4..b45334c2ab 100644 --- a/stepmania/src/PercentageDisplay.h +++ b/stepmania/src/PercentageDisplay.h @@ -19,12 +19,10 @@ public: void Update( float fDeltaTime ); void TweenOffScreen(); - static CString FormatPercentScore( float fPercentDancePoints, int iTotalSize, int iDecimalPlaces ); + static CString FormatPercentScore( float fPercentDancePoints ); private: ThemeMetric DANCE_POINT_DIGITS; - ThemeMetric PERCENT_DECIMAL_PLACES; - ThemeMetric PERCENT_TOTAL_SIZE; ThemeMetric PERCENT_USE_REMAINDER; ThemeMetric APPLY_SCORE_DISPLAY_OPTIONS; diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index 5e62924f90..0cd3d7c255 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -13,6 +13,7 @@ #include "RageLog.h" #include "UnlockManager.h" #include "ScreenDimensions.h" +#include "PercentageDisplay.h" static const CString PageTypeNames[NUM_PAGE_TYPES] = { "Category", @@ -90,8 +91,6 @@ ScreenRanking::ScreenRanking( CString sClassName ) : ScreenAttract( sClassName ) SHOW_ALL_COURSE_SCORES (m_sName,"ShowAllCourseScores"), SECONDS_PER_PAGE (m_sName,"SecondsPerPage"), PAGE_FADE_SECONDS (m_sName,"PageFadeSeconds"), - PERCENT_DECIMAL_PLACES (m_sName,"PercentDecimalPlaces"), - PERCENT_TOTAL_SIZE (m_sName,"PercentTotalSize"), NO_SCORE_NAME (m_sName,"NoScoreName"), ROW_SPACING_X (m_sName,"RowSpacingX"), @@ -844,9 +843,7 @@ float ScreenRanking::SetPage( PageToShow pts ) hs.sName = NO_SCORE_NAME; } - CString s; - s = hs.GetDisplayName() + "\n"; - s += ssprintf( "%0*.*f%%", PERCENT_TOTAL_SIZE.GetValue(), PERCENT_DECIMAL_PLACES.GetValue(), hs.fPercentDP*100 ); + CString s = hs.GetDisplayName() + "\n" + PercentageDisplay::FormatPercentScore( hs.fPercentDP ); pTextStepsScore->SetText( s ); } } @@ -887,9 +884,7 @@ float ScreenRanking::SetPage( PageToShow pts ) hs.sName = NO_SCORE_NAME; } - CString s; - s = hs.GetDisplayName() + "\n"; - s += ssprintf( "%0*.*f%%", PERCENT_TOTAL_SIZE.GetValue(), PERCENT_DECIMAL_PLACES.GetValue(), hs.fPercentDP*100 ); + CString s = hs.GetDisplayName() + "\n" + PercentageDisplay::FormatPercentScore( hs.fPercentDP ); pTextStepsScore->SetText( s ); } } diff --git a/stepmania/src/ScreenRanking.h b/stepmania/src/ScreenRanking.h index 05ce24a234..d23108f45f 100644 --- a/stepmania/src/ScreenRanking.h +++ b/stepmania/src/ScreenRanking.h @@ -109,8 +109,6 @@ protected: ThemeMetric SHOW_ALL_COURSE_SCORES; ThemeMetric SECONDS_PER_PAGE; ThemeMetric PAGE_FADE_SECONDS; - ThemeMetric PERCENT_DECIMAL_PLACES; - ThemeMetric PERCENT_TOTAL_SIZE; ThemeMetric NO_SCORE_NAME; ThemeMetric ROW_SPACING_X;