(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
+40 -1
View File
@@ -33,6 +33,9 @@ namespace Ashwild.Inventory
[Header("Context Menu")]
[SerializeField] private SlotContextMenu contextMenu;
[Header("Hover Description")]
[SerializeField] private HoverDescriptionUI hoverDescription;
[Header("Categories")]
[SerializeField] private InventoryCategoryManager categoryManager;
@@ -93,7 +96,7 @@ namespace Ashwild.Inventory
int slotIndex = inventory.HotbarSize + i;
GameObject slotGO = Instantiate(slotPrefab, slotContainer);
SlotUI slotUI = slotGO.GetComponent<SlotUI>();
slotUI.Initialize(slotIndex, OnSwapRequested, OnSlotClicked);
slotUI.Initialize(slotIndex, OnSwapRequested, OnSlotClicked, OnSlotHoverEnter, OnSlotHoverExit);
slotUIs[i] = slotUI;
}
@@ -133,6 +136,9 @@ namespace Ashwild.Inventory
if (contextMenu != null)
contextMenu.Hide();
if (hoverDescription != null)
hoverDescription.Hide();
if (categoryManager != null)
categoryManager.Close();
@@ -192,6 +198,39 @@ namespace Ashwild.Inventory
}
}
/// <summary>
/// Builds the description payload for the hovered slot and shows the side panel. Empty slots
/// keep the panel hidden. The duration bar reflects the item's remaining uses/durability.
/// </summary>
private void OnSlotHoverEnter(int index)
{
if (hoverDescription == null || inventory == null) 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 slot.
/// </summary>
private void OnSlotHoverExit()
{
if (hoverDescription != null)
hoverDescription.Hide();
}
private void RefreshSlot(int index)
{
if (slotUIs == null) return;