"for( p=0; p<NUM_PLAYERS; p++ )" -> "FOREACH_PlayerNumber( p )"

This commit is contained in:
Chris Danford
2004-05-24 08:16:17 +00:00
parent b05d25ab24
commit a9db266eb2
14 changed files with 130 additions and 181 deletions
+3 -5
View File
@@ -50,22 +50,20 @@ Background::Background()
BLINK_DANGER_ALL.Refresh(); BLINK_DANGER_ALL.Refresh();
DANGER_ALL_IS_OPAQUE.Refresh(); DANGER_ALL_IS_OPAQUE.Refresh();
int p;
m_iCurBGChangeIndex = -1; m_iCurBGChangeIndex = -1;
m_pCurrentBGA = NULL; m_pCurrentBGA = NULL;
m_pFadingBGA = NULL; m_pFadingBGA = NULL;
m_fSecsLeftInFade = 0; m_fSecsLeftInFade = 0;
m_DangerAll.LoadFromAniDir( THEME->GetPathToB("ScreenGameplay danger all") ); m_DangerAll.LoadFromAniDir( THEME->GetPathToB("ScreenGameplay danger all") );
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
m_DangerPlayer[p].LoadFromAniDir( THEME->GetPathToB(ssprintf("ScreenGameplay danger p%d",p+1)) ); m_DangerPlayer[p].LoadFromAniDir( THEME->GetPathToB(ssprintf("ScreenGameplay danger p%d",p+1)) );
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
m_DeadPlayer[p].LoadFromAniDir( THEME->GetPathToB(ssprintf("ScreenGameplay dead p%d",p+1)) ); m_DeadPlayer[p].LoadFromAniDir( THEME->GetPathToB(ssprintf("ScreenGameplay dead p%d",p+1)) );
bool bOneOrMoreChars = false; bool bOneOrMoreChars = false;
bool bShowingBeginnerHelper = false; bool bShowingBeginnerHelper = false;
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( !GAMESTATE->IsHumanPlayer(p) ) if( !GAMESTATE->IsHumanPlayer(p) )
continue; continue;
+2 -3
View File
@@ -25,8 +25,7 @@ CombinedLifeMeterTug::CombinedLifeMeterTug()
{ {
METER_WIDTH.Refresh(); METER_WIDTH.Refresh();
int p; FOREACH_PlayerNumber( p )
for( p=0; p<NUM_PLAYERS; p++ )
{ {
CString sStreamPath = THEME->GetPathToG(ssprintf("CombinedLifeMeterTug stream p%d",p+1)); CString sStreamPath = THEME->GetPathToG(ssprintf("CombinedLifeMeterTug stream p%d",p+1));
CString sTipPath = THEME->GetPathToG(ssprintf("CombinedLifeMeterTug tip p%d",p+1)); CString sTipPath = THEME->GetPathToG(ssprintf("CombinedLifeMeterTug tip p%d",p+1));
@@ -42,7 +41,7 @@ CombinedLifeMeterTug::CombinedLifeMeterTug()
this->AddChild( &m_sprFrame ); this->AddChild( &m_sprFrame );
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
Character* pCharacter = GAMESTATE->m_pCurCharacters[p]; Character* pCharacter = GAMESTATE->m_pCurCharacters[p];
ASSERT( pCharacter ); ASSERT( pCharacter );
+17 -21
View File
@@ -337,37 +337,33 @@ void DancingCharacters::DrawPrimitives()
m_LookAt, m_LookAt,
RageVector3(0,1,0) ); RageVector3(0,1,0) );
int p; FOREACH_EnabledPlayer( p )
for( p=0; p<NUM_PLAYERS; p++ )
{ {
if( GAMESTATE->IsPlayerEnabled(p) ) bool bFailed = g_CurStageStats.bFailed[p];
{ bool bDanger = m_bDrawDangerLight;
bool bFailed = g_CurStageStats.bFailed[p];
bool bDanger = m_bDrawDangerLight;
DISPLAY->SetLighting( true ); DISPLAY->SetLighting( true );
RageColor ambient = bFailed ? RageColor(0.2f,0.1f,0.1f,1) : (bDanger ? RageColor(0.4f,0.1f,0.1f,1) : RageColor(0.4f,0.4f,0.4f,1)); RageColor ambient = bFailed ? RageColor(0.2f,0.1f,0.1f,1) : (bDanger ? RageColor(0.4f,0.1f,0.1f,1) : RageColor(0.4f,0.4f,0.4f,1));
RageColor diffuse = bFailed ? RageColor(0.4f,0.1f,0.1f,1) : (bDanger ? RageColor(0.8f,0.1f,0.1f,1) : RageColor(0.8f,0.8f,0.8f,1)); RageColor diffuse = bFailed ? RageColor(0.4f,0.1f,0.1f,1) : (bDanger ? RageColor(0.8f,0.1f,0.1f,1) : RageColor(0.8f,0.8f,0.8f,1));
RageColor specular = RageColor(0.8f,0.8f,0.8f,1); RageColor specular = RageColor(0.8f,0.8f,0.8f,1);
DISPLAY->SetLightDirectional( DISPLAY->SetLightDirectional(
0, 0,
ambient, ambient,
diffuse, diffuse,
specular, specular,
RageVector3(+1, 0, +1) ); RageVector3(+1, 0, +1) );
m_Character[p].Draw(); m_Character[p].Draw();
DISPLAY->SetLightOff( 0 ); DISPLAY->SetLightOff( 0 );
DISPLAY->SetLighting( false ); DISPLAY->SetLighting( false );
}
} }
DISPLAY->CameraPopMatrix(); DISPLAY->CameraPopMatrix();
// now draw any potential 2D stuff // now draw any potential 2D stuff
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if(m_bHasIdleAnim[p] && m_i2DAnimState[p] == AS2D_IDLE) if(m_bHasIdleAnim[p] && m_i2DAnimState[p] == AS2D_IDLE)
m_bgIdle[p].Draw(); m_bgIdle[p].Draw();
+4 -6
View File
@@ -113,18 +113,16 @@ void GameState::Reset()
ASSERT( THEME ); ASSERT( THEME );
int p;
m_timeGameStarted.SetZero(); m_timeGameStarted.SetZero();
m_CurStyle = STYLE_INVALID; m_CurStyle = STYLE_INVALID;
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
m_bSideIsJoined[p] = false; m_bSideIsJoined[p] = false;
m_bPlayersFinalized = false; m_bPlayersFinalized = false;
// m_iCoins = 0; // don't reset coin count! // m_iCoins = 0; // don't reset coin count!
m_MasterPlayerNumber = PLAYER_INVALID; m_MasterPlayerNumber = PLAYER_INVALID;
m_sPreferredGroup = GROUP_ALL_MUSIC; m_sPreferredGroup = GROUP_ALL_MUSIC;
m_bChangedFailType = false; m_bChangedFailType = false;
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
m_PreferredDifficulty[p] = DIFFICULTY_INVALID; m_PreferredDifficulty[p] = DIFFICULTY_INVALID;
m_PreferredCourseDifficulty[p] = COURSE_DIFFICULTY_REGULAR; m_PreferredCourseDifficulty[p] = COURSE_DIFFICULTY_REGULAR;
@@ -154,7 +152,7 @@ void GameState::Reset()
SAFE_DELETE( m_pPosition ); SAFE_DELETE( m_pPosition );
m_pPosition = new NoteFieldPositioning("Positioning.ini"); m_pPosition = new NoteFieldPositioning("Positioning.ini");
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
m_bAttackBeganThisUpdate[p] = false; m_bAttackBeganThisUpdate[p] = false;
ResetMusicStatistics(); ResetMusicStatistics();
@@ -165,7 +163,7 @@ void GameState::Reset()
g_vPlayedStageStats.clear(); g_vPlayedStageStats.clear();
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
m_CurrentPlayerOptions[p].Init(); m_CurrentPlayerOptions[p].Init();
m_PlayerOptions[p].Init(); m_PlayerOptions[p].Init();
+1 -2
View File
@@ -291,8 +291,7 @@ void MusicWheelItem::DrawPrimitives()
case TYPE_SONG: case TYPE_SONG:
m_TextBanner.Draw(); m_TextBanner.Draw();
m_WheelNotifyIcon.Draw(); m_WheelNotifyIcon.Draw();
int p; FOREACH_PlayerNumber( p )
for( p=0; p<NUM_PLAYERS; p++ )
m_GradeDisplay[p].Draw(); m_GradeDisplay[p].Draw();
break; break;
case TYPE_COURSE: case TYPE_COURSE:
+4 -6
View File
@@ -1123,13 +1123,11 @@ void ScreenEvaluation::CommitScores(
void ScreenEvaluation::TweenOffScreen() void ScreenEvaluation::TweenOffScreen()
{ {
int p;
// large banner area // large banner area
OFF_COMMAND( m_LargeBanner ); OFF_COMMAND( m_LargeBanner );
OFF_COMMAND( m_sprLargeBannerFrame ); OFF_COMMAND( m_sprLargeBannerFrame );
OFF_COMMAND( m_sprStage ); OFF_COMMAND( m_sprStage );
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( !GAMESTATE->IsPlayerEnabled(p) ) if( !GAMESTATE->IsPlayerEnabled(p) )
continue; continue;
@@ -1148,7 +1146,7 @@ void ScreenEvaluation::TweenOffScreen()
// grade area // grade area
if( SHOW_GRADE_AREA ) if( SHOW_GRADE_AREA )
{ {
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( !GAMESTATE->IsPlayerEnabled(p) ) if( !GAMESTATE->IsPlayerEnabled(p) )
continue; continue;
@@ -1160,7 +1158,7 @@ void ScreenEvaluation::TweenOffScreen()
if( SHOW_GRAPH_AREA ) if( SHOW_GRAPH_AREA )
{ {
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( !GAMESTATE->IsPlayerEnabled(p) ) if( !GAMESTATE->IsPlayerEnabled(p) )
continue; // skip continue; // skip
@@ -1172,7 +1170,7 @@ void ScreenEvaluation::TweenOffScreen()
if( SHOW_COMBO_AREA ) if( SHOW_COMBO_AREA )
{ {
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( !GAMESTATE->IsPlayerEnabled(p) ) if( !GAMESTATE->IsPlayerEnabled(p) )
continue; // skip continue; // skip
+2 -3
View File
@@ -50,8 +50,7 @@ ScreenEz2SelectPlayer::ScreenEz2SelectPlayer( CString sName ) : ScreenWithMenuEl
{ {
// Unjoin the players, then let them join back in on this screen // Unjoin the players, then let them join back in on this screen
// GAMESTATE->m_bPlayersCanJoin = true; // GAMESTATE->m_bPlayersCanJoin = true;
int p; FOREACH_PlayerNumber( p )
for( p=0; p<NUM_PLAYERS; p++ )
GAMESTATE->m_bSideIsJoined[p] = false; GAMESTATE->m_bSideIsJoined[p] = false;
LOG->Trace( "ScreenEz2SelectPlayer::ScreenEz2SelectPlayer()" ); LOG->Trace( "ScreenEz2SelectPlayer::ScreenEz2SelectPlayer()" );
@@ -59,7 +58,7 @@ ScreenEz2SelectPlayer::ScreenEz2SelectPlayer( CString sName ) : ScreenWithMenuEl
m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenEz2SelectPlayer background") ); m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenEz2SelectPlayer background") );
this->AddChild( &m_Background ); // animated background =) this->AddChild( &m_Background ); // animated background =)
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
m_sprJoinFrame[p].Load( THEME->GetPathToG("ScreenEz2SelectPlayer join frame 1x2") ); m_sprJoinFrame[p].Load( THEME->GetPathToG("ScreenEz2SelectPlayer join frame 1x2") );
m_sprJoinFrame[p].StopAnimating(); m_sprJoinFrame[p].StopAnimating();
+2 -4
View File
@@ -134,12 +134,10 @@ ScreenNameEntry::ScreenNameEntry( CString sClassName ) : Screen( sClassName )
GAMESTATE->m_SongOptions = SongOptions(); GAMESTATE->m_SongOptions = SongOptions();
} }
int p;
vector<GameState::RankingFeat> aFeats[NUM_PLAYERS]; vector<GameState::RankingFeat> aFeats[NUM_PLAYERS];
// Find out if players deserve to enter their name // Find out if players deserve to enter their name
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
GAMESTATE->GetRankingFeats( (PlayerNumber)p, aFeats[p] ); GAMESTATE->GetRankingFeats( (PlayerNumber)p, aFeats[p] );
m_bStillEnteringName[p] = aFeats[p].size()>0; m_bStillEnteringName[p] = aFeats[p].size()>0;
@@ -169,7 +167,7 @@ ScreenNameEntry::ScreenNameEntry( CString sClassName ) : Screen( sClassName )
m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenNameEntry background") ); m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenNameEntry background") );
this->AddChild( &m_Background ); this->AddChild( &m_Background );
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
// load last used ranking name if any // load last used ranking name if any
Profile* pProfile = PROFILEMAN->GetProfile((PlayerNumber)p); Profile* pProfile = PROFILEMAN->GetProfile((PlayerNumber)p);
+3 -3
View File
@@ -91,7 +91,7 @@ ScreenSelectCharacter::ScreenSelectCharacter( CString sClassName ) : ScreenWithM
int p; int p;
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
m_iSelectedCharacter[p] = 0; m_iSelectedCharacter[p] = 0;
if( GAMESTATE->IsHumanPlayer(p) ) if( GAMESTATE->IsHumanPlayer(p) )
@@ -99,7 +99,7 @@ ScreenSelectCharacter::ScreenSelectCharacter( CString sClassName ) : ScreenWithM
} }
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( !GAMESTATE->IsPlayerEnabled(p) ) if( !GAMESTATE->IsPlayerEnabled(p) )
continue; continue;
@@ -155,7 +155,7 @@ ScreenSelectCharacter::ScreenSelectCharacter( CString sClassName ) : ScreenWithM
SOUND->PlayMusic( THEME->GetPathToS("ScreenSelectCharacter music") ); SOUND->PlayMusic( THEME->GetPathToS("ScreenSelectCharacter music") );
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( GAMESTATE->IsHumanPlayer(p) ) if( GAMESTATE->IsHumanPlayer(p) )
{ {
+30 -46
View File
@@ -39,8 +39,8 @@
ScreenSelectDifficulty::ScreenSelectDifficulty( CString sClassName ) : ScreenSelect( sClassName ) ScreenSelectDifficulty::ScreenSelectDifficulty( CString sClassName ) : ScreenSelect( sClassName )
{ {
m_CurrentPage = PAGE_1; m_CurrentPage = PAGE_1;
int p;
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
m_iChoiceOnPage[p] = 0; m_iChoiceOnPage[p] = 0;
m_bChosen[p] = false; m_bChosen[p] = false;
@@ -84,7 +84,7 @@ ScreenSelectDifficulty::ScreenSelectDifficulty( CString sClassName ) : ScreenSel
} }
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
CLAMP( m_iChoiceOnPage[p], 0, (int)m_ModeChoices[0].size()-1 ); CLAMP( m_iChoiceOnPage[p], 0, (int)m_ModeChoices[0].size()-1 );
m_bChosen[p] = false; m_bChosen[p] = false;
@@ -182,11 +182,10 @@ void ScreenSelectDifficulty::UpdateSelectableChoices()
// I'm not sure why this was here -- but there seem no ill effects // I'm not sure why this was here -- but there seem no ill effects
// of it's removal. // of it's removal.
// //
//FOREACH_PlayerNumber( p ) //FOREACH_HumanPlayer( p )
// if( GAMESTATE->IsHumanPlayer(p) )
// { // {
// MenuRight( (PlayerNumber)p ); // MenuRight( p );
// MenuLeft( (PlayerNumber)p ); // MenuLeft( p );
// } // }
} }
@@ -281,11 +280,9 @@ void ScreenSelectDifficulty::MenuRight( PlayerNumber pn )
void ScreenSelectDifficulty::ChangePage( Page newPage ) void ScreenSelectDifficulty::ChangePage( Page newPage )
{ {
int p;
// If anyone has already chosen, don't allow changing of pages // If anyone has already chosen, don't allow changing of pages
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsHumanPlayer(p) && m_bChosen[p] ) if( m_bChosen[p] )
return; return;
bool bPageIncreasing = newPage > m_CurrentPage; bool bPageIncreasing = newPage > m_CurrentPage;
@@ -321,8 +318,8 @@ void ScreenSelectDifficulty::ChangePage( Page newPage )
} }
// change both players // change both players
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
ChangeWithinPage( (PlayerNumber)p, iSwitchToIndex, true ); ChangeWithinPage( p, iSwitchToIndex, true );
m_soundChange.Play(); m_soundChange.Play();
@@ -335,11 +332,8 @@ void ScreenSelectDifficulty::ChangePage( Page newPage )
bool ScreenSelectDifficulty::ChangeWithinPage( PlayerNumber pn, int iNewChoice, bool bChangingPages ) bool ScreenSelectDifficulty::ChangeWithinPage( PlayerNumber pn, int iNewChoice, bool bChangingPages )
{ {
bool bAnyChanged = false; bool bAnyChanged = false;
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
{ {
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
if( p!=pn && m_CurrentPage==PAGE_1 ) if( p!=pn && m_CurrentPage==PAGE_1 )
continue; // skip continue; // skip
if( m_iChoiceOnPage[p] == iNewChoice ) if( m_iChoiceOnPage[p] == iNewChoice )
@@ -348,8 +342,8 @@ bool ScreenSelectDifficulty::ChangeWithinPage( PlayerNumber pn, int iNewChoice,
bAnyChanged = true; bAnyChanged = true;
m_iChoiceOnPage[p] = iNewChoice; m_iChoiceOnPage[p] = iNewChoice;
float fCursorX = GetCursorX( (PlayerNumber)p ); float fCursorX = GetCursorX( p );
float fCursorY = GetCursorY( (PlayerNumber)p ); float fCursorY = GetCursorY( p );
m_sprCursor[p].StopTweening(); m_sprCursor[p].StopTweening();
m_sprCursor[p].BeginTweening( 0.2f, bChangingPages ? TWEEN_LINEAR : TWEEN_DECELERATE ); m_sprCursor[p].BeginTweening( 0.2f, bChangingPages ? TWEEN_LINEAR : TWEEN_DECELERATE );
@@ -386,28 +380,26 @@ void ScreenSelectDifficulty::MenuStart( PlayerNumber pn )
SCREENMAN->PlayStartSound(); SCREENMAN->PlayStartSound();
} }
int p;
// courses should be selected for both players at all times // courses should be selected for both players at all times
if( BothPlayersModeChoice(mc) ) if( BothPlayersModeChoice(mc) )
{ {
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( p )
{ {
if( m_bChosen[p] || !GAMESTATE->IsHumanPlayer((PlayerNumber)p) || p == pn ) if( m_bChosen[p] || p == pn )
continue; continue;
// move all cursors to the oni/nonstop selection so it graphically looks as if all players selected the same option. // move all cursors to the oni/nonstop selection so it graphically looks as if all players selected the same option.
ChangeWithinPage( (PlayerNumber)p, m_iChoiceOnPage[pn], false ); ChangeWithinPage( p, m_iChoiceOnPage[pn], false );
bPlaySelect = false; bPlaySelect = false;
MenuStart( (PlayerNumber)p ); // agree everyone MenuStart( p ); // agree everyone
bPlaySelect = true; bPlaySelect = true;
} }
} }
else // someone must have chosen arcade style play so oni/nonstop/endless must be disabled else // someone must have chosen arcade style play so oni/nonstop/endless must be disabled
{ {
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( p )
{ {
if( m_bChosen[p] || !GAMESTATE->IsHumanPlayer((PlayerNumber)p) || p == pn ) if( m_bChosen[p] || p == pn )
continue; continue;
if( !BothPlayersModeChoice(m_ModeChoices[m_CurrentPage][m_iChoiceOnPage[p]]) ) if( !BothPlayersModeChoice(m_ModeChoices[m_CurrentPage][m_iChoiceOnPage[p]]) )
@@ -437,16 +429,16 @@ void ScreenSelectDifficulty::MenuStart( PlayerNumber pn )
ASSERT( iSwitchToIndex != -1 ); ASSERT( iSwitchToIndex != -1 );
// move the cursor // move the cursor
ChangeWithinPage( (PlayerNumber) p, iSwitchToIndex, false ); ChangeWithinPage( p, iSwitchToIndex, false );
} }
/* If the other player is active and hasn't yet chosen, gray out unselectable options. /* If the other player is active and hasn't yet chosen, gray out unselectable options.
* Otherwise, don't do this, so we don't gray out stuff when nothing else can be selected * Otherwise, don't do this, so we don't gray out stuff when nothing else can be selected
* anyway. */ * anyway. */
bool bAnyPlayersLeft = false; bool bAnyPlayersLeft = false;
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( p )
{ {
if( !GAMESTATE->IsHumanPlayer((PlayerNumber)p) || m_bChosen[p] || p == pn ) if( m_bChosen[p] || p == pn )
continue; continue;
bAnyPlayersLeft = true; bAnyPlayersLeft = true;
} }
@@ -470,13 +462,13 @@ void ScreenSelectDifficulty::MenuStart( PlayerNumber pn )
if( m_CurrentPage == PAGE_2 ) if( m_CurrentPage == PAGE_2 )
{ {
// choose this for all the other players too // choose this for all the other players too
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( m_bChosen[p] ) if( m_bChosen[p] )
continue; continue;
bPlaySelect = false; bPlaySelect = false;
MenuStart( (PlayerNumber)p ); MenuStart( p );
bPlaySelect = true; bPlaySelect = true;
} }
} }
@@ -489,9 +481,9 @@ void ScreenSelectDifficulty::MenuStart( PlayerNumber pn )
// check to see if everyone has chosen // check to see if everyone has chosen
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( p )
{ {
if( GAMESTATE->IsHumanPlayer((PlayerNumber)p) && m_bChosen[p] == false ) if( m_bChosen[p] == false )
return; return;
} }
this->PostScreenMessage( SM_BeginFadingOut, SLEEP_AFTER_CHOICE_SECONDS ); // tell our owner it's time to move on this->PostScreenMessage( SM_BeginFadingOut, SLEEP_AFTER_CHOICE_SECONDS ); // tell our owner it's time to move on
@@ -499,8 +491,6 @@ void ScreenSelectDifficulty::MenuStart( PlayerNumber pn )
void ScreenSelectDifficulty::TweenOnScreen() void ScreenSelectDifficulty::TweenOnScreen()
{ {
unsigned p;
for( int page=0; page<NUM_PAGES; page++ ) for( int page=0; page<NUM_PAGES; page++ )
{ {
SET_XY_AND_ON_COMMAND( m_sprExplanation[page] ); SET_XY_AND_ON_COMMAND( m_sprExplanation[page] );
@@ -513,13 +503,10 @@ void ScreenSelectDifficulty::TweenOnScreen()
} }
} }
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( p )
{ {
if( !GAMESTATE->IsHumanPlayer((PlayerNumber)p) ) float fCursorX = GetCursorX( p );
continue; float fCursorY = GetCursorY( p );
float fCursorX = GetCursorX( (PlayerNumber)p );
float fCursorY = GetCursorY( (PlayerNumber)p );
m_sprCursor[p].SetXY( fCursorX, fCursorY ); m_sprCursor[p].SetXY( fCursorX, fCursorY );
ON_COMMAND( m_sprCursor[p] ); ON_COMMAND( m_sprCursor[p] );
@@ -536,11 +523,8 @@ void ScreenSelectDifficulty::TweenOffScreen()
OFF_COMMAND( m_sprExplanation[page] ); OFF_COMMAND( m_sprExplanation[page] );
OFF_COMMAND( m_sprMore[page] ); OFF_COMMAND( m_sprMore[page] );
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
{ {
if( !GAMESTATE->IsHumanPlayer(p) )
continue;
OFF_COMMAND( m_sprCursor[p] ); OFF_COMMAND( m_sprCursor[p] );
OFF_COMMAND( m_sprOK[p] ); OFF_COMMAND( m_sprOK[p] );
OFF_COMMAND( m_sprShadow[p] ); OFF_COMMAND( m_sprShadow[p] );
+7 -10
View File
@@ -56,8 +56,8 @@
ScreenSelectDifficultyEX::ScreenSelectDifficultyEX( CString sClassName ) : ScreenSelect( sClassName ) ScreenSelectDifficultyEX::ScreenSelectDifficultyEX( CString sClassName ) : ScreenSelect( sClassName )
{ {
m_CurrentPage = PAGE_1; m_CurrentPage = PAGE_1;
int p;
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
m_iChoice[p] = 0; m_iChoice[p] = 0;
m_bChosen[p] = false; m_bChosen[p] = false;
@@ -98,7 +98,7 @@ ScreenSelectDifficultyEX::ScreenSelectDifficultyEX( CString sClassName ) : Scree
} }
SetDifficultyIconText( false ); // Make sure we show the names! SetDifficultyIconText( false ); // Make sure we show the names!
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( GAMESTATE->IsPlayerEnabled(p) ) // Only show their cursor, if they're enabled if( GAMESTATE->IsPlayerEnabled(p) ) // Only show their cursor, if they're enabled
{ {
@@ -374,8 +374,7 @@ void ScreenSelectDifficultyEX::MenuStart( PlayerNumber pn )
const ModeChoice& mc = m_ModeChoices[m_iChoice[pn]]; const ModeChoice& mc = m_ModeChoices[m_iChoice[pn]];
bool AnotherPlayerSelected = false; bool AnotherPlayerSelected = false;
int p; FOREACH_PlayerNumber( p )
for( p=0; p<NUM_PLAYERS; p++ )
{ {
if(p != pn && m_bChosen[p]) { AnotherPlayerSelected = true; } if(p != pn && m_bChosen[p]) { AnotherPlayerSelected = true; }
} }
@@ -398,7 +397,7 @@ void ScreenSelectDifficultyEX::MenuStart( PlayerNumber pn )
if( IsACourse( m_iChoice[pn] ) ) if( IsACourse( m_iChoice[pn] ) )
{ {
// If this is course/mode, choose this for all the other players too // If this is course/mode, choose this for all the other players too
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( m_bChosen[p] ) { continue; } if( m_bChosen[p] ) { continue; }
MenuStart( (PlayerNumber)p ); MenuStart( (PlayerNumber)p );
@@ -416,7 +415,7 @@ void ScreenSelectDifficultyEX::MenuStart( PlayerNumber pn )
// check to see if everyone has chosen // check to see if everyone has chosen
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( GAMESTATE->IsPlayerEnabled((PlayerNumber)p) && m_bChosen[p] == false ) if( GAMESTATE->IsPlayerEnabled((PlayerNumber)p) && m_bChosen[p] == false )
{ {
@@ -428,9 +427,7 @@ void ScreenSelectDifficultyEX::MenuStart( PlayerNumber pn )
void ScreenSelectDifficultyEX::TweenOnScreen() void ScreenSelectDifficultyEX::TweenOnScreen()
{ {
unsigned p; FOREACH_PlayerNumber( p )
for( p=0; p<NUM_PLAYERS; p++ )
{ {
if( !GAMESTATE->IsPlayerEnabled((PlayerNumber)p) ) { continue; } if( !GAMESTATE->IsPlayerEnabled((PlayerNumber)p) ) { continue; }
+52 -66
View File
@@ -50,9 +50,7 @@ const ScreenMessage SM_PlayPostSwitchPage = (ScreenMessage)(SM_User+1);
ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sClassName ) ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sClassName )
{ {
int p, i; FOREACH_PlayerNumber( p )
for( p=0; p<NUM_PLAYERS; p++ )
{ {
m_iChoice[p] = clamp( DEFAULT_CHOICE-1, 0, (int) m_aModeChoices.size() ); m_iChoice[p] = clamp( DEFAULT_CHOICE-1, 0, (int) m_aModeChoices.size() );
m_bChosen[p] = false; m_bChosen[p] = false;
@@ -61,7 +59,7 @@ ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sCl
// init cursor // init cursor
if( SHARED_PREVIEW_AND_CURSOR ) if( SHARED_PREVIEW_AND_CURSOR )
{ {
for( i=0; i<NUM_CURSOR_PARTS; i++ ) for( int i=0; i<NUM_CURSOR_PARTS; i++ )
{ {
CString sFName = ssprintf("%s Cursor Part%d", m_sName.c_str(),i+1); CString sFName = ssprintf("%s Cursor Part%d", m_sName.c_str(),i+1);
m_sprCursor[i][0].SetName( ssprintf("CursorPart%d",i+1) ); m_sprCursor[i][0].SetName( ssprintf("CursorPart%d",i+1) );
@@ -71,12 +69,10 @@ ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sCl
} }
else else
{ {
for( i=0; i<NUM_CURSOR_PARTS; i++ ) for( int i=0; i<NUM_CURSOR_PARTS; i++ )
{ {
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( p )
{ {
if( !GAMESTATE->IsPlayerEnabled(p) )
continue; // skip
CString sFName = ssprintf("%s Cursor Part%d P%d", m_sName.c_str(),i+1,p+1); CString sFName = ssprintf("%s Cursor Part%d P%d", m_sName.c_str(),i+1,p+1);
m_sprCursor[i][p].SetName( ssprintf("CursorPart%dP%d",i+1,p+1) ); m_sprCursor[i][p].SetName( ssprintf("CursorPart%dP%d",i+1,p+1) );
m_sprCursor[i][p].Load( THEME->GetPathToG(sFName) ); m_sprCursor[i][p].Load( THEME->GetPathToG(sFName) );
@@ -112,11 +108,8 @@ ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sCl
} }
else else
{ {
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( p )
{ {
if( !GAMESTATE->IsPlayerEnabled(p) )
continue; // skip
m_Scroller[p].Load( m_Scroller[p].Load(
SCROLLER_SECONDS_PER_ITEM, SCROLLER_SECONDS_PER_ITEM,
7, 7,
@@ -145,7 +138,7 @@ ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sCl
const ModeChoice& mc = m_aModeChoices[c]; const ModeChoice& mc = m_aModeChoices[c];
// init icon // init icon
for( i=0; i<NUM_ICON_PARTS; i++ ) for( int i=0; i<NUM_ICON_PARTS; i++ )
{ {
CString sFName = ssprintf("%s Icon Part%d Choice%s", m_sName.c_str(),i+1,mc.m_sName.c_str()); CString sFName = ssprintf("%s Icon Part%d Choice%s", m_sName.c_str(),i+1,mc.m_sName.c_str());
m_sprIcon[i][c].Load( THEME->GetPathToG(sFName) ); m_sprIcon[i][c].Load( THEME->GetPathToG(sFName) );
@@ -166,10 +159,8 @@ ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sCl
} }
else else
{ {
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( p )
{ {
if( !GAMESTATE->IsPlayerEnabled(p) )
continue; // skip
for( i=0; i<NUM_PREVIEW_PARTS; i++ ) for( i=0; i<NUM_PREVIEW_PARTS; i++ )
{ {
CString sFName = ssprintf("%s Preview Part%d Choice%s P%d", m_sName.c_str(),i+1,mc.m_sName.c_str(),p+1); CString sFName = ssprintf("%s Preview Part%d Choice%s P%d", m_sName.c_str(),i+1,mc.m_sName.c_str(),p+1);
@@ -194,7 +185,7 @@ ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sCl
} }
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
CLAMP( m_iChoice[p], 0, (int)m_aModeChoices.size()-1 ); CLAMP( m_iChoice[p], 0, (int)m_aModeChoices.size()-1 );
m_bChosen[p] = false; m_bChosen[p] = false;
@@ -290,12 +281,11 @@ void ScreenSelectMaster::HandleScreenMessage( const ScreenMessage SM )
else else
{ {
for( int i=0; i<NUM_CURSOR_PARTS; i++ ) for( int i=0; i<NUM_CURSOR_PARTS; i++ )
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsPlayerEnabled(p) ) {
{ m_sprCursor[i][p].SetXY( GetCursorX((PlayerNumber)p,i), GetCursorY((PlayerNumber)p,i) );
m_sprCursor[i][p].SetXY( GetCursorX((PlayerNumber)p,i), GetCursorY((PlayerNumber)p,i) ); COMMAND( m_sprCursor[i][p], "PostSwitchPage" );
COMMAND( m_sprCursor[i][p], "PostSwitchPage" ); }
}
} }
if( SHARED_PREVIEW_AND_CURSOR ) if( SHARED_PREVIEW_AND_CURSOR )
@@ -306,9 +296,8 @@ void ScreenSelectMaster::HandleScreenMessage( const ScreenMessage SM )
else else
{ {
for( int i=0; i<NUM_PREVIEW_PARTS; i++ ) for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsPlayerEnabled(p) ) COMMAND( m_sprPreview[i][m_iChoice[p]][p], "PostSwitchPage" );
COMMAND( m_sprPreview[i][m_iChoice[p]][p], "PostSwitchPage" );
} }
m_fLockInputSecs = POST_SWITCH_PAGE_SECONDS; m_fLockInputSecs = POST_SWITCH_PAGE_SECONDS;
@@ -406,8 +395,7 @@ bool ScreenSelectMaster::ChangePage( int iNewChoice )
Page newPage = GetPage(iNewChoice); Page newPage = GetPage(iNewChoice);
// If anyone has already chosen, don't allow changing of pages // If anyone has already chosen, don't allow changing of pages
int p; FOREACH_PlayerNumber( p )
for( p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsHumanPlayer(p) && m_bChosen[p] ) if( GAMESTATE->IsHumanPlayer(p) && m_bChosen[p] )
return false; return false;
@@ -432,15 +420,18 @@ bool ScreenSelectMaster::ChangePage( int iNewChoice )
if( SHARED_PREVIEW_AND_CURSOR ) if( SHARED_PREVIEW_AND_CURSOR )
{ {
int iChoice = m_iChoice[GAMESTATE->m_MasterPlayerNumber];
for( int i=0; i<NUM_PREVIEW_PARTS; i++ ) for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
COMMAND( m_sprPreview[i][m_iChoice[p]][0], "PreSwitchPage" ); COMMAND( m_sprPreview[i][iChoice][0], "PreSwitchPage" );
} }
else else
{ {
for( int i=0; i<NUM_PREVIEW_PARTS; i++ ) for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsPlayerEnabled(p) ) {
COMMAND( m_sprPreview[i][m_iChoice[p]][p], "PreSwitchPage" ); int iChoice = m_iChoice[p];
COMMAND( m_sprPreview[i][iChoice][p], "PreSwitchPage" );
}
} }
for( int page=0; page<NUM_PAGES; page++ ) for( int page=0; page<NUM_PAGES; page++ )
@@ -462,7 +453,7 @@ bool ScreenSelectMaster::ChangePage( int iNewChoice )
} }
// change both players // change both players
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
m_iChoice[p] = iNewChoice; m_iChoice[p] = iNewChoice;
m_fLockInputSecs = PRE_SWITCH_PAGE_SECONDS; m_fLockInputSecs = PRE_SWITCH_PAGE_SECONDS;
@@ -664,14 +655,13 @@ void ScreenSelectMaster::TweenOnScreen()
} }
else else
{ {
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsPlayerEnabled(p) ) for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
for( int i=0; i<NUM_PREVIEW_PARTS; i++ ) {
{ COMMAND( m_sprPreview[i][c][p], int(c) == m_iChoice[p]? "GainFocus":"LoseFocus" );
COMMAND( m_sprPreview[i][c][p], int(c) == m_iChoice[p]? "GainFocus":"LoseFocus" ); m_sprPreview[i][c][p]->FinishTweening();
m_sprPreview[i][c][p]->FinishTweening(); SET_XY_AND_ON_COMMAND( m_sprPreview[i][c][p] );
SET_XY_AND_ON_COMMAND( m_sprPreview[i][c][p] ); }
}
} }
} }
@@ -687,12 +677,11 @@ void ScreenSelectMaster::TweenOnScreen()
else else
{ {
for( int i=0; i<NUM_CURSOR_PARTS; i++ ) for( int i=0; i<NUM_CURSOR_PARTS; i++ )
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsPlayerEnabled(p) ) {
{ m_sprCursor[i][p].SetXY( GetCursorX((PlayerNumber)p,i), GetCursorY((PlayerNumber)p,i) );
m_sprCursor[i][p].SetXY( GetCursorX((PlayerNumber)p,i), GetCursorY((PlayerNumber)p,i) ); ON_COMMAND( m_sprCursor[i][p] );
ON_COMMAND( m_sprCursor[i][p] ); }
}
} }
if( SHOW_SCROLLER ) if( SHOW_SCROLLER )
@@ -705,14 +694,13 @@ void ScreenSelectMaster::TweenOnScreen()
COMMAND( *m_sprScroll[c][0], int(c) == m_iChoice[0]? "GainFocus":"LoseFocus" ); COMMAND( *m_sprScroll[c][0], int(c) == m_iChoice[0]? "GainFocus":"LoseFocus" );
} }
else else
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsPlayerEnabled(p) ) {
{ m_Scroller[p].SetCurrentAndDestinationItem( m_iChoice[p] );
m_Scroller[p].SetCurrentAndDestinationItem( m_iChoice[p] ); SET_XY_AND_ON_COMMAND( m_Scroller[p] );
SET_XY_AND_ON_COMMAND( m_Scroller[p] ); for( unsigned c=0; c<m_aModeChoices.size(); c++ )
for( unsigned c=0; c<m_aModeChoices.size(); c++ ) COMMAND( *m_sprScroll[c][p], int(c) == m_iChoice[p]? "GainFocus":"LoseFocus" );
COMMAND( *m_sprScroll[c][p], int(c) == m_iChoice[p]? "GainFocus":"LoseFocus" ); }
}
} }
SET_XY_AND_ON_COMMAND( m_sprExplanation[GetCurrentPage()] ); SET_XY_AND_ON_COMMAND( m_sprExplanation[GetCurrentPage()] );
@@ -731,9 +719,8 @@ void ScreenSelectMaster::TweenOffScreen()
else else
{ {
for( int i=0; i<NUM_CURSOR_PARTS; i++ ) for( int i=0; i<NUM_CURSOR_PARTS; i++ )
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsPlayerEnabled(p) ) OFF_COMMAND( m_sprCursor[i][p] );
OFF_COMMAND( m_sprCursor[i][p] );
} }
for( unsigned c=0; c<m_aModeChoices.size(); c++ ) for( unsigned c=0; c<m_aModeChoices.size(); c++ )
@@ -748,8 +735,8 @@ void ScreenSelectMaster::TweenOffScreen()
SelectedByEitherPlayer = true; SelectedByEitherPlayer = true;
} }
else else
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsPlayerEnabled(p) && m_iChoice[p] == (int)c ) if( m_iChoice[p] == (int)c )
SelectedByEitherPlayer = true; SelectedByEitherPlayer = true;
for( int i=0; i<NUM_ICON_PARTS; i++ ) for( int i=0; i<NUM_ICON_PARTS; i++ )
@@ -770,12 +757,11 @@ void ScreenSelectMaster::TweenOffScreen()
else else
{ {
for( int i=0; i<NUM_PREVIEW_PARTS; i++ ) for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
FOREACH_PlayerNumber( p ) FOREACH_HumanPlayer( p )
if( GAMESTATE->IsPlayerEnabled(p) ) {
{ OFF_COMMAND( m_sprPreview[i][c][p] );
OFF_COMMAND( m_sprPreview[i][c][p] ); COMMAND( m_sprPreview[i][c][0], SelectedByEitherPlayer? "OffFocused":"OffUnfocused" );
COMMAND( m_sprPreview[i][c][0], SelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); }
}
} }
} }
+2 -4
View File
@@ -101,10 +101,8 @@ ScreenSelectMusic::ScreenSelectMusic( CString sClassName ) : ScreenWithMenuEleme
m_MusicWheel.Load(); m_MusicWheel.Load();
int p;
// pop'n music has this under the songwheel... // pop'n music has this under the songwheel...
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
Character* pChar = GAMESTATE->m_pCurCharacters[p]; Character* pChar = GAMESTATE->m_pCurCharacters[p];
m_sprCharacterIcon[p].SetName( ssprintf("CharacterIconP%d",p+1) ); m_sprCharacterIcon[p].SetName( ssprintf("CharacterIconP%d",p+1) );
@@ -239,7 +237,7 @@ ScreenSelectMusic::ScreenSelectMusic( CString sClassName ) : ScreenWithMenuEleme
this->AddChild( &m_DifficultyList ); this->AddChild( &m_DifficultyList );
} }
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_PlayerNumber( p )
{ {
if( !GAMESTATE->IsHumanPlayer(p) ) if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip continue; // skip
+1 -2
View File
@@ -126,8 +126,7 @@ void ScreenStage::HandleScreenMessage( const ScreenMessage SM )
case SM_BeginFadingOut: case SM_BeginFadingOut:
m_Out.StartTransitioning(); m_Out.StartTransitioning();
int p; FOREACH_PlayerNumber( p )
for( p=0; p<NUM_PLAYERS; p++ )
OFF_COMMAND( m_sprCharacterIcon[p] ); OFF_COMMAND( m_sprCharacterIcon[p] );
OFF_COMMAND( m_SongTitle ); OFF_COMMAND( m_SongTitle );
OFF_COMMAND( m_Artist ); OFF_COMMAND( m_Artist );