2003-02-16 04:01:45 +00:00
#include "global.h"
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-07-08 00:10:34 +00:00
#include "GameSoundManager.h"
2004-06-27 02:16:12 +00:00
#include "GameManager.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
{
2004-07-25 04:27:20 +00:00
GAMESTATE -> m_pCurStyle = GAMEMAN -> GetDemonstrationStyleForGame ( GAMESTATE -> m_pCurGame );
2003-01-10 02:22:07 +00:00
2004-06-11 06:05:35 +00:00
GAMESTATE -> m_PlayMode = PLAY_MODE_REGULAR ;
2003-01-10 02:22:07 +00:00
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
}
2004-11-26 17:28:47 +00:00
REGISTER_SCREEN_CLASS ( ScreenDemonstration );
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 :
if ( ! GAMESTATE -> IsTimeToPlayAttractSounds () )
SOUNDMAN -> SetPrefs ( 0 ); // silent
2004-03-25 10:25:22 +00:00
break ;
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
2003-01-10 02:22:07 +00:00
case SM_GoToNextScreen :
2004-10-25 03:47:22 +00:00
if ( m_pSoundMusic )
m_pSoundMusic -> 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
}
2004-06-08 05:22:33 +00:00
/*
* (c) 2003-2004 Chris Danford
* 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.
*/