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:
Moses
2020-07-26 07:25:38 -05:00
committed by GitHub
parent bab1345b87
commit 8e08c64fcf
9 changed files with 135 additions and 4 deletions

View File

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