diff --git a/Content.Client/Storage/ClientStorageComponent.cs b/Content.Client/Storage/ClientStorageComponent.cs index b614ccb8c0..ed5d05ace2 100644 --- a/Content.Client/Storage/ClientStorageComponent.cs +++ b/Content.Client/Storage/ClientStorageComponent.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using Content.Client.Animations; using Content.Client.Hands; +using Content.Client.Items.Managers; using Content.Client.Items.Components; using Content.Client.UserInterface.Controls; using Content.Shared.DragDrop; @@ -15,6 +16,7 @@ using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.GameObjects; +using Robust.Shared.Input; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; @@ -31,6 +33,8 @@ namespace Content.Client.Storage [RegisterComponent] public class ClientStorageComponent : SharedStorageComponent, IDraggable { + [Dependency] private readonly IItemSlotManager _itemSlotManager = default!; + private List _storedEntities = new(); private int StorageSizeUsed; private int StorageCapacityMax; @@ -172,9 +176,17 @@ namespace Content.Client.Storage /// Function for clicking one of the stored entity buttons in the UI, tells server to remove that entity /// /// - private void Interact(EntityUid entityUid) + private void Interact(BaseButton.ButtonEventArgs buttonEventArgs, EntityUid entityUid) { - SendNetworkMessage(new RemoveEntityMessage(entityUid)); + if (buttonEventArgs.Event.Function == EngineKeyFunctions.UIClick) + { + SendNetworkMessage(new RemoveEntityMessage(entityUid)); + buttonEventArgs.Event.Handle(); + } + else if (Owner.EntityManager.TryGetEntity(entityUid, out var entity)) + { + _itemSlotManager.OnButtonPressed(buttonEventArgs.Event, entity); + } } public override bool Remove(IEntity entity) @@ -191,7 +203,7 @@ namespace Content.Client.Storage /// /// Button created for each entity that represents that item in the storage UI, with a texture, and name and size label /// - private void GenerateButton(EntityUid entityUid, Control button) + private void GenerateButton(EntityUid entityUid, EntityContainerButton button) { if (!Owner.EntityManager.TryGetEntity(entityUid, out var entity)) return; @@ -226,6 +238,8 @@ namespace Content.Client.Storage } } }); + + button.EnableAllKeybinds = true; } /// diff --git a/Content.Client/UserInterface/Controls/EntityListDisplay.cs b/Content.Client/UserInterface/Controls/EntityListDisplay.cs index d3923470fe..d45946bad4 100644 --- a/Content.Client/UserInterface/Controls/EntityListDisplay.cs +++ b/Content.Client/UserInterface/Controls/EntityListDisplay.cs @@ -15,8 +15,8 @@ namespace Content.Client.UserInterface.Controls public const string StylePropertySeparation = "separation"; public int? SeparationOverride { get; set; } - public Action? GenerateItem; - public Action? ItemPressed; + public Action? GenerateItem; + public Action? ItemPressed; private const int DefaultSeparation = 3; @@ -82,7 +82,7 @@ namespace Content.Client.UserInterface.Controls { if (args.Button is not EntityContainerButton button) return; - ItemPressed?.Invoke(button.EntityUid); + ItemPressed?.Invoke(args, button.EntityUid); } [Pure] @@ -136,7 +136,7 @@ namespace Content.Client.UserInterface.Controls #region Rebuild Children /* * Example: - * + * * var _itemHeight = 32; * var separation = 3; * 32 | 32 | Control.Size.Y 0 @@ -146,13 +146,13 @@ namespace Content.Client.UserInterface.Controls * 102 | 32 | Control.Size.Y 2 * 105 | 3 | Padding * 137 | 32 | Control.Size.Y 3 - * + * * If viewport height is 60 * visible should be 2 items (start = 0, end = 1) - * + * * scroll.Y = 11 * visible should be 3 items (start = 0, end = 2) - * + * * start expected: 11 (item: 0) * var start = (int) (scroll.Y *