Files
itgmania212121/stepmania/src/ScreenAttract.cpp
T

152 lines
4.1 KiB
C++
Raw Normal View History

#include "stdafx.h"
/*
-----------------------------------------------------------------------------
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"
#include "SDL_Utils.h"
#include "RageSoundManager.h"
2003-01-19 04:44:22 +00:00
#define SECONDS_TO_SHOW THEME->GetMetricF("Screen"+m_sMetricName,"SecondsToShow")
#define NEXT_SCREEN THEME->GetMetric("Screen"+m_sMetricName,"NextScreen")
const ScreenMessage SM_BeginFadingOut = ScreenMessage(SM_User+2);
const ScreenMessage SM_GoToNextScreen = ScreenMessage(SM_User+3);
2003-01-19 04:44:22 +00:00
ScreenAttract::ScreenAttract( CString sMetricName, CString sElementName )
{
2003-01-19 04:44:22 +00:00
LOG->Trace( "ScreenAttract::ScreenAttract(%s, %s)", sMetricName.c_str(), sElementName.c_str() );
m_sMetricName = sMetricName;
m_sElementName = sElementName;
// We have to do initialization in the first update because this->GetElementName() won't
// work until the object has been fully constructed.
m_Background.LoadFromAniDir( THEME->GetPathTo("BGAnimations",m_sElementName) );
this->AddChild( &m_Background );
m_Fade.SetClosed();
m_Fade.OpenWipingRight( SM_None );
this->AddChild( &m_Fade );
SOUNDMAN->PlayOnceFromDir( ANNOUNCER->GetPathTo(m_sElementName) );
m_soundStart.Load( THEME->GetPathTo("Sounds","menu start") );
m_soundMusic.Load( THEME->GetPathTo("Sounds",m_sElementName + " music") );
m_soundMusic.Play();
GAMESTATE->m_bPlayersCanJoin = true;
this->SendScreenMessage( SM_BeginFadingOut, SECONDS_TO_SHOW );
}
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-01-19 04:44:22 +00:00
LOG->Trace( "ScreenAttract::Input()" );
if(type != IET_FIRST_PRESS) return; // don't care
2003-01-19 04:44:22 +00:00
if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == SDLK_F3 )
{
(int&)PREFSMAN->m_CoinMode = (PREFSMAN->m_CoinMode+1) % PrefsManager::NUM_COIN_MODES;
ResetGame();
CString sMessage = "Coin Mode: ";
switch( PREFSMAN->m_CoinMode )
{
case PrefsManager::COIN_HOME: sMessage += "HOME"; break;
case PrefsManager::COIN_PAY: sMessage += "PAY"; break;
case PrefsManager::COIN_FREE: sMessage += "FREE"; break;
}
SCREENMAN->SystemMessage( sMessage );
return;
2003-01-19 04:44:22 +00:00
}
if( MenuI.IsValid() )
{
switch( MenuI.button )
{
case MENU_BUTTON_LEFT:
case MENU_BUTTON_RIGHT:
2003-01-19 04:44:22 +00:00
if( !m_Fade.IsOpening() && !m_Fade.IsClosing() )
m_Fade.CloseWipingRight( SM_GoToNextScreen );
break;
2003-01-19 04:44:22 +00:00
case MENU_BUTTON_COIN:
Screen::MenuCoin( MenuI.player ); // increment coins, play sound
m_soundMusic.Stop();
2003-01-19 04:44:22 +00:00
::Sleep( 200 ); // do a little pause, like the arcade does
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
break;
2003-01-19 04:44:22 +00:00
case MENU_BUTTON_START:
case MENU_BUTTON_BACK:
2003-01-19 04:44:22 +00:00
switch( PREFSMAN->m_CoinMode )
{
case PrefsManager::COIN_PAY:
if( GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit )
break; // don't fall through
// fall through
case PrefsManager::COIN_FREE:
case PrefsManager::COIN_HOME:
m_soundMusic.Stop();
SOUNDMAN->PlayOnce( THEME->GetPathTo("Sounds","insert coin") );
::Sleep( 200 ); // do a little pause, like the arcade does
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
break;
default:
ASSERT(0);
}
break;
}
}
// Screen::Input( DeviceI, type, GameI, MenuI, StyleI );
}
void ScreenAttract::Update( float fDelta )
{
Screen::Update(fDelta);
}
void ScreenAttract::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
case SM_BeginFadingOut:
if( !m_Fade.IsClosing() )
m_Fade.CloseWipingRight( SM_GoToNextScreen );
break;
case SM_GoToNextScreen:
SCREENMAN->SetNewScreen( NEXT_SCREEN );
break;
}
}