/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

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