Files
itgmania212121/stepmania/src/ScreenPlayerOptions.cpp
T

231 lines
7.1 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-05-20 08:59:37 +00:00
#include "ScreenPlayerOptions.h"
#include "ScreenManager.h"
#include "RageLog.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
#include "ThemeManager.h"
#include "AnnouncerManager.h"
2004-07-08 00:10:34 +00:00
#include "GameSoundManager.h"
2003-04-21 22:36:45 +00:00
#include "ScreenSongOptions.h"
#include "PrefsManager.h"
#include "CodeDetector.h"
#include "ScreenDimensions.h"
#include "Style.h"
#include "PlayerState.h"
2002-05-20 08:59:37 +00:00
#define PREV_SCREEN THEME->GetMetric ("ScreenPlayerOptions","PrevScreen")
#define NEXT_SCREEN THEME->GetMetric ("ScreenPlayerOptions","NextScreen")
2002-05-20 08:59:37 +00:00
2004-11-26 17:28:47 +00:00
REGISTER_SCREEN_CLASS( ScreenPlayerOptions );
2003-09-27 22:30:51 +00:00
ScreenPlayerOptions::ScreenPlayerOptions( CString sClassName ) :
ScreenOptionsMaster( sClassName )
2002-05-20 08:59:37 +00:00
{
LOG->Trace( "ScreenPlayerOptions::ScreenPlayerOptions()" );
}
void ScreenPlayerOptions::Init()
{
ScreenOptionsMaster::Init();
2003-09-30 05:25:22 +00:00
m_bAskOptionsMessage =
!GAMESTATE->m_bEditing && PREFSMAN->m_ShowSongOptions == PrefsManager::ASK;
/* If we're going to "press start for more options" or skipping options
* entirely, we need a different fade out. XXX: this is a hack */
2003-09-30 05:25:22 +00:00
if( PREFSMAN->m_ShowSongOptions == PrefsManager::NO || GAMESTATE->m_bEditing )
2005-02-06 03:32:53 +00:00
{
m_Out.Load( THEME->GetPathB("ScreenPlayerOptions","direct out") ); /* direct to stage */
}
2003-09-30 05:25:22 +00:00
else if( m_bAskOptionsMessage )
{
2005-02-06 03:32:53 +00:00
m_Out.Load( THEME->GetPathB("ScreenPlayerOptions","option out") ); /* optional song options */
2003-09-05 07:34:13 +00:00
2005-02-06 03:32:53 +00:00
m_sprOptionsMessage.Load( THEME->GetPathG("ScreenPlayerOptions","options") );
2003-09-30 05:25:22 +00:00
m_sprOptionsMessage.StopAnimating();
2004-11-05 06:35:10 +00:00
m_sprOptionsMessage.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y );
2003-09-30 05:25:22 +00:00
m_sprOptionsMessage.SetZoom( 1 );
m_sprOptionsMessage.SetDiffuse( RageColor(1,1,1,0) );
//this->AddChild( &m_sprOptionsMessage ); // we have to draw this manually over the top of transitions
}
m_bAcceptedChoices = false;
2003-09-05 07:34:13 +00:00
m_bGoToOptions = ( PREFSMAN->m_ShowSongOptions == PrefsManager::YES );
2005-02-07 23:31:55 +00:00
CString sPath = THEME->GetPathS( m_sName,"cancel all", true );
if( sPath != "" )
m_CancelAll.Load( sPath, true );
2003-07-26 23:05:16 +00:00
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("player options intro") );
FOREACH_HumanPlayer( p )
{
m_sprCancelAll[p].LoadAndSetName( "ScreenPlayerOptions", ssprintf("CancelAllP%d",p+1) );
SET_XY_AND_ON_COMMAND( m_sprCancelAll[p] );
this->AddChild( m_sprCancelAll[p] );
}
FOREACH_HumanPlayer( p )
UpdateDisqualified( p );
2002-05-20 08:59:37 +00:00
}
2004-12-05 11:59:39 +00:00
void ScreenPlayerOptions::GoToPrevScreen()
2002-05-20 08:59:37 +00:00
{
2003-02-19 05:46:09 +00:00
if( GAMESTATE->m_bEditing )
{
2003-02-19 05:46:09 +00:00
SCREENMAN->PopTopScreen();
}
else
{
SCREENMAN->DeletePreparedScreens();
SCREENMAN->SetNewScreen( PREV_SCREEN );
}
2002-05-20 08:59:37 +00:00
}
2004-12-05 11:59:39 +00:00
void ScreenPlayerOptions::GoToNextScreen()
2002-05-20 08:59:37 +00:00
{
2003-02-19 05:46:09 +00:00
if( GAMESTATE->m_bEditing )
SCREENMAN->PopTopScreen();
else
2003-08-11 06:09:57 +00:00
{
GAMESTATE->AdjustFailType();
2003-09-05 07:34:13 +00:00
if( m_bGoToOptions )
SCREENMAN->SetNewScreen( NEXT_SCREEN );
2003-09-05 07:34:13 +00:00
else
SCREENMAN->SetNewScreen( ScreenSongOptions::GetNextScreen() );
2003-08-11 06:09:57 +00:00
}
2002-05-20 08:59:37 +00:00
}
2003-03-11 08:52:45 +00:00
void ScreenPlayerOptions::Update( float fDelta )
{
ScreenOptionsMaster::Update( fDelta );
2003-09-30 05:25:22 +00:00
if( m_bAskOptionsMessage )
m_sprOptionsMessage.Update( fDelta );
2003-03-11 08:52:45 +00:00
}
2002-05-20 08:59:37 +00:00
2003-03-11 08:52:45 +00:00
void ScreenPlayerOptions::DrawPrimitives()
{
ScreenOptionsMaster::DrawPrimitives();
2003-09-30 05:25:22 +00:00
if( m_bAskOptionsMessage )
m_sprOptionsMessage.Draw();
2003-03-11 08:52:45 +00:00
}
void ScreenPlayerOptions::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
2003-09-30 05:25:22 +00:00
if( m_bAskOptionsMessage &&
type == IET_FIRST_PRESS &&
!m_In.IsTransitioning() &&
MenuI.IsValid() &&
2003-09-30 05:25:22 +00:00
MenuI.button == MENU_BUTTON_START )
{
if( m_bAcceptedChoices && !m_bGoToOptions )
{
m_bGoToOptions = true;
m_sprOptionsMessage.SetState( 1 );
SCREENMAN->PlayStartSound();
}
}
2003-09-05 07:34:13 +00:00
PlayerNumber pn = GAMESTATE->GetCurrentStyle()->ControllerToPlayerNumber( GameI.controller );
if( GAMESTATE->IsHumanPlayer(pn) && CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_CANCEL_ALL_PLAYER_OPTIONS) )
{
2005-02-07 23:31:55 +00:00
if( m_CancelAll.IsLoaded() )
m_CancelAll.Play();
2004-03-13 17:38:26 +00:00
// apply the game default mods, but not the Profile saved mods
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.Init();
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.FromString( PREFSMAN->m_sDefaultModifiers );
2004-03-13 17:38:26 +00:00
2005-01-17 22:42:57 +00:00
COMMAND( m_sprCancelAll[pn], "Show" );
for( unsigned r=0; r<m_Rows.size(); r++ )
this->ImportOptions( r, pn );
this->PositionUnderlines();
this->UpdateDisqualified( pn );
}
ScreenOptionsMaster::Input( DeviceI, type, GameI, MenuI, StyleI );
// UGLY: Update m_Disqualified whenever Start is pressed
if( MenuI.IsValid() && MenuI.button == MENU_BUTTON_START )
UpdateDisqualified( pn );
2003-03-11 08:52:45 +00:00
}
void ScreenPlayerOptions::HandleScreenMessage( const ScreenMessage SM )
{
2003-09-30 05:25:22 +00:00
if( m_bAskOptionsMessage )
2003-09-05 07:34:13 +00:00
{
switch( SM )
{
case SM_BeginFadingOut: // when the user accepts the page of options
{
m_bAcceptedChoices = true;
float fShowSeconds = m_Out.GetLengthSeconds();
2003-09-05 07:34:13 +00:00
// show "hold START for options"
m_sprOptionsMessage.SetDiffuse( RageColor(1,1,1,0) );
m_sprOptionsMessage.BeginTweening( 0.15f ); // fade in
m_sprOptionsMessage.SetZoomY( 1 );
m_sprOptionsMessage.SetDiffuse( RageColor(1,1,1,1) );
m_sprOptionsMessage.BeginTweening( fShowSeconds-0.3f ); // sleep
m_sprOptionsMessage.BeginTweening( 0.15f ); // fade out
m_sprOptionsMessage.SetDiffuse( RageColor(1,1,1,0) );
m_sprOptionsMessage.SetZoomY( 0 );
}
break;
}
}
ScreenOptionsMaster::HandleScreenMessage( SM );
2003-09-19 01:11:32 +00:00
}
void ScreenPlayerOptions::UpdateDisqualified( PlayerNumber pn )
{
// save current player options
PlayerOptions po = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions;
// export the currently selection options, which will fill GAMESTATE->m_PlayerOptions
for( unsigned r=0; r<OptionRowHandlers.size(); r++ )
ScreenOptionsMaster::ExportOptions( r, pn );
2004-06-03 08:22:02 +00:00
FOREACH_HumanPlayer( p )
{
2004-06-03 08:22:02 +00:00
bool bIsHandicap = GAMESTATE->IsDisqualified(p);
m_sprDisqualify[p]->SetHidden( !bIsHandicap );
2004-06-03 08:22:02 +00:00
// restore previous player options in case the user escapes back after this
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions = po;
}
}
2004-06-08 05:22:33 +00:00
/*
* (c) 2001-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.
*/