simplify: pull out loop

This commit is contained in:
Glenn Maynard
2006-02-03 09:45:06 +00:00
parent 082d3b570a
commit fc1a0fd75b
2 changed files with 21 additions and 22 deletions
+6 -7
View File
@@ -294,9 +294,11 @@ void ScreenOptions::RestartOptions()
PositionRows(); PositionRows();
FOREACH_HumanPlayer( pn ) FOREACH_HumanPlayer( pn )
{
for( unsigned r=0; r<m_pRows.size(); ++r ) for( unsigned r=0; r<m_pRows.size(); ++r )
this->RefreshIcons( r, pn ); this->RefreshIcons( r, pn );
PositionCursors(); PositionCursor( pn );
}
UpdateEnabledDisabled(); UpdateEnabledDisabled();
FOREACH_PlayerNumber( p ) FOREACH_PlayerNumber( p )
@@ -418,21 +420,19 @@ void ScreenOptions::RefreshIcons( int iRow, PlayerNumber pn )
m_pRows[iRow]->SetOptionIcon( pn, sIcon, gc ); m_pRows[iRow]->SetOptionIcon( pn, sIcon, gc );
} }
void ScreenOptions::PositionCursors() void ScreenOptions::PositionCursor( PlayerNumber pn )
{ {
// Set the position of the cursor showing the current option the user is changing. // Set the position of the cursor showing the current option the user is changing.
FOREACH_HumanPlayer( pn )
{
const int iRow = m_iCurrentRow[pn]; const int iRow = m_iCurrentRow[pn];
if( iRow == -1 ) if( iRow == -1 )
continue; return;
ASSERT_M( iRow >= 0 && iRow < (int)m_pRows.size(), ssprintf("%i < %i", iRow, (int)m_pRows.size() ) ); ASSERT_M( iRow >= 0 && iRow < (int)m_pRows.size(), ssprintf("%i < %i", iRow, (int)m_pRows.size() ) );
const OptionRow &row = *m_pRows[iRow]; const OptionRow &row = *m_pRows[iRow];
const int iChoiceWithFocus = row.GetChoiceInRowWithFocus(pn); const int iChoiceWithFocus = row.GetChoiceInRowWithFocus(pn);
if( iChoiceWithFocus == -1 ) if( iChoiceWithFocus == -1 )
continue; // skip return;
int iWidth, iX, iY; int iWidth, iX, iY;
GetWidthXY( pn, iRow, iChoiceWithFocus, iWidth, iX, iY ); GetWidthXY( pn, iRow, iChoiceWithFocus, iWidth, iX, iY );
@@ -443,7 +443,6 @@ void ScreenOptions::PositionCursors()
bool bCanGoLeft = iChoiceWithFocus > 0; bool bCanGoLeft = iChoiceWithFocus > 0;
bool bCanGoRight = iChoiceWithFocus >= 0 && iChoiceWithFocus < (int) row.GetRowDef().m_vsChoices.size()-1; bool bCanGoRight = iChoiceWithFocus >= 0 && iChoiceWithFocus < (int) row.GetRowDef().m_vsChoices.size()-1;
cursor.SetCanGo( bCanGoLeft, bCanGoRight ); cursor.SetCanGo( bCanGoLeft, bCanGoRight );
}
} }
void ScreenOptions::TweenCursor( PlayerNumber pn ) void ScreenOptions::TweenCursor( PlayerNumber pn )
+1 -1
View File
@@ -58,7 +58,7 @@ protected:
void GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ) const; void GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ) const;
RString GetExplanationText( int iRow ) const; RString GetExplanationText( int iRow ) const;
void RefreshIcons( int iRow, PlayerNumber pn ); void RefreshIcons( int iRow, PlayerNumber pn );
void PositionCursors(); void PositionCursor( PlayerNumber pn );
void PositionRows(); void PositionRows();
void TweenCursor( PlayerNumber pn ); void TweenCursor( PlayerNumber pn );
void UpdateEnabledDisabled(); void UpdateEnabledDisabled();