fix jumpy scrolling if one player holds 2 directions
This commit is contained in:
@@ -29,7 +29,8 @@ struct MenuInput
|
||||
PlayerNumber player;
|
||||
MenuButton button;
|
||||
|
||||
// bool operator==( const MenuInput &other ) { return player == other.player && button == other.button; };
|
||||
bool operator==( const MenuInput &other ) { return player == other.player && button == other.button; };
|
||||
bool operator!=( const MenuInput &other ) { return !operator==(other); };
|
||||
|
||||
inline bool IsValid() const { return player != PLAYER_INVALID; };
|
||||
inline void MakeInvalid() { player = PLAYER_INVALID; button = MENU_BUTTON_INVALID; };
|
||||
|
||||
@@ -55,7 +55,7 @@ void ScreenSelectMaster::Init()
|
||||
{
|
||||
ScreenSelect::Init();
|
||||
|
||||
m_TrackingRepeatingInputFromPlayer = PLAYER_INVALID;
|
||||
m_TrackingRepeatingInput.MakeInvalid();
|
||||
|
||||
vector<PlayerNumber> vpns;
|
||||
if( SHARED_SELECTION )
|
||||
@@ -416,13 +416,16 @@ void ScreenSelectMaster::MenuLeft( const InputEventPlus &input )
|
||||
return;
|
||||
if( input.type == IET_RELEASE )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS && !ALLOW_REPEATING_INPUT )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS && m_TrackingRepeatingInputFromPlayer != pn )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS )
|
||||
{
|
||||
if( !ALLOW_REPEATING_INPUT )
|
||||
return;
|
||||
if( m_TrackingRepeatingInput != input.MenuI )
|
||||
return;
|
||||
}
|
||||
if( Move(pn, MENU_DIR_LEFT) )
|
||||
{
|
||||
m_TrackingRepeatingInputFromPlayer = pn;
|
||||
m_TrackingRepeatingInput = input.MenuI;
|
||||
m_soundChange.Play();
|
||||
MESSAGEMAN->Broadcast( (Message)(Message_MenuLeftP1+pn) );
|
||||
}
|
||||
@@ -435,13 +438,16 @@ void ScreenSelectMaster::MenuRight( const InputEventPlus &input )
|
||||
return;
|
||||
if( input.type == IET_RELEASE )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS && !ALLOW_REPEATING_INPUT )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS && m_TrackingRepeatingInputFromPlayer != pn )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS )
|
||||
{
|
||||
if( !ALLOW_REPEATING_INPUT )
|
||||
return;
|
||||
if( m_TrackingRepeatingInput != input.MenuI )
|
||||
return;
|
||||
}
|
||||
if( Move(pn, MENU_DIR_RIGHT) )
|
||||
{
|
||||
m_TrackingRepeatingInputFromPlayer = pn;
|
||||
m_TrackingRepeatingInput = input.MenuI;
|
||||
m_soundChange.Play();
|
||||
MESSAGEMAN->Broadcast( (Message)(Message_MenuRightP1+pn) );
|
||||
}
|
||||
@@ -454,13 +460,16 @@ void ScreenSelectMaster::MenuUp( const InputEventPlus &input )
|
||||
return;
|
||||
if( input.type == IET_RELEASE )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS && !ALLOW_REPEATING_INPUT )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS && m_TrackingRepeatingInputFromPlayer != pn )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS )
|
||||
{
|
||||
if( !ALLOW_REPEATING_INPUT )
|
||||
return;
|
||||
if( m_TrackingRepeatingInput != input.MenuI )
|
||||
return;
|
||||
}
|
||||
if( Move(pn, MENU_DIR_UP) )
|
||||
{
|
||||
m_TrackingRepeatingInputFromPlayer = pn;
|
||||
m_TrackingRepeatingInput = input.MenuI;
|
||||
m_soundChange.Play();
|
||||
MESSAGEMAN->Broadcast( (Message)(Message_MenuUpP1+pn) );
|
||||
}
|
||||
@@ -473,13 +482,16 @@ void ScreenSelectMaster::MenuDown( const InputEventPlus &input )
|
||||
return;
|
||||
if( input.type == IET_RELEASE )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS && !ALLOW_REPEATING_INPUT )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS && m_TrackingRepeatingInputFromPlayer != pn )
|
||||
return;
|
||||
if( input.type != IET_FIRST_PRESS )
|
||||
{
|
||||
if( !ALLOW_REPEATING_INPUT )
|
||||
return;
|
||||
if( m_TrackingRepeatingInput != input.MenuI )
|
||||
return;
|
||||
}
|
||||
if( Move(pn, MENU_DIR_DOWN) )
|
||||
{
|
||||
m_TrackingRepeatingInputFromPlayer = pn;
|
||||
m_TrackingRepeatingInput = input.MenuI;
|
||||
m_soundChange.Play();
|
||||
MESSAGEMAN->Broadcast( (Message)(Message_MenuDownP1+pn) );
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "RandomSample.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "ActorScroller.h"
|
||||
#include "MenuInput.h"
|
||||
|
||||
#define MAX_CHOICES 30
|
||||
|
||||
@@ -92,7 +93,7 @@ protected:
|
||||
bool m_bChosen[NUM_PLAYERS];
|
||||
|
||||
float m_fLockInputSecs;
|
||||
PlayerNumber m_TrackingRepeatingInputFromPlayer;
|
||||
MenuInput m_TrackingRepeatingInput;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user