diff --git a/Content.Client/GameObjects/Components/HUD/Inventory/HumanInventoryInterfaceController.cs b/Content.Client/GameObjects/Components/HUD/Inventory/HumanInventoryInterfaceController.cs index f824ac1f6c..2410ca7c26 100644 --- a/Content.Client/GameObjects/Components/HUD/Inventory/HumanInventoryInterfaceController.cs +++ b/Content.Client/GameObjects/Components/HUD/Inventory/HumanInventoryInterfaceController.cs @@ -114,13 +114,13 @@ namespace Content.Client.GameObjects } } - protected override void HandleInventoryKeybind(BaseButton.ButtonEventArgs args, Slots slot) + protected override void HandleInventoryKeybind(GUIBoundKeyEventArgs args, Slots slot) { if (!_inventoryButtons.TryGetValue(slot, out var buttons)) return; if (!Owner.TryGetSlot(slot, out var item)) return; - if (_itemSlotManager.OnButtonPressed(args.Event, item)) + if (_itemSlotManager.OnButtonPressed(args, item)) return; base.HandleInventoryKeybind(args, slot); diff --git a/Content.Client/GameObjects/Components/HUD/Inventory/InventoryInterfaceController.cs b/Content.Client/GameObjects/Components/HUD/Inventory/InventoryInterfaceController.cs index da6fa94b5c..62237e09cf 100644 --- a/Content.Client/GameObjects/Components/HUD/Inventory/InventoryInterfaceController.cs +++ b/Content.Client/GameObjects/Components/HUD/Inventory/InventoryInterfaceController.cs @@ -2,8 +2,9 @@ using Content.Client.UserInterface; using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.Input; -using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface; using Robust.Client.UserInterface.CustomControls; +using Robust.Shared.Input; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; @@ -62,39 +63,35 @@ namespace Content.Client.GameObjects { } - protected virtual void HandleInventoryKeybind(BaseButton.ButtonEventArgs args, EquipmentSlotDefines.Slots slot) + protected virtual void HandleInventoryKeybind(GUIBoundKeyEventArgs args, EquipmentSlotDefines.Slots slot) { - if (args.Event.CanFocus) + if (args.Function == EngineKeyFunctions.UIClick) { - UseItemOnInventory(args, slot); + UseItemOnInventory(slot); } } - protected void AddToInventory(BaseButton.ButtonEventArgs args, EquipmentSlotDefines.Slots slot) + protected void AddToInventory(GUIBoundKeyEventArgs args, EquipmentSlotDefines.Slots slot) { - if (!args.Event.CanFocus) + if (args.Function != EngineKeyFunctions.UIClick) { return; } - args.Button.Pressed = false; Owner.SendEquipMessage(slot); } - protected void UseItemOnInventory(BaseButton.ButtonEventArgs args, EquipmentSlotDefines.Slots slot) + protected void UseItemOnInventory(EquipmentSlotDefines.Slots slot) { - args.Button.Pressed = false; - Owner.SendUseMessage(slot); } - protected void OpenStorage(BaseButton.ButtonEventArgs args, EquipmentSlotDefines.Slots slot) + protected void OpenStorage(GUIBoundKeyEventArgs args, EquipmentSlotDefines.Slots slot) { - if (!args.Event.CanFocus && args.Event.Function != ContentKeyFunctions.ActivateItemInWorld) + if (args.Function != EngineKeyFunctions.UIClick && args.Function != ContentKeyFunctions.ActivateItemInWorld) { return; } - args.Button.Pressed = false; Owner.SendOpenStorageUIMessage(slot); } diff --git a/Content.Client/UserInterface/HandsGui.cs b/Content.Client/UserInterface/HandsGui.cs index 2356d7e24e..bf20579a28 100644 --- a/Content.Client/UserInterface/HandsGui.cs +++ b/Content.Client/UserInterface/HandsGui.cs @@ -57,10 +57,10 @@ namespace Content.Client.UserInterface AddChild(hBox); - _leftButton.OnPressed += args => HandKeyBindDown(args.Event, HandNameLeft); - _leftButton.OnStoragePressed += args => _OnStoragePressed(args.Event, HandNameLeft); - _rightButton.OnPressed += args => HandKeyBindDown(args.Event, HandNameRight); - _rightButton.OnStoragePressed += args => _OnStoragePressed(args.Event, HandNameRight); + _leftButton.OnPressed += args => HandKeyBindDown(args, HandNameLeft); + _leftButton.OnStoragePressed += args => _OnStoragePressed(args, HandNameLeft); + _rightButton.OnPressed += args => HandKeyBindDown(args, HandNameRight); + _rightButton.OnStoragePressed += args => _OnStoragePressed(args, HandNameRight); // Active hand _leftButton.AddChild(ActiveHandRect = new TextureRect diff --git a/Content.Client/UserInterface/ItemSlotButton.cs b/Content.Client/UserInterface/ItemSlotButton.cs index f27583f737..54bc4c027c 100644 --- a/Content.Client/UserInterface/ItemSlotButton.cs +++ b/Content.Client/UserInterface/ItemSlotButton.cs @@ -1,5 +1,7 @@ using System; +using Content.Shared.Input; using Robust.Client.Graphics; +using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Shared.Input; using Robust.Shared.Maths; @@ -8,26 +10,26 @@ namespace Content.Client.GameObjects { public sealed class ItemSlotButton : MarginContainer { - public BaseButton Button { get; } + public TextureRect Button { get; } public SpriteView SpriteView { get; } public BaseButton StorageButton { get; } public TextureRect CooldownCircle { get; } - public Action OnPressed { get; set; } - public Action OnStoragePressed { get; set; } + public Action OnPressed { get; set; } + public Action OnStoragePressed { get; set; } public ItemSlotButton(Texture texture, Texture storageTexture) { CustomMinimumSize = (64, 64); - AddChild(Button = new TextureButton + AddChild(Button = new TextureRect { - TextureNormal = texture, - Scale = (2, 2), - EnableAllKeybinds = true + Texture = texture, + TextureScale = (2, 2), + MouseFilter = MouseFilterMode.Stop }); - Button.OnPressed += OnButtonPressed; + Button.OnKeyBindDown += OnButtonPressed; AddChild(SpriteView = new SpriteView { @@ -42,9 +44,16 @@ namespace Content.Client.GameObjects SizeFlagsHorizontal = SizeFlags.ShrinkEnd, SizeFlagsVertical = SizeFlags.ShrinkEnd, Visible = false, - EnableAllKeybinds = true }); + StorageButton.OnKeyBindDown += args => + { + if (args.Function != EngineKeyFunctions.UIClick) + { + OnButtonPressed(args); + } + }; + StorageButton.OnPressed += OnStorageButtonPressed; AddChild(CooldownCircle = new TextureRect @@ -57,20 +66,20 @@ namespace Content.Client.GameObjects }); } - private void OnButtonPressed(BaseButton.ButtonEventArgs args) + private void OnButtonPressed(GUIBoundKeyEventArgs args) { OnPressed?.Invoke(args); } private void OnStorageButtonPressed(BaseButton.ButtonEventArgs args) { - if (args.Event.Function == EngineKeyFunctions.Use) + if (args.Event.Function == EngineKeyFunctions.UIClick) { - OnStoragePressed?.Invoke(args); + OnStoragePressed?.Invoke(args.Event); } else { - OnPressed?.Invoke(args); + OnPressed?.Invoke(args.Event); } } } diff --git a/Resources/keybinds.yml b/Resources/keybinds.yml index 05cf30d140..38db90e8b7 100644 --- a/Resources/keybinds.yml +++ b/Resources/keybinds.yml @@ -1,5 +1,9 @@ version: 1 # Not used right now, whatever. binds: +- function: UIClick + type: state + key: MouseLeft + canFocus: true - function: Use type: state key: MouseLeft @@ -84,6 +88,7 @@ binds: - function: ActivateItemInWorld type: state key: E + canFocus: true - function: ThrowItemInHand type: state key: MouseLeft diff --git a/RobustToolbox b/RobustToolbox index 51b87513ed..f54f4ffe52 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 51b87513ed7867b97a0c5d3bb4146a9e40a5da1d +Subproject commit f54f4ffe52b79ed8ade6154f7b42e7375a3a22c9