From eb21c4bddd0c5ffea49c95cd8fb4d1388f762529 Mon Sep 17 00:00:00 2001 From: rob-v Date: Wed, 9 Aug 2017 09:54:05 +0200 Subject: [PATCH] Keep Attack M./Guard action while holding hotkey (revert Playtest change) --- .../Widgets/Logic/Ingame/CommandBarLogic.cs | 23 +++++++++++++------ mods/cnc/chrome/ingame.yaml | 2 -- mods/d2k/chrome/ingame-player.yaml | 2 -- mods/ra/chrome/ingame-player.yaml | 2 -- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs index 5df118e579..ef54eea9b8 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs @@ -10,13 +10,10 @@ #endregion using System; -using System.Drawing; using System.Linq; -using OpenRA.Graphics; using OpenRA.Mods.Common.Orders; using OpenRA.Mods.Common.Traits; using OpenRA.Orders; -using OpenRA.Primitives; using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets @@ -58,14 +55,20 @@ namespace OpenRA.Mods.Common.Widgets attackMoveButton.IsHighlighted = () => world.OrderGenerator is GenericSelectTarget && ((GenericSelectTarget)world.OrderGenerator).OrderName == "AttackMove"; - attackMoveButton.OnClick = () => + Action toggle = allowCancel => { if (attackMoveButton.IsHighlighted()) - world.CancelInputMode(); + { + if (allowCancel) + world.CancelInputMode(); + } else world.OrderGenerator = new GenericSelectTarget(selectedActors, "AttackMove", "attackmove", Game.Settings.Game.MouseButtonPreference.Action); }; + + attackMoveButton.OnClick = () => toggle(true); + attackMoveButton.OnKeyPress = _ => toggle(false); } var forceMoveButton = widget.GetOrNull("FORCE_MOVE"); @@ -110,14 +113,20 @@ namespace OpenRA.Mods.Common.Widgets guardButton.IsHighlighted = () => world.OrderGenerator is GenericSelectTarget && ((GenericSelectTarget)world.OrderGenerator).OrderName == "Guard"; - guardButton.OnClick = () => + Action toggle = allowCancel => { if (guardButton.IsHighlighted()) - world.CancelInputMode(); + { + if (allowCancel) + world.CancelInputMode(); + } else world.OrderGenerator = new GuardOrderGenerator(selectedActors, "Guard", "guard", Game.Settings.Game.MouseButtonPreference.Action); }; + + guardButton.OnClick = () => toggle(true); + guardButton.OnKeyPress = _ => toggle(false); } var scatterButton = widget.GetOrNull("SCATTER"); diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 8ad77bf961..f44eeb9acb 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -270,7 +270,6 @@ Container@PLAYER_WIDGETS: Width: 34 Height: 34 Background: command-button - DisableKeyRepeat: true DisableKeySound: true TooltipText: Attack Move TooltipDesc: Selected units will move to the desired location\nand attack any enemies they encounter en route.\n\nLeft-click icon then right-click on target location. @@ -321,7 +320,6 @@ Container@PLAYER_WIDGETS: Width: 34 Height: 34 Background: command-button - DisableKeyRepeat: true DisableKeySound: true TooltipText: Guard TooltipDesc: Selected units will follow the targeted unit.\n\nLeft-click icon then right-click on target unit. diff --git a/mods/d2k/chrome/ingame-player.yaml b/mods/d2k/chrome/ingame-player.yaml index bba8912d0f..1651d06b4c 100644 --- a/mods/d2k/chrome/ingame-player.yaml +++ b/mods/d2k/chrome/ingame-player.yaml @@ -43,7 +43,6 @@ Container@PLAYER_WIDGETS: Height: 41 VisualHeight: 0 Background: command-button - DisableKeyRepeat: true DisableKeySound: true TooltipText: Attack Move TooltipDesc: Selected units will move to the desired location\nand attack any enemies they encounter en route.\n\nLeft-click icon then right-click on target location. @@ -94,7 +93,6 @@ Container@PLAYER_WIDGETS: Height: 41 VisualHeight: 0 Background: command-button - DisableKeyRepeat: true DisableKeySound: true TooltipText: Guard TooltipDesc: Selected units will follow the targeted unit.\n\nLeft-click icon then right-click on target unit. diff --git a/mods/ra/chrome/ingame-player.yaml b/mods/ra/chrome/ingame-player.yaml index a07fa234a2..1f394b390c 100644 --- a/mods/ra/chrome/ingame-player.yaml +++ b/mods/ra/chrome/ingame-player.yaml @@ -49,7 +49,6 @@ Container@PLAYER_WIDGETS: Height: 26 VisualHeight: 0 Background: command-button - DisableKeyRepeat: true DisableKeySound: true TooltipText: Attack Move TooltipDesc: Selected units will move to the desired location\nand attack any enemies they encounter en route.\n\nLeft-click icon then right-click on target location. @@ -103,7 +102,6 @@ Container@PLAYER_WIDGETS: Height: 26 VisualHeight: 0 Background: command-button - DisableKeyRepeat: true DisableKeySound: true TooltipText: Guard TooltipDesc: Selected units will follow the targeted unit.\n\nLeft-click icon then right-click on target unit.