remove MAX_OPTION_LINES, cleanup selection tracking

This commit is contained in:
Chris Danford
2004-01-10 05:09:51 +00:00
parent 3583209f32
commit e7936d8312
5 changed files with 182 additions and 167 deletions
+130 -110
View File
@@ -105,9 +105,6 @@ ScreenOptions::ScreenOptions( CString sClassName ) : Screen(sClassName)
{
m_iCurrentRow[p] = 0;
m_bWasOnExit[p] = false;
for( unsigned l=0; l<MAX_OPTION_LINES; l++ )
m_iSelectedOption[p][l] = 0;
}
m_framePage.Command( FRAME_ON_COMMAND );
@@ -118,27 +115,37 @@ void ScreenOptions::LoadOptionIcon( PlayerNumber pn, int iRow, CString sText )
m_Rows[iRow]->m_OptionIcons[pn].Load( pn, sText, false );
}
void ScreenOptions::Init( InputMode im, OptionRow OptionRows[], int iNumOptionLines )
void ScreenOptions::Init( InputMode im, OptionRowData OptionRows[], int iNumOptionLines )
{
LOG->Trace( "ScreenOptions::Set()" );
m_InputMode = im;
this->ImportOptions();
int r;
for( r=0; r<iNumOptionLines; r++ ) // foreach row
{
m_Rows.push_back( new Row() );
m_Rows[r]->m_RowDef = OptionRows[r];
for( int r=0; r<iNumOptionLines; r++ ) // foreach row
{
m_Rows.push_back( new Row() );
m_Rows[r]->m_RowDef = OptionRows[r];
if( m_Rows[r]->m_RowDef.bOneChoiceForAllPlayers )
for( int p=1; p<NUM_PLAYERS; p++ )
m_iSelectedOption[0][r] = m_iSelectedOption[p][r];
for( int p=0; p<NUM_PLAYERS; p++ )
m_Rows[r]->m_iSelection[p] = 0;
if( m_Rows[r]->m_RowDef.bOneChoiceForAllPlayers )
for( int p=1; p<NUM_PLAYERS; p++ )
m_Rows[r]->m_iSelection[p] = m_Rows[r]->m_iSelection[0];
}
}
this->ImportOptions();
int p;
{
for( int r=0; r<iNumOptionLines; r++ ) // foreach row
{
if( m_Rows[r]->m_RowDef.bOneChoiceForAllPlayers )
for( int p=1; p<NUM_PLAYERS; p++ )
m_Rows[r]->m_iSelection[p] = m_Rows[r]->m_iSelection[0];
}
}
m_sprPage.Load( THEME->GetPathToG(m_sName+" page") );
m_sprPage->SetName( "Page" );
@@ -146,109 +153,114 @@ void ScreenOptions::Init( InputMode im, OptionRow OptionRows[], int iNumOptionLi
m_framePage.AddChild( m_sprPage );
// init highlights
for( p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
m_sprLineHighlight[p].Load( THEME->GetPathToG("ScreenOptions line highlight") );
m_sprLineHighlight[p].SetName( "LineHighlight" );
m_sprLineHighlight[p].SetX( CENTER_X );
m_framePage.AddChild( &m_sprLineHighlight[p] );
UtilOnCommand( m_sprLineHighlight[p], "ScreenOptions" );
m_sprLineHighlight[p].Load( THEME->GetPathToG("ScreenOptions line highlight") );
m_sprLineHighlight[p].SetName( "LineHighlight" );
m_sprLineHighlight[p].SetX( CENTER_X );
m_framePage.AddChild( &m_sprLineHighlight[p] );
UtilOnCommand( m_sprLineHighlight[p], "ScreenOptions" );
m_Highlight[p].Load( (PlayerNumber)p, false );
m_framePage.AddChild( &m_Highlight[p] );
m_Highlight[p].Load( (PlayerNumber)p, false );
m_framePage.AddChild( &m_Highlight[p] );
}
}
// init underlines
for( p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
for( unsigned l=0; l<m_Rows.size(); l++ )
for( int p=0; p<NUM_PLAYERS; p++ )
{
Row &row = *m_Rows[l];
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
LoadOptionIcon( (PlayerNumber)p, l, "" );
m_framePage.AddChild( &row.m_OptionIcons[p] );
for( unsigned l=0; l<m_Rows.size(); l++ )
{
Row &row = *m_Rows[l];
row.m_Underline[p].Load( (PlayerNumber)p, true );
m_framePage.AddChild( &row.m_Underline[p] );
LoadOptionIcon( (PlayerNumber)p, l, "" );
m_framePage.AddChild( &row.m_OptionIcons[p] );
row.m_Underline[p].Load( (PlayerNumber)p, true );
m_framePage.AddChild( &row.m_Underline[p] );
}
}
}
// init m_textItems from optionLines
for( r=0; r<m_Rows.size(); r++ ) // foreach row
{
Row &row = *m_Rows[r];
row.Type = Row::ROW_NORMAL;
vector<BitmapText *> & textItems = row.m_textItems;
const OptionRow &optline = m_Rows[r]->m_RowDef;
unsigned c;
m_framePage.AddChild( &row.m_sprBullet );
m_framePage.AddChild( &row.m_textTitle );
float fX = ITEMS_START_X; // indent 70 pixels
for( c=0; c<optline.choices.size(); c++ )
for( int r=0; r<m_Rows.size(); r++ ) // foreach row
{
BitmapText *bt = new BitmapText;
textItems.push_back( bt );
Row &row = *m_Rows[r];
row.Type = Row::ROW_NORMAL;
bt->LoadFromFont( THEME->GetPathToF("ScreenOptions item") );
bt->SetText( optline.choices[c] );
bt->SetZoom( ITEMS_ZOOM );
bt->EnableShadow( false );
vector<BitmapText *> & textItems = row.m_textItems;
const OptionRowData &optline = m_Rows[r]->m_RowDef;
// set the X position of each item in the line
const float fItemWidth = bt->GetZoomedWidth();
fX += fItemWidth/2;
bt->SetX( fX );
fX += fItemWidth/2 + ITEMS_GAP_X;
}
unsigned c;
if( fX > SCREEN_RIGHT-40 )
{
// It goes off the edge of the screen. Re-init with the "long row" style.
row.m_bRowIsLong = true;
for( unsigned j=0; j<optline.choices.size(); j++ ) // for each option on this row
delete textItems[j];
textItems.clear();
m_framePage.AddChild( &row.m_sprBullet );
m_framePage.AddChild( &row.m_textTitle );
for( unsigned p=0; p<NUM_PLAYERS; p++ )
float fX = ITEMS_START_X; // indent 70 pixels
for( c=0; c<optline.choices.size(); c++ )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue;
BitmapText *bt = new BitmapText;
textItems.push_back( bt );
const int iChoiceInRow = m_iSelectedOption[p][r];
bt->LoadFromFont( THEME->GetPathToF("ScreenOptions item") );
bt->SetText( optline.choices[iChoiceInRow] );
bt->SetText( optline.choices[c] );
bt->SetZoom( ITEMS_ZOOM );
bt->EnableShadow( false );
/* if choices are locked together, center the item. */
if( optline.bOneChoiceForAllPlayers )
bt->SetX( (ITEM_X[0]+ITEM_X[1])/2 );
else
bt->SetX( ITEM_X[p] );
/* If bOneChoiceForAllPlayers, then only initialize one text item. */
if( optline.bOneChoiceForAllPlayers )
break;
// set the X position of each item in the line
const float fItemWidth = bt->GetZoomedWidth();
fX += fItemWidth/2;
bt->SetX( fX );
fX += fItemWidth/2 + ITEMS_GAP_X;
}
}
for( c=0; c<textItems.size(); c++ )
m_framePage.AddChild( textItems[c] );
if( fX > SCREEN_RIGHT-40 )
{
// It goes off the edge of the screen. Re-init with the "long row" style.
row.m_bRowIsLong = true;
for( unsigned j=0; j<optline.choices.size(); j++ ) // for each option on this row
delete textItems[j];
textItems.clear();
for( unsigned p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue;
BitmapText *bt = new BitmapText;
textItems.push_back( bt );
const int iChoiceInRow = m_Rows[r]->m_iSelection[p];
bt->LoadFromFont( THEME->GetPathToF("ScreenOptions item") );
bt->SetText( optline.choices[iChoiceInRow] );
bt->SetZoom( ITEMS_ZOOM );
bt->EnableShadow( false );
/* if choices are locked together, center the item. */
if( optline.bOneChoiceForAllPlayers )
bt->SetX( (ITEM_X[0]+ITEM_X[1])/2 );
else
bt->SetX( ITEM_X[p] );
/* If bOneChoiceForAllPlayers, then only initialize one text item. */
if( optline.bOneChoiceForAllPlayers )
break;
}
}
for( c=0; c<textItems.size(); c++ )
m_framePage.AddChild( textItems[c] );
}
}
// TRICKY: Add one more item. This will be "EXIT"
@@ -272,19 +284,21 @@ void ScreenOptions::Init( InputMode im, OptionRow OptionRows[], int iNumOptionLi
InitOptionsText();
// add explanation here so it appears on top
for( p=0; p<NUM_PLAYERS; p++ )
{
m_textExplanation[p].LoadFromFont( THEME->GetPathToF("ScreenOptions explanation") );
m_textExplanation[p].SetZoom( EXPLANATION_ZOOM );
m_textExplanation[p].SetShadowLength( 0 );
m_framePage.AddChild( &m_textExplanation[p] );
for( int p=0; p<NUM_PLAYERS; p++ )
{
m_textExplanation[p].LoadFromFont( THEME->GetPathToF("ScreenOptions explanation") );
m_textExplanation[p].SetZoom( EXPLANATION_ZOOM );
m_textExplanation[p].SetShadowLength( 0 );
m_framePage.AddChild( &m_textExplanation[p] );
}
}
/* Hack: if m_CurStyle is set, we're probably in the player or song options menu, so
* the player name is meaningful. Otherwise, we're probably in the system menu. */
if( GAMESTATE->m_CurStyle != STYLE_INVALID )
{
for( p=0; p<NUM_PLAYERS; p++ )
for( int p=0; p<NUM_PLAYERS; p++ )
{
m_textPlayerName[p].LoadFromFont( THEME->GetPathToF( "ScreenOptions player") );
m_textPlayerName[p].SetName( ssprintf("PlayerNameP%i",p+1) );
@@ -299,7 +313,7 @@ void ScreenOptions::Init( InputMode im, OptionRow OptionRows[], int iNumOptionLi
m_ScrollBar.SetName( "DualScrollBar", "ScrollBar" );
m_ScrollBar.SetBarHeight( SCROLL_BAR_HEIGHT );
m_ScrollBar.SetBarTime( SCROLL_BAR_TIME );
for( p=0; p<NUM_PLAYERS; p++ )
for( int p=0; p<NUM_PLAYERS; p++ )
m_ScrollBar.EnablePlayer( (PlayerNumber)p, GAMESTATE->IsHumanPlayer(p) );
m_ScrollBar.Load();
UtilSetXY( m_ScrollBar, "ScreenOptions" );
@@ -314,8 +328,10 @@ void ScreenOptions::Init( InputMode im, OptionRow OptionRows[], int iNumOptionLi
switch( m_InputMode )
{
case INPUTMODE_INDIVIDUAL:
for( p=0; p<NUM_PLAYERS; p++ )
m_textExplanation[p].SetXY( EXPLANATION_X(p), EXPLANATION_Y(p) );
{
for( int p=0; p<NUM_PLAYERS; p++ )
m_textExplanation[p].SetXY( EXPLANATION_X(p), EXPLANATION_Y(p) );
}
break;
case INPUTMODE_TOGETHER:
m_textExplanation[0].SetXY( EXPLANATION_TOGETHER_X, EXPLANATION_TOGETHER_Y );
@@ -329,10 +345,12 @@ void ScreenOptions::Init( InputMode im, OptionRow OptionRows[], int iNumOptionLi
m_framePage.AddChild( m_sprFrame );
// poke once at all the explanation metrics so that we catch missing ones early
for( r=0; r<(int)m_Rows.size(); r++ ) // foreach row
{
GetExplanationText( r );
GetExplanationTitle( r );
for( int r=0; r<(int)m_Rows.size(); r++ ) // foreach row
{
GetExplanationText( r );
GetExplanationTitle( r );
}
}
CHECKPOINT;
@@ -343,15 +361,17 @@ void ScreenOptions::Init( InputMode im, OptionRow OptionRows[], int iNumOptionLi
RefreshIcons();
PositionCursors();
UpdateEnabledDisabled();
for( p=0; p<NUM_PLAYERS; p++ )
OnChange( (PlayerNumber)p );
{
for( int p=0; p<NUM_PLAYERS; p++ )
OnChange( (PlayerNumber)p );
}
CHECKPOINT;
/* 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. */
for( r=0; r<(int) m_Rows.size(); r++ ) // foreach options line
for( int r=0; r<(int) m_Rows.size(); r++ ) // foreach options line
{
Row &row = *m_Rows[r];
row.m_sprBullet.FinishTweening();
@@ -424,7 +444,7 @@ BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow )
if( !row.m_bRowIsLong )
{
unsigned iOptionInRow = m_iSelectedOption[pn][iRow];
unsigned iOptionInRow = m_Rows[iRow]->m_iSelection[pn];
return *row.m_textItems[iOptionInRow];
}
@@ -615,9 +635,9 @@ void ScreenOptions::UpdateText( PlayerNumber player_no, int iRow )
if( !row.m_bRowIsLong )
return;
int iChoiceInRow = m_iSelectedOption[player_no][iRow];
int iChoiceInRow = m_Rows[iRow]->m_iSelection[player_no];
const OptionRow &optrow = m_Rows[iRow]->m_RowDef;
const OptionRowData &optrow = m_Rows[iRow]->m_RowDef;
unsigned item_no = optrow.bOneChoiceForAllPlayers?0:player_no;
@@ -1013,7 +1033,7 @@ void ScreenOptions::ChangeValue( PlayerNumber pn, int iDelta, bool Repeat )
{
const int iCurRow = m_iCurrentRow[pn];
Row &row = *m_Rows[iCurRow];
OptionRow &optrow = m_Rows[iCurRow]->m_RowDef;
OptionRowData &optrow = m_Rows[iCurRow]->m_RowDef;
/* If START is being pressed, and in NAV_THREE_KEY, then we're holding left/right
* and start to move backwards. Don't move left and right, too. */
@@ -1044,23 +1064,23 @@ void ScreenOptions::ChangeValue( PlayerNumber pn, int iDelta, bool Repeat )
if( p != pn )
continue; // skip
int iNewSel = m_iSelectedOption[p][iCurRow] + iDelta;
int iNewSel = m_Rows[iCurRow]->m_iSelection[p] + iDelta;
wrap( iNewSel, iNumOptions );
if( iNewSel != m_iSelectedOption[p][iCurRow] )
if( iNewSel != m_Rows[iCurRow]->m_iSelection[p] )
bOneChanged = true;
if( optrow.bOneChoiceForAllPlayers )
{
for( int p2=0; p2<NUM_PLAYERS; p2++ )
{
m_iSelectedOption[p2][iCurRow] = iNewSel;
m_Rows[iCurRow]->m_iSelection[p2] = iNewSel;
UpdateText( (PlayerNumber)p2, iCurRow );
}
}
else
{
m_iSelectedOption[p][iCurRow] = iNewSel;
m_Rows[iCurRow]->m_iSelection[p] = iNewSel;
UpdateText( (PlayerNumber)p, iCurRow );
}
OnChange( (PlayerNumber)p );
+7 -10
View File
@@ -23,18 +23,16 @@
#include "DualScrollBar.h"
const unsigned MAX_OPTION_LINES = 40;
struct OptionRow
struct OptionRowData
{
CString name;
bool bOneChoiceForAllPlayers;
vector<CString> choices;
bool bMultiSelect;
OptionRow(): name(""), bOneChoiceForAllPlayers(false), bMultiSelect(false) { }
OptionRowData(): name(""), bOneChoiceForAllPlayers(false), bMultiSelect(false) { }
OptionRow( const char *n, int b, const char *c0=NULL, const char *c1=NULL, const char *c2=NULL, const char *c3=NULL, const char *c4=NULL, const char *c5=NULL, const char *c6=NULL, const char *c7=NULL, const char *c8=NULL, const char *c9=NULL, const char *c10=NULL, const char *c11=NULL, const char *c12=NULL, const char *c13=NULL, const char *c14=NULL, const char *c15=NULL, const char *c16=NULL, const char *c17=NULL, const char *c18=NULL, const char *c19=NULL )
OptionRowData( const char *n, int b, const char *c0=NULL, const char *c1=NULL, const char *c2=NULL, const char *c3=NULL, const char *c4=NULL, const char *c5=NULL, const char *c6=NULL, const char *c7=NULL, const char *c8=NULL, const char *c9=NULL, const char *c10=NULL, const char *c11=NULL, const char *c12=NULL, const char *c13=NULL, const char *c14=NULL, const char *c15=NULL, const char *c16=NULL, const char *c17=NULL, const char *c18=NULL, const char *c19=NULL )
{
name = n;
bOneChoiceForAllPlayers = !!b;
@@ -56,7 +54,7 @@ class ScreenOptions : public Screen
{
public:
ScreenOptions( CString sClassName );
void Init( InputMode im, OptionRow OptionRow[], int iNumOptionLines );
void Init( InputMode im, OptionRowData OptionRowData[], int iNumOptionLines );
virtual ~ScreenOptions();
virtual void Update( float fDeltaTime );
virtual void DrawPrimitives();
@@ -96,14 +94,12 @@ protected:
void MenuDown( PlayerNumber pn, const InputEventType type ) { Move( pn, +1, type != IET_FIRST_PRESS ); }
void Move( PlayerNumber pn, int dir, bool Repeat );
/* Returns -1 if on a row with no OptionRow (eg. EXIT). */
/* Returns -1 if on a row with no OptionRowData (eg. EXIT). */
int GetCurrentRow(PlayerNumber pn = PLAYER_1) const;
MenuElements m_Menu;
protected: // derived classes need access to these
int m_iSelectedOption[NUM_PLAYERS][MAX_OPTION_LINES];
void LoadOptionIcon( PlayerNumber pn, int iRow, CString sText );
enum Navigation { NAV_THREE_KEY, NAV_THREE_KEY_MENU, NAV_FIVE_KEY };
void SetNavigation( Navigation nav ) { m_OptionsNavigation = nav; }
@@ -114,7 +110,7 @@ protected:
{
Row();
~Row();
OptionRow m_RowDef;
OptionRowData m_RowDef;
enum { ROW_NORMAL, ROW_EXIT } Type;
vector<BitmapText *> m_textItems;
Sprite m_sprBullet;
@@ -125,6 +121,7 @@ protected:
float m_fY;
bool m_bRowIsLong; // goes off edge of screen
bool m_bHidden; // currently off screen
int m_iSelection[NUM_PLAYERS];
};
vector<Row*> m_Rows;
+19 -21
View File
@@ -35,7 +35,7 @@
// #define PREV_SCREEN( play_mode ) THEME->GetMetric (m_sName,"PrevScreen"+Capitalize(PlayModeToString(play_mode)))
/* Add the list named "ListName" to the given row/handler. */
void ScreenOptionsMaster::SetList( OptionRow &row, OptionRowHandler &hand, CString ListName, CString &TitleOut )
void ScreenOptionsMaster::SetList( OptionRowData &row, OptionRowHandler &hand, CString ListName, CString &TitleOut )
{
hand.type = ROW_LIST;
@@ -89,7 +89,7 @@ void ScreenOptionsMaster::SetList( OptionRow &row, OptionRowHandler &hand, CStri
}
/* Add a list of difficulties/edits to the given row/handler. */
void ScreenOptionsMaster::SetStep( OptionRow &row, OptionRowHandler &hand )
void ScreenOptionsMaster::SetStep( OptionRowData &row, OptionRowHandler &hand )
{
hand.type = ROW_STEP;
row.bOneChoiceForAllPlayers = false;
@@ -131,7 +131,7 @@ void ScreenOptionsMaster::SetStep( OptionRow &row, OptionRowHandler &hand )
/* Add the given configuration value to the given row/handler. */
void ScreenOptionsMaster::SetConf( OptionRow &row, OptionRowHandler &hand, CString param, CString &TitleOut )
void ScreenOptionsMaster::SetConf( OptionRowData &row, OptionRowHandler &hand, CString param, CString &TitleOut )
{
/* Configuration values are never per-player. */
row.bOneChoiceForAllPlayers = true;
@@ -147,7 +147,7 @@ void ScreenOptionsMaster::SetConf( OptionRow &row, OptionRowHandler &hand, CStri
}
/* Add a list of available characters to the given row/handler. */
void ScreenOptionsMaster::SetCharacter( OptionRow &row, OptionRowHandler &hand )
void ScreenOptionsMaster::SetCharacter( OptionRowData &row, OptionRowHandler &hand )
{
hand.type = ROW_CHARACTER;
row.bOneChoiceForAllPlayers = false;
@@ -163,7 +163,7 @@ void ScreenOptionsMaster::SetCharacter( OptionRow &row, OptionRowHandler &hand )
}
/* Add a list of available characters to the given row/handler. */
void ScreenOptionsMaster::SetSaveToProfile( OptionRow &row, OptionRowHandler &hand )
void ScreenOptionsMaster::SetSaveToProfile( OptionRowData &row, OptionRowHandler &hand )
{
hand.type = ROW_SAVE_TO_PROFILE;
row.bOneChoiceForAllPlayers = false;
@@ -213,10 +213,10 @@ ScreenOptionsMaster::ScreenOptionsMaster( CString sClassName ):
if( NumRows == -1 )
RageException::Throw( "%s::OptionMenuFlags is missing \"rows\" field", m_sName.c_str() );
m_OptionRowAlloc = new OptionRow[NumRows];
m_OptionRowAlloc = new OptionRowData[NumRows];
for( i = 0; (int) i < NumRows; ++i )
{
OptionRow &row = m_OptionRowAlloc[i];
OptionRowData &row = m_OptionRowAlloc[i];
CStringArray asParts;
split( ROW_LINE(i), ";", asParts );
@@ -271,7 +271,7 @@ ScreenOptionsMaster::~ScreenOptionsMaster()
delete [] m_OptionRowAlloc;
}
int ScreenOptionsMaster::ImportOption( const OptionRow &row, const OptionRowHandler &hand, int pn, int rowno )
int ScreenOptionsMaster::ImportOption( const OptionRowData &row, const OptionRowHandler &hand, int pn, int rowno )
{
/* Figure out which selection is the default. */
switch( hand.type )
@@ -362,13 +362,13 @@ void ScreenOptionsMaster::ImportOptions()
for( unsigned i = 0; i < OptionRowHandlers.size(); ++i )
{
const OptionRowHandler &hand = OptionRowHandlers[i];
const OptionRow &row = m_OptionRowAlloc[i];
const OptionRowData &row = m_OptionRowAlloc[i];
if( row.bOneChoiceForAllPlayers )
{
int col = ImportOption( row, hand, 0, i );
m_iSelectedOption[0][i] = col;
ASSERT( m_iSelectedOption[0][i] < (int)row.choices.size() );
m_Rows[i]->m_iSelection[0] = col;
ASSERT( m_Rows[i]->m_iSelection[0] < (int)row.choices.size() );
}
else
for( int pn=0; pn<NUM_PLAYERS; pn++ )
@@ -377,15 +377,15 @@ void ScreenOptionsMaster::ImportOptions()
continue;
int col = ImportOption( row, hand, pn, i );
m_iSelectedOption[pn][i] = col;
ASSERT( m_iSelectedOption[pn][i] < (int)row.choices.size() );
m_Rows[i]->m_iSelection[pn] = col;
ASSERT( m_Rows[i]->m_iSelection[pn] < (int)row.choices.size() );
}
}
}
/* Returns an OPT mask. */
int ScreenOptionsMaster::ExportOption( const OptionRow &row, const OptionRowHandler &hand, int pn, int sel )
int ScreenOptionsMaster::ExportOption( const OptionRowData &row, const OptionRowHandler &hand, int pn, int sel )
{
/* Figure out which selection is the default. */
switch( hand.type )
@@ -485,14 +485,14 @@ void ScreenOptionsMaster::ExportOptions()
for( i = 0; i < OptionRowHandlers.size(); ++i )
{
const OptionRowHandler &hand = OptionRowHandlers[i];
const OptionRow &row = m_OptionRowAlloc[i];
const OptionRowData &row = m_OptionRowAlloc[i];
for( int pn=0; pn<NUM_PLAYERS; pn++ )
{
if( !GAMESTATE->IsHumanPlayer(pn) )
continue;
ChangeMask |= ExportOption( row, hand, pn, m_iSelectedOption[pn][i] );
ChangeMask |= ExportOption( row, hand, pn, m_Rows[i]->m_iSelection[pn] );
}
}
@@ -507,7 +507,7 @@ void ScreenOptionsMaster::ExportOptions()
const OptionRowHandler &hand = OptionRowHandlers[row];
if( hand.type == ROW_LIST )
{
const int sel = m_iSelectedOption[0][row];
const int sel = m_Rows[row]->m_iSelection[0];
const ModeChoice &mc = hand.ListEntries[sel];
if( mc.m_sScreen != "" )
m_NextScreen = mc.m_sScreen;
@@ -571,8 +571,6 @@ void ScreenOptionsMaster::GoToPrevState()
void ScreenOptionsMaster::RefreshIcons()
{
ASSERT( m_Rows.size() < MAX_OPTION_LINES );
for( int p=0; p<NUM_PLAYERS; p++ ) // foreach player
{
if( !GAMESTATE->IsHumanPlayer(p) )
@@ -583,9 +581,9 @@ void ScreenOptionsMaster::RefreshIcons()
if( m_Rows[i]->Type == Row::ROW_EXIT )
continue; // skip
const OptionRow &row = m_Rows[i]->m_RowDef;
const OptionRowData &row = m_Rows[i]->m_RowDef;
int iSelection = m_iSelectedOption[p][i];
int iSelection = m_Rows[i]->m_iSelection[p];
if( iSelection >= (int)row.choices.size() )
{
/* Invalid selection. Send debug output, to aid debugging. */
+8 -8
View File
@@ -39,15 +39,15 @@ private:
CString m_NextScreen;
vector<OptionRowHandler> OptionRowHandlers;
OptionRow *m_OptionRowAlloc;
OptionRowData *m_OptionRowAlloc;
int ExportOption( const OptionRow &row, const OptionRowHandler &hand, int pn, int sel );
int ImportOption( const OptionRow &row, const OptionRowHandler &hand, int pn, int rowno );
void SetList( OptionRow &row, OptionRowHandler &hand, CString param, CString &TitleOut );
void SetStep( OptionRow &row, OptionRowHandler &hand );
void SetConf( OptionRow &row, OptionRowHandler &hand, CString param, CString &TitleOut );
void SetCharacter( OptionRow &row, OptionRowHandler &hand );
void SetSaveToProfile( OptionRow &row, OptionRowHandler &hand );
int ExportOption( const OptionRowData &row, const OptionRowHandler &hand, int pn, int sel );
int ImportOption( const OptionRowData &row, const OptionRowHandler &hand, int pn, int rowno );
void SetList( OptionRowData &row, OptionRowHandler &hand, CString param, CString &TitleOut );
void SetStep( OptionRowData &row, OptionRowHandler &hand );
void SetConf( OptionRowData &row, OptionRowHandler &hand, CString param, CString &TitleOut );
void SetCharacter( OptionRowData &row, OptionRowHandler &hand );
void SetSaveToProfile( OptionRowData &row, OptionRowHandler &hand );
protected:
virtual void ImportOptions();
+18 -18
View File
@@ -33,14 +33,14 @@ enum {
NUM_PROFILE_OPTIONS_LINES
};
OptionRow g_ProfileOptionsLines[NUM_PROFILE_OPTIONS_LINES] = {
OptionRow( "Player1\nProfile", true ),
OptionRow( "Player2\nProfile", true ),
OptionRow( "Create\nNew", true, "PRESS START" ),
OptionRow( "Delete", true ),
OptionRow( "Rename", true ),
OptionRow( "OS Mount\nPlayer1", true, "" ),
OptionRow( "OS Mount\nPlayer2", true, "" ),
OptionRowData g_ProfileOptionsLines[NUM_PROFILE_OPTIONS_LINES] = {
OptionRowData( "Player1\nProfile", true ),
OptionRowData( "Player2\nProfile", true ),
OptionRowData( "Create\nNew", true, "PRESS START" ),
OptionRowData( "Delete", true ),
OptionRowData( "Rename", true ),
OptionRowData( "OS Mount\nPlayer1", true, "" ),
OptionRowData( "OS Mount\nPlayer2", true, "" ),
};
const ScreenMessage SM_DoneCreating = ScreenMessage(SM_User+1);
@@ -97,14 +97,14 @@ void ScreenProfileOptions::ImportOptions()
vsProfiles.end(),
PREFSMAN->m_sDefaultLocalProfileID[PLAYER_1] );
if( iter != vsProfiles.end() )
m_iSelectedOption[0][PO_PLAYER1] = iter - vsProfiles.begin() + 1;
m_Rows[PO_PLAYER1]->m_iSelection[0] = iter - vsProfiles.begin() + 1;
iter = find(
vsProfiles.begin(),
vsProfiles.end(),
PREFSMAN->m_sDefaultLocalProfileID[PLAYER_2] );
if( iter != vsProfiles.end() )
m_iSelectedOption[0][PO_PLAYER2] = iter - vsProfiles.begin() + 1;
m_Rows[PO_PLAYER2]->m_iSelection[0] = iter - vsProfiles.begin() + 1;
}
void ScreenProfileOptions::ExportOptions()
@@ -112,13 +112,13 @@ void ScreenProfileOptions::ExportOptions()
vector<CString> vsProfiles;
PROFILEMAN->GetLocalProfileIDs( vsProfiles );
if( m_iSelectedOption[0][PO_PLAYER1] > 0 )
PREFSMAN->m_sDefaultLocalProfileID[PLAYER_1] = vsProfiles[m_iSelectedOption[0][PO_PLAYER1]-1];
if( m_Rows[PO_PLAYER1]->m_iSelection[0] > 0 )
PREFSMAN->m_sDefaultLocalProfileID[PLAYER_1] = vsProfiles[m_Rows[PO_PLAYER1]->m_iSelection[0]-1];
else
PREFSMAN->m_sDefaultLocalProfileID[PLAYER_1] = "";
if( m_iSelectedOption[0][PO_PLAYER2] > 0 )
PREFSMAN->m_sDefaultLocalProfileID[PLAYER_2] = vsProfiles[m_iSelectedOption[0][PO_PLAYER2]-1];
if( m_Rows[PO_PLAYER2]->m_iSelection[0] > 0 )
PREFSMAN->m_sDefaultLocalProfileID[PLAYER_2] = vsProfiles[m_Rows[PO_PLAYER2]->m_iSelection[0]-1];
else
PREFSMAN->m_sDefaultLocalProfileID[PLAYER_2] = "";
}
@@ -212,17 +212,17 @@ CString ScreenProfileOptions::GetSelectedProfileID()
vector<CString> vsProfiles;
PROFILEMAN->GetLocalProfileIDs( vsProfiles );
if( m_iSelectedOption[0][GetCurrentRow()]==0 )
if( m_Rows[GetCurrentRow()]->m_iSelection[0] )
return "";
else
return vsProfiles[m_iSelectedOption[0][GetCurrentRow()]-1];
return vsProfiles[ m_Rows[GetCurrentRow()]->m_iSelection[0]-1];
}
CString ScreenProfileOptions::GetSelectedProfileName()
{
if( m_iSelectedOption[0][GetCurrentRow()]==0 )
if( m_Rows[GetCurrentRow()]->m_iSelection[0] )
return "";
else
return g_ProfileOptionsLines[PO_PLAYER1].choices[ m_iSelectedOption[0][GetCurrentRow()] ];
return g_ProfileOptionsLines[PO_PLAYER1].choices[ m_Rows[GetCurrentRow()]->m_iSelection[0] ];
}