MoveRowRelative should skip disabled rows, but didn't because
it was used by MoveRowAbsolute. Refactor: MoveRowAbsolute sets directly, ignoring whether a row is disabled (if you say "select row 3", you mean it). MoveRowRelative checks disabled rows, with logic pulled from MenuUpDown (slightly refactored). That way, the disabled-row logic affects all relative movement. (Net simplification.)
This commit is contained in:
@@ -955,7 +955,7 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input )
|
|||||||
case NAV_FIVE_KEY:
|
case NAV_FIVE_KEY:
|
||||||
/* Jump to the exit row. (If everyone's already on the exit row, then
|
/* Jump to the exit row. (If everyone's already on the exit row, then
|
||||||
* we'll have already gone to the next screen above.) */
|
* we'll have already gone to the next screen above.) */
|
||||||
if( MoveRowRelative(pn, m_pRows.size()-m_iCurrentRow[pn]-1, input.type != IET_FIRST_PRESS) )
|
if( MoveRowAbsolute(pn, m_pRows.size()-1, input.type != IET_FIRST_PRESS) )
|
||||||
m_SoundNextRow.Play();
|
m_SoundNextRow.Play();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1139,32 +1139,33 @@ bool ScreenOptions::MoveRowRelative( PlayerNumber pn, int iDir, bool bRepeat )
|
|||||||
{
|
{
|
||||||
LOG->Trace( "MoveRowRelative(pn %i, dir %i, rep %i)", pn, iDir, bRepeat );
|
LOG->Trace( "MoveRowRelative(pn %i, dir %i, rep %i)", pn, iDir, bRepeat );
|
||||||
|
|
||||||
bool bChanged = false;
|
int iDest = -1;
|
||||||
FOREACH_PlayerNumber( p )
|
ASSERT( m_pRows.size() );
|
||||||
|
for( int r=1; r<(int)m_pRows.size(); r++ )
|
||||||
{
|
{
|
||||||
if( m_InputMode == INPUTMODE_INDIVIDUAL && p != pn )
|
int iDelta = r*iDir;
|
||||||
continue; // skip
|
iDest = m_iCurrentRow[pn] + iDelta;
|
||||||
|
wrap( iDest, m_pRows.size() );
|
||||||
|
|
||||||
//
|
OptionRow &row = *m_pRows[iDest];
|
||||||
// Update m_iCurrentRow.
|
if( row.GetRowDef().IsEnabledForPlayer(pn) )
|
||||||
//
|
break;
|
||||||
int iRow = m_iCurrentRow[p] + iDir;
|
|
||||||
if( bRepeat && ( iRow == -1 || iRow == (int) m_pRows.size() ) )
|
|
||||||
continue; // don't wrap while repeating
|
|
||||||
|
|
||||||
wrap( iRow, m_pRows.size() );
|
iDest = -1;
|
||||||
|
|
||||||
if( m_iCurrentRow[p] == iRow )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
m_iCurrentRow[p] = iRow;
|
|
||||||
ASSERT( iRow >= 0 && iRow < (int)m_pRows.size() );
|
|
||||||
|
|
||||||
AfterChangeRow( p );
|
|
||||||
bChanged = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bChanged;
|
if( iDest == -1 )
|
||||||
|
return false;
|
||||||
|
if( bRepeat )
|
||||||
|
{
|
||||||
|
// Don't wrap on repeating inputs.
|
||||||
|
if( iDir > 0 && iDest < m_iCurrentRow[pn] )
|
||||||
|
return false;
|
||||||
|
if( iDir < 0 && iDest > m_iCurrentRow[pn] )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MoveRowAbsolute( pn, iDest, bRepeat );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenOptions::AfterChangeRow( PlayerNumber pn )
|
void ScreenOptions::AfterChangeRow( PlayerNumber pn )
|
||||||
@@ -1203,7 +1204,6 @@ void ScreenOptions::AfterChangeRow( PlayerNumber pn )
|
|||||||
// the first choice.
|
// the first choice.
|
||||||
row.SetChoiceInRowWithFocus( pn, 0 );
|
row.SetChoiceInRowWithFocus( pn, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AfterChangeValueOrRow( pn );
|
AfterChangeValueOrRow( pn );
|
||||||
@@ -1211,8 +1211,22 @@ void ScreenOptions::AfterChangeRow( PlayerNumber pn )
|
|||||||
|
|
||||||
bool ScreenOptions::MoveRowAbsolute( PlayerNumber pn, int iRow, bool bRepeat )
|
bool ScreenOptions::MoveRowAbsolute( PlayerNumber pn, int iRow, bool bRepeat )
|
||||||
{
|
{
|
||||||
int iDir = iRow - m_iCurrentRow[pn];
|
bool bChanged = false;
|
||||||
return MoveRowRelative( pn, iDir, bRepeat );
|
FOREACH_PlayerNumber( p )
|
||||||
|
{
|
||||||
|
if( m_InputMode == INPUTMODE_INDIVIDUAL && p != pn )
|
||||||
|
continue; // skip
|
||||||
|
|
||||||
|
if( m_iCurrentRow[p] == iRow )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
m_iCurrentRow[p] = iRow;
|
||||||
|
|
||||||
|
AfterChangeRow( p );
|
||||||
|
bChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenOptions::MenuUp( const InputEventPlus &input )
|
void ScreenOptions::MenuUp( const InputEventPlus &input )
|
||||||
@@ -1253,36 +1267,13 @@ void ScreenOptions::MenuUpDown( const InputEventPlus &input, int iDir )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bRepeat = input.type != IET_FIRST_PRESS;
|
if( MoveRowRelative(pn, iDir, input.type != IET_FIRST_PRESS) )
|
||||||
|
|
||||||
int iDest = -1;
|
|
||||||
for( int r=1; r<(int)m_pRows.size(); r++ )
|
|
||||||
{
|
|
||||||
int iDelta = r*iDir;
|
|
||||||
iDest = m_iCurrentRow[pn] + iDelta;
|
|
||||||
int iOldDest = iDest;
|
|
||||||
ASSERT( m_pRows.size() );
|
|
||||||
wrap( iDest, m_pRows.size() );
|
|
||||||
|
|
||||||
// Don't wrap on repeating inputs.
|
|
||||||
bool bWrapped = iOldDest != iDest;
|
|
||||||
if( bRepeat && bWrapped )
|
|
||||||
return;
|
|
||||||
|
|
||||||
OptionRow &row = *m_pRows[iDest];
|
|
||||||
|
|
||||||
if( row.GetRowDef().IsEnabledForPlayer(pn) )
|
|
||||||
{
|
|
||||||
if( MoveRowRelative(pn, iDelta, bRepeat) )
|
|
||||||
{
|
{
|
||||||
if( iDir < 0 )
|
if( iDir < 0 )
|
||||||
m_SoundPrevRow.Play();
|
m_SoundPrevRow.Play();
|
||||||
else
|
else
|
||||||
m_SoundNextRow.Play();
|
m_SoundNextRow.Play();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user