-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLinkID.lua
104 lines (94 loc) · 4.35 KB
/
LinkID.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
local LibEvent = LibStub:GetLibrary("LibEvent.7000")
local addon = TinyTooltip
local function ParseHyperLink(link)
local name, value = string.match(link or "", "|?H(%a+):(%d+):")
if (name and value) then
return name:gsub("^([a-z])", strupper), value
end
end
local function ShowId(tooltip, name, value, noBlankLine)
if (not name or not value) then return end
if (IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown() or addon.db.general.alwaysShowIdInfo) then
local line = addon:FindLine(tooltip, name)
if (not line) then
if (not noBlankLine) then tooltip:AddLine(" ") end
tooltip:AddLine(format("%s: |cffffffff%s|r", name, value), 0, 1, 0.8)
tooltip:Show()
end
LibEvent:trigger("tooltip.linkid", tooltip, name, value, noBlankLine)
end
end
local function ShowLinkIdInfo(tooltip, link)
ShowId(tooltip, ParseHyperLink(link or select(2,tooltip:GetItem())))
end
-- keystone
local function KeystoneAffixDescription(self, link)
link = link or select(2, self:GetItem())
local data, name, description, AffixID
if (link and strfind(link, "keystone:")) then
link = link:gsub("|H(keystone:.-)|.+", "%1")
data = {strsplit(":", link)}
self:AddLine(" ")
for i = 5, 8 do
AffixID = tonumber(data[i])
if (AffixID and AffixID > 0) then
name, description = C_ChallengeMode.GetAffixInfo(AffixID)
if (name and description) then
self:AddLine(format("|cffffcc33%s:|r%s", name, description), 0.1, 0.9, 0.1, true)
end
end
end
self:Show()
end
end
GameTooltip:HookScript("OnTooltipSetItem", KeystoneAffixDescription)
hooksecurefunc(ItemRefTooltip, "SetHyperlink", KeystoneAffixDescription)
-- Item
hooksecurefunc(GameTooltip, "SetHyperlink", ShowLinkIdInfo)
hooksecurefunc(ItemRefTooltip, "SetHyperlink", ShowLinkIdInfo)
hooksecurefunc("SetItemRef", function(link) ShowLinkIdInfo(ItemRefTooltip, link) end)
GameTooltip:HookScript("OnTooltipSetItem", ShowLinkIdInfo)
ItemRefTooltip:HookScript("OnTooltipSetItem", ShowLinkIdInfo)
ShoppingTooltip1:HookScript("OnTooltipSetItem", ShowLinkIdInfo)
ShoppingTooltip2:HookScript("OnTooltipSetItem", ShowLinkIdInfo)
ItemRefShoppingTooltip1:HookScript("OnTooltipSetItem", ShowLinkIdInfo)
ItemRefShoppingTooltip2:HookScript("OnTooltipSetItem", ShowLinkIdInfo)
-- Spell
GameTooltip:HookScript("OnTooltipSetSpell", function(self) ShowId(self, "Spell", (select(2,self:GetSpell()))) end)
hooksecurefunc(GameTooltip, "SetUnitAura", function(self, ...) ShowId(self, "Spell", (select(10,UnitAura(...)))) end)
hooksecurefunc(GameTooltip, "SetUnitBuff", function(self, ...) ShowId(self, "Spell", (select(10,UnitBuff(...)))) end)
hooksecurefunc(GameTooltip, "SetUnitDebuff", function(self, ...) ShowId(self, "Spell", (select(10,UnitDebuff(...)))) end)
if (GameTooltip.SetArtifactPowerByID) then
hooksecurefunc(GameTooltip, "SetArtifactPowerByID", function(self, powerID)
ShowId(self, "Power", powerID)
ShowId(self, "Spell", C_ArtifactUI.GetPowerInfo(powerID).spellID, 1)
end)
end
-- Quest
if (QuestMapLogTitleButton_OnEnter) then
hooksecurefunc("QuestMapLogTitleButton_OnEnter", function(self)
if (self.questID) then ShowId(GameTooltip, "Quest", self.questID) end
end)
end
-- Achievement UI
local function ShowAchievementId(self)
if ((IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown() or addon.db.general.alwaysShowIdInfo) and self.id) then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT", 0, -32)
GameTooltip:SetText("|cffffdd22Achievement:|r " .. self.id, 0, 1, 0.8)
GameTooltip:Show()
end
end
if (HybridScrollFrame_CreateButtons) then
hooksecurefunc("HybridScrollFrame_CreateButtons", function(self, buttonTemplate)
if (buttonTemplate == "StatTemplate") then
for _, button in pairs(self.buttons) do
button:HookScript("OnEnter", ShowAchievementId)
end
elseif (buttonTemplate == "AchievementTemplate") then
for _, button in pairs(self.buttons) do
button:HookScript("OnEnter", ShowAchievementId)
button:HookScript("OnLeave", GameTooltip_Hide)
end
end
end)
end