Files
itgmania212121/stepmania/src/ScoreDisplayNormal.cpp
T

88 lines
2.0 KiB
C++
Raw Normal View History

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"
#include "ThemeManager.h"
2002-07-23 01:41:40 +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()
{
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
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
m_fScore = 0;
2002-07-23 01:41:40 +00:00
m_fTrailingScore = 0;
m_fScoreVelocity = 0;
2002-07-23 01:41:40 +00:00
CString s;
for( int i=0; i<NUM_SCORE_DIGITS; i++ )
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
}
}