2003-02-16 04:01:45 +00:00
# include "global.h"
2003-01-08 23:43:54 +00:00
# include "ScreenAttract.h"
# include "ScreenManager.h"
# include "GameConstantsAndTypes.h"
# include "RageUtil.h"
# include "StepMania.h"
# include "PrefsManager.h"
# include "RageLog.h"
# include "SongManager.h"
# include "GameState.h"
# include "GameManager.h"
# include "InputMapper.h"
# include "ThemeManager.h"
2004-07-08 00:10:34 +00:00
# include "GameSoundManager.h"
2004-07-17 22:15:39 +00:00
# include "CommonMetrics.h"
2005-09-05 02:26:50 +00:00
# include "InputEventPlus.h"
2005-10-04 06:51:06 +00:00
# include "RageSoundManager.h"
2003-01-08 23:43:54 +00:00
2005-03-17 07:23:59 +00:00
# define START_SCREEN(sScreenName) THEME->GetMetric (sScreenName,"StartScreen")
2003-01-08 23:43:54 +00:00
2005-04-05 03:27:42 +00:00
ThemeMetric < bool > BACK_GOES_TO_START_SCREEN ( " ScreenAttract " , " BackGoesToStartScreen " ) ;
2004-11-26 17:28:47 +00:00
REGISTER_SCREEN_CLASS ( ScreenAttract ) ;
2005-02-27 09:59:38 +00:00
ScreenAttract : : ScreenAttract ( CString sName , bool bResetGameState ) : ScreenWithMenuElements ( sName )
2003-01-08 23:43:54 +00:00
{
2005-02-23 06:29:05 +00:00
if ( bResetGameState )
GAMESTATE - > Reset ( ) ;
2003-01-19 04:44:22 +00:00
2005-06-11 11:25:34 +00:00
GAMESTATE - > VisitAttractScreen ( sName ) ;
2005-10-04 07:39:03 +00:00
SOUNDMAN - > SetPlayOnlyCriticalSounds ( ! GAMESTATE - > IsTimeToPlayAttractSounds ( ) ) ; // mute attract sounds
2005-02-23 06:29:05 +00:00
}
2003-12-28 19:46:50 +00:00
2003-01-08 23:43:54 +00:00
2005-09-05 02:26:50 +00:00
void ScreenAttract : : Input ( const InputEventPlus & input )
2003-01-08 23:43:54 +00:00
{
2003-04-22 07:42:50 +00:00
// LOG->Trace( "ScreenAttract::Input()" );
2003-01-08 23:43:54 +00:00
2005-09-05 02:26:50 +00:00
AttractInput ( input , this ) ;
2003-03-09 00:55:49 +00:00
}
2003-01-10 02:22:07 +00:00
2005-09-05 02:26:50 +00:00
void ScreenAttract : : AttractInput ( const InputEventPlus & input , ScreenWithMenuElements * pScreen )
2003-03-09 00:55:49 +00:00
{
2005-09-05 02:26:50 +00:00
if ( input . type ! = IET_FIRST_PRESS )
2003-03-09 00:55:49 +00:00
return ; // don't care
2005-09-05 02:26:50 +00:00
if ( input . MenuI . IsValid ( ) )
2003-01-10 02:22:07 +00:00
{
2005-09-05 02:26:50 +00:00
switch ( input . MenuI . button )
2003-01-10 02:22:07 +00:00
{
case MENU_BUTTON_BACK :
2005-04-05 03:27:42 +00:00
if ( ! ( bool ) BACK_GOES_TO_START_SCREEN )
break ;
// fall through
case MENU_BUTTON_START :
2003-03-09 00:55:49 +00:00
case MENU_BUTTON_COIN :
2005-02-21 17:29:49 +00:00
switch ( GAMESTATE - > GetCoinMode ( ) )
2003-01-19 04:44:22 +00:00
{
2005-05-20 17:45:44 +00:00
case COIN_MODE_PAY :
2005-05-06 20:41:05 +00:00
LOG - > Trace ( " ScreenAttract::AttractInput: COIN_PAY (%i/%i) " , GAMESTATE - > m_iCoins , PREFSMAN - > m_iCoinsPerCredit . Get ( ) ) ;
2003-01-19 04:44:22 +00:00
if ( GAMESTATE - > m_iCoins < PREFSMAN - > m_iCoinsPerCredit )
break ; // don't fall through
// fall through
2005-05-20 17:45:44 +00:00
case COIN_MODE_HOME :
case COIN_MODE_FREE :
2005-04-01 12:35:49 +00:00
if ( pScreen - > IsTransitioning ( ) )
return ;
LOG - > Trace ( " ScreenAttract::AttractInput: begin fading to START_SCREEN " ) ;
2005-01-19 21:45:09 +00:00
/* HandleGlobalInputs() already played the coin sound. Don't play it again. */
2005-09-05 02:26:50 +00:00
if ( input . MenuI . button ! = MENU_BUTTON_COIN )
2004-03-23 23:56:38 +00:00
SCREENMAN - > PlayCoinSound ( ) ;
2005-04-01 12:35:49 +00:00
2005-10-04 06:51:06 +00:00
SOUNDMAN - > SetPlayOnlyCriticalSounds ( false ) ; // unmute attract sounds
2005-10-04 07:40:00 +00:00
pScreen - > Cancel ( SM_GoToStartScreen ) ;
2003-01-19 04:44:22 +00:00
break ;
default :
ASSERT ( 0 ) ;
}
2003-01-10 02:22:07 +00:00
break ;
}
}
2005-04-01 12:35:49 +00:00
if ( pScreen - > IsTransitioning ( ) )
2003-03-09 00:55:49 +00:00
return ;
2005-09-05 02:26:50 +00:00
if ( input . MenuI . IsValid ( ) )
2003-03-09 00:55:49 +00:00
{
2005-09-05 02:26:50 +00:00
switch ( input . MenuI . button )
2003-03-09 00:55:49 +00:00
{
case MENU_BUTTON_LEFT :
case MENU_BUTTON_RIGHT :
2003-03-25 21:17:29 +00:00
SCREENMAN - > PostMessageToTopScreen ( SM_BeginFadingOut , 0 ) ;
2003-03-09 00:55:49 +00:00
break ;
}
2005-02-28 04:44:51 +00:00
}
2003-03-09 00:55:49 +00:00
2005-09-05 02:26:50 +00:00
// Screen::Input( input );
2003-01-08 23:43:54 +00:00
}
2005-03-22 22:53:39 +00:00
void ScreenAttract : : StartPlayingMusic ( )
2003-01-10 02:22:07 +00:00
{
2005-03-22 22:53:39 +00:00
ScreenWithMenuElements : : StartPlayingMusic ( ) ;
}
2003-01-08 23:43:54 +00:00
void ScreenAttract : : HandleScreenMessage ( const ScreenMessage SM )
{
2005-04-01 12:35:49 +00:00
if ( SM = = SM_MenuTimer | |
SM = = SM_BeginFadingOut )
2003-01-08 23:43:54 +00:00
{
2005-02-28 06:08:55 +00:00
if ( ! IsTransitioning ( ) )
2005-10-13 22:17:13 +00:00
StartTransitioningScreen ( SM_GoToNextScreen ) ;
2005-04-01 12:35:49 +00:00
}
else if ( SM = = SM_GoToStartScreen )
{
GoToStartScreen ( m_sName ) ;
}
else if ( SM = = SM_GoToNextScreen )
{
2004-02-14 01:29:09 +00:00
/* Look at the def of the screen we're going to; if it has a music theme element
* and it's the same as the one we're playing now, don't stop. However, if we're
* going to interrupt it when we fade in, stop the old music before we fade out. */
2005-03-21 01:14:30 +00:00
bool bMusicChanging = false ;
if ( PLAY_MUSIC )
2005-07-22 09:12:16 +00:00
bMusicChanging = THEME - > GetPathS ( m_sName , " music " ) ! = THEME - > GetPathS ( GetNextScreen ( ) , " music " , true ) ; // GetPath optional on the next screen because it may not have music.
2005-03-21 01:14:30 +00:00
if ( bMusicChanging )
2005-07-22 23:07:49 +00:00
SOUND - > StopMusic ( ) ;
2003-01-08 23:43:54 +00:00
}
2005-07-22 09:12:16 +00:00
ScreenWithMenuElements : : HandleScreenMessage ( SM ) ;
2003-01-08 23:43:54 +00:00
}
2004-06-09 04:28:27 +00:00
2005-04-01 12:35:49 +00:00
void ScreenAttract : : GoToStartScreen ( CString sScreenName )
{
SCREENMAN - > SetNewScreen ( START_SCREEN ( sScreenName ) ) ;
}
2004-06-09 04:28:27 +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.
*/