From a8dc8454cb4a82e6b0e73b104d38ebfbda891a40 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Thu, 1 Sep 2016 18:01:55 +0200 Subject: [PATCH 1/3] Fix ignoring deadzone with joystick scrolling This re-introduces a bug where releasing the RMB button causes an order to be generated for the selected units if the user didn't move their mouse just prior. --- OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs index 7eb3aa5e59..73e8778a8a 100644 --- a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs @@ -315,7 +315,7 @@ namespace OpenRA.Mods.Common.Widgets if (mi.Event == MouseInputEvent.Up) { - var wasJoystickScrolling = joystickScrollStart.HasValue && joystickScrollEnd.HasValue; + var wasJoystickScrolling = IsJoystickScrolling; joystickScrollStart = joystickScrollEnd = null; YieldMouseFocus(mi); From f5be50464015b30007b40c4e0e4415aa3a748825 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Thu, 1 Sep 2016 18:04:57 +0200 Subject: [PATCH 2/3] 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; From f554531bd2824dffed8a3f9aa94be2ced0783e12 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Thu, 1 Sep 2016 21:39:37 +0200 Subject: [PATCH 3/3] Fix not showing scroll cursor during standard-scrolling ... when edge scrolling was also disabled. --- OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs index 565a56767a..e2fa41c31b 100644 --- a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs @@ -210,7 +210,7 @@ namespace OpenRA.Mods.Common.Widgets public override string GetCursor(int2 pos) { - if (!IsJoystickScrolling && + if (!(IsJoystickScrolling || isStandardScrolling) && (!Game.Settings.Game.ViewportEdgeScroll || Ui.MouseOverWidget != this)) return null;