Move the last global to the class.

Make m_iSelectedStyle a bitfield, which simplifies some things.

Don't select player 1 if player 2 selects at the last second.
This commit is contained in:
Glenn Maynard
2002-08-26 01:20:03 +00:00
parent 2f3d12ee8e
commit 40d96cc613
2 changed files with 55 additions and 55 deletions
+47 -53
View File
@@ -54,8 +54,6 @@ const float OPT_Y[NUM_EZ2_GRAPHICS] = {
float ez2_bounce=0.f; // used for the bouncing of the '1p' and '2p' images
/************************************ /************************************
ScreenEz2SelectPlayer (Constructor) ScreenEz2SelectPlayer (Constructor)
Desc: Sets up the screen display Desc: Sets up the screen display
@@ -64,8 +62,9 @@ Desc: Sets up the screen display
ScreenEz2SelectPlayer::ScreenEz2SelectPlayer() ScreenEz2SelectPlayer::ScreenEz2SelectPlayer()
{ {
LOG->Trace( "ScreenEz2SelectPlayer::ScreenEz2SelectPlayer()" ); LOG->Trace( "ScreenEz2SelectPlayer::ScreenEz2SelectPlayer()" );
m_iSelectedStyle=3; // by bbf: frieza, was this supposed to be 3 ? m_iSelectedStyle=0;
GAMESTATE->m_CurStyle = STYLE_NONE; GAMESTATE->m_CurStyle = STYLE_NONE;
ez2_bounce=0.f;
// GAMESTATE->m_MasterPlayerNumber = PLAYER_INVALID; // GAMESTATE->m_MasterPlayerNumber = PLAYER_INVALID;
// Load in the sprites we will be working with. // Load in the sprites we will be working with.
@@ -182,30 +181,39 @@ void ScreenEz2SelectPlayer::HandleScreenMessage( const ScreenMessage SM )
switch( SM ) switch( SM )
{ {
case SM_MenuTimer: case SM_MenuTimer:
MenuStart(PLAYER_1); // Automatically Choose Player 1 /* If a player has already chosen, then he chose within the last second
* of the menu timer; just stop and let it come through as if the menu
* timer didn't expire. */
if(!m_iSelectedStyle)
MenuStart(PLAYER_1);
break; break;
case SM_PlayersChosen: case SM_PlayersChosen:
if (m_iSelectedStyle == 0) // only the left pad was selected if (m_iSelectedStyle & EZ2_PLAYER_1)
{ {
// GAMESTATE->m_MasterPlayerNumber = PLAYER_1; if (m_iSelectedStyle & EZ2_PLAYER_2)
GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE; {
// they both selected
// GAMESTATE->m_MasterPlayerNumber = PLAYER_1;
// GAMESTATE->m_bIsJoined[PLAYER_1] = true;
GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_VERSUS;
} else {
// only the left pad was selected
// GAMESTATE->m_MasterPlayerNumber = PLAYER_1;
GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE;
// GAMESTATE->m_bIsJoined[PLAYER_2] = true;
}
} }
else if (m_iSelectedStyle == 1) // only the right pad was selected else if (m_iSelectedStyle & EZ2_PLAYER_2) {
{ // only the right pad was selected
// GAMESTATE->m_MasterPlayerNumber = PLAYER_2; // GAMESTATE->m_MasterPlayerNumber = PLAYER_2;
GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE; GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE;
} // GAMESTATE->m_bIsJoined[PLAYER_2] = true;
else // they both selected } else ASSERT(0);
{
// GAMESTATE->m_MasterPlayerNumber = PLAYER_1;
GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_VERSUS;
}
MUSIC->Stop(); MUSIC->Stop();
m_Menu.TweenOffScreenToMenu( SM_GoToNextState ); m_Menu.TweenOffScreenToMenu( SM_GoToNextState );
TweenOffScreen();
break; break;
case SM_GoToPrevState: case SM_GoToPrevState:
@@ -257,44 +265,30 @@ presses the button bound to start
************************************/ ************************************/
void ScreenEz2SelectPlayer::MenuStart( PlayerNumber p ) void ScreenEz2SelectPlayer::MenuStart( PlayerNumber p )
{ {
//disallow multiple presses of the menu start. int this_player_bit = (p == PLAYER_1)? EZ2_PLAYER_1:EZ2_PLAYER_2;
if ( (m_iSelectedStyle == 0 && p == PLAYER_1) || (m_iSelectedStyle == 1 && p == PLAYER_2))
{ // disallow multiple presses of the menu start.
if ( m_iSelectedStyle & this_player_bit )
return; return;
}
// figure out whether we should add a player into the fray or not // figure out whether we should add a player into the fray or not
// if( GAMESTATE->m_MasterPlayerNumber != PLAYER_2 && GAMESTATE->m_MasterPlayerNumber != PLAYER_1 ) // if( GAMESTATE->m_MasterPlayerNumber != PLAYER_2 && GAMESTATE->m_MasterPlayerNumber != PLAYER_1 )
if (m_iSelectedStyle == 3) if (m_iSelectedStyle == 0)
{ {
// GAMESTATE->m_MasterPlayerNumber = p; // GAMESTATE->m_MasterPlayerNumber = p;
if (p == PLAYER_1) m_iSelectedStyle |= this_player_bit;
{
// GAMESTATE->m_bIsJoined[PLAYER_1] = true;
m_iSelectedStyle = 0;
}
else
{
m_iSelectedStyle = 1;
// GAMESTATE->m_bIsJoined[PLAYER_2] = true;
}
m_soundSelect.PlayRandom();
// wait for a bit incase another player wants to join before moving on. // wait for a bit in case another player wants to join before moving on.
this->ClearMessageQueue();
SCREENMAN->SendMessageToTopScreen( SM_PlayersChosen, 1.f ); SCREENMAN->SendMessageToTopScreen( SM_PlayersChosen, 1.f );
} }
else else
{ {
m_iSelectedStyle = 2; m_iSelectedStyle |= this_player_bit;
// GAMESTATE->m_bIsJoined[PLAYER_1] = true;
// GAMESTATE->m_bIsJoined[PLAYER_2] = true;
m_soundSelect.PlayRandom();
} }
m_soundSelect.PlayRandom();
TweenOffScreen(); TweenOffScreen();
} }
/************************************ /************************************
@@ -304,18 +298,18 @@ changes state.
************************************/ ************************************/
void ScreenEz2SelectPlayer::TweenOffScreen() void ScreenEz2SelectPlayer::TweenOffScreen()
{ {
if (m_iSelectedStyle == 0 || m_iSelectedStyle == 2) if (m_iSelectedStyle & EZ2_PLAYER_1)
{ {
m_sprOpt[1].BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); m_sprOpt[1].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprOpt[1].SetTweenZoomY( 0 ); m_sprOpt[1].SetTweenZoomY( 0 );
m_sprOpt[2].BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); m_sprOpt[2].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprOpt[2].SetTweenZoomY( 0 ); m_sprOpt[2].SetTweenZoomY( 0 );
} }
if (m_iSelectedStyle == 1 || m_iSelectedStyle == 2) if (m_iSelectedStyle & EZ2_PLAYER_2)
{ {
m_sprOpt[0].BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); m_sprOpt[0].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprOpt[0].SetTweenZoomY( 0 ); m_sprOpt[0].SetTweenZoomY( 0 );
m_sprOpt[3].BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); m_sprOpt[3].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprOpt[3].SetTweenZoomY( 0 ); m_sprOpt[3].SetTweenZoomY( 0 );
} }
} }
+6
View File
@@ -44,9 +44,15 @@ private:
MenuElements m_Menu; MenuElements m_Menu;
Sprite m_sprOpt[NUM_EZ2_GRAPHICS]; Sprite m_sprOpt[NUM_EZ2_GRAPHICS];
/* Bitflags for m_iSelectedStyle. */
enum { EZ2_PLAYER_1 = 0x01,
EZ2_PLAYER_2 = 0x02 };
int m_iSelectedStyle; int m_iSelectedStyle;
RandomSample m_soundChange; RandomSample m_soundChange;
RandomSample m_soundSelect; RandomSample m_soundSelect;
RandomSample m_soundInvalid; RandomSample m_soundInvalid;
// used for the bouncing of the '1p' and '2p' images
float ez2_bounce;
}; };