diff --git a/OpenRA.Game/GameRules/UserSettings.cs b/OpenRA.Game/GameRules/UserSettings.cs index 0701d7855c..d9fad57127 100644 --- a/OpenRA.Game/GameRules/UserSettings.cs +++ b/OpenRA.Game/GameRules/UserSettings.cs @@ -19,6 +19,9 @@ namespace OpenRA.GameRules { public class UserSettings { + // Behaviour settings + public bool ViewportEdgeScroll = true; + // Debug settings public bool PerfDebug = false; public bool RecordSyncReports = true; diff --git a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs index de1fbba052..c42d9ce7a9 100644 --- a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs @@ -46,6 +46,14 @@ namespace OpenRA.Widgets.Delegates }; name.OnEnterKey = () => { name.LoseFocus(); return true; }; + var edgeScroll = general.GetWidget("EDGE_SCROLL"); + edgeScroll.Checked = () => Game.Settings.ViewportEdgeScroll; + edgeScroll.OnMouseDown = mi => + { + Game.Settings.ViewportEdgeScroll ^= true; + return true; + }; + // Audio var audio = bg.GetWidget("AUDIO_PANE"); diff --git a/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs b/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs index bb7dea3bed..62bf79ea5e 100644 --- a/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs +++ b/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs @@ -27,14 +27,11 @@ namespace OpenRA.Widgets Down = 4, Right = 8 } - + class ViewportScrollControllerWidget : Widget { public int EdgeScrollThreshold = 15; - public bool EdgeScroll = true; - public bool KeyboardScroll = true; - public bool MouseScroll = true; - + ScrollDirection Keyboard; ScrollDirection Edge; @@ -43,10 +40,7 @@ namespace OpenRA.Widgets public override void DrawInner( World world ) {} public override bool HandleInputInner(MouseInput mi) - { - if (!MouseScroll) - return false; - + { if (mi.Event == MouseInputEvent.Move && (mi.Button == MouseButton.Middle || mi.Button == (MouseButton.Left | MouseButton.Right))) { @@ -58,7 +52,7 @@ namespace OpenRA.Widgets public override string GetCursor(int2 pos) { - if (!EdgeScroll) + if (!Game.Settings.ViewportEdgeScroll) return null; if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Left)) @@ -89,10 +83,7 @@ namespace OpenRA.Widgets } public override bool HandleKeyPressInner(KeyInput e) - { - if (!KeyboardScroll) - return false; - + { switch (e.KeyName) { case "up": Keyboard = Keyboard.Set(ScrollDirection.Up, (e.Event == KeyInputEvent.Down)); return true; @@ -106,7 +97,7 @@ namespace OpenRA.Widgets public override void Tick(World world) { Edge = ScrollDirection.None; - if (EdgeScroll) + if (Game.Settings.ViewportEdgeScroll) { // Check for edge-scroll if (Widget.LastMousePos.X < EdgeScrollThreshold) diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 98fd77401b..5912e8ed7b 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -86,6 +86,13 @@ Container@ROOT: X:90 Y:0 MaxLength:16 + Checkbox@EDGE_SCROLL: + Id:EDGE_SCROLL + X:0 + Y:30 + Width:200 + Height:20 + Text: Enable Edge Scrolling Container@AUDIO_PANE: Id:AUDIO_PANE X:37 diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index 98fd77401b..5912e8ed7b 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -86,6 +86,13 @@ Container@ROOT: X:90 Y:0 MaxLength:16 + Checkbox@EDGE_SCROLL: + Id:EDGE_SCROLL + X:0 + Y:30 + Width:200 + Height:20 + Text: Enable Edge Scrolling Container@AUDIO_PANE: Id:AUDIO_PANE X:37