Files
itgmania212121/stepmania/src/ScreenOptions.cpp
T

718 lines
20 KiB
C++
Raw Normal View History

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
2002-05-20 08:59:37 +00:00
-----------------------------------------------------------------------------
*/
#include "ScreenOptions.h"
#include "RageUtil.h"
2003-01-02 07:54:28 +00:00
#include "RageSoundManager.h"
2002-05-20 08:59:37 +00:00
#include "ScreenManager.h"
#include "PrefsManager.h"
#include "GameConstantsAndTypes.h"
#include "RageLog.h"
#include "GameState.h"
#include "ThemeManager.h"
2002-05-20 08:59:37 +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))
#define ARROWS_X THEME->GetMetricF("ScreenOptions","ArrowsX")
2002-09-03 06:33:08 +00:00
#define LABELS_X THEME->GetMetricF("ScreenOptions","LabelsX")
#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")
#define EXPLANATION_X THEME->GetMetricF("ScreenOptions","ExplanationX")
#define EXPLANATION_Y THEME->GetMetricF("ScreenOptions","ExplanationY")
#define EXPLANATION_ZOOM THEME->GetMetricF("ScreenOptions","ExplanationZoom")
2002-08-27 16:53:25 +00:00
#define HELP_TEXT THEME->GetMetric("ScreenOptions","HelpText")
#define TIMER_SECONDS THEME->GetMetricI("ScreenOptions","TimerSeconds")
#define COLOR_SELECTED THEME->GetMetricC("ScreenOptions","ColorSelected")
#define COLOR_NOT_SELECTED THEME->GetMetricC("ScreenOptions","ColorNotSelected")
2002-05-20 08:59:37 +00:00
2003-06-16 03:29:59 +00:00
const int total = 10;
const int halfsize = total / 2;
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
{
LOG->Trace( "ScreenOptions::ScreenOptions()" );
2002-05-20 08:59:37 +00:00
2003-04-12 06:16:12 +00:00
m_sName = sClassName;
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
this->AddChild( &m_Menu );
2002-05-20 08:59:37 +00:00
// add everything to m_framePage so we can animate everything at once
this->AddChild( &m_framePage );
m_sprPage.Load( THEME->GetPathToG(sClassName+" page") );
m_sprPage.SetXY( CENTER_X, CENTER_Y );
m_framePage.AddChild( &m_sprPage );
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;
}
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 );
memset(&m_bRowIsLong, 0, sizeof(m_bRowIsLong));
2002-05-20 08:59:37 +00:00
}
void ScreenOptions::Init( InputMode im, OptionRow OptionRow[], int iNumOptionLines, bool bUseIcons, bool bLoadExplanations )
2002-05-20 08:59:37 +00:00
{
LOG->Trace( "ScreenOptions::Set()" );
2002-05-20 08:59:37 +00:00
m_InputMode = im;
m_OptionRow = OptionRow;
m_iNumOptionRows = iNumOptionLines;
m_bUseIcons = bUseIcons;
m_bLoadExplanations = bLoadExplanations;
2002-05-20 08:59:37 +00:00
this->ImportOptions();
if( m_InputMode == INPUTMODE_BOTH )
{
2002-11-16 20:21:00 +00:00
for( unsigned l=0; l<MAX_OPTION_LINES; l++ )
m_iSelectedOption[PLAYER_2][l] = m_iSelectedOption[PLAYER_1][l];
}
// init highlights and underlines
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
for( int l=0; l<m_iNumOptionRows; l++ )
{
m_Underline[p][l].Load( (PlayerNumber)p, true );
m_framePage.AddChild( &m_Underline[p][l] );
2002-09-03 06:33:08 +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] );
}
m_Highlight[p].Load( (PlayerNumber)p, false );
m_framePage.AddChild( &m_Highlight[p] );
}
// init text
2002-11-16 20:21:00 +00:00
int i;
2002-11-16 20:30:51 +00:00
for( i=0; i<m_iNumOptionRows; i++ ) // foreach line
{
m_framePage.AddChild( &m_sprBullets[i] );
m_framePage.AddChild( &m_textTitles[i] );
for( unsigned j=0; j<m_OptionRow[i].choices.size(); j++ )
m_framePage.AddChild( &m_textItems[i][j] );
}
// TRICKY: Add one more item. This will be "EXIT"
m_framePage.AddChild( &m_textItems[i][0] );
// add explanation here so it appears on top
m_textExplanation.LoadFromFont( THEME->GetPathToF("ScreenOptions explanation") );
m_textExplanation.SetXY( EXPLANATION_X, EXPLANATION_Y );
m_textExplanation.SetZoom( EXPLANATION_ZOOM );
m_textExplanation.SetShadowLength( 0 );
m_framePage.AddChild( &m_textExplanation );
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();
RefreshIcons();
PositionCursors();
UpdateEnabledDisabled();
OnChange();
2002-05-20 08:59:37 +00:00
}
ScreenOptions::~ScreenOptions()
{
LOG->Trace( "ScreenOptions::~ScreenOptions()" );
2002-05-20 08:59:37 +00:00
}
void ScreenOptions::GetWidthXY( PlayerNumber pn, int iRow, int &iWidthOut, int &iXOut, int &iYOut )
2002-05-20 08:59:37 +00:00
{
bool bExitRow = iRow == m_iNumOptionRows;
bool bLotsOfOptions = m_bRowIsLong[iRow];
int iOptionInRow = bExitRow ? 0 : bLotsOfOptions ? pn : m_iSelectedOption[pn][iRow];
2002-05-20 08:59:37 +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()
{
// 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
{
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
BitmapText &title = m_textTitles[i];
2002-05-20 08:59:37 +00:00
title.LoadFromFont( THEME->GetPathToF("ScreenOptions title") );
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 );
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
Sprite &bullet = m_sprBullets[i];
bullet.Load( THEME->GetPathToG("ScreenOptions bullet") );
bullet.SetXY( ARROWS_X, fY );
2002-05-20 08:59:37 +00:00
// init all text in this line and count the width of the line
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
{
BitmapText &option = m_textItems[i][j];
option.LoadFromFont( THEME->GetPathToF("ScreenOptions item") );
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
for( unsigned j=0; j<optline.choices.size(); j++ ) // for each option on this line
m_textItems[i][j].SetText( "" );
for( int p=0; p<NUM_PLAYERS; p++ )
{
2003-04-22 00:27:52 +00:00
if( !GAMESTATE->IsHumanPlayer(p) )
continue;
2003-04-22 00:27:52 +00:00
BitmapText &option = m_textItems[i][p];
2003-04-22 00:27:52 +00:00
const int iChoiceInRow = m_iSelectedOption[p][i];
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-05-21 01:58:47 +00:00
option.SetY( fY );
/* If we're in INPUTMODE_BOTH, center the items. */
if( m_InputMode == INPUTMODE_BOTH )
option.SetX( (ITEM_X[0]+ITEM_X[1])/2 );
else
option.SetX( ITEM_X[p] );
2003-04-22 00:27:52 +00:00
UpdateText( (PlayerNumber)p );
}
}
2002-05-20 08:59:37 +00:00
}
BitmapText &option = m_textItems[i][0];
option.LoadFromFont( THEME->GetPathToF("ScreenOptions item") );
option.SetText( "EXIT" );
option.SetZoom( ITEMS_ZOOM );
option.SetShadowLength( 0 );
2003-06-16 03:29:59 +00:00
float fY = ITEMS_START_Y + ITEMS_SPACING_Y*i;
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
{
for( int i=0; i<m_iNumOptionRows; i++ ) // foreach options line
2002-05-20 08:59:37 +00:00
{
OptionsCursor &underline = m_Underline[p][i];
2002-05-20 08:59:37 +00:00
2003-06-16 03:29:59 +00:00
underline.StopTweening();
/* Don't tween X movement. */
int iWidth, iX, iY;
GetWidthXY( (PlayerNumber)p, i, iWidth, iX, iY );
underline.SetX( (float)iX );
2003-02-01 01:11:00 +00:00
// If there's only one choice (ScreenOptionsMenu), don't show underlines.
// It looks silly.
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 03:29:59 +00:00
/* XXX: this doesn't work since underline is an ActorFrame */
underline.BeginTweening( 0.3f );
underline.SetDiffuse( RageColor(1,1,1,hidden? 0.0f:1.0f) );
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
{
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];
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) );
icon.StopTweening();
/* XXX: this doesn't work since icon is an ActorFrame */
icon.BeginTweening( 0.3f );
icon.SetY( (float)iY );
icon.SetDiffuse( RageColor(1,1,1, m_bRowIsHidden[i]? 0.0f:1.0f) );
2002-09-03 06:33:08 +00:00
}
}
}
void ScreenOptions::RefreshIcons()
{
for( int p=0; p<NUM_PLAYERS; p++ ) // foreach player
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue;
for( int i=0; i<m_iNumOptionRows; i++ ) // foreach options line
{
OptionIcon &icon = m_OptionIcons[p][i];
int iSelection = m_iSelectedOption[p][i];
CString sSelection = m_OptionRow[i].choices[iSelection];
if( sSelection == "ON" )
sSelection = m_OptionRow[i].name;
icon.Load( (PlayerNumber)p, m_bUseIcons ? sSelection : "", false );
}
}
}
2002-09-03 06:33: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];
OptionsCursor &highlight = m_Highlight[p];
2002-05-20 08:59:37 +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
}
}
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];
OptionsCursor &highlight = m_Highlight[player_no];
2002-05-20 08:59:37 +00:00
int iWidth, iX, iY;
GetWidthXY( player_no, iCurRow, iWidth, iX, iY );
highlight.StopTweening();
2002-05-20 08:59:37 +00:00
highlight.BeginTweening( 0.2f );
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
}
void ScreenOptions::UpdateText( PlayerNumber player_no )
{
int iCurRow = m_iCurrentRow[player_no];
int iChoiceInRow = m_iSelectedOption[player_no][iCurRow];
bool bLotsOfOptions = m_bRowIsLong[iCurRow];
if( bLotsOfOptions )
m_textItems[iCurRow][player_no].SetText( m_OptionRow[iCurRow].choices[iChoiceInRow] );
}
void ScreenOptions::UpdateEnabledDisabled()
{
RageColor colorSelected = COLOR_SELECTED;
RageColor colorNotSelected = COLOR_NOT_SELECTED;
// init text
2003-05-21 01:58:47 +00:00
for( int i=0; i<m_iNumOptionRows; i++ ) // foreach line
{
bool bThisRowIsSelected = false;
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsHumanPlayer(p) && m_iCurrentRow[p] == i )
bThisRowIsSelected = true;
2003-06-16 03:29:59 +00:00
m_sprBullets[i].StopTweening();
m_textTitles[i].StopTweening();
m_sprBullets[i].BeginTweening( 0.3f );
m_textTitles[i].BeginTweening( 0.3f );
for( unsigned j=0; j<m_OptionRow[i].choices.size(); j++ )
{
m_textItems[i][j].StopTweening();
m_textItems[i][j].BeginTweening( 0.3f );
}
2003-06-16 03:29:59 +00:00
RageColor color = bThisRowIsSelected ? colorSelected : colorNotSelected;
if( m_bRowIsHidden[i] )
color.a = 0.0f;
m_sprBullets[i].SetDiffuse( color );
m_textTitles[i].SetDiffuse( color );
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-05-21 01:58:47 +00:00
{
2003-06-16 03:29:59 +00:00
m_textItems[i][j].SetDiffuse( color );
m_textItems[i][j].SetY( m_fRowY[i] );
2003-05-21 01:58:47 +00:00
/* Hide the text of all but the first player, so we don't overdraw. */
if( m_InputMode == INPUTMODE_BOTH && j != 0 )
2003-06-16 03:29:59 +00:00
{
m_textItems[i][j].StopTweening();
2003-05-21 01:58:47 +00:00
m_textItems[i][j].SetDiffuse( RageColor(1,1,1,0) );
2003-06-16 03:29:59 +00:00
}
2003-05-21 01:58:47 +00:00
}
else
for( unsigned j=0; j<m_OptionRow[i].choices.size(); j++ )
2003-06-16 03:29:59 +00:00
{
m_textItems[i][j].SetDiffuse( color );
m_textItems[i][j].SetY( m_fRowY[i] );
}
}
2003-05-21 01:58:47 +00:00
bool bExitRowIsSelectedByBoth = true;
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
m_textItems[m_iNumOptionRows][0].StopTweening();
m_textItems[m_iNumOptionRows][0].BeginTweening( 0.3f );
RageColor color = bExitRowIsSelectedByBoth ? colorSelected : colorNotSelected;
if( m_bRowIsHidden[i] )
color.a = 0.0f;
m_textItems[m_iNumOptionRows][0].SetDiffuse( color );
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 );
else
2003-05-21 01:58:47 +00:00
m_textItems[m_iNumOptionRows][0].SetEffectNone();
}
2002-05-20 08:59:37 +00:00
void ScreenOptions::Update( float fDeltaTime )
{
//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;
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;
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 );
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 );
break;
2002-05-20 08:59:37 +00:00
}
}
2003-06-16 03:29:59 +00:00
void ScreenOptions::PositionItems()
{
int NumRows = m_iNumOptionRows + 1;
/* First half: */
const int earliest = min( m_iCurrentRow[PLAYER_1], m_iCurrentRow[PLAYER_2] );
int first_start = max( earliest - halfsize+1, 0 );
int first_end = first_start + halfsize - 1;
/* Second half: */
int latest = max( m_iCurrentRow[PLAYER_1], m_iCurrentRow[PLAYER_2] );
int second_start = max( latest - halfsize + 1, 0 );
/* Never overlap: */
second_start = max( second_start, first_end + 1 );
int second_end = second_start + halfsize - 1;
if( second_end >= NumRows )
{
first_start = NumRows - total;
first_end = NumRows;
second_start = 9999;
second_end = 9999;
}
bool is_split = false;
if(first_end+1 < second_start)
is_split = true;
for( int i=0; i<NumRows; i++ ) // foreach line
{
float ItemPosition;
if( i < first_start )
ItemPosition = -0.5f;
else if( i <= first_end )
ItemPosition = float(i - first_start);
else if( i < second_start )
ItemPosition = first_end + 0.5f;
else if( i <= second_end )
ItemPosition = float(halfsize + i - second_start);
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 ||
(i > first_end && i < second_start) ||
i > second_end;
}
}
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();
RefreshIcons();
2003-06-16 03:29:59 +00:00
PositionIcons();
UpdateEnabledDisabled();
2003-06-16 03:29:59 +00:00
for( int i=0; i<m_iNumOptionRows; i++ ) // foreach line
{
m_sprBullets[i].StopTweening();
m_sprBullets[i].BeginTweening( 0.3f );
m_sprBullets[i].SetY( m_fRowY[i] );
RageColor color = m_sprBullets[i].GetDiffuse();
color.a = m_bRowIsHidden[i]? 0.0f:1.0f;
m_sprBullets[i].SetDiffuse( color );
}
for( int pn=0; pn<NUM_PLAYERS; pn++ )
TweenCursor( (PlayerNumber)pn );
int iCurRow = m_iCurrentRow[PLAYER_1];
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) );
}
else
m_textExplanation.SetText( "" );
2002-05-20 08:59:37 +00:00
}
void ScreenOptions::MenuBack( PlayerNumber pn )
2002-05-20 08:59:37 +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
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;
if( PREFSMAN->m_bArcadeOptionsNavigation )
{
bool bAllOnExit = true;
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsHumanPlayer(p) && m_iCurrentRow[p] != m_iNumOptionRows )
bAllOnExit = false;
2002-09-05 03:45:07 +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 );
}
else // !m_bArcadeOptionsNavigation
{
2003-03-25 21:17:29 +00:00
this->PostScreenMessage( SM_BeginFadingOut, 0 );
}
2002-05-20 08:59:37 +00:00
}
void ScreenOptions::MenuLeft( PlayerNumber pn )
2002-05-20 08:59:37 +00:00
{
for( int p=0; p<NUM_PLAYERS; p++ )
2002-05-20 08:59:37 +00:00
{
if( m_InputMode == INPUTMODE_PLAYERS && p != pn )
continue; // skip
2002-05-20 08:59:37 +00:00
int iCurRow = m_iCurrentRow[p];
2002-08-22 07:35:58 +00:00
if( iCurRow == m_iNumOptionRows ) // EXIT is selected
return; // don't allow a move
const int iNumOptions = m_OptionRow[iCurRow].choices.size();
2003-02-01 01:11:00 +00:00
if( iNumOptions == 1 )
continue;
m_iSelectedOption[p][iCurRow] = (m_iSelectedOption[p][iCurRow]-1+iNumOptions) % iNumOptions;
UpdateText( (PlayerNumber)p );
}
m_SoundChangeCol.Play();
2002-05-20 08:59:37 +00:00
OnChange();
}
void ScreenOptions::MenuRight( PlayerNumber pn )
2002-05-20 08:59:37 +00:00
{
for( int p=0; p<NUM_PLAYERS; p++ )
2002-05-20 08:59:37 +00:00
{
if( m_InputMode == INPUTMODE_PLAYERS && p != pn )
continue; // skip
int iCurRow = m_iCurrentRow[p];
if( iCurRow == m_iNumOptionRows ) // EXIT is selected
return; // don't allow a move
const int iNumOptions = m_OptionRow[iCurRow].choices.size();
2003-02-01 01:11:00 +00:00
if( iNumOptions == 1 )
continue;
m_iSelectedOption[p][iCurRow] = (m_iSelectedOption[p][iCurRow]+1) % iNumOptions;
UpdateText( (PlayerNumber)p );
2002-05-20 08:59:37 +00:00
}
m_SoundChangeCol.Play();
2002-05-20 08:59:37 +00:00
OnChange();
}
void ScreenOptions::MenuUp( PlayerNumber pn )
2002-05-20 08:59:37 +00:00
{
for( int p=0; p<NUM_PLAYERS; p++ )
2002-05-20 08:59:37 +00:00
{
if( m_InputMode == INPUTMODE_PLAYERS && p != pn )
continue; // skip
2002-05-20 08:59:37 +00:00
if( m_iCurrentRow[p] == 0 ) // on first row
return; // can't go up any more
m_iCurrentRow[p]--;
}
m_SoundPrevRow.Play();
2002-05-20 08:59:37 +00:00
OnChange();
}
2002-08-22 08:08:16 +00:00
void ScreenOptions::MenuDown( PlayerNumber pn )
2002-05-20 08:59:37 +00:00
{
for( int p=0; p<NUM_PLAYERS; p++ )
2002-05-20 08:59:37 +00:00
{
if( m_InputMode == INPUTMODE_PLAYERS && p != pn )
continue; // skip
2002-05-20 08:59:37 +00:00
if( m_iCurrentRow[p] == m_iNumOptionRows ) // on exit
return; // can't go down any more
m_iCurrentRow[p]++;
}
m_SoundNextRow.Play();
2002-05-20 08:59:37 +00:00
OnChange();
}