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-10-12 20:00:49 +00:00
# include "RageSoundManager.h"
2004-01-20 06:08:56 +00:00
# include "RageSounds.h"
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 ;
2004-01-22 07:00:44 +00:00
/* If needed, turn sound off. We need to do this before the ScreenGameplay ctor,
* since changes to sound volume aren't guaranteed to take effect if done *after*
* the sound starts playing. */
if ( ! GAMESTATE - > IsTimeToPlayAttractSounds ( ) )
SOUNDMAN - > SetPrefs ( 0 ) ; // silent
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
}
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 ;
2004-03-25 10:07:11 +00:00
case SM_GainFocus :
2003-12-28 19:46:50 +00:00
if ( ! GAMESTATE - > IsTimeToPlayAttractSounds ( ) )
2004-03-25 10:07:11 +00:00
SOUNDMAN - > SetPrefs ( 0 ) ; // silent
2004-03-25 10:25:22 +00:00
break ;
2003-10-12 20:00:49 +00:00
2004-03-25 10:07:11 +00:00
case SM_LoseFocus :
SOUNDMAN - > SetPrefs ( PREFSMAN - > m_fSoundVolume ) ; // turn volume back on
2004-03-25 10:25:22 +00:00
break ;
2004-03-25 10:07:11 +00:00
case SM_GoToNextScreen :
2004-05-21 00:58:48 +00:00
m_soundMusic . Stop ( ) ;
2003-03-11 08:52:45 +00:00
GAMESTATE - > Reset ( ) ;
2004-03-25 10:45:30 +00:00
SOUNDMAN - > SetPrefs ( PREFSMAN - > m_fSoundVolume ) ; // turn volume back on
2003-01-10 02:22:07 +00:00
SCREENMAN - > SetNewScreen ( NEXT_SCREEN ) ;
return ;
}
ScreenGameplay : : HandleScreenMessage ( SM ) ;
2003-02-15 00:05:48 +00:00
}