position underlines per-player

This commit is contained in:
Chris Danford
2005-03-13 02:15:38 +00:00
parent 3ee87782eb
commit 0ab7c031bc
5 changed files with 54 additions and 52 deletions
+31 -33
View File
@@ -375,7 +375,7 @@ void OptionRow::LoadExit()
m_textTitle.SetHidden( true ); m_textTitle.SetHidden( true );
} }
void OptionRow::PositionUnderlines() void OptionRow::PositionUnderlines( PlayerNumber pn )
{ {
/* /*
SHOW_UNDERLINES SHOW_UNDERLINES
@@ -384,43 +384,40 @@ void OptionRow::PositionUnderlines()
if( m_RowType == ROW_EXIT ) if( m_RowType == ROW_EXIT )
return; return;
FOREACH_HumanPlayer( p ) vector<OptionsCursor*> &vpUnderlines = m_Underline[pn];
PlayerNumber pnTakeSelectedFrom = m_RowDef.bOneChoiceForAllPlayers ? PLAYER_1 : pn;
const int iNumUnderlines = (m_RowDef.layoutType == LAYOUT_SHOW_ONE_IN_ROW) ? 1 : vpUnderlines.size();
for( int i=0; i<iNumUnderlines; i++ )
{ {
vector<OptionsCursor*> &vpUnderlines = m_Underline[p]; OptionsCursor& ul = *vpUnderlines[i];
PlayerNumber pnTakeSelectedFrom = m_RowDef.bOneChoiceForAllPlayers ? PLAYER_1 : p; int iChoiceWithFocus = (m_RowDef.layoutType == LAYOUT_SHOW_ONE_IN_ROW) ? m_iChoiceInRowWithFocus[pnTakeSelectedFrom] : i;
const int iNumUnderlines = (m_RowDef.layoutType == LAYOUT_SHOW_ONE_IN_ROW) ? 1 : vpUnderlines.size(); /* Don't tween X movement and color changes. */
int iWidth, iX, iY;
GetWidthXY( pn, iChoiceWithFocus, iWidth, iX, iY );
ul.SetGlobalX( (float)iX );
ul.SetGlobalDiffuseColor( RageColor(1,1,1, 1.0f) );
for( int i=0; i<iNumUnderlines; i++ ) ASSERT( m_vbSelected[pnTakeSelectedFrom].size() == m_RowDef.choices.size() );
bool bSelected = m_vbSelected[pnTakeSelectedFrom][ iChoiceWithFocus ];
bool bHidden = !bSelected || m_bHidden;
if( !(bool)SHOW_UNDERLINES )
bHidden = true;
if( ul.GetDestY() != m_fY )
{ {
OptionsCursor& ul = *vpUnderlines[i]; ul.StopTweening();
ul.BeginTweening( TWEEN_SECONDS );
int iChoiceWithFocus = (m_RowDef.layoutType == LAYOUT_SHOW_ONE_IN_ROW) ? m_iChoiceInRowWithFocus[pnTakeSelectedFrom] : i;
/* Don't tween X movement and color changes. */
int iWidth, iX, iY;
GetWidthXY( p, iChoiceWithFocus, iWidth, iX, iY );
ul.SetGlobalX( (float)iX );
ul.SetGlobalDiffuseColor( RageColor(1,1,1, 1.0f) );
ASSERT( m_vbSelected[pnTakeSelectedFrom].size() == m_RowDef.choices.size() );
bool bSelected = m_vbSelected[pnTakeSelectedFrom][ iChoiceWithFocus ];
bool bHidden = !bSelected || m_bHidden;
if( !(bool)SHOW_UNDERLINES )
bHidden = true;
if( ul.GetDestY() != m_fY )
{
ul.StopTweening();
ul.BeginTweening( TWEEN_SECONDS );
}
ul.SetHidden( bHidden );
ul.SetBarWidth( iWidth );
ul.SetY( (float)iY );
} }
ul.SetHidden( bHidden );
ul.SetBarWidth( iWidth );
ul.SetY( (float)iY );
} }
} }
@@ -715,7 +712,8 @@ void OptionRow::Reload()
UpdateEnabledDisabled(); UpdateEnabledDisabled();
UpdateText(); UpdateText();
PositionUnderlines(); FOREACH_HumanPlayer( p )
PositionUnderlines( p );
} }
break; break;
case OptionRow::ROW_EXIT: case OptionRow::ROW_EXIT:
+1 -1
View File
@@ -88,7 +88,7 @@ public:
); );
void DetachHandler(); void DetachHandler();
void PositionUnderlines(); void PositionUnderlines( PlayerNumber pn );
void PositionIcons(); void PositionIcons();
void UpdateText(); void UpdateText();
void SetRowFocus( bool bRowHasFocus[NUM_PLAYERS] ); void SetRowFocus( bool bRowHasFocus[NUM_PLAYERS] );
+16 -14
View File
@@ -265,7 +265,7 @@ void ScreenOptions::InitMenu( InputMode im, const vector<OptionRowDefinition> &v
CHECKPOINT; CHECKPOINT;
PositionItems(); PositionItems();
PositionUnderlines(); PositionAllUnderlines();
PositionIcons(); PositionIcons();
RefreshIcons(); RefreshIcons();
PositionCursors(); PositionCursors();
@@ -368,18 +368,17 @@ void ScreenOptions::GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int
row.GetWidthXY( pn, iChoiceOnRow, iWidthOut, iXOut, iYOut ); row.GetWidthXY( pn, iChoiceOnRow, iWidthOut, iXOut, iYOut );
} }
void ScreenOptions::PositionUnderlines() void ScreenOptions::PositionUnderlines( int r, PlayerNumber pn )
{ {
// OPTIMIZATION OPPORTUNITY: There's no reason to the underlines for OptionRow &row = *m_Rows[r];
// all rows when something changes. Just recalulate for the row that row.PositionUnderlines( pn );
// changed. }
// Set the position of the underscores showing the current choice for each option line. void ScreenOptions::PositionAllUnderlines()
for( unsigned r=0; r<m_Rows.size(); r++ ) // foreach options line {
{ for( unsigned r=0; r<m_Rows.size(); r++ )
OptionRow &row = *m_Rows[r]; FOREACH_HumanPlayer( p )
row.PositionUnderlines(); PositionUnderlines( r, p );
}
} }
void ScreenOptions::PositionIcons() void ScreenOptions::PositionIcons()
@@ -661,11 +660,13 @@ void ScreenOptions::OnChange( PlayerNumber pn )
if( !GAMESTATE->IsHumanPlayer(pn) ) if( !GAMESTATE->IsHumanPlayer(pn) )
return; return;
const int iCurRow = m_iCurrentRow[pn];
/* Update m_fY and m_bHidden[]. */ /* Update m_fY and m_bHidden[]. */
PositionItems(); PositionItems();
/* Do positioning. */ /* Do positioning. */
PositionUnderlines(); PositionUnderlines( iCurRow, pn );
RefreshIcons(); RefreshIcons();
PositionIcons(); PositionIcons();
UpdateEnabledDisabled(); UpdateEnabledDisabled();
@@ -706,7 +707,6 @@ void ScreenOptions::OnChange( PlayerNumber pn )
} }
} }
const int iCurRow = m_iCurrentRow[pn];
const CString text = GetExplanationText( iCurRow ); const CString text = GetExplanationText( iCurRow );
BitmapText *pText = NULL; BitmapText *pText = NULL;
@@ -820,11 +820,13 @@ void ScreenOptions::MenuStart( PlayerNumber pn, const InputEventType selectType
int iChoiceInRow = row.GetChoiceInRowWithFocus(pn); int iChoiceInRow = row.GetChoiceInRowWithFocus(pn);
bool bSelected = !row.GetSelected( pn, iChoiceInRow ); bool bSelected = !row.GetSelected( pn, iChoiceInRow );
row.SetSelected( pn, iChoiceInRow, bSelected ); row.SetSelected( pn, iChoiceInRow, bSelected );
if( bSelected ) if( bSelected )
m_SoundToggleOn.Play(); m_SoundToggleOn.Play();
else else
m_SoundToggleOff.Play(); m_SoundToggleOff.Play();
PositionUnderlines();
PositionUnderlines( iCurRow, pn );
RefreshIcons(); RefreshIcons();
if( row.GetFirstItemGoesDown() ) if( row.GetFirstItemGoesDown() )
+2 -1
View File
@@ -40,7 +40,8 @@ protected:
CString GetExplanationText( int row ) const; CString GetExplanationText( int row ) const;
CString GetExplanationTitle( int row ) const; CString GetExplanationTitle( int row ) const;
BitmapText &GetTextItemForRow( PlayerNumber pn, int iRow, int iChoiceOnRow ); BitmapText &GetTextItemForRow( PlayerNumber pn, int iRow, int iChoiceOnRow );
void PositionUnderlines(); void PositionUnderlines( int row, PlayerNumber pn );
void PositionAllUnderlines();
void PositionIcons(); void PositionIcons();
virtual void RefreshIcons(); virtual void RefreshIcons();
void PositionCursors(); void PositionCursors();
+3 -2
View File
@@ -148,10 +148,11 @@ void ScreenPlayerOptions::Input( const DeviceInput& DeviceI, const InputEventTyp
COMMAND( m_sprCancelAll[pn], "Show" ); COMMAND( m_sprCancelAll[pn], "Show" );
for( unsigned r=0; r<m_Rows.size(); r++ ) for( unsigned r=0; r<m_Rows.size(); r++ )
{
this->ImportOptions( r, pn ); this->ImportOptions( r, pn );
this->PositionUnderlines(); this->PositionUnderlines( r, pn );
for( unsigned r=0; r<m_Rows.size(); r++ )
this->UpdateDisqualified( r, pn ); this->UpdateDisqualified( r, pn );
}
} }
ScreenOptionsMaster::Input( DeviceI, type, GameI, MenuI, StyleI ); ScreenOptionsMaster::Input( DeviceI, type, GameI, MenuI, StyleI );