PHP код:
local engine, modules, media = select(2, ...):unpack()
local tooltip = modules:LoadModule("Tooltip")
local SetIcon = function(self, icon)
local title = icon and _G[self:GetName().."TextLeft1"]
if title then
title:SetFormattedText("|T%s:20:20:0:0:64:64:5:59:5:59:%d|t %s", icon, 20, title:GetText())
end
end
local Hook = function(method, func)
return function(tooltip)
local modified = false
tooltip:HookScript("OnTooltipCleared", function(self, ...)
modified = false
end)
tooltip:HookScript(method, function(self, ...)
if not modified then
modified = true
func(self, ...)
end
end)
end
end
local hookItem = Hook("OnTooltipSetItem", function(self, ...)
local _, link = self:GetItem()
if link then
SetIcon(self, GetItemIcon(link))
end
end)
local hookSpell = Hook("OnTooltipSetSpell", function(self, ...)
local _, _, id = self:GetSpell()
if id then
SetIcon(self, select(3, GetSpellInfo(id)))
end
end)
local addLine = function(self, id, isItem)
for i = 1, self:NumLines() do
local line = _G["GameTooltipTextLeft"..i]
if not line then break end
local text = line:GetText()
if text and (text:match("ID") or text:match("ID")) then return end
end
if isItem then
self:AddLine("|cFF4488FFID|r "..id)
else
self:AddLine("|cFF4488FFID|r "..id)
end
self:Show()
end
local attachItemTooltip = function(self)
local link = select(2, self:GetItem())
if not link then return end
local id = select(3, strfind(link, "^|%x+|Hitem:(%-?%d+):(%d+):(%d+):(%d+):(%d+):(%d+):(%-?%d+):(%-?%d+)"))
if id then addLine(self, id, true) end
end
function tooltip:Init()
for _, tooltip in pairs{GameTooltip, ItemRefTooltip, ItemRefShoppingTooltip1, ItemRefShoppingTooltip2, ShoppingTooltip1, ShoppingTooltip2} do
hookItem(tooltip)
hookSpell(tooltip)
end
hooksecurefunc(GameTooltip, "SetUnitAura", function(self, ...)
local id = select(11, UnitAura(...))
if id then addLine(self, id) end
end)
GameTooltip:HookScript("OnTooltipSetSpell", function(self)
local id = select(3, self:GetSpell())
if id then addLine(self, id) end
end)
hooksecurefunc("SetItemRef", function(link, ...)
local id = tonumber(link:match("spell:(%d+)"))
if id then addLine(ItemRefTooltip, id) end
end)
GameTooltip:HookScript("OnTooltipSetItem", attachItemTooltip)
ItemRefTooltip:HookScript("OnTooltipSetItem", attachItemTooltip)
ItemRefShoppingTooltip1:HookScript("OnTooltipSetItem", attachItemTooltip)
ItemRefShoppingTooltip2:HookScript("OnTooltipSetItem", attachItemTooltip)
ShoppingTooltip1:HookScript("OnTooltipSetItem", attachItemTooltip)
ShoppingTooltip2:HookScript("OnTooltipSetItem", attachItemTooltip)
end