Add Menu(Left/Right/Up/Down)(P1/P2) messages to ScreenOptions.
This commit is contained in:
+28
-22
@@ -692,15 +692,15 @@ void ScreenOptions::AfterChangeValueOrRow( PlayerNumber pn )
|
|||||||
if( iCurRow == -1 )
|
if( iCurRow == -1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Update m_fY and m_bHidden[]. */
|
// Update m_fY and m_bHidden[].
|
||||||
PositionRows( true );
|
PositionRows( true );
|
||||||
|
|
||||||
/* Do positioning. */
|
// Do positioning.
|
||||||
RefreshIcons( iCurRow, pn );
|
RefreshIcons( iCurRow, pn );
|
||||||
for( unsigned r=0; r<m_pRows.size(); r++ )
|
for( unsigned r=0; r<m_pRows.size(); r++ )
|
||||||
{
|
{
|
||||||
/* After changing a value, position underlines. Do this for both players, since
|
/* After changing a value, position underlines. Do this for both players,
|
||||||
* underlines for both players will change with m_bOneChoiceForAllPlayers. */
|
* since underlines for both players will change with m_bOneChoiceForAllPlayers. */
|
||||||
FOREACH_HumanPlayer( p )
|
FOREACH_HumanPlayer( p )
|
||||||
m_pRows[r]->PositionUnderlines( p );
|
m_pRows[r]->PositionUnderlines( p );
|
||||||
m_pRows[r]->PositionIcons( pn );
|
m_pRows[r]->PositionIcons( pn );
|
||||||
@@ -716,7 +716,7 @@ void ScreenOptions::AfterChangeValueOrRow( PlayerNumber pn )
|
|||||||
m_ScrollBar.SetPercentage( pn, fPercent );
|
m_ScrollBar.SetPercentage( pn, fPercent );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update all players, since changing one player can move both cursors. */
|
// Update all players, since changing one player can move both cursors.
|
||||||
FOREACH_HumanPlayer( p )
|
FOREACH_HumanPlayer( p )
|
||||||
TweenCursor( p );
|
TweenCursor( p );
|
||||||
|
|
||||||
@@ -826,14 +826,12 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Check whether Start ends this screen.
|
// Check whether Start ends this screen.
|
||||||
//
|
|
||||||
{
|
{
|
||||||
bool bEndThisScreen = false;
|
bool bEndThisScreen = false;
|
||||||
|
|
||||||
// If we didn't apply and return above in NAV_THREE_KEY_MENU, then the selection
|
// If we didn't apply and return above in NAV_THREE_KEY_MENU, then the
|
||||||
// sets a screen.
|
// selection sets a screen.
|
||||||
if( m_OptionsNavigation == NAV_THREE_KEY_MENU )
|
if( m_OptionsNavigation == NAV_THREE_KEY_MENU )
|
||||||
bEndThisScreen = true;
|
bEndThisScreen = true;
|
||||||
|
|
||||||
@@ -845,7 +843,7 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input )
|
|||||||
if( AllAreOnLastRow() )
|
if( AllAreOnLastRow() )
|
||||||
bEndThisScreen = true;
|
bEndThisScreen = true;
|
||||||
|
|
||||||
/* Don't accept START to go to the next screen if we're still transitioning in. */
|
// Don't accept START to go to the next screen if we're still transitioning in.
|
||||||
if( bEndThisScreen &&
|
if( bEndThisScreen &&
|
||||||
(input.type != IET_FIRST_PRESS || IsTransitioning()) )
|
(input.type != IET_FIRST_PRESS || IsTransitioning()) )
|
||||||
return;
|
return;
|
||||||
@@ -933,7 +931,7 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input )
|
|||||||
|
|
||||||
void ScreenOptions::StoreFocus( PlayerNumber pn )
|
void ScreenOptions::StoreFocus( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
/* Long rows always put us in the center, so don't update the focus. */
|
// Long rows always put us in the center, so don't update the focus.
|
||||||
int iCurrentRow = m_iCurrentRow[pn];
|
int iCurrentRow = m_iCurrentRow[pn];
|
||||||
const OptionRow &row = *m_pRows[iCurrentRow];
|
const OptionRow &row = *m_pRows[iCurrentRow];
|
||||||
if( row.GetRowDef().m_layoutType == LAYOUT_SHOW_ONE_IN_ROW )
|
if( row.GetRowDef().m_layoutType == LAYOUT_SHOW_ONE_IN_ROW )
|
||||||
@@ -980,7 +978,7 @@ void ScreenOptions::BeginFadingOut()
|
|||||||
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Left/right */
|
// Left/right
|
||||||
void ScreenOptions::ChangeValueInRowAbsolute( int iRow, PlayerNumber pn, int iChoiceIndex, bool bRepeat )
|
void ScreenOptions::ChangeValueInRowAbsolute( int iRow, PlayerNumber pn, int iChoiceIndex, bool bRepeat )
|
||||||
{
|
{
|
||||||
if( iRow == -1 ) // no row selected
|
if( iRow == -1 ) // no row selected
|
||||||
@@ -1011,8 +1009,9 @@ void ScreenOptions::ChangeValueInRowRelative( int iRow, PlayerNumber pn, int iDe
|
|||||||
/* There are no other options on the row; move up or down instead of left and right.
|
/* There are no other options on the row; move up or down instead of left and right.
|
||||||
* This allows navigating the options menu with left/right/start.
|
* This allows navigating the options menu with left/right/start.
|
||||||
*
|
*
|
||||||
* XXX: Only allow repeats if the opposite key isn't pressed; otherwise, holding both
|
* XXX: Only allow repeats if the opposite key isn't pressed; otherwise,
|
||||||
* directions will repeat in place continuously, which is weird. */
|
* holding both directions will repeat in place continuously,
|
||||||
|
* which is weird. */
|
||||||
if( MoveRowRelative(pn, iDelta, bRepeat) )
|
if( MoveRowRelative(pn, iDelta, bRepeat) )
|
||||||
{
|
{
|
||||||
if( iDelta < 0 )
|
if( iDelta < 0 )
|
||||||
@@ -1031,7 +1030,6 @@ void ScreenOptions::ChangeValueInRowRelative( int iRow, PlayerNumber pn, int iDe
|
|||||||
|
|
||||||
bool bOneChanged = false;
|
bool bOneChanged = false;
|
||||||
|
|
||||||
|
|
||||||
int iCurrentChoiceWithFocus = row.GetChoiceInRowWithFocus(pn);
|
int iCurrentChoiceWithFocus = row.GetChoiceInRowWithFocus(pn);
|
||||||
int iNewChoiceWithFocus = iCurrentChoiceWithFocus + iDelta;
|
int iNewChoiceWithFocus = iCurrentChoiceWithFocus + iDelta;
|
||||||
if( !bRepeat && WRAP_VALUE_IN_ROW.GetValue() )
|
if( !bRepeat && WRAP_VALUE_IN_ROW.GetValue() )
|
||||||
@@ -1058,7 +1056,7 @@ void ScreenOptions::ChangeValueInRowRelative( int iRow, PlayerNumber pn, int iDe
|
|||||||
bForceFocusedChoiceTogether = true;
|
bForceFocusedChoiceTogether = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Also lock focus if the screen is explicitly set to share cursors. */
|
// Also lock focus if the screen is explicitly set to share cursors.
|
||||||
if( m_InputMode == INPUTMODE_SHARE_CURSOR )
|
if( m_InputMode == INPUTMODE_SHARE_CURSOR )
|
||||||
bForceFocusedChoiceTogether = true;
|
bForceFocusedChoiceTogether = true;
|
||||||
|
|
||||||
@@ -1110,10 +1108,10 @@ void ScreenOptions::AfterChangeValueInRow( int iRow, PlayerNumber pn )
|
|||||||
AfterChangeValueOrRow( pn );
|
AfterChangeValueOrRow( pn );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move up/down. Returns true if we actually moved. */
|
// Move up/down. Returns true if we actually moved.
|
||||||
bool ScreenOptions::MoveRowRelative( PlayerNumber pn, int iDir, bool bRepeat )
|
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 );
|
||||||
|
|
||||||
int iDest = -1;
|
int iDest = -1;
|
||||||
ASSERT( m_pRows.size() );
|
ASSERT( m_pRows.size() );
|
||||||
@@ -1149,9 +1147,7 @@ void ScreenOptions::AfterChangeRow( PlayerNumber pn )
|
|||||||
const int iRow = m_iCurrentRow[pn];
|
const int iRow = m_iCurrentRow[pn];
|
||||||
if( iRow != -1 )
|
if( iRow != -1 )
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// In FIVE_KEY, keep the selection in the row near the focus.
|
// In FIVE_KEY, keep the selection in the row near the focus.
|
||||||
//
|
|
||||||
OptionRow &row = *m_pRows[iRow];
|
OptionRow &row = *m_pRows[iRow];
|
||||||
switch( m_OptionsNavigation )
|
switch( m_OptionsNavigation )
|
||||||
{
|
{
|
||||||
@@ -1211,6 +1207,9 @@ void ScreenOptions::MenuLeft( const InputEventPlus &input )
|
|||||||
MenuUpDown( input, -1 );
|
MenuUpDown( input, -1 );
|
||||||
else
|
else
|
||||||
ChangeValueInRowRelative(m_iCurrentRow[input.pn],input.pn,-1, input.type != IET_FIRST_PRESS);
|
ChangeValueInRowRelative(m_iCurrentRow[input.pn],input.pn,-1, input.type != IET_FIRST_PRESS);
|
||||||
|
|
||||||
|
PlayerNumber pn = input.pn;
|
||||||
|
MESSAGEMAN->Broadcast( (MessageID)(Message_MenuLeftP1+pn) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenOptions::MenuRight( const InputEventPlus &input )
|
void ScreenOptions::MenuRight( const InputEventPlus &input )
|
||||||
@@ -1219,16 +1218,23 @@ void ScreenOptions::MenuRight( const InputEventPlus &input )
|
|||||||
MenuUpDown( input, +1 );
|
MenuUpDown( input, +1 );
|
||||||
else
|
else
|
||||||
ChangeValueInRowRelative(m_iCurrentRow[input.pn], input.pn,+1, input.type != IET_FIRST_PRESS);
|
ChangeValueInRowRelative(m_iCurrentRow[input.pn], input.pn,+1, input.type != IET_FIRST_PRESS);
|
||||||
|
|
||||||
|
PlayerNumber pn = input.pn;
|
||||||
|
MESSAGEMAN->Broadcast( (MessageID)(Message_MenuRightP1+pn) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenOptions::MenuUp( const InputEventPlus &input )
|
void ScreenOptions::MenuUp( const InputEventPlus &input )
|
||||||
{
|
{
|
||||||
MenuUpDown( input, -1 );
|
MenuUpDown( input, -1 );
|
||||||
|
PlayerNumber pn = input.pn;
|
||||||
|
MESSAGEMAN->Broadcast( (MessageID)(Message_MenuUpP1+pn) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenOptions::MenuDown( const InputEventPlus &input )
|
void ScreenOptions::MenuDown( const InputEventPlus &input )
|
||||||
{
|
{
|
||||||
MenuUpDown( input, +1 );
|
MenuUpDown( input, +1 );
|
||||||
|
PlayerNumber pn = input.pn;
|
||||||
|
MESSAGEMAN->Broadcast( (MessageID)(Message_MenuDownP1+pn) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenOptions::MenuSelect( const InputEventPlus &input )
|
void ScreenOptions::MenuSelect( const InputEventPlus &input )
|
||||||
@@ -1243,8 +1249,8 @@ void ScreenOptions::MenuUpDown( const InputEventPlus &input, int iDir )
|
|||||||
|
|
||||||
if( input.type == IET_REPEAT )
|
if( input.type == IET_REPEAT )
|
||||||
{
|
{
|
||||||
/* If down is pressed, don't allow up to repeat, and vice versa. This prevents
|
/* If down is pressed, don't allow up to repeat, and vice versa. This
|
||||||
* holding both up and down from toggling repeatedly in-place. */
|
* prevents holding both up and down from toggling repeatedly in-place. */
|
||||||
if( iDir == +1 )
|
if( iDir == +1 )
|
||||||
{
|
{
|
||||||
if( INPUTMAPPER->IsBeingPressed(GAME_BUTTON_MENUUP, pn) ||
|
if( INPUTMAPPER->IsBeingPressed(GAME_BUTTON_MENUUP, pn) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user