SelectTypeToString, StringToSelectType, LayoutTypeToString, StringToLayoutType

This commit is contained in:
Glenn Maynard
2005-02-12 05:08:43 +00:00
parent 93b8ba48b6
commit ccc31cad7f
4 changed files with 48 additions and 25 deletions
+15
View File
@@ -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()
{
}
+10 -2
View File
@@ -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<CString> choices;
OptionRowDefinition(): name(""), bOneChoiceForAllPlayers(false), selectType(SELECT_ONE), layoutType(SHOW_ALL_IN_LINE) { }
+16 -16
View File
@@ -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<optline.choices.size(); c++ )
@@ -587,13 +587,13 @@ BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow, int iCh
int index = -1;
switch( row.m_RowDef.layoutType )
{
case OptionRowDefinition::SHOW_ONE_IN_LINE:
case SHOW_ONE_IN_LINE:
index = bOneChoice ? 0 : pn;
/* If only P2 is enabled, his selections will be in index 0. */
if( row.m_textItems.size() == 1 )
index = 0;
break;
case OptionRowDefinition::SHOW_ALL_IN_LINE:
case SHOW_ALL_IN_LINE:
index = iChoiceOnRow;
break;
default:
@@ -666,13 +666,13 @@ void ScreenOptions::PositionUnderlines()
{
vector<OptionsCursor*> &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; i<iNumUnderlines; i++ )
{
OptionsCursor& ul = *vpUnderlines[i];
int iChoiceWithFocus = (row.m_RowDef.layoutType == OptionRowDefinition::SHOW_ONE_IN_LINE) ? row.m_iChoiceInRowWithFocus[p] : i;
int iChoiceWithFocus = (row.m_RowDef.layoutType == SHOW_ONE_IN_LINE) ? row.m_iChoiceInRowWithFocus[p] : i;
/* Don't tween X movement and color changes. */
int iWidth, iX, iY;
@@ -801,7 +801,7 @@ void ScreenOptions::UpdateText( int iRow )
OptionRow &row = *m_Rows[iRow];
const OptionRowDefinition &data = row.m_RowDef;
if( !row.m_RowDef.layoutType == OptionRowDefinition::SHOW_ONE_IN_LINE )
if( !row.m_RowDef.layoutType == SHOW_ONE_IN_LINE )
return;
FOREACH_HumanPlayer( pn )
@@ -1216,7 +1216,7 @@ void ScreenOptions::MenuStart( PlayerNumber pn, const InputEventType selectType
}
// If this is a bFirstChoiceGoesDown, then if this is a multiselect row.
if( data.selectType == OptionRowDefinition::SELECT_MULTIPLE )
if( data.selectType == SELECT_MULTIPLE )
{
int iChoiceInRow = row.m_iChoiceInRowWithFocus[pn];
row.m_vbSelected[pn][iChoiceInRow] = !row.m_vbSelected[pn][iChoiceInRow];
@@ -1242,7 +1242,7 @@ void ScreenOptions::MenuStart( PlayerNumber pn, const InputEventType selectType
break;
case NAV_TOGGLE_THREE_KEY:
case NAV_TOGGLE_FIVE_KEY:
if( data.selectType != OptionRowDefinition::SELECT_MULTIPLE )
if( data.selectType != SELECT_MULTIPLE )
{
int iChoiceInRow = row.m_iChoiceInRowWithFocus[pn];
if( row.m_RowDef.bOneChoiceForAllPlayers )
@@ -1273,7 +1273,7 @@ void ScreenOptions::StoreFocus( PlayerNumber pn )
{
/* Long rows always put us in the center, so don't update the focus. */
const OptionRow &OptionRow = *m_Rows[m_iCurrentRow[pn]];
if( OptionRow.m_RowDef.layoutType == OptionRowDefinition::SHOW_ONE_IN_LINE )
if( OptionRow.m_RowDef.layoutType == SHOW_ONE_IN_LINE )
return;
int iWidth, iY;
@@ -1353,7 +1353,7 @@ void ScreenOptions::ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat )
}
else
{
if( optrow.selectType == OptionRowDefinition::SELECT_MULTIPLE )
if( optrow.selectType == SELECT_MULTIPLE )
; // do nothing. User must press Start to toggle the selection.
else
row.SetOneSelection( p, iNewChoiceWithFocus );
@@ -1368,7 +1368,7 @@ void ScreenOptions::ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat )
}
else
{
if( optrow.selectType == OptionRowDefinition::SELECT_MULTIPLE )
if( optrow.selectType == SELECT_MULTIPLE )
; // do nothing. User must press Start to toggle the selection.
else
row.SetOneSelection( pn, iNewChoiceWithFocus );
@@ -1417,7 +1417,7 @@ void ScreenOptions::MoveRow( PlayerNumber pn, int dir, bool Repeat )
{
case NAV_TOGGLE_THREE_KEY:
case NAV_TOGGLE_FIVE_KEY:
if( m_Rows[row]->m_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 )
+7 -7
View File
@@ -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] );