/Tukui/modules/tooltip/itemidcount.lua
http://github.com/Asphyxia/Tukui · Lua · 74 lines · 63 code · 10 blank · 1 comment · 21 complexity · 762402acfb791b725755bda79bdd45f5 MD5 · raw file
- local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
- if C.tooltip.enable ~= true then return end
- GameTooltip:HookScript("OnTooltipCleared", function(self) self.TukuiItemTooltip = nil end)
- GameTooltip:HookScript("OnTooltipSetItem", function(self)
- if (IsShiftKeyDown() or IsAltKeyDown()) and (TukuiItemTooltip and not self.TukuiItemTooltip and (TukuiItemTooltip.id or TukuiItemTooltip.count)) then
- local item, link = self:GetItem()
- local num = GetItemCount(link)
- local left = ""
- local right = ""
-
- if TukuiItemTooltip.id and link ~= nil then
- left = "|cFFCA3C3CID|r "..link:match(":(%w+)")
- end
-
- if TukuiItemTooltip.count and num > 1 then
- right = "|cFFCA3C3C"..L.tooltip_count.."|r "..num
- end
-
- self:AddLine(" ")
- self:AddDoubleLine(left, right)
- self.TukuiItemTooltip = 1
- end
- end)
- local f = CreateFrame("Frame")
- f:RegisterEvent("ADDON_LOADED")
- f:SetScript("OnEvent", function(_, _, name)
- if name ~= "Tukui" then return end
- f:UnregisterEvent("ADDON_LOADED")
- f:SetScript("OnEvent", nil)
- TukuiItemTooltip = TukuiItemTooltip or {count=true, id=true}
- end)
- -- SpellID on Tooltips (Credits to Silverwind)
- hooksecurefunc(GameTooltip, "SetUnitBuff", function(self,...)
- local id = select(11,UnitBuff(...))
- if id then
- self:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
- self:Show()
- end
- end)
- hooksecurefunc(GameTooltip, "SetUnitDebuff", function(self,...)
- local id = select(11,UnitDebuff(...))
- if id then
- self:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
- self:Show()
- end
- end)
- hooksecurefunc(GameTooltip, "SetUnitAura", function(self,...)
- local id = select(11,UnitAura(...))
- if id then
- self:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
- self:Show()
- end
- end)
- hooksecurefunc("SetItemRef", function(link, text, button, chatFrame)
- if string.find(link,"^spell:") then
- local id = string.sub(link,7)
- ItemRefTooltip:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
- ItemRefTooltip:Show()
- end
- end)
- GameTooltip:HookScript("OnTooltipSetSpell", function(self)
- local id = select(3,self:GetSpell())
- if id then
- self:AddLine("|cFFCA3C3C"..ID.."|r".." "..id)
- self:Show()
- end
- end)