Advertisement
Guest User

TooltipID

a guest
Aug 25th, 2016
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.33 KB | None | 0 0
  1. -- ---------------------------------------------------------------------------------------------------------------------------
  2. -- Tooltip IDs
  3. -- ---------------------------------------------------------------------------------------------------------------------------
  4.  
  5. local hooksecurefunc, select, UnitBuff, UnitDebuff, UnitAura, UnitGUID, GetGlyphSocketInfo, tonumber, strfind =
  6. hooksecurefunc, select, UnitBuff, UnitDebuff, UnitAura, UnitGUID, GetGlyphSocketInfo, tonumber, strfind
  7.  
  8. local types = {
  9. spell = "SpellID:",
  10. item = "ItemID:",
  11. unit = "NPC ID:",
  12. quest = "QuestID:",
  13. talent = "TalentID:",
  14. achievement = "AchievementID:",
  15. ability = "AbilityID:",
  16. currency = "CurrencyID:",
  17. artifactpower = "ArtifactPowerID:"
  18. }
  19.  
  20. local function addLine(tooltip, id, type)
  21. local found = false
  22.  
  23. -- Check if we already added to this tooltip. Happens on the talent frame
  24. for i = 1,15 do
  25. local frame = _G[tooltip:GetName() .. "TextLeft" .. i]
  26. local text
  27. if frame then text = frame:GetText() end
  28. if text and text == type then found = true break end
  29. end
  30.  
  31. if not found then
  32. tooltip:AddDoubleLine(type, "|cffffffff" .. id)
  33. tooltip:Show()
  34. end
  35. end
  36.  
  37. -- All types, primarily for detached tooltips
  38. local function onSetHyperlink(self, link)
  39. local type, id = string.match(link,"^(%a+):(%d+)")
  40. if not type or not id then return end
  41. if type == "spell" or type == "enchant" or type == "trade" then
  42. addLine(self, id, types.spell)
  43. elseif type == "talent" then
  44. addLine(self, id, types.talent)
  45. elseif type == "quest" then
  46. addLine(self, id, types.quest)
  47. elseif type == "achievement" then
  48. addLine(self, id, types.achievement)
  49. elseif type == "item" then
  50. addLine(self, id, types.item)
  51. elseif type == "currency" then
  52. addLine(self, id, types.currency)
  53. elseif type == "artifact" then
  54. addLine(self, id, types.artifactpower)
  55. end
  56. end
  57.  
  58. hooksecurefunc(ItemRefTooltip, "SetHyperlink", onSetHyperlink)
  59. hooksecurefunc(GameTooltip, "SetHyperlink", onSetHyperlink)
  60.  
  61. -- Spells
  62. hooksecurefunc(GameTooltip, "SetUnitBuff", function(self, ...)
  63. local id = select(11, UnitBuff(...))
  64. if id then addLine(self, id, types.spell) end
  65. end)
  66.  
  67. hooksecurefunc(GameTooltip, "SetUnitDebuff", function(self,...)
  68. local id = select(11, UnitDebuff(...))
  69. if id then addLine(self, id, types.spell) end
  70. end)
  71.  
  72. hooksecurefunc(GameTooltip, "SetUnitAura", function(self,...)
  73. local id = select(11, UnitAura(...))
  74. if id then addLine(self, id, types.spell) end
  75. end)
  76.  
  77. hooksecurefunc("SetItemRef", function(link, ...)
  78. local id = tonumber(link:match("spell:(%d+)"))
  79. if id then addLine(ItemRefTooltip, id, types.spell) end
  80. end)
  81.  
  82. GameTooltip:HookScript("OnTooltipSetSpell", function(self)
  83. local id = select(3, self:GetSpell())
  84. if id then addLine(self, id, types.spell) end
  85. end)
  86.  
  87. -- ArtifactPowerIDs
  88. hooksecurefunc(GameTooltip, "SetArtifactPowerByID", function(self, id)
  89. if id then
  90. addLine(self, id, types.artifactpower);
  91. addLine(self, id, types.spell);
  92. end
  93. end)
  94.  
  95.  
  96.  
  97. -- NPCs
  98. GameTooltip:HookScript("OnTooltipSetUnit", function(self)
  99. if C_PetBattles.IsInBattle() then return end
  100. local unit = select(2, self:GetUnit())
  101. if unit then
  102. local guid = UnitGUID(unit) or ""
  103. local id = tonumber(guid:match("-(%d+)-%x+$"), 10)
  104. if id and guid:match("%a+") ~= "Player" then addLine(GameTooltip, id, types.unit) end
  105. end
  106. end)
  107.  
  108. -- Items
  109. local function attachItemTooltip(self)
  110. local link = select(2, self:GetItem())
  111. if link then
  112. local id = string.match(link, "item:(%d*)")
  113. if (id == "" or id == "0") and TradeSkillFrame ~= nil and TradeSkillFrame:IsVisible() and GetMouseFocus().reagentIndex then
  114. local selectedRecipe = TradeSkillFrame.RecipeList:GetSelectedRecipeID()
  115. for i = 1, 8 do
  116. if GetMouseFocus().reagentIndex == i then
  117. id = C_TradeSkillUI.GetRecipeReagentItemLink(selectedRecipe, i):match("item:(%d+):") or nil
  118. break
  119. end
  120. end
  121. end
  122. if id then
  123. addLine(self, id, types.item)
  124. end
  125. end
  126. end
  127.  
  128. GameTooltip:HookScript("OnTooltipSetItem", attachItemTooltip)
  129. ItemRefTooltip:HookScript("OnTooltipSetItem", attachItemTooltip)
  130. ItemRefShoppingTooltip1:HookScript("OnTooltipSetItem", attachItemTooltip)
  131. ItemRefShoppingTooltip2:HookScript("OnTooltipSetItem", attachItemTooltip)
  132. ShoppingTooltip1:HookScript("OnTooltipSetItem", attachItemTooltip)
  133. ShoppingTooltip2:HookScript("OnTooltipSetItem", attachItemTooltip)
  134.  
  135. -- Achievement Frame Tooltips
  136. local f = CreateFrame("frame")
  137. f:RegisterEvent("ADDON_LOADED")
  138. f:SetScript("OnEvent", function(_, _, what)
  139. if what == "Blizzard_AchievementUI" then
  140. for i,button in ipairs(AchievementFrameAchievementsContainer.buttons) do
  141. button:HookScript("OnEnter", function()
  142. GameTooltip:SetOwner(button, "ANCHOR_NONE")
  143. GameTooltip:SetPoint("TOPLEFT", button, "TOPRIGHT", 0, 0)
  144. addLine(GameTooltip, button.id, types.achievement)
  145. GameTooltip:Show()
  146. end)
  147. button:HookScript("OnLeave", function()
  148. GameTooltip:Hide()
  149. end)
  150. end
  151. end
  152. end)
  153.  
  154. -- Pet battle buttons
  155. hooksecurefunc("PetBattleAbilityButton_OnEnter", function(self)
  156. local petIndex = C_PetBattles.GetActivePet(LE_BATTLE_PET_ALLY)
  157. if ( self:GetEffectiveAlpha() > 0 ) then
  158. local id = select(1, C_PetBattles.GetAbilityInfo(LE_BATTLE_PET_ALLY, petIndex, self:GetID()))
  159. if id then
  160. local oldText = PetBattlePrimaryAbilityTooltip.Description:GetText(id)
  161. PetBattlePrimaryAbilityTooltip.Description:SetText(oldText .. "\r\r" .. types.ability .. "|cffffffff " .. id .. "|r")
  162. end
  163. end
  164. end)
  165.  
  166. -- Pet battle auras
  167. hooksecurefunc("PetBattleAura_OnEnter", function(self)
  168. local parent = self:GetParent()
  169. local id = select(1, C_PetBattles.GetAuraInfo(parent.petOwner, parent.petIndex, self.auraIndex))
  170. if id then
  171. local oldText = PetBattlePrimaryAbilityTooltip.Description:GetText(id)
  172. PetBattlePrimaryAbilityTooltip.Description:SetText(oldText .. "\r\r" .. types.ability .. "|cffffffff " .. id .. "|r")
  173. end
  174. end)
  175.  
  176. -- Currencies
  177. hooksecurefunc(GameTooltip, "SetCurrencyToken", function(self, index)
  178. local id = tonumber(string.match(GetCurrencyListLink(index),"currency:(%d+)"))
  179. if id then addLine(self, id, types.currency) end
  180. end)
  181.  
  182. hooksecurefunc(GameTooltip, "SetCurrencyByID", function(self, id)
  183. if id then addLine(self, id, types.currency) end
  184. end)
  185.  
  186. hooksecurefunc(GameTooltip, "SetCurrencyTokenByID", function(self, id)
  187. if id then addLine(self, id, types.currency) end
  188. end)
  189.  
  190. -- Quests
  191. do
  192. local function questhook(self)
  193. if self.questID then addLine(GameTooltip, self.questID, types.quest) end
  194. end
  195. local titlebuttonshooked = {}
  196. hooksecurefunc("QuestLogQuests_GetTitleButton", function(index)
  197. local titles = QuestMapFrame.QuestsFrame.Contents.Titles;
  198. if titles[index] and not titlebuttonshooked[index] then
  199. titles[index]:HookScript("OnEnter", questhook)
  200. titlebuttonshooked[index] = true
  201. end
  202. end)
  203. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement