From f5be50464015b30007b40c4e0e4415aa3a748825 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Thu, 1 Sep 2016 18:04:57 +0200 Subject: [PATCH] Add a deadzone for standard scrolling --- OpenRA.Game/Settings.cs | 2 +- OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 4fdd3aee30..2ac48affb0 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -171,7 +171,7 @@ namespace OpenRA public float ViewportEdgeScrollStep = 10f; public float UIScrollSpeed = 50f; public int SelectionDeadzone = 24; - public int JoystickScrollDeadzone = 8; + public int MouseScrollDeadzone = 8; public bool UseClassicMouseStyle = false; public StatusBarsType StatusBars = StatusBarsType.Standard; diff --git a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs index 73e8778a8a..565a56767a 100644 --- a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs @@ -35,6 +35,7 @@ namespace OpenRA.Mods.Common.Widgets public int EdgeCornerScrollThreshold = 35; int2? joystickScrollStart, joystickScrollEnd; + int2? standardScrollStart; bool isStandardScrolling; static readonly Dictionary ScrollCursors = new Dictionary @@ -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;