2003-10-04 08:20:37 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
|
|
#include "PercentageDisplay.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "PrefsManager.h"
|
2003-10-04 08:45:53 +00:00
|
|
|
#include "ActorUtil.h"
|
2003-10-04 08:20:37 +00:00
|
|
|
|
|
|
|
|
#include "RageLog.h"
|
2003-10-04 09:13:33 +00:00
|
|
|
#define DANCE_POINT_DIGITS THEME->GetMetricI(m_sName,"DancePointsDigits")
|
|
|
|
|
#define PERCENT_DECIMAL_PLACES THEME->GetMetricI(m_sName,"PercentDecimalPlaces")
|
|
|
|
|
#define PERCENT_TOTAL_SIZE THEME->GetMetricI(m_sName,"PercentTotalSize")
|
2003-10-04 08:20:37 +00:00
|
|
|
|
|
|
|
|
PercentageDisplay::PercentageDisplay()
|
|
|
|
|
{
|
|
|
|
|
this->AddChild( &m_textPercent );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PercentageDisplay::Load( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
m_PlayerNumber = pn;
|
|
|
|
|
m_Last = 0;
|
|
|
|
|
|
2003-10-04 08:45:53 +00:00
|
|
|
m_textPercent.SetName( ssprintf("PercentP%i", pn+1) );
|
|
|
|
|
m_textPercent.LoadFromNumbers( THEME->GetPathToN(m_sName + " text") );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_textPercent );
|
2003-10-04 08:20:37 +00:00
|
|
|
|
|
|
|
|
if( PREFSMAN->m_bDancePointsForOni )
|
|
|
|
|
m_textPercent.SetText( " " );
|
|
|
|
|
else
|
2003-10-04 09:13:33 +00:00
|
|
|
m_textPercent.SetText( ssprintf( "%0*.*f%%", PERCENT_TOTAL_SIZE, PERCENT_DECIMAL_PLACES, 0 ) );
|
2003-10-04 08:20:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PercentageDisplay::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
const int iActualDancePoints = GAMESTATE->m_CurStageStats.iActualDancePoints[m_PlayerNumber];
|
|
|
|
|
if( iActualDancePoints == m_Last )
|
|
|
|
|
return;
|
|
|
|
|
m_Last = iActualDancePoints;
|
|
|
|
|
|
|
|
|
|
CString sNumToDisplay;
|
|
|
|
|
if( !PREFSMAN->m_bDancePointsForOni )
|
|
|
|
|
{
|
|
|
|
|
int iPossibleDancePoints = GAMESTATE->m_CurStageStats.iPossibleDancePoints[m_PlayerNumber];
|
|
|
|
|
iPossibleDancePoints = max( 1, iPossibleDancePoints );
|
|
|
|
|
float fPercentDancePoints = iActualDancePoints / (float)iPossibleDancePoints + 0.00001f; // correct for rounding errors
|
|
|
|
|
|
|
|
|
|
float fNumToDisplay = max( 0, fPercentDancePoints*100 );
|
2003-10-04 09:13:33 +00:00
|
|
|
sNumToDisplay = ssprintf( "%0*.*f%%", PERCENT_TOTAL_SIZE, PERCENT_DECIMAL_PLACES, fNumToDisplay );
|
2003-10-04 08:20:37 +00:00
|
|
|
}
|
|
|
|
|
else
|
2003-10-04 09:13:33 +00:00
|
|
|
sNumToDisplay = ssprintf( "%*d", DANCE_POINT_DIGITS, iActualDancePoints );
|
2003-10-04 08:20:37 +00:00
|
|
|
|
|
|
|
|
m_textPercent.SetText( sNumToDisplay );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
|
|
|
|
|
* Chris Danford
|
|
|
|
|
*/
|