Fix: Tooltip error in other addons that hook itemlink for tooltip
This commit is contained in:
+7
-8
@@ -483,15 +483,14 @@ function Tooltip:Initialize()
|
|||||||
local oldSetHyperlink = GameTooltip.SetHyperlink
|
local oldSetHyperlink = GameTooltip.SetHyperlink
|
||||||
function GameTooltip:SetHyperlink(link)
|
function GameTooltip:SetHyperlink(link)
|
||||||
return WithDeferredMoney(self, function()
|
return WithDeferredMoney(self, function()
|
||||||
|
-- The native Blizzard SetHyperlink only accepts a bare "item:ID:e:e:e" string.
|
||||||
|
-- Any addon that captured the native before Guda loaded (e.g. AtlasLoot) will
|
||||||
|
-- call it directly with whatever we pass here, so we MUST strip the color codes
|
||||||
|
-- and |H...|h wrapper before forwarding. Passing the full colored link causes
|
||||||
|
-- "unknown link type" in those addons.
|
||||||
local _, _, inner = string.find(link or "", "|H(.+)|h")
|
local _, _, inner = string.find(link or "", "|H(.+)|h")
|
||||||
local forwarded = link
|
local forwarded = inner or link
|
||||||
local itemLinkForCounts = link
|
local itemLinkForCounts = inner or link
|
||||||
if inner then
|
|
||||||
forwarded = inner
|
|
||||||
if strfind(inner, "^item:") then
|
|
||||||
itemLinkForCounts = inner
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local ret = oldSetHyperlink(self, forwarded)
|
local ret = oldSetHyperlink(self, forwarded)
|
||||||
if itemLinkForCounts and strfind(itemLinkForCounts, "item:") then
|
if itemLinkForCounts and strfind(itemLinkForCounts, "item:") then
|
||||||
Tooltip:AddInventoryInfo(self, itemLinkForCounts)
|
Tooltip:AddInventoryInfo(self, itemLinkForCounts)
|
||||||
|
|||||||
+10
-2
@@ -2524,10 +2524,18 @@ function Guda_ItemButton_OnEnter(self)
|
|||||||
GameTooltip:SetHyperlink(self.itemData.link)
|
GameTooltip:SetHyperlink(self.itemData.link)
|
||||||
end
|
end
|
||||||
elseif self.bagID == -2 then
|
elseif self.bagID == -2 then
|
||||||
-- Keyring: SetBagItem might be unreliable for -2 in some 1.12.1 environments, fallback to hyperlink if needed
|
-- Keyring (bag -2): in 1.12 the native SetBagItem builds the keyring tooltip
|
||||||
|
-- by internally calling SetHyperlink with the FULL colored link
|
||||||
|
-- (|cff..|Hitem:..|h[Name]|h|r). When other addons (AtlasLoot, WoWTranslate)
|
||||||
|
-- have re-hooked SetHyperlink in an order that bypasses Guda's stripping, that
|
||||||
|
-- full link reaches a hook whose captured original is the raw Blizzard
|
||||||
|
-- SetHyperlink — which only accepts the BARE "item:ID:0:0:0" form and otherwise
|
||||||
|
-- throws "unknown link type". We avoid that internal path entirely by calling
|
||||||
|
-- SetHyperlink ourselves with the bare form extracted from the container link.
|
||||||
local link = GetContainerItemLink(self.bagID, self.slotID)
|
local link = GetContainerItemLink(self.bagID, self.slotID)
|
||||||
if link then
|
if link then
|
||||||
GameTooltip:SetHyperlink(link)
|
local _, _, bare = string.find(link, "|H(item:[^|]+)|h")
|
||||||
|
GameTooltip:SetHyperlink(bare or link)
|
||||||
else
|
else
|
||||||
GameTooltip:SetBagItem(self.bagID, self.slotID)
|
GameTooltip:SetBagItem(self.bagID, self.slotID)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user