From d0d8062dbfa300c6853245dff0de397627078607 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 9 Aug 2017 22:18:43 +0100 Subject: [PATCH] Extract ViewportEdgeScrollMargin settings entry. --- OpenRA.Game/Settings.cs | 2 ++ .../Widgets/ViewportControllerWidget.cs | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 8cf3ec1ead..2693d0388e 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -157,6 +157,8 @@ namespace OpenRA public string Platform = "Default"; public bool ViewportEdgeScroll = true; + public int ViewportEdgeScrollMargin = 5; + public bool LockMouseWindow = false; public MouseScrollType MiddleMouseScroll = MouseScrollType.Standard; public MouseScrollType RightMouseScroll = MouseScrollType.Disabled; diff --git a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs index 0f86fbc540..9d73a8f06b 100644 --- a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs @@ -35,8 +35,6 @@ namespace OpenRA.Mods.Common.Widgets public FrozenActor FrozenActorTooltip { get; private set; } public ResourceType ResourceTooltip { get; private set; } - public int EdgeScrollThreshold = 5; - int2? joystickScrollStart, joystickScrollEnd; int2? standardScrollStart; bool isStandardScrolling; @@ -474,14 +472,15 @@ namespace OpenRA.Mods.Common.Widgets ScrollDirection CheckForDirections() { + var margin = Game.Settings.Game.ViewportEdgeScrollMargin; var directions = ScrollDirection.None; - if (Viewport.LastMousePos.X < EdgeScrollThreshold) + if (Viewport.LastMousePos.X < margin) directions |= ScrollDirection.Left; - if (Viewport.LastMousePos.Y < EdgeScrollThreshold) + if (Viewport.LastMousePos.Y < margin) directions |= ScrollDirection.Up; - if (Viewport.LastMousePos.X >= Game.Renderer.Resolution.Width - EdgeScrollThreshold) + if (Viewport.LastMousePos.X >= Game.Renderer.Resolution.Width - margin) directions |= ScrollDirection.Right; - if (Viewport.LastMousePos.Y >= Game.Renderer.Resolution.Height - EdgeScrollThreshold) + if (Viewport.LastMousePos.Y >= Game.Renderer.Resolution.Height - margin) directions |= ScrollDirection.Down; return directions;