PageRenderTime 29ms CodeModel.GetById 21ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Tukui/modules/tooltip/itemidcount.lua

http://github.com/Asphyxia/Tukui
Lua | 74 lines | 63 code | 10 blank | 1 comment | 10 complexity | 762402acfb791b725755bda79bdd45f5 MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2if C.tooltip.enable ~= true then return end
 3
 4GameTooltip:HookScript("OnTooltipCleared", function(self) self.TukuiItemTooltip = nil end)
 5GameTooltip:HookScript("OnTooltipSetItem", function(self)
 6	if (IsShiftKeyDown() or IsAltKeyDown()) and (TukuiItemTooltip and not self.TukuiItemTooltip and (TukuiItemTooltip.id or TukuiItemTooltip.count)) then
 7		local item, link = self:GetItem()
 8		local num = GetItemCount(link)
 9		local left = ""
10		local right = ""
11		
12		if TukuiItemTooltip.id and link ~= nil then
13			left = "|cFFCA3C3CID|r "..link:match(":(%w+)")
14		end
15		
16		if TukuiItemTooltip.count and num > 1 then
17			right = "|cFFCA3C3C"..L.tooltip_count.."|r "..num
18		end
19				
20		self:AddLine(" ")
21		self:AddDoubleLine(left, right)
22		self.TukuiItemTooltip = 1
23	end
24end)
25
26local f = CreateFrame("Frame")
27f:RegisterEvent("ADDON_LOADED")
28f:SetScript("OnEvent", function(_, _, name)
29	if name ~= "Tukui" then return end
30	f:UnregisterEvent("ADDON_LOADED")
31	f:SetScript("OnEvent", nil)
32	TukuiItemTooltip = TukuiItemTooltip or {count=true, id=true}
33end)
34
35-- SpellID on Tooltips (Credits to Silverwind)
36hooksecurefunc(GameTooltip, "SetUnitBuff", function(self,...)
37	local id = select(11,UnitBuff(...))
38	if id then
39		self:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
40		self:Show()
41	end
42end)
43
44hooksecurefunc(GameTooltip, "SetUnitDebuff", function(self,...)
45	local id = select(11,UnitDebuff(...))
46	if id then
47		self:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
48		self:Show()
49	end
50end)
51
52hooksecurefunc(GameTooltip, "SetUnitAura", function(self,...)
53	local id = select(11,UnitAura(...))
54	if id then
55		self:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
56		self:Show()
57	end
58end)
59
60hooksecurefunc("SetItemRef", function(link, text, button, chatFrame)
61	if string.find(link,"^spell:") then
62		local id = string.sub(link,7)
63		ItemRefTooltip:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
64		ItemRefTooltip:Show()
65	end
66end)
67
68GameTooltip:HookScript("OnTooltipSetSpell", function(self)
69	local id = select(3,self:GetSpell())
70	if id then
71		self:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
72		self:Show()
73	end
74end)