-
Notifications
You must be signed in to change notification settings - Fork 3
/
KeystoneTooltip.lua
145 lines (117 loc) · 5.28 KB
/
KeystoneTooltip.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
local line_added = false
local font_color = "|cffffffff"
local dungeon_reward_string = "Dungeon Reward: "
local vault_reward_string = "Vault Reward: "
local dungeon_item_level_table = { 597, 597, 600, 603, 606, 610, 610, 613 }
local dungeon_upgrade_track_table = { "Champion 1", "Champion 1", "Champion 2", "Champion 3", "Champion 4", "Hero 1", "Hero 1", "Hero 2"}
local vault_item_reward_table = { 606, 610, 610, 613, 613, 616, 619, 619, 623 }
local vault_upgrade_track_table = { "Champion 4", "Hero 1", "Hero 1", "Hero 2", "Hero 2", "Hero 3", "Hero 4", "Hero 4", "Myth 1" }
SLASH_KEYSTONETOOLTIP1 = "/kt"
SlashCmdList["KEYSTONETOOLTIP"] = function(msg)
print(dungeon_reward_string .. GetDungeonReward(tonumber(msg)) .. ", " .. GetDungeonRewardTrack(tonumber(msg)))
print(vault_reward_string .. GetVaultReward(tonumber(msg)) .. ", " .. GetVaultRewardTrack(tonumber(msg)))
end
local frame = CreateFrame("Frame");
frame:RegisterEvent("ADDON_LOADED");
frame:SetScript("OnEvent", function(self, event, ...)
if (event == "ADDON_LOADED") then
local addon = ...
end
end)
local function GetItemString(parent_string)
return string.match(parent_string, "keystone[%-?%d:]+")
end
local function GetKeyLevel(parent_string)
return tonumber(string.sub(select(4, strsplit(":", parent_string)), 1, 2))
end
local function OnTooltipSetItem(tooltip, ...)
name, link = GameTooltip:GetItem()
if (link == nil) then return end
for item_link in link:gmatch("|%x+|Hkeystone:.-|h.-|h|r") do
local item_string = GetItemString(item_link)
local key_level = GetKeyLevel(item_string)
local dungeon_item_level = GetDungeonReward(key_level)
local dungeon_upgrade_track = GetDungeonRewardTrack(key_level)
local vault_item_level = GetVaultReward(key_level)
local vault_upgrade_track = GetVaultRewardTrack(key_level)
if not line_added then
tooltip:AddLine(font_color .. dungeon_reward_string .. dungeon_item_level .. ", " .. dungeon_upgrade_track .. "|r")
tooltip:AddLine(font_color .. vault_reward_string .. vault_item_level .. ", " .. vault_upgrade_track .. "|r")
line_added = true
end
end
end
local function OnTooltipCleared(tooltip, ...) line_added = false end
local function SetHyperlink_Hook(self, hyperlink, text, button)
local item_string = GetItemString(hyperlink)
if item_string == nil or item_string == "" then return end
if strsplit(":", item_string) == "keystone" then
local key_level = GetKeyLevel(hyperlink)
local dungeon_item_level = GetDungeonReward(key_level)
local dungeon_upgrade_track = GetDungeonRewardTrack(key_level)
local vault_item_level = GetVaultReward(key_level)
local vault_upgrade_track = GetVaultRewardTrack(key_level)
ItemRefTooltip:AddLine(font_color .. dungeon_reward_string .. dungeon_item_level .. ", " .. dungeon_upgrade_track .. "|r", 1, 1, 1, true)
ItemRefTooltip:AddLine(font_color .. vault_reward_string .. vault_item_level .. ", " .. vault_upgrade_track .. "|r", 1, 1, 1, true)
ItemRefTooltip:Show()
end
end
function GetDungeonReward(key_level)
if key_level == nil or key_level < 2 then
-- Key value outside of normal range, return err
return "Unknown Key Level"
else
if key_level > 9 then
-- return the last element in the table
return tostring(dungeon_item_level_table[#dungeon_item_level_table])
else
-- return the element at the index of key_level-1
return tostring(dungeon_item_level_table[key_level-1])
end
end
end
function GetDungeonRewardTrack(key_level)
if key_level == nil or key_level < 2 then
-- Key value outside of normal range, return err
return "Unknown Key Level"
else
if key_level > 9 then
-- return the last element in the table
return dungeon_upgrade_track_table[#dungeon_upgrade_track_table]
else
-- return the element at the index of key_level-1
return dungeon_upgrade_track_table[key_level-1]
end
end
end
function GetVaultReward(key_level)
if key_level == nil or key_level < 2 then
-- Key value outside of normal range, return err
return "Unknown Key Level"
else
if key_level > 10 then
-- return the last element in the table
return tostring(vault_item_reward_table[#vault_item_reward_table])
else
-- return the element at the index of key_level-1
return tostring(vault_item_reward_table[key_level-1])
end
end
end
function GetVaultRewardTrack(key_level)
if key_level == nil or key_level < 2 then
-- Key value outside of normal range, return err
return "Unknown Key Level"
else
if key_level > 10 then
-- return the last element in the table
return vault_upgrade_track_table[#vault_upgrade_track_table]
else
-- return the element at the index of key_level-1
return vault_upgrade_track_table[key_level-1]
end
end
end
GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
hooksecurefunc("ChatFrame_OnHyperlinkShow", SetHyperlink_Hook)
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, OnTooltipSetItem)