use the Meter and Description text in DifficultyMeter instead of duplicating them in DifficultyList

This commit is contained in:
Chris Danford
2005-04-11 15:42:39 +00:00
parent 16dfd54522
commit 04eb5056f3
4 changed files with 70 additions and 102 deletions
+3 -72
View File
@@ -30,7 +30,6 @@ void DifficultyList::SetName( const CString &sName, const CString &sID )
ActorFrame::SetName( sName, sID ); ActorFrame::SetName( sName, sID );
ITEMS_SPACING_Y.Load( m_sName, "ItemsSpacingY" ); ITEMS_SPACING_Y.Load( m_sName, "ItemsSpacingY" );
DESCRIPTION_MAX_WIDTH.Load( m_sName, "DescriptionMaxWidth" );
NUM_SHOWN_ITEMS.Load( m_sName, "NumShownItems" ); NUM_SHOWN_ITEMS.Load( m_sName, "NumShownItems" );
CAPITALIZE_DIFFICULTY_NAMES.Load( m_sName, "CapitalizeDifficultyNames" ); CAPITALIZE_DIFFICULTY_NAMES.Load( m_sName, "CapitalizeDifficultyNames" );
MOVE_COMMAND.Load( m_sName, "MoveCommand" ); MOVE_COMMAND.Load( m_sName, "MoveCommand" );
@@ -61,27 +60,15 @@ void DifficultyList::Load()
for( unsigned m = 0; m < m_Lines.size(); ++m ) for( unsigned m = 0; m < m_Lines.size(); ++m )
{ {
m_Lines[m].m_Meter.SetName( "Row" ); m_Lines[m].m_Meter.SetName( "Row" );
m_Lines[m].m_Meter.Load( "DifficultySummaryRow" ); m_Lines[m].m_Meter.Load( "DifficultyListRow" );
this->AddChild( &m_Lines[m].m_Meter ); this->AddChild( &m_Lines[m].m_Meter );
m_Lines[m].m_Description.SetName( "Description" );
m_Lines[m].m_Description.LoadFromFont( THEME->GetPathF(m_sName,"description") );
this->AddChild( &m_Lines[m].m_Description );
m_Lines[m].m_Number.SetName( "Number" );
m_Lines[m].m_Number.LoadFromFont( THEME->GetPathF(m_sName,"number") );
this->AddChild( &m_Lines[m].m_Number );
} }
FOREACH_HumanPlayer( pn ) FOREACH_HumanPlayer( pn )
ON_COMMAND( m_Cursors[pn] ); ON_COMMAND( m_Cursors[pn] );
for( int m = 0; m < MAX_METERS; ++m ) for( int m = 0; m < MAX_METERS; ++m )
{
ON_COMMAND( m_Lines[m].m_Meter ); ON_COMMAND( m_Lines[m].m_Meter );
ON_COMMAND( m_Lines[m].m_Description );
ON_COMMAND( m_Lines[m].m_Number );
}
UpdatePositions(); UpdatePositions();
PositionItems(); PositionItems();
@@ -207,9 +194,7 @@ void DifficultyList::PositionItems()
for( int i = 0; i < MAX_METERS; ++i ) for( int i = 0; i < MAX_METERS; ++i )
{ {
bool bUnused = ( i >= (int)m_Rows.size() ); bool bUnused = ( i >= (int)m_Rows.size() );
m_Lines[i].m_Description.SetHidden( bUnused );
m_Lines[i].m_Meter.SetHidden( bUnused ); m_Lines[i].m_Meter.SetHidden( bUnused );
m_Lines[i].m_Number.SetHidden( bUnused );
} }
for( int m = 0; m < (int)m_Rows.size(); ++m ) for( int m = 0; m < (int)m_Rows.size(); ++m )
@@ -220,18 +205,14 @@ void DifficultyList::PositionItems()
bHidden = true; bHidden = true;
const float fDiffuseAlpha = bHidden? 0.0f:1.0f; const float fDiffuseAlpha = bHidden? 0.0f:1.0f;
if( m_Lines[m].m_Number.GetDestY() != row.m_fY || if( m_Lines[m].m_Meter.GetDestY() != row.m_fY ||
m_Lines[m].m_Number.DestTweenState().diffuse[0][3] != fDiffuseAlpha ) m_Lines[m].m_Meter.DestTweenState().diffuse[0][3] != fDiffuseAlpha )
{ {
m_Lines[m].m_Description.RunCommands( MOVE_COMMAND );
m_Lines[m].m_Meter.RunCommands( MOVE_COMMAND ); m_Lines[m].m_Meter.RunCommands( MOVE_COMMAND );
m_Lines[m].m_Meter.RunCommandsOnChildren( MOVE_COMMAND ); m_Lines[m].m_Meter.RunCommandsOnChildren( MOVE_COMMAND );
m_Lines[m].m_Number.RunCommands( MOVE_COMMAND );
} }
m_Lines[m].m_Description.SetY( row.m_fY );
m_Lines[m].m_Meter.SetY( row.m_fY ); m_Lines[m].m_Meter.SetY( row.m_fY );
m_Lines[m].m_Number.SetY( row.m_fY );
} }
for( int m=0; m < MAX_METERS; ++m ) for( int m=0; m < MAX_METERS; ++m )
@@ -242,9 +223,7 @@ void DifficultyList::PositionItems()
float fDiffuseAlpha = bHidden?0.0f:1.0f; float fDiffuseAlpha = bHidden?0.0f:1.0f;
m_Lines[m].m_Description.SetDiffuseAlpha( fDiffuseAlpha );
m_Lines[m].m_Meter.SetDiffuseAlpha( fDiffuseAlpha ); m_Lines[m].m_Meter.SetDiffuseAlpha( fDiffuseAlpha );
m_Lines[m].m_Number.SetDiffuseAlpha( fDiffuseAlpha );
} }
@@ -275,8 +254,6 @@ void DifficultyList::SetFromGameState()
for( int m = 0; m < MAX_METERS; ++m ) for( int m = 0; m < MAX_METERS; ++m )
{ {
m_Lines[m].m_Meter.Unset(); m_Lines[m].m_Meter.Unset();
m_Lines[m].m_Number.SetText( "" );
m_Lines[m].m_Description.SetText( "" );
} }
m_Rows.clear(); m_Rows.clear();
@@ -297,12 +274,6 @@ void DifficultyList::SetFromGameState()
m_Lines[i].m_Meter.SetFromMeterAndDifficulty( 0, *d ); m_Lines[i].m_Meter.SetFromMeterAndDifficulty( 0, *d );
m_Lines[i].m_Description.SetText( GetDifficultyString(*d) );
m_Lines[i].m_Description.SetDiffuseColor( SONGMAN->GetDifficultyColor(*d) );
m_Lines[i].m_Number.SetDiffuseColor( SONGMAN->GetDifficultyColor(*d) );
m_Lines[i].m_Number.SetText( "?" );
i++; i++;
} }
} }
@@ -324,19 +295,6 @@ void DifficultyList::SetFromGameState()
m_Lines[i].m_Meter.SetFromSteps( m_Rows[i].m_Steps ); m_Lines[i].m_Meter.SetFromSteps( m_Rows[i].m_Steps );
row.m_dc = row.m_Steps->GetDifficulty(); row.m_dc = row.m_Steps->GetDifficulty();
CString s;
if( row.m_Steps->GetDifficulty() == DIFFICULTY_EDIT )
s = row.m_Steps->GetDescription();
else
s = GetDifficultyString(row.m_dc);
m_Lines[i].m_Description.SetMaxWidth( DESCRIPTION_MAX_WIDTH );
m_Lines[i].m_Description.SetText( s );
/* Don't mess with alpha; it might be fading on. */
m_Lines[i].m_Description.SetDiffuseColor( SONGMAN->GetDifficultyColor(row.m_dc) );
m_Lines[i].m_Number.SetDiffuseColor( SONGMAN->GetDifficultyColor(row.m_dc) );
m_Lines[i].m_Number.SetText( ssprintf("%d",row.m_Steps->GetMeter()) );
} }
} }
} }
@@ -347,11 +305,7 @@ void DifficultyList::SetFromGameState()
if( bSongChanged ) if( bSongChanged )
{ {
for( int m = 0; m < MAX_METERS; ++m ) for( int m = 0; m < MAX_METERS; ++m )
{
m_Lines[m].m_Meter.FinishTweening(); m_Lines[m].m_Meter.FinishTweening();
m_Lines[m].m_Description.FinishTweening();
m_Lines[m].m_Number.FinishTweening();
}
} }
} }
@@ -361,13 +315,8 @@ void DifficultyList::HideRows()
{ {
Line &l = m_Lines[m]; Line &l = m_Lines[m];
l.m_Description.FinishTweening();
l.m_Meter.FinishTweening(); l.m_Meter.FinishTweening();
l.m_Number.FinishTweening();
l.m_Description.SetDiffuseAlpha(0);
l.m_Meter.SetDiffuseAlpha(0); l.m_Meter.SetDiffuseAlpha(0);
l.m_Number.SetDiffuseAlpha(0);
} }
} }
@@ -379,20 +328,14 @@ void DifficultyList::TweenOnScreen()
{ {
Line &l = m_Lines[m]; Line &l = m_Lines[m];
l.m_Description.FinishTweening();
l.m_Meter.FinishTweening(); l.m_Meter.FinishTweening();
l.m_Number.FinishTweening();
} }
// PositionItems();
HideRows(); HideRows();
PositionItems(); PositionItems();
FOREACH_HumanPlayer( pn ) FOREACH_HumanPlayer( pn )
{
COMMAND( m_Cursors[pn], "TweenOn" ); COMMAND( m_Cursors[pn], "TweenOn" );
}
} }
void DifficultyList::TweenOffScreen() void DifficultyList::TweenOffScreen()
@@ -410,9 +353,7 @@ void DifficultyList::Show()
PositionItems(); PositionItems();
FOREACH_HumanPlayer( pn ) FOREACH_HumanPlayer( pn )
{
COMMAND( m_Cursors[pn], "Show" ); COMMAND( m_Cursors[pn], "Show" );
}
} }
void DifficultyList::Hide() void DifficultyList::Hide()
@@ -421,17 +362,7 @@ void DifficultyList::Hide()
PositionItems(); PositionItems();
FOREACH_HumanPlayer( pn ) FOREACH_HumanPlayer( pn )
{
COMMAND( m_Cursors[pn], "Hide" ); COMMAND( m_Cursors[pn], "Hide" );
}
}
CString DifficultyList::GetDifficultyString( Difficulty d ) const
{
CString s = DifficultyToThemedString( d );
if( CAPITALIZE_DIFFICULTY_NAMES )
s.MakeUpper();
return s;
} }
/* /*
-4
View File
@@ -30,10 +30,8 @@ private:
void PositionItems(); void PositionItems();
int GetCurrentRowIndex( PlayerNumber pn ) const; int GetCurrentRowIndex( PlayerNumber pn ) const;
void HideRows(); void HideRows();
CString GetDifficultyString( Difficulty d ) const;
ThemeMetric<float> ITEMS_SPACING_Y; ThemeMetric<float> ITEMS_SPACING_Y;
ThemeMetric<float> DESCRIPTION_MAX_WIDTH;
ThemeMetric<int> NUM_SHOWN_ITEMS; ThemeMetric<int> NUM_SHOWN_ITEMS;
ThemeMetric<bool> CAPITALIZE_DIFFICULTY_NAMES; ThemeMetric<bool> CAPITALIZE_DIFFICULTY_NAMES;
ThemeMetric<apActorCommands> MOVE_COMMAND; ThemeMetric<apActorCommands> MOVE_COMMAND;
@@ -44,8 +42,6 @@ private:
struct Line struct Line
{ {
DifficultyMeter m_Meter; DifficultyMeter m_Meter;
BitmapText m_Description;
BitmapText m_Number;
}; };
vector<Line> m_Lines; vector<Line> m_Lines;
+51 -19
View File
@@ -10,6 +10,7 @@
#include "SongManager.h" #include "SongManager.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include "Style.h" #include "Style.h"
#include "XmlFile.h"
// lua start // lua start
LUA_REGISTER_CLASS( DifficultyMeter ) LUA_REGISTER_CLASS( DifficultyMeter )
@@ -23,7 +24,7 @@ DifficultyMeter::DifficultyMeter()
static CString GetDifficultyCommandName( Difficulty d ) { return "Set"+DifficultyToString(d); } static CString GetDifficultyCommandName( Difficulty d ) { return "Set"+DifficultyToString(d); }
static CString GetCourseDifficultyCommandName( CourseDifficulty d ) { return "Set"+CourseDifficultyToString(d)+"Course"; } static CString GetCourseDifficultyCommandName( CourseDifficulty d ) { return "Set"+CourseDifficultyToString(d)+"Course"; }
static const CString DIFFICULTY_COMMAND_NAME_NONE = "None"; static const CString DIFFICULTY_COMMAND_NAME_NONE = "SetNone";
/* sID experiment: /* sID experiment:
* *
@@ -51,16 +52,14 @@ void DifficultyMeter::Load( const CString &sType )
{ {
/* We can't use global ThemeMetric<CString>s, because we can have multiple /* We can't use global ThemeMetric<CString>s, because we can have multiple
* DifficultyMeters on screen at once, with different names. */ * DifficultyMeters on screen at once, with different names. */
m_iNumFeetInMeter = THEME->GetMetricI(sType,"NumFeetInMeter"); m_iNumFeetInMeter.Load(sType,"NumFeetInMeter");
m_iMaxFeetInMeter = THEME->GetMetricI(sType,"MaxFeetInMeter"); m_iMaxFeetInMeter.Load(sType,"MaxFeetInMeter");
m_iGlowIfMeterGreaterThan = THEME->GetMetricI(sType,"GlowIfMeterGreaterThan"); m_iGlowIfMeterGreaterThan.Load(sType,"GlowIfMeterGreaterThan");
m_bShowFeet = THEME->GetMetricB(sType,"ShowFeet"); m_bShowFeet.Load(sType,"ShowFeet");
/* "easy", "hard" */ m_bShowDifficulty.Load(sType,"ShowDifficulty");
m_bShowDifficulty = THEME->GetMetricB(sType,"ShowDifficulty"); m_bShowMeter.Load(sType,"ShowMeter");
/* 3, 9 */ m_bShowEditDescription.Load(sType,"ShowEditDescription");
m_bShowMeter = THEME->GetMetricB(sType,"ShowMeter"); m_bFeetPerDifficulty.Load(sType,"FeetPerDifficulty");
m_bFeetIsDifficultyColor = THEME->GetMetricB(sType,"FeetIsDifficultyColor");
m_bFeetPerDifficulty = THEME->GetMetricB(sType,"FeetPerDifficulty");
if( m_bShowFeet ) if( m_bShowFeet )
{ {
@@ -106,10 +105,28 @@ void DifficultyMeter::Load( const CString &sType )
ActorUtil::LoadCommand( m_textMeter, sType, GetCourseDifficultyCommandName(d) ); ActorUtil::LoadCommand( m_textMeter, sType, GetCourseDifficultyCommandName(d) );
ActorUtil::LoadCommand( m_textMeter, sType, DIFFICULTY_COMMAND_NAME_NONE ); ActorUtil::LoadCommand( m_textMeter, sType, DIFFICULTY_COMMAND_NAME_NONE );
} }
if( m_bShowEditDescription )
{
m_textEditDescription.SetName( "EditDescription" );
m_textEditDescription.LoadFromFont( THEME->GetPathF(sType,"EditDescription") );
ActorUtil::SetXYAndOnCommand( m_textEditDescription, sType );
this->AddChild( &m_textEditDescription );
}
Unset(); Unset();
} }
void DifficultyMeter::LoadFromNode( const CString& sDir, const XNode* pNode )
{
ActorFrame::LoadFromNode( sDir, pNode );
CString s;
pNode->GetAttrValue( "Type", s );
ASSERT( s.size() );
Load( s );
}
void DifficultyMeter::SetFromGameState( PlayerNumber pn ) void DifficultyMeter::SetFromGameState( PlayerNumber pn )
{ {
if( GAMESTATE->IsCourseMode() ) if( GAMESTATE->IsCourseMode() )
@@ -138,8 +155,21 @@ void DifficultyMeter::SetFromSteps( const Steps* pSteps )
return; return;
} }
SetFromMeterAndDifficulty( pSteps->GetMeter(), pSteps->GetDifficulty() ); Difficulty dc = pSteps->GetDifficulty();
PlayDifficultyCommand( GetDifficultyCommandName( pSteps->GetDifficulty() ) ); SetFromMeterAndDifficulty( pSteps->GetMeter(), dc );
PlayDifficultyCommand( GetDifficultyCommandName( dc ) );
if( m_bShowEditDescription )
{
if( dc == DIFFICULTY_EDIT )
{
m_textEditDescription.SetVisible( true );
m_textEditDescription.SetText( pSteps->GetDescription() );
}
else
{
m_textEditDescription.SetVisible( false );
}
}
} }
void DifficultyMeter::SetFromTrail( const Trail* pTrail ) void DifficultyMeter::SetFromTrail( const Trail* pTrail )
@@ -150,14 +180,19 @@ void DifficultyMeter::SetFromTrail( const Trail* pTrail )
return; return;
} }
SetFromMeterAndDifficulty( pTrail->GetMeter(), pTrail->m_CourseDifficulty ); CourseDifficulty cd = pTrail->m_CourseDifficulty;
PlayDifficultyCommand( GetCourseDifficultyCommandName( pTrail->m_CourseDifficulty ) ); SetFromMeterAndDifficulty( pTrail->GetMeter(), cd );
PlayDifficultyCommand( GetCourseDifficultyCommandName( cd ) );
if( m_bShowEditDescription )
m_textEditDescription.SetVisible( false );
} }
void DifficultyMeter::Unset() void DifficultyMeter::Unset()
{ {
SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER );
PlayDifficultyCommand( DIFFICULTY_COMMAND_NAME_NONE ); PlayDifficultyCommand( DIFFICULTY_COMMAND_NAME_NONE );
if( m_bShowEditDescription )
m_textEditDescription.SetText("");
} }
void DifficultyMeter::SetFromDifficulty( Difficulty dc ) void DifficultyMeter::SetFromDifficulty( Difficulty dc )
@@ -182,7 +217,7 @@ void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc )
on = char(dc + '0'); on = char(dc + '0');
CString sNewText; CString sNewText;
int iNumOn = min( m_iMaxFeetInMeter, iMeter ); int iNumOn = min( (int)m_iMaxFeetInMeter, iMeter );
sNewText.insert( sNewText.end(), iNumOn, on ); sNewText.insert( sNewText.end(), iNumOn, on );
int iNumOff = max( 0, m_iNumFeetInMeter-iNumOn ); int iNumOff = max( 0, m_iNumFeetInMeter-iNumOn );
sNewText.insert( sNewText.end(), iNumOff, off ); sNewText.insert( sNewText.end(), iNumOff, off );
@@ -193,9 +228,6 @@ void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc )
m_textFeet.SetEffectGlowShift(); m_textFeet.SetEffectGlowShift();
else else
m_textFeet.SetEffectNone(); m_textFeet.SetEffectNone();
if( m_bFeetIsDifficultyColor )
m_textFeet.SetDiffuse( SONGMAN->GetDifficultyColor( dc ) );
} }
if( m_bShowMeter ) if( m_bShowMeter )
+16 -7
View File
@@ -10,6 +10,7 @@
#include "ActorUtil.h" #include "ActorUtil.h"
#include "Difficulty.h" #include "Difficulty.h"
#include "ActorFrame.h" #include "ActorFrame.h"
#include "ThemeMetric.h"
class Steps; class Steps;
class Trail; class Trail;
@@ -51,6 +52,9 @@ public:
DifficultyMeter(); DifficultyMeter();
void Load( const CString &sType ); void Load( const CString &sType );
void LoadFromNode( const CString& sDir, const XNode* pNode );
void SetFromGameState( PlayerNumber pn ); void SetFromGameState( PlayerNumber pn );
void SetFromMeterAndDifficulty( int iMeter, Difficulty dc ); void SetFromMeterAndDifficulty( int iMeter, Difficulty dc );
void SetFromSteps( const Steps* pSteps ); void SetFromSteps( const Steps* pSteps );
@@ -66,15 +70,20 @@ private:
void PlayDifficultyCommand( CString diff ); void PlayDifficultyCommand( CString diff );
BitmapText m_textFeet; BitmapText m_textFeet; // bar
CString m_sCurDifficultyCommand; CString m_sCurDifficultyCommand;
AutoActor m_Difficulty; AutoActor m_Difficulty; /* "easy", "hard" */
BitmapText m_textMeter; /* 3, 9 */
BitmapText m_textEditDescription;
BitmapText m_textMeter; ThemeMetric<int> m_iNumFeetInMeter;
ThemeMetric<int> m_iMaxFeetInMeter;
int m_iNumFeetInMeter, m_iMaxFeetInMeter, m_iGlowIfMeterGreaterThan; ThemeMetric<int> m_iGlowIfMeterGreaterThan;
bool m_bShowFeet, m_bShowDifficulty, m_bShowMeter, m_bFeetIsDifficultyColor, m_bFeetPerDifficulty; ThemeMetric<bool> m_bShowFeet;
ThemeMetric<bool> m_bShowDifficulty;
ThemeMetric<bool> m_bShowMeter;
ThemeMetric<bool> m_bShowEditDescription;
ThemeMetric<bool> m_bFeetPerDifficulty;
}; };
#endif #endif