2003-02-16 04:01:45 +00:00
# include "global.h"
2003-01-08 23:43:54 +00:00
/*
-----------------------------------------------------------------------------
Class: ScreenDemonstration
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
2003-01-10 02:22:07 +00:00
# include "ScreenDemonstration.h"
# include "RageLog.h"
# include "ThemeManager.h"
# include "GameState.h"
# include "SongManager.h"
# include "StepMania.h"
2003-03-09 00:55:49 +00:00
# include "ScreenAttract.h" // for AttractInput()
2003-04-13 00:44:50 +00:00
# include "ScreenManager.h"
2003-01-10 02:22:07 +00:00
2003-04-21 04:10:52 +00:00
# define SHOW_RANDOM_MODIFIERS THEME->GetMetricF("ScreenDemonstration","SecondsToShow")
2003-01-10 02:22:07 +00:00
# define SECONDS_TO_SHOW THEME->GetMetricF("ScreenDemonstration","SecondsToShow")
# define NEXT_SCREEN THEME->GetMetric("ScreenDemonstration","NextScreen")
2003-03-17 04:56:47 +00:00
const ScreenMessage SM_NotesEnded = ScreenMessage ( SM_User + 10 ) ; // MUST be same as in ScreenGameplay
2003-01-10 02:22:07 +00:00
2003-03-09 00:55:49 +00:00
bool PrepareForDemonstration ( ) // always return true.
2003-01-10 02:22:07 +00:00
{
switch ( GAMESTATE - > m_CurGame )
{
case GAME_DANCE : GAMESTATE - > m_CurStyle = STYLE_DANCE_VERSUS ; break ;
case GAME_PUMP : GAMESTATE - > m_CurStyle = STYLE_PUMP_VERSUS ; break ;
case GAME_EZ2 : GAMESTATE - > m_CurStyle = STYLE_EZ2_SINGLE_VERSUS ; break ;
case GAME_PARA : GAMESTATE - > m_CurStyle = STYLE_PARA_SINGLE ; break ;
case GAME_DS3DDX : GAMESTATE - > m_CurStyle = STYLE_DS3DDX_SINGLE ; break ;
case GAME_BM : GAMESTATE - > m_CurStyle = STYLE_BM_SINGLE ; break ;
2003-09-03 04:30:29 +00:00
case GAME_MANIAX : GAMESTATE - > m_CurStyle = STYLE_MANIAX_SINGLE ; break ;
2003-10-07 17:57:52 +00:00
case GAME_PNM : GAMESTATE - > m_CurStyle = STYLE_PNM_NINE ; break ;
2003-01-10 02:22:07 +00:00
default : ASSERT ( 0 ) ;
}
GAMESTATE - > m_PlayMode = PLAY_MODE_ARCADE ;
2003-01-19 04:44:22 +00:00
return true ;
2003-01-10 02:22:07 +00:00
}
2003-09-27 22:30:51 +00:00
ScreenDemonstration : : ScreenDemonstration ( CString sName ) : ScreenJukebox ( sName , PrepareForDemonstration ( ) ) // this is a hack to get some code to execute before the ScreenGameplay constructor
2003-01-10 02:22:07 +00:00
{
2003-01-19 04:44:22 +00:00
LOG - > Trace ( " ScreenDemonstration::ScreenDemonstration() " ) ;
2003-01-10 02:22:07 +00:00
2003-01-19 21:05:03 +00:00
if ( GAMESTATE - > m_pCurSong = = NULL ) // we didn't find a song.
{
2003-04-13 06:29:02 +00:00
HandleScreenMessage ( SM_GoToNextScreen ) ; // Abort demonstration.
2003-01-19 21:05:03 +00:00
return ;
}
2003-01-10 02:22:07 +00:00
2003-04-12 17:39:27 +00:00
m_Overlay . LoadFromAniDir ( THEME - > GetPathToB ( " ScreenDemonstration overlay " ) ) ;
2003-03-09 00:55:49 +00:00
this - > AddChild ( & m_Overlay ) ;
2003-01-10 02:22:07 +00:00
2003-03-09 00:55:49 +00:00
this - > MoveToTail ( & m_In ) ;
this - > MoveToTail ( & m_Out ) ;
2003-01-10 02:22:07 +00:00
2003-03-09 00:55:49 +00:00
ClearMessageQueue ( ) ; // remove all of the messages set in ScreenGameplay that drive "ready", "go", etc.
2003-01-10 02:22:07 +00:00
2003-01-25 11:05:12 +00:00
GAMESTATE - > m_bPastHereWeGo = true ;
2003-01-10 02:22:07 +00:00
m_DancingState = STATE_DANCING ;
2003-03-25 21:17:29 +00:00
this - > PostScreenMessage ( SM_BeginFadingOut , SECONDS_TO_SHOW ) ;
2003-01-10 02:22:07 +00:00
}
2003-01-19 04:44:22 +00:00
ScreenDemonstration : : ~ ScreenDemonstration ( )
2003-01-10 02:22:07 +00:00
{
2003-01-19 04:44:22 +00:00
}
2003-01-11 18:37:52 +00:00
2003-01-19 04:44:22 +00:00
void ScreenDemonstration : : Update ( float fDeltaTime )
{
2003-01-10 02:22:07 +00:00
ScreenGameplay : : Update ( fDeltaTime ) ;
}
void ScreenDemonstration : : Input ( const DeviceInput & DeviceI , const InputEventType type , const GameInput & GameI , const MenuInput & MenuI , const StyleInput & StyleI )
{
//LOG->Trace( "ScreenDemonstration::Input()" );
2003-01-19 04:44:22 +00:00
2003-06-13 18:40:40 +00:00
if ( MenuI . IsValid ( ) & & type = = IET_FIRST_PRESS )
2003-01-10 02:22:07 +00:00
{
switch ( MenuI . button )
{
2003-01-19 04:44:22 +00:00
case MENU_BUTTON_COIN :
case MENU_BUTTON_START :
2003-01-10 02:22:07 +00:00
case MENU_BUTTON_BACK :
2003-01-19 04:44:22 +00:00
2003-04-13 04:50:08 +00:00
if ( PREFSMAN - > m_iCoinMode = = COIN_PAY )
2003-01-19 04:44:22 +00:00
if ( GAMESTATE - > m_iCoins < PREFSMAN - > m_iCoinsPerCredit )
break ; // don't fall through
2003-03-09 03:28:34 +00:00
m_soundMusic . Stop ( ) ;
2003-01-10 02:22:07 +00:00
break ;
}
}
2003-03-09 00:55:49 +00:00
ScreenAttract : : AttractInput ( DeviceI , type , GameI , MenuI , StyleI , m_In . IsTransitioning ( ) | | m_Out . IsTransitioning ( ) ) ;
2003-01-10 02:22:07 +00:00
}
void ScreenDemonstration : : HandleScreenMessage ( const ScreenMessage SM )
{
switch ( SM )
{
case SM_NotesEnded :
2003-03-09 00:55:49 +00:00
case SM_BeginFadingOut :
2003-04-02 06:07:58 +00:00
if ( ! m_Out . IsTransitioning ( ) )
m_Out . StartTransitioning ( SM_GoToNextScreen ) ;
2003-01-10 02:22:07 +00:00
return ;
case SM_GoToNextScreen :
2003-02-03 05:53:59 +00:00
m_soundMusic . Stop ( ) ;
2003-03-11 08:52:45 +00:00
GAMESTATE - > Reset ( ) ;
2003-01-10 02:22:07 +00:00
SCREENMAN - > SetNewScreen ( NEXT_SCREEN ) ;
return ;
}
ScreenGameplay : : HandleScreenMessage ( SM ) ;
2003-02-15 00:05:48 +00:00
}