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 COURSE_MACHINE_HIGH_SCORE:
|
||||||
case SONG_PROFILE_HIGH_SCORE:
|
case SONG_PROFILE_HIGH_SCORE:
|
||||||
case COURSE_PROFILE_HIGH_SCORE:
|
case COURSE_PROFILE_HIGH_SCORE:
|
||||||
str = PercentageDisplay::FormatPercentScore( val, 5, 2 );
|
str = PercentageDisplay::FormatPercentScore( val );
|
||||||
break;
|
break;
|
||||||
case SONG_NUM_STEPS:
|
case SONG_NUM_STEPS:
|
||||||
case SONG_JUMPS:
|
case SONG_JUMPS:
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "StageStats.h"
|
#include "StageStats.h"
|
||||||
#include "PlayerState.h"
|
#include "PlayerState.h"
|
||||||
|
|
||||||
|
ThemeMetric<int> PERCENT_DECIMAL_PLACES ( "PercentageDisplay", "PercentDecimalPlaces" );
|
||||||
|
ThemeMetric<int> PERCENT_TOTAL_SIZE ( "PercentageDisplay", "PercentTotalSize" );
|
||||||
|
|
||||||
PercentageDisplay::PercentageDisplay()
|
PercentageDisplay::PercentageDisplay()
|
||||||
{
|
{
|
||||||
@@ -24,8 +26,6 @@ void PercentageDisplay::Load( PlayerNumber pn, PlayerStageStats* pSource, const
|
|||||||
m_LastMax = -1;
|
m_LastMax = -1;
|
||||||
|
|
||||||
DANCE_POINT_DIGITS.Load( sMetricsGroup, "DancePointsDigits" );
|
DANCE_POINT_DIGITS.Load( sMetricsGroup, "DancePointsDigits" );
|
||||||
PERCENT_DECIMAL_PLACES.Load( sMetricsGroup, "PercentDecimalPlaces" );
|
|
||||||
PERCENT_TOTAL_SIZE.Load( sMetricsGroup, "PercentTotalSize" );
|
|
||||||
PERCENT_USE_REMAINDER.Load( sMetricsGroup, "PercentUseRemainder" );
|
PERCENT_USE_REMAINDER.Load( sMetricsGroup, "PercentUseRemainder" );
|
||||||
APPLY_SCORE_DISPLAY_OPTIONS.Load( sMetricsGroup, "ApplyScoreDisplayOptions" );
|
APPLY_SCORE_DISPLAY_OPTIONS.Load( sMetricsGroup, "ApplyScoreDisplayOptions" );
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ void PercentageDisplay::Refresh()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sNumToDisplay = FormatPercentScore( fPercentDancePoints, PERCENT_TOTAL_SIZE, PERCENT_DECIMAL_PLACES );
|
sNumToDisplay = FormatPercentScore( fPercentDancePoints );
|
||||||
|
|
||||||
// HACK: Use the last frame in the numbers texture as '-'
|
// HACK: Use the last frame in the numbers texture as '-'
|
||||||
sNumToDisplay.Replace('-','x');
|
sNumToDisplay.Replace('-','x');
|
||||||
@@ -131,11 +131,11 @@ void PercentageDisplay::Refresh()
|
|||||||
m_textPercent.SetText( sNumToDisplay );
|
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
|
// 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.
|
// 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
|
// TRICKY: ftruncf is rounding 1.0000000 to 0.99990004. Give a little boost to
|
||||||
// fPercentDancePoints to correct for this.
|
// fPercentDancePoints to correct for this.
|
||||||
@@ -143,9 +143,13 @@ CString PercentageDisplay::FormatPercentScore( float fPercentDancePoints, int iT
|
|||||||
|
|
||||||
fPercentDancePoints = ftruncf( fPercentDancePoints, fTruncInterval );
|
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
|
* (c) 2001-2003 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -19,12 +19,10 @@ public:
|
|||||||
void Update( float fDeltaTime );
|
void Update( float fDeltaTime );
|
||||||
void TweenOffScreen();
|
void TweenOffScreen();
|
||||||
|
|
||||||
static CString FormatPercentScore( float fPercentDancePoints, int iTotalSize, int iDecimalPlaces );
|
static CString FormatPercentScore( float fPercentDancePoints );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThemeMetric<int> DANCE_POINT_DIGITS;
|
ThemeMetric<int> DANCE_POINT_DIGITS;
|
||||||
ThemeMetric<int> PERCENT_DECIMAL_PLACES;
|
|
||||||
ThemeMetric<int> PERCENT_TOTAL_SIZE;
|
|
||||||
ThemeMetric<bool> PERCENT_USE_REMAINDER;
|
ThemeMetric<bool> PERCENT_USE_REMAINDER;
|
||||||
ThemeMetric<bool> APPLY_SCORE_DISPLAY_OPTIONS;
|
ThemeMetric<bool> APPLY_SCORE_DISPLAY_OPTIONS;
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "UnlockManager.h"
|
#include "UnlockManager.h"
|
||||||
#include "ScreenDimensions.h"
|
#include "ScreenDimensions.h"
|
||||||
|
#include "PercentageDisplay.h"
|
||||||
|
|
||||||
static const CString PageTypeNames[NUM_PAGE_TYPES] = {
|
static const CString PageTypeNames[NUM_PAGE_TYPES] = {
|
||||||
"Category",
|
"Category",
|
||||||
@@ -90,8 +91,6 @@ ScreenRanking::ScreenRanking( CString sClassName ) : ScreenAttract( sClassName )
|
|||||||
SHOW_ALL_COURSE_SCORES (m_sName,"ShowAllCourseScores"),
|
SHOW_ALL_COURSE_SCORES (m_sName,"ShowAllCourseScores"),
|
||||||
SECONDS_PER_PAGE (m_sName,"SecondsPerPage"),
|
SECONDS_PER_PAGE (m_sName,"SecondsPerPage"),
|
||||||
PAGE_FADE_SECONDS (m_sName,"PageFadeSeconds"),
|
PAGE_FADE_SECONDS (m_sName,"PageFadeSeconds"),
|
||||||
PERCENT_DECIMAL_PLACES (m_sName,"PercentDecimalPlaces"),
|
|
||||||
PERCENT_TOTAL_SIZE (m_sName,"PercentTotalSize"),
|
|
||||||
NO_SCORE_NAME (m_sName,"NoScoreName"),
|
NO_SCORE_NAME (m_sName,"NoScoreName"),
|
||||||
|
|
||||||
ROW_SPACING_X (m_sName,"RowSpacingX"),
|
ROW_SPACING_X (m_sName,"RowSpacingX"),
|
||||||
@@ -844,9 +843,7 @@ float ScreenRanking::SetPage( PageToShow pts )
|
|||||||
hs.sName = NO_SCORE_NAME;
|
hs.sName = NO_SCORE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
CString s;
|
CString s = hs.GetDisplayName() + "\n" + PercentageDisplay::FormatPercentScore( hs.fPercentDP );
|
||||||
s = hs.GetDisplayName() + "\n";
|
|
||||||
s += ssprintf( "%0*.*f%%", PERCENT_TOTAL_SIZE.GetValue(), PERCENT_DECIMAL_PLACES.GetValue(), hs.fPercentDP*100 );
|
|
||||||
pTextStepsScore->SetText( s );
|
pTextStepsScore->SetText( s );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -887,9 +884,7 @@ float ScreenRanking::SetPage( PageToShow pts )
|
|||||||
hs.sName = NO_SCORE_NAME;
|
hs.sName = NO_SCORE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
CString s;
|
CString s = hs.GetDisplayName() + "\n" + PercentageDisplay::FormatPercentScore( hs.fPercentDP );
|
||||||
s = hs.GetDisplayName() + "\n";
|
|
||||||
s += ssprintf( "%0*.*f%%", PERCENT_TOTAL_SIZE.GetValue(), PERCENT_DECIMAL_PLACES.GetValue(), hs.fPercentDP*100 );
|
|
||||||
pTextStepsScore->SetText( s );
|
pTextStepsScore->SetText( s );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,8 +109,6 @@ protected:
|
|||||||
ThemeMetric<bool> SHOW_ALL_COURSE_SCORES;
|
ThemeMetric<bool> SHOW_ALL_COURSE_SCORES;
|
||||||
ThemeMetric<float> SECONDS_PER_PAGE;
|
ThemeMetric<float> SECONDS_PER_PAGE;
|
||||||
ThemeMetric<float> PAGE_FADE_SECONDS;
|
ThemeMetric<float> PAGE_FADE_SECONDS;
|
||||||
ThemeMetric<int> PERCENT_DECIMAL_PLACES;
|
|
||||||
ThemeMetric<int> PERCENT_TOTAL_SIZE;
|
|
||||||
ThemeMetric<CString> NO_SCORE_NAME;
|
ThemeMetric<CString> NO_SCORE_NAME;
|
||||||
|
|
||||||
ThemeMetric<float> ROW_SPACING_X;
|
ThemeMetric<float> ROW_SPACING_X;
|
||||||
|
|||||||
Reference in New Issue
Block a user