Files
itgmania212121/stepmania/src/ScreenDemonstration.cpp
T

115 lines
3.8 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
#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"
#include "RageSoundManager.h"
2004-07-08 00:10:34 +00:00
#include "GameSoundManager.h"
#include "GameManager.h"
#define SECONDS_TO_SHOW THEME->GetMetricF("ScreenDemonstration","SecondsToShow")
#define NEXT_SCREEN THEME->GetMetric("ScreenDemonstration","NextScreen")
const ScreenMessage SM_NotesEnded = ScreenMessage(SM_User+10); // MUST be same as in ScreenGameplay
2003-03-09 00:55:49 +00:00
bool PrepareForDemonstration() // always return true.
{
2004-06-28 07:26:00 +00:00
GAMESTATE->m_pCurStyle = GAMEMAN->GetDemonstrationStyleForGame(GAMESTATE->m_CurGame);
GAMESTATE->m_PlayMode = PLAY_MODE_REGULAR;
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-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-19 04:44:22 +00:00
LOG->Trace( "ScreenDemonstration::ScreenDemonstration()" );
2003-01-19 21:05:03 +00:00
if( GAMESTATE->m_pCurSong == NULL ) // we didn't find a song.
{
HandleScreenMessage( SM_GoToNextScreen ); // Abort demonstration.
2003-01-19 21:05:03 +00:00
return;
}
m_Overlay.LoadFromAniDir( THEME->GetPathToB("ScreenDemonstration overlay") );
2003-03-09 00:55:49 +00:00
this->AddChild( &m_Overlay );
2003-03-09 00:55:49 +00:00
this->MoveToTail( &m_In );
this->MoveToTail( &m_Out );
2003-03-09 00:55:49 +00:00
ClearMessageQueue(); // remove all of the messages set in ScreenGameplay that drive "ready", "go", etc.
2003-01-25 11:05:12 +00:00
GAMESTATE->m_bPastHereWeGo = true;
m_DancingState = STATE_DANCING;
2003-03-25 21:17:29 +00:00
this->PostScreenMessage( SM_BeginFadingOut, SECONDS_TO_SHOW );
}
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 );
return;
case SM_GainFocus:
2003-12-28 19:46:50 +00:00
if( !GAMESTATE->IsTimeToPlayAttractSounds() )
SOUNDMAN->SetPrefs( 0 ); // silent
break;
case SM_LoseFocus:
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on
break;
case SM_GoToNextScreen:
m_soundMusic.Stop();
2003-03-11 08:52:45 +00:00
GAMESTATE->Reset();
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on
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.
*/