fix: tooltip inventory

This commit is contained in:
Salikh Gurgenidze
2025-11-18 03:49:35 +04:00
parent 8f47879955
commit e433e45e19
+140 -8
View File
@@ -82,7 +82,6 @@ function Tooltip:AddInventoryInfo(tooltip, link)
-- Count items across all characters -- Count items across all characters
for charName, charData in pairs(Guda_DB.characters) do for charName, charData in pairs(Guda_DB.characters) do
local bagCount, bankCount = CountItemsForCharacter(itemID, charData) local bagCount, bankCount = CountItemsForCharacter(itemID, charData)
if bagCount > 0 or bankCount > 0 then
totalBags = totalBags + bagCount totalBags = totalBags + bagCount
totalBank = totalBank + bankCount totalBank = totalBank + bankCount
table.insert(characterCounts, { table.insert(characterCounts, {
@@ -93,12 +92,10 @@ function Tooltip:AddInventoryInfo(tooltip, link)
}) })
addon:Debug("Found " .. (bagCount + bankCount) .. " items on " .. charName .. " (Bags: " .. bagCount .. ", Bank: " .. bankCount .. ")") addon:Debug("Found " .. (bagCount + bankCount) .. " items on " .. charName .. " (Bags: " .. bagCount .. ", Bank: " .. bankCount .. ")")
end end
end
local totalCount = totalBags + totalBank local totalCount = totalBags + totalBank
-- Only add to tooltip if we found items -- ALWAYS add to tooltip, even if 0 items
if totalCount > 0 then
addon:Debug("Adding inventory info - Total: " .. totalCount) addon:Debug("Adding inventory info - Total: " .. totalCount)
tooltip:AddLine(" ") tooltip:AddLine(" ")
@@ -125,9 +122,6 @@ function Tooltip:AddInventoryInfo(tooltip, link)
end end
tooltip:Show() tooltip:Show()
else
addon:Debug("No items found for ID: " .. itemID)
end
end end
function Tooltip:Initialize() function Tooltip:Initialize()
@@ -165,14 +159,152 @@ function Tooltip:Initialize()
return ret return ret
end end
-- Hook SetLootItem for loot windows
local oldSetLootItem = GameTooltip.SetLootItem
function GameTooltip:SetLootItem(slot)
local ret = oldSetLootItem(self, slot)
local link = GetLootSlotLink(slot)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetQuestItem for quest rewards
local oldSetQuestItem = GameTooltip.SetQuestItem
function GameTooltip:SetQuestItem(itemType, index)
local ret = oldSetQuestItem(self, itemType, index)
local link = GetQuestItemLink(itemType, index)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetQuestLogItem for quest log items
local oldSetQuestLogItem = GameTooltip.SetQuestLogItem
function GameTooltip:SetQuestLogItem(itemType, index)
local ret = oldSetQuestLogItem(self, itemType, index)
local link = GetQuestLogItemLink(itemType, index)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetTradeSkillItem for tradeskill windows
local oldSetTradeSkillItem = GameTooltip.SetTradeSkillItem
function GameTooltip:SetTradeSkillItem(skillIndex, reagentIndex)
local ret = oldSetTradeSkillItem(self, skillIndex, reagentIndex)
local link
if reagentIndex then
link = GetTradeSkillReagentItemLink(skillIndex, reagentIndex)
else
link = GetTradeSkillItemLink(skillIndex)
end
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetCraftItem for craft windows
local oldSetCraftItem = GameTooltip.SetCraftItem
function GameTooltip:SetCraftItem(skillIndex, reagentIndex)
local ret = oldSetCraftItem(self, skillIndex, reagentIndex)
local link = GetCraftReagentItemLink(skillIndex, reagentIndex)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetAuctionItem for auction house
local oldSetAuctionItem = GameTooltip.SetAuctionItem
function GameTooltip:SetAuctionItem(type, index)
local ret = oldSetAuctionItem(self, type, index)
local link = GetAuctionItemLink(type, index)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetInboxItem for mail
local oldSetInboxItem = GameTooltip.SetInboxItem
function GameTooltip:SetInboxItem(index)
local ret = oldSetInboxItem(self, index)
local link = GetInboxItemLink(index)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetSendMailItem for sending mail
local oldSetSendMailItem = GameTooltip.SetSendMailItem
function GameTooltip:SetSendMailItem(index)
local ret = oldSetSendMailItem(self, index)
local link = GetSendMailItemLink(index)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetMerchantItem for vendor items
local oldSetMerchantItem = GameTooltip.SetMerchantItem
function GameTooltip:SetMerchantItem(index)
local ret = oldSetMerchantItem(self, index)
local link = GetMerchantItemLink(index)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetBuybackItem for buyback items
local oldSetBuybackItem = GameTooltip.SetBuybackItem
function GameTooltip:SetBuybackItem(index)
local ret = oldSetBuybackItem(self, index)
local link = GetBuybackItemLink(index)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetTradePlayerItem for trade window (player side)
local oldSetTradePlayerItem = GameTooltip.SetTradePlayerItem
function GameTooltip:SetTradePlayerItem(index)
local ret = oldSetTradePlayerItem(self, index)
local link = GetTradePlayerItemLink(index)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Hook SetTradeTargetItem for trade window (target side)
local oldSetTradeTargetItem = GameTooltip.SetTradeTargetItem
function GameTooltip:SetTradeTargetItem(index)
local ret = oldSetTradeTargetItem(self, index)
local link = GetTradeTargetItemLink(index)
if link then
Tooltip:AddInventoryInfo(self, link)
end
return ret
end
-- Also hook ItemRefTooltip for chat links -- Also hook ItemRefTooltip for chat links
if ItemRefTooltip then if ItemRefTooltip then
local oldItemRefSetHyperlink = ItemRefTooltip.SetHyperlink local oldItemRefSetHyperlink = ItemRefTooltip.SetHyperlink
function ItemRefTooltip:SetHyperlink(link) function ItemRefTooltip:SetHyperlink(link)
oldItemRefSetHyperlink(self, link) local ret = oldItemRefSetHyperlink(self, link)
if link and strfind(link, "item:") then if link and strfind(link, "item:") then
Tooltip:AddInventoryInfo(self, link) Tooltip:AddInventoryInfo(self, link)
end end
return ret
end end
end end