save the Handler in OptionRow so a row can refresh itself without needing the Screen to Import/Export

This commit is contained in:
Chris Danford
2005-02-24 13:48:14 +00:00
parent ab22e629d4
commit fb4ab8886c
8 changed files with 34 additions and 19 deletions
+6 -1
View File
@@ -26,6 +26,8 @@ OptionRow::OptionRow()
this->AddChild( &m_OptionIcons[p] ); this->AddChild( &m_OptionIcons[p] );
this->AddChild( &m_sprBullet ); this->AddChild( &m_sprBullet );
this->AddChild( &m_textTitle ); this->AddChild( &m_textTitle );
m_pHand = NULL;
} }
OptionRow::~OptionRow() OptionRow::~OptionRow()
@@ -49,12 +51,15 @@ void OptionRow::Clear()
SAFE_DELETE( m_Underline[p][i] ); SAFE_DELETE( m_Underline[p][i] );
m_Underline[p].clear(); m_Underline[p].clear();
} }
m_pHand = NULL;
} }
void OptionRow::LoadNormal( const OptionRowDefinition &def ) void OptionRow::LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pHand )
{ {
m_RowDef = def; m_RowDef = def;
m_RowType = OptionRow::ROW_NORMAL; m_RowType = OptionRow::ROW_NORMAL;
m_pHand = pHand;
if( !def.choices.size() ) if( !def.choices.size() )
RageException::Throw( "Screen %s menu entry \"%s\" has no choices", RageException::Throw( "Screen %s menu entry \"%s\" has no choices",
+5 -2
View File
@@ -10,6 +10,7 @@
#include "ThemeMetric.h" #include "ThemeMetric.h"
class Font; class Font;
class OptionRowHandler;
enum SelectType enum SelectType
{ {
@@ -83,7 +84,7 @@ public:
~OptionRow(); ~OptionRow();
void Clear(); void Clear();
void LoadNormal( const OptionRowDefinition &def ); void LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pHand );
void LoadExit( void LoadExit(
const CString &sFontPath, const CString &sFontPath,
const CString &sExitText, const CString &sExitText,
@@ -136,9 +137,10 @@ public:
ROW_NORMAL, ROW_NORMAL,
ROW_EXIT ROW_EXIT
}; };
RowType GetRowType() const { return m_RowType; }
const OptionRowDefinition &GetRowDef() const { return m_RowDef; } const OptionRowDefinition &GetRowDef() const { return m_RowDef; }
OptionRowDefinition &GetRowDef() { return m_RowDef; } OptionRowDefinition &GetRowDef() { return m_RowDef; }
RowType GetRowType() const { return m_RowType; }
OptionRowHandler *GetHandler() { return m_pHand; }
BitmapText &GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow ); BitmapText &GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow );
void GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ); void GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut );
@@ -154,6 +156,7 @@ public:
protected: protected:
OptionRowDefinition m_RowDef; OptionRowDefinition m_RowDef;
RowType m_RowType; RowType m_RowType;
OptionRowHandler* m_pHand;
vector<BitmapText *> m_textItems; // size depends on m_bRowIsLong and which players are joined vector<BitmapText *> m_textItems; // size depends on m_bRowIsLong and which players are joined
vector<OptionsCursor *> m_Underline[NUM_PLAYERS]; // size depends on m_bRowIsLong and which players are joined vector<OptionsCursor *> m_Underline[NUM_PLAYERS]; // size depends on m_bRowIsLong and which players are joined
Sprite m_sprBullet; Sprite m_sprBullet;
+4 -4
View File
@@ -56,10 +56,10 @@ void ScreenNetworkOptions::Init()
g_NetworkOptionsLines[PO_SERVER].choices.push_back("Stop"); g_NetworkOptionsLines[PO_SERVER].choices.push_back("Stop");
g_NetworkOptionsLines[PO_SERVER].choices.push_back("Start..."); g_NetworkOptionsLines[PO_SERVER].choices.push_back("Start...");
InitMenu( vector<OptionRowDefinition> vDefs( &g_NetworkOptionsLines[0], &g_NetworkOptionsLines[ARRAYSIZE(g_NetworkOptionsLines)] );
INPUTMODE_SHARE_CURSOR, vector<OptionRowHandler*> vHands( vDefs.size(), NULL );
g_NetworkOptionsLines,
NUM_NETWORK_OPTIONS_LINES ); InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands );
SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") ); SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") );
} }
+6 -4
View File
@@ -150,22 +150,24 @@ void ScreenOptions::LoadOptionIcon( PlayerNumber pn, int iRow, CString sText )
m_Rows[iRow]->LoadOptionIcon( pn, sText ); m_Rows[iRow]->LoadOptionIcon( pn, sText );
} }
void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNumOptionLines, bool bShowUnderlines ) void ScreenOptions::InitMenu( InputMode im, const vector<OptionRowDefinition> &vDefs, const vector<OptionRowHandler*> &vHands, bool bShowUnderlines )
{ {
LOG->Trace( "ScreenOptions::Set()" ); LOG->Trace( "ScreenOptions::Set()" );
ASSERT( vDefs.size() == vHands.size() );
m_InputMode = im; m_InputMode = im;
m_bShowUnderlines = bShowUnderlines; m_bShowUnderlines = bShowUnderlines;
Font* pFont = FONT->LoadFont( THEME->GetPathF(m_sName,"item") ); Font* pFont = FONT->LoadFont( THEME->GetPathF(m_sName,"item") );
for( int r=0; r<iNumOptionLines; r++ ) // foreach row for( unsigned r=0; r<vDefs.size(); r++ ) // foreach row
{ {
m_Rows.push_back( new OptionRow() ); m_Rows.push_back( new OptionRow() );
OptionRow &row = *m_Rows.back(); OptionRow &row = *m_Rows.back();
row.LoadNormal( defs[r] ); row.LoadNormal( vDefs[r], vHands[r] );
this->ImportOptions( r ); this->ImportOptions( r );
@@ -1150,7 +1152,7 @@ void ScreenOptions::RefreshRowChoices( int r, const OptionRowDefinition &newdef
{ {
Font* pFont = FONT->LoadFont( THEME->GetPathF(m_sName,"item") ); Font* pFont = FONT->LoadFont( THEME->GetPathF(m_sName,"item") );
row.Clear(); row.Clear();
row.LoadNormal( newdef ); row.LoadNormal( newdef, row.GetHandler() );
row.AfterImportOptions( row.AfterImportOptions(
pFont, pFont,
ITEMS_START_X, ITEMS_START_X,
+2 -1
View File
@@ -10,6 +10,7 @@
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "OptionRow.h" #include "OptionRow.h"
class OptionRowHandler;
enum InputMode enum InputMode
{ {
@@ -23,7 +24,7 @@ class ScreenOptions : public ScreenWithMenuElements
public: public:
ScreenOptions( CString sClassName ); ScreenOptions( CString sClassName );
virtual void Init(); virtual void Init();
void InitMenu( InputMode im, OptionRowDefinition defs[], int iNumOptionLines, bool bShowUnderlines = true ); void InitMenu( InputMode im, const vector<OptionRowDefinition> &vDefs, const vector<OptionRowHandler*> &vHands, bool bShowUnderlines = true );
virtual ~ScreenOptions(); virtual ~ScreenOptions();
virtual void Update( float fDeltaTime ); virtual void Update( float fDeltaTime );
virtual void DrawPrimitives(); virtual void DrawPrimitives();
+3 -1
View File
@@ -105,7 +105,9 @@ void ScreenOptionsMaster::Init()
ASSERT( OptionRowHandlers.size() == asLineNames.size() ); ASSERT( OptionRowHandlers.size() == asLineNames.size() );
InitMenu( im, &m_OptionRowAlloc[0], asLineNames.size(), bShowUnderlines ); vector<OptionRowHandler*> vHands( m_OptionRowAlloc.size(), NULL );
InitMenu( im, m_OptionRowAlloc, vHands, bShowUnderlines );
} }
ScreenOptionsMaster::~ScreenOptionsMaster() ScreenOptionsMaster::~ScreenOptionsMaster()
+3 -4
View File
@@ -72,10 +72,9 @@ void ScreenProfileOptions::Init()
else else
g_ProfileOptionsLines[PO_OS_MOUNT_2].choices[0] = PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_2]; g_ProfileOptionsLines[PO_OS_MOUNT_2].choices[0] = PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_2];
InitMenu( vector<OptionRowDefinition> vDefs( &g_ProfileOptionsLines[0], &g_ProfileOptionsLines[ARRAYSIZE(g_ProfileOptionsLines)] );
INPUTMODE_SHARE_CURSOR, vector<OptionRowHandler*> vHands( vDefs.size(), NULL );
g_ProfileOptionsLines, InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands );
NUM_PROFILE_OPTIONS_LINES );
SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") ); SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") );
} }
+4 -1
View File
@@ -44,7 +44,10 @@ void ScreenSMOnlineLogin::Init()
} }
else else
{ {
InitMenu(INPUTMODE_SHARE_CURSOR, g_ProfileLine, 1); vector<OptionRowDefinition> vDefs( &g_ProfileLine[0], &g_ProfileLine[ARRAYSIZE(g_ProfileLine)] );
vector<OptionRowHandler*> vHands( vDefs.size(), NULL );
InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands );
SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions", "music")); SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions", "music"));
OptionRow &row = *m_Rows.back(); OptionRow &row = *m_Rows.back();
row.SetExitText("Login"); row.SetExitText("Login");