From 6471f55a49c2548e437a1a101f92c3416c676893 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:36:18 +1200 Subject: [PATCH] Action UI fixes (#27468) --- .../Systems/Actions/ActionUIController.cs | 108 +++++++++--------- .../Systems/Actions/Controls/ActionButton.cs | 30 +++-- 2 files changed, 70 insertions(+), 68 deletions(-) diff --git a/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs b/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs index c79f0f80f9..5d9706452c 100644 --- a/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs +++ b/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs @@ -15,6 +15,7 @@ using Content.Shared.Actions; using Content.Shared.Input; using Robust.Client.GameObjects; using Robust.Client.Graphics; +using Robust.Client.Input; using Robust.Client.Player; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controllers; @@ -42,6 +43,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged position && position >= 0) + _actions.RemoveAt(position); } } else if (button.TryReplaceWith(actionId.Value, _actionsSystem) && @@ -539,23 +546,22 @@ public sealed class ActionUIController : UIController, IOnStateChanged - { - Depress(args, true); - OnPressed(args); - }; - OnKeyBindUp += args => - { - Depress(args, false); - OnUnpressed(args); - }; + OnKeyBindDown += OnPressed; + OnKeyBindUp += OnUnpressed; TooltipSupplier = SupplyTooltip; } @@ -175,11 +167,23 @@ public sealed class ActionButton : Control, IEntityControl private void OnPressed(GUIBoundKeyEventArgs args) { + if (args.Function != EngineKeyFunctions.UIClick && args.Function != EngineKeyFunctions.UIRightClick) + return; + + if (args.Function == EngineKeyFunctions.UIRightClick) + Depress(args, true); + ActionPressed?.Invoke(args, this); } private void OnUnpressed(GUIBoundKeyEventArgs args) { + if (args.Function != EngineKeyFunctions.UIClick && args.Function != EngineKeyFunctions.UIRightClick) + return; + + if (args.Function == EngineKeyFunctions.UIRightClick) + Depress(args, false); + ActionUnpressed?.Invoke(args, this); } @@ -378,12 +382,6 @@ public sealed class ActionButton : Control, IEntityControl if (_action is not {Enabled: true}) return; - if (_depressed && !depress) - { - // fire the action - OnUnpressed(args); - } - _depressed = depress; DrawModeChanged(); }