Files
itgmania212121/stepmania/src/ScreenContinue.cpp
T

144 lines
4.0 KiB
C++
Raw Normal View History

#include "global.h"
#include "ScreenContinue.h"
2007-04-28 23:21:32 +00:00
#include "ScreenManager.h"
#include "ActorUtil.h"
#include "GameState.h"
#include "RageLog.h"
#include "InputEventPlus.h"
#include "MenuTimer.h"
2007-05-30 02:13:32 +00:00
#include "MemoryCardManager.h"
REGISTER_SCREEN_CLASS( ScreenContinue );
void ScreenContinue::Init()
{
ScreenWithMenuElementsSimple::Init();
this->SubscribeToMessage( Message_PlayerJoined );
FORCE_TIMER_WAIT.Load( m_sName, "ForceTimerWait" );
}
void ScreenContinue::BeginScreen()
{
GAMESTATE->SetCurrentStyle( NULL );
// Unjoin human players with 0 stages left and reset non-human players.
// We need to reset non-human players because data in non-human (CPU)
// players will be filled, and there may be stale pointers to things like
// edit Steps.
FOREACH_ENUM( PlayerNumber, p )
{
if( GAMESTATE->IsHumanPlayer(p) )
2007-05-30 02:13:32 +00:00
{
bool bPlayerDone = GAMESTATE->m_iPlayerStageTokens[p] <= 0;
if( bPlayerDone )
{
GAMESTATE->UnjoinPlayer( p );
MEMCARDMAN->UnlockCard( p );
}
}
else
{
GAMESTATE->ResetPlayer( p );
2007-05-30 02:13:32 +00:00
}
}
ScreenWithMenuElementsSimple::BeginScreen();
}
void ScreenContinue::Input( const InputEventPlus &input )
{
2007-05-10 17:59:13 +00:00
if( input.MenuI == GAME_BUTTON_COIN && input.type == IET_FIRST_PRESS )
2007-04-18 00:26:33 +00:00
ResetTimer();
2008-05-21 05:36:09 +00:00
if( input.MenuI == GAME_BUTTON_START && input.type == IET_FIRST_PRESS && GAMESTATE->JoinInput(input.pn) )
return; // handled
if( IsTransitioning() )
return;
if( input.type == IET_FIRST_PRESS && GAMESTATE->IsHumanPlayer(input.pn) && FORCE_TIMER_WAIT )
{
switch( input.MenuI )
{
case GAME_BUTTON_START:
2008-05-21 05:36:09 +00:00
case GAME_BUTTON_UP:
case GAME_BUTTON_DOWN:
case GAME_BUTTON_LEFT:
case GAME_BUTTON_RIGHT:
2007-04-25 22:57:55 +00:00
float fSeconds = floorf(m_MenuTimer->GetSeconds()) - 0.0001f;
fSeconds = max( fSeconds, 0.0001f ); // don't set to 0
m_MenuTimer->SetSeconds( fSeconds );
2007-05-31 05:26:08 +00:00
Message msg("HurryTimer");
msg.SetParam( "PlayerNumber", input.pn );
2007-05-31 05:26:35 +00:00
this->HandleMessage( msg );
return; // handled
}
}
ScreenWithMenuElementsSimple::Input( input );
}
void ScreenContinue::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_MenuTimer )
{
if( !IsTransitioning() )
StartTransitioningScreen( SM_GoToNextScreen );
return;
}
ScreenWithMenuElementsSimple::HandleScreenMessage( SM );
}
void ScreenContinue::HandleMessage( const Message &msg )
{
if( msg == Message_PlayerJoined )
{
ResetTimer();
bool bAllPlayersAreEnabled = true;
FOREACH_ENUM( PlayerNumber, p )
{
if( !GAMESTATE->IsPlayerEnabled(p) )
bAllPlayersAreEnabled = false;
}
if( bAllPlayersAreEnabled )
{
m_MenuTimer->Stop();
if( !IsTransitioning() )
StartTransitioningScreen( SM_GoToNextScreen );
}
}
ScreenWithMenuElementsSimple::HandleMessage( msg );
}
/*
* (c) 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.
*/