2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2003-01-08 23:43:54 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: ScreenAttract
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#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 "AnnouncerManager.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "GameManager.h"
|
|
|
|
|
#include "InputMapper.h"
|
|
|
|
|
#include "ThemeManager.h"
|
2003-02-14 06:43:23 +00:00
|
|
|
#include "SDL_utils.h"
|
2003-07-26 22:53:22 +00:00
|
|
|
#include "RageSounds.h"
|
2003-01-08 23:43:54 +00:00
|
|
|
|
2003-12-28 19:46:50 +00:00
|
|
|
#define NEXT_SCREEN THEME->GetMetric(m_sName,"NextScreen")
|
|
|
|
|
#define INITIAL_SCREEN THEME->GetMetric("Common","InitialScreen")
|
2003-01-08 23:43:54 +00:00
|
|
|
|
|
|
|
|
|
2004-01-07 02:56:47 +00:00
|
|
|
ScreenAttract::ScreenAttract( CString sClassName, bool bResetGameState ) : Screen( sClassName )
|
2003-01-08 23:43:54 +00:00
|
|
|
{
|
2003-03-09 00:55:49 +00:00
|
|
|
LOG->Trace( "ScreenAttract::ScreenAttract(%s)", sClassName.c_str() );
|
2003-01-19 04:44:22 +00:00
|
|
|
|
2003-12-28 19:46:50 +00:00
|
|
|
// increment times through attract count
|
|
|
|
|
if( sClassName == INITIAL_SCREEN )
|
|
|
|
|
GAMESTATE->m_iNumTimesThroughAttract++;
|
|
|
|
|
|
2004-01-07 02:56:47 +00:00
|
|
|
if( bResetGameState )
|
|
|
|
|
GAMESTATE->Reset();
|
2003-01-20 04:33:45 +00:00
|
|
|
|
2003-01-19 04:44:22 +00:00
|
|
|
// We have to do initialization in the first update because this->GetElementName() won't
|
|
|
|
|
// work until the object has been fully constructed.
|
2003-04-12 17:39:27 +00:00
|
|
|
m_Background.LoadFromAniDir( THEME->GetPathToB(m_sName+" background") );
|
2003-01-19 04:44:22 +00:00
|
|
|
this->AddChild( &m_Background );
|
|
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_In.Load( THEME->GetPathToB("ScreenAttract in") );
|
2003-03-09 00:55:49 +00:00
|
|
|
m_In.StartTransitioning();
|
|
|
|
|
this->AddChild( &m_In );
|
2003-01-19 04:44:22 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_Out.Load( THEME->GetPathToB("ScreenAttract out") );
|
2003-03-09 00:55:49 +00:00
|
|
|
this->AddChild( &m_Out );
|
2003-01-19 04:44:22 +00:00
|
|
|
|
2003-07-26 22:53:22 +00:00
|
|
|
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(m_sName) );
|
2003-01-19 04:44:22 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_soundStart.Load( THEME->GetPathToS("Common start") );
|
2003-03-09 00:55:49 +00:00
|
|
|
|
2003-12-28 19:46:50 +00:00
|
|
|
if( GAMESTATE->IsTimeToPlayAttractSounds() )
|
2003-10-12 19:45:28 +00:00
|
|
|
SOUND->PlayMusic( THEME->GetPathToS(m_sName + " music") );
|
2003-10-19 21:38:11 +00:00
|
|
|
else
|
|
|
|
|
SOUND->PlayMusic( "" ); // stop music
|
2003-01-19 04:44:22 +00:00
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
float fTimeUntilBeginFadingOut = m_Background.GetLengthSeconds() - m_Out.GetLengthSeconds();
|
2003-10-10 03:47:45 +00:00
|
|
|
if( fTimeUntilBeginFadingOut < 0 )
|
|
|
|
|
{
|
|
|
|
|
LOG->Warn( "Screen '%s' Out BGAnimation (%f seconds) is longer than Background BGAnimation (%f seconds); background BGA will be truncated",
|
|
|
|
|
m_sName.c_str(), m_Out.GetLengthSeconds(), m_Background.GetLengthSeconds() );
|
|
|
|
|
fTimeUntilBeginFadingOut = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 21:17:29 +00:00
|
|
|
this->PostScreenMessage( SM_BeginFadingOut, fTimeUntilBeginFadingOut );
|
2003-01-08 23:43:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ScreenAttract::~ScreenAttract()
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenAttract::~ScreenAttract()" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ScreenAttract::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
|
|
|
{
|
2003-04-22 07:42:50 +00:00
|
|
|
// LOG->Trace( "ScreenAttract::Input()" );
|
2003-01-08 23:43:54 +00:00
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
AttractInput( DeviceI, type, GameI, MenuI, StyleI, m_In.IsTransitioning() || m_Out.IsTransitioning() );
|
|
|
|
|
}
|
2003-01-10 02:22:07 +00:00
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenAttract::AttractInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI, bool bTransitioning )
|
|
|
|
|
{
|
|
|
|
|
if(type != IET_FIRST_PRESS)
|
|
|
|
|
return; // don't care
|
|
|
|
|
|
|
|
|
|
ChangeCoinModeInput( DeviceI, type, GameI, MenuI, StyleI );
|
2003-01-08 23:43:54 +00:00
|
|
|
|
2003-01-10 02:22:07 +00:00
|
|
|
if( MenuI.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
switch( MenuI.button )
|
|
|
|
|
{
|
2003-01-19 04:44:22 +00:00
|
|
|
case MENU_BUTTON_START:
|
2003-01-10 02:22:07 +00:00
|
|
|
case MENU_BUTTON_BACK:
|
2003-03-09 00:55:49 +00:00
|
|
|
case MENU_BUTTON_COIN:
|
2003-04-13 04:50:08 +00:00
|
|
|
switch( PREFSMAN->m_iCoinMode )
|
2003-01-19 04:44:22 +00:00
|
|
|
{
|
2003-04-13 04:50:08 +00:00
|
|
|
case COIN_PAY:
|
2003-10-18 21:01:04 +00:00
|
|
|
LOG->Trace("ScreenAttract::AttractInput: COIN_PAY (%i/%i)", GAMESTATE->m_iCoins, PREFSMAN->m_iCoinsPerCredit );
|
2003-01-19 04:44:22 +00:00
|
|
|
if( GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit )
|
|
|
|
|
break; // don't fall through
|
|
|
|
|
// fall through
|
2003-04-13 04:50:08 +00:00
|
|
|
case COIN_HOME:
|
|
|
|
|
case COIN_FREE:
|
2003-07-26 22:53:22 +00:00
|
|
|
SOUND->StopMusic();
|
2003-10-13 08:33:39 +00:00
|
|
|
/* We already played the coin sound. Don't play it again. */
|
2003-03-09 03:28:34 +00:00
|
|
|
if( MenuI.button != MENU_BUTTON_COIN )
|
2003-07-26 22:53:22 +00:00
|
|
|
SOUND->PlayOnce( THEME->GetPathToS("Common coin") );
|
2003-02-14 06:43:23 +00:00
|
|
|
SDL_Delay( 800 ); // do a little pause, like the arcade does
|
2003-10-18 21:01:04 +00:00
|
|
|
LOG->Trace("ScreenAttract::AttractInput: go to ScreenTitleMenu" );
|
2003-01-19 04:44:22 +00:00
|
|
|
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
|
|
|
|
}
|
2003-01-10 02:22:07 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
if( bTransitioning )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if( MenuI.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
switch( MenuI.button )
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-10 02:22:07 +00:00
|
|
|
// Screen::Input( DeviceI, type, GameI, MenuI, StyleI );
|
2003-01-08 23:43:54 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-10 02:22:07 +00:00
|
|
|
void ScreenAttract::Update( float fDelta )
|
|
|
|
|
{
|
2003-01-08 23:43:54 +00:00
|
|
|
Screen::Update(fDelta);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenAttract::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
|
|
|
|
case SM_BeginFadingOut:
|
2003-03-09 00:55:49 +00:00
|
|
|
if( !m_Out.IsTransitioning() )
|
|
|
|
|
m_Out.StartTransitioning( SM_GoToNextScreen );
|
2003-01-08 23:43:54 +00:00
|
|
|
break;
|
|
|
|
|
case SM_GoToNextScreen:
|
2003-01-19 10:14:46 +00:00
|
|
|
/* XXX: 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, it's cleaner to stop it before we fade out.) */
|
2003-02-18 09:36:59 +00:00
|
|
|
|
2003-01-26 20:49:05 +00:00
|
|
|
/* Don't stop the music, or else the music will start over from the
|
|
|
|
|
* beginning for consecutive screens with the same music. -Chris */
|
2003-02-18 09:36:59 +00:00
|
|
|
|
|
|
|
|
/* But if you don't stop it, for screens that have their own unique
|
|
|
|
|
* music, it will constantly loop even after the screen has gone on
|
|
|
|
|
* to the next attract screen. -- Miryokuteki */
|
2003-07-26 22:53:22 +00:00
|
|
|
SOUND->PlayMusic( "" );
|
2003-01-08 23:43:54 +00:00
|
|
|
SCREENMAN->SetNewScreen( NEXT_SCREEN );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|