2003-06-20 23:07:45 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: ScreenSelectMaster
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ScreenSelectMaster.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "GameManager.h"
|
|
|
|
|
#include "ThemeManager.h"
|
2003-07-26 23:05:16 +00:00
|
|
|
#include "RageSounds.h"
|
2003-06-20 23:07:45 +00:00
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "AnnouncerManager.h"
|
|
|
|
|
#include "ModeChoice.h"
|
|
|
|
|
#include "ActorUtil.h"
|
2003-11-05 18:49:57 +00:00
|
|
|
#include "RageLog.h"
|
2003-06-20 23:07:45 +00:00
|
|
|
|
2003-11-04 20:57:19 +00:00
|
|
|
#define NUM_ICON_PARTS THEME->GetMetricI(m_sName,"NumIconParts")
|
|
|
|
|
#define NUM_PREVIEW_PARTS THEME->GetMetricI(m_sName,"NumPreviewParts")
|
|
|
|
|
#define NUM_CURSOR_PARTS THEME->GetMetricI(m_sName,"NumCursorParts")
|
|
|
|
|
#define SHARED_PREVIEW_AND_CURSOR THEME->GetMetricB(m_sName,"SharedPreviewAndCursor")
|
|
|
|
|
#define NUM_CHOICES_ON_PAGE_1 THEME->GetMetricI(m_sName,"NumChoicesOnPage1")
|
|
|
|
|
#define CURSOR_OFFSET_X_FROM_ICON( p, part ) THEME->GetMetricF(m_sName,ssprintf("CursorPart%dP%dOffsetXFromIcon",part+1,p+1))
|
|
|
|
|
#define CURSOR_OFFSET_Y_FROM_ICON( p, part ) THEME->GetMetricF(m_sName,ssprintf("CursorPart%dP%dOffsetYFromIcon",part+1,p+1))
|
|
|
|
|
#define DISABLED_COLOR THEME->GetMetricC(m_sName,"DisabledColor")
|
|
|
|
|
#define PRE_SWITCH_PAGE_SECONDS THEME->GetMetricF(m_sName,"PreSwitchPageSeconds")
|
|
|
|
|
#define POST_SWITCH_PAGE_SECONDS THEME->GetMetricF(m_sName,"PostSwitchPageSeconds")
|
2003-06-20 23:07:45 +00:00
|
|
|
|
|
|
|
|
const ScreenMessage SM_PlayPostSwitchPage = (ScreenMessage)(SM_User+1);
|
|
|
|
|
|
2003-09-27 22:30:51 +00:00
|
|
|
ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sClassName )
|
2003-06-20 23:07:45 +00:00
|
|
|
{
|
|
|
|
|
int p, i;
|
|
|
|
|
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
{
|
|
|
|
|
m_iChoice[p] = 0;
|
|
|
|
|
m_bChosen[p] = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
CString sFName = ssprintf("%s Cursor Part%d", m_sName.c_str(),i+1);
|
|
|
|
|
m_sprCursor[i][0].SetName( ssprintf("CursorPart%d",i+1) );
|
|
|
|
|
m_sprCursor[i][0].Load( THEME->GetPathToG(sFName) );
|
|
|
|
|
this->AddChild( &m_sprCursor[i][0] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
{
|
|
|
|
|
if( !GAMESTATE->IsPlayerEnabled(p) )
|
|
|
|
|
continue; // skip
|
|
|
|
|
CString sFName = ssprintf("%s Cursor Part%d P%d", m_sName.c_str(),i+1,p+1);
|
|
|
|
|
m_sprCursor[i][p].SetName( ssprintf("CursorPart%dP%d",i+1,p+1) );
|
|
|
|
|
m_sprCursor[i][p].Load( THEME->GetPathToG(sFName) );
|
|
|
|
|
this->AddChild( &m_sprCursor[i][p] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( unsigned c=0; c<m_aModeChoices.size(); c++ )
|
|
|
|
|
{
|
2003-06-24 20:06:42 +00:00
|
|
|
// const ModeChoice& mc = m_aModeChoices[c];
|
2003-06-20 23:07:45 +00:00
|
|
|
|
|
|
|
|
for( i=0; i<NUM_ICON_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
CString sFName = ssprintf("%s Icon Part%d Choice%d", m_sName.c_str(),i+1,c+1);
|
|
|
|
|
m_sprIcon[i][c].Load( THEME->GetPathToG(sFName) );
|
2003-11-05 04:09:10 +00:00
|
|
|
m_sprIcon[i][c]->SetName( ssprintf("IconPart%dChoice%d",i+1,c+1) );
|
|
|
|
|
this->AddChild( m_sprIcon[i][c] );
|
2003-06-20 23:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
CString sFName = ssprintf("%s Preview Part%d Choice%d", m_sName.c_str(),i+1,c+1);
|
|
|
|
|
m_sprPreview[i][c][0].Load( THEME->GetPathToG(sFName) );
|
2003-11-05 04:09:10 +00:00
|
|
|
m_sprPreview[i][c][0]->SetName( ssprintf("PreviewPart%d",i+1) );
|
|
|
|
|
this->AddChild( m_sprPreview[i][c][0] );
|
2003-06-20 23:07:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
{
|
|
|
|
|
if( !GAMESTATE->IsPlayerEnabled(p) )
|
|
|
|
|
continue; // skip
|
|
|
|
|
CString sFName = ssprintf("%s Preview Part%d Choice%d P%d", m_sName.c_str(),i+1,c+1,p+1);
|
|
|
|
|
m_sprPreview[i][c][p].Load( THEME->GetPathToG(sFName) );
|
2003-11-05 04:09:10 +00:00
|
|
|
m_sprPreview[i][c][p]->SetName( ssprintf("PreviewPart%dP%d",i+1,p+1) );
|
|
|
|
|
this->AddChild( m_sprPreview[i][c][p] );
|
2003-06-20 23:07:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( int page=0; page<NUM_PAGES; page++ )
|
|
|
|
|
{
|
|
|
|
|
m_sprMore[page].SetName( ssprintf("MorePage%d",page+1) );
|
2003-11-04 21:07:36 +00:00
|
|
|
m_sprMore[page].Load( THEME->GetPathToG( ssprintf("%s more page%d",m_sName.c_str(), page+1) ) );
|
2003-06-20 23:07:45 +00:00
|
|
|
this->AddChild( &m_sprMore[page] );
|
|
|
|
|
|
|
|
|
|
m_sprExplanation[page].SetName( ssprintf("ExplanationPage%d",page+1) );
|
2003-11-04 21:07:36 +00:00
|
|
|
m_sprExplanation[page].Load( THEME->GetPathToG( ssprintf("%s explanation page%d",m_sName.c_str(), page+1) ) );
|
2003-06-20 23:07:45 +00:00
|
|
|
this->AddChild( &m_sprExplanation[page] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
{
|
|
|
|
|
CLAMP( m_iChoice[p], 0, (int)m_aModeChoices.size()-1 );
|
|
|
|
|
m_bChosen[p] = false;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-04 20:57:19 +00:00
|
|
|
m_soundChange.Load( THEME->GetPathToS( ssprintf("%s change", m_sName.c_str())) );
|
2003-06-20 23:07:45 +00:00
|
|
|
m_soundSelect.Load( THEME->GetPathToS( "Common start") );
|
|
|
|
|
m_soundDifficult.Load( ANNOUNCER->GetPathTo("select difficulty challenge") );
|
|
|
|
|
|
|
|
|
|
m_fLockInputSecs = TweenOnScreen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelectMaster::Update( float fDelta )
|
|
|
|
|
{
|
|
|
|
|
ScreenSelect::Update( fDelta );
|
|
|
|
|
m_fLockInputSecs = max( 0, m_fLockInputSecs-fDelta );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelectMaster::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
ScreenSelect::HandleScreenMessage( SM );
|
|
|
|
|
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
|
|
|
|
case SM_PlayPostSwitchPage:
|
|
|
|
|
{
|
|
|
|
|
float fSecs = 0;
|
|
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
m_sprCursor[i][0].SetXY( GetCursorX((PlayerNumber)0,i), GetCursorY((PlayerNumber)0,i) );
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprCursor[i][0], "PostSwitchPage" ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsPlayerEnabled(p) )
|
|
|
|
|
{
|
|
|
|
|
m_sprCursor[i][p].SetXY( GetCursorX((PlayerNumber)p,i), GetCursorY((PlayerNumber)p,i) );
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprCursor[i][p], "PostSwitchPage" ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprPreview[i][m_iChoice[0]][0], "PostSwitchPage" ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsPlayerEnabled(p) )
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprPreview[i][m_iChoice[p]][p], "PostSwitchPage" ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_fLockInputSecs = POST_SWITCH_PAGE_SECONDS;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SM_BeginFadingOut:
|
|
|
|
|
float fSecs = TweenOffScreen();
|
|
|
|
|
SCREENMAN->PostMessageToTopScreen( SM_AllDoneChoosing, fSecs ); // nofify parent that we're finished
|
|
|
|
|
m_Menu.m_MenuTimer.Stop();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ScreenSelectMaster::GetSelectionIndex( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
return m_iChoice[pn];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelectMaster::UpdateSelectableChoices()
|
|
|
|
|
{
|
|
|
|
|
/* XXX: If a player joins during the tween-in, this diffuse change
|
|
|
|
|
* will be undone by the tween. Hmm. */
|
|
|
|
|
for( unsigned c=0; c<m_aModeChoices.size(); c++ )
|
|
|
|
|
{
|
2003-09-27 03:11:37 +00:00
|
|
|
if( m_aModeChoices[c].IsPlayable() )
|
2003-06-20 23:07:45 +00:00
|
|
|
for( int i=0; i<NUM_ICON_PARTS; i++ )
|
2003-11-05 04:09:10 +00:00
|
|
|
m_sprIcon[i][c]->SetDiffuse( RageColor(1,1,1,1) );
|
2003-06-20 23:07:45 +00:00
|
|
|
else
|
|
|
|
|
for( int i=0; i<NUM_ICON_PARTS; i++ )
|
2003-11-05 04:09:10 +00:00
|
|
|
m_sprIcon[i][c]->SetDiffuse( DISABLED_COLOR );
|
2003-06-20 23:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
{
|
|
|
|
|
if( GAMESTATE->IsHumanPlayer(p) )
|
|
|
|
|
{
|
|
|
|
|
MenuRight( (PlayerNumber)p );
|
|
|
|
|
MenuLeft( (PlayerNumber)p );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelectMaster::MenuLeft( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
if( m_fLockInputSecs > 0 )
|
|
|
|
|
return;
|
|
|
|
|
if( m_bChosen[pn] )
|
|
|
|
|
return;
|
|
|
|
|
if( m_iChoice[pn] == 0 ) // can't go left any more
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if( GetPage(m_iChoice[pn]) != GetPage(m_iChoice[pn]-1) )
|
|
|
|
|
ChangePage( GetPage(m_iChoice[pn]-1) );
|
|
|
|
|
else
|
|
|
|
|
ChangeSelection( pn, m_iChoice[pn]-1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ScreenSelectMaster::MenuRight( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
if( m_fLockInputSecs > 0 )
|
|
|
|
|
return;
|
|
|
|
|
if( m_bChosen[pn] )
|
|
|
|
|
return;
|
|
|
|
|
if( m_iChoice[pn] == (int)m_aModeChoices.size()-1 ) // can't go right any more
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if( GetPage(m_iChoice[pn]) != GetPage(m_iChoice[pn]+1) )
|
|
|
|
|
ChangePage( GetPage(m_iChoice[pn]+1) );
|
|
|
|
|
else
|
|
|
|
|
ChangeSelection( pn, m_iChoice[pn]+1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelectMaster::ChangePage( Page newPage )
|
|
|
|
|
{
|
|
|
|
|
// If anyone has already chosen, don't allow changing of pages
|
2003-06-21 15:58:19 +00:00
|
|
|
int p;
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
2003-06-20 23:07:45 +00:00
|
|
|
if( GAMESTATE->IsHumanPlayer(p) && m_bChosen[p] )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
float fSecs = 0;
|
|
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprCursor[i][0], "PreSwitchPage" ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsHumanPlayer(p) )
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprCursor[i][p], "PreSwitchPage" ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CString sIconAndExplanationCommand = ssprintf( "SwitchToPage%d", newPage+1 );
|
|
|
|
|
|
|
|
|
|
for( unsigned c=0; c<m_aModeChoices.size(); c++ )
|
|
|
|
|
for( int i=0; i<NUM_ICON_PARTS; i++ )
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprIcon[i][c], sIconAndExplanationCommand ) );
|
|
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprPreview[i][m_iChoice[p]][0], "PreSwitchPage" ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsPlayerEnabled(p) )
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprPreview[i][m_iChoice[p]][p], "PreSwitchPage" ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( int page=0; page<NUM_PAGES; page++ )
|
|
|
|
|
{
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprExplanation[page], sIconAndExplanationCommand ) );
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprMore[page], sIconAndExplanationCommand ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( newPage == PAGE_2 )
|
|
|
|
|
{
|
|
|
|
|
// XXX: only play this once (I thought we already did that?)
|
|
|
|
|
// DDR plays it on every change to page 2. -Chris
|
2003-11-04 20:57:19 +00:00
|
|
|
/* That sounds ugly if you go back and forth quickly. -g */
|
2003-06-20 23:07:45 +00:00
|
|
|
m_soundDifficult.Stop();
|
|
|
|
|
m_soundDifficult.PlayRandom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// change both players
|
|
|
|
|
int iNewChoice = (newPage==PAGE_1) ? (NUM_CHOICES_ON_PAGE_1-1) : NUM_CHOICES_ON_PAGE_1;
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
m_iChoice[p] = iNewChoice;
|
|
|
|
|
|
|
|
|
|
m_soundChange.Play();
|
|
|
|
|
|
|
|
|
|
m_fLockInputSecs = PRE_SWITCH_PAGE_SECONDS;
|
|
|
|
|
this->PostScreenMessage( SM_PlayPostSwitchPage, PRE_SWITCH_PAGE_SECONDS );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelectMaster::ChangeSelection( PlayerNumber pn, int iNewChoice )
|
|
|
|
|
{
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
{
|
|
|
|
|
if( !GAMESTATE->IsHumanPlayer(p) )
|
|
|
|
|
continue; // skip
|
|
|
|
|
|
|
|
|
|
if( p!=pn && GetCurrentPage()==PAGE_1 )
|
|
|
|
|
continue; // skip
|
|
|
|
|
|
|
|
|
|
const int iOldChoice = m_iChoice[p];
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
COMMAND( m_sprPreview[i][iOldChoice][0], "LoseFocus" );
|
|
|
|
|
COMMAND( m_sprPreview[i][iNewChoice][0], "GainFocus" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
COMMAND( m_sprPreview[i][iOldChoice][p], "LoseFocus" );
|
|
|
|
|
COMMAND( m_sprPreview[i][iNewChoice][p], "GainFocus" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-05 04:09:10 +00:00
|
|
|
{
|
2003-11-05 18:49:57 +00:00
|
|
|
/* XXX: If !SharedPreviewAndCursor, this is incorrect. (Nothing uses
|
|
|
|
|
* both icon focus and !SharedPreviewAndCursor right now.) */
|
2003-11-05 04:09:10 +00:00
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
COMMAND( m_sprIcon[i][iOldChoice], "LoseFocus" );
|
|
|
|
|
COMMAND( m_sprIcon[i][iNewChoice], "GainFocus" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-20 23:07:45 +00:00
|
|
|
m_iChoice[p] = iNewChoice;
|
|
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
COMMAND( m_sprCursor[i][0], "Change" );
|
|
|
|
|
m_sprCursor[i][0].SetXY( GetCursorX((PlayerNumber)0,i), GetCursorY((PlayerNumber)0,i) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
COMMAND( m_sprCursor[i][p], "Change" );
|
|
|
|
|
m_sprCursor[i][p].SetXY( GetCursorX((PlayerNumber)p,i), GetCursorY((PlayerNumber)p,i) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_soundChange.Play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenSelectMaster::Page ScreenSelectMaster::GetPage( int iChoiceIndex )
|
|
|
|
|
{
|
|
|
|
|
if( iChoiceIndex < NUM_CHOICES_ON_PAGE_1 )
|
|
|
|
|
return PAGE_1;
|
|
|
|
|
else
|
|
|
|
|
return PAGE_2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenSelectMaster::Page ScreenSelectMaster::GetCurrentPage()
|
|
|
|
|
{
|
|
|
|
|
// Both players are guaranteed to be on the same page.
|
|
|
|
|
return GetPage( m_iChoice[GAMESTATE->m_MasterPlayerNumber] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ScreenSelectMaster::MenuStart( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
if( m_fLockInputSecs > 0 )
|
|
|
|
|
return;
|
|
|
|
|
if( m_bChosen[pn] == true )
|
|
|
|
|
return;
|
|
|
|
|
m_bChosen[pn] = true;
|
|
|
|
|
|
|
|
|
|
for( int page=0; page<NUM_PAGES; page++ )
|
|
|
|
|
OFF_COMMAND( m_sprMore[page] );
|
|
|
|
|
|
|
|
|
|
const ModeChoice& mc = m_aModeChoices[m_iChoice[pn]];
|
|
|
|
|
/* Don't play sound if we're on the second page and another player
|
|
|
|
|
* has already selected, since it just played. */
|
|
|
|
|
bool AnotherPlayerSelected = false;
|
|
|
|
|
int p;
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if(p != pn && m_bChosen[p])
|
|
|
|
|
AnotherPlayerSelected = true;
|
|
|
|
|
|
|
|
|
|
if(GetCurrentPage() != PAGE_2 || !AnotherPlayerSelected)
|
|
|
|
|
{
|
2003-11-04 21:07:36 +00:00
|
|
|
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(ssprintf("%s comment %s",m_sName.c_str(), mc.m_sName.c_str())) );
|
2003-06-20 23:07:45 +00:00
|
|
|
m_soundSelect.Play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( GetCurrentPage() == PAGE_2 )
|
|
|
|
|
{
|
|
|
|
|
// choose this for all the other players too
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsHumanPlayer(p) && !m_bChosen[p] )
|
|
|
|
|
MenuStart( (PlayerNumber)p );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float fSecs = 0;
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprCursor[i][pn], "Choose") );
|
|
|
|
|
|
|
|
|
|
bool bAllDone = true;
|
2003-11-05 18:49:57 +00:00
|
|
|
|
|
|
|
|
/* If SHARED_PREVIEW_AND_CURSOR, only one player has to pick. */
|
|
|
|
|
if( !SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
// check to see if everyone has chosen
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsHumanPlayer((PlayerNumber)p) )
|
|
|
|
|
bAllDone &= m_bChosen[p];
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-20 23:07:45 +00:00
|
|
|
if( bAllDone )
|
|
|
|
|
this->PostScreenMessage( SM_BeginFadingOut, fSecs );// tell our owner it's time to move on
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-05 18:49:57 +00:00
|
|
|
/*
|
|
|
|
|
* We want all items to always run OnCommand and either GainFocus or LoseFocus on
|
|
|
|
|
* tween-in. If we only run OnCommand, then it has to contain a copy of either
|
|
|
|
|
* GainFocus or LoseFocus, which implies that the default setting is hard-coded in
|
|
|
|
|
* the theme. Always run both.
|
|
|
|
|
*
|
|
|
|
|
* However, the actual tween-in is OnCommand; we don't always want to actually run
|
|
|
|
|
* through the Gain/LoseFocus tweens during initial tween-in. So, we run the focus
|
|
|
|
|
* command first, do a FinishTweening to pop it in place, and then run OnCommand.
|
|
|
|
|
* This means that the focus command should be position neutral; eg. only use "addx",
|
|
|
|
|
* not "x".
|
|
|
|
|
*/
|
2003-06-20 23:07:45 +00:00
|
|
|
float ScreenSelectMaster::TweenOnScreen()
|
|
|
|
|
{
|
|
|
|
|
float fSecs = 0;
|
|
|
|
|
|
|
|
|
|
for( unsigned c=0; c<m_aModeChoices.size(); c++ )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_ICON_PARTS; i++ )
|
2003-11-05 04:09:10 +00:00
|
|
|
{
|
2003-11-05 18:49:57 +00:00
|
|
|
COMMAND( m_sprIcon[i][c], (int(c) == m_iChoice[0])? "GainFocus":"LoseFocus" );
|
|
|
|
|
m_sprIcon[i][c]->FinishTweening();
|
2003-06-20 23:07:45 +00:00
|
|
|
fSecs = max( fSecs, SET_XY_AND_ON_COMMAND( m_sprIcon[i][c] ) );
|
2003-11-05 04:09:10 +00:00
|
|
|
}
|
2003-06-20 23:07:45 +00:00
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
int p=0;
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
{
|
2003-11-05 18:49:57 +00:00
|
|
|
COMMAND( m_sprPreview[i][c][p], (int(c) == m_iChoice[p])? "GainFocus":"LoseFocus" );
|
|
|
|
|
m_sprPreview[i][c][p]->FinishTweening();
|
2003-11-05 04:09:10 +00:00
|
|
|
fSecs = max( fSecs, SET_XY_AND_ON_COMMAND( m_sprPreview[i][c][p] ) );
|
2003-06-20 23:07:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsPlayerEnabled(p) )
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
{
|
2003-11-05 18:49:57 +00:00
|
|
|
COMMAND( m_sprPreview[i][c][p], int(c) == m_iChoice[p]? "GainFocus":"LoseFocus" );
|
|
|
|
|
m_sprPreview[i][c][p]->FinishTweening();
|
2003-11-05 04:09:10 +00:00
|
|
|
fSecs = max( fSecs, SET_XY_AND_ON_COMMAND( m_sprPreview[i][c][p] ) );
|
2003-06-20 23:07:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Need to SetXY of Cursor after Icons since it depends on the Icons' positions.
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
{
|
|
|
|
|
m_sprCursor[i][0].SetXY( GetCursorX((PlayerNumber)0,i), GetCursorY((PlayerNumber)0,i) );
|
|
|
|
|
fSecs = max( fSecs, ON_COMMAND( m_sprCursor[i][0] ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsPlayerEnabled(p) )
|
|
|
|
|
{
|
|
|
|
|
m_sprCursor[i][p].SetXY( GetCursorX((PlayerNumber)p,i), GetCursorY((PlayerNumber)p,i) );
|
|
|
|
|
fSecs = max( fSecs, ON_COMMAND( m_sprCursor[i][p] ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fSecs = max( fSecs, SET_XY_AND_ON_COMMAND( m_sprExplanation[GetCurrentPage()] ) );
|
|
|
|
|
fSecs = max( fSecs, SET_XY_AND_ON_COMMAND( m_sprMore[GetCurrentPage()] ) );
|
|
|
|
|
|
|
|
|
|
this->SortByZ();
|
|
|
|
|
|
|
|
|
|
return fSecs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float ScreenSelectMaster::TweenOffScreen()
|
|
|
|
|
{
|
|
|
|
|
float fSecs = 0;
|
|
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
fSecs = max( fSecs, OFF_COMMAND( m_sprCursor[i][0] ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_CURSOR_PARTS; i++ )
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsPlayerEnabled(p) )
|
|
|
|
|
fSecs = max( fSecs, OFF_COMMAND( m_sprCursor[i][p] ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( unsigned c=0; c<m_aModeChoices.size(); c++ )
|
|
|
|
|
{
|
|
|
|
|
if( GetPage(c) != GetCurrentPage() )
|
|
|
|
|
continue; // skip
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<NUM_ICON_PARTS; i++ )
|
2003-11-05 18:49:57 +00:00
|
|
|
{
|
2003-06-20 23:07:45 +00:00
|
|
|
fSecs = max( fSecs, OFF_COMMAND( m_sprIcon[i][c] ) );
|
2003-11-05 18:49:57 +00:00
|
|
|
bool SelectedByEitherPlayer = false;
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsPlayerEnabled(p) && m_iChoice[p] == (int)c )
|
|
|
|
|
SelectedByEitherPlayer = true;
|
|
|
|
|
|
|
|
|
|
if( SelectedByEitherPlayer )
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprIcon[i][c], "OffFocused" ) );
|
|
|
|
|
else
|
|
|
|
|
fSecs = max( fSecs, COMMAND( m_sprIcon[i][c], "OffUnfocused" ) );
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-20 23:07:45 +00:00
|
|
|
|
|
|
|
|
if( SHARED_PREVIEW_AND_CURSOR )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
fSecs = max( fSecs, OFF_COMMAND( m_sprPreview[i][c][0] ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<NUM_PREVIEW_PARTS; i++ )
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
if( GAMESTATE->IsPlayerEnabled(p) )
|
|
|
|
|
fSecs = max( fSecs, OFF_COMMAND( m_sprPreview[i][c][p] ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fSecs = max( fSecs, OFF_COMMAND( m_sprExplanation[GetCurrentPage()] ) );
|
|
|
|
|
fSecs = max( fSecs, OFF_COMMAND( m_sprMore[GetCurrentPage()] ) );
|
|
|
|
|
|
|
|
|
|
return fSecs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float ScreenSelectMaster::GetCursorX( PlayerNumber pn, int iPartIndex )
|
|
|
|
|
{
|
2003-11-05 04:09:10 +00:00
|
|
|
return m_sprIcon[0][m_iChoice[pn]]->GetX() + CURSOR_OFFSET_X_FROM_ICON(pn, iPartIndex);
|
2003-06-20 23:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float ScreenSelectMaster::GetCursorY( PlayerNumber pn, int iPartIndex )
|
|
|
|
|
{
|
2003-11-05 04:09:10 +00:00
|
|
|
return m_sprIcon[0][m_iChoice[pn]]->GetY() + CURSOR_OFFSET_Y_FROM_ICON(pn, iPartIndex);
|
2003-06-20 23:07:45 +00:00
|
|
|
}
|