diff --git a/stepmania/src/OptionRow.cpp b/stepmania/src/OptionRow.cpp index afd13b5c7f..513a3c4b03 100644 --- a/stepmania/src/OptionRow.cpp +++ b/stepmania/src/OptionRow.cpp @@ -720,9 +720,17 @@ void OptionRow::Reload() if( m_pHand == NULL ) return; - if( m_RowDef.m_bExportOnChange ) - FOREACH_HumanPlayer( p ) - ExportOptions( p, false ); + vector vpns; + FOREACH_HumanPlayer( p ) + 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 ); ASSERT( !m_RowDef.choices.empty() ); @@ -730,8 +738,8 @@ void OptionRow::Reload() FOREACH_PlayerNumber( p ) m_vbSelected[p].resize( m_RowDef.choices.size(), false ); - FOREACH_HumanPlayer( p ) - ImportOptions( p ); + // TODO: Nothing uses this yet and it causes skips when changing options. + //ImportOptions( vpns ); switch( m_RowDef.selectType ) { @@ -747,9 +755,13 @@ void OptionRow::Reload() ASSERT(0); } - if( m_RowDef.m_bExportOnChange ) - FOREACH_HumanPlayer( p ) - ExportOptions( p, false ); + // 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 ); + //} UpdateEnabledDisabled(); UpdateText(); @@ -792,24 +804,36 @@ static void VerifySelected( SelectType st, const vector &vbSelected, const } } -void OptionRow::ImportOptions( PlayerNumber pn ) +void OptionRow::ImportOptions( const vector &vpns ) { if( m_pHand == NULL ) return; ASSERT( m_RowDef.choices.size() > 0 ); - FOREACH( bool, m_vbSelected[pn], b ) - *b = false; + FOREACH_CONST( PlayerNumber, vpns, iter ) + { + PlayerNumber p = *iter; - ASSERT( m_vbSelected[pn].size() == m_RowDef.choices.size() ); - ERASE_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[pn] ); - 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 ); + FOREACH( bool, m_vbSelected[p], b ) + *b = false; + + ASSERT( m_vbSelected[p].size() == m_RowDef.choices.size() ); + ERASE_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[p] ); + } + + 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 &vpns, bool bRowHasFocus[NUM_PLAYERS] ) { if( m_pHand == NULL ) return 0; @@ -818,23 +842,36 @@ int OptionRow::ExportOptions( PlayerNumber pn, bool bRowHasFocus ) int iChangeMask = 0; - VerifySelected( m_RowDef.selectType, m_vbSelected[pn], m_RowDef.name ); - ASSERT( m_vbSelected[pn].size() == m_RowDef.choices.size() ); - ERASE_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[pn] ); + FOREACH_CONST( PlayerNumber, vpns, iter ) + { + PlayerNumber p = *iter; + bool bFocus = bRowHasFocus[p]; - // SELECT_NONE rows get exported if they have focus when the user presses - // Start. - int iChoice = GetChoiceInRowWithFocus( pn ); - if( m_RowDef.selectType == SELECT_NONE && bRowHasFocus ) - m_vbSelected[pn][iChoice] = true; + 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] ); - iChangeMask |= m_pHand->ExportOption( m_RowDef, pn, m_vbSelected[pn] ); - - if( m_RowDef.selectType == SELECT_NONE && bRowHasFocus ) - m_vbSelected[pn][iChoice] = false; - - INSERT_ONE_BOOL_AT_FRONT_IF_NEEDED( m_vbSelected[pn] ); + // SELECT_NONE rows get exported if they have focus when the user presses + // Start. + int iChoice = GetChoiceInRowWithFocus( p ); + if( m_RowDef.selectType == SELECT_NONE && bFocus ) + m_vbSelected[p][iChoice] = true; + } + + iChangeMask |= m_pHand->ExportOption( m_RowDef, vpns, m_vbSelected ); + FOREACH_CONST( PlayerNumber, vpns, iter ) + { + PlayerNumber p = *iter; + bool bFocus = bRowHasFocus[p]; + + 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; } diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index 9abe3fb5da..6dd1d7169c 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -90,8 +90,8 @@ public: CString GetRowTitle() const; - void ImportOptions( PlayerNumber pn ); - int ExportOptions( PlayerNumber pn, bool bRowHasFocus ); + void ImportOptions( const vector &vpns ); + int ExportOptions( const vector &vpns, bool bRowHasFocus[NUM_PLAYERS] ); void AfterImportOptions( float fY ); void DetachHandler(); diff --git a/stepmania/src/OptionRowHandler.cpp b/stepmania/src/OptionRowHandler.cpp index 979207ca30..6c16a472ae 100644 --- a/stepmania/src/OptionRowHandler.cpp +++ b/stepmania/src/OptionRowHandler.cpp @@ -151,75 +151,87 @@ public: defOut.choices.push_back( sChoice ); } } - void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector &vbSelectedOut ) const + void ImportOption( const OptionRowDefinition &def, const vector &vpns, vector vbSelectedOut[NUM_PLAYERS] ) const { int FallbackOption = -1; bool UseFallbackOption = true; - for( unsigned e = 0; e < ListEntries.size(); ++e ) + FOREACH_CONST( PlayerNumber, vpns, pn ) { - const GameCommand &mc = ListEntries[e]; + PlayerNumber p = *pn; + vector &vbSelOut = vbSelectedOut[p]; - vbSelectedOut[e] = false; - - if( mc.IsZero() ) + for( unsigned e = 0; e < ListEntries.size(); ++e ) { - /* 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( def.selectType != SELECT_MULTIPLE ) - FallbackOption = e; - continue; - } + const GameCommand &mc = ListEntries[e]; - if( def.bOneChoiceForAllPlayers ) - { - if( mc.DescribesCurrentModeForAllPlayers() ) + vbSelOut[e] = false; + + if( mc.IsZero() ) { - UseFallbackOption = false; + /* 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( def.selectType != SELECT_MULTIPLE ) - SelectExactlyOne( e, vbSelectedOut ); - else - vbSelectedOut[e] = true; + FallbackOption = e; + continue; + } + + if( def.bOneChoiceForAllPlayers ) + { + if( mc.DescribesCurrentModeForAllPlayers() ) + { + UseFallbackOption = false; + if( def.selectType != SELECT_MULTIPLE ) + SelectExactlyOne( e, vbSelOut ); + else + vbSelOut[e] = true; + } + } + else + { + if( mc.DescribesCurrentMode( p) ) + { + UseFallbackOption = false; + if( def.selectType != SELECT_MULTIPLE ) + SelectExactlyOne( e, vbSelOut ); + else + vbSelOut[e] = true; + } } } - else + + if( UseFallbackOption && FallbackOption == -1 ) { - if( mc.DescribesCurrentMode( pn) ) - { - UseFallbackOption = false; - if( def.selectType != SELECT_MULTIPLE ) - SelectExactlyOne( e, vbSelectedOut ); - else - vbSelectedOut[e] = true; - } + LOG->Warn( "No options in row \"%s\" were selected, and no fallback row found; selected entry 0", m_sName.c_str() ); + FallbackOption = 0; } - } - if( UseFallbackOption && FallbackOption == -1 ) - { - LOG->Warn( "No options in row \"%s\" were selected, and no fallback row found; selected entry 0", m_sName.c_str() ); - FallbackOption = 0; - } - - if( def.selectType == SELECT_ONE && - UseFallbackOption && - FallbackOption != -1 ) - { - SelectExactlyOne( FallbackOption, vbSelectedOut ); + if( def.selectType == SELECT_ONE && + UseFallbackOption && + FallbackOption != -1 ) + { + SelectExactlyOne( FallbackOption, vbSelOut ); + } } } - int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector &vbSelected ) const + int ExportOption( const OptionRowDefinition &def, const vector &vpns, const vector vbSelected[NUM_PLAYERS] ) const { - Default.Apply( pn ); - for( unsigned i=0; i &vbSel = vbSelected[p]; + + Default.Apply( p ); + for( unsigned i=0; iBroadcast( *s ); } - FOREACH_CONST( CString, m_vsBroadcastOnExport, s ) - MESSAGEMAN->Broadcast( *s ); return 0; } @@ -500,55 +512,103 @@ public: if( m_pLuaTable->GetLuaType() != LUA_TTABLE ) RageException::Throw( "Result of \"%s\" is not a table", sLuaFunction.c_str() ); + m_pLuaTable->PushSelf( LUA->L ); + + lua_pushstring( LUA->L, "Name" ); + lua_gettable( LUA->L, -2 ); + const char *pStr = lua_tostring( LUA->L, -1 ); + if( pStr == NULL ) + RageException::Throw( "\"%s\" \"Name\" entry is not a string", sLuaFunction.c_str() ); + defOut.name = pStr; + lua_pop( LUA->L, 1 ); + + + lua_pushstring( LUA->L, "OneChoiceForAllPlayers" ); + lua_gettable( LUA->L, -2 ); + defOut.bOneChoiceForAllPlayers = !!lua_toboolean( LUA->L, -1 ); + lua_pop( LUA->L, 1 ); + + + lua_pushstring( LUA->L, "ExportOnChange" ); + lua_gettable( LUA->L, -2 ); + defOut.m_bExportOnChange = !!lua_toboolean( LUA->L, -1 ); + lua_pop( LUA->L, 1 ); + + + lua_pushstring( LUA->L, "LayoutType" ); + lua_gettable( LUA->L, -2 ); + pStr = lua_tostring( LUA->L, -1 ); + if( pStr == NULL ) + RageException::Throw( "\"%s\" \"LayoutType\" entry is not a string", sLuaFunction.c_str() ); + defOut.layoutType = StringToLayoutType( pStr ); + ASSERT( defOut.layoutType != LAYOUT_INVALID ); + lua_pop( LUA->L, 1 ); + + + lua_pushstring( LUA->L, "SelectType" ); + lua_gettable( LUA->L, -2 ); + pStr = lua_tostring( LUA->L, -1 ); + if( pStr == NULL ) + RageException::Throw( "\"%s\" \"SelectType\" entry is not a string", sLuaFunction.c_str() ); + defOut.selectType = StringToSelectType( pStr ); + ASSERT( defOut.selectType != SELECT_INVALID ); + lua_pop( LUA->L, 1 ); + + + /* Iterate over the "Choices" table. */ + lua_pushstring( LUA->L, "Choices" ); + lua_gettable( LUA->L, -2 ); + if( !lua_istable( LUA->L, -1 ) ) + RageException::Throw( "\"%s\" \"Choices\" is not a table", sLuaFunction.c_str() ); + + lua_pushnil( LUA->L ); + while( lua_next(LUA->L, -2) != 0 ) { - m_pLuaTable->PushSelf( LUA->L ); + /* `key' is at index -2 and `value' at index -1 */ + const char *pValue = lua_tostring( LUA->L, -1 ); + if( pValue == NULL ) + RageException::Throw( "\"%s\" Column entry is not a string", sLuaFunction.c_str() ); +// LOG->Trace( "'%s'", pValue); - lua_pushstring( LUA->L, "Name" ); - lua_gettable( LUA->L, -2 ); - const char *pStr = lua_tostring( LUA->L, -1 ); - if( pStr == NULL ) - RageException::Throw( "\"%s\" \"Name\" entry is not a string", sLuaFunction.c_str() ); - defOut.name = pStr; - lua_pop( LUA->L, 1 ); + defOut.choices.push_back( pValue ); + + lua_pop( LUA->L, 1 ); /* removes `value'; keeps `key' for next iteration */ + } + + lua_pop( LUA->L, 1 ); /* pop choices table */ - lua_pushstring( LUA->L, "OneChoiceForAllPlayers" ); - lua_gettable( LUA->L, -2 ); - defOut.bOneChoiceForAllPlayers = !!lua_toboolean( LUA->L, -1 ); - lua_pop( LUA->L, 1 ); - - - lua_pushstring( LUA->L, "ExportOnChange" ); - lua_gettable( LUA->L, -2 ); - defOut.m_bExportOnChange = !!lua_toboolean( LUA->L, -1 ); - lua_pop( LUA->L, 1 ); - - - lua_pushstring( LUA->L, "LayoutType" ); - lua_gettable( LUA->L, -2 ); - pStr = lua_tostring( LUA->L, -1 ); - if( pStr == NULL ) - RageException::Throw( "\"%s\" \"LayoutType\" entry is not a string", sLuaFunction.c_str() ); - defOut.layoutType = StringToLayoutType( pStr ); - ASSERT( defOut.layoutType != LAYOUT_INVALID ); - lua_pop( LUA->L, 1 ); - - - lua_pushstring( LUA->L, "SelectType" ); - lua_gettable( LUA->L, -2 ); - pStr = lua_tostring( LUA->L, -1 ); - if( pStr == NULL ) - RageException::Throw( "\"%s\" \"SelectType\" entry is not a string", sLuaFunction.c_str() ); - defOut.selectType = StringToSelectType( pStr ); - ASSERT( defOut.selectType != SELECT_INVALID ); - lua_pop( LUA->L, 1 ); - - - /* Iterate over the "Choices" table. */ - lua_pushstring( LUA->L, "Choices" ); - lua_gettable( LUA->L, -2 ); + /* Iterate over the "EnabledForPlayers" table. */ + lua_pushstring( LUA->L, "EnabledForPlayers" ); + lua_gettable( LUA->L, -2 ); + if( !lua_isnil( LUA->L, -1 ) ) + { if( !lua_istable( LUA->L, -1 ) ) - RageException::Throw( "\"%s\" \"Choices\" is not a table", sLuaFunction.c_str() ); + RageException::Throw( "\"%s\" \"EnabledForPlayers\" is not a table", sLuaFunction.c_str() ); + + defOut.m_vEnabledForPlayers.clear(); // and fill in with supplied PlayerNumbers below + + lua_pushnil( LUA->L ); + while( lua_next(LUA->L, -2) != 0 ) + { + /* `key' is at index -2 and `value' at index -1 */ + PlayerNumber pn = (PlayerNumber)luaL_checkint( LUA->L, -1 ); + + defOut.m_vEnabledForPlayers.insert( pn ); + + lua_pop( LUA->L, 1 ); /* removes `value'; keeps `key' for next iteration */ + } + } + lua_pop( LUA->L, 1 ); /* pop EnabledForPlayers table */ + + + /* Iterate over the "ReloadRowMessages" table. */ + lua_pushstring( LUA->L, "ReloadRowMessages" ); + lua_gettable( LUA->L, -2 ); + if( !lua_isnil( LUA->L, -1 ) ) + { + if( !lua_istable( LUA->L, -1 ) ) + RageException::Throw( "\"%s\" \"ReloadRowMessages\" is not a table", sLuaFunction.c_str() ); lua_pushnil( LUA->L ); while( lua_next(LUA->L, -2) != 0 ) @@ -557,192 +617,165 @@ public: const char *pValue = lua_tostring( LUA->L, -1 ); if( pValue == NULL ) RageException::Throw( "\"%s\" Column entry is not a string", sLuaFunction.c_str() ); -// LOG->Trace( "'%s'", pValue); + LOG->Trace( "Found ReloadRowMessage '%s'", pValue); - defOut.choices.push_back( pValue ); + m_vsReloadRowMessages.push_back( pValue ); 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 choices table */ + + /* Look for "ExportOnChange" value. */ + lua_pushstring( LUA->L, "ExportOnChange" ); + lua_gettable( LUA->L, -2 ); + if( !lua_isnil( LUA->L, -1 ) ) + { + defOut.m_bExportOnChange = !!MyLua_checkboolean( LUA->L, -1 ); + } + lua_pop( LUA->L, 1 ); /* pop ExportOnChange value */ - /* Iterate over the "EnabledForPlayers" table. */ - lua_pushstring( LUA->L, "EnabledForPlayers" ); - lua_gettable( LUA->L, -2 ); - if( !lua_isnil( LUA->L, -1 ) ) + lua_pop( LUA->L, 1 ); /* pop main table */ + 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 ); + if( !lua_isnil( LUA->L, -1 ) ) + { + if( !lua_istable( LUA->L, -1 ) ) + RageException::Throw( "\"%s\" \"EnabledForPlayers\" is not a table", m_sName.c_str() ); + + defOut.m_vEnabledForPlayers.clear(); // and fill in with supplied PlayerNumbers below + + lua_pushnil( LUA->L ); + while( lua_next(LUA->L, -2) != 0 ) { - if( !lua_istable( LUA->L, -1 ) ) - RageException::Throw( "\"%s\" \"EnabledForPlayers\" is not a table", sLuaFunction.c_str() ); + /* `key' is at index -2 and `value' at index -1 */ + PlayerNumber pn = (PlayerNumber)luaL_checkint( LUA->L, -1 ); - defOut.m_vEnabledForPlayers.clear(); // and fill in with supplied PlayerNumbers below + defOut.m_vEnabledForPlayers.insert( pn ); - lua_pushnil( LUA->L ); - while( lua_next(LUA->L, -2) != 0 ) - { - /* `key' is at index -2 and `value' at index -1 */ - PlayerNumber pn = (PlayerNumber)luaL_checkint( LUA->L, -1 ); - - 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 EnabledForPlayers table */ + } + lua_pop( LUA->L, 1 ); /* pop EnabledForPlayers table */ + + lua_pop( LUA->L, 1 ); /* pop main table */ + ASSERT( lua_gettop(LUA->L) == 0 ); + } + virtual void ImportOption( const OptionRowDefinition &def, const vector &vpns, vector vbSelectedOut[NUM_PLAYERS] ) const + { + ASSERT( lua_gettop(LUA->L) == 0 ); + + FOREACH_CONST( PlayerNumber, vpns, pn ) + { + PlayerNumber p = *pn; + vector &vbSelOut = vbSelectedOut[p]; + + /* Evaluate the LoadSelections(self,array,pn) function, where array is a table + * representing vbSelectedOut. */ + + /* All selections default to false. */ + for( unsigned i = 0; i < vbSelOut.size(); ++i ) + vbSelOut[i] = false; + + /* Create the vbSelectedOut table. */ + LUA->CreateTableFromArrayB( vbSelOut ); + ASSERT( lua_gettop(LUA->L) == 1 ); /* vbSelectedOut table */ + + /* Get the function to call from m_LuaTable. */ + m_pLuaTable->PushSelf( LUA->L ); + ASSERT( lua_istable( LUA->L, -1 ) ); + + lua_pushstring( LUA->L, "LoadSelections" ); + lua_gettable( LUA->L, -2 ); + if( !lua_isfunction( LUA->L, -1 ) ) + RageException::Throw( "\"%s\" \"LoadSelections\" entry is not a function", def.name.c_str() ); + + /* Argument 1 (self): */ + m_pLuaTable->PushSelf( LUA->L ); + + /* Argument 2 (vbSelectedOut): */ + lua_pushvalue( LUA->L, 1 ); + + /* Argument 3 (pn): */ + LuaHelpers::PushStack( (int) p ); + + ASSERT( lua_gettop(LUA->L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ + + lua_call( LUA->L, 3, 0 ); // call function with 3 arguments and 0 results + ASSERT( lua_gettop(LUA->L) == 2 ); + + lua_pop( LUA->L, 1 ); /* pop option table */ + + LUA->ReadArrayFromTableB( vbSelOut ); - /* Iterate over the "ReloadRowMessages" table. */ - lua_pushstring( LUA->L, "ReloadRowMessages" ); - lua_gettable( LUA->L, -2 ); - if( !lua_isnil( LUA->L, -1 ) ) - { - if( !lua_istable( LUA->L, -1 ) ) - RageException::Throw( "\"%s\" \"ReloadRowMessages\" is not a table", sLuaFunction.c_str() ); + lua_pop( LUA->L, 1 ); /* pop vbSelectedOut table */ - lua_pushnil( LUA->L ); - while( lua_next(LUA->L, -2) != 0 ) - { - /* `key' is at index -2 and `value' at index -1 */ - const char *pValue = lua_tostring( 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 ); - - lua_pop( LUA->L, 1 ); /* removes `value'; keeps `key' for next iteration */ - } - } - lua_pop( LUA->L, 1 ); /* pop ReloadRowMessages table */ - - - /* Look for "ExportOnChange" value. */ - lua_pushstring( LUA->L, "ExportOnChange" ); - lua_gettable( LUA->L, -2 ); - if( !lua_isnil( LUA->L, -1 ) ) - { - defOut.m_bExportOnChange = !!MyLua_checkboolean( LUA->L, -1 ); - } - lua_pop( LUA->L, 1 ); /* pop ExportOnChange value */ - - - /* Iterate over the "ReloadRowMessages" table. */ - lua_pushstring( LUA->L, "ReloadRowMessages" ); - lua_gettable( LUA->L, -2 ); - if( !lua_isnil( LUA->L, -1 ) ) - { - if( !lua_istable( LUA->L, -1 ) ) - RageException::Throw( "\"%s\" \"ReloadRowMessages\" is not a table", sLuaFunction.c_str() ); - - m_vsReloadRowMessages.clear(); // and fill in with supplied PlayerNumbers below - - lua_pushnil( LUA->L ); - while( lua_next(LUA->L, -2) != 0 ) - { - /* `key' is at index -2 and `value' at index -1 */ - const char *pValue = lua_tostring( 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 ); - - 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 main table */ ASSERT( lua_gettop(LUA->L) == 0 ); } } - virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector &vbSelectedOut ) const + virtual int ExportOption( const OptionRowDefinition &def, const vector &vpns, const vector vbSelected[NUM_PLAYERS] ) const { ASSERT( lua_gettop(LUA->L) == 0 ); - /* Evaluate the LoadSelections(self,array,pn) function, where array is a table - * representing vbSelectedOut. */ + FOREACH_CONST( PlayerNumber, vpns, pn ) + { + PlayerNumber p = *pn; + const vector &vbSel = vbSelected[p]; - /* All selections default to false. */ - for( unsigned i = 0; i < vbSelectedOut.size(); ++i ) - vbSelectedOut[i] = false; + /* Evaluate SaveSelections(self,array,pn) function, where array is a table + * representing vbSelectedOut. */ - /* Create the vbSelectedOut table. */ - LUA->CreateTableFromArrayB( vbSelectedOut ); - ASSERT( lua_gettop(LUA->L) == 1 ); /* vbSelectedOut table */ + vector vbSelectedCopy = vbSel; - /* Get the function to call from m_LuaTable. */ - m_pLuaTable->PushSelf( LUA->L ); - ASSERT( lua_istable( LUA->L, -1 ) ); + /* Create the vbSelectedOut table. */ + LUA->CreateTableFromArrayB( vbSelectedCopy ); + ASSERT( lua_gettop(LUA->L) == 1 ); /* vbSelectedOut table */ - lua_pushstring( LUA->L, "LoadSelections" ); - lua_gettable( LUA->L, -2 ); - if( !lua_isfunction( LUA->L, -1 ) ) - RageException::Throw( "\"%s\" \"LoadSelections\" entry is not a function", def.name.c_str() ); + /* Get the function to call. */ + m_pLuaTable->PushSelf( LUA->L ); + ASSERT( lua_istable( LUA->L, -1 ) ); - /* Argument 1 (self): */ - m_pLuaTable->PushSelf( LUA->L ); + lua_pushstring( LUA->L, "SaveSelections" ); + lua_gettable( LUA->L, -2 ); + if( !lua_isfunction( LUA->L, -1 ) ) + RageException::Throw( "\"%s\" \"SaveSelections\" entry is not a function", def.name.c_str() ); - /* Argument 2 (vbSelectedOut): */ - lua_pushvalue( LUA->L, 1 ); + /* Argument 1 (self): */ + m_pLuaTable->PushSelf( LUA->L ); - /* Argument 3 (pn): */ - LuaHelpers::PushStack( (int) pn ); + /* Argument 2 (vbSelectedOut): */ + lua_pushvalue( LUA->L, 1 ); - ASSERT( lua_gettop(LUA->L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ + /* Argument 3 (pn): */ + LuaHelpers::PushStack( (int) p ); - lua_call( LUA->L, 3, 0 ); // call function with 3 arguments and 0 results - ASSERT( lua_gettop(LUA->L) == 2 ); + ASSERT( lua_gettop(LUA->L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ - lua_pop( LUA->L, 1 ); /* pop option table */ + lua_call( LUA->L, 3, 0 ); // call function with 3 arguments and 0 results + ASSERT( lua_gettop(LUA->L) == 2 ); - LUA->ReadArrayFromTableB( vbSelectedOut ); - - lua_pop( LUA->L, 1 ); /* pop vbSelectedOut table */ + lua_pop( LUA->L, 1 ); /* pop option table */ + lua_pop( LUA->L, 1 ); /* pop vbSelected table */ - ASSERT( lua_gettop(LUA->L) == 0 ); - } - virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector &vbSelected ) const - { - ASSERT( lua_gettop(LUA->L) == 0 ); - - /* Evaluate SaveSelections(self,array,pn) function, where array is a table - * representing vbSelectedOut. */ - - vector vbSelectedCopy = vbSelected; - - /* Create the vbSelectedOut table. */ - LUA->CreateTableFromArrayB( vbSelectedCopy ); - ASSERT( lua_gettop(LUA->L) == 1 ); /* vbSelectedOut table */ - - /* Get the function to call. */ - m_pLuaTable->PushSelf( LUA->L ); - ASSERT( lua_istable( LUA->L, -1 ) ); - - lua_pushstring( LUA->L, "SaveSelections" ); - lua_gettable( LUA->L, -2 ); - if( !lua_isfunction( LUA->L, -1 ) ) - RageException::Throw( "\"%s\" \"SaveSelections\" entry is not a function", def.name.c_str() ); - - /* Argument 1 (self): */ - m_pLuaTable->PushSelf( LUA->L ); - - /* Argument 2 (vbSelectedOut): */ - lua_pushvalue( LUA->L, 1 ); - - /* Argument 3 (pn): */ - LuaHelpers::PushStack( (int) pn ); - - ASSERT( lua_gettop(LUA->L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ - - lua_call( LUA->L, 3, 0 ); // call function with 3 arguments and 0 results - ASSERT( lua_gettop(LUA->L) == 2 ); - - lua_pop( LUA->L, 1 ); /* pop option 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 return 0; @@ -781,29 +814,43 @@ public: defOut.name = opt->name; } - virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector &vbSelectedOut ) const + virtual void ImportOption( const OptionRowDefinition &def, const vector &vpns, vector vbSelectedOut[NUM_PLAYERS] ) const { - int iSelection = opt->Get(); - SelectExactlyOne( iSelection, vbSelectedOut ); + FOREACH_CONST( PlayerNumber, vpns, pn ) + { + PlayerNumber p = *pn; + vector &vbSelOut = vbSelectedOut[p]; + + int iSelection = opt->Get(); + SelectExactlyOne( iSelection, vbSelOut ); + } } - virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector &vbSelected ) const + virtual int ExportOption( const OptionRowDefinition &def, const vector &vpns, const vector vbSelected[NUM_PLAYERS] ) const { - int sel = GetOneSelection(vbSelected); + bool bChanged = false; - /* Get the original choice. */ - int Original = opt->Get(); + FOREACH_CONST( PlayerNumber, vpns, pn ) + { + PlayerNumber p = *pn; + const vector &vbSel = vbSelected[p]; - /* Apply. */ - opt->Put( sel ); + int sel = GetOneSelection(vbSel); - /* Get the new choice. */ - int New = opt->Get(); + /* Get the original choice. */ + int Original = opt->Get(); - /* If it didn't change, don't return any side-effects. */ - if( Original == New ) - return 0; + /* Apply. */ + opt->Put( sel ); - return opt->GetEffects(); + /* Get the new choice. */ + int New = opt->Get(); + + /* If it didn't change, don't return any side-effects. */ + if( Original != New ) + bChanged = true; + } + + return bChanged ? opt->GetEffects() : 0; } }; @@ -864,25 +911,38 @@ public: if( *m_pstToFill == STEPS_TYPE_INVALID ) m_pstToFill->Set( m_vStepsTypesToShow[0] ); } - virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector &vbSelectedOut ) const + virtual void ImportOption( const OptionRowDefinition &def, const vector &vpns, vector vbSelectedOut[NUM_PLAYERS] ) const { - if( GAMESTATE->m_pCurSteps[0] ) + FOREACH_CONST( PlayerNumber, vpns, pn ) { - StepsType st = GAMESTATE->m_pCurSteps[0]->m_StepsType; - vector::const_iterator iter = find( m_vStepsTypesToShow.begin(), m_vStepsTypesToShow.end(), st ); - if( iter != m_vStepsTypesToShow.end() ) + PlayerNumber p = *pn; + vector &vbSelOut = vbSelectedOut[p]; + + if( GAMESTATE->m_pCurSteps[0] ) { - unsigned i = iter - m_vStepsTypesToShow.begin(); - vbSelectedOut[i] = true; - return; + StepsType st = GAMESTATE->m_pCurSteps[0]->m_StepsType; + vector::const_iterator iter = find( m_vStepsTypesToShow.begin(), m_vStepsTypesToShow.end(), st ); + if( iter != m_vStepsTypesToShow.end() ) + { + unsigned i = iter - m_vStepsTypesToShow.begin(); + vbSelOut[i] = true; + continue; // done with this player + } } + vbSelOut[0] = true; } - vbSelectedOut[0] = true; } - virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector &vbSelected ) const + virtual int ExportOption( const OptionRowDefinition &def, const vector &vpns, const vector vbSelected[NUM_PLAYERS] ) const { - int index = GetOneSelection( vbSelected ); - m_pstToFill->Set( m_vStepsTypesToShow[index] ); + FOREACH_CONST( PlayerNumber, vpns, pn ) + { + PlayerNumber p = *pn; + const vector &vbSel = vbSelected[p]; + + int index = GetOneSelection( vbSel ); + m_pstToFill->Set( m_vStepsTypesToShow[index] ); + } + return 0; } }; @@ -992,43 +1052,58 @@ public: m_pDifficultyToFill->Set( m_vDifficulties[0] ); m_ppStepsToFill->Set( m_vSteps[0] ); } - virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector &vbSelectedOut ) const + virtual void ImportOption( const OptionRowDefinition &def, const vector &vpns, vector vbSelectedOut[NUM_PLAYERS] ) const { - ASSERT( m_vSteps.size() == vbSelectedOut.size() ); + FOREACH_CONST( PlayerNumber, vpns, pn ) + { + PlayerNumber p = *pn; + vector &vbSelOut = vbSelectedOut[p]; - // look for matching steps - vector::const_iterator iter = find( m_vSteps.begin(), m_vSteps.end(), m_ppStepsToFill->Get() ); - if( iter != m_vSteps.end() ) - { - unsigned i = iter - m_vSteps.begin(); - vbSelectedOut[i] = true; - return; - } - // look for matching difficulty - if( m_pDifficultyToFill ) - { - FOREACH_CONST( Difficulty, m_vDifficulties, d ) + ASSERT( m_vSteps.size() == vbSelOut.size() ); + + // look for matching steps + vector::const_iterator iter = find( m_vSteps.begin(), m_vSteps.end(), m_ppStepsToFill->Get() ); + if( iter != m_vSteps.end() ) { - unsigned i = d - m_vDifficulties.begin(); - if( *d == GAMESTATE->m_PreferredDifficulty[0] ) + unsigned i = iter - m_vSteps.begin(); + vbSelOut[i] = true; + return; + } + // look for matching difficulty + if( m_pDifficultyToFill ) + { + FOREACH_CONST( Difficulty, m_vDifficulties, d ) { - vbSelectedOut[i] = true; - ExportOption( def, pn, vbSelectedOut ); // current steps changed - return; + unsigned i = d - m_vDifficulties.begin(); + if( *d == GAMESTATE->m_PreferredDifficulty[0] ) + { + vbSelOut[i] = true; + vector v; + v.push_back( p ); + ExportOption( def, v, vbSelectedOut ); // current steps changed + continue; + } } } + // default to 1st + vbSelOut[0] = true; } - // default to 1st - vbSelectedOut[0] = true; } - virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector &vbSelected ) const + virtual int ExportOption( const OptionRowDefinition &def, const vector &vpns, const vector vbSelected[NUM_PLAYERS] ) const { - int index = GetOneSelection( vbSelected ); - Difficulty dc = m_vDifficulties[index]; - Steps *pSteps = m_vSteps[index]; - if( m_pDifficultyToFill ) - m_pDifficultyToFill->Set( dc ); - m_ppStepsToFill->Set( pSteps ); + FOREACH_CONST( PlayerNumber, vpns, pn ) + { + PlayerNumber p = *pn; + const vector &vbSel = vbSelected[p]; + + int index = GetOneSelection( vbSel ); + Difficulty dc = m_vDifficulties[index]; + Steps *pSteps = m_vSteps[index]; + if( m_pDifficultyToFill ) + m_pDifficultyToFill->Set( dc ); + m_ppStepsToFill->Set( pSteps ); + } + return 0; } }; diff --git a/stepmania/src/OptionRowHandler.h b/stepmania/src/OptionRowHandler.h index 2bb5642515..aebe1e1129 100644 --- a/stepmania/src/OptionRowHandler.h +++ b/stepmania/src/OptionRowHandler.h @@ -23,10 +23,10 @@ public: m_vsReloadRowMessages.clear(); } virtual void Load( OptionRowDefinition &defOut, CString sParam ) = 0; - void Reload( OptionRowDefinition &defOut ) { this->Load(defOut,m_sName); } - virtual void ImportOption( const OptionRowDefinition &row, PlayerNumber pn, vector &vbSelectedOut ) const = 0; + virtual void Reload( OptionRowDefinition &defOut ) { this->Load(defOut,m_sName); } + virtual void ImportOption( const OptionRowDefinition &row, const vector &vpns, vector vbSelectedOut[NUM_PLAYERS] ) const = 0; /* Returns an OPT mask. */ - virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector &vbSelected ) const = 0; + virtual int ExportOption( const OptionRowDefinition &def, const vector &vpns, const vector vbSelected[NUM_PLAYERS] ) const = 0; virtual CString GetIconText( const OptionRowDefinition &def, int iFirstSelection ) const { return ""; } virtual bool HasScreen( int iChoice ) const { return false; } }; diff --git a/stepmania/src/ScreenMiniMenu.cpp b/stepmania/src/ScreenMiniMenu.cpp index 9350132e89..c90fe66da3 100644 --- a/stepmania/src/ScreenMiniMenu.cpp +++ b/stepmania/src/ScreenMiniMenu.cpp @@ -86,7 +86,7 @@ void ScreenMiniMenu::Init( const Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMe ScreenOptions::InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands ); } -void ScreenMiniMenu::ImportOptions( int r, PlayerNumber pn ) +void ScreenMiniMenu::ImportOptions( int r, const vector &vpns ) { OptionRow &optrow = *m_Rows[r]; MenuRow &mr = m_vMenuRows[r]; @@ -94,7 +94,7 @@ void ScreenMiniMenu::ImportOptions( int r, PlayerNumber pn ) optrow.SetOneSharedSelection( mr.iDefaultChoice ); } -void ScreenMiniMenu::ExportOptions( int r, PlayerNumber pn ) +void ScreenMiniMenu::ExportOptions( int r, const vector &vpns ) { if( r == GetCurrentRow() ) s_iLastRowCode = m_vMenuRows[r].iRowCode; diff --git a/stepmania/src/ScreenMiniMenu.h b/stepmania/src/ScreenMiniMenu.h index 5c3eb627e0..5261bc35db 100644 --- a/stepmania/src/ScreenMiniMenu.h +++ b/stepmania/src/ScreenMiniMenu.h @@ -58,8 +58,8 @@ public: ScreenMiniMenu( CString sScreenClass ); void Init( const Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel ); protected: - virtual void ImportOptions( int row, PlayerNumber pn ); - virtual void ExportOptions( int row, PlayerNumber pn ); + virtual void ImportOptions( int row, const vector &vpns ); + virtual void ExportOptions( int row, const vector &vpns ); virtual void GoToNextScreen(); virtual void GoToPrevScreen(); diff --git a/stepmania/src/ScreenNetworkOptions.cpp b/stepmania/src/ScreenNetworkOptions.cpp index 9abf318801..f5ade2ced3 100644 --- a/stepmania/src/ScreenNetworkOptions.cpp +++ b/stepmania/src/ScreenNetworkOptions.cpp @@ -154,8 +154,8 @@ void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type #endif } -void ScreenNetworkOptions::ImportOptions( int row, PlayerNumber pn ) { } -void ScreenNetworkOptions::ExportOptions( int row, PlayerNumber pn ) { } +void ScreenNetworkOptions::ImportOptions( int row, const vector &vpns ) { } +void ScreenNetworkOptions::ExportOptions( int row, const vector &vpns ) { } void ScreenNetworkOptions::UpdateConnectStatus( ) { diff --git a/stepmania/src/ScreenNetworkOptions.h b/stepmania/src/ScreenNetworkOptions.h index 7c8db3a96c..6accc45203 100644 --- a/stepmania/src/ScreenNetworkOptions.h +++ b/stepmania/src/ScreenNetworkOptions.h @@ -14,8 +14,8 @@ public: virtual void MenuStart( PlayerNumber pn, const InputEventType type ); private: - void ImportOptions( int row, PlayerNumber pn ); - void ExportOptions( int row, PlayerNumber pn ); + void ImportOptions( int row, const vector &vpns ); + void ExportOptions( int row, const vector &vpns ); void GoToNextScreen(); void GoToPrevScreen(); diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index 68a7485e77..33dba58ba6 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -154,8 +154,10 @@ void ScreenOptions::InitMenu( InputMode im, const vector &v row.LoadMetrics( m_sName ); row.LoadNormal( def, hand, bFirstRowGoesDown ); + vector vpns; 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()) ); @@ -511,8 +513,12 @@ void ScreenOptions::HandleScreenMessage( const ScreenMessage SM ) break; case SM_GoToNextScreen: for( unsigned r=0; r vpns; FOREACH_HumanPlayer( p ) - this->ExportOptions( r, p ); + vpns.push_back( p ); + this->ExportOptions( r, vpns ); + } this->GoToNextScreen(); break; case SM_BeginFadingOut: @@ -999,8 +1005,12 @@ void ScreenOptions::ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat ) m_SoundChangeCol.Play(); if( row.GetRowDef().m_bExportOnChange ) + { + vector vpns; FOREACH_HumanPlayer( p ) - ExportOptions( iCurRow, p ); + vpns.push_back( p ); + ExportOptions( iCurRow, vpns ); + } } diff --git a/stepmania/src/ScreenOptions.h b/stepmania/src/ScreenOptions.h index 3060ad118d..513935d385 100644 --- a/stepmania/src/ScreenOptions.h +++ b/stepmania/src/ScreenOptions.h @@ -34,8 +34,8 @@ public: virtual void HandleScreenMessage( const ScreenMessage SM ); protected: - virtual void ImportOptions( int row, PlayerNumber pn ) = 0; - virtual void ExportOptions( int row, PlayerNumber pn ) = 0; + virtual void ImportOptions( int row, const vector &vpns ) = 0; + virtual void ExportOptions( int row, const vector &vpns ) = 0; void InitOptionsText(); void GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ); diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index d94bf8c8dd..40b11407d8 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -105,18 +105,22 @@ ScreenOptionsMaster::~ScreenOptionsMaster() OptionRowHandlers.clear(); } -void ScreenOptionsMaster::ImportOptions( int r, PlayerNumber pn ) +void ScreenOptionsMaster::ImportOptions( int r, const vector &vpns ) { - ASSERT( GAMESTATE->IsHumanPlayer(pn) ); + FOREACH_CONST( PlayerNumber, vpns, pn ) + ASSERT( GAMESTATE->IsHumanPlayer(*pn) ); 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 &vpns ) { OptionRow &row = *m_Rows[r]; - bool bRowHasFocus = m_iCurrentRow[pn] == r; - m_iChangeMask |= row.ExportOptions( pn, bRowHasFocus ); + bool bRowHasFocus[NUM_PLAYERS]; + ZERO( bRowHasFocus ); + FOREACH_CONST( PlayerNumber, vpns, pn ) + bRowHasFocus[*pn] = m_iCurrentRow[*pn] == r; + m_iChangeMask |= row.ExportOptions( vpns, bRowHasFocus ); } void ScreenOptionsMaster::BeginFadingOut() @@ -216,8 +220,10 @@ void ScreenOptionsMaster::HandleScreenMessage( const ScreenMessage SM ) { CHECKPOINT_M( ssprintf("%i/%i", r, int(OptionRowHandlers.size())) ); + vector vpns; FOREACH_OptionsPlayer( p ) - ExportOptions( r, p ); + vpns.push_back( p ); + ExportOptions( r, vpns ); } if( m_iChangeMask & OPT_APPLY_ASPECT_RATIO ) diff --git a/stepmania/src/ScreenOptionsMaster.h b/stepmania/src/ScreenOptionsMaster.h index 01962db0a1..7d1e97a6df 100644 --- a/stepmania/src/ScreenOptionsMaster.h +++ b/stepmania/src/ScreenOptionsMaster.h @@ -21,8 +21,8 @@ protected: protected: void HandleScreenMessage( const ScreenMessage SM ); - virtual void ImportOptions( int row, PlayerNumber pn ); - virtual void ExportOptions( int row, PlayerNumber pn ); + virtual void ImportOptions( int row, const vector &vpns ); + virtual void ExportOptions( int row, const vector &vpns ); virtual void BeginFadingOut(); virtual void GoToNextScreen(); diff --git a/stepmania/src/ScreenPlayerOptions.cpp b/stepmania/src/ScreenPlayerOptions.cpp index 097e4a8d76..70a9ed000f 100644 --- a/stepmania/src/ScreenPlayerOptions.cpp +++ b/stepmania/src/ScreenPlayerOptions.cpp @@ -150,7 +150,9 @@ void ScreenPlayerOptions::Input( const DeviceInput& DeviceI, const InputEventTyp for( unsigned r=0; rImportOptions( r, pn ); + vector v; + v.push_back( pn ); + this->ImportOptions( r, v ); this->PositionUnderlines( 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. // Exporting the row will fill GAMESTATE->m_PlayerOptions. GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions = PlayerOptions(); - ExportOptions( row, pn ); + vector v; + v.push_back( pn ); + ExportOptions( row, v ); bool bRowCausesDisqualified = GAMESTATE->IsDisqualified( pn ); m_bRowCausesDisqualified[pn][row] = bRowCausesDisqualified; diff --git a/stepmania/src/ScreenProfileOptions.cpp b/stepmania/src/ScreenProfileOptions.cpp index 9f793d1152..c9336ca5e7 100644 --- a/stepmania/src/ScreenProfileOptions.cpp +++ b/stepmania/src/ScreenProfileOptions.cpp @@ -84,12 +84,8 @@ void ScreenProfileOptions::Init() SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions","music") ); } -void ScreenProfileOptions::ImportOptions( int row, PlayerNumber pn ) +void ScreenProfileOptions::ImportOptions( int row, const vector &vpns ) { - // Only take action for the master player - if( pn != GAMESTATE->m_MasterPlayerNumber ) - return; - switch( row ) { 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 &vpns ) { - // Only take action for the master player - if( pn != GAMESTATE->m_MasterPlayerNumber ) - return; - switch( row ) { case PO_PLAYER1: diff --git a/stepmania/src/ScreenProfileOptions.h b/stepmania/src/ScreenProfileOptions.h index a3d17323fd..138fdcd550 100644 --- a/stepmania/src/ScreenProfileOptions.h +++ b/stepmania/src/ScreenProfileOptions.h @@ -14,8 +14,8 @@ public: virtual void MenuStart( PlayerNumber pn, const InputEventType type ); private: - void ImportOptions( int row, PlayerNumber pn ); - void ExportOptions( int row, PlayerNumber pn ); + void ImportOptions( int row, const vector &vpns ); + void ExportOptions( int row, const vector &vpns ); void GoToNextScreen(); void GoToPrevScreen(); diff --git a/stepmania/src/ScreenSMOnlineLogin.cpp b/stepmania/src/ScreenSMOnlineLogin.cpp index f153a5c0bb..26fc3b3223 100644 --- a/stepmania/src/ScreenSMOnlineLogin.cpp +++ b/stepmania/src/ScreenSMOnlineLogin.cpp @@ -58,12 +58,8 @@ void ScreenSMOnlineLogin::Init() } } -void ScreenSMOnlineLogin::ImportOptions( int row, PlayerNumber pn ) +void ScreenSMOnlineLogin::ImportOptions( int row, const vector &vpns ) { - // Only take action for the master player - if( pn != GAMESTATE->m_MasterPlayerNumber ) - return; - switch( row ) { 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 &vpns ) { - // Only take action for the master player - if( pn != GAMESTATE->m_MasterPlayerNumber ) - return; - switch( row ) { case 0: @@ -113,8 +105,11 @@ void ScreenSMOnlineLogin::GoToPrevScreen() void ScreenSMOnlineLogin::GoToNextScreen() { + vector v; + v.push_back( GAMESTATE->m_MasterPlayerNumber ); for( unsigned r=0; rm_MasterPlayerNumber ); + ExportOptions( r, v ); + PREFSMAN->SaveGlobalPrefsToDisk(); FOREACH_EnabledPlayer(pn) { diff --git a/stepmania/src/ScreenSMOnlineLogin.h b/stepmania/src/ScreenSMOnlineLogin.h index 1cbcc41ab0..cb95358862 100644 --- a/stepmania/src/ScreenSMOnlineLogin.h +++ b/stepmania/src/ScreenSMOnlineLogin.h @@ -13,8 +13,8 @@ public: void SendLogin(CString sPassword); private: - void ImportOptions( int row, PlayerNumber pn ); - void ExportOptions( int row, PlayerNumber pn ); + void ImportOptions( int row, const vector &vpns ); + void ExportOptions( int row, const vector &vpns ); void GoToNextScreen(); void GoToPrevScreen(); CString GetSelectedProfileID();