to score leading character coloring in code. Font hacks are messy because there would need to be leading versions of both '0' and ','

This commit is contained in:
Chris Danford
2008-08-17 14:34:53 +00:00
parent d0a95bc1d1
commit 7d0c896612
5 changed files with 50 additions and 5 deletions
+1
View File
@@ -40,6 +40,7 @@ public:
void SetHorizAlign( float f );
void SetStrokeColor( RageColor c ) { m_StrokeColor = c; }
RageColor GetStrokeColor() { return m_StrokeColor; }
void GetLines( vector<wstring> &wTextLines ) const { wTextLines = m_wTextLines; }
const vector<wstring> &GetLines() const { return m_wTextLines; }
+41
View File
@@ -18,10 +18,49 @@ void RollingNumbers::Load( const RString &sMetricsGroup )
{
TEXT_FORMAT.Load(sMetricsGroup, "TextFormat");
APPROACH_SECONDS.Load(sMetricsGroup, "ApproachSeconds");
COMMIFY.Load(sMetricsGroup, "Commify");
LEADING_ZERO_MULTIPLY_COLOR.Load(sMetricsGroup, "LeadingZeroMultiplyColor");
UpdateText();
}
void RollingNumbers::DrawPrimitives()
{
RageColor c_orig = this->GetDiffuse();
RageColor c2_orig = this->GetStrokeColor();
RageColor c = this->GetDiffuse();
c *= LEADING_ZERO_MULTIPLY_COLOR;
RageColor c2 = this->GetStrokeColor();
c2 *= LEADING_ZERO_MULTIPLY_COLOR;
RString s = this->GetText();
int i;
for( i=0; i<(int)s.length(); i++ )
{
if( s[i] != '0' && s[i] != ',' )
break;
}
float f = i / (float)s.length();
// draw leading part
SetDiffuse( c );
SetStrokeColor( c2 );
SetCropLeft( 0 );
SetCropRight( 1-f );
BitmapText::DrawPrimitives();
// draw regular color part
SetDiffuse( c_orig );
SetStrokeColor( c2_orig );
SetCropLeft( f );
SetCropRight( 0 );
BitmapText::DrawPrimitives();
SetCropLeft( 0 );
SetCropRight( 0 );
}
void RollingNumbers::Update( float fDeltaTime )
{
if( m_fCurrentNumber != m_fTargetNumber )
@@ -44,6 +83,8 @@ void RollingNumbers::SetTargetNumber( float fTargetNumber )
void RollingNumbers::UpdateText()
{
RString s = ssprintf( TEXT_FORMAT.GetValue(), m_fCurrentNumber );
if( COMMIFY )
s = Commify( s );
SetText( s );
}
+3
View File
@@ -14,6 +14,7 @@ public:
void Load( const RString &sMetricsGroup );
virtual RollingNumbers *Copy() const;
virtual void DrawPrimitives();
virtual void Update( float fDeltaTime );
void SetTargetNumber( float fTargetNumber );
@@ -28,6 +29,8 @@ public:
private:
ThemeMetric<RString> TEXT_FORMAT;
ThemeMetric<float> APPROACH_SECONDS;
ThemeMetric<bool> COMMIFY;
ThemeMetric<RageColor> LEADING_ZERO_MULTIPLY_COLOR;
float m_fCurrentNumber; // currently showing this
float m_fTargetNumber; // approach this
+2 -3
View File
@@ -30,8 +30,6 @@
#include "ScoreKeeperNormal.h"
#include "InputEventPlus.h"
const int NUM_SCORE_DIGITS = 9;
// metrics that are common to all ScreenEvaluation classes
#define BANNER_WIDTH THEME->GetMetricF(m_sName,"BannerWidth")
@@ -581,9 +579,10 @@ void ScreenEvaluation::Init()
{
m_textScore[p].LoadFromFont( THEME->GetPathF(m_sName, "ScoreNumber") );
m_textScore[p].SetName( ssprintf("ScoreNumberP%d",p+1) );
m_textScore[p].Load( "RollingNumbersEvaluation" );
ActorUtil::LoadAllCommands( m_textScore[p], m_sName );
SET_XY( m_textScore[p] );
m_textScore[p].SetText( ssprintf("%*.0i", NUM_SCORE_DIGITS, m_pStageStats->m_player[p].m_iScore) );
m_textScore[p].SetTargetNumber( m_pStageStats->m_player[p].m_iScore );
this->AddChild( &m_textScore[p] );
}
}
+3 -2
View File
@@ -12,6 +12,7 @@
#include "ActorUtil.h"
#include "RageSound.h"
#include "ThemeMetric.h"
#include "RollingNumbers.h"
const int MAX_SONGS_TO_SHOW = 5; // In summary, we show last 3 stages, plus extra stages if passed
enum JudgmentLine
@@ -100,7 +101,7 @@ protected:
// score area
AutoActor m_sprScoreLabel;
BitmapText m_textScore[NUM_PLAYERS];
RollingNumbers m_textScore[NUM_PLAYERS];
// time area
AutoActor m_sprTimeLabel;
@@ -110,7 +111,7 @@ protected:
AutoActor m_sprMachineRecord[NUM_PLAYERS];
AutoActor m_sprProfileRecord[NUM_PLAYERS];
AutoActor m_sprTryExtraStage;
bool m_bFailed;
bool m_bFailed;
RageSound m_soundStart; // sound played if the player passes or fails