/Tukui/modules/tooltip/tooltipicon.lua
http://github.com/Asphyxia/Tukui · Lua · 31 lines · 28 code · 3 blank · 0 comment · 5 complexity · 8d97bb6756f9b04b4c93ba12a5a6ab2a MD5 · raw file
- local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
- local function AddTooltipIcon(self, icon)
- if icon then
- local title = _G[self:GetName() .. "TextLeft1"]
- if title and not title:GetText():find("|T" .. icon) then
- title:SetFormattedText("|T%s:20:20:0:0:64:64:5:59:5:59:%d|t %s", icon, 40, title:GetText())
- end
- end
- end
- local function hookItem(tip)
- tip:HookScript("OnTooltipSetItem", function(self, ...)
- local name, link = self:GetItem()
- local icon = link and GetItemIcon(link)
- AddTooltipIcon(self, icon)
- end)
- end
- hookItem(_G["GameTooltip"])
- hookItem(_G["ItemRefTooltip"])
- local function hookSpell(tip)
- tip:HookScript("OnTooltipSetSpell", function(self, ...)
- if self:GetSpell() then
- local name, rank, icon = GetSpellInfo(self:GetSpell())
- AddTooltipIcon(self, icon)
- end
- end)
- end
- hookSpell(_G["GameTooltip"])
- hookSpell(_G["ItemRefTooltip"])