Skip to content

Commit 387638d

Browse files
committed
update tooltip, tidy up quantity UI
1 parent 798c73e commit 387638d

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

UnityHiroInventory/Assets/UnityHiroInventory/Scripts/HiroInventoryController.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ private void InitializeUI()
170170

171171
// Item tooltip
172172
itemTooltip = rootElement.Q<VisualElement>("item-tooltip");
173+
itemTooltip.pickingMode = PickingMode.Ignore; // Prevent tooltip from intercepting mouse events
173174
tooltipNameLabel = rootElement.Q<Label>("tooltip-name");
174175
tooltipDescriptionLabel = rootElement.Q<Label>("tooltip-description");
175176
tooltipCategoryLabel = rootElement.Q<Label>("tooltip-category");
@@ -269,7 +270,7 @@ private void PopulateInventoryGrid()
269270

270271
// Update quantity label
271272
var quantityLabel = slotRoot.Q<Label>("item-quantity");
272-
quantityLabel.text = $"x{item.Count}";
273+
quantityLabel.text = $"{item.Count}";
273274

274275
// Get rarity and set background color
275276
var rarity = item.StringProperties.ContainsKey("rarity")
@@ -397,28 +398,35 @@ private void ShowTooltip(IInventoryItem item, Vector2 mousePosition)
397398
tooltipCategoryLabel.text = $"Category: {item.Category ?? "Uncategorized"}";
398399
tooltipQuantityLabel.text = $"Quantity: {item.Count}";
399400

400-
// Display properties if any
401+
// Build comprehensive properties text
401402
var propertiesText = "";
403+
404+
// Item Attributes
405+
propertiesText += "Item Attributes:\n";
406+
propertiesText += $" • Stackable: {(item.Stackable ? "Yes" : "No")}\n";
407+
propertiesText += $" • Consumable: {(item.Consumable ? "Yes" : "No")}\n";
408+
propertiesText += $" • Max Stack: {item.MaxCount}\n";
409+
410+
// String Properties
402411
if (item.StringProperties != null && item.StringProperties.Count > 0)
403412
{
404-
propertiesText += "String Properties:\n";
413+
propertiesText += "\nString Properties:\n";
405414
foreach (var prop in item.StringProperties)
406415
{
407416
propertiesText += $" • {prop.Key}: {prop.Value}\n";
408417
}
409418
}
419+
420+
// Numeric Properties
410421
if (item.NumericProperties != null && item.NumericProperties.Count > 0)
411422
{
412-
if (propertiesText.Length > 0) propertiesText += "\n";
413-
propertiesText += "Numeric Properties:\n";
423+
propertiesText += "\nNumeric Properties:\n";
414424
foreach (var prop in item.NumericProperties)
415425
{
416426
propertiesText += $" • {prop.Key}: {prop.Value}\n";
417427
}
418428
}
419-
tooltipPropertiesLabel.text = string.IsNullOrEmpty(propertiesText)
420-
? "No custom properties."
421-
: propertiesText;
429+
tooltipPropertiesLabel.text = propertiesText;
422430

423431
// Position tooltip near the mouse cursor, offset to the right
424432
var offsetX = 20f;

UnityHiroInventory/Assets/UnityHiroInventory/Scripts/InventoryItemView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void SetVisualElement(VisualElement visualElement)
2323
public void SetInventoryItem(IInventoryItem item)
2424
{
2525
nameLabel.text = item.Name;
26-
quantityLabel.text = item.Count > 0 ? $"x{item.Count}" : "x0";
26+
quantityLabel.text = item.Count > 0 ? $"{item.Count}" : "0";
2727
categoryLabel.text = item.Category ?? "Uncategorized";
2828

2929
// Add visual indicator for consumable items

UnityHiroInventory/Assets/UnityHiroInventory/UI/InventoryItemTemplate.uxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<Style src="project://database/Assets/UnityHiroInventory/HeroicUI/USS/HeroicUSS.uss?fileID=7433441132597879392&amp;guid=c85112b37ef124d80aa9b1b987d1c4d8&amp;type=3#HeroicUSS" />
33
<ui:VisualElement name="inventory-slot" class="inventory-slot" style="width: 200px; height: 200px; margin: 5px; border-width: 0; border-radius: 10px; align-items: center; justify-content: center; -unity-background-scale-mode: stretch-to-fill; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; border-top-width: 4px; border-right-width: 4px; border-bottom-width: 4px; border-left-width: 4px; border-left-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); border-top-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); min-width: auto; min-height: auto; flex-shrink: 0; flex-grow: 0; border-top-left-radius: 15px; border-top-right-radius: 15px; border-bottom-right-radius: 15px; border-bottom-left-radius: 15px;">
44
<ui:VisualElement name="item-icon" style="width: 60%; height: 60%; border-radius: 0; background-color: rgba(0, 0, 0, 0); align-items: center; justify-content: center; -unity-background-scale-mode: scale-to-fit;" />
5-
<ui:Label name="item-quantity" text="x0" style="position: absolute; bottom: 5px; right: 5px; font-size: 50%; color: rgb(255, 255, 255); -unity-font-style: bold; padding: 2px 6px; border-radius: 5px; text-shadow: 3px 3px 3px rgb(0, 0, 0); -unity-background-image-tint-color: rgb(0, 0, 0); -unity-text-outline-width: 0; -unity-text-outline-color: rgb(0, 0, 0);" />
5+
<ui:Label name="item-quantity" text="0" style="position: absolute; bottom: 5px; right: 5px; font-size: 42%; color: rgb(255, 255, 255); -unity-font-style: bold; padding: 2px 6px; border-radius: 5px; text-shadow: 3px 3px 3px rgb(0, 0, 0); -unity-background-image-tint-color: rgb(0, 0, 0); -unity-text-outline-width: 0; -unity-text-outline-color: rgb(0, 0, 0);" />
66
</ui:VisualElement>
77
</ui:UXML>

0 commit comments

Comments
 (0)