optimize
This commit is contained in:
@@ -12,17 +12,6 @@
|
|||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
|
|
||||||
|
|
||||||
#define NUM_FEET_IN_METER THEME->GetMetricI(m_sName,"NumFeetInMeter")
|
|
||||||
#define MAX_FEET_IN_METER THEME->GetMetricI(m_sName,"MaxFeetInMeter")
|
|
||||||
#define GLOW_IF_METER_GREATER_THAN THEME->GetMetricI(m_sName,"GlowIfMeterGreaterThan")
|
|
||||||
#define SHOW_FEET THEME->GetMetricB(m_sName,"ShowFeet")
|
|
||||||
/* "easy", "hard" */
|
|
||||||
#define SHOW_DIFFICULTY THEME->GetMetricB(m_sName,"ShowDifficulty")
|
|
||||||
/* 3, 9 */
|
|
||||||
#define SHOW_METER THEME->GetMetricB(m_sName,"ShowMeter")
|
|
||||||
#define FEET_IS_DIFFICULTY_COLOR THEME->GetMetricB(m_sName,"FeetIsDifficultyColor")
|
|
||||||
#define FEET_PER_DIFFICULTY THEME->GetMetricB(m_sName,"FeetPerDifficulty")
|
|
||||||
|
|
||||||
DifficultyMeter::DifficultyMeter()
|
DifficultyMeter::DifficultyMeter()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -51,11 +40,24 @@ DifficultyMeter::DifficultyMeter()
|
|||||||
|
|
||||||
void DifficultyMeter::Load()
|
void DifficultyMeter::Load()
|
||||||
{
|
{
|
||||||
if( SHOW_FEET )
|
/* We can't use global CachedThemeMetrics, because we can have multiple
|
||||||
|
* DifficultyMeters on screen at once, with different names. */
|
||||||
|
m_iNumFeetInMeter = THEME->GetMetricI(m_sName,"NumFeetInMeter");
|
||||||
|
m_iMaxFeetInMeter = THEME->GetMetricI(m_sName,"MaxFeetInMeter");
|
||||||
|
m_iGlowIfMeterGreaterThan = THEME->GetMetricI(m_sName,"GlowIfMeterGreaterThan");
|
||||||
|
m_bShowFeet = THEME->GetMetricB(m_sName,"ShowFeet");
|
||||||
|
/* "easy", "hard" */
|
||||||
|
m_bShowDifficulty = THEME->GetMetricB(m_sName,"ShowDifficulty");
|
||||||
|
/* 3, 9 */
|
||||||
|
m_bShowMeter = THEME->GetMetricB(m_sName,"ShowMeter");
|
||||||
|
m_bFeetIsDifficultyColor = THEME->GetMetricB(m_sName,"FeetIsDifficultyColor");
|
||||||
|
m_bFeetPerDifficulty = THEME->GetMetricB(m_sName,"FeetPerDifficulty");
|
||||||
|
|
||||||
|
if( m_bShowFeet )
|
||||||
{
|
{
|
||||||
m_textFeet.SetName( "Feet" );
|
m_textFeet.SetName( "Feet" );
|
||||||
CString Feet;
|
CString Feet;
|
||||||
if( FEET_PER_DIFFICULTY )
|
if( m_bFeetPerDifficulty )
|
||||||
{
|
{
|
||||||
for( unsigned i = 0; i < NUM_DIFFICULTIES; ++i )
|
for( unsigned i = 0; i < NUM_DIFFICULTIES; ++i )
|
||||||
Feet += char(i + '0'); // 01234
|
Feet += char(i + '0'); // 01234
|
||||||
@@ -68,7 +70,7 @@ void DifficultyMeter::Load()
|
|||||||
this->AddChild( &m_textFeet );
|
this->AddChild( &m_textFeet );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( SHOW_DIFFICULTY )
|
if( m_bShowDifficulty )
|
||||||
{
|
{
|
||||||
m_Difficulty.Load( THEME->GetPathG(m_sName,"difficulty") );
|
m_Difficulty.Load( THEME->GetPathG(m_sName,"difficulty") );
|
||||||
m_Difficulty->SetName( "Difficulty" );
|
m_Difficulty->SetName( "Difficulty" );
|
||||||
@@ -76,7 +78,7 @@ void DifficultyMeter::Load()
|
|||||||
this->AddChild( m_Difficulty );
|
this->AddChild( m_Difficulty );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( SHOW_METER )
|
if( m_bShowMeter )
|
||||||
{
|
{
|
||||||
m_textMeter.SetName( "Meter" );
|
m_textMeter.SetName( "Meter" );
|
||||||
m_textMeter.LoadFromFont( THEME->GetPathF(m_sName,"meter") );
|
m_textMeter.LoadFromFont( THEME->GetPathF(m_sName,"meter") );
|
||||||
@@ -151,32 +153,31 @@ void DifficultyMeter::SetFromCourseDifficulty( CourseDifficulty cd )
|
|||||||
|
|
||||||
void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc )
|
void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc )
|
||||||
{
|
{
|
||||||
if( SHOW_FEET )
|
if( m_bShowFeet )
|
||||||
{
|
{
|
||||||
CString on = "0";
|
char on = '0';
|
||||||
CString off = "X";
|
char off = 'X';
|
||||||
if( FEET_PER_DIFFICULTY )
|
if( m_bFeetPerDifficulty )
|
||||||
on = char(dc + '0');
|
on = char(dc + '0');
|
||||||
|
|
||||||
CString sNewText;
|
CString sNewText;
|
||||||
int f;
|
int iNumOn = min( m_iMaxFeetInMeter, iMeter );
|
||||||
for( f=0; f<NUM_FEET_IN_METER; f++ )
|
sNewText.insert( sNewText.end(), iNumOn, on );
|
||||||
sNewText += (f<iMeter) ? on : off;
|
int iNumOff = max( 0, m_iNumFeetInMeter-iNumOn );
|
||||||
for( f=NUM_FEET_IN_METER; f<MAX_FEET_IN_METER && f<iMeter; f++ )
|
sNewText.insert( sNewText.end(), iNumOff, off );
|
||||||
sNewText += on;
|
|
||||||
|
|
||||||
m_textFeet.SetText( sNewText );
|
m_textFeet.SetText( sNewText );
|
||||||
|
|
||||||
if( iMeter > GLOW_IF_METER_GREATER_THAN )
|
if( iMeter > m_iGlowIfMeterGreaterThan )
|
||||||
m_textFeet.SetEffectGlowShift();
|
m_textFeet.SetEffectGlowShift();
|
||||||
else
|
else
|
||||||
m_textFeet.SetEffectNone();
|
m_textFeet.SetEffectNone();
|
||||||
|
|
||||||
if( FEET_IS_DIFFICULTY_COLOR )
|
if( m_bFeetIsDifficultyColor )
|
||||||
m_textFeet.SetDiffuse( SONGMAN->GetDifficultyColor( dc ) );
|
m_textFeet.SetDiffuse( SONGMAN->GetDifficultyColor( dc ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( SHOW_METER )
|
if( m_bShowMeter )
|
||||||
{
|
{
|
||||||
if( iMeter == 0 ) // Unset calls with this
|
if( iMeter == 0 ) // Unset calls with this
|
||||||
{
|
{
|
||||||
@@ -196,9 +197,9 @@ void DifficultyMeter::SetDifficulty( CString diff )
|
|||||||
return;
|
return;
|
||||||
m_CurDifficulty = diff;
|
m_CurDifficulty = diff;
|
||||||
|
|
||||||
if( SHOW_DIFFICULTY )
|
if( m_bShowDifficulty )
|
||||||
COMMAND( m_Difficulty, "Set" + Capitalize(diff) );
|
COMMAND( m_Difficulty, "Set" + Capitalize(diff) );
|
||||||
if( SHOW_METER )
|
if( m_bShowMeter )
|
||||||
COMMAND( m_textMeter, "Set" + Capitalize(diff) );
|
COMMAND( m_textMeter, "Set" + Capitalize(diff) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ private:
|
|||||||
AutoActor m_Difficulty;
|
AutoActor m_Difficulty;
|
||||||
|
|
||||||
BitmapText m_textMeter;
|
BitmapText m_textMeter;
|
||||||
|
|
||||||
|
int m_iNumFeetInMeter, m_iMaxFeetInMeter, m_iGlowIfMeterGreaterThan;
|
||||||
|
bool m_bShowFeet, m_bShowDifficulty, m_bShowMeter, m_bFeetIsDifficultyColor, m_bFeetPerDifficulty;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user