fix skip when changing value in row:

broadcast the row export only once - not for each player
disable export/import on reload - nothing uses it yet
This commit is contained in:
Chris Danford
2005-04-03 06:21:02 +00:00
parent afd53cfc5e
commit 134cdb4451
17 changed files with 505 additions and 386 deletions
+62 -25
View File
@@ -720,9 +720,17 @@ void OptionRow::Reload()
if( m_pHand == NULL ) if( m_pHand == NULL )
return; return;
if( m_RowDef.m_bExportOnChange ) vector<PlayerNumber> vpns;
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
ExportOptions( p, false ); vpns.push_back( p );
// TODO: Nothing uses this yet and it causes skips when changing options.
//if( m_RowDef.m_bExportOnChange )
//{
// bool bRowHasFocus[NUM_PLAYERS];
// ZERO( bRowHasFocus );
// ExportOptions( vpns, bRowHasFocus );
//}
m_pHand->Reload( m_RowDef ); m_pHand->Reload( m_RowDef );
ASSERT( !m_RowDef.choices.empty() ); ASSERT( !m_RowDef.choices.empty() );
@@ -730,8 +738,8 @@ void OptionRow::Reload()
FOREACH_PlayerNumber( p ) FOREACH_PlayerNumber( p )
m_vbSelected[p].resize( m_RowDef.choices.size(), false ); m_vbSelected[p].resize( m_RowDef.choices.size(), false );
FOREACH_HumanPlayer( p ) // TODO: Nothing uses this yet and it causes skips when changing options.
ImportOptions( p ); //ImportOptions( vpns );
switch( m_RowDef.selectType ) switch( m_RowDef.selectType )
{ {
@@ -747,9 +755,13 @@ void OptionRow::Reload()
ASSERT(0); ASSERT(0);
} }
if( m_RowDef.m_bExportOnChange ) // TODO: Nothing uses this yet and it causes skips when changing options.
FOREACH_HumanPlayer( p ) //if( m_RowDef.m_bExportOnChange )
ExportOptions( p, false ); //{
// bool bRowHasFocus[NUM_PLAYERS];
// ZERO( bRowHasFocus );
// ExportOptions( vpns, bRowHasFocus );
//}
UpdateEnabledDisabled(); UpdateEnabledDisabled();
UpdateText(); UpdateText();
@@ -792,24 +804,36 @@ static void VerifySelected( SelectType st, const vector<bool> &vbSelected, const
} }
} }
void OptionRow::ImportOptions( PlayerNumber pn ) void OptionRow::ImportOptions( const vector<PlayerNumber> &vpns )
{ {
if( m_pHand == NULL ) if( m_pHand == NULL )
return; return;
ASSERT( m_RowDef.choices.size() > 0 ); ASSERT( m_RowDef.choices.size() > 0 );
FOREACH( bool, m_vbSelected[pn], b ) FOREACH_CONST( PlayerNumber, vpns, iter )
{
PlayerNumber p = *iter;
FOREACH( bool, m_vbSelected[p], b )
*b = false; *b = false;
ASSERT( m_vbSelected[pn].size() == m_RowDef.choices.size() ); ASSERT( m_vbSelected[p].size() == m_RowDef.choices.size() );
ERASE_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[pn] ); ERASE_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[p] );
m_pHand->ImportOption( m_RowDef, pn, m_vbSelected[pn] ); }
INSERT_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[pn] );
VerifySelected( m_RowDef.selectType, m_vbSelected[pn], m_RowDef.name ); m_pHand->ImportOption( m_RowDef, vpns, m_vbSelected );
FOREACH_CONST( PlayerNumber, vpns, iter )
{
PlayerNumber p = *iter;
INSERT_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[p] );
VerifySelected( m_RowDef.selectType, m_vbSelected[p], m_RowDef.name );
}
} }
int OptionRow::ExportOptions( PlayerNumber pn, bool bRowHasFocus ) int OptionRow::ExportOptions( const vector<PlayerNumber> &vpns, bool bRowHasFocus[NUM_PLAYERS] )
{ {
if( m_pHand == NULL ) if( m_pHand == NULL )
return 0; return 0;
@@ -818,22 +842,35 @@ int OptionRow::ExportOptions( PlayerNumber pn, bool bRowHasFocus )
int iChangeMask = 0; int iChangeMask = 0;
VerifySelected( m_RowDef.selectType, m_vbSelected[pn], m_RowDef.name ); FOREACH_CONST( PlayerNumber, vpns, iter )
ASSERT( m_vbSelected[pn].size() == m_RowDef.choices.size() ); {
ERASE_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[pn] ); PlayerNumber p = *iter;
bool bFocus = bRowHasFocus[p];
VerifySelected( m_RowDef.selectType, m_vbSelected[p], m_RowDef.name );
ASSERT( m_vbSelected[p].size() == m_RowDef.choices.size() );
ERASE_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[p] );
// SELECT_NONE rows get exported if they have focus when the user presses // SELECT_NONE rows get exported if they have focus when the user presses
// Start. // Start.
int iChoice = GetChoiceInRowWithFocus( pn ); int iChoice = GetChoiceInRowWithFocus( p );
if( m_RowDef.selectType == SELECT_NONE && bRowHasFocus ) if( m_RowDef.selectType == SELECT_NONE && bFocus )
m_vbSelected[pn][iChoice] = true; m_vbSelected[p][iChoice] = true;
}
iChangeMask |= m_pHand->ExportOption( m_RowDef, pn, m_vbSelected[pn] ); iChangeMask |= m_pHand->ExportOption( m_RowDef, vpns, m_vbSelected );
if( m_RowDef.selectType == SELECT_NONE && bRowHasFocus ) FOREACH_CONST( PlayerNumber, vpns, iter )
m_vbSelected[pn][iChoice] = false; {
PlayerNumber p = *iter;
bool bFocus = bRowHasFocus[p];
INSERT_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[pn] ); int iChoice = GetChoiceInRowWithFocus( p );
if( m_RowDef.selectType == SELECT_NONE && bFocus )
m_vbSelected[p][iChoice] = false;
INSERT_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[p] );
}
return iChangeMask; return iChangeMask;
} }
+2 -2
View File
@@ -90,8 +90,8 @@ public:
CString GetRowTitle() const; CString GetRowTitle() const;
void ImportOptions( PlayerNumber pn ); void ImportOptions( const vector<PlayerNumber> &vpns );
int ExportOptions( PlayerNumber pn, bool bRowHasFocus ); int ExportOptions( const vector<PlayerNumber> &vpns, bool bRowHasFocus[NUM_PLAYERS] );
void AfterImportOptions( float fY ); void AfterImportOptions( float fY );
void DetachHandler(); void DetachHandler();
+132 -57
View File
@@ -151,16 +151,21 @@ public:
defOut.choices.push_back( sChoice ); defOut.choices.push_back( sChoice );
} }
} }
void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector<bool> &vbSelectedOut ) const void ImportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
{ {
int FallbackOption = -1; int FallbackOption = -1;
bool UseFallbackOption = true; bool UseFallbackOption = true;
FOREACH_CONST( PlayerNumber, vpns, pn )
{
PlayerNumber p = *pn;
vector<bool> &vbSelOut = vbSelectedOut[p];
for( unsigned e = 0; e < ListEntries.size(); ++e ) for( unsigned e = 0; e < ListEntries.size(); ++e )
{ {
const GameCommand &mc = ListEntries[e]; const GameCommand &mc = ListEntries[e];
vbSelectedOut[e] = false; vbSelOut[e] = false;
if( mc.IsZero() ) if( mc.IsZero() )
{ {
@@ -178,20 +183,20 @@ public:
{ {
UseFallbackOption = false; UseFallbackOption = false;
if( def.selectType != SELECT_MULTIPLE ) if( def.selectType != SELECT_MULTIPLE )
SelectExactlyOne( e, vbSelectedOut ); SelectExactlyOne( e, vbSelOut );
else else
vbSelectedOut[e] = true; vbSelOut[e] = true;
} }
} }
else else
{ {
if( mc.DescribesCurrentMode( pn) ) if( mc.DescribesCurrentMode( p) )
{ {
UseFallbackOption = false; UseFallbackOption = false;
if( def.selectType != SELECT_MULTIPLE ) if( def.selectType != SELECT_MULTIPLE )
SelectExactlyOne( e, vbSelectedOut ); SelectExactlyOne( e, vbSelOut );
else else
vbSelectedOut[e] = true; vbSelOut[e] = true;
} }
} }
} }
@@ -206,20 +211,27 @@ public:
UseFallbackOption && UseFallbackOption &&
FallbackOption != -1 ) FallbackOption != -1 )
{ {
SelectExactlyOne( FallbackOption, vbSelectedOut ); SelectExactlyOne( FallbackOption, vbSelOut );
}
} }
} }
int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector<bool> &vbSelected ) const int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const
{ {
Default.Apply( pn ); FOREACH_CONST( PlayerNumber, vpns, pn )
for( unsigned i=0; i<vbSelected.size(); i++ )
{ {
if( vbSelected[i] ) PlayerNumber p = *pn;
ListEntries[i].Apply( pn ); const vector<bool> &vbSel = vbSelected[p];
Default.Apply( p );
for( unsigned i=0; i<vbSel.size(); i++ )
{
if( vbSel[i] )
ListEntries[i].Apply( p );
} }
FOREACH_CONST( CString, m_vsBroadcastOnExport, s ) FOREACH_CONST( CString, m_vsBroadcastOnExport, s )
MESSAGEMAN->Broadcast( *s ); MESSAGEMAN->Broadcast( *s );
}
return 0; return 0;
} }
@@ -500,7 +512,6 @@ public:
if( m_pLuaTable->GetLuaType() != LUA_TTABLE ) if( m_pLuaTable->GetLuaType() != LUA_TTABLE )
RageException::Throw( "Result of \"%s\" is not a table", sLuaFunction.c_str() ); RageException::Throw( "Result of \"%s\" is not a table", sLuaFunction.c_str() );
{
m_pLuaTable->PushSelf( LUA->L ); m_pLuaTable->PushSelf( LUA->L );
lua_pushstring( LUA->L, "Name" ); lua_pushstring( LUA->L, "Name" );
@@ -606,7 +617,7 @@ public:
const char *pValue = lua_tostring( LUA->L, -1 ); const char *pValue = lua_tostring( LUA->L, -1 );
if( pValue == NULL ) if( pValue == NULL )
RageException::Throw( "\"%s\" Column entry is not a string", sLuaFunction.c_str() ); RageException::Throw( "\"%s\" Column entry is not a string", sLuaFunction.c_str() );
LOG->Trace( "'%s'", pValue); LOG->Trace( "Found ReloadRowMessage '%s'", pValue);
m_vsReloadRowMessages.push_back( pValue ); m_vsReloadRowMessages.push_back( pValue );
@@ -626,50 +637,65 @@ public:
lua_pop( LUA->L, 1 ); /* pop ExportOnChange value */ lua_pop( LUA->L, 1 ); /* pop ExportOnChange value */
/* Iterate over the "ReloadRowMessages" table. */ lua_pop( LUA->L, 1 ); /* pop main table */
lua_pushstring( LUA->L, "ReloadRowMessages" ); ASSERT( lua_gettop(LUA->L) == 0 );
}
virtual void Reload( OptionRowDefinition &defOut )
{
/* Run the Lua expression. It should return a table. */
m_pLuaTable->SetFromExpression( m_sName );
if( m_pLuaTable->GetLuaType() != LUA_TTABLE )
RageException::Throw( "Result of \"%s\" is not a table", m_sName.c_str() );
m_pLuaTable->PushSelf( LUA->L );
/* Iterate over the "EnabledForPlayers" table. */
lua_pushstring( LUA->L, "EnabledForPlayers" );
lua_gettable( LUA->L, -2 ); lua_gettable( LUA->L, -2 );
if( !lua_isnil( LUA->L, -1 ) ) if( !lua_isnil( LUA->L, -1 ) )
{ {
if( !lua_istable( LUA->L, -1 ) ) if( !lua_istable( LUA->L, -1 ) )
RageException::Throw( "\"%s\" \"ReloadRowMessages\" is not a table", sLuaFunction.c_str() ); RageException::Throw( "\"%s\" \"EnabledForPlayers\" is not a table", m_sName.c_str() );
m_vsReloadRowMessages.clear(); // and fill in with supplied PlayerNumbers below defOut.m_vEnabledForPlayers.clear(); // and fill in with supplied PlayerNumbers below
lua_pushnil( LUA->L ); lua_pushnil( LUA->L );
while( lua_next(LUA->L, -2) != 0 ) while( lua_next(LUA->L, -2) != 0 )
{ {
/* `key' is at index -2 and `value' at index -1 */ /* `key' is at index -2 and `value' at index -1 */
const char *pValue = lua_tostring( LUA->L, -1 ); PlayerNumber pn = (PlayerNumber)luaL_checkint( LUA->L, -1 );
if( pValue == NULL )
RageException::Throw( "\"%s\" Column entry is not a string", sLuaFunction.c_str() );
LOG->Trace( "'%s'", pValue);
m_vsReloadRowMessages.push_back( pValue ); defOut.m_vEnabledForPlayers.insert( pn );
lua_pop( LUA->L, 1 ); /* removes `value'; keeps `key' for next iteration */ lua_pop( LUA->L, 1 ); /* removes `value'; keeps `key' for next iteration */
} }
} }
lua_pop( LUA->L, 1 ); /* pop ReloadRowMessages table */ lua_pop( LUA->L, 1 ); /* pop EnabledForPlayers table */
lua_pop( LUA->L, 1 ); /* pop main table */ lua_pop( LUA->L, 1 ); /* pop main table */
ASSERT( lua_gettop(LUA->L) == 0 ); ASSERT( lua_gettop(LUA->L) == 0 );
} }
} virtual void ImportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector<bool> &vbSelectedOut ) const
{ {
ASSERT( lua_gettop(LUA->L) == 0 ); ASSERT( lua_gettop(LUA->L) == 0 );
FOREACH_CONST( PlayerNumber, vpns, pn )
{
PlayerNumber p = *pn;
vector<bool> &vbSelOut = vbSelectedOut[p];
/* Evaluate the LoadSelections(self,array,pn) function, where array is a table /* Evaluate the LoadSelections(self,array,pn) function, where array is a table
* representing vbSelectedOut. */ * representing vbSelectedOut. */
/* All selections default to false. */ /* All selections default to false. */
for( unsigned i = 0; i < vbSelectedOut.size(); ++i ) for( unsigned i = 0; i < vbSelOut.size(); ++i )
vbSelectedOut[i] = false; vbSelOut[i] = false;
/* Create the vbSelectedOut table. */ /* Create the vbSelectedOut table. */
LUA->CreateTableFromArrayB( vbSelectedOut ); LUA->CreateTableFromArrayB( vbSelOut );
ASSERT( lua_gettop(LUA->L) == 1 ); /* vbSelectedOut table */ ASSERT( lua_gettop(LUA->L) == 1 ); /* vbSelectedOut table */
/* Get the function to call from m_LuaTable. */ /* Get the function to call from m_LuaTable. */
@@ -688,7 +714,7 @@ public:
lua_pushvalue( LUA->L, 1 ); lua_pushvalue( LUA->L, 1 );
/* Argument 3 (pn): */ /* Argument 3 (pn): */
LuaHelpers::PushStack( (int) pn ); LuaHelpers::PushStack( (int) p );
ASSERT( lua_gettop(LUA->L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ ASSERT( lua_gettop(LUA->L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */
@@ -697,20 +723,26 @@ public:
lua_pop( LUA->L, 1 ); /* pop option table */ lua_pop( LUA->L, 1 ); /* pop option table */
LUA->ReadArrayFromTableB( vbSelectedOut ); LUA->ReadArrayFromTableB( vbSelOut );
lua_pop( LUA->L, 1 ); /* pop vbSelectedOut table */ lua_pop( LUA->L, 1 ); /* pop vbSelectedOut table */
ASSERT( lua_gettop(LUA->L) == 0 ); ASSERT( lua_gettop(LUA->L) == 0 );
} }
virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector<bool> &vbSelected ) const }
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const
{ {
ASSERT( lua_gettop(LUA->L) == 0 ); ASSERT( lua_gettop(LUA->L) == 0 );
FOREACH_CONST( PlayerNumber, vpns, pn )
{
PlayerNumber p = *pn;
const vector<bool> &vbSel = vbSelected[p];
/* Evaluate SaveSelections(self,array,pn) function, where array is a table /* Evaluate SaveSelections(self,array,pn) function, where array is a table
* representing vbSelectedOut. */ * representing vbSelectedOut. */
vector<bool> vbSelectedCopy = vbSelected; vector<bool> vbSelectedCopy = vbSel;
/* Create the vbSelectedOut table. */ /* Create the vbSelectedOut table. */
LUA->CreateTableFromArrayB( vbSelectedCopy ); LUA->CreateTableFromArrayB( vbSelectedCopy );
@@ -732,7 +764,7 @@ public:
lua_pushvalue( LUA->L, 1 ); lua_pushvalue( LUA->L, 1 );
/* Argument 3 (pn): */ /* Argument 3 (pn): */
LuaHelpers::PushStack( (int) pn ); LuaHelpers::PushStack( (int) p );
ASSERT( lua_gettop(LUA->L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ ASSERT( lua_gettop(LUA->L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */
@@ -743,6 +775,7 @@ public:
lua_pop( LUA->L, 1 ); /* pop vbSelected table */ lua_pop( LUA->L, 1 ); /* pop vbSelected table */
ASSERT( lua_gettop(LUA->L) == 0 ); ASSERT( lua_gettop(LUA->L) == 0 );
}
// XXX: allow specifying the mask // XXX: allow specifying the mask
return 0; return 0;
@@ -781,14 +814,27 @@ public:
defOut.name = opt->name; defOut.name = opt->name;
} }
virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector<bool> &vbSelectedOut ) const virtual void ImportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
{ {
FOREACH_CONST( PlayerNumber, vpns, pn )
{
PlayerNumber p = *pn;
vector<bool> &vbSelOut = vbSelectedOut[p];
int iSelection = opt->Get(); int iSelection = opt->Get();
SelectExactlyOne( iSelection, vbSelectedOut ); SelectExactlyOne( iSelection, vbSelOut );
} }
virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector<bool> &vbSelected ) const }
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const
{ {
int sel = GetOneSelection(vbSelected); bool bChanged = false;
FOREACH_CONST( PlayerNumber, vpns, pn )
{
PlayerNumber p = *pn;
const vector<bool> &vbSel = vbSelected[p];
int sel = GetOneSelection(vbSel);
/* Get the original choice. */ /* Get the original choice. */
int Original = opt->Get(); int Original = opt->Get();
@@ -800,10 +846,11 @@ public:
int New = opt->Get(); int New = opt->Get();
/* If it didn't change, don't return any side-effects. */ /* If it didn't change, don't return any side-effects. */
if( Original == New ) if( Original != New )
return 0; bChanged = true;
}
return opt->GetEffects(); return bChanged ? opt->GetEffects() : 0;
} }
}; };
@@ -864,8 +911,13 @@ public:
if( *m_pstToFill == STEPS_TYPE_INVALID ) if( *m_pstToFill == STEPS_TYPE_INVALID )
m_pstToFill->Set( m_vStepsTypesToShow[0] ); m_pstToFill->Set( m_vStepsTypesToShow[0] );
} }
virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector<bool> &vbSelectedOut ) const virtual void ImportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
{ {
FOREACH_CONST( PlayerNumber, vpns, pn )
{
PlayerNumber p = *pn;
vector<bool> &vbSelOut = vbSelectedOut[p];
if( GAMESTATE->m_pCurSteps[0] ) if( GAMESTATE->m_pCurSteps[0] )
{ {
StepsType st = GAMESTATE->m_pCurSteps[0]->m_StepsType; StepsType st = GAMESTATE->m_pCurSteps[0]->m_StepsType;
@@ -873,16 +925,24 @@ public:
if( iter != m_vStepsTypesToShow.end() ) if( iter != m_vStepsTypesToShow.end() )
{ {
unsigned i = iter - m_vStepsTypesToShow.begin(); unsigned i = iter - m_vStepsTypesToShow.begin();
vbSelectedOut[i] = true; vbSelOut[i] = true;
return; continue; // done with this player
} }
} }
vbSelectedOut[0] = true; vbSelOut[0] = true;
} }
virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector<bool> &vbSelected ) const }
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const
{ {
int index = GetOneSelection( vbSelected ); FOREACH_CONST( PlayerNumber, vpns, pn )
{
PlayerNumber p = *pn;
const vector<bool> &vbSel = vbSelected[p];
int index = GetOneSelection( vbSel );
m_pstToFill->Set( m_vStepsTypesToShow[index] ); m_pstToFill->Set( m_vStepsTypesToShow[index] );
}
return 0; return 0;
} }
}; };
@@ -992,16 +1052,21 @@ public:
m_pDifficultyToFill->Set( m_vDifficulties[0] ); m_pDifficultyToFill->Set( m_vDifficulties[0] );
m_ppStepsToFill->Set( m_vSteps[0] ); m_ppStepsToFill->Set( m_vSteps[0] );
} }
virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector<bool> &vbSelectedOut ) const virtual void ImportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
{ {
ASSERT( m_vSteps.size() == vbSelectedOut.size() ); FOREACH_CONST( PlayerNumber, vpns, pn )
{
PlayerNumber p = *pn;
vector<bool> &vbSelOut = vbSelectedOut[p];
ASSERT( m_vSteps.size() == vbSelOut.size() );
// look for matching steps // look for matching steps
vector<Steps*>::const_iterator iter = find( m_vSteps.begin(), m_vSteps.end(), m_ppStepsToFill->Get() ); vector<Steps*>::const_iterator iter = find( m_vSteps.begin(), m_vSteps.end(), m_ppStepsToFill->Get() );
if( iter != m_vSteps.end() ) if( iter != m_vSteps.end() )
{ {
unsigned i = iter - m_vSteps.begin(); unsigned i = iter - m_vSteps.begin();
vbSelectedOut[i] = true; vbSelOut[i] = true;
return; return;
} }
// look for matching difficulty // look for matching difficulty
@@ -1012,23 +1077,33 @@ public:
unsigned i = d - m_vDifficulties.begin(); unsigned i = d - m_vDifficulties.begin();
if( *d == GAMESTATE->m_PreferredDifficulty[0] ) if( *d == GAMESTATE->m_PreferredDifficulty[0] )
{ {
vbSelectedOut[i] = true; vbSelOut[i] = true;
ExportOption( def, pn, vbSelectedOut ); // current steps changed vector<PlayerNumber> v;
return; v.push_back( p );
ExportOption( def, v, vbSelectedOut ); // current steps changed
continue;
} }
} }
} }
// default to 1st // default to 1st
vbSelectedOut[0] = true; vbSelOut[0] = true;
} }
virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector<bool> &vbSelected ) const }
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const
{ {
int index = GetOneSelection( vbSelected ); FOREACH_CONST( PlayerNumber, vpns, pn )
{
PlayerNumber p = *pn;
const vector<bool> &vbSel = vbSelected[p];
int index = GetOneSelection( vbSel );
Difficulty dc = m_vDifficulties[index]; Difficulty dc = m_vDifficulties[index];
Steps *pSteps = m_vSteps[index]; Steps *pSteps = m_vSteps[index];
if( m_pDifficultyToFill ) if( m_pDifficultyToFill )
m_pDifficultyToFill->Set( dc ); m_pDifficultyToFill->Set( dc );
m_ppStepsToFill->Set( pSteps ); m_ppStepsToFill->Set( pSteps );
}
return 0; return 0;
} }
}; };
+3 -3
View File
@@ -23,10 +23,10 @@ public:
m_vsReloadRowMessages.clear(); m_vsReloadRowMessages.clear();
} }
virtual void Load( OptionRowDefinition &defOut, CString sParam ) = 0; virtual void Load( OptionRowDefinition &defOut, CString sParam ) = 0;
void Reload( OptionRowDefinition &defOut ) { this->Load(defOut,m_sName); } virtual void Reload( OptionRowDefinition &defOut ) { this->Load(defOut,m_sName); }
virtual void ImportOption( const OptionRowDefinition &row, PlayerNumber pn, vector<bool> &vbSelectedOut ) const = 0; virtual void ImportOption( const OptionRowDefinition &row, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const = 0;
/* Returns an OPT mask. */ /* Returns an OPT mask. */
virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector<bool> &vbSelected ) const = 0; virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const = 0;
virtual CString GetIconText( const OptionRowDefinition &def, int iFirstSelection ) const { return ""; } virtual CString GetIconText( const OptionRowDefinition &def, int iFirstSelection ) const { return ""; }
virtual bool HasScreen( int iChoice ) const { return false; } virtual bool HasScreen( int iChoice ) const { return false; }
}; };
+2 -2
View File
@@ -86,7 +86,7 @@ void ScreenMiniMenu::Init( const Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMe
ScreenOptions::InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands ); ScreenOptions::InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands );
} }
void ScreenMiniMenu::ImportOptions( int r, PlayerNumber pn ) void ScreenMiniMenu::ImportOptions( int r, const vector<PlayerNumber> &vpns )
{ {
OptionRow &optrow = *m_Rows[r]; OptionRow &optrow = *m_Rows[r];
MenuRow &mr = m_vMenuRows[r]; MenuRow &mr = m_vMenuRows[r];
@@ -94,7 +94,7 @@ void ScreenMiniMenu::ImportOptions( int r, PlayerNumber pn )
optrow.SetOneSharedSelection( mr.iDefaultChoice ); optrow.SetOneSharedSelection( mr.iDefaultChoice );
} }
void ScreenMiniMenu::ExportOptions( int r, PlayerNumber pn ) void ScreenMiniMenu::ExportOptions( int r, const vector<PlayerNumber> &vpns )
{ {
if( r == GetCurrentRow() ) if( r == GetCurrentRow() )
s_iLastRowCode = m_vMenuRows[r].iRowCode; s_iLastRowCode = m_vMenuRows[r].iRowCode;
+2 -2
View File
@@ -58,8 +58,8 @@ public:
ScreenMiniMenu( CString sScreenClass ); ScreenMiniMenu( CString sScreenClass );
void Init( const Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel ); void Init( const Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel );
protected: protected:
virtual void ImportOptions( int row, PlayerNumber pn ); virtual void ImportOptions( int row, const vector<PlayerNumber> &vpns );
virtual void ExportOptions( int row, PlayerNumber pn ); virtual void ExportOptions( int row, const vector<PlayerNumber> &vpns );
virtual void GoToNextScreen(); virtual void GoToNextScreen();
virtual void GoToPrevScreen(); virtual void GoToPrevScreen();
+2 -2
View File
@@ -154,8 +154,8 @@ void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type
#endif #endif
} }
void ScreenNetworkOptions::ImportOptions( int row, PlayerNumber pn ) { } void ScreenNetworkOptions::ImportOptions( int row, const vector<PlayerNumber> &vpns ) { }
void ScreenNetworkOptions::ExportOptions( int row, PlayerNumber pn ) { } void ScreenNetworkOptions::ExportOptions( int row, const vector<PlayerNumber> &vpns ) { }
void ScreenNetworkOptions::UpdateConnectStatus( ) void ScreenNetworkOptions::UpdateConnectStatus( )
{ {
+2 -2
View File
@@ -14,8 +14,8 @@ public:
virtual void MenuStart( PlayerNumber pn, const InputEventType type ); virtual void MenuStart( PlayerNumber pn, const InputEventType type );
private: private:
void ImportOptions( int row, PlayerNumber pn ); void ImportOptions( int row, const vector<PlayerNumber> &vpns );
void ExportOptions( int row, PlayerNumber pn ); void ExportOptions( int row, const vector<PlayerNumber> &vpns );
void GoToNextScreen(); void GoToNextScreen();
void GoToPrevScreen(); void GoToPrevScreen();
+13 -3
View File
@@ -154,8 +154,10 @@ void ScreenOptions::InitMenu( InputMode im, const vector<OptionRowDefinition> &v
row.LoadMetrics( m_sName ); row.LoadMetrics( m_sName );
row.LoadNormal( def, hand, bFirstRowGoesDown ); row.LoadNormal( def, hand, bFirstRowGoesDown );
vector<PlayerNumber> vpns;
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
this->ImportOptions( r, p ); vpns.push_back( p );
this->ImportOptions( r, vpns );
CHECKPOINT_M( ssprintf("row %i: %s", r, row.GetRowDef().name.c_str()) ); CHECKPOINT_M( ssprintf("row %i: %s", r, row.GetRowDef().name.c_str()) );
@@ -511,8 +513,12 @@ void ScreenOptions::HandleScreenMessage( const ScreenMessage SM )
break; break;
case SM_GoToNextScreen: case SM_GoToNextScreen:
for( unsigned r=0; r<m_Rows.size(); r++ ) // foreach row for( unsigned r=0; r<m_Rows.size(); r++ ) // foreach row
{
vector<PlayerNumber> vpns;
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
this->ExportOptions( r, p ); vpns.push_back( p );
this->ExportOptions( r, vpns );
}
this->GoToNextScreen(); this->GoToNextScreen();
break; break;
case SM_BeginFadingOut: case SM_BeginFadingOut:
@@ -999,8 +1005,12 @@ void ScreenOptions::ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat )
m_SoundChangeCol.Play(); m_SoundChangeCol.Play();
if( row.GetRowDef().m_bExportOnChange ) if( row.GetRowDef().m_bExportOnChange )
{
vector<PlayerNumber> vpns;
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
ExportOptions( iCurRow, p ); vpns.push_back( p );
ExportOptions( iCurRow, vpns );
}
} }
+2 -2
View File
@@ -34,8 +34,8 @@ public:
virtual void HandleScreenMessage( const ScreenMessage SM ); virtual void HandleScreenMessage( const ScreenMessage SM );
protected: protected:
virtual void ImportOptions( int row, PlayerNumber pn ) = 0; virtual void ImportOptions( int row, const vector<PlayerNumber> &vpns ) = 0;
virtual void ExportOptions( int row, PlayerNumber pn ) = 0; virtual void ExportOptions( int row, const vector<PlayerNumber> &vpns ) = 0;
void InitOptionsText(); void InitOptionsText();
void GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ); void GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut );
+13 -7
View File
@@ -105,18 +105,22 @@ ScreenOptionsMaster::~ScreenOptionsMaster()
OptionRowHandlers.clear(); OptionRowHandlers.clear();
} }
void ScreenOptionsMaster::ImportOptions( int r, PlayerNumber pn ) void ScreenOptionsMaster::ImportOptions( int r, const vector<PlayerNumber> &vpns )
{ {
ASSERT( GAMESTATE->IsHumanPlayer(pn) ); FOREACH_CONST( PlayerNumber, vpns, pn )
ASSERT( GAMESTATE->IsHumanPlayer(*pn) );
OptionRow &row = *m_Rows[r]; OptionRow &row = *m_Rows[r];
row.ImportOptions( pn ); row.ImportOptions( vpns );
} }
void ScreenOptionsMaster::ExportOptions( int r, PlayerNumber pn ) void ScreenOptionsMaster::ExportOptions( int r, const vector<PlayerNumber> &vpns )
{ {
OptionRow &row = *m_Rows[r]; OptionRow &row = *m_Rows[r];
bool bRowHasFocus = m_iCurrentRow[pn] == r; bool bRowHasFocus[NUM_PLAYERS];
m_iChangeMask |= row.ExportOptions( pn, bRowHasFocus ); ZERO( bRowHasFocus );
FOREACH_CONST( PlayerNumber, vpns, pn )
bRowHasFocus[*pn] = m_iCurrentRow[*pn] == r;
m_iChangeMask |= row.ExportOptions( vpns, bRowHasFocus );
} }
void ScreenOptionsMaster::BeginFadingOut() void ScreenOptionsMaster::BeginFadingOut()
@@ -216,8 +220,10 @@ void ScreenOptionsMaster::HandleScreenMessage( const ScreenMessage SM )
{ {
CHECKPOINT_M( ssprintf("%i/%i", r, int(OptionRowHandlers.size())) ); CHECKPOINT_M( ssprintf("%i/%i", r, int(OptionRowHandlers.size())) );
vector<PlayerNumber> vpns;
FOREACH_OptionsPlayer( p ) FOREACH_OptionsPlayer( p )
ExportOptions( r, p ); vpns.push_back( p );
ExportOptions( r, vpns );
} }
if( m_iChangeMask & OPT_APPLY_ASPECT_RATIO ) if( m_iChangeMask & OPT_APPLY_ASPECT_RATIO )
+2 -2
View File
@@ -21,8 +21,8 @@ protected:
protected: protected:
void HandleScreenMessage( const ScreenMessage SM ); void HandleScreenMessage( const ScreenMessage SM );
virtual void ImportOptions( int row, PlayerNumber pn ); virtual void ImportOptions( int row, const vector<PlayerNumber> &vpns );
virtual void ExportOptions( int row, PlayerNumber pn ); virtual void ExportOptions( int row, const vector<PlayerNumber> &vpns );
virtual void BeginFadingOut(); virtual void BeginFadingOut();
virtual void GoToNextScreen(); virtual void GoToNextScreen();
+6 -2
View File
@@ -150,7 +150,9 @@ void ScreenPlayerOptions::Input( const DeviceInput& DeviceI, const InputEventTyp
for( unsigned r=0; r<m_Rows.size(); r++ ) for( unsigned r=0; r<m_Rows.size(); r++ )
{ {
this->ImportOptions( r, pn ); vector<PlayerNumber> v;
v.push_back( pn );
this->ImportOptions( r, v );
this->PositionUnderlines( r, pn ); this->PositionUnderlines( r, pn );
this->UpdateDisqualified( r, pn ); this->UpdateDisqualified( r, pn );
} }
@@ -205,7 +207,9 @@ void ScreenPlayerOptions::UpdateDisqualified( int row, PlayerNumber pn )
// Find out if the current row when exprorted causes disqualification. // Find out if the current row when exprorted causes disqualification.
// Exporting the row will fill GAMESTATE->m_PlayerOptions. // Exporting the row will fill GAMESTATE->m_PlayerOptions.
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions = PlayerOptions(); GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions = PlayerOptions();
ExportOptions( row, pn ); vector<PlayerNumber> v;
v.push_back( pn );
ExportOptions( row, v );
bool bRowCausesDisqualified = GAMESTATE->IsDisqualified( pn ); bool bRowCausesDisqualified = GAMESTATE->IsDisqualified( pn );
m_bRowCausesDisqualified[pn][row] = bRowCausesDisqualified; m_bRowCausesDisqualified[pn][row] = bRowCausesDisqualified;
+2 -10
View File
@@ -84,12 +84,8 @@ void ScreenProfileOptions::Init()
SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") ); SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") );
} }
void ScreenProfileOptions::ImportOptions( int row, PlayerNumber pn ) void ScreenProfileOptions::ImportOptions( int row, const vector<PlayerNumber> &vpns )
{ {
// Only take action for the master player
if( pn != GAMESTATE->m_MasterPlayerNumber )
return;
switch( row ) switch( row )
{ {
case PO_PLAYER1: case PO_PLAYER1:
@@ -110,12 +106,8 @@ void ScreenProfileOptions::ImportOptions( int row, PlayerNumber pn )
} }
} }
void ScreenProfileOptions::ExportOptions( int row, PlayerNumber pn ) void ScreenProfileOptions::ExportOptions( int row, const vector<PlayerNumber> &vpns )
{ {
// Only take action for the master player
if( pn != GAMESTATE->m_MasterPlayerNumber )
return;
switch( row ) switch( row )
{ {
case PO_PLAYER1: case PO_PLAYER1:
+2 -2
View File
@@ -14,8 +14,8 @@ public:
virtual void MenuStart( PlayerNumber pn, const InputEventType type ); virtual void MenuStart( PlayerNumber pn, const InputEventType type );
private: private:
void ImportOptions( int row, PlayerNumber pn ); void ImportOptions( int row, const vector<PlayerNumber> &vpns );
void ExportOptions( int row, PlayerNumber pn ); void ExportOptions( int row, const vector<PlayerNumber> &vpns );
void GoToNextScreen(); void GoToNextScreen();
void GoToPrevScreen(); void GoToPrevScreen();
+6 -11
View File
@@ -58,12 +58,8 @@ void ScreenSMOnlineLogin::Init()
} }
} }
void ScreenSMOnlineLogin::ImportOptions( int row, PlayerNumber pn ) void ScreenSMOnlineLogin::ImportOptions( int row, const vector<PlayerNumber> &vpns )
{ {
// Only take action for the master player
if( pn != GAMESTATE->m_MasterPlayerNumber )
return;
switch( row ) switch( row )
{ {
case 0: case 0:
@@ -84,12 +80,8 @@ void ScreenSMOnlineLogin::ImportOptions( int row, PlayerNumber pn )
} }
} }
void ScreenSMOnlineLogin::ExportOptions( int row, PlayerNumber pn ) void ScreenSMOnlineLogin::ExportOptions( int row, const vector<PlayerNumber> &vpns )
{ {
// Only take action for the master player
if( pn != GAMESTATE->m_MasterPlayerNumber )
return;
switch( row ) switch( row )
{ {
case 0: case 0:
@@ -113,8 +105,11 @@ void ScreenSMOnlineLogin::GoToPrevScreen()
void ScreenSMOnlineLogin::GoToNextScreen() void ScreenSMOnlineLogin::GoToNextScreen()
{ {
vector<PlayerNumber> v;
v.push_back( GAMESTATE->m_MasterPlayerNumber );
for( unsigned r=0; r<m_Rows.size(); r++ ) for( unsigned r=0; r<m_Rows.size(); r++ )
ExportOptions( r, GAMESTATE->m_MasterPlayerNumber ); ExportOptions( r, v );
PREFSMAN->SaveGlobalPrefsToDisk(); PREFSMAN->SaveGlobalPrefsToDisk();
FOREACH_EnabledPlayer(pn) FOREACH_EnabledPlayer(pn)
{ {
+2 -2
View File
@@ -13,8 +13,8 @@ public:
void SendLogin(CString sPassword); void SendLogin(CString sPassword);
private: private:
void ImportOptions( int row, PlayerNumber pn ); void ImportOptions( int row, const vector<PlayerNumber> &vpns );
void ExportOptions( int row, PlayerNumber pn ); void ExportOptions( int row, const vector<PlayerNumber> &vpns );
void GoToNextScreen(); void GoToNextScreen();
void GoToPrevScreen(); void GoToPrevScreen();
CString GetSelectedProfileID(); CString GetSelectedProfileID();