Files
itgmania212121/stepmania/src/ScreenEz2SelectPlayer.cpp
T

259 lines
7.8 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
#include "ScreenEz2SelectPlayer.h"
#include "ScreenManager.h"
2004-07-08 00:10:34 +00:00
#include "GameSoundManager.h"
#include "GameConstantsAndTypes.h"
#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 "RageTimer.h"
#include "ThemeManager.h"
2003-11-07 20:10:38 +00:00
#include "MenuTimer.h"
#include "ScreenDimensions.h"
2006-09-15 01:47:24 +00:00
#include "InputEventPlus.h"
/* Constants */
#define JOIN_FRAME_X( p ) THEME->GetMetricF("ScreenEz2SelectPlayer",ssprintf("JoinFrameP%dX",p+1))
#define JOIN_FRAME_Y( i ) THEME->GetMetricF("ScreenEz2SelectPlayer",ssprintf("JoinFrameP%dY",i+1))
#define JOIN_MESSAGE_X( p ) THEME->GetMetricF("ScreenEz2SelectPlayer",ssprintf("JoinMessageP%dX",p+1))
#define JOIN_MESSAGE_Y( i ) THEME->GetMetricF("ScreenEz2SelectPlayer",ssprintf("JoinMessageP%dY",i+1))
2006-01-08 18:40:20 +00:00
#define HELP_TEXT THEME->GetString("ScreenEz2SelectPlayer","HelpText")
2002-08-27 16:53:25 +00:00
#define TIMER_SECONDS THEME->GetMetricI("ScreenEz2SelectPlayer","TimerSeconds")
2003-03-11 21:33:11 +00:00
#define SILENT_WAIT THEME->GetMetricB("ScreenEz2SelectPlayer","SilentWait")
#define BOUNCE_JOIN_MESSAGE THEME->GetMetricB("ScreenEz2SelectPlayer","BounceJoinMessage")
#define FOLD_ON_JOIN THEME->GetMetricB("ScreenEz2SelectPlayer","FoldOnJoin")
const float TWEEN_TIME = 0.35f;
2006-01-15 20:46:15 +00:00
REGISTER_SCREEN_CLASS( ScreenEz2SelectPlayer );
2006-01-15 18:54:03 +00:00
void ScreenEz2SelectPlayer::Init()
{
// Unjoin the players, then let them join back in on this screen
FOREACH_PlayerNumber( p )
GAMESTATE->m_bSideIsJoined[p] = false;
ScreenWithMenuElements::Init();
FOREACH_PlayerNumber( p )
{
2005-02-06 03:32:53 +00:00
m_sprJoinFrame[p].Load( THEME->GetPathG("ScreenEz2SelectPlayer","join frame 1x2") );
m_sprJoinFrame[p].StopAnimating();
m_sprJoinFrame[p].SetState( p );
m_sprJoinFrame[p].SetXY( JOIN_FRAME_X(p), JOIN_FRAME_Y(p) );
this->AddChild( &m_sprJoinFrame[p] );
if( GAMESTATE->m_bSideIsJoined[p] )
m_sprJoinFrame[p].SetZoomY( 0 );
2005-02-06 03:32:53 +00:00
m_sprJoinMessage[p].Load( THEME->GetPathG("ScreenEz2SelectPlayer","join message 2x2") );
m_sprJoinMessage[p].StopAnimating();
m_sprJoinMessage[p].SetState( p );
m_sprJoinMessage[p].SetXY( JOIN_MESSAGE_X(p), JOIN_MESSAGE_Y(p) );
if( BOUNCE_JOIN_MESSAGE )
2003-03-02 01:43:33 +00:00
m_sprJoinMessage[p].SetEffectBounce( 0.5f, RageVector3(0,10,0) );
this->AddChild( &m_sprJoinMessage[p] );
if( GAMESTATE->m_bSideIsJoined[p] )
{
m_sprJoinMessage[p].SetState( p+NUM_PLAYERS );
if( FOLD_ON_JOIN )
{
m_sprJoinMessage[p].SetZoomY( 0 );
m_sprJoinFrame[p].SetZoomY( 0 );
}
}
}
2003-07-26 22:53:22 +00:00
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("select player intro") );
}
/************************************
~ScreenSelectMode (Destructor)
Desc: Writes line to log when screen
is terminated.
************************************/
ScreenEz2SelectPlayer::~ScreenEz2SelectPlayer()
{
LOG->Trace( "ScreenEz2SelectPlayer::~ScreenEz2SelectPlayer()" );
}
/************************************
Update
Desc: Animates the 1p/2p selection
************************************/
void ScreenEz2SelectPlayer::Update( float fDeltaTime )
{
2006-11-21 20:03:28 +00:00
ScreenWithMenuElements::Update( fDeltaTime );
}
/************************************
Input
Desc: Handles player input.
************************************/
void ScreenEz2SelectPlayer::Input( const InputEventPlus &input )
{
LOG->Trace( "ScreenEz2SelectPlayer::Input()" );
if( IsTransitioning() )
return;
2006-11-21 20:03:28 +00:00
ScreenWithMenuElements::Input( input ); // default input handler
}
/************************************
HandleScreenMessage
Desc: Handles Screen Messages and changes
game states.
************************************/
void ScreenEz2SelectPlayer::HandleScreenMessage( const ScreenMessage SM )
{
2006-11-21 20:03:28 +00:00
ScreenWithMenuElements::HandleScreenMessage( SM );
2006-02-24 00:20:41 +00:00
if( SM == SM_MenuTimer )
{
2002-09-29 05:06:18 +00:00
if( GAMESTATE->GetNumSidesJoined() == 0 )
{
2006-09-15 01:47:24 +00:00
InputEventPlus iep;
iep.pn = PLAYER_1;
MenuStart(iep);
}
2002-09-29 05:06:18 +00:00
StartTransitioningScreen( SM_GoToNextScreen );
}
2005-07-12 05:38:13 +00:00
ScreenWithMenuElements::HandleScreenMessage( SM );
}
/************************************
MenuBack
Desc: Actions performed when a player
presses the button bound to back
************************************/
2006-09-15 01:47:24 +00:00
void ScreenEz2SelectPlayer::MenuBack( const InputEventPlus &input )
{
2003-07-26 22:53:22 +00:00
SOUND->StopMusic();
Cancel( SM_GoToPrevScreen );
}
/************************************
2002-07-08 00:49:48 +00:00
MenuDown
Desc: Actions performed when a player
2002-07-08 00:49:48 +00:00
presses the button bound to down
************************************/
2006-09-15 01:47:24 +00:00
void ScreenEz2SelectPlayer::MenuDown( const InputEventPlus &input )
{
2006-09-15 01:47:24 +00:00
MenuStart( input );
}
/************************************
2002-07-08 00:49:48 +00:00
MenuStart
Desc: Actions performed when a player
2002-07-08 00:49:48 +00:00
presses the button bound to start
************************************/
2006-09-15 01:47:24 +00:00
void ScreenEz2SelectPlayer::MenuStart( const InputEventPlus &input )
{
2006-09-15 01:47:24 +00:00
PlayerNumber pn = input.pn;
if( GAMESTATE->m_bSideIsJoined[pn] ) // already joined
return; // ignore
GAMESTATE->JoinPlayer( pn );
SCREENMAN->PlayStartSound();
2002-09-30 17:33:49 +00:00
m_sprJoinMessage[pn].SetState( pn+NUM_PLAYERS );
2002-09-30 17:02:29 +00:00
if( FOLD_ON_JOIN )
{
m_sprJoinMessage[pn].BeginTweening( 0.25f );
2003-04-12 06:16:12 +00:00
m_sprJoinMessage[pn].SetZoomY( 0 );
2002-09-30 17:02:29 +00:00
m_sprJoinFrame[pn].BeginTweening( 0.25f );
2003-04-12 06:16:12 +00:00
m_sprJoinFrame[pn].SetZoomY( 0 );
2002-09-30 17:02:29 +00:00
}
2002-07-23 01:41:40 +00:00
bool bBothSidesJoined = true;
FOREACH_PlayerNumber( p )
2002-09-04 20:09:56 +00:00
if( !GAMESTATE->m_bSideIsJoined[p] )
bBothSidesJoined = false;
2002-08-26 01:20:03 +00:00
if( bBothSidesJoined )
{
StartTransitioningScreen( SM_GoToNextScreen );
}
else
{
// give the other player a little time to join
m_MenuTimer->SetSeconds( 1 );
m_MenuTimer->Start();
m_MenuTimer->EnableStealth( SILENT_WAIT ); // do we wanna make the timer 'quiet' ?
}
}
2002-07-12 17:46:15 +00:00
2005-10-14 03:11:50 +00:00
void ScreenEz2SelectPlayer::TweenOnScreen()
{
FOREACH_PlayerNumber( p )
{
float fOffScreenOffset = float( (p==PLAYER_1) ? -SCREEN_WIDTH/2 : +SCREEN_WIDTH/2 );
float fOriginalX;
fOriginalX = m_sprJoinMessage[p].GetX();
m_sprJoinMessage[p].SetX( m_sprJoinMessage[p].GetX()+fOffScreenOffset );
m_sprJoinMessage[p].BeginTweening( 0.5f, TWEEN_ACCELERATE );
2003-04-12 06:16:12 +00:00
m_sprJoinMessage[p].SetX( fOriginalX );
fOriginalX = m_sprJoinFrame[p].GetX();
m_sprJoinFrame[p].SetX( m_sprJoinMessage[p].GetX()+fOffScreenOffset );
m_sprJoinFrame[p].BeginTweening( 0.5f, TWEEN_ACCELERATE );
2003-04-12 06:16:12 +00:00
m_sprJoinFrame[p].SetX( fOriginalX );
}
2005-10-14 03:11:50 +00:00
ScreenWithMenuElements::TweenOnScreen();
}
2005-10-13 22:49:20 +00:00
void ScreenEz2SelectPlayer::TweenOffScreen()
{
2005-10-13 22:49:20 +00:00
ScreenWithMenuElements::TweenOffScreen();
FOREACH_PlayerNumber( p )
{
float fOffScreenOffset = float( (p==PLAYER_1) ? -SCREEN_WIDTH : +SCREEN_WIDTH );
2006-01-23 04:42:12 +00:00
m_sprJoinMessage[p].BeginTweening( 0.5f, TWEEN_DECELERATE );
2003-04-12 06:16:12 +00:00
m_sprJoinMessage[p].SetX( m_sprJoinMessage[p].GetX()+fOffScreenOffset );
2006-01-23 04:42:12 +00:00
m_sprJoinFrame[p].BeginTweening( 0.5f, TWEEN_DECELERATE );
2003-04-12 06:16:12 +00:00
m_sprJoinFrame[p].SetX( m_sprJoinMessage[p].GetX()+fOffScreenOffset );
2002-08-26 01:20:03 +00:00
}
}
2004-06-08 05:22:33 +00:00
/*
* (c) 2002-2003 "Frieza"
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/