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

@@ -48,6 +48,7 @@ namespace Content.Client.GameObjects
{
button.OnPressed = (e) => AddToInventory(e, slot);
button.OnStoragePressed = (e) => OpenStorage(e, slot);
button.OnHover = (e) => RequestItemHover(slot);
_inventoryButtons.Add(slot, new List<ItemSlotButton> {button});
}
@@ -58,7 +59,8 @@ namespace Content.Client.GameObjects
variable = new ItemSlotButton(texture, storageTexture)
{
OnPressed = (e) => AddToInventory(e, slot),
OnStoragePressed = (e) => OpenStorage(e, slot)
OnStoragePressed = (e) => OpenStorage(e, slot),
OnHover = (e) => RequestItemHover(slot)
};
_inventoryButtons[slot].Add(variable);
}
@@ -114,6 +116,21 @@ namespace Content.Client.GameObjects
}
}
public override void HoverInSlot(Slots slot, IEntity entity, bool fits)
{
base.HoverInSlot(slot, entity, fits);
if (!_inventoryButtons.TryGetValue(slot, out var buttons))
{
return;
}
foreach (var button in buttons)
{
_itemSlotManager.HoverInSlot(button, entity, fits);
}
}
protected override void HandleInventoryKeybind(GUIBoundKeyEventArgs args, Slots slot)
{
if (!_inventoryButtons.TryGetValue(slot, out var buttons))