(Feat) add crafting discovery + notification + inventory tool tips

This commit is contained in:
2026-07-09 17:44:52 +02:00
parent c6830fa7a4
commit faa061cced
454 changed files with 2445 additions and 229 deletions
+39 -1
View File
@@ -24,6 +24,10 @@ namespace Ashwild.Inventory
[Header("Context Menu")]
[SerializeField] private SlotContextMenu contextMenu;
[Header("Hover Description")]
[Tooltip("Same panel used by the inventory — assign the shared HoverDescriptionUI here too.")]
[SerializeField] private HoverDescriptionUI hoverDescription;
private PlayerInventory inventory;
private Tweener scaleTween;
private Tweener alphaTween;
@@ -51,7 +55,7 @@ namespace Ashwild.Inventory
{
// Visual setup that does not need the player.
for (int i = 0; i < hotbarSlot.Length; i++)
hotbarSlot[i].Initialize(i, InventoryUI.OnSwapRequested, OnSlotClicked);
hotbarSlot[i].Initialize(i, InventoryUI.OnSwapRequested, OnSlotClicked, OnSlotHoverEnter, OnSlotHoverExit);
transform.localScale = Vector3.one * idleScale;
if (canvasGroup != null)
@@ -167,6 +171,40 @@ namespace Ashwild.Inventory
hotbarSlot[index].UpdateVisual(inventory.GetSlot(index));
}
/// <summary>
/// Shows the shared description panel for a hovered hotbar slot, but only while the inventory
/// is open — during normal play the hotbar must not pop a description. The duration bar
/// reflects the item's remaining uses/durability.
/// </summary>
private void OnSlotHoverEnter(int index)
{
if (hoverDescription == null || inventory == null || !PlayerEvents.IsInventoryOpen) return;
InventorySlot slot = inventory.GetSlot(index);
if (slot == null || slot.IsEmpty)
{
hoverDescription.Hide();
return;
}
ItemData item = slot.ItemData;
bool hasDuration = item.HasUses;
float fill = hasDuration ? (float)slot.CurrentUses / item.MaxUses : 0f;
string durationText = hasDuration ? $"{slot.CurrentUses} / {item.MaxUses}" : string.Empty;
hoverDescription.Show(new ItemDescriptionView(
item.Icon, item.ItemName, item.Description, hasDuration, fill, durationText));
}
/// <summary>
/// Hides the description panel when the pointer leaves a hotbar slot.
/// </summary>
private void OnSlotHoverExit()
{
if (hoverDescription != null)
hoverDescription.Hide();
}
private void UpdateSelection(int selectedIndex)
{
for (int i = 0; i < hotbarSlot.Length; i++)