* Fixed HandsGui children so that HandsGui is clickable * Added TextureButton for opening Storage items * Update ClientInventoryComponent.cs Fixed HandleComponentState so that it only updates the inventory when there are changes. * Implemented storage button on Inventory Adds a small button on the bottom right of Storage items when inside the inventory. When the button is pressed it opens the Storage UI.
54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using System;
|
|
using Content.Shared.GameObjects.Components.Inventory;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.Client.GameObjects
|
|
{
|
|
public sealed class InventoryButton : MarginContainer
|
|
{
|
|
public EquipmentSlotDefines.Slots Slot { get; }
|
|
public EntityUid EntityUid { get; set; }
|
|
|
|
public BaseButton Button { get; }
|
|
public SpriteView SpriteView { get; }
|
|
public BaseButton StorageButton { get; }
|
|
|
|
public Action<BaseButton.ButtonEventArgs> OnPressed { get; set; }
|
|
public Action<BaseButton.ButtonEventArgs> OnStoragePressed { get; set; }
|
|
|
|
public InventoryButton(EquipmentSlotDefines.Slots slot, Texture texture, Texture storageTexture)
|
|
{
|
|
Slot = slot;
|
|
|
|
CustomMinimumSize = (64, 64);
|
|
|
|
AddChild(Button = new TextureButton
|
|
{
|
|
TextureNormal = texture,
|
|
Scale = (2, 2)
|
|
});
|
|
|
|
Button.OnPressed += e => OnPressed?.Invoke(e);
|
|
|
|
AddChild(SpriteView = new SpriteView
|
|
{
|
|
MouseFilter = MouseFilterMode.Ignore,
|
|
Scale = (2, 2)
|
|
});
|
|
|
|
AddChild(StorageButton = new TextureButton
|
|
{
|
|
TextureNormal = storageTexture,
|
|
Scale = (0.75f, 0.75f),
|
|
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
|
|
SizeFlagsVertical = SizeFlags.ShrinkEnd,
|
|
Visible = false
|
|
});
|
|
|
|
StorageButton.OnPressed += e => OnStoragePressed?.Invoke(e);
|
|
}
|
|
}
|
|
}
|