/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

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