2003-03-03 10:03:02 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "ScreenSelect.h"
|
|
|
|
|
#include "ScreenManager.h"
|
2004-07-08 00:10:34 +00:00
|
|
|
#include "GameSoundManager.h"
|
2003-03-03 10:03:02 +00:00
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "AnnouncerManager.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "ThemeManager.h"
|
2004-12-02 06:29:20 +00:00
|
|
|
#include "GameCommand.h"
|
2004-03-30 07:44:29 +00:00
|
|
|
#include "LightsManager.h"
|
2005-01-26 11:21:43 +00:00
|
|
|
#include "Command.h"
|
2003-03-03 10:03:02 +00:00
|
|
|
|
2004-02-13 05:10:18 +00:00
|
|
|
#define CHOICE_NAMES THEME->GetMetric (m_sName,"ChoiceNames")
|
2005-01-26 11:21:43 +00:00
|
|
|
#define CHOICE( sChoiceName ) THEME->GetMetricM(m_sName,ssprintf("Choice%s",sChoiceName.c_str()))
|
2005-01-05 04:34:35 +00:00
|
|
|
#define CODE_NAMES THEME->GetMetric (m_sName,"CodeNames")
|
2005-03-21 10:11:48 +00:00
|
|
|
#define CODE( s ) THEME->GetMetric (m_sName,ssprintf("Code%s",s.c_str()))
|
|
|
|
|
#define CODE_ACTION( s ) THEME->GetMetricM(m_sName,ssprintf("Code%sAction",s.c_str()))
|
2004-02-13 05:10:18 +00:00
|
|
|
#define NEXT_SCREEN( c ) THEME->GetMetric (m_sName,ssprintf("NextScreen%d",c+1))
|
2005-01-04 11:06:12 +00:00
|
|
|
#define IDLE_TIMEOUT_SCREEN THEME->GetMetric (m_sName,"IdleTimeoutScreen")
|
|
|
|
|
#define ALLOW_DISABLED_PLAYER_INPUT THEME->GetMetricB(m_sName,"AllowDisabledPlayerInput")
|
2005-03-10 19:41:37 +00:00
|
|
|
#define UPDATE_ON_MESSAGE THEME->GetMetric (m_sName,"UpdateOnMessage")
|
2003-03-03 10:03:02 +00:00
|
|
|
|
2005-01-04 11:06:12 +00:00
|
|
|
ScreenSelect::ScreenSelect( CString sClassName ) :
|
|
|
|
|
ScreenWithMenuElements(sClassName),
|
|
|
|
|
IDLE_COMMENT_SECONDS(m_sName,"IdleCommentSeconds"),
|
|
|
|
|
IDLE_TIMEOUT_SECONDS(m_sName,"IdleTimeoutSeconds")
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenSelect::ScreenSelect()" );
|
2005-02-23 06:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelect::Init()
|
|
|
|
|
{
|
|
|
|
|
ScreenWithMenuElements::Init();
|
2003-03-03 10:03:02 +00:00
|
|
|
|
2005-07-12 04:13:03 +00:00
|
|
|
m_bTimeToFinalizePlayers = false;
|
|
|
|
|
|
2005-03-10 19:41:37 +00:00
|
|
|
//
|
|
|
|
|
// Load messages to update on
|
|
|
|
|
//
|
|
|
|
|
split( UPDATE_ON_MESSAGE, ",", m_asSubscribedMessages );
|
|
|
|
|
for( unsigned i = 0; i < m_asSubscribedMessages.size(); ++i )
|
|
|
|
|
MESSAGEMAN->Subscribe( this, m_asSubscribedMessages[i] );
|
|
|
|
|
|
2004-02-13 08:15:05 +00:00
|
|
|
//
|
|
|
|
|
// Load choices
|
|
|
|
|
//
|
2003-03-09 00:55:49 +00:00
|
|
|
{
|
2004-02-13 08:15:05 +00:00
|
|
|
// Instead of using NUM_CHOICES, use a comma-separated list of choices. Each
|
|
|
|
|
// element in the list is a choice name. This level of indirection
|
|
|
|
|
// makes it easier to add or remove items without having to change a bunch
|
|
|
|
|
// of indices.
|
|
|
|
|
CStringArray asChoiceNames;
|
|
|
|
|
split( CHOICE_NAMES, ",", asChoiceNames, true );
|
|
|
|
|
|
|
|
|
|
for( unsigned c=0; c<asChoiceNames.size(); c++ )
|
|
|
|
|
{
|
|
|
|
|
CString sChoiceName = asChoiceNames[c];
|
|
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
GameCommand mc;
|
2004-02-13 08:15:05 +00:00
|
|
|
mc.m_sName = sChoiceName;
|
2004-12-04 22:33:18 +00:00
|
|
|
mc.Load( c, CHOICE(sChoiceName) );
|
2004-12-02 06:29:20 +00:00
|
|
|
m_aGameCommands.push_back( mc );
|
2004-02-13 08:15:05 +00:00
|
|
|
}
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
2004-02-13 08:15:05 +00:00
|
|
|
//
|
|
|
|
|
// Load codes
|
|
|
|
|
//
|
2004-01-25 16:31:38 +00:00
|
|
|
{
|
2005-01-05 04:34:35 +00:00
|
|
|
CStringArray vsCodeNames;
|
|
|
|
|
split( CODE_NAMES, ",", vsCodeNames, true );
|
|
|
|
|
|
|
|
|
|
for( unsigned c=0; c<vsCodeNames.size(); c++ )
|
|
|
|
|
{
|
|
|
|
|
CString sCodeName = vsCodeNames[c];
|
2004-02-13 08:15:05 +00:00
|
|
|
|
2005-01-05 04:34:35 +00:00
|
|
|
CodeItem code;
|
2005-03-21 10:11:48 +00:00
|
|
|
if( !code.Load( CODE(sCodeName) ) )
|
2005-01-05 04:34:35 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
m_aCodes.push_back( code );
|
|
|
|
|
GameCommand mc;
|
2005-03-21 10:11:48 +00:00
|
|
|
mc.Load( c, CODE_ACTION(sCodeName) );
|
2005-01-05 04:34:35 +00:00
|
|
|
m_aCodeChoices.push_back( mc );
|
|
|
|
|
}
|
2004-01-25 16:31:38 +00:00
|
|
|
}
|
2004-03-30 07:44:29 +00:00
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
if( !m_aGameCommands.size() )
|
2004-04-25 04:31:18 +00:00
|
|
|
RageException::Throw( "Screen \"%s\" does not set any choices", m_sName.c_str() );
|
2004-03-30 07:44:29 +00:00
|
|
|
|
2004-04-25 04:31:18 +00:00
|
|
|
// derived classes can override if they want
|
2004-03-30 07:44:29 +00:00
|
|
|
LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ScreenSelect::~ScreenSelect()
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenSelect::~ScreenSelect()" );
|
2005-03-10 19:41:37 +00:00
|
|
|
for( unsigned i = 0; i < m_asSubscribedMessages.size(); ++i )
|
|
|
|
|
MESSAGEMAN->Unsubscribe( this, m_asSubscribedMessages[i] );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelect::Update( float fDelta )
|
|
|
|
|
{
|
2005-01-04 11:06:12 +00:00
|
|
|
if( !IsTransitioning() )
|
|
|
|
|
{
|
|
|
|
|
if( IDLE_COMMENT_SECONDS > 0 && m_timerIdleComment.PeekDeltaTime() >= IDLE_COMMENT_SECONDS )
|
|
|
|
|
{
|
|
|
|
|
SOUND->PlayOnceFromAnnouncer( m_sName+" IdleComment" );
|
|
|
|
|
m_timerIdleComment.GetDeltaTime();
|
|
|
|
|
}
|
|
|
|
|
// don't time out on this screen is coin mode is pay.
|
|
|
|
|
// If we're here, then there's a credit in the machine.
|
2005-05-20 17:45:44 +00:00
|
|
|
if( GAMESTATE->GetCoinMode() != COIN_MODE_PAY )
|
2005-01-04 11:06:12 +00:00
|
|
|
{
|
|
|
|
|
if( IDLE_TIMEOUT_SECONDS > 0 && m_timerIdleTimeout.PeekDeltaTime() >= IDLE_TIMEOUT_SECONDS )
|
|
|
|
|
{
|
|
|
|
|
SCREENMAN->SetNewScreen( IDLE_TIMEOUT_SCREEN );
|
|
|
|
|
m_timerIdleTimeout.GetDeltaTime();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-17 08:41:13 +00:00
|
|
|
ScreenWithMenuElements::Update( fDelta );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelect::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
Screen::DrawPrimitives();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelect::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
|
|
|
{
|
2003-04-11 01:49:57 +00:00
|
|
|
// LOG->Trace( "ScreenSelect::Input()" );
|
2003-03-03 10:03:02 +00:00
|
|
|
|
2005-01-04 11:06:12 +00:00
|
|
|
/* Reset the demonstration timer when a key is pressed. */
|
|
|
|
|
m_timerIdleComment.GetDeltaTime();
|
|
|
|
|
m_timerIdleTimeout.GetDeltaTime();
|
|
|
|
|
|
2005-01-08 09:50:59 +00:00
|
|
|
|
|
|
|
|
// HACK: Don't process JoinInput on the TitleMenu. Otherwise, if the user presses start
|
|
|
|
|
// on a choice that doesn't move to a new screen, the player will be joined and the
|
|
|
|
|
// user will still be on the title menu.
|
|
|
|
|
bool bAllowJoinInput = !ALLOW_DISABLED_PLAYER_INPUT;
|
|
|
|
|
|
2004-05-07 08:08:11 +00:00
|
|
|
if( MenuI.button == MENU_BUTTON_COIN ||
|
2005-01-08 09:50:59 +00:00
|
|
|
(bAllowJoinInput && Screen::JoinInput(MenuI)) )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2004-06-04 21:56:36 +00:00
|
|
|
if( type == IET_FIRST_PRESS )
|
|
|
|
|
this->UpdateSelectableChoices();
|
2005-01-04 11:06:12 +00:00
|
|
|
|
2005-01-08 09:50:59 +00:00
|
|
|
if( !ALLOW_DISABLED_PLAYER_INPUT )
|
2005-01-04 11:06:12 +00:00
|
|
|
return; // don't let the screen handle the MENU_START press
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
2005-01-04 11:51:53 +00:00
|
|
|
// block input of disabled players
|
|
|
|
|
if( !ALLOW_DISABLED_PLAYER_INPUT && !GAMESTATE->IsPlayerEnabled(MenuI.player) )
|
|
|
|
|
return;
|
|
|
|
|
|
2004-05-01 23:19:33 +00:00
|
|
|
if( IsTransitioning() )
|
2003-03-03 10:03:02 +00:00
|
|
|
return;
|
|
|
|
|
|
2004-01-25 16:31:38 +00:00
|
|
|
for( unsigned i = 0; i < m_aCodes.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
if( !m_aCodes[i].EnteredCode( GameI.controller ) )
|
|
|
|
|
continue;
|
|
|
|
|
|
2004-12-05 11:49:29 +00:00
|
|
|
LOG->Trace("entered code for index %d", i);
|
2004-01-25 16:49:05 +00:00
|
|
|
m_aCodeChoices[i].Apply( MenuI.player );
|
2004-01-25 16:31:38 +00:00
|
|
|
}
|
2003-03-03 10:03:02 +00:00
|
|
|
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelect::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
2005-03-23 08:48:38 +00:00
|
|
|
if( SM == SM_BeginFadingOut ) /* Screen is starting to tween out. */
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2005-03-23 08:48:38 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2005-03-23 08:48:38 +00:00
|
|
|
GameCommand gc = m_aGameCommands[this->GetSelectionIndex(p)];
|
2005-04-26 05:39:12 +00:00
|
|
|
CString sThisScreen = gc.GetAndClearScreen();
|
2005-07-12 04:13:03 +00:00
|
|
|
if( m_sNextScreen == "" )
|
|
|
|
|
m_sNextScreen = sThisScreen;
|
2005-03-23 08:48:38 +00:00
|
|
|
gc.Apply( p );
|
|
|
|
|
}
|
2004-10-13 02:56:29 +00:00
|
|
|
|
2005-07-12 04:13:03 +00:00
|
|
|
SCREENMAN->RefreshCreditsMessages();
|
|
|
|
|
|
2005-03-23 08:48:38 +00:00
|
|
|
//
|
|
|
|
|
// Finalize players if we set a style on this screen.
|
|
|
|
|
//
|
|
|
|
|
FOREACH_HumanPlayer( p )
|
|
|
|
|
{
|
|
|
|
|
const int sel = GetSelectionIndex( p );
|
|
|
|
|
if( m_aGameCommands[sel].m_pStyle )
|
2004-10-13 02:56:29 +00:00
|
|
|
{
|
2005-07-12 04:13:03 +00:00
|
|
|
m_bTimeToFinalizePlayers = true;
|
2005-03-23 08:48:38 +00:00
|
|
|
break;
|
2004-10-13 02:56:29 +00:00
|
|
|
}
|
2005-03-23 08:48:38 +00:00
|
|
|
}
|
2003-09-16 05:57:23 +00:00
|
|
|
|
2005-07-12 04:13:03 +00:00
|
|
|
if( m_sNextScreen == "" )
|
2005-03-23 08:48:38 +00:00
|
|
|
{
|
|
|
|
|
const int iSelectionIndex = GetSelectionIndex(GAMESTATE->m_MasterPlayerNumber);
|
2005-07-12 04:13:03 +00:00
|
|
|
m_sNextScreen = NEXT_SCREEN(iSelectionIndex);
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
2005-07-12 04:13:03 +00:00
|
|
|
}
|
|
|
|
|
else if( SM == SM_AllDoneChoosing ) /* It's our turn to tween out. */
|
|
|
|
|
{
|
|
|
|
|
if( !IsTransitioning() )
|
|
|
|
|
StartTransitioning( SM_GoToNextScreen );
|
|
|
|
|
}
|
|
|
|
|
else if( SM == SM_GoToNextScreen )
|
|
|
|
|
{
|
|
|
|
|
/* Finalizing players can take a long time, since it reads profile data. Do it
|
|
|
|
|
* here.(XXX: this should be done in a separate screen.) */
|
|
|
|
|
if( m_bTimeToFinalizePlayers )
|
|
|
|
|
GAMESTATE->PlayersFinalized();
|
|
|
|
|
|
|
|
|
|
SCREENMAN->SetNewScreen( m_sNextScreen );
|
2004-05-08 06:26:24 +00:00
|
|
|
return;
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
2004-05-08 06:26:24 +00:00
|
|
|
|
|
|
|
|
Screen::HandleScreenMessage( SM );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-10 19:41:37 +00:00
|
|
|
void ScreenSelect::HandleMessage( const CString &sMessage )
|
|
|
|
|
{
|
|
|
|
|
this->UpdateSelectableChoices();
|
|
|
|
|
|
|
|
|
|
Screen::HandleMessage( sMessage );
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 10:03:02 +00:00
|
|
|
void ScreenSelect::MenuBack( PlayerNumber pn )
|
|
|
|
|
{
|
2003-07-26 23:05:16 +00:00
|
|
|
SOUND->StopMusic();
|
2003-03-03 10:03:02 +00:00
|
|
|
|
2005-03-20 06:14:41 +00:00
|
|
|
Cancel( SM_GoToPrevScreen );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|