diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index b0e86e3d11..7828e1181d 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -27,6 +27,8 @@ namespace OpenRA { public static class Game { + public static MouseButtonPreference mouseButtonPreference = new MouseButtonPreference(); + public const int NetTickScale = 3; // 120 ms net tick for 40 ms local tick public const int Timestep = 40; public const int TimestepJankThreshold = 250; // Don't catch up for delays larger than 250ms diff --git a/OpenRA.Game/Input/InputHandler.cs b/OpenRA.Game/Input/InputHandler.cs index 79fb87f130..68b5e92cd1 100755 --- a/OpenRA.Game/Input/InputHandler.cs +++ b/OpenRA.Game/Input/InputHandler.cs @@ -49,4 +49,25 @@ namespace OpenRA Sync.CheckSyncUnchanged(world, () => Ui.HandleInput(input)); } } + + public class MouseButtonPreference + { + + public MouseButton Action + { + get + { + return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right; + } + } + + + public MouseButton Cancel + { + get + { + return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Right : MouseButton.Left; + } + } + } } diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index fe54431119..2515ebce99 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -96,7 +96,7 @@ namespace OpenRA.Orders if (self.Destroyed || !target.IsValidFor(self)) return null; - if (mi.Button == MouseButton.Right) + if (mi.Button == Game.mouseButtonPreference.Action) { foreach (var o in self.TraitsImplementing() .SelectMany(trait => trait.Orders diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 265166385c..875a64ef5b 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -130,6 +130,7 @@ namespace OpenRA public float ViewportEdgeScrollStep = 10f; public float UIScrollSpeed = 50f; + public bool UseClassicMouseStyle = false; public bool AlwaysShowStatusBars = false; public bool TeamHealthColors = false; diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index cdf82eab71..d9b7c9d002 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -55,6 +55,9 @@ namespace OpenRA.Widgets public override bool HandleMouseInput(MouseInput mi) { var xy = worldRenderer.Viewport.ViewToWorldPx(mi.Location); + + var useClassicMouseStyle = Game.Settings.Game.UseClassicMouseStyle; + var hasBox = SelectionBox != null; var multiClick = mi.MultiTapCount >= 2; @@ -66,7 +69,8 @@ namespace OpenRA.Widgets dragStart = xy; // place buildings - ApplyOrders(World, xy, mi); + if(!useClassicMouseStyle) + ApplyOrders(World, xy, mi); } if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Move && dragStart.HasValue) @@ -74,6 +78,18 @@ namespace OpenRA.Widgets if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up) { + if (useClassicMouseStyle && HasMouseFocus) + { + // order units around + if (!hasBox && World.Selection.Actors.Any() && !multiClick) + { + ApplyOrders(World, xy, mi); + YieldMouseFocus(mi); + return true; + } + } + + if (World.OrderGenerator is UnitOrderGenerator) { if (multiClick) @@ -97,9 +113,14 @@ namespace OpenRA.Widgets YieldMouseFocus(mi); } - // don't issue orders while selecting - if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down && !hasBox) - ApplyOrders(World, xy, mi); + if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down) + { + if (useClassicMouseStyle) + World.Selection.Clear(); + + if (!hasBox) // don't issue orders while selecting + ApplyOrders(World, xy, mi); + } lastMousePosition = xy; @@ -172,7 +193,7 @@ namespace OpenRA.Widgets var mi = new MouseInput { Location = screenPos, - Button = MouseButton.Right, + Button = Game.mouseButtonPreference.Action, Modifiers = Game.GetModifierKeys() }; diff --git a/OpenRA.Mods.Common/Traits/Guard.cs b/OpenRA.Mods.Common/Traits/Guard.cs index 2e0c4a30f3..b17be9ee3e 100644 --- a/OpenRA.Mods.Common/Traits/Guard.cs +++ b/OpenRA.Mods.Common/Traits/Guard.cs @@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits public IEnumerable Order(World world, CPos xy, MouseInput mi) { - if (mi.Button == MouseButton.Left) + if (mi.Button == Game.mouseButtonPreference.Cancel) { world.CancelInputMode(); yield break; diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 30d15c34e7..9934948cb2 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -312,6 +312,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var gs = Game.Settings.Game; var ks = Game.Settings.Keys; + BindCheckboxPref(panel, "CLASSICORDERS_CHECKBOX", gs, "UseClassicMouseStyle"); BindCheckboxPref(panel, "EDGESCROLL_CHECKBOX", gs, "ViewportEdgeScroll"); BindCheckboxPref(panel, "LOCKMOUSE_CHECKBOX", gs, "LockMouseWindow"); BindSliderPref(panel, "SCROLLSPEED_SLIDER", gs, "ViewportEdgeScrollStep"); @@ -472,6 +473,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic return () => { + gs.UseClassicMouseStyle = dgs.UseClassicMouseStyle; gs.MouseScroll = dgs.MouseScroll; gs.LockMouseWindow = dgs.LockMouseWindow; gs.ViewportEdgeScroll = dgs.ViewportEdgeScroll; diff --git a/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs index fd9a392925..c1f7fbb2fb 100644 --- a/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs @@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets if (actors.Any()) world.OrderGenerator = new GenericSelectTarget(actors, - "AttackMove", "attackmove", MouseButton.Right); + "AttackMove", "attackmove", Game.mouseButtonPreference.Action); return true; } diff --git a/OpenRA.Mods.RA/Traits/Minelayer.cs b/OpenRA.Mods.RA/Traits/Minelayer.cs index 721540a673..a1020e2f7f 100644 --- a/OpenRA.Mods.RA/Traits/Minelayer.cs +++ b/OpenRA.Mods.RA/Traits/Minelayer.cs @@ -146,7 +146,7 @@ namespace OpenRA.Mods.RA.Traits public IEnumerable Order(World world, CPos xy, MouseInput mi) { - if (mi.Button == MouseButton.Left) + if (mi.Button == Game.mouseButtonPreference.Cancel) { world.CancelInputMode(); yield break; @@ -157,7 +157,7 @@ namespace OpenRA.Mods.RA.Traits .MaxByOrDefault(a => a.Info.Traits.Contains() ? a.Info.Traits.Get().Priority : int.MinValue); - if (mi.Button == MouseButton.Right && underCursor == null) + if (mi.Button == Game.mouseButtonPreference.Action && underCursor == null) { minelayer.World.CancelInputMode(); yield return new Order("PlaceMinefield", minelayer, false) { TargetLocation = xy }; diff --git a/OpenRA.Mods.RA/Traits/PortableChrono.cs b/OpenRA.Mods.RA/Traits/PortableChrono.cs index 9d72c6e854..ee845a03d7 100644 --- a/OpenRA.Mods.RA/Traits/PortableChrono.cs +++ b/OpenRA.Mods.RA/Traits/PortableChrono.cs @@ -153,7 +153,7 @@ namespace OpenRA.Mods.RA.Traits public IEnumerable Order(World world, CPos xy, MouseInput mi) { - if (mi.Button == MouseButton.Left) + if (mi.Button == Game.mouseButtonPreference.Cancel) { world.CancelInputMode(); yield break; diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 7760764ece..e20b0219f5 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -320,53 +320,16 @@ Container@SETTINGS_PANEL: Font: Bold Text: Input Align: Center - Checkbox@EDGESCROLL_CHECKBOX: + Checkbox@CLASSICORDERS_CHECKBOX: X: 15 Y: 40 - Width: 130 - Height: 20 - Font: Regular - Text: Edge Scrolling - Checkbox@LOCKMOUSE_CHECKBOX: - X: 15 - Y: 70 - Width: 130 - Height: 20 - Font: Regular - Text: Lock mouse to window - Label@SCROLL_SPEED_LABEL: - X: PARENT_RIGHT - WIDTH - 270 - Y: 37 - Width: 95 - Height: 25 - Text: Scroll Speed: - Align: Right - Slider@SCROLLSPEED_SLIDER: - X: PARENT_RIGHT - WIDTH - 15 - Y: 43 Width: 250 Height: 20 - Ticks: 5 - MinimumValue: 10 - MaximumValue: 50 - Label@UI_SCROLL_SPEED_LABEL: - X: PARENT_RIGHT - WIDTH - 270 - Y: 67 - Width: 95 - Height: 25 - Text: UI Scroll Speed: - Align: Right - Slider@UI_SCROLLSPEED_SLIDER: - X: PARENT_RIGHT - WIDTH - 15 - Y: 73 - Width: 250 - Height: 20 - Ticks: 5 - MinimumValue: 1 - MaximumValue: 100 + Font: Regular + Text: Left-Click Orders Label@MOUSE_SCROLL_LABEL: X: PARENT_RIGHT - WIDTH - 120 - Y: 99 + Y: 39 Width: 160 Height: 20 Font: Regular @@ -374,11 +337,55 @@ Container@SETTINGS_PANEL: Align: Right DropDownButton@MOUSE_SCROLL: X: PARENT_RIGHT - WIDTH - 15 - Y: 98 + Y: 38 Width: 100 Height: 25 Font: Regular Text: Enabled + Checkbox@EDGESCROLL_CHECKBOX: + X: 15 + Y: 70 + Width: 130 + Height: 20 + Font: Regular + Text: Edge Scrolling + Checkbox@LOCKMOUSE_CHECKBOX: + X: 15 + Y: 100 + Width: 130 + Height: 20 + Font: Regular + Text: Lock mouse to window + Label@SCROLL_SPEED_LABEL: + X: PARENT_RIGHT - WIDTH - 270 + Y: 67 + Width: 95 + Height: 25 + Text: Scroll Speed: + Align: Right + Slider@SCROLLSPEED_SLIDER: + X: PARENT_RIGHT - WIDTH - 15 + Y: 73 + Width: 250 + Height: 20 + Ticks: 5 + MinimumValue: 10 + MaximumValue: 50 + Label@UI_SCROLL_SPEED_LABEL: + X: PARENT_RIGHT - WIDTH - 270 + Y: 97 + Width: 95 + Height: 25 + Text: UI Scroll Speed: + Align: Right + Slider@UI_SCROLLSPEED_SLIDER: + X: PARENT_RIGHT - WIDTH - 15 + Y: 103 + Width: 250 + Height: 20 + Ticks: 5 + MinimumValue: 1 + MaximumValue: 100 Label@HOTKEYS_TITLE: Y: 135 Width: PARENT_RIGHT diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index bc60296a97..846da5cf86 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -324,53 +324,16 @@ Background@SETTINGS_PANEL: Width: PARENT_RIGHT - 10 Height: PARENT_BOTTOM Children: - Checkbox@EDGESCROLL_CHECKBOX: + Checkbox@CLASSICORDERS_CHECKBOX: X: 15 Y: 40 - Width: 130 - Height: 20 - Font: Regular - Text: Edge Scrolling - Checkbox@LOCKMOUSE_CHECKBOX: - X: 15 - Y: 70 - Width: 130 - Height: 20 - Font: Regular - Text: Lock mouse to window - Label@SCROLL_SPEED_LABEL: - X: PARENT_RIGHT - WIDTH - 270 - Y: 37 - Width: 95 - Height: 25 - Text: Scroll Speed: - Align: Right - Slider@SCROLLSPEED_SLIDER: - X: PARENT_RIGHT - WIDTH - 15 - Y: 43 Width: 250 Height: 20 - Ticks: 5 - MinimumValue: 10 - MaximumValue: 50 - Label@UI_SCROLL_SPEED_LABEL: - X: PARENT_RIGHT - WIDTH - 270 - Y: 67 - Width: 95 - Height: 25 - Text: UI Scroll Speed: - Align: Right - Slider@UI_SCROLLSPEED_SLIDER: - X: PARENT_RIGHT - WIDTH - 15 - Y: 73 - Width: 250 - Height: 20 - Ticks: 5 - MinimumValue: 1 - MaximumValue: 100 + Font: Regular + Text: Left-Click Orders Label@MOUSE_SCROLL_LABEL: X: PARENT_RIGHT - WIDTH - 120 - Y: 99 + Y: 39 Width: 160 Height: 20 Font: Regular @@ -378,11 +341,55 @@ Background@SETTINGS_PANEL: Align: Right DropDownButton@MOUSE_SCROLL: X: PARENT_RIGHT - WIDTH - 15 - Y: 98 + Y: 38 Width: 100 Height: 25 Font: Regular Text: Enabled + Checkbox@EDGESCROLL_CHECKBOX: + X: 15 + Y: 70 + Width: 130 + Height: 20 + Font: Regular + Text: Edge Scrolling + Checkbox@LOCKMOUSE_CHECKBOX: + X: 15 + Y: 100 + Width: 130 + Height: 20 + Font: Regular + Text: Lock mouse to window + Label@SCROLL_SPEED_LABEL: + X: PARENT_RIGHT - WIDTH - 270 + Y: 67 + Width: 95 + Height: 25 + Text: Scroll Speed: + Align: Right + Slider@SCROLLSPEED_SLIDER: + X: PARENT_RIGHT - WIDTH - 15 + Y: 73 + Width: 250 + Height: 20 + Ticks: 5 + MinimumValue: 10 + MaximumValue: 50 + Label@UI_SCROLL_SPEED_LABEL: + X: PARENT_RIGHT - WIDTH - 270 + Y: 97 + Width: 95 + Height: 25 + Text: UI Scroll Speed: + Align: Right + Slider@UI_SCROLLSPEED_SLIDER: + X: PARENT_RIGHT - WIDTH - 15 + Y: 103 + Width: 250 + Height: 20 + Ticks: 5 + MinimumValue: 1 + MaximumValue: 100 Label@HOTKEYS_TITLE: Y: 135 Width: PARENT_RIGHT