Add a deadzone for standard scrolling

This commit is contained in:
Oliver Brakmann
2016-09-01 18:04:57 +02:00
parent a8dc8454cb
commit f5be504640
2 changed files with 8 additions and 3 deletions

View File

@@ -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;