SelectTypeToString, StringToSelectType, LayoutTypeToString, StringToLayoutType
This commit is contained in:
@@ -2,6 +2,21 @@
|
|||||||
#include "OptionRow.h"
|
#include "OptionRow.h"
|
||||||
#include "RageUtil.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()
|
OptionRow::OptionRow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,20 @@
|
|||||||
#include "OptionsCursor.h"
|
#include "OptionsCursor.h"
|
||||||
#include "OptionIcon.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
|
struct OptionRowDefinition
|
||||||
{
|
{
|
||||||
CString name;
|
CString name;
|
||||||
bool bOneChoiceForAllPlayers;
|
bool bOneChoiceForAllPlayers;
|
||||||
enum SelectType { SELECT_ONE, SELECT_MULTIPLE, SELECT_NONE } selectType;
|
enum SelectType selectType;
|
||||||
enum LayoutType { SHOW_ALL_IN_LINE, SHOW_ONE_IN_LINE } layoutType;
|
enum LayoutType layoutType;
|
||||||
vector<CString> choices;
|
vector<CString> choices;
|
||||||
|
|
||||||
OptionRowDefinition(): name(""), bOneChoiceForAllPlayers(false), selectType(SELECT_ONE), layoutType(SHOW_ALL_IN_LINE) { }
|
OptionRowDefinition(): name(""), bOneChoiceForAllPlayers(false), selectType(SELECT_ONE), layoutType(SHOW_ALL_IN_LINE) { }
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNum
|
|||||||
vbSelected[j] = false;
|
vbSelected[j] = false;
|
||||||
|
|
||||||
// set select the first item if a SELECT_ONE row
|
// 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;
|
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"
|
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. */
|
/* Make sure the row actually has a selection. */
|
||||||
bool bHasSelection = false;
|
bool bHasSelection = false;
|
||||||
@@ -284,7 +284,7 @@ void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNum
|
|||||||
|
|
||||||
if( fX > ITEMS_END_X )
|
if( fX > ITEMS_END_X )
|
||||||
{
|
{
|
||||||
row.m_RowDef.layoutType = OptionRowDefinition::SHOW_ONE_IN_LINE;
|
row.m_RowDef.layoutType = SHOW_ONE_IN_LINE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,7 @@ void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNum
|
|||||||
|
|
||||||
switch( row.m_RowDef.layoutType )
|
switch( row.m_RowDef.layoutType )
|
||||||
{
|
{
|
||||||
case OptionRowDefinition::SHOW_ONE_IN_LINE:
|
case SHOW_ONE_IN_LINE:
|
||||||
// init text
|
// init text
|
||||||
FOREACH_HumanPlayer( p )
|
FOREACH_HumanPlayer( p )
|
||||||
{
|
{
|
||||||
@@ -330,7 +330,7 @@ void ScreenOptions::InitMenu( InputMode im, OptionRowDefinition defs[], int iNum
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionRowDefinition::SHOW_ALL_IN_LINE:
|
case SHOW_ALL_IN_LINE:
|
||||||
{
|
{
|
||||||
float fX = ITEMS_START_X;
|
float fX = ITEMS_START_X;
|
||||||
for( unsigned c=0; c<optline.choices.size(); c++ )
|
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;
|
int index = -1;
|
||||||
switch( row.m_RowDef.layoutType )
|
switch( row.m_RowDef.layoutType )
|
||||||
{
|
{
|
||||||
case OptionRowDefinition::SHOW_ONE_IN_LINE:
|
case SHOW_ONE_IN_LINE:
|
||||||
index = bOneChoice ? 0 : pn;
|
index = bOneChoice ? 0 : pn;
|
||||||
/* If only P2 is enabled, his selections will be in index 0. */
|
/* If only P2 is enabled, his selections will be in index 0. */
|
||||||
if( row.m_textItems.size() == 1 )
|
if( row.m_textItems.size() == 1 )
|
||||||
index = 0;
|
index = 0;
|
||||||
break;
|
break;
|
||||||
case OptionRowDefinition::SHOW_ALL_IN_LINE:
|
case SHOW_ALL_IN_LINE:
|
||||||
index = iChoiceOnRow;
|
index = iChoiceOnRow;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -666,13 +666,13 @@ void ScreenOptions::PositionUnderlines()
|
|||||||
{
|
{
|
||||||
vector<OptionsCursor*> &vpUnderlines = row.m_Underline[p];
|
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++ )
|
for( int i=0; i<iNumUnderlines; i++ )
|
||||||
{
|
{
|
||||||
OptionsCursor& ul = *vpUnderlines[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. */
|
/* Don't tween X movement and color changes. */
|
||||||
int iWidth, iX, iY;
|
int iWidth, iX, iY;
|
||||||
@@ -801,7 +801,7 @@ void ScreenOptions::UpdateText( int iRow )
|
|||||||
OptionRow &row = *m_Rows[iRow];
|
OptionRow &row = *m_Rows[iRow];
|
||||||
const OptionRowDefinition &data = row.m_RowDef;
|
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;
|
return;
|
||||||
|
|
||||||
FOREACH_HumanPlayer( pn )
|
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 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];
|
int iChoiceInRow = row.m_iChoiceInRowWithFocus[pn];
|
||||||
row.m_vbSelected[pn][iChoiceInRow] = !row.m_vbSelected[pn][iChoiceInRow];
|
row.m_vbSelected[pn][iChoiceInRow] = !row.m_vbSelected[pn][iChoiceInRow];
|
||||||
@@ -1242,7 +1242,7 @@ void ScreenOptions::MenuStart( PlayerNumber pn, const InputEventType selectType
|
|||||||
break;
|
break;
|
||||||
case NAV_TOGGLE_THREE_KEY:
|
case NAV_TOGGLE_THREE_KEY:
|
||||||
case NAV_TOGGLE_FIVE_KEY:
|
case NAV_TOGGLE_FIVE_KEY:
|
||||||
if( data.selectType != OptionRowDefinition::SELECT_MULTIPLE )
|
if( data.selectType != SELECT_MULTIPLE )
|
||||||
{
|
{
|
||||||
int iChoiceInRow = row.m_iChoiceInRowWithFocus[pn];
|
int iChoiceInRow = row.m_iChoiceInRowWithFocus[pn];
|
||||||
if( row.m_RowDef.bOneChoiceForAllPlayers )
|
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. */
|
/* Long rows always put us in the center, so don't update the focus. */
|
||||||
const OptionRow &OptionRow = *m_Rows[m_iCurrentRow[pn]];
|
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;
|
return;
|
||||||
|
|
||||||
int iWidth, iY;
|
int iWidth, iY;
|
||||||
@@ -1353,7 +1353,7 @@ void ScreenOptions::ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( optrow.selectType == OptionRowDefinition::SELECT_MULTIPLE )
|
if( optrow.selectType == SELECT_MULTIPLE )
|
||||||
; // do nothing. User must press Start to toggle the selection.
|
; // do nothing. User must press Start to toggle the selection.
|
||||||
else
|
else
|
||||||
row.SetOneSelection( p, iNewChoiceWithFocus );
|
row.SetOneSelection( p, iNewChoiceWithFocus );
|
||||||
@@ -1368,7 +1368,7 @@ void ScreenOptions::ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( optrow.selectType == OptionRowDefinition::SELECT_MULTIPLE )
|
if( optrow.selectType == SELECT_MULTIPLE )
|
||||||
; // do nothing. User must press Start to toggle the selection.
|
; // do nothing. User must press Start to toggle the selection.
|
||||||
else
|
else
|
||||||
row.SetOneSelection( pn, iNewChoiceWithFocus );
|
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_THREE_KEY:
|
||||||
case NAV_TOGGLE_FIVE_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;
|
int iSelectionDist = -1;
|
||||||
for( unsigned i = 0; i < m_Rows[row]->m_textItems.size(); ++i )
|
for( unsigned i = 0; i < m_Rows[row]->m_textItems.size(); ++i )
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ void ScreenOptionsMaster::SetList( OptionRowDefinition &row, OptionRowHandler &h
|
|||||||
if( asParts[i].CompareNoCase("together") == 0 )
|
if( asParts[i].CompareNoCase("together") == 0 )
|
||||||
row.bOneChoiceForAllPlayers = true;
|
row.bOneChoiceForAllPlayers = true;
|
||||||
else if( asParts[i].CompareNoCase("SelectMultiple") == 0 )
|
else if( asParts[i].CompareNoCase("SelectMultiple") == 0 )
|
||||||
row.selectType = OptionRowDefinition::SELECT_MULTIPLE;
|
row.selectType = SELECT_MULTIPLE;
|
||||||
else if( asParts[i].CompareNoCase("SelectNone") == 0 )
|
else if( asParts[i].CompareNoCase("SelectNone") == 0 )
|
||||||
row.selectType = OptionRowDefinition::SELECT_NONE;
|
row.selectType = SELECT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int col = 0; col < NumCols; ++col )
|
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
|
/* The entry has no effect. This is usually a default "none of the
|
||||||
* above" entry. It will always return true for DescribesCurrentMode().
|
* above" entry. It will always return true for DescribesCurrentMode().
|
||||||
* It's only the selected choice if nothing else matches. */
|
* It's only the selected choice if nothing else matches. */
|
||||||
if( row.selectType != OptionRowDefinition::SELECT_MULTIPLE )
|
if( row.selectType != SELECT_MULTIPLE )
|
||||||
FallbackOption = e;
|
FallbackOption = e;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -424,7 +424,7 @@ void ScreenOptionsMaster::ImportOption( const OptionRowDefinition &row, const Op
|
|||||||
if( mc.DescribesCurrentModeForAllPlayers() )
|
if( mc.DescribesCurrentModeForAllPlayers() )
|
||||||
{
|
{
|
||||||
UseFallbackOption = false;
|
UseFallbackOption = false;
|
||||||
if( row.selectType != OptionRowDefinition::SELECT_MULTIPLE )
|
if( row.selectType != SELECT_MULTIPLE )
|
||||||
SelectExactlyOne( e, vbSelectedOut );
|
SelectExactlyOne( e, vbSelectedOut );
|
||||||
else
|
else
|
||||||
vbSelectedOut[e] = true;
|
vbSelectedOut[e] = true;
|
||||||
@@ -435,7 +435,7 @@ void ScreenOptionsMaster::ImportOption( const OptionRowDefinition &row, const Op
|
|||||||
if( mc.DescribesCurrentMode( pn) )
|
if( mc.DescribesCurrentMode( pn) )
|
||||||
{
|
{
|
||||||
UseFallbackOption = false;
|
UseFallbackOption = false;
|
||||||
if( row.selectType != OptionRowDefinition::SELECT_MULTIPLE )
|
if( row.selectType != SELECT_MULTIPLE )
|
||||||
SelectExactlyOne( e, vbSelectedOut );
|
SelectExactlyOne( e, vbSelectedOut );
|
||||||
else
|
else
|
||||||
vbSelectedOut[e] = true;
|
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 &&
|
UseFallbackOption &&
|
||||||
FallbackOption != -1 )
|
FallbackOption != -1 )
|
||||||
{
|
{
|
||||||
@@ -464,7 +464,7 @@ void ScreenOptionsMaster::ImportOption( const OptionRowDefinition &row, const Op
|
|||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( row.selectType != OptionRowDefinition::SELECT_MULTIPLE )
|
if( row.selectType != SELECT_MULTIPLE )
|
||||||
{
|
{
|
||||||
// The first row ("go down") should not be selected.
|
// The first row ("go down") should not be selected.
|
||||||
ASSERT( !vbSelectedOut[0] );
|
ASSERT( !vbSelectedOut[0] );
|
||||||
|
|||||||
Reference in New Issue
Block a user