Files
itgmania212121/stepmania/src/ScreenEz2SelectStyle.cpp
T

331 lines
9.1 KiB
C++
Raw Normal View History

#include "stdafx.h"
2002-06-23 11:43:53 +00:00
/****************************************
ScreenEzSelectPlayer,cpp
Desc: See Header
Copyright (C):
Andrew Livy
*****************************************/
/* Includes */
#include "ScreenEz2SelectStyle.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-23 11:43:53 +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-08-29 20:18:41 +00:00
#include "GameState.h"
2002-06-23 11:43:53 +00:00
/* Constants */
const ScreenMessage SM_GoToPrevScreen = ScreenMessage(SM_User + 1);
const ScreenMessage SM_GoToNextScreen = ScreenMessage(SM_User + 2);
2002-08-29 20:18:41 +00:00
#define CURSOR_X( p ) THEME->GetMetricF("ScreenEz2SelectStyle",ssprintf("CursorP%dX",p+1))
#define CURSOR_Y( i ) THEME->GetMetricF("ScreenEz2SelectStyle",ssprintf("CursorP%dY",i+1))
#define CONTROLLER_X( p ) THEME->GetMetricF("ScreenEz2SelectStyle",ssprintf("ControllerP%dX",p+1))
#define CONTROLLER_Y( i ) THEME->GetMetricF("ScreenEz2SelectStyle",ssprintf("ControllerP%dY",i+1))
#define HELP_TEXT THEME->GetMetric("ScreenEz2SelectStyle","HelpText")
#define TIMER_SECONDS THEME->GetMetricI("ScreenEz2SelectStyle","TimerSeconds")
#define NEXT_SCREEN THEME->GetMetric("ScreenEz2SelectStyle","NextScreen")
2002-06-23 11:43:53 +00:00
const float TWEEN_TIME = 0.35f;
2002-06-23 11:43:53 +00:00
/************************************
ScreenEz2SelectStyle (Constructor)
Desc: Sets up the screen display
************************************/
ScreenEz2SelectStyle::ScreenEz2SelectStyle()
{
LOG->Trace( "ScreenEz2SelectStyle::ScreenEz2SelectStyle()" );
2002-06-23 11:43:53 +00:00
2002-08-29 20:18:41 +00:00
GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE; // the only mode you can select on this screen
2002-08-29 20:18:41 +00:00
m_ScrollingList.SetXY( CENTER_X, CENTER_Y );
m_ScrollingList.SetSpacing( 400 );
m_ScrollingList.SetNumberVisible( 5 );
this->AddChild( &m_ScrollingList );
2002-08-29 20:18:41 +00:00
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-08-29 20:18:41 +00:00
if( GAMESTATE->m_bSideIsJoined[p] ) // if side is already joined
continue; // don't show bobbing join and blob
m_sprControllers[p].Load( THEME->GetPathTo("Graphics","select player controller") );
m_sprControllers[p].SetXY( CONTROLLER_X(p), CONTROLLER_Y(p) );
this->AddChild( &m_sprControllers[p] );
2002-08-29 20:18:41 +00:00
m_sprCursors[p].Load( THEME->GetPathTo("Graphics",ssprintf("select player cursor p%d",p+1)) );
m_sprCursors[p].SetXY( CURSOR_X(p), CURSOR_Y(p) );
m_sprCursors[p].SetEffectBouncing( D3DXVECTOR3(0,10,0), 0.5f );
this->AddChild( &m_sprCursors[p] );
}
2002-08-29 20:18:41 +00:00
2002-06-23 11:43:53 +00:00
m_Menu.Load(
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-23 11:43:53 +00:00
);
this->AddChild( &m_Menu );
2002-06-23 11:43:53 +00:00
m_soundSelect.Load( THEME->GetPathTo("Sounds","menu start") );
2002-08-29 20:18:41 +00:00
m_soundChange.Load( THEME->GetPathTo("Sounds","select style change") );
2002-06-23 11:43:53 +00:00
2002-08-29 20:18:41 +00:00
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo("select style intro") );
2002-06-23 11:43:53 +00:00
2002-08-27 16:53:25 +00:00
MUSIC->LoadAndPlayIfNotAlready( THEME->GetPathTo("Sounds","select style music") );
2002-08-29 20:18:41 +00:00
RefreshStylesAndList();
TweenOnScreen();
2002-06-23 11:43:53 +00:00
m_Menu.TweenOnScreenFromBlack( SM_None );
}
/************************************
~ScreenEz2SelectStyle (Destructor)
Desc: Writes line to log when screen
is terminated.
************************************/
ScreenEz2SelectStyle::~ScreenEz2SelectStyle()
{
LOG->Trace( "ScreenEz2SelectStyle::~ScreenEz2SelectStyle()" );
2002-06-23 11:43:53 +00:00
}
2002-08-29 20:18:41 +00:00
/************************************
Update
Desc: Animates the 1p/2p selection
************************************/
void ScreenEz2SelectStyle::Update( float fDeltaTime )
{
Screen::Update( fDeltaTime );
}
2002-06-23 11:43:53 +00:00
/************************************
DrawPrimitives
Desc: Draws the screen =P
************************************/
void ScreenEz2SelectStyle::DrawPrimitives()
{
m_Menu.DrawBottomLayer();
Screen::DrawPrimitives();
m_Menu.DrawTopLayer();
}
/************************************
Input
Desc: Handles player input.
************************************/
void ScreenEz2SelectStyle::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
LOG->Trace( "ScreenEz2SelectStyle::Input()" );
2002-06-23 11:43:53 +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 ScreenEz2SelectStyle::HandleScreenMessage( const ScreenMessage SM )
{
Screen::HandleScreenMessage( SM );
switch( SM )
{
case SM_MenuTimer:
2002-08-29 20:18:41 +00:00
{
bool bAtLeastOneJoined = false;
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->m_bSideIsJoined[p] )
bAtLeastOneJoined = true;
if( !bAtLeastOneJoined )
{
MenuStart(PLAYER_1);
m_Menu.StopTimer();
}
TweenOffScreen();
m_Menu.TweenOffScreenToMenu( SM_GoToNextScreen );
}
2002-06-23 11:43:53 +00:00
break;
case SM_GoToPrevScreen:
2002-06-23 11:43:53 +00:00
MUSIC->Stop();
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
2002-06-23 11:43:53 +00:00
break;
case SM_GoToNextScreen:
SCREENMAN->SetNewScreen( NEXT_SCREEN );
2002-06-23 11:43:53 +00:00
break;
}
}
2002-08-29 20:18:41 +00:00
void ScreenEz2SelectStyle::RefreshStylesAndList()
{
GAMEMAN->GetGameplayStylesForGame( GAMESTATE->m_CurGame, m_aPossibleStyles );
ASSERT( m_aPossibleStyles.GetSize() > 0 ); // every game should have at least one Style, or else why have the Game? :-)
// strip out Styles that don't work for the current number of players
int iNumSidesJoined = 0;
for( int c=0; c<2; c++ )
if( GAMESTATE->m_bSideIsJoined[c] )
iNumSidesJoined++; // left side, and right side
for( int i=m_aPossibleStyles.GetSize()-1; i>=0; i-- )
{
Style style = m_aPossibleStyles[i];
switch( GAMEMAN->GetStyleDefForStyle(style)->m_StyleType )
{
case StyleDef::ONE_PLAYER_ONE_CREDIT:
if( iNumSidesJoined!=1 )
m_aPossibleStyles.RemoveAt( i );
break;
case StyleDef::ONE_PLAYER_TWO_CREDITS:
case StyleDef::TWO_PLAYERS_TWO_CREDITS:
if( iNumSidesJoined!=2 )
m_aPossibleStyles.RemoveAt( i );
break;
default: ASSERT(0);
}
}
CStringArray asGraphicPaths;
for( i=0; i<m_aPossibleStyles.GetSize(); i++ )
2002-08-29 20:18:41 +00:00
{
Style style = m_aPossibleStyles[i];
CString sGameName = GAMESTATE->GetCurrentGameDef()->m_szName;
CString sStyleName = GAMEMAN->GetStyleDefForStyle(style)->m_szName;
asGraphicPaths.Add( THEME->GetPathTo("Graphics",ssprintf("select style info %s %s",sGameName,sStyleName)) );
}
m_ScrollingList.Load( asGraphicPaths );
}
2002-06-23 11:43:53 +00:00
/************************************
MenuBack
Desc: Actions performed when a player
presses the button bound to back
************************************/
void ScreenEz2SelectStyle::MenuBack( PlayerNumber p )
2002-06-23 11:43:53 +00:00
{
MUSIC->Stop();
m_Menu.TweenOffScreenToBlack( SM_GoToPrevScreen, true );
2002-06-23 11:43:53 +00:00
}
2002-07-08 19:08:15 +00:00
2002-08-29 20:18:41 +00:00
void ScreenEz2SelectStyle::MenuLeft( PlayerNumber p )
2002-06-23 11:43:53 +00:00
{
2002-08-29 20:18:41 +00:00
m_ScrollingList.Left();
m_soundChange.Play();
2002-06-23 11:43:53 +00:00
}
void ScreenEz2SelectStyle::MenuRight( PlayerNumber p )
{
2002-08-29 20:18:41 +00:00
m_ScrollingList.Right();
m_soundChange.Play();
2002-06-23 11:43:53 +00:00
}
/************************************
2002-08-29 20:18:41 +00:00
MenuDown
2002-06-23 11:43:53 +00:00
Desc: Actions performed when a player
2002-08-29 20:18:41 +00:00
presses the button bound to down
2002-06-23 11:43:53 +00:00
************************************/
2002-08-29 20:18:41 +00:00
void ScreenEz2SelectStyle::MenuDown( PlayerNumber p )
2002-06-23 11:43:53 +00:00
{
2002-08-29 20:18:41 +00:00
if( GAMESTATE->m_bSideIsJoined[p] ) // already joined
return; // ignore
2002-08-29 20:18:41 +00:00
MenuStart( p );
2002-06-23 11:43:53 +00:00
}
/************************************
MenuStart
Desc: Actions performed when a player
presses the button bound to start
************************************/
void ScreenEz2SelectStyle::MenuStart( PlayerNumber p )
{
2002-08-29 20:18:41 +00:00
if( !GAMESTATE->m_bSideIsJoined[p] )
2002-07-08 17:25:02 +00:00
{
2002-08-29 20:18:41 +00:00
// join them
GAMESTATE->m_bSideIsJoined[p] = true;
SCREENMAN->RefreshCreditsMessages();
m_soundSelect.Play();
m_sprCursors[p].BeginTweening( 0.25f );
m_sprCursors[p].SetTweenZoomY( 0 );
m_sprControllers[p].BeginTweening( 0.25f );
m_sprControllers[p].SetTweenZoomY( 0 );
RefreshStylesAndList();
m_ScrollingList.SetSelection( 0 );
2002-07-08 17:25:02 +00:00
}
2002-08-29 20:18:41 +00:00
else
2002-07-08 17:25:02 +00:00
{
2002-08-29 20:18:41 +00:00
// made a selection
m_soundSelect.Play();
GAMESTATE->m_CurStyle = m_aPossibleStyles[m_ScrollingList.GetSelection()];
TweenOffScreen();
m_Menu.TweenOffScreenToMenu( SM_GoToNextScreen );
2002-07-08 17:25:02 +00:00
}
}
2002-08-29 20:18:41 +00:00
void ScreenEz2SelectStyle::TweenOnScreen()
{
2002-08-29 20:18:41 +00:00
float fOriginalZoomY = m_ScrollingList.GetZoomY();
m_ScrollingList.BeginTweening( 0.5f );
m_ScrollingList.SetTweenZoomY( fOriginalZoomY );
for( int p=0; p<NUM_PLAYERS; p++ )
2002-07-15 23:53:13 +00:00
{
2002-08-29 20:18:41 +00:00
float fOffScreenOffset = float( (p==PLAYER_1) ? -SCREEN_WIDTH/2 : +SCREEN_WIDTH/2 );
float fOriginalX;
fOriginalX = m_sprCursors[p].GetX();
m_sprCursors[p].SetX( m_sprCursors[p].GetX()+fOffScreenOffset );
m_sprCursors[p].BeginTweening( 0.5f, Actor::TWEEN_BOUNCE_END );
m_sprCursors[p].SetTweenX( fOriginalX );
fOriginalX = m_sprControllers[p].GetX();
m_sprControllers[p].SetX( m_sprCursors[p].GetX()+fOffScreenOffset );
m_sprControllers[p].BeginTweening( 0.5f, Actor::TWEEN_BOUNCE_END );
m_sprControllers[p].SetTweenX( fOriginalX );
}
2002-06-23 11:43:53 +00:00
}
2002-07-08 17:25:02 +00:00
2002-08-29 20:18:41 +00:00
void ScreenEz2SelectStyle::TweenOffScreen()
{
2002-08-29 20:18:41 +00:00
m_ScrollingList.BeginTweening( 0.5f );
m_ScrollingList.SetTweenZoomY( 0 );
2002-08-29 20:18:41 +00:00
for( int p=0; p<NUM_PLAYERS; p++ )
{
float fOffScreenOffset = float( (p==PLAYER_1) ? -SCREEN_WIDTH : +SCREEN_WIDTH );
2002-08-29 20:18:41 +00:00
m_sprCursors[p].BeginTweening( 0.5f, Actor::TWEEN_BIAS_END );
m_sprCursors[p].SetTweenX( m_sprCursors[p].GetX()+fOffScreenOffset );
m_sprControllers[p].BeginTweening( 0.5f, Actor::TWEEN_BIAS_END );
m_sprControllers[p].SetTweenX( m_sprCursors[p].GetX()+fOffScreenOffset );
}
}