use PercentageDisplay::FormatPercentScore in ScreenRanking
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "StageStats.h"
|
||||
#include "PlayerState.h"
|
||||
|
||||
ThemeMetric<int> PERCENT_DECIMAL_PLACES ( "PercentageDisplay", "PercentDecimalPlaces" );
|
||||
ThemeMetric<int> 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.
|
||||
|
||||
@@ -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<int> DANCE_POINT_DIGITS;
|
||||
ThemeMetric<int> PERCENT_DECIMAL_PLACES;
|
||||
ThemeMetric<int> PERCENT_TOTAL_SIZE;
|
||||
ThemeMetric<bool> PERCENT_USE_REMAINDER;
|
||||
ThemeMetric<bool> APPLY_SCORE_DISPLAY_OPTIONS;
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,6 @@ protected:
|
||||
ThemeMetric<bool> SHOW_ALL_COURSE_SCORES;
|
||||
ThemeMetric<float> SECONDS_PER_PAGE;
|
||||
ThemeMetric<float> PAGE_FADE_SECONDS;
|
||||
ThemeMetric<int> PERCENT_DECIMAL_PLACES;
|
||||
ThemeMetric<int> PERCENT_TOTAL_SIZE;
|
||||
ThemeMetric<CString> NO_SCORE_NAME;
|
||||
|
||||
ThemeMetric<float> ROW_SPACING_X;
|
||||
|
||||
Reference in New Issue
Block a user