* Create ItemSlotButton * Refactor inventory buttons Refactor so that KeyBind handling of inventory and hands are the same. * Refactor InventoryInterfaceController to call ItemSlotManager with entities This change allows HandsGUI and InventoryInterfaceController to just call ItemSlotManager.OnButtonPressed with an entity instead of a slot. * Add CooldownCircle to ItemSlotButton This allows Hands and Inventory to have cooldown circles on their ItemSlots. * Refactor HandsGUI to use ItemSlots This allows functionality and GUI to be the same between Inventory and Hands. Added clicking empty hand to switch ActiveHand to clicked hand. * Implement CooldownCircle in ItemSlotManager Reorganize files
80 lines
2.4 KiB
C#
80 lines
2.4 KiB
C#
using System;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.Input;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Content.Client.GameObjects
|
|
{
|
|
public sealed class ItemSlotButton : MarginContainer
|
|
{
|
|
public BaseButton Button { get; }
|
|
public SpriteView SpriteView { get; }
|
|
public BaseButton StorageButton { get; }
|
|
public TextureRect CooldownCircle { get; }
|
|
|
|
public Action<BaseButton.ButtonEventArgs> OnPressed { get; set; }
|
|
public Action<BaseButton.ButtonEventArgs> OnStoragePressed { get; set; }
|
|
|
|
public ItemSlotButton(Texture texture, Texture storageTexture)
|
|
{
|
|
CustomMinimumSize = (64, 64);
|
|
|
|
AddChild(Button = new TextureButton
|
|
{
|
|
TextureNormal = texture,
|
|
Scale = (2, 2),
|
|
EnableAllKeybinds = true
|
|
});
|
|
|
|
Button.OnPressed += OnButtonPressed;
|
|
|
|
AddChild(SpriteView = new SpriteView
|
|
{
|
|
MouseFilter = MouseFilterMode.Ignore,
|
|
Scale = (2, 2),
|
|
OverrideDirection = Direction.South
|
|
});
|
|
|
|
AddChild(StorageButton = new TextureButton
|
|
{
|
|
TextureNormal = storageTexture,
|
|
Scale = (0.75f, 0.75f),
|
|
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
|
|
SizeFlagsVertical = SizeFlags.ShrinkEnd,
|
|
Visible = false,
|
|
EnableAllKeybinds = true
|
|
});
|
|
|
|
StorageButton.OnPressed += OnStorageButtonPressed;
|
|
|
|
AddChild(CooldownCircle = new TextureRect
|
|
{
|
|
SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
|
|
SizeFlagsVertical = SizeFlags.ShrinkCenter,
|
|
MouseFilter = MouseFilterMode.Ignore,
|
|
Stretch = TextureRect.StretchMode.KeepCentered,
|
|
TextureScale = (2, 2),
|
|
Visible = false,
|
|
});
|
|
}
|
|
|
|
private void OnButtonPressed(BaseButton.ButtonEventArgs args)
|
|
{
|
|
OnPressed?.Invoke(args);
|
|
}
|
|
|
|
private void OnStorageButtonPressed(BaseButton.ButtonEventArgs args)
|
|
{
|
|
if (args.Event.Function == EngineKeyFunctions.Use)
|
|
{
|
|
OnStoragePressed?.Invoke(args);
|
|
}
|
|
else
|
|
{
|
|
OnPressed?.Invoke(args);
|
|
}
|
|
}
|
|
}
|
|
}
|