separate initializing text and setting m_iChoiceInRowWithFocus
This commit is contained in:
+57
-44
@@ -230,52 +230,16 @@ CString OptionRow::GetRowTitle() const
|
|||||||
return sTitle;
|
return sTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionRow::AfterImportOptions()
|
/* Set up text, underlines and titles for options. This can be called
|
||||||
|
* as soon as m_RowDef is available. */
|
||||||
|
void OptionRow::InitText()
|
||||||
{
|
{
|
||||||
// Make all selections the same if bOneChoiceForAllPlayers
|
/* If we have elements already, we're being updated from a new set of options.
|
||||||
// Hack: we only import active players, so if only player 2 is imported,
|
* Delete the old ones. */
|
||||||
// we need to copy p2 to p1, not p1 to p2.
|
m_ItemFrame.DeleteAllChildren();
|
||||||
if( m_RowDef.m_bOneChoiceForAllPlayers )
|
m_textItems.clear();
|
||||||
{
|
|
||||||
PlayerNumber pnCopyFrom = GAMESTATE->m_MasterPlayerNumber;
|
|
||||||
if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID )
|
|
||||||
pnCopyFrom = PLAYER_1;
|
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
m_vbSelected[p] = m_vbSelected[pnCopyFrom];
|
m_Underline[p].clear();
|
||||||
}
|
|
||||||
|
|
||||||
FOREACH_PlayerNumber( p )
|
|
||||||
{
|
|
||||||
switch( m_RowDef.m_selectType )
|
|
||||||
{
|
|
||||||
case SELECT_ONE:
|
|
||||||
{
|
|
||||||
/* Make sure the row actually has a selection. */
|
|
||||||
bool bHasASelection = false;
|
|
||||||
for( unsigned i=0; i<m_vbSelected[p].size(); i++ )
|
|
||||||
{
|
|
||||||
if( m_vbSelected[p][i] )
|
|
||||||
bHasASelection = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !bHasASelection && !m_vbSelected[p].empty() )
|
|
||||||
m_vbSelected[p][0] = true;
|
|
||||||
|
|
||||||
m_iChoiceInRowWithFocus[p] = GetOneSelection(p, true); // focus on the selection we just set
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SELECT_MULTIPLE:
|
|
||||||
case SELECT_NONE:
|
|
||||||
m_iChoiceInRowWithFocus[p] = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// init row icons
|
|
||||||
FOREACH_HumanPlayer( p )
|
|
||||||
SetOptionIcon( p, "" );
|
|
||||||
|
|
||||||
// If the items will go off the edge of the screen, then re-init with the "long row" style.
|
// If the items will go off the edge of the screen, then re-init with the "long row" style.
|
||||||
{
|
{
|
||||||
@@ -398,6 +362,55 @@ void OptionRow::AfterImportOptions()
|
|||||||
m_textTitle.RunCommands( LABELS_ON_COMMAND );
|
m_textTitle.RunCommands( LABELS_ON_COMMAND );
|
||||||
|
|
||||||
m_sprBullet.SetX( ARROWS_X );
|
m_sprBullet.SetX( ARROWS_X );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* After importing options, choose which item is focused. */
|
||||||
|
void OptionRow::AfterImportOptions()
|
||||||
|
{
|
||||||
|
// Make all selections the same if bOneChoiceForAllPlayers
|
||||||
|
// Hack: we only import active players, so if only player 2 is imported,
|
||||||
|
// we need to copy p2 to p1, not p1 to p2.
|
||||||
|
if( m_RowDef.m_bOneChoiceForAllPlayers )
|
||||||
|
{
|
||||||
|
PlayerNumber pnCopyFrom = GAMESTATE->m_MasterPlayerNumber;
|
||||||
|
if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID )
|
||||||
|
pnCopyFrom = PLAYER_1;
|
||||||
|
FOREACH_PlayerNumber( p )
|
||||||
|
m_vbSelected[p] = m_vbSelected[pnCopyFrom];
|
||||||
|
}
|
||||||
|
|
||||||
|
FOREACH_PlayerNumber( p )
|
||||||
|
{
|
||||||
|
switch( m_RowDef.m_selectType )
|
||||||
|
{
|
||||||
|
case SELECT_ONE:
|
||||||
|
{
|
||||||
|
/* Make sure the row actually has a selection. */
|
||||||
|
bool bHasASelection = false;
|
||||||
|
for( unsigned i=0; i<m_vbSelected[p].size(); i++ )
|
||||||
|
{
|
||||||
|
if( m_vbSelected[p][i] )
|
||||||
|
bHasASelection = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !bHasASelection && !m_vbSelected[p].empty() )
|
||||||
|
m_vbSelected[p][0] = true;
|
||||||
|
|
||||||
|
m_iChoiceInRowWithFocus[p] = GetOneSelection(p, true); // focus on the selection we just set
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SELECT_MULTIPLE:
|
||||||
|
case SELECT_NONE:
|
||||||
|
m_iChoiceInRowWithFocus[p] = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// init row icons
|
||||||
|
FOREACH_HumanPlayer( p )
|
||||||
|
SetOptionIcon( p, "" );
|
||||||
|
|
||||||
//
|
//
|
||||||
// HACK: Set focus to one item in the row, which is "go down"
|
// HACK: Set focus to one item in the row, which is "go down"
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ public:
|
|||||||
void ImportOptions( const vector<PlayerNumber> &vpns );
|
void ImportOptions( const vector<PlayerNumber> &vpns );
|
||||||
int ExportOptions( const vector<PlayerNumber> &vpns, bool bRowHasFocus[NUM_PLAYERS] );
|
int ExportOptions( const vector<PlayerNumber> &vpns, bool bRowHasFocus[NUM_PLAYERS] );
|
||||||
|
|
||||||
|
void InitText();
|
||||||
void AfterImportOptions();
|
void AfterImportOptions();
|
||||||
void DetachHandler();
|
void DetachHandler();
|
||||||
|
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ void ScreenOptions::InitMenu( const vector<OptionRowDefinition> &vDefs, const ve
|
|||||||
|
|
||||||
row.LoadMetrics( m_sName );
|
row.LoadMetrics( m_sName );
|
||||||
row.LoadNormal( def, hand, bFirstRowGoesDown );
|
row.LoadNormal( def, hand, bFirstRowGoesDown );
|
||||||
|
row.InitText();
|
||||||
|
|
||||||
vector<PlayerNumber> vpns;
|
vector<PlayerNumber> vpns;
|
||||||
FOREACH_HumanPlayer( p )
|
FOREACH_HumanPlayer( p )
|
||||||
|
|||||||
Reference in New Issue
Block a user