diff --git a/stepmania/src/OptionRow.cpp b/stepmania/src/OptionRow.cpp index 47d329c415..58abf3ec92 100644 --- a/stepmania/src/OptionRow.cpp +++ b/stepmania/src/OptionRow.cpp @@ -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() ); diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index 82efba34e1..1f28cdb4a6 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -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 m_textItems; // size depends on m_bRowIsLong and which players are joined vector m_Underline[NUM_PLAYERS]; // size depends on m_bRowIsLong and which players are joined Sprite m_sprBullet; diff --git a/stepmania/src/ScreenNetworkOptions.cpp b/stepmania/src/ScreenNetworkOptions.cpp index 8ff3f5c664..f0461ac44d 100644 --- a/stepmania/src/ScreenNetworkOptions.cpp +++ b/stepmania/src/ScreenNetworkOptions.cpp @@ -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 vDefs( &g_NetworkOptionsLines[0], &g_NetworkOptionsLines[ARRAYSIZE(g_NetworkOptionsLines)] ); + vector vHands( vDefs.size(), NULL ); + + InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands ); SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") ); } diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index 8f845acad5..4434f0a470 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -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 &vDefs, const vector &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; rImportOptions( 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, diff --git a/stepmania/src/ScreenOptions.h b/stepmania/src/ScreenOptions.h index 03fe7b1cb9..d72e38f4c7 100644 --- a/stepmania/src/ScreenOptions.h +++ b/stepmania/src/ScreenOptions.h @@ -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 &vDefs, const vector &vHands, bool bShowUnderlines = true ); virtual ~ScreenOptions(); virtual void Update( float fDeltaTime ); virtual void DrawPrimitives(); diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index fbdc68321e..f3e794ba76 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -105,7 +105,9 @@ void ScreenOptionsMaster::Init() ASSERT( OptionRowHandlers.size() == asLineNames.size() ); - InitMenu( im, &m_OptionRowAlloc[0], asLineNames.size(), bShowUnderlines ); + vector vHands( m_OptionRowAlloc.size(), NULL ); + + InitMenu( im, m_OptionRowAlloc, vHands, bShowUnderlines ); } ScreenOptionsMaster::~ScreenOptionsMaster() diff --git a/stepmania/src/ScreenProfileOptions.cpp b/stepmania/src/ScreenProfileOptions.cpp index 659a6588f2..cfd46295b9 100644 --- a/stepmania/src/ScreenProfileOptions.cpp +++ b/stepmania/src/ScreenProfileOptions.cpp @@ -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 vDefs( &g_ProfileOptionsLines[0], &g_ProfileOptionsLines[ARRAYSIZE(g_ProfileOptionsLines)] ); + vector vHands( vDefs.size(), NULL ); + InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands ); SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") ); } diff --git a/stepmania/src/ScreenSMOnlineLogin.cpp b/stepmania/src/ScreenSMOnlineLogin.cpp index 5e54133974..ed9489e38d 100644 --- a/stepmania/src/ScreenSMOnlineLogin.cpp +++ b/stepmania/src/ScreenSMOnlineLogin.cpp @@ -44,7 +44,10 @@ void ScreenSMOnlineLogin::Init() } else { - InitMenu(INPUTMODE_SHARE_CURSOR, g_ProfileLine, 1); + vector vDefs( &g_ProfileLine[0], &g_ProfileLine[ARRAYSIZE(g_ProfileLine)] ); + vector vHands( vDefs.size(), NULL ); + + InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands ); SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions", "music")); OptionRow &row = *m_Rows.back(); row.SetExitText("Login");