From 3583209f3256dd8266b91e1a1beb223d1e9cb0ec Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 10 Jan 2004 04:35:30 +0000 Subject: [PATCH] Make a OptionRow own its own definition --- stepmania/src/ScreenOptions.cpp | 39 +++++++++++++-------------- stepmania/src/ScreenOptions.h | 9 ++++--- stepmania/src/ScreenOptionsMaster.cpp | 19 +++++++------ 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index fd8b4e6085..90608b5ba8 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -123,15 +123,19 @@ void ScreenOptions::Init( InputMode im, OptionRow OptionRows[], int iNumOptionLi LOG->Trace( "ScreenOptions::Set()" ); m_InputMode = im; - m_OptionRow = OptionRows; - m_iNumOptionRows = iNumOptionLines; this->ImportOptions(); - for( int l=0; lm_RowDef = OptionRows[r]; + if( m_Rows[r]->m_RowDef.bOneChoiceForAllPlayers ) + for( int p=1; pIsHumanPlayer(p) ) continue; // skip - for( int l=0; l & textItems = row.m_textItems; - const OptionRow &optline = m_OptionRow[r]; + const OptionRow &optline = m_Rows[r]->m_RowDef; unsigned c; @@ -382,7 +381,7 @@ CString ScreenOptions::GetExplanationText( int iRow ) const if( m_Rows[iRow]->Type == Row::ROW_EXIT ) return ""; - CString sLineName = m_OptionRow[iRow].name; + CString sLineName = m_Rows[iRow]->m_RowDef.name; sLineName.Replace("\n-",""); sLineName.Replace("\n",""); sLineName.Replace(" ",""); @@ -394,7 +393,7 @@ CString ScreenOptions::GetExplanationTitle( int iRow ) const if( m_Rows[iRow]->Type == Row::ROW_EXIT ) return ""; - CString sLineName = m_OptionRow[iRow].name; + CString sLineName = m_Rows[iRow]->m_RowDef.name; sLineName.Replace("\n-",""); sLineName.Replace("\n",""); sLineName.Replace(" ",""); @@ -429,7 +428,7 @@ BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow ) return *row.m_textItems[iOptionInRow]; } - const bool bOneChoice = m_OptionRow[iRow].bOneChoiceForAllPlayers; + const bool bOneChoice = m_Rows[iRow]->m_RowDef.bOneChoiceForAllPlayers; if( bOneChoice ) return *row.m_textItems[0]; @@ -510,7 +509,7 @@ void ScreenOptions::PositionUnderlines() // If there's only one choice (ScreenOptionsMenu), don't show underlines. // It looks silly. - bool bOnlyOneChoice = m_OptionRow[i].choices.size() == 1; + bool bOnlyOneChoice = m_Rows[i]->m_RowDef.choices.size() == 1; bool hidden = bOnlyOneChoice || row.m_bHidden; if( underline.GetDestY() != row.m_fY ) @@ -618,14 +617,14 @@ void ScreenOptions::UpdateText( PlayerNumber player_no, int iRow ) int iChoiceInRow = m_iSelectedOption[player_no][iRow]; - const OptionRow &optrow = m_OptionRow[iRow]; + const OptionRow &optrow = m_Rows[iRow]->m_RowDef; unsigned item_no = optrow.bOneChoiceForAllPlayers?0:player_no; /* If player_no is 2 and there is no player 1: */ item_no = min( item_no, m_Rows[iRow]->m_textItems.size()-1 ); - m_Rows[iRow]->m_textItems[item_no]->SetText( m_OptionRow[iRow].choices[iChoiceInRow] ); + m_Rows[iRow]->m_textItems[item_no]->SetText( m_Rows[iRow]->m_RowDef.choices[iChoiceInRow] ); } void ScreenOptions::UpdateEnabledDisabled() @@ -1014,7 +1013,7 @@ void ScreenOptions::ChangeValue( PlayerNumber pn, int iDelta, bool Repeat ) { const int iCurRow = m_iCurrentRow[pn]; Row &row = *m_Rows[iCurRow]; - OptionRow &optrow = m_OptionRow[iCurRow]; + OptionRow &optrow = m_Rows[iCurRow]->m_RowDef; /* If START is being pressed, and in NAV_THREE_KEY, then we're holding left/right * and start to move backwards. Don't move left and right, too. */ diff --git a/stepmania/src/ScreenOptions.h b/stepmania/src/ScreenOptions.h index 058c4fcd10..d8ab2cd99e 100644 --- a/stepmania/src/ScreenOptions.h +++ b/stepmania/src/ScreenOptions.h @@ -30,8 +30,9 @@ struct OptionRow CString name; bool bOneChoiceForAllPlayers; vector choices; + bool bMultiSelect; - OptionRow(): name(""), bOneChoiceForAllPlayers(false) { } + OptionRow(): name(""), bOneChoiceForAllPlayers(false), bMultiSelect(false) { } OptionRow( const char *n, int b, const char *c0=NULL, const char *c1=NULL, const char *c2=NULL, const char *c3=NULL, const char *c4=NULL, const char *c5=NULL, const char *c6=NULL, const char *c7=NULL, const char *c8=NULL, const char *c9=NULL, const char *c10=NULL, const char *c11=NULL, const char *c12=NULL, const char *c13=NULL, const char *c14=NULL, const char *c15=NULL, const char *c16=NULL, const char *c17=NULL, const char *c18=NULL, const char *c19=NULL ) { @@ -40,6 +41,7 @@ struct OptionRow #define PUSH( c ) if(c) choices.push_back(c); PUSH(c0);PUSH(c1);PUSH(c2);PUSH(c3);PUSH(c4);PUSH(c5);PUSH(c6);PUSH(c7);PUSH(c8);PUSH(c9);PUSH(c10);PUSH(c11);PUSH(c12);PUSH(c13);PUSH(c14);PUSH(c15);PUSH(c16);PUSH(c17);PUSH(c18);PUSH(c19); #undef PUSH + bMultiSelect = false; } }; @@ -98,22 +100,21 @@ protected: int GetCurrentRow(PlayerNumber pn = PLAYER_1) const; MenuElements m_Menu; - OptionRow* m_OptionRow; protected: // derived classes need access to these int m_iSelectedOption[NUM_PLAYERS][MAX_OPTION_LINES]; - int m_iNumOptionRows; void LoadOptionIcon( PlayerNumber pn, int iRow, CString sText ); enum Navigation { NAV_THREE_KEY, NAV_THREE_KEY_MENU, NAV_FIVE_KEY }; void SetNavigation( Navigation nav ) { m_OptionsNavigation = nav; } -private: +protected: /* Map menu lines to m_OptionRow entries. */ struct Row { Row(); ~Row(); + OptionRow m_RowDef; enum { ROW_NORMAL, ROW_EXIT } Type; vector m_textItems; Sprite m_sprBullet; diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index ed08b55231..9d22090fb0 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -571,27 +571,30 @@ void ScreenOptionsMaster::GoToPrevState() void ScreenOptionsMaster::RefreshIcons() { - ASSERT( m_iNumOptionRows < (int) MAX_OPTION_LINES ); + ASSERT( m_Rows.size() < MAX_OPTION_LINES ); for( int p=0; pIsHumanPlayer(p) ) continue; - for( int i=0; iType == Row::ROW_EXIT ) + continue; // skip + + const OptionRow &row = m_Rows[i]->m_RowDef; int iSelection = m_iSelectedOption[p][i]; - if( iSelection >= (int)m_OptionRow[i].choices.size() ) + if( iSelection >= (int)row.choices.size() ) { /* Invalid selection. Send debug output, to aid debugging. */ CString error = ssprintf("Option row with name '%s' selects item %i, but there are only %i items:\n", - m_OptionRow[i].name.c_str(), - iSelection, (int) m_OptionRow[i].choices.size() ); + row.name.c_str(), + iSelection, (int) row.choices.size() ); - for( unsigned j = 0; j < m_OptionRow[i].choices.size(); ++j ) - error += ssprintf(" %s\n", m_OptionRow[i].choices[j].c_str()); + for( unsigned j = 0; j < row.choices.size(); ++j ) + error += ssprintf(" %s\n", row.choices[j].c_str()); RageException::Throw( "%s", error.c_str() ); }