Files
tbd-station-14/Content.Client/GameObjects/Components/HUD/Inventory/InventoryButton.cs
ShadowCommander d9628d39eb 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.
2019-07-29 13:32:04 -07:00

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);
}
}
}