Make FindItemIcon return the icon consistently from both paths

The equipped-slot path returned (slot, nil, icon, count) while the bag path returned just the icon. The sole caller (AddAnimation) uses only the first return value as the texture, so equipped items produced a slot number instead of an icon path. Both paths now return the icon as the first value. Also call FindItemIcon once in the caller instead of three times, folding the no-icon case into the same branch.
This commit is contained in:
Brues
2026-06-22 19:15:30 -05:00
parent 8c35b8b6ad
commit 9d0f945c59
@@ -1884,12 +1884,14 @@ function MikSBT.AddAnimation(animationEvent)
end
elseif not texture and BS and BS.GetSpellIcon and BS:GetSpellIcon(name) then
texture = BS:GetSpellIcon(name)
elseif not texture and MikSBT.FindItemIcon(lowerName) then
texture = MikSBT.FindItemIcon(lowerName)
ICON_CACHE[lowerName] = MikSBT.FindItemIcon(lowerName)
elseif not texture then
texture = nil
NO_ICON_CACHE[lowerName] = 1
local itemIcon = MikSBT.FindItemIcon(lowerName)
if itemIcon then
texture = itemIcon
ICON_CACHE[lowerName] = itemIcon
else
NO_ICON_CACHE[lowerName] = 1
end
end
end
@@ -1954,19 +1956,17 @@ function MikSBT.FindItemIcon(item)
local itemLocation = ItemLocation:CreateFromEquipmentSlot(slot)
local itemName = C_Item.GetItemName(itemLocation)
if itemName and item == string.lower(itemName) then
return slot, nil, C_Item.GetItemIcon(itemLocation), GetInventoryItemCount('player', slot)
return C_Item.GetItemIcon(itemLocation)
end
end
local count, texture;
for i = 0, NUM_BAG_FRAMES do
for j = 1, GetContainerNumSlots(i) do
local itemName = C_Item.GetItemName(ItemLocation:CreateFromBagAndSlot(i,j))
if itemName and item == string.lower(itemName) then
texture, count = GetContainerItemInfo(i,j);
return (GetContainerItemInfo(i,j))
end
end
end
return texture;
end
-- **********************************************************************************