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
+7 -2
View File
@@ -26,6 +26,8 @@ OptionRow::OptionRow()
this->AddChild( &m_OptionIcons[p] );
this->AddChild( &m_sprBullet );
this->AddChild( &m_textTitle );
m_pHand = NULL;
}
OptionRow::~OptionRow()
@@ -49,13 +51,16 @@ void OptionRow::Clear()
SAFE_DELETE( m_Underline[p][i] );
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_RowType = OptionRow::ROW_NORMAL;
m_pHand = pHand;
if( !def.choices.size() )
RageException::Throw( "Screen %s menu entry \"%s\" has no choices",
m_sName.c_str(), def.name.c_str() );
+5 -2
View File
@@ -10,6 +10,7 @@
#include "ThemeMetric.h"
class Font;
class OptionRowHandler;
enum SelectType
{
@@ -83,7 +84,7 @@ public:
~OptionRow();
void Clear();
void LoadNormal( const OptionRowDefinition &def );
void LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pHand );
void LoadExit(
const CString &sFontPath,
const CString &sExitText,
@@ -136,9 +137,10 @@ public:
ROW_NORMAL,
ROW_EXIT
};
RowType GetRowType() const { return m_RowType; }
const OptionRowDefinition &GetRowDef() const { 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 );
void GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut );
@@ -154,6 +156,7 @@ public:
protected:
OptionRowDefinition m_RowDef;
RowType m_RowType;
OptionRowHandler* m_pHand;
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
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("Start...");
InitMenu(
INPUTMODE_SHARE_CURSOR,
g_NetworkOptionsLines,
NUM_NETWORK_OPTIONS_LINES );
vector<OptionRowDefinition> vDefs( &g_NetworkOptionsLines[0], &g_NetworkOptionsLines[ARRAYSIZE(g_NetworkOptionsLines)] );
vector<OptionRowHandler*> vHands( vDefs.size(), NULL );
InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands );
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 );
}
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()" );
ASSERT( vDefs.size() == vHands.size() );
m_InputMode = im;
m_bShowUnderlines = bShowUnderlines;
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() );
OptionRow &row = *m_Rows.back();
row.LoadNormal( defs[r] );
row.LoadNormal( vDefs[r], vHands[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") );
row.Clear();
row.LoadNormal( newdef );
row.LoadNormal( newdef, row.GetHandler() );
row.AfterImportOptions(
pFont,
ITEMS_START_X,
+2 -1
View File
@@ -10,6 +10,7 @@
#include "ThemeMetric.h"
#include "OptionRow.h"
class OptionRowHandler;
enum InputMode
{
@@ -23,7 +24,7 @@ class ScreenOptions : public ScreenWithMenuElements
public:
ScreenOptions( CString sClassName );
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 void Update( float fDeltaTime );
virtual void DrawPrimitives();
+3 -1
View File
@@ -105,7 +105,9 @@ void ScreenOptionsMaster::Init()
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()
+3 -4
View File
@@ -72,10 +72,9 @@ void ScreenProfileOptions::Init()
else
g_ProfileOptionsLines[PO_OS_MOUNT_2].choices[0] = PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_2];
InitMenu(
INPUTMODE_SHARE_CURSOR,
g_ProfileOptionsLines,
NUM_PROFILE_OPTIONS_LINES );
vector<OptionRowDefinition> vDefs( &g_ProfileOptionsLines[0], &g_ProfileOptionsLines[ARRAYSIZE(g_ProfileOptionsLines)] );
vector<OptionRowHandler*> vHands( vDefs.size(), NULL );
InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands );
SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") );
}
+4 -1
View File
@@ -44,7 +44,10 @@ void ScreenSMOnlineLogin::Init()
}
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"));
OptionRow &row = *m_Rows.back();
row.SetExitText("Login");