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"
|
2002-11-11 04:53:31 +00:00
|
|
|
#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"
|
2003-09-29 09:08:02 +00:00
|
|
|
#include "PrefsManager.h"
|
2004-02-23 07:44:57 +00:00
|
|
|
#include "CodeDetector.h"
|
2004-09-21 06:07:12 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2004-12-20 06:25:59 +00:00
|
|
|
#include "PlayerState.h"
|
2005-03-13 01:43:44 +00:00
|
|
|
#include "Foreach.h"
|
2005-09-05 02:26:50 +00:00
|
|
|
#include "InputEventPlus.h"
|
2003-09-29 09:08:02 +00:00
|
|
|
|
2006-01-15 20:46:15 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenPlayerOptions );
|
2005-02-23 06:29:05 +00:00
|
|
|
|
|
|
|
|
void ScreenPlayerOptions::Init()
|
|
|
|
|
{
|
|
|
|
|
ScreenOptionsMaster::Init();
|
2003-09-30 05:25:22 +00:00
|
|
|
|
2006-01-16 05:09:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
|
|
|
|
{
|
|
|
|
|
m_sprDisqualify[p].Load( THEME->GetPathG(m_sName,"disqualify") );
|
|
|
|
|
m_sprDisqualify[p]->SetName( ssprintf("DisqualifyP%i",p+1) );
|
2007-02-19 09:30:07 +00:00
|
|
|
LOAD_ALL_COMMANDS_AND_SET_XY( m_sprDisqualify[p] );
|
2007-02-13 06:32:26 +00:00
|
|
|
m_sprDisqualify[p]->SetVisible( false ); // unhide later if handicapping options are discovered
|
2006-01-16 05:09:11 +00:00
|
|
|
m_sprDisqualify[p]->SetDrawOrder( 2 );
|
2008-05-10 21:53:43 +00:00
|
|
|
m_frameContainer.AddChild( m_sprDisqualify[p] );
|
2006-01-16 05:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
2003-09-30 05:25:22 +00:00
|
|
|
m_bAskOptionsMessage =
|
2006-10-07 05:52:45 +00:00
|
|
|
!GAMESTATE->IsEditing() && PREFSMAN->m_ShowSongOptions == Maybe_ASK;
|
2003-09-30 05:25:22 +00:00
|
|
|
|
2003-06-16 03:44:15 +00:00
|
|
|
m_bAcceptedChoices = false;
|
2006-10-07 05:52:45 +00:00
|
|
|
m_bGoToOptions = ( PREFSMAN->m_ShowSongOptions == Maybe_YES );
|
2003-06-16 03:44:15 +00:00
|
|
|
|
2003-07-26 23:05:16 +00:00
|
|
|
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("player options intro") );
|
2004-03-08 07:49:01 +00:00
|
|
|
|
2005-07-23 06:13:33 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
|
|
|
|
m_bRowCausesDisqualified[p].resize( m_pRows.size(), false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ScreenPlayerOptions::BeginScreen()
|
|
|
|
|
{
|
2006-01-16 05:09:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
|
|
|
|
ON_COMMAND( m_sprDisqualify[p] );
|
|
|
|
|
|
2005-07-23 06:13:33 +00:00
|
|
|
ScreenOptionsMaster::BeginScreen();
|
|
|
|
|
|
2005-03-16 02:16:55 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
2005-03-13 01:43:44 +00:00
|
|
|
{
|
2005-06-23 08:05:09 +00:00
|
|
|
for( unsigned r=0; r<m_pRows.size(); r++ )
|
2005-03-13 01:43:44 +00:00
|
|
|
UpdateDisqualified( r, p );
|
|
|
|
|
}
|
2003-03-11 08:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
void ScreenPlayerOptions::Input( const InputEventPlus &input )
|
2003-03-11 08:52:45 +00:00
|
|
|
{
|
2003-09-30 05:25:22 +00:00
|
|
|
if( m_bAskOptionsMessage &&
|
2005-09-05 02:26:50 +00:00
|
|
|
input.type == IET_FIRST_PRESS &&
|
2004-05-01 23:19:33 +00:00
|
|
|
!m_In.IsTransitioning() &&
|
2008-05-21 05:36:09 +00:00
|
|
|
input.MenuI == GAME_BUTTON_START )
|
2003-06-16 03:44:15 +00:00
|
|
|
{
|
|
|
|
|
if( m_bAcceptedChoices && !m_bGoToOptions )
|
|
|
|
|
{
|
|
|
|
|
m_bGoToOptions = true;
|
2007-02-26 02:52:42 +00:00
|
|
|
this->PlayCommand( "GoToOptions" );
|
2004-03-23 23:56:38 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
2003-06-16 03:44:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-09-05 07:34:13 +00:00
|
|
|
|
2006-09-13 10:02:58 +00:00
|
|
|
PlayerNumber pn = input.pn;
|
2005-09-05 02:26:50 +00:00
|
|
|
if( GAMESTATE->IsHumanPlayer(pn) && CodeDetector::EnteredCode(input.GameI.controller,CODE_CANCEL_ALL_PLAYER_OPTIONS) )
|
2004-02-23 07:44:57 +00:00
|
|
|
{
|
2004-03-13 17:38:26 +00:00
|
|
|
// apply the game default mods, but not the Profile saved mods
|
2007-04-06 15:44:39 +00:00
|
|
|
GAMESTATE->m_pPlayerState[pn]->ResetToDefaultPlayerOptions( ModsLevel_Preferred );
|
2004-03-13 17:38:26 +00:00
|
|
|
|
2005-06-25 08:03:08 +00:00
|
|
|
MESSAGEMAN->Broadcast( ssprintf("CancelAllP%i", pn+1) );
|
2004-03-13 18:15:50 +00:00
|
|
|
|
2005-06-23 08:05:09 +00:00
|
|
|
for( unsigned r=0; r<m_pRows.size(); r++ )
|
2005-03-13 02:15:38 +00:00
|
|
|
{
|
2005-04-03 06:21:02 +00:00
|
|
|
vector<PlayerNumber> v;
|
|
|
|
|
v.push_back( pn );
|
2006-01-19 01:54:25 +00:00
|
|
|
int iOldFocus = m_pRows[r]->GetChoiceInRowWithFocus( pn );
|
2005-04-03 06:21:02 +00:00
|
|
|
this->ImportOptions( r, v );
|
2006-01-19 01:54:25 +00:00
|
|
|
m_pRows[r]->AfterImportOptions( pn );
|
2005-03-13 01:43:44 +00:00
|
|
|
this->UpdateDisqualified( r, pn );
|
2006-01-19 01:54:25 +00:00
|
|
|
m_pRows[r]->SetChoiceInRowWithFocus( pn, iOldFocus );
|
2005-03-13 02:15:38 +00:00
|
|
|
}
|
2004-02-23 07:44:57 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
ScreenOptionsMaster::Input( input );
|
2004-03-08 07:49:01 +00:00
|
|
|
|
|
|
|
|
// UGLY: Update m_Disqualified whenever Start is pressed
|
2008-05-21 05:36:09 +00:00
|
|
|
if( GAMESTATE->IsHumanPlayer(pn) && input.MenuI == GAME_BUTTON_START )
|
2005-03-13 01:43:44 +00:00
|
|
|
{
|
|
|
|
|
int row = m_iCurrentRow[pn];
|
|
|
|
|
UpdateDisqualified( row, pn );
|
|
|
|
|
}
|
2003-03-11 08:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenPlayerOptions::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
2006-02-25 00:17:48 +00:00
|
|
|
if( SM == SM_BeginFadingOut && m_bAskOptionsMessage ) // user accepts the page of options
|
2003-09-05 07:34:13 +00:00
|
|
|
{
|
2006-02-25 00:17:48 +00:00
|
|
|
m_bAcceptedChoices = true;
|
|
|
|
|
|
|
|
|
|
// show "hold START for options"
|
2007-02-26 02:52:42 +00:00
|
|
|
this->PlayCommand( "AskForGoToOptions" );
|
2003-09-05 07:34:13 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-12 06:33:00 +00:00
|
|
|
ScreenOptionsMaster::HandleScreenMessage( SM );
|
2005-06-25 08:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-13 01:43:44 +00:00
|
|
|
void ScreenPlayerOptions::UpdateDisqualified( int row, PlayerNumber pn )
|
2004-03-08 07:49:01 +00:00
|
|
|
{
|
2005-03-16 02:16:55 +00:00
|
|
|
ASSERT( GAMESTATE->IsHumanPlayer(pn) );
|
|
|
|
|
|
2005-03-13 01:43:44 +00:00
|
|
|
// save original player options
|
2006-08-05 02:38:05 +00:00
|
|
|
PlayerOptions poOrig = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetPreferred();
|
2005-03-13 01:43:44 +00:00
|
|
|
|
2007-04-25 20:00:18 +00:00
|
|
|
// Find out if the current row when exported causes disqualification.
|
2005-03-13 01:43:44 +00:00
|
|
|
// Exporting the row will fill GAMESTATE->m_PlayerOptions.
|
2006-08-05 08:02:49 +00:00
|
|
|
PO_GROUP_CALL( GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions, ModsLevel_Preferred, Init );
|
2005-04-03 06:21:02 +00:00
|
|
|
vector<PlayerNumber> v;
|
|
|
|
|
v.push_back( pn );
|
|
|
|
|
ExportOptions( row, v );
|
2007-04-25 20:00:18 +00:00
|
|
|
bool bRowCausesDisqualified = GAMESTATE->CurrentOptionsDisqualifyPlayer( pn );
|
2005-03-13 01:43:44 +00:00
|
|
|
m_bRowCausesDisqualified[pn][row] = bRowCausesDisqualified;
|
|
|
|
|
|
|
|
|
|
// Update disqualified graphic
|
|
|
|
|
bool bDisqualified = false;
|
|
|
|
|
FOREACH_CONST( bool, m_bRowCausesDisqualified[pn], b )
|
2004-03-08 07:49:01 +00:00
|
|
|
{
|
2005-03-13 01:43:44 +00:00
|
|
|
if( *b )
|
|
|
|
|
{
|
|
|
|
|
bDisqualified = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-03-08 07:49:01 +00:00
|
|
|
}
|
2007-02-13 06:32:26 +00:00
|
|
|
m_sprDisqualify[pn]->SetVisible( bDisqualified );
|
2005-03-13 01:43:44 +00:00
|
|
|
|
|
|
|
|
// restore previous player options in case the user escapes back after this
|
2006-08-05 04:47:01 +00:00
|
|
|
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.Assign( ModsLevel_Preferred, poOrig );
|
2004-03-08 07:49:01 +00:00
|
|
|
}
|
2004-06-08 05:22:33 +00:00
|
|
|
|
2005-06-25 05:03:35 +00:00
|
|
|
// lua start
|
|
|
|
|
#include "LuaBinding.h"
|
|
|
|
|
|
|
|
|
|
class LunaScreenPlayerOptions: public Luna<ScreenPlayerOptions>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static int GetGoToOptions( T* p, lua_State *L ) { lua_pushboolean( L, p->GetGoToOptions() ); return 1; }
|
2006-09-27 19:47:52 +00:00
|
|
|
|
|
|
|
|
LunaScreenPlayerOptions()
|
2005-06-25 05:03:35 +00:00
|
|
|
{
|
2006-09-27 19:47:52 +00:00
|
|
|
ADD_METHOD( GetGoToOptions );
|
2005-06-25 05:03:35 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2005-07-12 05:48:15 +00:00
|
|
|
LUA_REGISTER_DERIVED_CLASS( ScreenPlayerOptions, ScreenWithMenuElements )
|
2005-06-25 05:03:35 +00:00
|
|
|
// lua end
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|