From 3ee87782eb9c80443472d3420fe0ce2e67cd7413 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 13 Mar 2005 01:43:44 +0000 Subject: [PATCH] optimize UpdateDisqualified: only export options for the current row --- stepmania/src/ScreenPlayerOptions.cpp | 53 ++++++++++++++++++--------- stepmania/src/ScreenPlayerOptions.h | 3 +- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/stepmania/src/ScreenPlayerOptions.cpp b/stepmania/src/ScreenPlayerOptions.cpp index 132712e67b..71dde35a2d 100644 --- a/stepmania/src/ScreenPlayerOptions.cpp +++ b/stepmania/src/ScreenPlayerOptions.cpp @@ -12,6 +12,7 @@ #include "ScreenDimensions.h" #include "Style.h" #include "PlayerState.h" +#include "Foreach.h" #define PREV_SCREEN THEME->GetMetric ("ScreenPlayerOptions","PrevScreen") @@ -65,8 +66,12 @@ void ScreenPlayerOptions::Init() this->AddChild( m_sprCancelAll[p] ); } - FOREACH_HumanPlayer( p ) - UpdateDisqualified( p ); + FOREACH_PlayerNumber( p ) + { + m_bRowCausesDisqualified[p].resize( m_Rows.size(), false ); + for( unsigned r=0; rImportOptions( r, pn ); this->PositionUnderlines(); - this->UpdateDisqualified( pn ); + for( unsigned r=0; rUpdateDisqualified( r, pn ); } ScreenOptionsMaster::Input( DeviceI, type, GameI, MenuI, StyleI ); // UGLY: Update m_Disqualified whenever Start is pressed if( MenuI.IsValid() && MenuI.button == MENU_BUTTON_START ) - UpdateDisqualified( pn ); + { + int row = m_iCurrentRow[pn]; + UpdateDisqualified( row, pn ); + } } void ScreenPlayerOptions::HandleScreenMessage( const ScreenMessage SM ) @@ -184,24 +193,32 @@ void ScreenPlayerOptions::HandleScreenMessage( const ScreenMessage SM ) ScreenOptionsMaster::HandleScreenMessage( SM ); } -void ScreenPlayerOptions::UpdateDisqualified( PlayerNumber pn ) +void ScreenPlayerOptions::UpdateDisqualified( int row, PlayerNumber pn ) { - // save current player options - PlayerOptions po = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions; - - // export the currently selection options, which will fill GAMESTATE->m_PlayerOptions - for( unsigned r=0; rm_pPlayerState[pn]->m_PlayerOptions; - FOREACH_HumanPlayer( p ) + // 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 ); + bool bRowCausesDisqualified = GAMESTATE->IsDisqualified( pn ); + m_bRowCausesDisqualified[pn][row] = bRowCausesDisqualified; + + // Update disqualified graphic + bool bDisqualified = false; + FOREACH_CONST( bool, m_bRowCausesDisqualified[pn], b ) { - bool bIsHandicap = GAMESTATE->IsDisqualified(p); - - m_sprDisqualify[p]->SetHidden( !bIsHandicap ); - - // restore previous player options in case the user escapes back after this - GAMESTATE->m_pPlayerState[p]->m_PlayerOptions = po; + if( *b ) + { + bDisqualified = true; + break; + } } + m_sprDisqualify[pn]->SetHidden( !bDisqualified ); + + // restore previous player options in case the user escapes back after this + GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions = poOrig; } /* diff --git a/stepmania/src/ScreenPlayerOptions.h b/stepmania/src/ScreenPlayerOptions.h index 36ee6bebca..cc8f0dd62a 100644 --- a/stepmania/src/ScreenPlayerOptions.h +++ b/stepmania/src/ScreenPlayerOptions.h @@ -18,7 +18,8 @@ private: void GoToNextScreen(); void GoToPrevScreen(); - void UpdateDisqualified( PlayerNumber pn ); + vector m_bRowCausesDisqualified[NUM_PLAYERS]; + void UpdateDisqualified( int row, PlayerNumber pn ); bool m_bAcceptedChoices; bool m_bGoToOptions;