fix: tooltip

This commit is contained in:
Salikh Gurgenidze
2025-12-28 00:52:51 +04:00
parent 89db6d04fa
commit 0b1b3e2dc0
5 changed files with 116 additions and 34 deletions
+53
View File
@@ -319,6 +319,59 @@ function DB:GetCharacterMailbox(fullName)
return char and char.mailbox or {}
end
-- Find an item ID and link by name in any character's data
function DB:FindItemByName(name)
if not name or name == "" or not Guda_DB or not Guda_DB.characters then return nil, nil end
for fullName, char in pairs(Guda_DB.characters) do
-- Check bags
if char.bags then
for bagID, bagData in pairs(char.bags) do
if type(bagData) == "table" and bagData.slots then
for slotID, item in pairs(bagData.slots) do
if item and item.name == name and item.link then
local itemID = addon.Modules.Utils:ExtractItemID(item.link)
if itemID then return itemID, item.link end
end
end
end
end
end
-- Check bank
if char.bank then
for bagID, bagData in pairs(char.bank) do
if type(bagData) == "table" and bagData.slots then
for slotID, item in pairs(bagData.slots) do
if item and item.name == name and item.link then
local itemID = addon.Modules.Utils:ExtractItemID(item.link)
if itemID then return itemID, item.link end
end
end
end
end
end
-- Check equipped
if char.equipped then
for slot, item in pairs(char.equipped) do
if item and item.name == name and item.link then
local itemID = addon.Modules.Utils:ExtractItemID(item.link)
if itemID then return itemID, item.link end
end
end
end
-- Check mailbox
if char.mailbox then
for _, mail in ipairs(char.mailbox) do
if mail.item and mail.item.name == name and mail.item.link then
local itemID = addon.Modules.Utils:ExtractItemID(mail.item.link)
if itemID then return itemID, mail.item.link end
end
end
end
end
return nil, nil
end
-- Get character's equipped items
function DB:GetCharacterEquipped(fullName)
local char = Guda_DB.characters[fullName]
+10 -1
View File
@@ -7,7 +7,10 @@ addon.Modules.Tooltip = Tooltip
-- Helper function to get item ID from link (Lua 5.0 compatible)
local function GetItemIDFromLink(link)
if not link then return nil end
local _, _, itemID = strfind(link, "item:(%d+):?")
if type(link) == "number" then return link end
-- Try to find itemID in a standard link or a raw item:ID string
local _, _, itemID = string.find(link, "item:(%d+)")
return itemID and tonumber(itemID) or nil
end
local function CountCurrentCharacterItems(itemID)
@@ -277,6 +280,12 @@ function Tooltip:AddInventoryInfo(tooltip, link)
return
end
-- Guard against double-adding for the same item on the same tooltip
if tooltip.GudaInventoryAdded == itemID then
return
end
tooltip.GudaInventoryAdded = itemID
local totalBags = 0
local totalBank = 0
local totalMail = 0
+8 -3
View File
@@ -103,15 +103,20 @@ scanTooltip:SetOwner(WorldFrame, "ANCHOR_NONE")
function Utils:GetInboxItemLink(index, itemIndex)
-- Try global function first (if it exists on this server/version)
if GetInboxItemLink then
local link = GetInboxItemLink(index)
-- Turtle WoW might support (index, itemIndex) for multiple attachments
local link = GetInboxItemLink(index, itemIndex or 1)
if link then return link end
-- Fallback to single argument if that failed
link = GetInboxItemLink(index)
if link then return link end
end
-- In 1.12.1, GameTooltip:GetHyperlink() does not exist.
-- Let's try to use GetItemInfo(name) as the primary way.
local name = GetInboxItem(index, itemIndex)
local name, texture, count, quality = GetInboxItem(index, itemIndex or 1)
if name then
local _, link = GetItemInfo(name)
local itemName, link = GetItemInfo(name)
if link then
return link
end