Add a deadzone for standard scrolling
This commit is contained in:
@@ -35,6 +35,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public int EdgeCornerScrollThreshold = 35;
|
||||
|
||||
int2? joystickScrollStart, joystickScrollEnd;
|
||||
int2? standardScrollStart;
|
||||
bool isStandardScrolling;
|
||||
|
||||
static readonly Dictionary<ScrollDirection, string> ScrollCursors = new Dictionary<ScrollDirection, string>
|
||||
@@ -235,7 +236,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
get
|
||||
{
|
||||
return joystickScrollStart.HasValue && joystickScrollEnd.HasValue &&
|
||||
(joystickScrollStart.Value - joystickScrollEnd.Value).Length > Game.Settings.Game.JoystickScrollDeadzone;
|
||||
(joystickScrollStart.Value - joystickScrollEnd.Value).Length > Game.Settings.Game.MouseScrollDeadzone;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +287,10 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
if (scrollType == MouseScrollType.Standard || scrollType == MouseScrollType.Inverted)
|
||||
{
|
||||
if (mi.Event == MouseInputEvent.Move)
|
||||
if (mi.Event == MouseInputEvent.Down && !isStandardScrolling)
|
||||
standardScrollStart = mi.Location;
|
||||
else if (mi.Event == MouseInputEvent.Move && (isStandardScrolling ||
|
||||
(standardScrollStart.HasValue && ((standardScrollStart.Value - mi.Location).Length > Game.Settings.Game.MouseScrollDeadzone))))
|
||||
{
|
||||
isStandardScrolling = true;
|
||||
var d = scrollType == MouseScrollType.Inverted ? -1 : 1;
|
||||
@@ -297,6 +301,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
var wasStandardScrolling = isStandardScrolling;
|
||||
isStandardScrolling = false;
|
||||
standardScrollStart = null;
|
||||
|
||||
if (wasStandardScrolling)
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user