2003-03-02 01:43:33 +00:00
|
|
|
#include "global.h"
|
2003-03-09 00:55:49 +00:00
|
|
|
#include "ScreenSelectDifficulty.h"
|
2003-04-09 04:41:06 +00:00
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "PrefsManager.h"
|
2004-07-08 00:10:34 +00:00
|
|
|
#include "GameSoundManager.h"
|
2003-03-02 01:43:33 +00:00
|
|
|
#include "GameManager.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "AnnouncerManager.h"
|
2004-12-02 06:29:20 +00:00
|
|
|
#include "GameCommand.h"
|
2003-04-13 21:17:14 +00:00
|
|
|
#include "ActorUtil.h"
|
2004-09-21 06:07:12 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2005-01-26 11:21:43 +00:00
|
|
|
#include "Command.h"
|
2003-03-03 10:03:02 +00:00
|
|
|
|
2003-10-15 22:25:53 +00:00
|
|
|
#define NUM_CHOICES_ON_PAGE_1 THEME->GetMetricI(m_sName,"NumChoicesOnPage1")
|
|
|
|
|
#define LOCK_INPUT_SECONDS THEME->GetMetricF(m_sName,"LockInputSeconds")
|
|
|
|
|
#define SLEEP_AFTER_CHOICE_SECONDS THEME->GetMetricF(m_sName,"SleepAfterChoiceSeconds")
|
|
|
|
|
#define SLEEP_AFTER_TWEEN_OFF_SECONDS THEME->GetMetricF(m_sName,"SleepAfterTweenOffSeconds")
|
2004-11-06 23:13:47 +00:00
|
|
|
#define CURSOR_CHOOSE_COMMAND THEME->GetMetricA(m_sName,"CursorChooseCommand")
|
2003-10-15 22:25:53 +00:00
|
|
|
#define CURSOR_OFFSET_X_FROM_PICTURE( p ) THEME->GetMetricF(m_sName,ssprintf("CursorP%dOffsetXFromPicture",p+1))
|
|
|
|
|
#define CURSOR_OFFSET_Y_FROM_PICTURE( p ) THEME->GetMetricF(m_sName,ssprintf("CursorP%dOffsetYFromPicture",p+1))
|
2004-11-06 23:13:47 +00:00
|
|
|
#define SHADOW_CHOOSE_COMMAND THEME->GetMetricA(m_sName,"ShadowChooseCommand")
|
2003-10-15 22:25:53 +00:00
|
|
|
#define SHADOW_LENGTH_X THEME->GetMetricF(m_sName,"ShadowLengthX")
|
|
|
|
|
#define SHADOW_LENGTH_Y THEME->GetMetricF(m_sName,"ShadowLengthY")
|
2004-11-06 23:13:47 +00:00
|
|
|
#define OK_CHOOSE_COMMAND THEME->GetMetricA(m_sName,"OKChooseCommand")
|
2003-10-15 22:25:53 +00:00
|
|
|
#define DISABLED_COLOR THEME->GetMetricC(m_sName,"DisabledColor")
|
2003-03-09 00:55:49 +00:00
|
|
|
|
2004-11-06 23:13:47 +00:00
|
|
|
#define IGNORED_ELEMENT_COMMAND THEME->GetMetricA(m_sName,"IgnoredElementOnCommand")
|
2003-03-09 00:55:49 +00:00
|
|
|
|
2004-11-26 17:28:47 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenSelectDifficulty );
|
2003-09-27 22:30:51 +00:00
|
|
|
ScreenSelectDifficulty::ScreenSelectDifficulty( CString sClassName ) : ScreenSelect( sClassName )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
m_CurrentPage = PAGE_1;
|
2005-02-23 06:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelectDifficulty::Init()
|
|
|
|
|
{
|
|
|
|
|
ScreenSelect::Init();
|
2004-05-24 08:16:17 +00:00
|
|
|
|
|
|
|
|
FOREACH_PlayerNumber( p )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
m_iChoiceOnPage[p] = 0;
|
|
|
|
|
m_bChosen[p] = false;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-23 06:29:05 +00:00
|
|
|
unsigned c;
|
2004-12-02 06:29:20 +00:00
|
|
|
for( c=0; c<m_aGameCommands.size(); c++ )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
if( (int)c < NUM_CHOICES_ON_PAGE_1 )
|
2004-12-02 06:29:20 +00:00
|
|
|
m_GameCommands[PAGE_1].push_back( m_aGameCommands[c] );
|
2003-03-02 01:43:33 +00:00
|
|
|
else
|
2004-12-02 06:29:20 +00:00
|
|
|
m_GameCommands[PAGE_2].push_back( m_aGameCommands[c] );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
2003-03-02 01:43:33 +00:00
|
|
|
|
2003-09-21 20:10:15 +00:00
|
|
|
c = 0;
|
2003-03-02 01:43:33 +00:00
|
|
|
for( int page=0; page<NUM_PAGES; page++ )
|
|
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned choice=0; choice<m_GameCommands[page].size(); choice++, c++ )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprPicture[page][choice].SetName( ssprintf("PicturePage%dChoice%d",page+1,choice+1) );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprPicture[page][choice].Load( THEME->GetPathG(m_sName,ssprintf("picture%d",c+1)) );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_framePages.AddChild( &m_sprPicture[page][choice] );
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprInfo[page][choice].SetName( ssprintf("InfoPage%dChoice%d",page+1,choice+1) );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprInfo[page][choice].Load( THEME->GetPathG(m_sName,ssprintf("info%d",c+1)) );
|
2003-03-09 00:55:49 +00:00
|
|
|
m_framePages.AddChild( &m_sprInfo[page][choice] );
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprMore[page].SetName( ssprintf("MorePage%d",page+1) );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprMore[page].Load( THEME->GetPathG(m_sName,ssprintf("more page%d",page+1)) );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_framePages.AddChild( &m_sprMore[page] );
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprExplanation[page].SetName( ssprintf("ExplanationPage%d",page+1) );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprExplanation[page].Load( THEME->GetPathG(m_sName,"explanation") );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_sprExplanation[page].StopAnimating();
|
|
|
|
|
m_sprExplanation[page].SetState( page );
|
|
|
|
|
m_framePages.AddChild( &m_sprExplanation[page] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
CLAMP( m_iChoiceOnPage[p], 0, (int)m_GameCommands[0].size()-1 );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_bChosen[p] = false;
|
|
|
|
|
|
2003-07-08 19:56:56 +00:00
|
|
|
if( !GAMESTATE->IsHumanPlayer(p) )
|
2003-03-02 01:43:33 +00:00
|
|
|
continue;
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprShadow[p].SetName( "Shadow" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprShadow[p].Load( THEME->GetPathG(m_sName,"shadow 2x1") );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_sprShadow[p].StopAnimating();
|
|
|
|
|
m_sprShadow[p].SetState( p );
|
|
|
|
|
m_sprShadow[p].SetDiffuse( RageColor(0,0,0,0.6f) );
|
|
|
|
|
m_framePages.AddChild( &m_sprShadow[p] );
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprCursor[p].SetName( "Cursor" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprCursor[p].Load( THEME->GetPathG(m_sName,"cursor 2x1") );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_sprCursor[p].StopAnimating();
|
|
|
|
|
m_sprCursor[p].SetState( p );
|
|
|
|
|
m_framePages.AddChild( &m_sprCursor[p] );
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprOK[p].SetName( "OK" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprOK[p].Load( THEME->GetPathG(m_sName,"ok 2x1") );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_sprOK[p].SetState( p );
|
|
|
|
|
m_sprOK[p].StopAnimating();
|
|
|
|
|
m_sprOK[p].SetDiffuse( RageColor(1,1,1,0) );
|
|
|
|
|
m_framePages.AddChild( &m_sprOK[p] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->AddChild( &m_framePages );
|
|
|
|
|
|
2005-02-06 03:32:53 +00:00
|
|
|
m_soundChange.Load( THEME->GetPathS(m_sName,"change"), true );
|
2003-03-09 00:55:49 +00:00
|
|
|
m_soundDifficult.Load( ANNOUNCER->GetPathTo("select difficulty challenge") );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
|
|
|
|
m_fLockInputTime = LOCK_INPUT_SECONDS;
|
2003-09-14 21:00:23 +00:00
|
|
|
|
|
|
|
|
this->UpdateSelectableChoices();
|
2003-03-03 10:03:02 +00:00
|
|
|
|
|
|
|
|
TweenOnScreen();
|
2004-02-13 05:39:15 +00:00
|
|
|
|
2004-05-02 03:01:27 +00:00
|
|
|
this->SortByDrawOrder();
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectDifficulty::Update( float fDelta )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2003-03-03 10:03:02 +00:00
|
|
|
ScreenSelect::Update( fDelta );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_fLockInputTime = max( 0, m_fLockInputTime-fDelta );
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectDifficulty::HandleScreenMessage( const ScreenMessage SM )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2003-03-03 10:09:34 +00:00
|
|
|
ScreenSelect::HandleScreenMessage( SM );
|
|
|
|
|
|
2003-03-02 01:43:33 +00:00
|
|
|
switch( SM )
|
|
|
|
|
{
|
|
|
|
|
case SM_BeginFadingOut:
|
|
|
|
|
TweenOffScreen();
|
2003-03-25 21:17:29 +00:00
|
|
|
SCREENMAN->PostMessageToTopScreen( SM_AllDoneChoosing, SLEEP_AFTER_TWEEN_OFF_SECONDS ); // nofify parent that we're finished
|
2004-05-01 23:19:33 +00:00
|
|
|
StopTimer();
|
2003-03-02 01:43:33 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
int ScreenSelectDifficulty::GetSelectionIndex( PlayerNumber pn )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2003-03-03 10:03:02 +00:00
|
|
|
int index = 0;
|
|
|
|
|
for( int page=0; page<m_CurrentPage; page++ )
|
2004-12-02 06:29:20 +00:00
|
|
|
index += m_GameCommands[page].size();
|
2003-03-03 10:03:02 +00:00
|
|
|
index += m_iChoiceOnPage[pn];
|
|
|
|
|
return index;
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectDifficulty::UpdateSelectableChoices()
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
for( int page=0; page<NUM_PAGES; page++ )
|
|
|
|
|
{
|
|
|
|
|
/* XXX: If a player joins during the tween-in, this diffuse change
|
|
|
|
|
* will be undone by the tween. Hmm. */
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=0; i<m_GameCommands[page].size(); i++ )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
/* If the icon is text, use a dimmer diffuse, or we won't be
|
|
|
|
|
* able to see the glow. */
|
2004-12-02 06:29:20 +00:00
|
|
|
if( m_GameCommands[page][i].IsPlayable() )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2003-03-09 00:55:49 +00:00
|
|
|
m_sprInfo[page][i].SetDiffuse( RageColor(1,1,1,1) );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_sprPicture[page][i].SetDiffuse( RageColor(1,1,1,1) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-03-09 00:55:49 +00:00
|
|
|
m_sprInfo[page][i].SetDiffuse( DISABLED_COLOR );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_sprPicture[page][i].SetDiffuse( DISABLED_COLOR );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-15 23:01:13 +00:00
|
|
|
// I'm not sure why this was here -- but there seem no ill effects
|
|
|
|
|
// of it's removal.
|
|
|
|
|
//
|
2004-05-24 08:16:17 +00:00
|
|
|
//FOREACH_HumanPlayer( p )
|
2003-09-15 23:01:13 +00:00
|
|
|
// {
|
2004-05-24 08:16:17 +00:00
|
|
|
// MenuRight( p );
|
|
|
|
|
// MenuLeft( p );
|
2003-09-15 23:01:13 +00:00
|
|
|
// }
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
static bool BothPlayersGameCommand( const GameCommand &mc )
|
2004-02-01 01:13:58 +00:00
|
|
|
{
|
|
|
|
|
switch( mc.m_pm )
|
|
|
|
|
{
|
|
|
|
|
case PLAY_MODE_ONI:
|
|
|
|
|
case PLAY_MODE_NONSTOP:
|
|
|
|
|
case PLAY_MODE_ENDLESS:
|
|
|
|
|
case PLAY_MODE_RAVE:
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectDifficulty::MenuLeft( PlayerNumber pn )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2003-04-16 02:22:24 +00:00
|
|
|
// if( m_fLockInputTime > 0 )
|
|
|
|
|
// return;
|
2003-03-02 01:43:33 +00:00
|
|
|
if( m_bChosen[pn] )
|
|
|
|
|
return;
|
2003-09-14 21:00:23 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
bool AnotherPlayerSelected = false;
|
2004-05-24 06:10:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2004-02-01 01:13:58 +00:00
|
|
|
if( p != pn && m_bChosen[p] )
|
|
|
|
|
AnotherPlayerSelected = true;
|
2004-01-28 02:11:27 +00:00
|
|
|
|
2003-09-14 21:00:23 +00:00
|
|
|
int iSwitchToIndex = -1;
|
|
|
|
|
for( int i=m_iChoiceOnPage[pn]-1; i>=0; i-- )
|
|
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
const GameCommand &mc = m_GameCommands[m_CurrentPage][i];
|
|
|
|
|
if( AnotherPlayerSelected && BothPlayersGameCommand(mc) )
|
2004-02-01 01:13:58 +00:00
|
|
|
continue;
|
|
|
|
|
if( mc.IsPlayable() )
|
2003-09-14 21:00:23 +00:00
|
|
|
{
|
|
|
|
|
iSwitchToIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( iSwitchToIndex == -1 )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
if( m_CurrentPage > 0 )
|
|
|
|
|
ChangePage( (Page)(m_CurrentPage-1) );
|
2003-09-14 21:00:23 +00:00
|
|
|
return;
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
2004-02-01 01:13:58 +00:00
|
|
|
if( ChangeWithinPage( pn, iSwitchToIndex, false ) )
|
|
|
|
|
m_soundChange.Play();
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectDifficulty::MenuRight( PlayerNumber pn )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2003-04-16 02:22:24 +00:00
|
|
|
// if( m_fLockInputTime > 0 )
|
|
|
|
|
// return;
|
2003-03-02 01:43:33 +00:00
|
|
|
if( m_bChosen[pn] )
|
|
|
|
|
return;
|
2003-09-14 21:00:23 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
bool AnotherPlayerSelected = false;
|
2004-05-24 06:10:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2004-02-01 01:13:58 +00:00
|
|
|
if( p != pn && m_bChosen[p] )
|
|
|
|
|
AnotherPlayerSelected = true;
|
2004-01-28 02:11:27 +00:00
|
|
|
|
2003-09-14 21:00:23 +00:00
|
|
|
int iSwitchToIndex = -1;
|
2004-12-02 06:29:20 +00:00
|
|
|
for( int i=m_iChoiceOnPage[pn]+1; i<(int) m_GameCommands[m_CurrentPage].size(); i++ )
|
2003-09-14 21:00:23 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
const GameCommand &mc = m_GameCommands[m_CurrentPage][i];
|
|
|
|
|
if( AnotherPlayerSelected && BothPlayersGameCommand(mc) )
|
2004-02-01 01:13:58 +00:00
|
|
|
continue;
|
|
|
|
|
if( mc.IsPlayable() )
|
2003-09-14 21:00:23 +00:00
|
|
|
{
|
|
|
|
|
iSwitchToIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( iSwitchToIndex == -1 )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
if( m_GameCommands[m_CurrentPage+1].size()==0 ) // there is no page 2
|
2003-07-08 19:56:56 +00:00
|
|
|
return;
|
|
|
|
|
|
2003-03-02 01:43:33 +00:00
|
|
|
if( m_CurrentPage < NUM_PAGES-1 )
|
|
|
|
|
ChangePage( (Page)(m_CurrentPage+1) );
|
2003-09-14 21:00:23 +00:00
|
|
|
return;
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
2003-09-14 21:00:23 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
if( ChangeWithinPage( pn, iSwitchToIndex, false ) )
|
|
|
|
|
m_soundChange.Play();
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectDifficulty::ChangePage( Page newPage )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
// If anyone has already chosen, don't allow changing of pages
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
|
|
|
|
if( m_bChosen[p] )
|
2003-03-02 01:43:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool bPageIncreasing = newPage > m_CurrentPage;
|
|
|
|
|
m_CurrentPage = newPage;
|
|
|
|
|
|
|
|
|
|
if( newPage == PAGE_2 )
|
|
|
|
|
{
|
2003-03-30 19:32:05 +00:00
|
|
|
/* XXX: only play this once (I thought we already did that?) */
|
2003-03-02 01:43:33 +00:00
|
|
|
m_soundDifficult.Stop();
|
|
|
|
|
m_soundDifficult.PlayRandom();
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-14 21:00:23 +00:00
|
|
|
// Find the first Playable mode on the new page
|
|
|
|
|
int iSwitchToIndex = -1;
|
2004-07-07 20:01:22 +00:00
|
|
|
if( !bPageIncreasing )
|
|
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
for( int i=m_GameCommands[newPage].size()-1; i>=0; i-- )
|
2003-09-14 21:00:23 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
if( m_GameCommands[newPage][i].IsPlayable() )
|
2003-09-14 21:00:23 +00:00
|
|
|
{
|
|
|
|
|
iSwitchToIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=0; i<m_GameCommands[newPage].size(); i++ )
|
2003-09-14 21:00:23 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
if( m_GameCommands[newPage][i].IsPlayable() )
|
2003-09-14 21:00:23 +00:00
|
|
|
{
|
|
|
|
|
iSwitchToIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-07 20:01:22 +00:00
|
|
|
if( iSwitchToIndex == -1 )
|
|
|
|
|
RageException::Throw( "%s has no selectable choices on page %i", m_sName.c_str(), newPage);
|
2003-09-14 21:00:23 +00:00
|
|
|
|
2003-03-02 01:43:33 +00:00
|
|
|
// change both players
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
|
|
|
|
ChangeWithinPage( p, iSwitchToIndex, true );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
2003-03-04 01:13:36 +00:00
|
|
|
m_soundChange.Play();
|
|
|
|
|
|
2003-03-02 01:43:33 +00:00
|
|
|
// move frame with choices
|
|
|
|
|
m_framePages.StopTweening();
|
|
|
|
|
m_framePages.BeginTweening( 0.2f );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_framePages.SetX( (float)newPage*-SCREEN_WIDTH );
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
bool ScreenSelectDifficulty::ChangeWithinPage( PlayerNumber pn, int iNewChoice, bool bChangingPages )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
ASSERT_M( iNewChoice >= 0 && iNewChoice < (int) m_GameCommands[m_CurrentPage].size(), ssprintf("%i, %i", iNewChoice, (int) m_GameCommands[m_CurrentPage].size()) );
|
2004-06-16 03:52:10 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
bool bAnyChanged = false;
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
if( p!=pn && m_CurrentPage==PAGE_1 )
|
|
|
|
|
continue; // skip
|
2004-05-25 06:29:42 +00:00
|
|
|
/* Don't do this. If we were on page one, with P1 on choice 0, and P2 moves
|
|
|
|
|
* to the second page, then we're setting choice 0 on the second page;
|
|
|
|
|
* m_iChoiceOnPage[p] is going from 0 to 0 (all that's changing is the page). */
|
|
|
|
|
// if( m_iChoiceOnPage[p] == iNewChoice )
|
|
|
|
|
// continue; // skip
|
2003-03-02 01:43:33 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
bAnyChanged = true;
|
2003-03-02 01:43:33 +00:00
|
|
|
m_iChoiceOnPage[p] = iNewChoice;
|
|
|
|
|
|
2004-05-24 08:16:17 +00:00
|
|
|
float fCursorX = GetCursorX( p );
|
|
|
|
|
float fCursorY = GetCursorY( p );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
|
|
|
|
m_sprCursor[p].StopTweening();
|
|
|
|
|
m_sprCursor[p].BeginTweening( 0.2f, bChangingPages ? TWEEN_LINEAR : TWEEN_DECELERATE );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprCursor[p].SetX( fCursorX );
|
|
|
|
|
m_sprCursor[p].SetY( fCursorY );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
|
|
|
|
m_sprShadow[p].StopTweening();
|
|
|
|
|
m_sprShadow[p].BeginTweening( 0.2f, bChangingPages ? TWEEN_LINEAR : TWEEN_DECELERATE );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprShadow[p].SetX( fCursorX + SHADOW_LENGTH_X );
|
|
|
|
|
m_sprShadow[p].SetY( fCursorY + SHADOW_LENGTH_Y );
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
return bAnyChanged;
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectDifficulty::MenuStart( PlayerNumber pn )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
if( m_fLockInputTime > 0 )
|
|
|
|
|
return;
|
2004-09-06 21:28:56 +00:00
|
|
|
if( m_bChosen[pn] )
|
2003-03-02 01:43:33 +00:00
|
|
|
return;
|
|
|
|
|
m_bChosen[pn] = true;
|
|
|
|
|
|
2003-03-30 21:02:15 +00:00
|
|
|
for( int page=0; page<NUM_PAGES; page++ )
|
2003-04-12 06:16:12 +00:00
|
|
|
OFF_COMMAND( m_sprMore[page] );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
const GameCommand& mc = m_GameCommands[m_CurrentPage][m_iChoiceOnPage[pn]];
|
2003-03-04 01:13:36 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
/* Don't play sound if we're recursive, since it just played. */
|
|
|
|
|
static bool bPlaySelect = true;
|
|
|
|
|
if( bPlaySelect )
|
2003-03-04 01:13:36 +00:00
|
|
|
{
|
2004-04-12 20:11:36 +00:00
|
|
|
SOUND->PlayOnceFromAnnouncer( ssprintf("ScreenSelectDifficulty comment %s",mc.m_sName.c_str()) );
|
2004-05-01 23:28:53 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
2003-03-04 01:13:36 +00:00
|
|
|
}
|
2003-03-02 01:43:33 +00:00
|
|
|
|
2004-01-28 02:11:27 +00:00
|
|
|
// courses should be selected for both players at all times
|
2004-12-02 06:29:20 +00:00
|
|
|
if( BothPlayersGameCommand(mc) )
|
2004-01-28 02:11:27 +00:00
|
|
|
{
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
2004-01-28 02:11:27 +00:00
|
|
|
{
|
2004-05-24 08:16:17 +00:00
|
|
|
if( m_bChosen[p] || p == pn )
|
2004-02-01 01:13:58 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// move all cursors to the oni/nonstop selection so it graphically looks as if all players selected the same option.
|
2004-05-24 08:16:17 +00:00
|
|
|
ChangeWithinPage( p, m_iChoiceOnPage[pn], false );
|
2004-02-01 01:13:58 +00:00
|
|
|
bPlaySelect = false;
|
2004-05-24 08:16:17 +00:00
|
|
|
MenuStart( p ); // agree everyone
|
2004-02-01 01:13:58 +00:00
|
|
|
bPlaySelect = true;
|
2004-01-28 02:11:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // someone must have chosen arcade style play so oni/nonstop/endless must be disabled
|
|
|
|
|
{
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
2004-01-28 02:11:27 +00:00
|
|
|
{
|
2004-05-24 08:16:17 +00:00
|
|
|
if( m_bChosen[p] || p == pn )
|
2004-02-01 01:13:58 +00:00
|
|
|
continue;
|
2004-01-28 02:11:27 +00:00
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
if( !BothPlayersGameCommand(m_GameCommands[m_CurrentPage][m_iChoiceOnPage[p]]) )
|
2004-02-01 01:13:58 +00:00
|
|
|
continue;
|
2004-01-28 02:11:27 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
/* This player is currently on a choice that is no longer available due to
|
|
|
|
|
* the selection just made. */
|
|
|
|
|
int iSwitchToIndex = -1;
|
2004-12-02 06:29:20 +00:00
|
|
|
for( int i=m_iChoiceOnPage[p]+1; iSwitchToIndex == -1 && i < (int) m_GameCommands[m_CurrentPage].size(); ++i )
|
2004-02-02 22:34:49 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
const GameCommand &mc = m_GameCommands[m_CurrentPage][i];
|
|
|
|
|
if( mc.IsPlayable() && !BothPlayersGameCommand(mc) )
|
2004-02-01 01:13:58 +00:00
|
|
|
iSwitchToIndex = i;
|
2004-02-02 22:34:49 +00:00
|
|
|
}
|
2004-02-01 05:24:11 +00:00
|
|
|
if( iSwitchToIndex == -1 ) /* couldn't find a spot looking up; look down */
|
2004-02-01 01:13:58 +00:00
|
|
|
{
|
2004-09-21 07:53:39 +00:00
|
|
|
for( int i=m_iChoiceOnPage[p]-1; iSwitchToIndex == -1 && i >= 0; --i )
|
2004-02-02 22:34:49 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
const GameCommand &mc = m_GameCommands[m_CurrentPage][i];
|
|
|
|
|
if( mc.IsPlayable() && !BothPlayersGameCommand(mc) )
|
2004-02-01 01:13:58 +00:00
|
|
|
iSwitchToIndex = i;
|
2004-02-02 22:34:49 +00:00
|
|
|
}
|
2004-02-01 01:13:58 +00:00
|
|
|
}
|
|
|
|
|
/* We should always find a place to go--we should at least be able to choose
|
|
|
|
|
* the same thing pn picked. */
|
|
|
|
|
ASSERT( iSwitchToIndex != -1 );
|
2004-01-28 02:11:27 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
// move the cursor
|
2004-05-24 08:16:17 +00:00
|
|
|
ChangeWithinPage( p, iSwitchToIndex, false );
|
2004-02-01 01:13:58 +00:00
|
|
|
}
|
2004-01-28 02:11:27 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
/* If the other player is active and hasn't yet chosen, gray out unselectable options.
|
|
|
|
|
* Otherwise, don't do this, so we don't gray out stuff when nothing else can be selected
|
|
|
|
|
* anyway. */
|
|
|
|
|
bool bAnyPlayersLeft = false;
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
2004-02-01 01:13:58 +00:00
|
|
|
{
|
2004-05-24 08:16:17 +00:00
|
|
|
if( m_bChosen[p] || p == pn )
|
2004-02-01 01:13:58 +00:00
|
|
|
continue;
|
|
|
|
|
bAnyPlayersLeft = true;
|
2004-01-28 02:11:27 +00:00
|
|
|
}
|
2004-02-01 01:13:58 +00:00
|
|
|
|
|
|
|
|
if( bAnyPlayersLeft )
|
2004-01-28 02:11:27 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned c=0; c<m_GameCommands[PAGE_1].size(); c++ )
|
2004-01-28 02:11:27 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
if( BothPlayersGameCommand(m_GameCommands[PAGE_1][c]) )
|
2004-02-01 01:13:58 +00:00
|
|
|
{
|
2004-12-03 05:19:46 +00:00
|
|
|
m_sprPicture[PAGE_1][c].RunCommands( IGNORED_ELEMENT_COMMAND );
|
|
|
|
|
m_sprInfo[PAGE_1][c].RunCommands( IGNORED_ELEMENT_COMMAND );
|
2004-01-28 02:11:27 +00:00
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
// IGNORED_ELEMENT_COMMAND
|
|
|
|
|
}
|
2004-12-02 06:29:20 +00:00
|
|
|
// m_GameCommands[PAGE_1].push_back( m_aGameCommands[c] );
|
2004-01-28 02:11:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-02 01:43:33 +00:00
|
|
|
if( m_CurrentPage == PAGE_2 )
|
|
|
|
|
{
|
|
|
|
|
// choose this for all the other players too
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
if( m_bChosen[p] )
|
|
|
|
|
continue;
|
|
|
|
|
|
2004-02-01 01:13:58 +00:00
|
|
|
bPlaySelect = false;
|
2004-05-24 08:16:17 +00:00
|
|
|
MenuStart( p );
|
2004-02-01 01:13:58 +00:00
|
|
|
bPlaySelect = true;
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 05:19:46 +00:00
|
|
|
m_sprCursor[pn].RunCommands( CURSOR_CHOOSE_COMMAND );
|
2004-02-01 01:13:58 +00:00
|
|
|
m_sprOK[pn].SetXY( m_sprShadow[pn].GetDestX(), m_sprShadow[pn].GetDestY() );
|
2004-12-03 05:19:46 +00:00
|
|
|
m_sprOK[pn].RunCommands( OK_CHOOSE_COMMAND );
|
|
|
|
|
m_sprShadow[pn].RunCommands( SHADOW_CHOOSE_COMMAND );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// check to see if everyone has chosen
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2004-09-06 21:28:56 +00:00
|
|
|
if( !m_bChosen[p] )
|
2003-03-02 01:43:33 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2003-03-25 21:17:29 +00:00
|
|
|
this->PostScreenMessage( SM_BeginFadingOut, SLEEP_AFTER_CHOICE_SECONDS ); // tell our owner it's time to move on
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectDifficulty::TweenOnScreen()
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
for( int page=0; page<NUM_PAGES; page++ )
|
|
|
|
|
{
|
2003-04-12 06:16:12 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( m_sprExplanation[page] );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_sprMore[page] );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned c=0; c<m_GameCommands[page].size(); c++ )
|
2003-04-12 06:16:12 +00:00
|
|
|
{
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_sprInfo[page][c] );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_sprPicture[page][c] );
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2004-05-24 08:16:17 +00:00
|
|
|
float fCursorX = GetCursorX( p );
|
|
|
|
|
float fCursorY = GetCursorY( p );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
|
|
|
|
m_sprCursor[p].SetXY( fCursorX, fCursorY );
|
2003-04-12 06:16:12 +00:00
|
|
|
ON_COMMAND( m_sprCursor[p] );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
|
|
|
|
m_sprShadow[p].SetXY( fCursorX + SHADOW_LENGTH_X, fCursorY + SHADOW_LENGTH_Y );
|
2003-04-12 06:16:12 +00:00
|
|
|
ON_COMMAND( m_sprShadow[p] );
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectDifficulty::TweenOffScreen()
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
const int page = m_CurrentPage;
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
OFF_COMMAND( m_sprExplanation[page] );
|
|
|
|
|
OFF_COMMAND( m_sprMore[page] );
|
2003-03-02 01:43:33 +00:00
|
|
|
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_HumanPlayer( p )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2003-04-12 06:16:12 +00:00
|
|
|
OFF_COMMAND( m_sprCursor[p] );
|
|
|
|
|
OFF_COMMAND( m_sprOK[p] );
|
|
|
|
|
OFF_COMMAND( m_sprShadow[p] );
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned c=0; c<m_GameCommands[page].size(); c++ )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
2003-04-12 06:16:12 +00:00
|
|
|
OFF_COMMAND( m_sprInfo[page][c] );
|
|
|
|
|
OFF_COMMAND( m_sprPicture[page][c] );
|
2003-03-02 01:43:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
float ScreenSelectDifficulty::GetCursorX( PlayerNumber pn )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
return m_sprPicture[m_CurrentPage][m_iChoiceOnPage[pn]].GetX() + CURSOR_OFFSET_X_FROM_PICTURE(pn);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
float ScreenSelectDifficulty::GetCursorY( PlayerNumber pn )
|
2003-03-02 01:43:33 +00:00
|
|
|
{
|
|
|
|
|
return m_sprPicture[m_CurrentPage][m_iChoiceOnPage[pn]].GetY() + CURSOR_OFFSET_Y_FROM_PICTURE(pn);
|
|
|
|
|
}
|
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.
|
|
|
|
|
*/
|