Permalink
Browse files

Extract ViewportEdgeScrollMargin settings entry.

  • Loading branch information...
pchote authored and abcdefg30 committed Aug 9, 2017
1 parent fd73556 commit 75130c47ffe9eb93b35249d3954be486c55dd279
Showing with 7 additions and 6 deletions.
  1. +2 −0 OpenRA.Game/Settings.cs
  2. +5 −6 OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs
View
@@ -157,6 +157,8 @@ public class GameSettings
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;
@@ -35,8 +35,6 @@ public class ViewportControllerWidget : Widget
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 @@ public override bool HandleKeyPress(KeyInput e)
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;

0 comments on commit 75130c4

Please sign in to comment.