Files
itgmania212121/stepmania/src/ScreenAttract.cpp
T

172 lines
5.2 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2004-06-09 02:48:38 +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"
#include "CommonMetrics.h"
2005-01-15 21:00:50 +00:00
#include "BGAnimation.h"
2004-03-23 21:02:58 +00:00
#define NEXT_SCREEN THEME->GetMetric (m_sName,"NextScreen")
2005-01-30 00:01:35 +00:00
#define START_SCREEN THEME->GetMetric ("ScreenAttract","StartScreen")
2004-11-26 17:28:47 +00:00
REGISTER_SCREEN_CLASS( ScreenAttract );
ScreenAttract::ScreenAttract( CString sName, bool bResetGameState ) : ScreenWithMenuElements( sName )
{
if( bResetGameState )
GAMESTATE->Reset();
2003-01-19 04:44:22 +00:00
2003-12-28 19:46:50 +00:00
// increment times through attract count
2005-02-12 21:03:39 +00:00
if( m_sName == INITIAL_SCREEN.GetValue() )
2003-12-28 19:46:50 +00:00
GAMESTATE->m_iNumTimesThroughAttract++;
}
2003-12-28 19:46:50 +00:00
void ScreenAttract::Init()
{
LOG->Trace( "ScreenAttract::ScreenAttract(%s)", m_sName.c_str() );
ScreenWithMenuElements::Init();
}
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-03-09 00:55:49 +00:00
AttractInput( DeviceI, type, GameI, MenuI, StyleI, m_In.IsTransitioning() || m_Out.IsTransitioning() );
}
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 );
if( MenuI.IsValid() )
{
switch( MenuI.button )
{
2003-01-19 04:44:22 +00:00
case MENU_BUTTON_START:
case MENU_BUTTON_BACK:
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
{
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
case COIN_HOME:
case COIN_FREE:
2003-07-26 22:53:22 +00:00
SOUND->StopMusic();
2005-01-19 21:45:09 +00:00
/* HandleGlobalInputs() already played the coin sound. Don't play it again. */
2003-03-09 03:28:34 +00:00
if( MenuI.button != MENU_BUTTON_COIN )
SCREENMAN->PlayCoinSound();
2004-06-09 02:48:38 +00:00
SCREENMAN->SendMessageToTopScreen( SM_StopMusic );
usleep( (int)(JOIN_PAUSE_SECONDS*1000*1000) ); // do a little pause, like the arcade does
2005-01-30 00:01:35 +00:00
LOG->Trace("ScreenAttract::AttractInput: go to START_SCREEN" );
SCREENMAN->SetNewScreen( START_SCREEN );
2003-01-19 04:44:22 +00:00
break;
default:
ASSERT(0);
}
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-03-09 00:55:49 +00:00
// Screen::Input( DeviceI, type, GameI, MenuI, StyleI );
}
void ScreenAttract::Update( float fDelta )
{
if( IsFirstUpdate() )
{
if( GAMESTATE->IsTimeToPlayAttractSounds() )
2005-02-06 03:32:53 +00:00
SOUND->PlayMusic( THEME->GetPathS(m_sName,"music") );
else
SOUND->PlayMusic( "" ); // stop music
}
ScreenWithMenuElements::Update(fDelta);
}
void ScreenAttract::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
case SM_MenuTimer:
case SM_BeginFadingOut:
2003-03-09 00:55:49 +00:00
if( !m_Out.IsTransitioning() )
m_Out.StartTransitioning( SM_GoToNextScreen );
break;
case 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. */
bool bGoingToPlayTheSameMusic =
THEME->GetPathS( NEXT_SCREEN, "music", false) == THEME->GetPathS( m_sName, "music", false);
if( bGoingToPlayTheSameMusic )
; // do nothing
else
SOUND->PlayMusic( "" ); // stop the music
SCREENMAN->SetNewScreen( NEXT_SCREEN );
break;
}
}
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.
*/