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