From 514aac93a96b236e887fe4ef65d5a102b296d5cf Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 10 Nov 2003 16:48:22 +0000 Subject: [PATCH] Replace m_bPlayersCanJoin with PlayersCanJoin(). Move GetNumSidesJoined out of the header. --- stepmania/src/GameState.cpp | 17 ++++++++-- stepmania/src/GameState.h | 11 ++----- stepmania/src/ModeChoice.cpp | 4 --- stepmania/src/Screen.cpp | 2 +- stepmania/src/ScreenAttract.cpp | 3 -- stepmania/src/ScreenCaution.cpp | 2 -- stepmania/src/ScreenEz2SelectPlayer.cpp | 2 +- stepmania/src/ScreenManager.cpp | 4 +-- stepmania/src/ScreenSelect.cpp | 42 ++++++++++++++++--------- stepmania/src/ScreenSelect.h | 1 + stepmania/src/ScreenTitleMenu.cpp | 1 - 11 files changed, 50 insertions(+), 39 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index ca91738f17..76fdc4898d 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -66,7 +66,6 @@ void GameState::Reset() int p; m_CurStyle = STYLE_INVALID; - m_bPlayersCanJoin = false; for( p=0; pm_CurStyle == STYLE_INVALID; +} + +int GameState::GetNumSidesJoined() const +{ + int iNumSidesJoined = 0; + for( int c=0; cm_bPlayersCanJoin ) + if( this->PlayersCanJoin() ) return m_bSideIsJoined[pn]; // only allow input from sides that have already joined else return true; // if we can't join, then we're on a screen like MusicScroll or GameOver diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 271cb2c5cd..e79b2bc320 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -47,7 +47,6 @@ public: UnlockSystem *m_pUnlockingSys; Game m_CurGame; Style m_CurStyle; - bool m_bPlayersCanJoin; // true if it's not too late for a player to join - this only has an effect on the credits message bool m_bSideIsJoined[NUM_PLAYERS]; // left side, right side PlayMode m_PlayMode; // many screens display different info depending on this value int m_iCoins; // not "credits" @@ -58,14 +57,8 @@ public: /* This is set to a random number per-game/round; it can be used for a random seed. */ int m_iGameSeed, m_iRoundSeed; - int GetNumSidesJoined() - { - int iNumSidesJoined = 0; - for( int c=0; cGameAndStringToStyle( GAMESTATE->m_CurGame, sValue ); if( style != STYLE_INVALID ) - { m_style = style; - // There is a choices that allows players to choose a style. Allow joining. - GAMESTATE->m_bPlayersCanJoin = true; - } else m_bInvalid |= true; } diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index edefb1e342..6c9930d58f 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -175,7 +175,7 @@ bool Screen::ChangeCoinModeInput( const DeviceInput& DeviceI, const InputEventTy bool Screen::JoinInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) { - if( !GAMESTATE->m_bPlayersCanJoin ) + if( !GAMESTATE->PlayersCanJoin() ) return false; if( MenuI.IsValid() && MenuI.button==MENU_BUTTON_START ) diff --git a/stepmania/src/ScreenAttract.cpp b/stepmania/src/ScreenAttract.cpp index f5f648296a..9b35bc4105 100644 --- a/stepmania/src/ScreenAttract.cpp +++ b/stepmania/src/ScreenAttract.cpp @@ -56,9 +56,6 @@ ScreenAttract::ScreenAttract( CString sClassName ) : Screen( sClassName ) else SOUND->PlayMusic( "" ); // stop music - GAMESTATE->m_bPlayersCanJoin = true; - - float fTimeUntilBeginFadingOut = m_Background.GetLengthSeconds() - m_Out.GetLengthSeconds(); if( fTimeUntilBeginFadingOut < 0 ) { diff --git a/stepmania/src/ScreenCaution.cpp b/stepmania/src/ScreenCaution.cpp index 81599547aa..53ce68cbea 100644 --- a/stepmania/src/ScreenCaution.cpp +++ b/stepmania/src/ScreenCaution.cpp @@ -29,8 +29,6 @@ const ScreenMessage SM_StartClosing = ScreenMessage(SM_User-8); ScreenCaution::ScreenCaution( CString sName ) : Screen( sName ) { - GAMESTATE->m_bPlayersCanJoin = true; - if(!PREFSMAN->m_bShowDontDie) { this->PostScreenMessage( SM_GoToNextScreen, 0.f ); diff --git a/stepmania/src/ScreenEz2SelectPlayer.cpp b/stepmania/src/ScreenEz2SelectPlayer.cpp index c5407857f8..ee5a9b7229 100644 --- a/stepmania/src/ScreenEz2SelectPlayer.cpp +++ b/stepmania/src/ScreenEz2SelectPlayer.cpp @@ -49,7 +49,7 @@ Desc: Sets up the screen display ScreenEz2SelectPlayer::ScreenEz2SelectPlayer( CString sName ) : Screen( sName ) { // Unjoin the players, then let them join back in on this screen - GAMESTATE->m_bPlayersCanJoin = true; +// GAMESTATE->m_bPlayersCanJoin = true; int p; for( p=0; pm_bSideIsJoined[p] = false; diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 317a149326..c5129c1da1 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -208,13 +208,13 @@ void ScreenSystemLayer::RefreshCreditsMessages() sPlayerInfo = ""; else if( PREFSMAN->m_sMemoryCardDir[p]!="" ) { - if( GAMESTATE->m_bPlayersCanJoin ) + if( GAMESTATE->PlayersCanJoin() ) sPlayerInfo = PLAYER_INFO_INSERT_CARD; else sPlayerInfo = PLAYER_INFO_NO_CARD; } } - else if( GAMESTATE->m_bPlayersCanJoin ) + else if( GAMESTATE->PlayersCanJoin() ) { if( PREFSMAN->m_iCoinMode==COIN_PAY && PREFSMAN->m_Premium!=PrefsManager::JOINT_PREMIUM && diff --git a/stepmania/src/ScreenSelect.cpp b/stepmania/src/ScreenSelect.cpp index 964a280bbc..dad574686a 100644 --- a/stepmania/src/ScreenSelect.cpp +++ b/stepmania/src/ScreenSelect.cpp @@ -39,9 +39,6 @@ ScreenSelect::ScreenSelect( CString sClassName ) : Screen(sClassName) m_sName = sClassName; - /* If we don't have a style set yet, players can still join. */ - GAMESTATE->m_bPlayersCanJoin = ( GAMESTATE->m_CurStyle == STYLE_INVALID ); - for( int c=0; cIsHumanPlayer(p) ) + { + const int sel = GetSelectionIndex( (PlayerNumber)p ); + + if( m_aModeChoices[sel].m_style != STYLE_INVALID ) + GAMESTATE->m_CurStyle = m_aModeChoices[sel].m_style; + } + SCREENMAN->RefreshCreditsMessages(); +} + void ScreenSelect::HandleScreenMessage( const ScreenMessage SM ) { switch( SM ) { + /* Screen is starting to tween out. */ + case SM_BeginFadingOut: + FinalizeChoices(); + break; + + /* It's our turn to tween out. */ case SM_AllDoneChoosing: - { - GAMESTATE->m_bPlayersCanJoin = ( GAMESTATE->m_CurStyle == STYLE_INVALID ); - const int iSelectionIndex = GetSelectionIndex(GAMESTATE->m_MasterPlayerNumber); - if( m_aModeChoices[iSelectionIndex].m_style != STYLE_INVALID ) - GAMESTATE->m_bPlayersCanJoin = false; - - SCREENMAN->RefreshCreditsMessages(); - - if( !m_Menu.IsTransitioning() ) - m_Menu.StartTransitioning( SM_GoToNextScreen ); - } + FinalizeChoices(); + if( !m_Menu.IsTransitioning() ) + m_Menu.StartTransitioning( SM_GoToNextScreen ); break; case SM_MenuTimer: { diff --git a/stepmania/src/ScreenSelect.h b/stepmania/src/ScreenSelect.h index 9435e978be..af95132c05 100644 --- a/stepmania/src/ScreenSelect.h +++ b/stepmania/src/ScreenSelect.h @@ -38,6 +38,7 @@ public: protected: virtual int GetSelectionIndex( PlayerNumber pn ) = 0; virtual void UpdateSelectableChoices() = 0; // derived screens must handle this + void FinalizeChoices(); CString m_sName; diff --git a/stepmania/src/ScreenTitleMenu.cpp b/stepmania/src/ScreenTitleMenu.cpp index 63d54eb32f..db216c984d 100644 --- a/stepmania/src/ScreenTitleMenu.cpp +++ b/stepmania/src/ScreenTitleMenu.cpp @@ -77,7 +77,6 @@ ScreenTitleMenu::ScreenTitleMenu( CString sClassName ) : ScreenSelect( sClassNam * options. Having special cases in attract screens and the title menu to reset * things stinks ... */ GAMESTATE->Reset(); - GAMESTATE->m_bPlayersCanJoin = true; CodeDetector::RefreshCacheItems();