PageRenderTime 55ms CodeModel.GetById 50ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Tukui/modules/tooltip/tooltipicon.lua

http://github.com/Asphyxia/Tukui
Lua | 31 lines | 28 code | 3 blank | 0 comment | 3 complexity | 8d97bb6756f9b04b4c93ba12a5a6ab2a MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2
 3local function AddTooltipIcon(self, icon)
 4	if icon then
 5		local title = _G[self:GetName() .. "TextLeft1"]
 6		if title and not title:GetText():find("|T" .. icon) then
 7			title:SetFormattedText("|T%s:20:20:0:0:64:64:5:59:5:59:%d|t %s", icon, 40, title:GetText())
 8		end
 9	end
10end
11
12local function hookItem(tip)
13	tip:HookScript("OnTooltipSetItem", function(self, ...)
14		local name, link = self:GetItem()
15		local icon = link and GetItemIcon(link)
16		AddTooltipIcon(self, icon)
17	end)
18end
19hookItem(_G["GameTooltip"])
20hookItem(_G["ItemRefTooltip"])
21
22local function hookSpell(tip)
23	tip:HookScript("OnTooltipSetSpell", function(self, ...)
24		if self:GetSpell() then
25			local name, rank, icon = GetSpellInfo(self:GetSpell())
26			AddTooltipIcon(self, icon)
27		end
28	end)
29end
30hookSpell(_G["GameTooltip"])
31hookSpell(_G["ItemRefTooltip"])