2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-07-31 22:37:58 +00:00
|
|
|
Class: ScreenOptions
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-07-31 22:37:58 +00:00
|
|
|
Desc: See header.
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-07-31 22:37:58 +00:00
|
|
|
Chris Danford
|
2003-06-16 17:34:20 +00:00
|
|
|
Glenn Maynard
|
2002-05-20 08:59:37 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ScreenOptions.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "RageLog.h"
|
2002-08-13 23:26:46 +00:00
|
|
|
#include "GameState.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-03-31 14:02:39 +00:00
|
|
|
const float ITEM_X[NUM_PLAYERS] = { 260, 420 };
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-09-03 06:33:08 +00:00
|
|
|
#define ICONS_X( p ) THEME->GetMetricF("ScreenOptions",ssprintf("IconsP%dX",p+1))
|
2002-09-04 03:49:08 +00:00
|
|
|
#define ARROWS_X THEME->GetMetricF("ScreenOptions","ArrowsX")
|
2002-09-03 06:33:08 +00:00
|
|
|
#define LABELS_X THEME->GetMetricF("ScreenOptions","LabelsX")
|
2002-09-04 03:49:08 +00:00
|
|
|
#define LABELS_ZOOM THEME->GetMetricF("ScreenOptions","LabelsZoom")
|
|
|
|
|
#define LABELS_H_ALIGN THEME->GetMetricI("ScreenOptions","LabelsHAlign")
|
|
|
|
|
#define ITEMS_ZOOM THEME->GetMetricF("ScreenOptions","ItemsZoom")
|
2002-09-03 06:33:08 +00:00
|
|
|
#define ITEMS_START_X THEME->GetMetricF("ScreenOptions","ItemsStartX")
|
|
|
|
|
#define ITEMS_GAP_X THEME->GetMetricF("ScreenOptions","ItemsGapX")
|
|
|
|
|
#define ITEMS_START_Y THEME->GetMetricF("ScreenOptions","ItemsStartY")
|
|
|
|
|
#define ITEMS_SPACING_Y THEME->GetMetricF("ScreenOptions","ItemsSpacingY")
|
2002-09-10 21:16:34 +00:00
|
|
|
#define EXPLANATION_X THEME->GetMetricF("ScreenOptions","ExplanationX")
|
|
|
|
|
#define EXPLANATION_Y THEME->GetMetricF("ScreenOptions","ExplanationY")
|
|
|
|
|
#define EXPLANATION_ZOOM THEME->GetMetricF("ScreenOptions","ExplanationZoom")
|
2002-09-04 03:49:08 +00:00
|
|
|
#define COLOR_SELECTED THEME->GetMetricC("ScreenOptions","ColorSelected")
|
|
|
|
|
#define COLOR_NOT_SELECTED THEME->GetMetricC("ScreenOptions","ColorNotSelected")
|
2003-07-20 22:21:00 +00:00
|
|
|
#define NUM_SHOWN_ITEMS THEME->GetMetricI("ScreenOptions","NumShownItems")
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
ScreenOptions::ScreenOptions( CString sClassName, bool bEnableTimer ) : Screen("ScreenOptions")
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenOptions::ScreenOptions()" );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sName = sClassName;
|
2003-03-15 19:25:37 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_SoundChangeCol.Load( THEME->GetPathToS("ScreenOptions change") );
|
|
|
|
|
m_SoundNextRow.Load( THEME->GetPathToS("ScreenOptions next") );
|
|
|
|
|
m_SoundPrevRow.Load( THEME->GetPathToS("ScreenOptions prev") );
|
|
|
|
|
m_SoundStart.Load( THEME->GetPathToS("Common start") );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
m_Menu.Load( sClassName, bEnableTimer, false ); // no style icon
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_Menu );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
// add everything to m_framePage so we can animate everything at once
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_framePage );
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_sprPage.Load( THEME->GetPathToG(sClassName+" page") );
|
2002-08-13 23:26:46 +00:00
|
|
|
m_sprPage.SetXY( CENTER_X, CENTER_Y );
|
2002-09-02 21:59:58 +00:00
|
|
|
m_framePage.AddChild( &m_sprPage );
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
{
|
|
|
|
|
m_iCurrentRow[p] = 0;
|
|
|
|
|
|
2002-11-16 20:21:00 +00:00
|
|
|
for( unsigned l=0; l<MAX_OPTION_LINES; l++ )
|
2002-05-20 08:59:37 +00:00
|
|
|
m_iSelectedOption[p][l] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
m_framePage.SetX( SCREEN_LEFT-SCREEN_WIDTH );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_framePage.BeginTweening( 0.3f, Actor::TWEEN_DECELERATE );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_framePage.SetX( 0 );
|
2003-03-31 23:03:43 +00:00
|
|
|
memset(&m_bRowIsLong, 0, sizeof(m_bRowIsLong));
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
void ScreenOptions::Init( InputMode im, OptionRow OptionRow[], int iNumOptionLines, bool bLoadExplanations )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenOptions::Set()" );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
m_InputMode = im;
|
2003-03-15 19:25:37 +00:00
|
|
|
m_OptionRow = OptionRow;
|
2002-09-04 03:49:08 +00:00
|
|
|
m_iNumOptionRows = iNumOptionLines;
|
2003-03-15 19:25:37 +00:00
|
|
|
m_bLoadExplanations = bLoadExplanations;
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
this->ImportOptions();
|
2003-08-23 22:04:57 +00:00
|
|
|
for( unsigned l=0; l<MAX_OPTION_LINES; l++ )
|
|
|
|
|
if( m_OptionRow[l].bOneChoiceForAllPlayers )
|
2002-08-13 23:26:46 +00:00
|
|
|
m_iSelectedOption[PLAYER_2][l] = m_iSelectedOption[PLAYER_1][l];
|
2003-08-23 22:04:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int p;
|
|
|
|
|
|
|
|
|
|
// init highlights
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
{
|
|
|
|
|
if( !GAMESTATE->IsHumanPlayer(p) )
|
|
|
|
|
continue; // skip
|
|
|
|
|
|
|
|
|
|
m_Highlight[p].Load( (PlayerNumber)p, false );
|
|
|
|
|
m_framePage.AddChild( &m_Highlight[p] );
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
// init underlines
|
|
|
|
|
for( p=0; p<NUM_PLAYERS; p++ )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2003-04-10 05:46:31 +00:00
|
|
|
if( !GAMESTATE->IsHumanPlayer(p) )
|
2002-08-13 23:26:46 +00:00
|
|
|
continue; // skip
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
for( int l=0; l<m_iNumOptionRows; l++ )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2002-09-03 22:31:06 +00:00
|
|
|
m_OptionIcons[p][l].Load( (PlayerNumber)p, "", false );
|
2002-09-03 06:33:08 +00:00
|
|
|
m_framePage.AddChild( &m_OptionIcons[p][l] );
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
m_Underline[p][l].Load( (PlayerNumber)p, true );
|
|
|
|
|
m_framePage.AddChild( &m_Underline[p][l] );
|
|
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// init text
|
2003-08-23 22:04:57 +00:00
|
|
|
int r;
|
|
|
|
|
for( r=0; r<m_iNumOptionRows; r++ ) // foreach line
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2003-08-23 22:04:57 +00:00
|
|
|
m_framePage.AddChild( &m_sprBullets[r] );
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
m_framePage.AddChild( &m_textTitles[r] );
|
2002-09-04 03:49:08 +00:00
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
int iNumChoices = min( m_OptionRow[r].choices.size(), MAX_VISIBLE_VALUES_PER_LINE );
|
|
|
|
|
for( unsigned c=0; c<iNumChoices; c++ )
|
|
|
|
|
{
|
|
|
|
|
m_framePage.AddChild( &m_textItems[r][c] );
|
|
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
// TRICKY: Add one more item. This will be "EXIT"
|
2003-08-23 22:04:57 +00:00
|
|
|
m_framePage.AddChild( &m_textItems[r][0] );
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2002-09-10 21:16:34 +00:00
|
|
|
// add explanation here so it appears on top
|
2003-04-12 17:39:27 +00:00
|
|
|
m_textExplanation.LoadFromFont( THEME->GetPathToF("ScreenOptions explanation") );
|
2002-09-10 21:16:34 +00:00
|
|
|
m_textExplanation.SetXY( EXPLANATION_X, EXPLANATION_Y );
|
|
|
|
|
m_textExplanation.SetZoom( EXPLANATION_ZOOM );
|
2003-06-15 17:45:26 +00:00
|
|
|
m_textExplanation.SetShadowLength( 0 );
|
2002-09-10 21:16:34 +00:00
|
|
|
m_framePage.AddChild( &m_textExplanation );
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
InitOptionsText();
|
2003-06-16 03:29:59 +00:00
|
|
|
PositionItems();
|
2002-05-20 08:59:37 +00:00
|
|
|
PositionUnderlines();
|
2002-09-03 06:33:08 +00:00
|
|
|
PositionIcons();
|
2002-09-03 22:31:06 +00:00
|
|
|
RefreshIcons();
|
2002-09-04 03:49:08 +00:00
|
|
|
PositionCursors();
|
|
|
|
|
UpdateEnabledDisabled();
|
2002-09-10 21:16:34 +00:00
|
|
|
OnChange();
|
2003-06-16 17:34:20 +00:00
|
|
|
|
|
|
|
|
/* It's tweening into position, but on the initial tween-in we only want to
|
|
|
|
|
* tween in the whole page at once. Since the tweens are nontrivial, it's
|
|
|
|
|
* easiest to queue the tweens and then force them to finish. */
|
2003-08-23 22:04:57 +00:00
|
|
|
for( r=0; r<m_iNumOptionRows; r++ ) // foreach options row
|
2003-06-16 17:34:20 +00:00
|
|
|
{
|
2003-08-23 22:04:57 +00:00
|
|
|
m_textTitles[r].FinishTweening();
|
|
|
|
|
m_sprBullets[r].FinishTweening();
|
|
|
|
|
for( unsigned c=0; c<m_OptionRow[r].choices.size(); c++ )
|
|
|
|
|
m_textItems[r][c].FinishTweening();
|
2003-06-16 17:34:20 +00:00
|
|
|
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ ) // foreach player
|
|
|
|
|
{
|
2003-08-23 22:04:57 +00:00
|
|
|
m_Underline[p][r].FinishTweening();
|
|
|
|
|
m_OptionIcons[p][r].FinishTweening();
|
2003-06-16 17:34:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenOptions::~ScreenOptions()
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenOptions::~ScreenOptions()" );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenOptions::GetWidthXY( PlayerNumber pn, int iRow, int &iWidthOut, int &iXOut, int &iYOut )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-03-31 14:02:39 +00:00
|
|
|
bool bExitRow = iRow == m_iNumOptionRows;
|
2003-03-31 23:03:43 +00:00
|
|
|
bool bLotsOfOptions = m_bRowIsLong[iRow];
|
2003-03-31 14:02:39 +00:00
|
|
|
int iOptionInRow = bExitRow ? 0 : bLotsOfOptions ? pn : m_iSelectedOption[pn][iRow];
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-03-31 14:02:39 +00:00
|
|
|
BitmapText &text = m_textItems[iRow][iOptionInRow];
|
|
|
|
|
|
|
|
|
|
iWidthOut = int(roundf( text.GetWidestLineWidthInSourcePixels() * text.GetZoomX() ));
|
2003-06-16 03:29:59 +00:00
|
|
|
iXOut = int(roundf( text.GetDestX() ));
|
|
|
|
|
/* We update m_fRowY, change colors and tween items, and then tween rows to
|
|
|
|
|
* their final positions. (This is so we don't tween colors, too.) m_fRowY
|
|
|
|
|
* is the actual destination position, even though we may not have set up the
|
|
|
|
|
* tween yet. */
|
|
|
|
|
iYOut = int(roundf( m_fRowY[iRow] ));
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenOptions::InitOptionsText()
|
|
|
|
|
{
|
2003-03-31 14:02:39 +00:00
|
|
|
// init m_textItems from optionLines
|
2002-11-16 20:21:00 +00:00
|
|
|
int i;
|
|
|
|
|
for( i=0; i<m_iNumOptionRows; i++ ) // foreach options line
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-03-15 19:25:37 +00:00
|
|
|
OptionRow &optline = m_OptionRow[i];
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-06-16 03:29:59 +00:00
|
|
|
const float fY = ITEMS_START_Y + ITEMS_SPACING_Y*i;
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-03-31 14:02:39 +00:00
|
|
|
BitmapText &title = m_textTitles[i];
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
title.LoadFromFont( THEME->GetPathToF("ScreenOptions title") );
|
2003-03-15 19:25:37 +00:00
|
|
|
CString sText = optline.name;
|
2002-09-04 22:57:40 +00:00
|
|
|
|
2002-09-03 06:33:08 +00:00
|
|
|
title.SetText( sText );
|
2002-06-14 22:25:22 +00:00
|
|
|
title.SetXY( LABELS_X, fY );
|
2002-09-04 03:49:08 +00:00
|
|
|
title.SetZoom( LABELS_ZOOM );
|
|
|
|
|
title.SetHorizAlign( (Actor::HorizAlign)LABELS_H_ALIGN );
|
2002-05-20 08:59:37 +00:00
|
|
|
title.SetVertAlign( Actor::align_middle );
|
2003-03-02 01:43:33 +00:00
|
|
|
title.EnableShadow( false );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
|
2003-03-31 14:02:39 +00:00
|
|
|
Sprite &bullet = m_sprBullets[i];
|
2003-04-12 17:39:27 +00:00
|
|
|
bullet.Load( THEME->GetPathToG("ScreenOptions bullet") );
|
2003-03-31 14:02:39 +00:00
|
|
|
bullet.SetXY( ARROWS_X, fY );
|
2002-09-04 03:49:08 +00:00
|
|
|
|
|
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
// init all text in this line and count the width of the line
|
2003-03-31 23:03:43 +00:00
|
|
|
float fX = ITEMS_START_X; // indent 70 pixels
|
|
|
|
|
for( unsigned j=0; j<optline.choices.size(); j++ ) // for each option on this line
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-03-31 23:03:43 +00:00
|
|
|
BitmapText &option = m_textItems[i][j];
|
|
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
option.LoadFromFont( THEME->GetPathToF("ScreenOptions item") );
|
2003-03-31 23:03:43 +00:00
|
|
|
option.SetText( optline.choices[j] );
|
|
|
|
|
option.SetZoom( ITEMS_ZOOM );
|
|
|
|
|
option.EnableShadow( false );
|
|
|
|
|
|
|
|
|
|
// set the XY position of each item in the line
|
|
|
|
|
float fItemWidth = option.GetWidestLineWidthInSourcePixels() * option.GetZoomX();
|
|
|
|
|
fX += fItemWidth/2;
|
|
|
|
|
option.SetXY( fX, fY );
|
|
|
|
|
fX += fItemWidth/2 + ITEMS_GAP_X;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_bRowIsLong[i] = fX > SCREEN_RIGHT-40; // goes off edge of screen
|
|
|
|
|
|
|
|
|
|
if( m_bRowIsLong[i] )
|
|
|
|
|
{
|
|
|
|
|
// re-init with "long row" style
|
2003-08-24 18:35:48 +00:00
|
|
|
unsigned j;
|
|
|
|
|
for( j=0; j<optline.choices.size(); j++ ) // for each option on this line
|
2003-03-31 23:03:43 +00:00
|
|
|
m_textItems[i][j].SetText( "" );
|
|
|
|
|
|
2003-03-31 14:02:39 +00:00
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
|
|
|
|
{
|
2003-04-22 00:27:52 +00:00
|
|
|
if( !GAMESTATE->IsHumanPlayer(p) )
|
|
|
|
|
continue;
|
2003-03-31 14:02:39 +00:00
|
|
|
|
2003-04-22 00:27:52 +00:00
|
|
|
BitmapText &option = m_textItems[i][p];
|
2003-03-31 14:02:39 +00:00
|
|
|
|
2003-04-22 00:27:52 +00:00
|
|
|
const int iChoiceInRow = m_iSelectedOption[p][i];
|
2003-03-31 14:02:39 +00:00
|
|
|
|
2003-04-22 00:27:52 +00:00
|
|
|
option.LoadFromFont( THEME->GetPathToF("ScreenOptions item") );
|
|
|
|
|
option.SetText( m_OptionRow[i].choices[iChoiceInRow] );
|
|
|
|
|
option.SetZoom( ITEMS_ZOOM );
|
|
|
|
|
option.EnableShadow( false );
|
2003-03-31 14:02:39 +00:00
|
|
|
|
2003-05-21 01:58:47 +00:00
|
|
|
option.SetY( fY );
|
2003-08-23 22:04:57 +00:00
|
|
|
|
|
|
|
|
/* if choices are locked together, center the item. */
|
|
|
|
|
if( optline.bOneChoiceForAllPlayers )
|
2003-05-21 01:58:47 +00:00
|
|
|
option.SetX( (ITEM_X[0]+ITEM_X[1])/2 );
|
|
|
|
|
else
|
|
|
|
|
option.SetX( ITEM_X[p] );
|
2003-04-22 00:27:52 +00:00
|
|
|
|
2003-08-23 22:13:06 +00:00
|
|
|
UpdateText( (PlayerNumber)p, j );
|
2003-03-31 14:02:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
2002-09-04 03:49:08 +00:00
|
|
|
|
2003-03-31 14:02:39 +00:00
|
|
|
BitmapText &option = m_textItems[i][0];
|
2003-04-12 17:39:27 +00:00
|
|
|
option.LoadFromFont( THEME->GetPathToF("ScreenOptions item") );
|
2002-09-04 03:49:08 +00:00
|
|
|
option.SetText( "EXIT" );
|
|
|
|
|
option.SetZoom( ITEMS_ZOOM );
|
2003-06-15 17:45:26 +00:00
|
|
|
option.SetShadowLength( 0 );
|
2003-06-16 03:29:59 +00:00
|
|
|
float fY = ITEMS_START_Y + ITEMS_SPACING_Y*i;
|
2002-09-04 03:49:08 +00:00
|
|
|
option.SetXY( CENTER_X, fY );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenOptions::PositionUnderlines()
|
|
|
|
|
{
|
|
|
|
|
// Set the position of the underscores showing the current choice for each option line.
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ ) // foreach player
|
|
|
|
|
{
|
2002-09-04 03:49:08 +00:00
|
|
|
for( int i=0; i<m_iNumOptionRows; i++ ) // foreach options line
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
OptionsCursor &underline = m_Underline[p][i];
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-06-16 20:01:18 +00:00
|
|
|
/* Don't tween X movement and color changes. */
|
2003-06-16 03:29:59 +00:00
|
|
|
int iWidth, iX, iY;
|
|
|
|
|
GetWidthXY( (PlayerNumber)p, i, iWidth, iX, iY );
|
2003-06-16 20:01:18 +00:00
|
|
|
underline.SetGlobalX( (float)iX );
|
|
|
|
|
underline.SetGlobalDiffuseColor( RageColor(1,1,1, 1.0f) );
|
2003-06-16 03:29:59 +00:00
|
|
|
|
2003-02-01 01:11:00 +00:00
|
|
|
// If there's only one choice (ScreenOptionsMenu), don't show underlines.
|
|
|
|
|
// It looks silly.
|
2003-03-15 19:25:37 +00:00
|
|
|
bool bOnlyOneChoice = m_OptionRow[i].choices.size() == 1;
|
2003-06-16 03:29:59 +00:00
|
|
|
bool hidden = bOnlyOneChoice || m_bRowIsHidden[i];
|
2003-02-01 01:11:00 +00:00
|
|
|
|
2003-06-16 20:01:18 +00:00
|
|
|
if( underline.GetDestY() != m_fRowY[i] )
|
|
|
|
|
{
|
|
|
|
|
underline.StopTweening();
|
|
|
|
|
underline.BeginTweening( 0.3f );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XXX: diffuse doesn't work since underline is an ActorFrame */
|
2003-06-16 03:29:59 +00:00
|
|
|
underline.SetDiffuse( RageColor(1,1,1,hidden? 0.0f:1.0f) );
|
2002-08-13 23:26:46 +00:00
|
|
|
underline.SetBarWidth( iWidth );
|
2003-06-16 03:29:59 +00:00
|
|
|
underline.SetY( (float)iY );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-03 06:33:08 +00:00
|
|
|
void ScreenOptions::PositionIcons()
|
|
|
|
|
{
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ ) // foreach player
|
|
|
|
|
{
|
2002-09-04 03:49:08 +00:00
|
|
|
for( int i=0; i<m_iNumOptionRows; i++ ) // foreach options line
|
2002-09-03 06:33:08 +00:00
|
|
|
{
|
|
|
|
|
OptionIcon &icon = m_OptionIcons[p][i];
|
|
|
|
|
|
2003-03-31 14:02:39 +00:00
|
|
|
int iWidth, iX, iY; // We only use iY
|
2002-09-03 06:33:08 +00:00
|
|
|
GetWidthXY( (PlayerNumber)p, i, iWidth, iX, iY );
|
2003-06-16 03:29:59 +00:00
|
|
|
icon.SetX( ICONS_X(p) );
|
2003-06-16 20:01:18 +00:00
|
|
|
|
|
|
|
|
if( icon.GetDestY() != m_fRowY[i] )
|
|
|
|
|
{
|
|
|
|
|
icon.StopTweening();
|
|
|
|
|
icon.BeginTweening( 0.3f );
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-16 03:29:59 +00:00
|
|
|
icon.SetY( (float)iY );
|
2003-06-16 20:01:18 +00:00
|
|
|
/* XXX: this doesn't work since icon is an ActorFrame */
|
2003-06-16 03:29:59 +00:00
|
|
|
icon.SetDiffuse( RageColor(1,1,1, m_bRowIsHidden[i]? 0.0f:1.0f) );
|
2002-09-03 06:33:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-03 22:31:06 +00:00
|
|
|
void ScreenOptions::RefreshIcons()
|
|
|
|
|
{
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ ) // foreach player
|
|
|
|
|
{
|
2003-04-21 02:41:10 +00:00
|
|
|
if( !GAMESTATE->IsHumanPlayer(p) )
|
|
|
|
|
continue;
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
for( int i=0; i<m_iNumOptionRows; i++ ) // foreach options line
|
2002-09-03 22:31:06 +00:00
|
|
|
{
|
2003-08-23 22:04:57 +00:00
|
|
|
OptionRow &row = m_OptionRow[i];
|
2002-09-03 22:31:06 +00:00
|
|
|
OptionIcon &icon = m_OptionIcons[p][i];
|
|
|
|
|
|
|
|
|
|
int iSelection = m_iSelectedOption[p][i];
|
2003-06-24 07:39:37 +00:00
|
|
|
if( iSelection >= (int)m_OptionRow[i].choices.size() )
|
|
|
|
|
{
|
|
|
|
|
/* Invalid selection. Send debug output, to aid debugging. */
|
|
|
|
|
CString error = ssprintf("Option row with name \"%s\" selects item %i, but there are only %i items:\n",
|
|
|
|
|
m_OptionRow[i].name.c_str(),
|
|
|
|
|
iSelection, m_OptionRow[i].choices.size() );
|
|
|
|
|
|
|
|
|
|
for( unsigned j = 0; j < m_OptionRow[i].choices.size(); ++j )
|
|
|
|
|
error += ssprintf(" %s\n", m_OptionRow[i].choices[j].c_str());
|
|
|
|
|
|
2003-08-16 18:36:19 +00:00
|
|
|
RageException::Throw( "%s", error.c_str() );
|
2003-06-24 07:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
CString sSelection = row.choices[iSelection];
|
2002-09-04 03:49:08 +00:00
|
|
|
if( sSelection == "ON" )
|
2003-03-15 19:25:37 +00:00
|
|
|
sSelection = m_OptionRow[i].name;
|
2003-08-23 22:04:57 +00:00
|
|
|
if( row.bOneChoiceForAllPlayers )
|
|
|
|
|
icon.Load( (PlayerNumber)p, "", false );
|
|
|
|
|
else
|
|
|
|
|
icon.Load( (PlayerNumber)p, sSelection, false );
|
2002-09-03 22:31:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-03 06:33:08 +00:00
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenOptions::PositionCursors()
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
|
|
|
|
// Set the position of the highlight showing the current option the user is changing.
|
|
|
|
|
// Set the position of the underscores showing the current choice for each option line.
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ ) // foreach player
|
|
|
|
|
{
|
|
|
|
|
int i=m_iCurrentRow[p];
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
OptionsCursor &highlight = m_Highlight[p];
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
int iWidth, iX, iY;
|
|
|
|
|
GetWidthXY( (PlayerNumber)p, i, iWidth, iX, iY );
|
|
|
|
|
highlight.SetBarWidth( iWidth );
|
|
|
|
|
highlight.SetXY( (float)iX, (float)iY );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenOptions::TweenCursor( PlayerNumber player_no )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
|
|
|
|
// Set the position of the highlight showing the current option the user is changing.
|
|
|
|
|
int iCurRow = m_iCurrentRow[player_no];
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
OptionsCursor &highlight = m_Highlight[player_no];
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
int iWidth, iX, iY;
|
|
|
|
|
GetWidthXY( player_no, iCurRow, iWidth, iX, iY );
|
2003-03-31 14:02:39 +00:00
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
highlight.StopTweening();
|
2002-05-20 08:59:37 +00:00
|
|
|
highlight.BeginTweening( 0.2f );
|
2002-08-13 23:26:46 +00:00
|
|
|
highlight.TweenBarWidth( iWidth );
|
2003-04-12 06:16:12 +00:00
|
|
|
highlight.SetXY( (float)iX, (float)iY );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-28 07:38:09 +00:00
|
|
|
void ScreenOptions::UpdateText( PlayerNumber player_no, int iRow )
|
2003-03-31 14:02:39 +00:00
|
|
|
{
|
2003-08-28 07:38:09 +00:00
|
|
|
int iChoiceInRow = m_iSelectedOption[player_no][iRow];
|
2003-03-31 14:02:39 +00:00
|
|
|
|
2003-08-28 07:38:09 +00:00
|
|
|
bool bLotsOfOptions = m_bRowIsLong[iRow];
|
|
|
|
|
|
|
|
|
|
OptionRow &row = m_OptionRow[iRow];
|
2003-03-31 14:02:39 +00:00
|
|
|
|
|
|
|
|
if( bLotsOfOptions )
|
2003-08-28 07:38:09 +00:00
|
|
|
m_textItems[iRow][row.bOneChoiceForAllPlayers?0:player_no].SetText( m_OptionRow[iRow].choices[iChoiceInRow] );
|
2003-03-31 14:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenOptions::UpdateEnabledDisabled()
|
|
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
RageColor colorSelected = COLOR_SELECTED;
|
|
|
|
|
RageColor colorNotSelected = COLOR_NOT_SELECTED;
|
2002-09-04 03:49:08 +00:00
|
|
|
|
|
|
|
|
// init text
|
2003-06-17 05:49:11 +00:00
|
|
|
for( int i=0; i<m_iNumOptionRows; i++ ) // foreach line
|
2002-09-04 03:49:08 +00:00
|
|
|
{
|
|
|
|
|
bool bThisRowIsSelected = false;
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
2003-04-10 05:46:31 +00:00
|
|
|
if( GAMESTATE->IsHumanPlayer(p) && m_iCurrentRow[p] == i )
|
2002-09-04 03:49:08 +00:00
|
|
|
bThisRowIsSelected = true;
|
|
|
|
|
|
2003-06-16 20:01:18 +00:00
|
|
|
/* Don't tween selection colors at all. */
|
2003-06-16 03:29:59 +00:00
|
|
|
RageColor color = bThisRowIsSelected ? colorSelected : colorNotSelected;
|
2003-06-16 20:01:18 +00:00
|
|
|
m_sprBullets[i].SetGlobalDiffuseColor( color );
|
|
|
|
|
m_textTitles[i].SetGlobalDiffuseColor( color );
|
2002-09-04 03:49:08 +00:00
|
|
|
|
2003-03-31 23:03:43 +00:00
|
|
|
if( m_bRowIsLong[i] )
|
2003-03-31 14:02:39 +00:00
|
|
|
for( unsigned j=0; j<NUM_PLAYERS; j++ )
|
2003-06-16 20:01:18 +00:00
|
|
|
m_textItems[i][j].SetGlobalDiffuseColor( color );
|
|
|
|
|
else
|
|
|
|
|
for( unsigned j=0; j<m_OptionRow[i].choices.size(); j++ )
|
|
|
|
|
m_textItems[i][j].SetGlobalDiffuseColor( color );
|
|
|
|
|
|
|
|
|
|
if( m_sprBullets[i].GetDestY() != m_fRowY[i] )
|
|
|
|
|
{
|
|
|
|
|
m_sprBullets[i].StopTweening();
|
|
|
|
|
m_textTitles[i].StopTweening();
|
|
|
|
|
m_sprBullets[i].BeginTweening( 0.3f );
|
|
|
|
|
m_textTitles[i].BeginTweening( 0.3f );
|
|
|
|
|
|
|
|
|
|
m_sprBullets[i].SetDiffuseAlpha( m_bRowIsHidden[i]? 0.0f:1.0f );
|
|
|
|
|
m_textTitles[i].SetDiffuseAlpha( m_bRowIsHidden[i]? 0.0f:1.0f );
|
2003-05-21 01:58:47 +00:00
|
|
|
|
2003-06-16 20:01:18 +00:00
|
|
|
m_sprBullets[i].SetY( m_fRowY[i] );
|
|
|
|
|
m_textTitles[i].SetY( m_fRowY[i] );
|
|
|
|
|
|
|
|
|
|
if( m_bRowIsLong[i] )
|
|
|
|
|
for( unsigned j=0; j<NUM_PLAYERS; j++ )
|
2003-06-16 03:29:59 +00:00
|
|
|
{
|
|
|
|
|
m_textItems[i][j].StopTweening();
|
2003-06-16 20:01:18 +00:00
|
|
|
m_textItems[i][j].BeginTweening( 0.3f );
|
|
|
|
|
m_textItems[i][j].SetDiffuseAlpha( m_bRowIsHidden[i]? 0.0f:1.0f );
|
|
|
|
|
m_textItems[i][j].SetY( m_fRowY[i] );
|
2003-06-16 03:29:59 +00:00
|
|
|
}
|
2003-06-16 20:01:18 +00:00
|
|
|
else
|
|
|
|
|
for( unsigned j=0; j<m_OptionRow[i].choices.size(); j++ )
|
|
|
|
|
{
|
|
|
|
|
m_textItems[i][j].StopTweening();
|
|
|
|
|
m_textItems[i][j].BeginTweening( 0.3f );
|
|
|
|
|
m_textItems[i][j].SetDiffuseAlpha( m_bRowIsHidden[i]? 0.0f:1.0f );
|
|
|
|
|
m_textItems[i][j].SetY( m_fRowY[i] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-07 20:54:59 +00:00
|
|
|
/* Hide the text of all but the first active player, so we don't overdraw. */
|
2003-08-23 22:04:57 +00:00
|
|
|
if( m_InputMode == INPUTMODE_TOGETHER && m_bRowIsLong[i] )
|
2003-06-16 20:01:18 +00:00
|
|
|
{
|
2003-07-07 20:54:59 +00:00
|
|
|
bool one = false;
|
|
|
|
|
for( unsigned j=0; j<NUM_PLAYERS; j++ )
|
2003-06-16 03:29:59 +00:00
|
|
|
{
|
2003-07-07 20:54:59 +00:00
|
|
|
if( GAMESTATE->IsHumanPlayer(j) )
|
|
|
|
|
{
|
|
|
|
|
if(!one)
|
|
|
|
|
{
|
|
|
|
|
one=true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-06-16 20:01:18 +00:00
|
|
|
m_textItems[i][j].StopTweening();
|
|
|
|
|
m_textItems[i][j].SetDiffuse( RageColor(1,1,1,0) );
|
2003-06-16 03:29:59 +00:00
|
|
|
}
|
2003-06-16 20:01:18 +00:00
|
|
|
}
|
2002-09-04 03:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
2003-05-21 01:58:47 +00:00
|
|
|
bool bExitRowIsSelectedByBoth = true;
|
2002-09-04 03:49:08 +00:00
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
2003-05-21 01:58:47 +00:00
|
|
|
if( GAMESTATE->IsHumanPlayer(p) && m_iCurrentRow[p] != m_iNumOptionRows )
|
|
|
|
|
bExitRowIsSelectedByBoth = false;
|
2003-06-16 03:29:59 +00:00
|
|
|
|
|
|
|
|
RageColor color = bExitRowIsSelectedByBoth ? colorSelected : colorNotSelected;
|
2003-06-16 20:01:18 +00:00
|
|
|
m_textItems[m_iNumOptionRows][0].SetGlobalDiffuseColor( color );
|
|
|
|
|
|
|
|
|
|
if( m_textItems[m_iNumOptionRows][0].GetDestY() != m_fRowY[m_iNumOptionRows] )
|
|
|
|
|
{
|
|
|
|
|
m_textItems[m_iNumOptionRows][0].StopTweening();
|
|
|
|
|
m_textItems[m_iNumOptionRows][0].BeginTweening( 0.3f );
|
2003-06-17 05:49:11 +00:00
|
|
|
m_textItems[m_iNumOptionRows][0].SetDiffuseAlpha( m_bRowIsHidden[m_iNumOptionRows]? 0.0f:1.0f );
|
2003-06-16 20:01:18 +00:00
|
|
|
m_textItems[m_iNumOptionRows][0].SetY( m_fRowY[m_iNumOptionRows] );
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-21 01:58:47 +00:00
|
|
|
if( bExitRowIsSelectedByBoth )
|
|
|
|
|
m_textItems[m_iNumOptionRows][0].SetEffectDiffuseShift( 1.0f, colorSelected, colorNotSelected );
|
2002-09-04 03:49:08 +00:00
|
|
|
else
|
2003-05-21 01:58:47 +00:00
|
|
|
m_textItems[m_iNumOptionRows][0].SetEffectNone();
|
2002-09-04 03:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
void ScreenOptions::Update( float fDeltaTime )
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
//LOG->Trace( "ScreenOptions::Update(%f)", fDeltaTime );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
Screen::Update( fDeltaTime );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenOptions::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
m_Menu.DrawBottomLayer();
|
|
|
|
|
Screen::DrawPrimitives();
|
|
|
|
|
m_Menu.DrawTopLayer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenOptions::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
|
|
|
{
|
2003-03-22 19:58:44 +00:00
|
|
|
/* Allow input when transitioning in (m_In.IsTransitioning()), but ignore it
|
|
|
|
|
* when we're transitioning out. */
|
|
|
|
|
if( m_Menu.m_Back.IsTransitioning() || m_Menu.m_Out.IsTransitioning() )
|
2002-05-20 08:59:37 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// default input handler
|
|
|
|
|
Screen::Input( DeviceI, type, GameI, MenuI, StyleI );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenOptions::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
2002-07-02 00:27:58 +00:00
|
|
|
case SM_MenuTimer:
|
2003-03-25 21:17:29 +00:00
|
|
|
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
2002-07-02 00:27:58 +00:00
|
|
|
break;
|
2002-08-27 23:31:41 +00:00
|
|
|
case SM_GoToPrevScreen:
|
2003-03-09 00:55:49 +00:00
|
|
|
// this->ExportOptions(); // Don't save options if we're going back!
|
2002-05-20 08:59:37 +00:00
|
|
|
this->GoToPrevState();
|
|
|
|
|
break;
|
2002-08-27 23:31:41 +00:00
|
|
|
case SM_GoToNextScreen:
|
2002-05-20 08:59:37 +00:00
|
|
|
this->ExportOptions();
|
|
|
|
|
this->GoToNextState();
|
|
|
|
|
break;
|
2003-03-11 08:52:45 +00:00
|
|
|
case SM_BeginFadingOut:
|
2003-03-30 21:42:10 +00:00
|
|
|
if(m_Menu.IsTransitioning())
|
|
|
|
|
return; /* already transitioning */
|
2003-03-09 00:55:49 +00:00
|
|
|
m_Menu.StartTransitioning( SM_GoToNextScreen );
|
2002-09-04 03:49:08 +00:00
|
|
|
|
|
|
|
|
m_SoundStart.Play();
|
|
|
|
|
|
2003-03-03 10:03:02 +00:00
|
|
|
m_framePage.BeginTweening( 0.3f, Actor::TWEEN_ACCELERATE );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_framePage.SetX( SCREEN_RIGHT );
|
2002-09-04 03:49:08 +00:00
|
|
|
break;
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-16 03:29:59 +00:00
|
|
|
void ScreenOptions::PositionItems()
|
|
|
|
|
{
|
2003-07-20 22:21:00 +00:00
|
|
|
const int total = NUM_SHOWN_ITEMS;
|
|
|
|
|
const int halfsize = total / 2;
|
|
|
|
|
|
2003-06-16 03:42:48 +00:00
|
|
|
/* Total number of rows, including "EXIT". */
|
|
|
|
|
const int NumRows = m_iNumOptionRows + 1;
|
|
|
|
|
|
2003-06-18 04:11:33 +00:00
|
|
|
int first_start, first_end, second_start, second_end;
|
|
|
|
|
|
2003-06-16 03:42:48 +00:00
|
|
|
/* Choices for each player. If only one player is active, it's the same for both. */
|
|
|
|
|
const int P1Choice = GAMESTATE->IsHumanPlayer(PLAYER_1)? m_iCurrentRow[PLAYER_1]: m_iCurrentRow[PLAYER_2];
|
|
|
|
|
const int P2Choice = GAMESTATE->IsHumanPlayer(PLAYER_2)? m_iCurrentRow[PLAYER_2]: m_iCurrentRow[PLAYER_1];
|
2003-06-16 03:29:59 +00:00
|
|
|
|
2003-06-18 04:11:33 +00:00
|
|
|
const bool BothPlayersActivated = GAMESTATE->IsHumanPlayer(PLAYER_1) && GAMESTATE->IsHumanPlayer(PLAYER_2);
|
2003-08-23 22:04:57 +00:00
|
|
|
if( m_InputMode == INPUTMODE_TOGETHER || !BothPlayersActivated )
|
2003-06-18 04:11:33 +00:00
|
|
|
{
|
|
|
|
|
/* Simply center the cursor. */
|
|
|
|
|
first_start = max( P1Choice - halfsize, 0 );
|
|
|
|
|
first_end = first_start + total;
|
|
|
|
|
second_start = second_end = first_end;
|
|
|
|
|
} else {
|
|
|
|
|
/* First half: */
|
|
|
|
|
const int earliest = min( P1Choice, P2Choice );
|
|
|
|
|
first_start = max( earliest - halfsize/2, 0 );
|
|
|
|
|
first_end = first_start + halfsize;
|
|
|
|
|
|
|
|
|
|
/* Second half: */
|
|
|
|
|
const int latest = max( P1Choice, P2Choice );
|
2003-06-16 03:29:59 +00:00
|
|
|
|
2003-06-18 04:11:33 +00:00
|
|
|
second_start = max( latest - halfsize/2, 0 );
|
2003-06-16 03:29:59 +00:00
|
|
|
|
2003-06-18 04:11:33 +00:00
|
|
|
/* Don't overlap. */
|
|
|
|
|
second_start = max( second_start, first_end );
|
2003-06-16 03:29:59 +00:00
|
|
|
|
2003-06-18 04:11:33 +00:00
|
|
|
second_end = second_start + halfsize;
|
2003-06-16 03:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
2003-06-18 04:11:33 +00:00
|
|
|
first_end = min( first_end, NumRows );
|
|
|
|
|
second_end = min( second_end, NumRows );
|
|
|
|
|
|
|
|
|
|
/* If less than total (and NumRows) are displayed, fill in the empty
|
|
|
|
|
* space intelligently. */
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
const int sum = (first_end - first_start) + (second_end - second_start);
|
|
|
|
|
if( sum >= NumRows || sum >= total)
|
|
|
|
|
break; /* nothing more to display, or no room */
|
|
|
|
|
|
|
|
|
|
/* First priority: expand the top of the second half until it meets
|
|
|
|
|
* the first half. */
|
|
|
|
|
if( second_start > first_end )
|
|
|
|
|
second_start--;
|
|
|
|
|
/* Otherwise, expand either end. */
|
|
|
|
|
else if( first_start > 0 )
|
|
|
|
|
first_start--;
|
|
|
|
|
else if( second_end < NumRows )
|
|
|
|
|
second_end++;
|
|
|
|
|
else
|
|
|
|
|
ASSERT(0); /* do we have room to grow or don't we? */
|
|
|
|
|
}
|
2003-06-16 03:29:59 +00:00
|
|
|
|
2003-06-18 04:11:33 +00:00
|
|
|
int pos = 0;
|
2003-06-16 03:29:59 +00:00
|
|
|
for( int i=0; i<NumRows; i++ ) // foreach line
|
|
|
|
|
{
|
|
|
|
|
float ItemPosition;
|
|
|
|
|
if( i < first_start )
|
|
|
|
|
ItemPosition = -0.5f;
|
2003-06-18 04:11:33 +00:00
|
|
|
else if( i < first_end )
|
|
|
|
|
ItemPosition = (float) pos++;
|
2003-06-16 03:29:59 +00:00
|
|
|
else if( i < second_start )
|
2003-06-18 00:26:34 +00:00
|
|
|
ItemPosition = halfsize - 0.5f;
|
2003-06-18 04:11:33 +00:00
|
|
|
else if( i < second_end )
|
|
|
|
|
ItemPosition = (float) pos++;
|
2003-06-16 03:29:59 +00:00
|
|
|
else
|
|
|
|
|
ItemPosition = (float) total - 0.5f;
|
|
|
|
|
|
|
|
|
|
float fY = ITEMS_START_Y + ITEMS_SPACING_Y*ItemPosition;
|
|
|
|
|
m_fRowY[i] = fY;
|
|
|
|
|
m_bRowIsHidden[i] = i < first_start ||
|
2003-06-18 04:11:33 +00:00
|
|
|
(i >= first_end && i < second_start) ||
|
|
|
|
|
i >= second_end;
|
2003-06-16 03:29:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
void ScreenOptions::OnChange()
|
|
|
|
|
{
|
2003-06-16 03:29:59 +00:00
|
|
|
/* Update m_fRowY[] and m_bRowIsHidden[]. */
|
|
|
|
|
PositionItems();
|
|
|
|
|
|
|
|
|
|
/* Do positioning. */
|
2002-05-20 08:59:37 +00:00
|
|
|
PositionUnderlines();
|
2002-09-03 22:31:06 +00:00
|
|
|
RefreshIcons();
|
2003-06-16 03:29:59 +00:00
|
|
|
PositionIcons();
|
2002-09-04 03:49:08 +00:00
|
|
|
UpdateEnabledDisabled();
|
2002-09-10 21:16:34 +00:00
|
|
|
|
2003-06-16 03:29:59 +00:00
|
|
|
for( int pn=0; pn<NUM_PLAYERS; pn++ )
|
|
|
|
|
TweenCursor( (PlayerNumber)pn );
|
|
|
|
|
|
2002-09-10 21:16:34 +00:00
|
|
|
int iCurRow = m_iCurrentRow[PLAYER_1];
|
2003-03-15 19:25:37 +00:00
|
|
|
|
|
|
|
|
bool bIsExitRow = iCurRow == m_iNumOptionRows;
|
|
|
|
|
|
|
|
|
|
if( !bIsExitRow && m_bLoadExplanations )
|
|
|
|
|
{
|
|
|
|
|
CString sLineName = m_OptionRow[iCurRow].name;
|
|
|
|
|
if( sLineName=="" )
|
|
|
|
|
sLineName = m_OptionRow[iCurRow].choices[0];
|
|
|
|
|
sLineName.Replace("\n","");
|
|
|
|
|
sLineName.Replace(" ","");
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textExplanation.SetText( THEME->GetMetric(m_sName,sLineName) );
|
2003-03-15 19:25:37 +00:00
|
|
|
}
|
2002-09-10 21:16:34 +00:00
|
|
|
else
|
|
|
|
|
m_textExplanation.SetText( "" );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenOptions::MenuBack( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-09-04 03:49:08 +00:00
|
|
|
Screen::MenuBack( pn );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-03-09 00:55:49 +00:00
|
|
|
m_Menu.Back( SM_GoToPrevScreen );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-02-12 00:41:56 +00:00
|
|
|
void ScreenOptions::StartGoToNextState()
|
|
|
|
|
{
|
2003-03-25 21:17:29 +00:00
|
|
|
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
2003-02-12 00:41:56 +00:00
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenOptions::MenuStart( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-03-12 03:44:55 +00:00
|
|
|
if( m_Menu.IsTransitioning() )
|
|
|
|
|
return;
|
|
|
|
|
|
2002-09-10 09:10:36 +00:00
|
|
|
if( PREFSMAN->m_bArcadeOptionsNavigation )
|
|
|
|
|
{
|
|
|
|
|
bool bAllOnExit = true;
|
|
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
2003-04-10 05:46:31 +00:00
|
|
|
if( GAMESTATE->IsHumanPlayer(p) && m_iCurrentRow[p] != m_iNumOptionRows )
|
2002-09-10 09:10:36 +00:00
|
|
|
bAllOnExit = false;
|
2002-09-05 03:45:07 +00:00
|
|
|
|
2002-09-10 09:10:36 +00:00
|
|
|
if( m_iCurrentRow[pn] != m_iNumOptionRows ) // not on exit
|
|
|
|
|
MenuDown( pn ); // can't go down any more
|
|
|
|
|
else if( bAllOnExit )
|
2003-03-25 21:17:29 +00:00
|
|
|
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
2002-09-10 09:10:36 +00:00
|
|
|
}
|
|
|
|
|
else // !m_bArcadeOptionsNavigation
|
|
|
|
|
{
|
2003-03-25 21:17:29 +00:00
|
|
|
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
2002-09-10 09:10:36 +00:00
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
|
|
|
|
|
void ScreenOptions::ChangeValue( PlayerNumber pn, int iDelta )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-08-24 21:18:18 +00:00
|
|
|
// if( m_InputMode == INPUTMODE_INDIVIDUAL && p != pn )
|
|
|
|
|
if( p != pn ) // don't check for INPUTMODE_INDIVIDUAL because on regular
|
|
|
|
|
// options it moves everything by 2
|
2002-08-13 23:26:46 +00:00
|
|
|
continue; // skip
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
int iCurRow = m_iCurrentRow[p];
|
2002-08-22 07:35:58 +00:00
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
if( iCurRow == m_iNumOptionRows ) // EXIT is selected
|
|
|
|
|
return; // don't allow a move
|
|
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
OptionRow &row = m_OptionRow[iCurRow];
|
|
|
|
|
const int iNumOptions = row.choices.size();
|
2003-02-01 01:11:00 +00:00
|
|
|
if( iNumOptions == 1 )
|
|
|
|
|
continue;
|
|
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
int iNewSel = (m_iSelectedOption[p][iCurRow]+iDelta+iNumOptions) % iNumOptions;
|
2002-09-04 03:49:08 +00:00
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
if( row.bOneChoiceForAllPlayers )
|
|
|
|
|
{
|
|
|
|
|
for( int p2=0; p2<NUM_PLAYERS; p2++ )
|
2003-08-23 22:13:06 +00:00
|
|
|
{
|
2003-08-23 22:04:57 +00:00
|
|
|
m_iSelectedOption[p2][iCurRow] = iNewSel;
|
2003-08-23 22:13:06 +00:00
|
|
|
UpdateText( (PlayerNumber)p2, iCurRow );
|
|
|
|
|
}
|
2003-08-23 22:04:57 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_iSelectedOption[p][iCurRow] = iNewSel;
|
2003-08-23 22:13:06 +00:00
|
|
|
UpdateText( (PlayerNumber)p, iCurRow );
|
2003-08-23 22:04:57 +00:00
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
2002-09-04 03:49:08 +00:00
|
|
|
m_SoundChangeCol.Play();
|
2002-05-20 08:59:37 +00:00
|
|
|
OnChange();
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-23 22:04:57 +00:00
|
|
|
|
2002-08-27 23:31:41 +00:00
|
|
|
void ScreenOptions::MenuUp( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-08-23 22:04:57 +00:00
|
|
|
if( m_InputMode == INPUTMODE_INDIVIDUAL && p != pn )
|
2002-08-13 23:26:46 +00:00
|
|
|
continue; // skip
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
if( m_iCurrentRow[p] == 0 ) // on first row
|
2003-07-03 08:12:06 +00:00
|
|
|
m_iCurrentRow[p] = m_iNumOptionRows; // on exit
|
|
|
|
|
else
|
|
|
|
|
m_iCurrentRow[p]--;
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
2002-09-04 03:49:08 +00:00
|
|
|
m_SoundPrevRow.Play();
|
2002-05-20 08:59:37 +00:00
|
|
|
OnChange();
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-22 08:08:16 +00:00
|
|
|
|
2002-08-27 23:31:41 +00:00
|
|
|
void ScreenOptions::MenuDown( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-08-23 22:04:57 +00:00
|
|
|
if( m_InputMode == INPUTMODE_INDIVIDUAL && p != pn )
|
2002-08-13 23:26:46 +00:00
|
|
|
continue; // skip
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
if( m_iCurrentRow[p] == m_iNumOptionRows ) // on exit
|
2003-07-03 08:12:06 +00:00
|
|
|
m_iCurrentRow[p] = 0; // on first row
|
|
|
|
|
else
|
|
|
|
|
m_iCurrentRow[p]++;
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
2002-09-04 03:49:08 +00:00
|
|
|
m_SoundNextRow.Play();
|
2002-05-20 08:59:37 +00:00
|
|
|
OnChange();
|
|
|
|
|
}
|