2002-08-13 23:26:46 +00:00
|
|
|
#include "stdafx.h"
|
2002-06-21 23:08:19 +00:00
|
|
|
/****************************************
|
|
|
|
|
ScreenEzSelectPlayer,cpp
|
|
|
|
|
Desc: See Header
|
|
|
|
|
Copyright (C):
|
|
|
|
|
Andrew Livy
|
|
|
|
|
*****************************************/
|
|
|
|
|
|
|
|
|
|
/* Includes */
|
|
|
|
|
|
|
|
|
|
#include "ScreenEz2SelectPlayer.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "RageMusic.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "PrefsManager.h"
|
2002-06-21 23:08:19 +00:00
|
|
|
#include "GameManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "AnnouncerManager.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "GameState.h"
|
2002-07-27 19:29:51 +00:00
|
|
|
#include "RageException.h"
|
|
|
|
|
#include "RageTimer.h"
|
2002-06-21 23:08:19 +00:00
|
|
|
|
|
|
|
|
/* Constants */
|
|
|
|
|
|
|
|
|
|
const ScreenMessage SM_GoToPrevState = ScreenMessage(SM_User + 1);
|
|
|
|
|
const ScreenMessage SM_GoToNextState = ScreenMessage(SM_User + 2);
|
2002-08-26 00:57:40 +00:00
|
|
|
const ScreenMessage SM_PlayersChosen = ScreenMessage(SM_User + 3);
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2002-08-27 03:59:22 +00:00
|
|
|
|
2002-08-27 16:53:25 +00:00
|
|
|
#define HELP_TEXT THEME->GetMetric("ScreenEz2SelectPlayer","HelpText")
|
|
|
|
|
#define TIMER_SECONDS THEME->GetMetricI("ScreenEz2SelectPlayer","TimerSeconds")
|
2002-08-27 03:59:22 +00:00
|
|
|
#define NEXT_SCREEN THEME->GetMetric("ScreenEz2SelectPlayer","NextScreen")
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2002-06-21 23:08:19 +00:00
|
|
|
const float TWEEN_TIME = 0.35f;
|
|
|
|
|
const D3DXCOLOR OPT_NOT_SELECTED = D3DXCOLOR(0.3f,0.3f,0.3f,1);
|
|
|
|
|
const D3DXCOLOR OPT_SELECTED = D3DXCOLOR(1.0f,1.0f,1.0f,1);
|
|
|
|
|
|
|
|
|
|
const float OPT_X[NUM_EZ2_GRAPHICS] = {
|
|
|
|
|
CENTER_X+200, // This is the pad X
|
|
|
|
|
CENTER_X-200, // This is the pad X
|
|
|
|
|
CENTER_X-198, // This is the 1p X
|
|
|
|
|
CENTER_X+195, // This is the 2p X
|
|
|
|
|
}; // tells us the default X position
|
|
|
|
|
const float OPT_Y[NUM_EZ2_GRAPHICS] = {
|
|
|
|
|
CENTER_Y+130,
|
|
|
|
|
CENTER_Y+130,
|
|
|
|
|
CENTER_Y+115,
|
|
|
|
|
CENTER_Y+115,
|
|
|
|
|
}; // tells us the default Y position
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
|
|
|
|
|
|
2002-06-21 23:08:19 +00:00
|
|
|
/************************************
|
|
|
|
|
ScreenEz2SelectPlayer (Constructor)
|
|
|
|
|
Desc: Sets up the screen display
|
|
|
|
|
************************************/
|
|
|
|
|
|
|
|
|
|
ScreenEz2SelectPlayer::ScreenEz2SelectPlayer()
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenEz2SelectPlayer::ScreenEz2SelectPlayer()" );
|
2002-08-26 01:20:03 +00:00
|
|
|
m_iSelectedStyle=0;
|
2002-07-23 01:41:40 +00:00
|
|
|
GAMESTATE->m_CurStyle = STYLE_NONE;
|
2002-08-26 01:20:03 +00:00
|
|
|
ez2_bounce=0.f;
|
2002-08-13 23:26:46 +00:00
|
|
|
// GAMESTATE->m_MasterPlayerNumber = PLAYER_INVALID;
|
2002-06-21 23:08:19 +00:00
|
|
|
|
|
|
|
|
// Load in the sprites we will be working with.
|
|
|
|
|
for( int i=0; i<NUM_EZ2_GRAPHICS; i++ )
|
|
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
CString sOptFileName;
|
2002-06-21 23:08:19 +00:00
|
|
|
switch( i )
|
|
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
case 0: sOptFileName = "select difficulty hard picture"; break;
|
|
|
|
|
case 1: sOptFileName = "select difficulty hard picture"; break;
|
|
|
|
|
case 2: sOptFileName = "select difficulty medium picture"; break;
|
|
|
|
|
case 3: sOptFileName = "select difficulty easy picture"; break;
|
2002-06-21 23:08:19 +00:00
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
m_sprOpt[i].Load( THEME->GetPathTo("Graphics",sOptFileName) );
|
2002-06-21 23:08:19 +00:00
|
|
|
m_sprOpt[i].SetXY( OPT_X[i], OPT_Y[i] );
|
2002-07-23 01:41:40 +00:00
|
|
|
this->AddSubActor( &m_sprOpt[i] );
|
2002-06-21 23:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_Menu.Load(
|
2002-08-13 23:26:46 +00:00
|
|
|
THEME->GetPathTo("Graphics","select style background"),
|
|
|
|
|
THEME->GetPathTo("Graphics","select style top edge"),
|
2002-08-27 16:53:25 +00:00
|
|
|
HELP_TEXT, true, TIMER_SECONDS
|
2002-06-21 23:08:19 +00:00
|
|
|
);
|
2002-07-23 01:41:40 +00:00
|
|
|
this->AddSubActor( &m_Menu );
|
2002-06-21 23:08:19 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
m_soundChange.Load( THEME->GetPathTo("Sounds","select style change") );
|
|
|
|
|
m_soundSelect.Load( THEME->GetPathTo("Sounds","menu start") );
|
|
|
|
|
m_soundInvalid.Load( THEME->GetPathTo("Sounds","menu invalid") );
|
2002-06-21 23:08:19 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
/* Chris: If EZ2 doesn't use this sound, make a theme that overrides is with a silent sound file */
|
|
|
|
|
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_SELECT_STYLE_INTRO) );
|
2002-06-21 23:08:19 +00:00
|
|
|
|
|
|
|
|
|
2002-08-27 03:59:22 +00:00
|
|
|
MUSIC->LoadAndPlayIfNotAlready( THEME->GetPathTo("Sounds","select player music") );
|
2002-06-21 23:08:19 +00:00
|
|
|
|
2002-08-25 23:10:28 +00:00
|
|
|
// GAMESTATE->m_bPlayersCanJoin = true;
|
|
|
|
|
// GAMESTATE->m_bIsJoined[PLAYER_1] = false;
|
|
|
|
|
// GAMESTATE->m_bIsJoined[PLAYER_2] = false;
|
|
|
|
|
|
2002-06-21 23:08:19 +00:00
|
|
|
// AfterChange();
|
|
|
|
|
// TweenOnScreen();
|
|
|
|
|
m_Menu.TweenOnScreenFromBlack( SM_None );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
|
~ScreenEz2SelectStyle (Destructor)
|
|
|
|
|
Desc: Writes line to log when screen
|
|
|
|
|
is terminated.
|
|
|
|
|
************************************/
|
|
|
|
|
ScreenEz2SelectPlayer::~ScreenEz2SelectPlayer()
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenEz2SelectPlayer::~ScreenEz2SelectPlayer()" );
|
2002-06-21 23:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************
|
2002-08-26 00:40:12 +00:00
|
|
|
Update
|
2002-06-21 23:08:19 +00:00
|
|
|
Desc: Animates the 1p/2p selection
|
|
|
|
|
************************************/
|
2002-08-26 00:40:12 +00:00
|
|
|
void ScreenEz2SelectPlayer::Update( float fDeltaTime )
|
2002-06-21 23:08:19 +00:00
|
|
|
{
|
2002-08-26 00:40:12 +00:00
|
|
|
Screen::Update( fDeltaTime );
|
2002-07-08 00:49:48 +00:00
|
|
|
|
2002-08-26 00:40:12 +00:00
|
|
|
fDeltaTime /= .01f;
|
|
|
|
|
|
2002-08-27 03:59:22 +00:00
|
|
|
ez2_bounce = fmodf((ez2_bounce+fDeltaTime), 20);
|
2002-08-26 00:40:12 +00:00
|
|
|
|
|
|
|
|
/* 0..10..19 -> 10..0..9 */
|
2002-08-27 03:59:22 +00:00
|
|
|
int offset = roundf( fabsf(10-ez2_bounce) );
|
2002-08-26 00:40:12 +00:00
|
|
|
m_sprOpt[2].SetXY( OPT_X[2], OPT_Y[2] - offset);
|
|
|
|
|
m_sprOpt[3].SetXY( OPT_X[3], OPT_Y[3] - offset);
|
2002-06-21 23:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
|
DrawPrimitives
|
|
|
|
|
Desc: Draws the screen =P
|
|
|
|
|
************************************/
|
|
|
|
|
|
|
|
|
|
void ScreenEz2SelectPlayer::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
m_Menu.DrawBottomLayer();
|
|
|
|
|
Screen::DrawPrimitives();
|
|
|
|
|
m_Menu.DrawTopLayer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
|
Input
|
|
|
|
|
Desc: Handles player input.
|
|
|
|
|
************************************/
|
|
|
|
|
void ScreenEz2SelectPlayer::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenEz2SelectPlayer::Input()" );
|
2002-06-21 23:08:19 +00:00
|
|
|
|
|
|
|
|
if( m_Menu.IsClosing() )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
|
HandleScreenMessage
|
|
|
|
|
Desc: Handles Screen Messages and changes
|
|
|
|
|
game states.
|
|
|
|
|
************************************/
|
|
|
|
|
void ScreenEz2SelectPlayer::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
Screen::HandleScreenMessage( SM );
|
|
|
|
|
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
|
|
|
|
case SM_MenuTimer:
|
2002-08-26 01:20:03 +00:00
|
|
|
/* 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);
|
2002-06-21 23:08:19 +00:00
|
|
|
break;
|
2002-08-26 00:57:40 +00:00
|
|
|
case SM_PlayersChosen:
|
2002-08-26 01:20:03 +00:00
|
|
|
if (m_iSelectedStyle & EZ2_PLAYER_1)
|
2002-08-26 00:57:40 +00:00
|
|
|
{
|
2002-08-26 01:20:03 +00:00
|
|
|
if (m_iSelectedStyle & EZ2_PLAYER_2)
|
|
|
|
|
{
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
2002-08-26 00:57:40 +00:00
|
|
|
}
|
2002-08-26 01:20:03 +00:00
|
|
|
else if (m_iSelectedStyle & EZ2_PLAYER_2) {
|
|
|
|
|
// only the right pad was selected
|
2002-08-26 00:57:40 +00:00
|
|
|
// GAMESTATE->m_MasterPlayerNumber = PLAYER_2;
|
|
|
|
|
GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE;
|
2002-08-26 01:20:03 +00:00
|
|
|
// GAMESTATE->m_bIsJoined[PLAYER_2] = true;
|
|
|
|
|
} else ASSERT(0);
|
2002-08-26 00:57:40 +00:00
|
|
|
|
|
|
|
|
MUSIC->Stop();
|
|
|
|
|
|
|
|
|
|
m_Menu.TweenOffScreenToMenu( SM_GoToNextState );
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
2002-06-21 23:08:19 +00:00
|
|
|
case SM_GoToPrevState:
|
|
|
|
|
MUSIC->Stop();
|
2002-08-27 03:59:22 +00:00
|
|
|
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
2002-06-21 23:08:19 +00:00
|
|
|
break;
|
|
|
|
|
case SM_GoToNextState:
|
2002-08-27 03:59:22 +00:00
|
|
|
SCREENMAN->SetNewScreen( NEXT_SCREEN );
|
2002-06-21 23:08:19 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
|
MenuBack
|
|
|
|
|
Desc: Actions performed when a player
|
|
|
|
|
presses the button bound to back
|
|
|
|
|
************************************/
|
|
|
|
|
|
|
|
|
|
void ScreenEz2SelectPlayer::MenuBack( const PlayerNumber p )
|
|
|
|
|
{
|
|
|
|
|
MUSIC->Stop();
|
|
|
|
|
|
|
|
|
|
m_Menu.TweenOffScreenToBlack( SM_GoToPrevState, true );
|
|
|
|
|
|
|
|
|
|
// m_Fade.CloseWipingLeft( SM_GoToPrevState );
|
|
|
|
|
|
|
|
|
|
// TweenOffScreen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************
|
2002-07-08 00:49:48 +00:00
|
|
|
MenuDown
|
2002-06-21 23:08:19 +00:00
|
|
|
Desc: Actions performed when a player
|
2002-07-08 00:49:48 +00:00
|
|
|
presses the button bound to down
|
2002-06-21 23:08:19 +00:00
|
|
|
************************************/
|
2002-07-08 00:49:48 +00:00
|
|
|
void ScreenEz2SelectPlayer::MenuDown( PlayerNumber p )
|
2002-06-21 23:08:19 +00:00
|
|
|
{
|
2002-07-08 00:49:48 +00:00
|
|
|
MenuStart( p );
|
2002-06-21 23:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
|
MenuStart
|
|
|
|
|
Desc: Actions performed when a player
|
|
|
|
|
presses the button bound to start
|
|
|
|
|
************************************/
|
|
|
|
|
void ScreenEz2SelectPlayer::MenuStart( PlayerNumber p )
|
|
|
|
|
{
|
2002-08-26 01:20:03 +00:00
|
|
|
int this_player_bit = (p == PLAYER_1)? EZ2_PLAYER_1:EZ2_PLAYER_2;
|
2002-06-21 23:08:19 +00:00
|
|
|
|
2002-08-26 01:20:03 +00:00
|
|
|
// disallow multiple presses of the menu start.
|
|
|
|
|
if ( m_iSelectedStyle & this_player_bit )
|
|
|
|
|
return;
|
|
|
|
|
|
2002-07-08 00:49:48 +00:00
|
|
|
// figure out whether we should add a player into the fray or not
|
2002-07-23 01:41:40 +00:00
|
|
|
// if( GAMESTATE->m_MasterPlayerNumber != PLAYER_2 && GAMESTATE->m_MasterPlayerNumber != PLAYER_1 )
|
2002-08-26 01:20:03 +00:00
|
|
|
if (m_iSelectedStyle == 0)
|
2002-07-08 00:49:48 +00:00
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
// GAMESTATE->m_MasterPlayerNumber = p;
|
2002-07-23 01:41:40 +00:00
|
|
|
|
2002-08-26 01:20:03 +00:00
|
|
|
m_iSelectedStyle |= this_player_bit;
|
|
|
|
|
|
|
|
|
|
// wait for a bit in case another player wants to join before moving on.
|
2002-08-26 00:57:40 +00:00
|
|
|
SCREENMAN->SendMessageToTopScreen( SM_PlayersChosen, 1.f );
|
2002-07-08 00:49:48 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-08-26 01:20:03 +00:00
|
|
|
m_iSelectedStyle |= this_player_bit;
|
2002-07-08 00:49:48 +00:00
|
|
|
}
|
2002-07-12 17:46:15 +00:00
|
|
|
|
2002-08-26 01:20:03 +00:00
|
|
|
m_soundSelect.PlayRandom();
|
2002-06-21 23:08:19 +00:00
|
|
|
TweenOffScreen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
|
TweenOffScreen
|
|
|
|
|
Desc: Squashes graphics before the screen
|
|
|
|
|
changes state.
|
|
|
|
|
************************************/
|
|
|
|
|
void ScreenEz2SelectPlayer::TweenOffScreen()
|
|
|
|
|
{
|
2002-08-26 01:20:03 +00:00
|
|
|
if (m_iSelectedStyle & EZ2_PLAYER_1)
|
|
|
|
|
{
|
|
|
|
|
m_sprOpt[1].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
|
|
|
|
|
m_sprOpt[1].SetTweenZoomY( 0 );
|
|
|
|
|
m_sprOpt[2].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
|
|
|
|
|
m_sprOpt[2].SetTweenZoomY( 0 );
|
|
|
|
|
}
|
|
|
|
|
if (m_iSelectedStyle & EZ2_PLAYER_2)
|
|
|
|
|
{
|
|
|
|
|
m_sprOpt[0].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
|
|
|
|
|
m_sprOpt[0].SetTweenZoomY( 0 );
|
|
|
|
|
m_sprOpt[3].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
|
|
|
|
|
m_sprOpt[3].SetTweenZoomY( 0 );
|
|
|
|
|
}
|
2002-06-21 23:08:19 +00:00
|
|
|
}
|