simplify: merge OptionsCursorPlus into OptionsCursor

This commit is contained in:
Chris Danford
2008-05-09 22:29:06 +00:00
parent 8a66c9b0f7
commit 28d81e635b
5 changed files with 73 additions and 80 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ void OptionRowType::Load( const RString &sMetricsGroup, Actor *pParent )
if( SHOW_UNDERLINES ) if( SHOW_UNDERLINES )
{ {
FOREACH_PlayerNumber( p ) FOREACH_PlayerNumber( p )
m_Underline[p].Load( "OptionsUnderline" + PlayerNumberToString(p) ); m_Underline[p].Load( "OptionsUnderline" + PlayerNumberToString(p), false );
} }
m_textTitle.LoadFromFont( THEME->GetPathF(sMetricsGroup,"title") ); m_textTitle.LoadFromFont( THEME->GetPathF(sMetricsGroup,"title") );
+37 -43
View File
@@ -6,10 +6,10 @@
OptionsCursor::OptionsCursor() OptionsCursor::OptionsCursor()
{ {
} m_iOriginalLeftX = 0;
m_iOriginalRightX = 0;
OptionsCursorPlus::OptionsCursorPlus() m_iOriginalCanGoLeftX = 0;
{ m_iOriginalCanGoRightX = 0;
} }
OptionsCursor::OptionsCursor( const OptionsCursor &cpy ): OptionsCursor::OptionsCursor( const OptionsCursor &cpy ):
@@ -17,26 +17,25 @@ OptionsCursor::OptionsCursor( const OptionsCursor &cpy ):
m_sprMiddle( cpy.m_sprMiddle ), m_sprMiddle( cpy.m_sprMiddle ),
m_sprLeft( cpy.m_sprLeft ), m_sprLeft( cpy.m_sprLeft ),
m_sprRight( cpy.m_sprRight ), m_sprRight( cpy.m_sprRight ),
m_sprCanGoLeft( cpy.m_sprCanGoLeft ),
m_sprCanGoRight( cpy.m_sprCanGoRight ),
m_iOriginalLeftX( cpy.m_iOriginalLeftX ), m_iOriginalLeftX( cpy.m_iOriginalLeftX ),
m_iOriginalRightX( cpy.m_iOriginalRightX ) m_iOriginalRightX( cpy.m_iOriginalRightX ),
m_iOriginalCanGoLeftX( cpy.m_iOriginalCanGoLeftX ),
m_iOriginalCanGoRightX( cpy.m_iOriginalCanGoRightX )
{ {
/* Re-add children, or m_SubActors will point to cpy's children and not our own. */ /* Re-add children, or m_SubActors will point to cpy's children and not our own. */
m_SubActors.clear(); m_SubActors.clear();
this->AddChild( m_sprMiddle ); this->AddChild( m_sprMiddle );
this->AddChild( m_sprLeft ); this->AddChild( m_sprLeft );
this->AddChild( m_sprRight ); this->AddChild( m_sprRight );
} if( m_sprCanGoLeft )
OptionsCursorPlus::OptionsCursorPlus( const OptionsCursorPlus &cpy ):
OptionsCursor( cpy ),
m_sprCanGoLeft( cpy.m_sprCanGoLeft ),
m_sprCanGoRight( cpy.m_sprCanGoRight )
{
this->AddChild( m_sprCanGoLeft ); this->AddChild( m_sprCanGoLeft );
if( m_sprCanGoRight )
this->AddChild( m_sprCanGoRight ); this->AddChild( m_sprCanGoRight );
} }
void OptionsCursor::Load( const RString &sMetricsGroup ) void OptionsCursor::Load( const RString &sMetricsGroup, bool bLoadCanGos )
{ {
#define LOAD_SPR( spr, name ) \ #define LOAD_SPR( spr, name ) \
spr.Load( THEME->GetPathG(sMetricsGroup,name) ); \ spr.Load( THEME->GetPathG(sMetricsGroup,name) ); \
@@ -47,32 +46,34 @@ void OptionsCursor::Load( const RString &sMetricsGroup )
LOAD_SPR( m_sprMiddle, "Middle" ); LOAD_SPR( m_sprMiddle, "Middle" );
LOAD_SPR( m_sprLeft, "Left" ); LOAD_SPR( m_sprLeft, "Left" );
LOAD_SPR( m_sprRight, "Right" ); LOAD_SPR( m_sprRight, "Right" );
if( bLoadCanGos )
{
LOAD_SPR( m_sprCanGoLeft, "CanGoLeft" );
LOAD_SPR( m_sprCanGoRight, "CanGoRight" );
}
#undef LOAD_SPR #undef LOAD_SPR
m_iOriginalLeftX = m_sprLeft->GetX(); m_iOriginalLeftX = m_sprLeft->GetX();
m_iOriginalRightX = m_sprRight->GetX(); m_iOriginalRightX = m_sprRight->GetX();
} if( bLoadCanGos )
{
void OptionsCursorPlus::Load( const RString &sMetricsGroup ) m_iOriginalCanGoLeftX = m_sprCanGoLeft->GetX();
{ m_iOriginalCanGoRightX = m_sprCanGoRight->GetX();
OptionsCursor::Load( sMetricsGroup ); }
m_sprCanGoLeft.Load( THEME->GetPathG(sMetricsGroup,"CanGoLeft") );
m_sprCanGoRight.Load( THEME->GetPathG(sMetricsGroup,"CanGoRight") );
this->AddChild( m_sprCanGoLeft );
this->AddChild( m_sprCanGoRight );
SetCanGo( false, false ); SetCanGo( false, false );
} }
void OptionsCursorPlus::SetCanGo( bool bCanGoLeft, bool bCanGoRight ) void OptionsCursor::SetCanGo( bool bCanGoLeft, bool bCanGoRight )
{ {
if( m_sprCanGoLeft )
{
m_sprCanGoLeft->EnableAnimation( bCanGoLeft ); m_sprCanGoLeft->EnableAnimation( bCanGoLeft );
m_sprCanGoRight->EnableAnimation( bCanGoRight ); m_sprCanGoRight->EnableAnimation( bCanGoRight );
m_sprCanGoLeft->SetDiffuse( bCanGoLeft ? RageColor(1,1,1,1) : RageColor(1,1,1,0) ); m_sprCanGoLeft->SetDiffuse( bCanGoLeft ? RageColor(1,1,1,1) : RageColor(1,1,1,0) );
m_sprCanGoRight->SetDiffuse( bCanGoRight ? RageColor(1,1,1,1) : RageColor(1,1,1,0) ); m_sprCanGoRight->SetDiffuse( bCanGoRight ? RageColor(1,1,1,1) : RageColor(1,1,1,0) );
}
} }
void OptionsCursor::StopTweening() void OptionsCursor::StopTweening()
@@ -82,14 +83,12 @@ void OptionsCursor::StopTweening()
m_sprMiddle->StopTweening(); m_sprMiddle->StopTweening();
m_sprLeft->StopTweening(); m_sprLeft->StopTweening();
m_sprRight->StopTweening(); m_sprRight->StopTweening();
}
void OptionsCursorPlus::StopTweening()
{
OptionsCursor::StopTweening();
if( m_sprCanGoLeft )
{
m_sprCanGoLeft->StopTweening(); m_sprCanGoLeft->StopTweening();
m_sprCanGoRight->StopTweening(); m_sprCanGoRight->StopTweening();
}
} }
void OptionsCursor::BeginTweening( float fSecs ) void OptionsCursor::BeginTweening( float fSecs )
@@ -99,14 +98,12 @@ void OptionsCursor::BeginTweening( float fSecs )
m_sprMiddle->BeginTweening( fSecs ); m_sprMiddle->BeginTweening( fSecs );
m_sprLeft->BeginTweening( fSecs ); m_sprLeft->BeginTweening( fSecs );
m_sprRight->BeginTweening( fSecs ); m_sprRight->BeginTweening( fSecs );
}
void OptionsCursorPlus::BeginTweening( float fSecs )
{
OptionsCursor::BeginTweening( fSecs );
if( m_sprCanGoLeft )
{
m_sprCanGoLeft->BeginTweening( fSecs ); m_sprCanGoLeft->BeginTweening( fSecs );
m_sprCanGoRight->BeginTweening( fSecs ); m_sprCanGoRight->BeginTweening( fSecs );
}
} }
void OptionsCursor::SetBarWidth( int iWidth ) void OptionsCursor::SetBarWidth( int iWidth )
@@ -117,14 +114,11 @@ void OptionsCursor::SetBarWidth( int iWidth )
m_sprLeft->SetX( m_iOriginalLeftX - fWidth/2 ); m_sprLeft->SetX( m_iOriginalLeftX - fWidth/2 );
m_sprRight->SetX( m_iOriginalRightX + fWidth/2 ); m_sprRight->SetX( m_iOriginalRightX + fWidth/2 );
} if( m_sprCanGoLeft )
{
void OptionsCursorPlus::SetBarWidth( int iWidth ) m_sprCanGoLeft->SetX( m_iOriginalCanGoLeftX - fWidth/2 );
{ m_sprCanGoRight->SetX( m_iOriginalCanGoRightX + fWidth/2 );
OptionsCursor::SetBarWidth( iWidth ); }
m_sprCanGoLeft->SetX( m_sprLeft->GetDestX() );
m_sprCanGoRight->SetX( m_sprRight->GetDestX() );
} }
int OptionsCursor::GetBarWidth() const int OptionsCursor::GetBarWidth() const
+8 -19
View File
@@ -14,38 +14,27 @@ public:
OptionsCursor(); OptionsCursor();
OptionsCursor( const OptionsCursor &cpy ); OptionsCursor( const OptionsCursor &cpy );
void Load( const RString &sMetricsGroup ); void Load( const RString &sMetricsGroup, bool bLoadCanGos );
void StopTweening(); void StopTweening();
void BeginTweening( float fSecs ); void BeginTweening( float fSecs );
void SetBarWidth( int iWidth ); void SetBarWidth( int iWidth );
int GetBarWidth() const; int GetBarWidth() const;
void SetCanGo( bool bCanGoLeft, bool bCanGoRight );
protected: protected:
AutoActor m_sprMiddle; AutoActor m_sprMiddle;
AutoActor m_sprLeft; AutoActor m_sprLeft;
AutoActor m_sprRight; AutoActor m_sprRight;
int m_iOriginalLeftX; // save the metrics-set X because it gets oblitterated on a call to SetBarWidth
int m_iOriginalRightX;
};
class OptionsCursorPlus : public OptionsCursor
{
public:
OptionsCursorPlus();
OptionsCursorPlus( const OptionsCursorPlus &cpy );
void Load( const RString &sMetricsGroup );
void StopTweening();
void BeginTweening( float fSecs );
void SetBarWidth( int iWidth );
void SetCanGo( bool bCanGoLeft, bool bCanGoRight );
protected:
AutoActor m_sprCanGoLeft; AutoActor m_sprCanGoLeft;
AutoActor m_sprCanGoRight; AutoActor m_sprCanGoRight;
// save the metrics-set X because it gets oblitterated on a call to SetBarWidth
int m_iOriginalLeftX;
int m_iOriginalRightX;
int m_iOriginalCanGoLeftX;
int m_iOriginalCanGoRightX;
}; };
#endif #endif
+15 -5
View File
@@ -134,7 +134,7 @@ void ScreenOptions::Init()
// init cursors // init cursors
FOREACH_PlayerNumber( p ) FOREACH_PlayerNumber( p )
{ {
m_Cursor[p].Load( "OptionsCursor" + PlayerNumberToString(p) ); m_Cursor[p].Load( "OptionsCursor" + PlayerNumberToString(p), true );
m_Cursor[p].SetName( "Cursor" ); m_Cursor[p].SetName( "Cursor" );
LOAD_ALL_COMMANDS( m_Cursor[p] ); LOAD_ALL_COMMANDS( m_Cursor[p] );
m_framePage.AddChild( &m_Cursor[p] ); m_framePage.AddChild( &m_Cursor[p] );
@@ -436,7 +436,7 @@ void ScreenOptions::PositionCursor( PlayerNumber pn )
int iWidth, iX, iY; int iWidth, iX, iY;
GetWidthXY( pn, iRow, iChoiceWithFocus, iWidth, iX, iY ); GetWidthXY( pn, iRow, iChoiceWithFocus, iWidth, iX, iY );
OptionsCursorPlus &cursor = m_Cursor[pn]; OptionsCursor &cursor = m_Cursor[pn];
cursor.SetBarWidth( iWidth ); cursor.SetBarWidth( iWidth );
cursor.SetXY( (float)iX, (float)iY ); cursor.SetXY( (float)iX, (float)iY );
bool bCanGoLeft = iChoiceWithFocus > 0; bool bCanGoLeft = iChoiceWithFocus > 0;
@@ -456,7 +456,7 @@ void ScreenOptions::TweenCursor( PlayerNumber pn )
int iWidth, iX, iY; int iWidth, iX, iY;
GetWidthXY( pn, iRow, iChoiceWithFocus, iWidth, iX, iY ); GetWidthXY( pn, iRow, iChoiceWithFocus, iWidth, iX, iY );
OptionsCursorPlus &cursor = m_Cursor[pn]; OptionsCursor &cursor = m_Cursor[pn];
if( cursor.GetDestX() != (float) iX || if( cursor.GetDestX() != (float) iX ||
cursor.GetDestY() != (float) iY || cursor.GetDestY() != (float) iY ||
cursor.GetBarWidth() != iWidth ) cursor.GetBarWidth() != iWidth )
@@ -468,10 +468,20 @@ void ScreenOptions::TweenCursor( PlayerNumber pn )
} }
bool bCanGoLeft = iChoiceWithFocus > 0; bool bCanGoLeft = false;
bool bCanGoRight = iChoiceWithFocus >= 0 && iChoiceWithFocus < (int) row.GetRowDef().m_vsChoices.size()-1; bool bCanGoRight = false;
switch( row.GetRowDef().m_layoutType )
{
case LAYOUT_SHOW_ONE_IN_ROW:
bCanGoLeft = iChoiceWithFocus > 0;
bCanGoRight = iChoiceWithFocus >= 0 && iChoiceWithFocus < (int) row.GetRowDef().m_vsChoices.size()-1;
break;
case LAYOUT_SHOW_ALL_IN_ROW:
break;
}
cursor.SetCanGo( bCanGoLeft, bCanGoRight ); cursor.SetCanGo( bCanGoLeft, bCanGoRight );
if( GAMESTATE->IsHumanPlayer(pn) ) if( GAMESTATE->IsHumanPlayer(pn) )
{ {
COMMAND( m_sprLineHighlight[pn], "Change" ); COMMAND( m_sprLineHighlight[pn], "Change" );
+1 -1
View File
@@ -114,7 +114,7 @@ protected: // derived classes need access to these
ActorFrame m_framePage; ActorFrame m_framePage;
AutoActor m_sprPage; AutoActor m_sprPage;
OptionsCursorPlus m_Cursor[NUM_PLAYERS]; OptionsCursor m_Cursor[NUM_PLAYERS];
AutoActor m_sprLineHighlight[NUM_PLAYERS]; AutoActor m_sprLineHighlight[NUM_PLAYERS];
BitmapText m_textExplanation[NUM_PLAYERS]; BitmapText m_textExplanation[NUM_PLAYERS];