2003-03-03 10:03:02 +00:00
|
|
|
#include "global.h"
|
2003-03-09 00:55:49 +00:00
|
|
|
#include "ScreenSelectStyle.h"
|
2003-03-03 10:03:02 +00:00
|
|
|
#include "GameManager.h"
|
2004-07-08 00:10:34 +00:00
|
|
|
#include "GameSoundManager.h"
|
2004-08-16 06:55:21 +00:00
|
|
|
#include "NetworkSyncManager.h"
|
2003-03-03 10:03:02 +00:00
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "GameState.h"
|
2003-04-01 19:46:13 +00:00
|
|
|
#include "AnnouncerManager.h"
|
2003-04-13 21:17:14 +00:00
|
|
|
#include "ActorUtil.h"
|
2003-11-16 04:45:12 +00:00
|
|
|
#include "LightsManager.h"
|
2004-07-17 22:15:39 +00:00
|
|
|
#include "CommonMetrics.h"
|
2005-01-26 11:21:43 +00:00
|
|
|
#include "Command.h"
|
2003-03-03 10:03:02 +00:00
|
|
|
|
|
|
|
|
|
2004-11-06 23:13:47 +00:00
|
|
|
#define ICON_GAIN_FOCUS_COMMAND THEME->GetMetricA(m_sName,"IconGainFocusCommand")
|
|
|
|
|
#define ICON_LOSE_FOCUS_COMMAND THEME->GetMetricA(m_sName,"IconLoseFocusCommand")
|
2003-10-15 22:09:53 +00:00
|
|
|
#define DISABLED_COLOR THEME->GetMetricC(m_sName,"DisabledColor")
|
2003-03-09 00:55:49 +00:00
|
|
|
|
|
|
|
|
|
2004-11-26 17:28:47 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenSelectStyle );
|
2003-09-27 22:30:51 +00:00
|
|
|
ScreenSelectStyle::ScreenSelectStyle( CString sClassName ) : ScreenSelect( sClassName )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
m_iSelection = 0;
|
|
|
|
|
|
2004-03-23 06:11:10 +00:00
|
|
|
LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
|
2003-11-16 04:45:12 +00:00
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=0; i<m_aGameCommands.size(); i++ )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
const GameCommand& mc = m_aGameCommands[i];
|
2003-03-03 10:03:02 +00:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Load icon
|
|
|
|
|
//
|
2005-02-06 03:32:53 +00:00
|
|
|
CString sIconPath = THEME->GetPathG(m_sName,ssprintf("icon%d",i+1));
|
2003-04-12 06:16:12 +00:00
|
|
|
|
|
|
|
|
m_textIcon[i].SetName( ssprintf("Icon%d",i+1) );
|
|
|
|
|
m_sprIcon[i].SetName( ssprintf("Icon%d",i+1) );
|
|
|
|
|
|
2003-03-03 10:03:02 +00:00
|
|
|
if( sIconPath.empty() ) // element doesn't exist
|
|
|
|
|
{
|
2005-02-06 03:32:53 +00:00
|
|
|
m_textIcon[i].LoadFromFont( THEME->GetPathF("Common","normal") );
|
2003-09-25 05:56:38 +00:00
|
|
|
m_textIcon[i].SetText( mc.m_sName );
|
2003-03-03 10:03:02 +00:00
|
|
|
m_textIcon[i].SetZoom(0.5f);
|
|
|
|
|
this->AddChild( &m_textIcon[i] );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_sprIcon[i].Load( sIconPath );
|
|
|
|
|
this->AddChild( &m_sprIcon[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2003-03-09 00:55:49 +00:00
|
|
|
// Load Picture
|
2003-03-03 10:03:02 +00:00
|
|
|
//
|
2005-02-06 03:32:53 +00:00
|
|
|
CString sPicturePath = THEME->GetPathG(m_sName, ssprintf("picture%d",i+1));
|
2003-03-09 00:55:49 +00:00
|
|
|
if( sPicturePath != "" )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprPicture[i].SetName( "Picture" );
|
2003-03-09 00:55:49 +00:00
|
|
|
m_sprPicture[i].Load( sPicturePath );
|
|
|
|
|
m_sprPicture[i].SetDiffuse( RageColor(1,1,1,0) );
|
|
|
|
|
this->AddChild( &m_sprPicture[i] );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Load info
|
|
|
|
|
//
|
2005-02-06 03:32:53 +00:00
|
|
|
CString sInfoPath = THEME->GetPathG(m_sName,ssprintf("info%d",i+1));
|
2003-03-03 10:03:02 +00:00
|
|
|
if( sInfoPath != "" )
|
|
|
|
|
{
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprInfo[i].SetName( "Info" );
|
2003-03-03 10:03:02 +00:00
|
|
|
m_sprInfo[i].Load( sInfoPath );
|
|
|
|
|
m_sprInfo[i].SetDiffuse( RageColor(1,1,1,0) );
|
|
|
|
|
this->AddChild( &m_sprInfo[i] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprWarning.SetName( "Warning" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprWarning.Load( THEME->GetPathG(m_sName,"warning") );
|
2003-03-09 00:55:49 +00:00
|
|
|
this->AddChild( &m_sprWarning );
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprExplanation.SetName( "Explanation" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprExplanation.Load( THEME->GetPathG(m_sName,"explanation") );
|
2003-03-09 00:55:49 +00:00
|
|
|
this->AddChild( &m_sprExplanation );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fix Z ordering of Picture and Info so that they draw on top
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=0; i<this->m_aGameCommands.size(); i++ )
|
2003-03-09 00:55:49 +00:00
|
|
|
this->MoveToTail( &m_sprPicture[i] );
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=0; i<this->m_aGameCommands.size(); i++ )
|
2003-03-03 10:03:02 +00:00
|
|
|
this->MoveToTail( &m_sprInfo[i] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this->UpdateSelectableChoices();
|
|
|
|
|
|
2003-11-09 08:55:21 +00:00
|
|
|
m_sprPremium.SetName( "Premium" );
|
2003-04-14 03:26:53 +00:00
|
|
|
|
2004-06-09 08:14:21 +00:00
|
|
|
switch( PREFSMAN->GetPremium() )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2005-01-04 10:51:25 +00:00
|
|
|
case PREMIUM_DOUBLES:
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprPremium.Load( THEME->GetPathG(m_sName,"doubles premium") );
|
2003-11-09 08:55:21 +00:00
|
|
|
this->AddChild( &m_sprPremium );
|
|
|
|
|
break;
|
2005-01-04 10:51:25 +00:00
|
|
|
case PREMIUM_JOINT:
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprPremium.Load( THEME->GetPathG(m_sName,"joint premium") );
|
2003-11-09 08:55:21 +00:00
|
|
|
this->AddChild( &m_sprPremium );
|
|
|
|
|
break;
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-02-06 03:32:53 +00:00
|
|
|
m_soundChange.Load( THEME->GetPathS(m_sName,"change"), true );
|
2003-03-03 10:03:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// TweenOnScreen
|
|
|
|
|
//
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=0; i<m_aGameCommands.size(); i++ )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2003-04-12 06:16:12 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( m_textIcon[i] );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_sprIcon[i] );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
2003-04-12 06:16:12 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( m_sprExplanation );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_sprWarning );
|
2003-11-09 08:55:21 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( m_sprPremium );
|
2003-03-03 10:03:02 +00:00
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
// let AfterChange tween Picture and Info
|
2004-05-02 03:01:27 +00:00
|
|
|
this->SortByDrawOrder();
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectStyle::MenuLeft( PlayerNumber pn )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
int iSwitchToIndex = -1; // -1 means none found
|
|
|
|
|
for( int i=m_iSelection-1; i>=0; i-- )
|
|
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
if( m_aGameCommands[i].IsPlayable() )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
iSwitchToIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( iSwitchToIndex == -1 )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
BeforeChange();
|
|
|
|
|
m_iSelection = iSwitchToIndex;
|
|
|
|
|
m_soundChange.Play();
|
|
|
|
|
AfterChange();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectStyle::MenuRight( PlayerNumber pn )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
int iSwitchToIndex = -1; // -1 means none found
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=m_iSelection+1; i<m_aGameCommands.size(); i++ )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
if( m_aGameCommands[i].IsPlayable() )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
iSwitchToIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( iSwitchToIndex == -1 )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
BeforeChange();
|
|
|
|
|
m_iSelection = iSwitchToIndex;
|
|
|
|
|
m_soundChange.Play();
|
|
|
|
|
AfterChange();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectStyle::MenuStart( PlayerNumber pn )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2004-06-29 19:30:45 +00:00
|
|
|
/* Stop all tweens where they are, since we might have selected before
|
|
|
|
|
* we finished tweening in. */
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
m_SubActors[i]->StopTweening();
|
|
|
|
|
|
2004-05-01 23:28:53 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
2004-04-25 23:36:00 +00:00
|
|
|
SCREENMAN->SendMessageToTopScreen( SM_AllDoneChoosing );
|
2003-03-03 10:03:02 +00:00
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
const GameCommand& mc = m_aGameCommands[GetSelectionIndex(pn)];
|
2003-10-15 22:09:53 +00:00
|
|
|
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(ssprintf("%s comment %s",m_sName.c_str(),mc.m_sName.c_str())) );
|
2003-04-01 19:46:13 +00:00
|
|
|
|
2003-03-03 10:03:02 +00:00
|
|
|
//
|
|
|
|
|
// TweenOffScreen
|
|
|
|
|
//
|
2003-03-04 22:56:51 +00:00
|
|
|
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=0; i<m_aGameCommands.size(); i++ )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2003-04-12 06:16:12 +00:00
|
|
|
OFF_COMMAND( m_sprIcon[i] );
|
|
|
|
|
OFF_COMMAND( m_textIcon[i] );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
2003-04-12 06:16:12 +00:00
|
|
|
OFF_COMMAND( m_sprExplanation );
|
|
|
|
|
OFF_COMMAND( m_sprWarning );
|
|
|
|
|
OFF_COMMAND( m_sprPicture[m_iSelection] );
|
|
|
|
|
OFF_COMMAND( m_sprInfo[m_iSelection] );
|
2003-11-09 08:55:21 +00:00
|
|
|
OFF_COMMAND( m_sprPremium );
|
2003-03-03 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
int ScreenSelectStyle::GetSelectionIndex( PlayerNumber pn )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
return m_iSelection;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectStyle::UpdateSelectableChoices()
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=0; i<m_aGameCommands.size(); i++ )
|
2003-03-03 10:03:02 +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_aGameCommands[i].IsPlayable() )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
m_sprIcon[i].SetDiffuse( RageColor(1,1,1,1) );
|
|
|
|
|
m_textIcon[i].SetDiffuse( RageColor(0.5f,0.5f,0.5f,1) ); // gray so glow is visible
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_sprIcon[i].SetDiffuse( DISABLED_COLOR );
|
|
|
|
|
m_textIcon[i].SetDiffuse( DISABLED_COLOR );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-04 22:49:46 +00:00
|
|
|
// Select the first enabled choice.
|
2003-03-03 10:03:02 +00:00
|
|
|
BeforeChange();
|
|
|
|
|
|
|
|
|
|
int iSwitchToStyleIndex = -1; // -1 means none found
|
2004-12-02 06:29:20 +00:00
|
|
|
for( unsigned i=0; i<m_aGameCommands.size(); i++ )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2004-12-02 06:29:20 +00:00
|
|
|
const GameCommand& mc = m_aGameCommands[i];
|
2003-11-26 06:40:03 +00:00
|
|
|
if( mc.IsPlayable() )
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
iSwitchToStyleIndex = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-06-04 22:49:46 +00:00
|
|
|
|
2003-11-26 06:40:03 +00:00
|
|
|
if( iSwitchToStyleIndex == -1 )// no styles are enabled. We're stuck!
|
|
|
|
|
{
|
|
|
|
|
DEBUG_ASSERT(0);
|
|
|
|
|
SCREENMAN->SystemMessage( "No Styles are selectable." );
|
2004-07-17 22:15:39 +00:00
|
|
|
SCREENMAN->SetNewScreen( INITIAL_SCREEN );
|
2003-11-26 06:40:03 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 10:03:02 +00:00
|
|
|
|
|
|
|
|
m_iSelection = iSwitchToStyleIndex;
|
|
|
|
|
AfterChange();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectStyle::BeforeChange()
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
|
|
|
|
// dim/hide old selection
|
2004-12-03 05:19:46 +00:00
|
|
|
m_sprIcon[m_iSelection].RunCommands( ICON_LOSE_FOCUS_COMMAND );
|
|
|
|
|
m_textIcon[m_iSelection].RunCommands( ICON_LOSE_FOCUS_COMMAND );
|
2003-03-09 00:55:49 +00:00
|
|
|
m_sprPicture[m_iSelection].StopTweening();
|
2003-03-03 10:03:02 +00:00
|
|
|
m_sprInfo[m_iSelection].StopTweening();
|
2003-03-09 00:55:49 +00:00
|
|
|
m_sprPicture[m_iSelection].SetDiffuse( RageColor(1,1,1,0) );
|
2003-03-03 10:03:02 +00:00
|
|
|
m_sprInfo[m_iSelection].SetDiffuse( RageColor(1,1,1,0) );
|
2003-03-09 00:55:49 +00:00
|
|
|
m_sprPicture[m_iSelection].SetGlow( RageColor(1,1,1,0) );
|
2003-03-03 10:03:02 +00:00
|
|
|
m_sprInfo[m_iSelection].SetGlow( RageColor(1,1,1,0) );
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
void ScreenSelectStyle::AfterChange()
|
2003-03-03 10:03:02 +00:00
|
|
|
{
|
2004-12-03 05:19:46 +00:00
|
|
|
m_sprIcon[m_iSelection].RunCommands( ICON_GAIN_FOCUS_COMMAND );
|
|
|
|
|
m_textIcon[m_iSelection].RunCommands( ICON_GAIN_FOCUS_COMMAND );
|
2003-03-09 00:55:49 +00:00
|
|
|
m_sprPicture[m_iSelection].SetDiffuse( RageColor(1,1,1,1) );
|
2003-03-03 10:03:02 +00:00
|
|
|
m_sprInfo[m_iSelection].SetDiffuse( RageColor(1,1,1,1) );
|
2003-03-09 00:55:49 +00:00
|
|
|
m_sprPicture[m_iSelection].SetZoom( 1 );
|
2003-03-03 10:03:02 +00:00
|
|
|
m_sprInfo[m_iSelection].SetZoom( 1 );
|
2003-04-12 06:16:12 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( m_sprPicture[m_iSelection] );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_sprInfo[m_iSelection] );
|
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.
|
|
|
|
|
*/
|