More themable percent display.
This commit is contained in:
@@ -7,8 +7,9 @@
|
|||||||
#include "ActorUtil.h"
|
#include "ActorUtil.h"
|
||||||
|
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
|
#define DANCE_POINT_DIGITS THEME->GetMetricI(m_sName,"DancePointsDigits")
|
||||||
const int NUM_DANCE_POINT_DIGITS = 5;
|
#define PERCENT_DECIMAL_PLACES THEME->GetMetricI(m_sName,"PercentDecimalPlaces")
|
||||||
|
#define PERCENT_TOTAL_SIZE THEME->GetMetricI(m_sName,"PercentTotalSize")
|
||||||
|
|
||||||
PercentageDisplay::PercentageDisplay()
|
PercentageDisplay::PercentageDisplay()
|
||||||
{
|
{
|
||||||
@@ -27,7 +28,7 @@ void PercentageDisplay::Load( PlayerNumber pn )
|
|||||||
if( PREFSMAN->m_bDancePointsForOni )
|
if( PREFSMAN->m_bDancePointsForOni )
|
||||||
m_textPercent.SetText( " " );
|
m_textPercent.SetText( " " );
|
||||||
else
|
else
|
||||||
m_textPercent.SetText( "00.0%" );
|
m_textPercent.SetText( ssprintf( "%0*.*f%%", PERCENT_TOTAL_SIZE, PERCENT_DECIMAL_PLACES, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PercentageDisplay::Update( float fDeltaTime )
|
void PercentageDisplay::Update( float fDeltaTime )
|
||||||
@@ -44,15 +45,11 @@ void PercentageDisplay::Update( float fDeltaTime )
|
|||||||
iPossibleDancePoints = max( 1, iPossibleDancePoints );
|
iPossibleDancePoints = max( 1, iPossibleDancePoints );
|
||||||
float fPercentDancePoints = iActualDancePoints / (float)iPossibleDancePoints + 0.00001f; // correct for rounding errors
|
float fPercentDancePoints = iActualDancePoints / (float)iPossibleDancePoints + 0.00001f; // correct for rounding errors
|
||||||
|
|
||||||
// LOG->Trace( "Actual %d, Possible %d, Percent %f\n", iActualDancePoints, iPossibleDancePoints, fPercentDancePoints );
|
|
||||||
|
|
||||||
float fNumToDisplay = max( 0, fPercentDancePoints*100 );
|
float fNumToDisplay = max( 0, fPercentDancePoints*100 );
|
||||||
sNumToDisplay = ssprintf("%03.1f%%", fNumToDisplay);
|
sNumToDisplay = ssprintf( "%0*.*f%%", PERCENT_TOTAL_SIZE, PERCENT_DECIMAL_PLACES, fNumToDisplay );
|
||||||
if( sNumToDisplay.GetLength() == 4 )
|
|
||||||
sNumToDisplay = "0" + sNumToDisplay;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sNumToDisplay = ssprintf( "%*d", NUM_DANCE_POINT_DIGITS , iActualDancePoints );
|
sNumToDisplay = ssprintf( "%*d", DANCE_POINT_DIGITS, iActualDancePoints );
|
||||||
|
|
||||||
m_textPercent.SetText( sNumToDisplay );
|
m_textPercent.SetText( sNumToDisplay );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user