* Multiple hands in gui first pass * Remove IHandsComponent interface * Create hand class and more hand textures * Refactor ServerHandsComponent to use a single list of hands * Seal SharedHand * Fix picked up items not showing on top of the hand buttons * Remove HandsGui buttons and panels dictionaries * Fix items in hands rendering * Fix wrong hand container comparison * Fix not updating the location of duplicate hands * Change ClientHandsComponent to use a SortedList instead of a dictionary * More merge conflict fixes * Change SortedList to List * Fix hand button order * Add item tooltip for more than 2 hands and updating when removing hands * Add add hand and remove hand command * Merge conflict fixes * Remove nullable reference type from ContainerSlot * Fix texture errors * Fix error when reaching 0 hands * Fix error when swapping hands with no hands * Merged remove hand methods * Fix item panel texture errors * Merge conflict fixes * Fix addhand and removehand command descriptions * Add properly displaying tooltips for 2 hands * Make hand indexes and locations consistent across the client and server * Add dropping held entity if a hand is removed * Change hand location to be calculated by index * Made different hand gui updates more consistent * Remove human body yml testing changes * Sanitize addhand and removehand commands * Merge conflict fixes * Remove testing changes * Revert body system changes * Add missing imports * Remove obsolete hands parameter in yml files * Fix broken import * Fix startup error and adding and removing hands on the same tick * Make hand container id use an uint In case someone gets more than 2 billion hands * Rename hand component files * Make hands state use an array
85 lines
2.5 KiB
C#
85 lines
2.5 KiB
C#
using System;
|
|
using Content.Shared.GameObjects.Components.Items;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.Input;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Content.Client.UserInterface
|
|
{
|
|
public class ItemSlotButton : MarginContainer
|
|
{
|
|
public TextureRect Button { get; }
|
|
public SpriteView SpriteView { get; }
|
|
public BaseButton StorageButton { get; }
|
|
public CooldownGraphic CooldownDisplay { get; }
|
|
|
|
public Action<GUIBoundKeyEventArgs> OnPressed { get; set; }
|
|
public Action<GUIBoundKeyEventArgs> OnStoragePressed { get; set; }
|
|
|
|
public ItemSlotButton(Texture texture, Texture storageTexture)
|
|
{
|
|
CustomMinimumSize = (64, 64);
|
|
|
|
AddChild(Button = new TextureRect
|
|
{
|
|
Texture = texture,
|
|
TextureScale = (2, 2),
|
|
MouseFilter = MouseFilterMode.Stop
|
|
});
|
|
|
|
Button.OnKeyBindDown += OnButtonPressed;
|
|
|
|
AddChild(SpriteView = new SpriteView
|
|
{
|
|
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,
|
|
});
|
|
|
|
StorageButton.OnKeyBindDown += args =>
|
|
{
|
|
if (args.Function != EngineKeyFunctions.UIClick)
|
|
{
|
|
OnButtonPressed(args);
|
|
}
|
|
};
|
|
|
|
StorageButton.OnPressed += OnStorageButtonPressed;
|
|
|
|
AddChild(CooldownDisplay = new CooldownGraphic
|
|
{
|
|
SizeFlagsHorizontal = SizeFlags.Fill,
|
|
SizeFlagsVertical = SizeFlags.Fill,
|
|
Visible = false,
|
|
});
|
|
}
|
|
|
|
private void OnButtonPressed(GUIBoundKeyEventArgs args)
|
|
{
|
|
OnPressed?.Invoke(args);
|
|
}
|
|
|
|
private void OnStorageButtonPressed(BaseButton.ButtonEventArgs args)
|
|
{
|
|
if (args.Event.Function == EngineKeyFunctions.UIClick)
|
|
{
|
|
OnStoragePressed?.Invoke(args.Event);
|
|
}
|
|
else
|
|
{
|
|
OnPressed?.Invoke(args.Event);
|
|
}
|
|
}
|
|
}
|
|
}
|