2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: ScoreDisplayNormal.h
|
|
|
|
|
|
|
|
|
|
Desc: A graphic displayed in the ScoreDisplayNormal during Dancing.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ScoreDisplayNormal.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "GameState.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
|
|
|
|
|
|
2002-09-12 00:40:48 +00:00
|
|
|
const float SCORE_TWEEN_TIME = 0.2f;
|
2003-02-25 00:33:42 +00:00
|
|
|
const int NUM_SCORE_DIGITS = 9;
|
2002-07-23 01:41:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
ScoreDisplayNormal::ScoreDisplayNormal()
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScoreDisplayNormal::ScoreDisplayNormal()" );
|
2002-07-23 01:41:40 +00:00
|
|
|
|
2003-05-05 06:48:20 +00:00
|
|
|
m_sprFrame.Load( THEME->GetPathToG("ScoreDisplayNormal frame") );
|
|
|
|
|
this->AddChild( &m_sprFrame );
|
|
|
|
|
|
2002-07-23 01:41:40 +00:00
|
|
|
// init the text
|
2003-04-12 17:39:27 +00:00
|
|
|
m_text.LoadFromNumbers( THEME->GetPathToN("ScoreDisplayNormal") );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_text.EnableShadow( false );
|
2002-07-23 01:41:40 +00:00
|
|
|
|
2002-08-01 20:30:40 +00:00
|
|
|
m_fScore = 0;
|
2002-07-23 01:41:40 +00:00
|
|
|
m_fTrailingScore = 0;
|
2002-08-01 20:30:40 +00:00
|
|
|
m_fScoreVelocity = 0;
|
2002-07-23 01:41:40 +00:00
|
|
|
|
2002-08-01 20:30:40 +00:00
|
|
|
CString s;
|
|
|
|
|
for( int i=0; i<NUM_SCORE_DIGITS; i++ )
|
2002-08-13 23:26:46 +00:00
|
|
|
s += ' ';
|
2003-02-25 00:33:42 +00:00
|
|
|
m_text.SetText( s );
|
|
|
|
|
this->AddChild( &m_text );
|
2002-07-23 01:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
2003-02-25 00:33:42 +00:00
|
|
|
void ScoreDisplayNormal::Init( PlayerNumber pn )
|
2002-07-23 01:41:40 +00:00
|
|
|
{
|
2003-02-25 00:33:42 +00:00
|
|
|
ScoreDisplay::Init( pn );
|
|
|
|
|
m_text.SetDiffuse( PlayerToColor(pn) );
|
2002-07-23 01:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScoreDisplayNormal::SetScore( float fNewScore )
|
|
|
|
|
{
|
|
|
|
|
m_fScore = fNewScore;
|
|
|
|
|
|
|
|
|
|
float fDelta = (float)m_fScore - m_fTrailingScore;
|
|
|
|
|
|
|
|
|
|
m_fScoreVelocity = fDelta / SCORE_TWEEN_TIME; // in score units per second
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 00:33:42 +00:00
|
|
|
void ScoreDisplayNormal::SetText( CString s )
|
|
|
|
|
{
|
|
|
|
|
m_text.SetText( s );
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-23 01:41:40 +00:00
|
|
|
void ScoreDisplayNormal::Update( float fDeltaTime )
|
|
|
|
|
{
|
2003-02-25 00:33:42 +00:00
|
|
|
ScoreDisplay::Update( fDeltaTime );
|
2002-07-23 01:41:40 +00:00
|
|
|
|
2002-07-28 20:28:37 +00:00
|
|
|
if( m_fTrailingScore != m_fScore )
|
2002-07-23 01:41:40 +00:00
|
|
|
{
|
2002-07-28 20:28:37 +00:00
|
|
|
float fDeltaBefore = (float)m_fScore - m_fTrailingScore;
|
|
|
|
|
m_fTrailingScore += m_fScoreVelocity * fDeltaTime;
|
|
|
|
|
float fDeltaAfter = (float)m_fScore - m_fTrailingScore;
|
2002-07-23 01:41:40 +00:00
|
|
|
|
2002-07-28 20:28:37 +00:00
|
|
|
if( fDeltaBefore * fDeltaAfter < 0 ) // the sign changed
|
|
|
|
|
{
|
|
|
|
|
m_fTrailingScore = (float)m_fScore;
|
|
|
|
|
m_fScoreVelocity = 0;
|
|
|
|
|
}
|
2002-07-23 01:41:40 +00:00
|
|
|
|
2003-02-25 00:33:42 +00:00
|
|
|
m_text.SetText( ssprintf("%*.0f", NUM_SCORE_DIGITS, m_fTrailingScore) );
|
2002-07-23 01:41:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|