From 5c76a6e7a74da2ce4088268be93d58eb79c6b49d Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 25 Jan 2020 18:31:09 +0000 Subject: [PATCH] Fix key up events queueing duplicate deploy/scatter/stop orders. --- .../Widgets/Logic/Ingame/CommandBarLogic.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs index 0cf8ffb504..3747ba67f9 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs @@ -207,6 +207,7 @@ namespace OpenRA.Mods.Common.Widgets if (keyOverrides != null) { var noShiftButtons = new[] { guardButton, deployButton, attackMoveButton }; + var keyUpButtons = new[] { guardButton, attackMoveButton }; keyOverrides.AddHandler(e => { // HACK: allow command buttons to be triggered if the shift (queue order modifier) key is held @@ -217,11 +218,20 @@ namespace OpenRA.Mods.Common.Widgets foreach (var b in noShiftButtons) { - if (b != null && !b.IsDisabled() && b.Key.IsActivatedBy(eNoShift)) - { - b.OnKeyPress(e); - return true; - } + // Button is not used by this mod + if (b == null) + continue; + + // Button is not valid for this event + if (b.IsDisabled() || !b.Key.IsActivatedBy(eNoShift)) + continue; + + // Event is not valid for this button + if (e.Event == KeyInputEvent.Up && !keyUpButtons.Contains(b)) + continue; + + b.OnKeyPress(e); + return true; } }