From ccc31cad7fa3edd8d5ed40c49521b402f46b5d05 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 12 Feb 2005 05:08:43 +0000 Subject: [PATCH] SelectTypeToString, StringToSelectType, LayoutTypeToString, StringToLayoutType --- stepmania/src/OptionRow.cpp | 15 +++++++++++++ stepmania/src/OptionRow.h | 12 ++++++++-- stepmania/src/ScreenOptions.cpp | 32 +++++++++++++-------------- stepmania/src/ScreenOptionsMaster.cpp | 14 ++++++------ 4 files changed, 48 insertions(+), 25 deletions(-) diff --git a/stepmania/src/OptionRow.cpp b/stepmania/src/OptionRow.cpp index 3d7090a40d..df5ac3c29d 100644 --- a/stepmania/src/OptionRow.cpp +++ b/stepmania/src/OptionRow.cpp @@ -2,6 +2,21 @@ #include "OptionRow.h" #include "RageUtil.h" +static const CString SelectTypeNames[NUM_SELECT_TYPES] = { + "SelectOne", + "SelectMultiple", + "SelectNone", +}; +XToString( SelectType ); +StringToX( SelectType ); + +static const CString LayoutTypeNames[NUM_LAYOUT_TYPES] = { + "ShowAllInLine", + "ShowOneLine", +}; +XToString( LayoutType ); +StringToX( LayoutType ); + OptionRow::OptionRow() { } diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index 55d4c32c33..32b12f023b 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -8,12 +8,20 @@ #include "OptionsCursor.h" #include "OptionIcon.h" +enum SelectType { SELECT_ONE, SELECT_MULTIPLE, SELECT_NONE, NUM_SELECT_TYPES, SELECT_INVALID }; +const CString& SelectTypeToString( SelectType pm ); +SelectType StringToSelectType( const CString& s ); + +enum LayoutType { SHOW_ALL_IN_LINE, SHOW_ONE_IN_LINE, NUM_LAYOUT_TYPES, LAYOUT_INVALID }; +const CString& LayoutTypeToString( LayoutType pm ); +LayoutType StringToLayoutType( const CString& s ); + struct OptionRowDefinition { CString name; bool bOneChoiceForAllPlayers; - enum SelectType { SELECT_ONE, SELECT_MULTIPLE, SELECT_NONE } selectType; - enum LayoutType { SHOW_ALL_IN_LINE, SHOW_ONE_IN_LINE } layoutType; + enum SelectType selectType; + enum LayoutType layoutType; vector choices; OptionRowDefinition(): name(""), bOneChoiceForAllPlayers(false), selectType(SELECT_ONE), layoutType(SHOW_ALL_IN_LINE) { } diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index ebf48d5919..adc8e7a8f6 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -167,7 +167,7 @@ void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNum vbSelected[j] = false; // set select the first item if a SELECT_ONE row - if( row.m_RowDef.selectType == OptionRowDefinition::SELECT_ONE ) + if( row.m_RowDef.selectType == SELECT_ONE ) vbSelected[0] = true; } } @@ -195,7 +195,7 @@ void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNum { row.m_iChoiceInRowWithFocus[p] = 0; // focus on the first row, which is "go down" } - else if( row.m_RowDef.selectType == OptionRowDefinition::SELECT_ONE ) + else if( row.m_RowDef.selectType == SELECT_ONE ) { /* Make sure the row actually has a selection. */ bool bHasSelection = false; @@ -284,7 +284,7 @@ void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNum if( fX > ITEMS_END_X ) { - row.m_RowDef.layoutType = OptionRowDefinition::SHOW_ONE_IN_LINE; + row.m_RowDef.layoutType = SHOW_ONE_IN_LINE; break; } } @@ -292,7 +292,7 @@ void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNum switch( row.m_RowDef.layoutType ) { - case OptionRowDefinition::SHOW_ONE_IN_LINE: + case SHOW_ONE_IN_LINE: // init text FOREACH_HumanPlayer( p ) { @@ -330,7 +330,7 @@ void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNum } break; - case OptionRowDefinition::SHOW_ALL_IN_LINE: + case SHOW_ALL_IN_LINE: { float fX = ITEMS_START_X; for( unsigned c=0; c &vpUnderlines = row.m_Underline[p]; - const int iNumUnderlines = (row.m_RowDef.layoutType == OptionRowDefinition::SHOW_ONE_IN_LINE) ? 1 : vpUnderlines.size(); + const int iNumUnderlines = (row.m_RowDef.layoutType == SHOW_ONE_IN_LINE) ? 1 : vpUnderlines.size(); for( int i=0; im_RowDef.layoutType != OptionRowDefinition::SHOW_ONE_IN_LINE ) + if( m_Rows[row]->m_RowDef.layoutType != SHOW_ONE_IN_LINE ) { int iSelectionDist = -1; for( unsigned i = 0; i < m_Rows[row]->m_textItems.size(); ++i ) diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index a4c346643b..4d6d13aafc 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -77,9 +77,9 @@ void ScreenOptionsMaster::SetList( OptionRowDefinition &row, OptionRowHandler &h if( asParts[i].CompareNoCase("together") == 0 ) row.bOneChoiceForAllPlayers = true; else if( asParts[i].CompareNoCase("SelectMultiple") == 0 ) - row.selectType = OptionRowDefinition::SELECT_MULTIPLE; + row.selectType = SELECT_MULTIPLE; else if( asParts[i].CompareNoCase("SelectNone") == 0 ) - row.selectType = OptionRowDefinition::SELECT_NONE; + row.selectType = SELECT_NONE; } for( int col = 0; col < NumCols; ++col ) @@ -414,7 +414,7 @@ void ScreenOptionsMaster::ImportOption( const OptionRowDefinition &row, const Op /* The entry has no effect. This is usually a default "none of the * above" entry. It will always return true for DescribesCurrentMode(). * It's only the selected choice if nothing else matches. */ - if( row.selectType != OptionRowDefinition::SELECT_MULTIPLE ) + if( row.selectType != SELECT_MULTIPLE ) FallbackOption = e; continue; } @@ -424,7 +424,7 @@ void ScreenOptionsMaster::ImportOption( const OptionRowDefinition &row, const Op if( mc.DescribesCurrentModeForAllPlayers() ) { UseFallbackOption = false; - if( row.selectType != OptionRowDefinition::SELECT_MULTIPLE ) + if( row.selectType != SELECT_MULTIPLE ) SelectExactlyOne( e, vbSelectedOut ); else vbSelectedOut[e] = true; @@ -435,7 +435,7 @@ void ScreenOptionsMaster::ImportOption( const OptionRowDefinition &row, const Op if( mc.DescribesCurrentMode( pn) ) { UseFallbackOption = false; - if( row.selectType != OptionRowDefinition::SELECT_MULTIPLE ) + if( row.selectType != SELECT_MULTIPLE ) SelectExactlyOne( e, vbSelectedOut ); else vbSelectedOut[e] = true; @@ -443,7 +443,7 @@ void ScreenOptionsMaster::ImportOption( const OptionRowDefinition &row, const Op } } - if( row.selectType == OptionRowDefinition::SELECT_ONE && + if( row.selectType == SELECT_ONE && UseFallbackOption && FallbackOption != -1 ) { @@ -464,7 +464,7 @@ void ScreenOptionsMaster::ImportOption( const OptionRowDefinition &row, const Op ASSERT(0); } - if( row.selectType != OptionRowDefinition::SELECT_MULTIPLE ) + if( row.selectType != SELECT_MULTIPLE ) { // The first row ("go down") should not be selected. ASSERT( !vbSelectedOut[0] );