Replace m_bPlayersCanJoin with PlayersCanJoin().
Move GetNumSidesJoined out of the header.
This commit is contained in:
@@ -66,7 +66,6 @@ void GameState::Reset()
|
||||
int p;
|
||||
|
||||
m_CurStyle = STYLE_INVALID;
|
||||
m_bPlayersCanJoin = false;
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
m_bSideIsJoined[p] = false;
|
||||
// m_iCoins = 0; // don't reset coin count!
|
||||
@@ -354,6 +353,20 @@ int GameState::GetCourseSongIndex()
|
||||
return iSongIndex;
|
||||
}
|
||||
|
||||
bool GameState::PlayersCanJoin() const
|
||||
{
|
||||
return GAMESTATE->m_CurStyle == STYLE_INVALID;
|
||||
}
|
||||
|
||||
int GameState::GetNumSidesJoined() const
|
||||
{
|
||||
int iNumSidesJoined = 0;
|
||||
for( int c=0; c<NUM_PLAYERS; c++ )
|
||||
if( m_bSideIsJoined[c] )
|
||||
iNumSidesJoined++; // left side, and right side
|
||||
return iNumSidesJoined;
|
||||
}
|
||||
|
||||
GameDef* GameState::GetCurrentGameDef()
|
||||
{
|
||||
ASSERT( m_CurGame != GAME_INVALID ); // the game must be set before calling this
|
||||
@@ -384,7 +397,7 @@ bool GameState::IsPlayerEnabled( PlayerNumber pn )
|
||||
bool GameState::IsHumanPlayer( PlayerNumber pn )
|
||||
{
|
||||
if( m_CurStyle == STYLE_INVALID ) // no style chosen
|
||||
if( this->m_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
|
||||
|
||||
@@ -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; c<NUM_PLAYERS; c++ )
|
||||
if( m_bSideIsJoined[c] )
|
||||
iNumSidesJoined++; // left side, and right side
|
||||
return iNumSidesJoined;
|
||||
};
|
||||
bool PlayersCanJoin() const; // true if it's not too late for a player to join
|
||||
int GetNumSidesJoined() const;
|
||||
|
||||
GameDef* GetCurrentGameDef();
|
||||
const StyleDef* GetCurrentStyleDef();
|
||||
|
||||
@@ -116,11 +116,7 @@ void ModeChoice::Load( int iIndex, CString sChoice )
|
||||
{
|
||||
Style style = GAMEMAN->GameAndStringToStyle( 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;
|
||||
}
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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; p<NUM_PLAYERS; p++ )
|
||||
GAMESTATE->m_bSideIsJoined[p] = false;
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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; c<NUM_CHOICES; c++ )
|
||||
{
|
||||
CString sChoice = CHOICE(c);
|
||||
@@ -105,22 +102,39 @@ void ScreenSelect::Input( const DeviceInput& DeviceI, const InputEventType type,
|
||||
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
|
||||
}
|
||||
|
||||
void ScreenSelect::FinalizeChoices()
|
||||
{
|
||||
/* At this point, we're tweening out; we can't change the selection.
|
||||
* We don't want to allow players to join if the style will be set,
|
||||
* since that can change the available selection and is likely to
|
||||
* invalidate the choice we've already made. Hack: apply the style.
|
||||
* (Applying the style may have other side-effects, so it'll be re-applied
|
||||
* in SM_GoToNextScreen.) */
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
if( GAMESTATE->IsHumanPlayer(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:
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user