Add examine, activate, and context menu to storage buttons (#4525)
* Add examine, activate, and context menu to storage buttons * Handle UIClick
This commit is contained in:
@@ -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<IEntity> _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
|
||||
/// </summary>
|
||||
/// <param name="entityUid"></param>
|
||||
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
|
||||
/// <summary>
|
||||
/// Button created for each entity that represents that item in the storage UI, with a texture, and name and size label
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user