Show if items can be placed in a slot when hovering (#1480)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
@@ -17,6 +17,10 @@ namespace Content.Client.UserInterface
|
||||
|
||||
public Action<GUIBoundKeyEventArgs> OnPressed { get; set; }
|
||||
public Action<GUIBoundKeyEventArgs> OnStoragePressed { get; set; }
|
||||
public Action<GUIMouseHoverEventArgs> OnHover { get; set; }
|
||||
|
||||
public bool EntityHover { get; set; } = false;
|
||||
public bool MouseIsHovering = false;
|
||||
|
||||
public ItemSlotButton(Texture texture, Texture storageTexture)
|
||||
{
|
||||
@@ -56,6 +60,24 @@ namespace Content.Client.UserInterface
|
||||
|
||||
StorageButton.OnPressed += OnStorageButtonPressed;
|
||||
|
||||
Button.OnMouseEntered += _ =>
|
||||
{
|
||||
MouseIsHovering = true;
|
||||
};
|
||||
Button.OnMouseEntered += OnButtonHover;
|
||||
|
||||
Button.OnMouseExited += _ =>
|
||||
{
|
||||
MouseIsHovering = false;
|
||||
if (EntityHover)
|
||||
{
|
||||
SpriteView.Sprite?.Owner.Delete();
|
||||
EntityHover = false;
|
||||
SpriteView.Sprite = null;
|
||||
StorageButton.Visible = false;
|
||||
}
|
||||
};
|
||||
|
||||
AddChild(CooldownDisplay = new CooldownGraphic
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
@@ -80,5 +102,10 @@ namespace Content.Client.UserInterface
|
||||
OnPressed?.Invoke(args.Event);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnButtonHover(GUIMouseHoverEventArgs args)
|
||||
{
|
||||
OnHover?.Invoke(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user