-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeystoneText.lua
90 lines (68 loc) · 2.55 KB
/
keystoneText.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
-- init
aura_env.nicknames = {}
for _, entry in pairs(aura_env.config.nicknames) do
aura_env.nicknames[entry.challengeMapId] = entry.nickname
end
aura_env.getKeystoneInfoFromItemLink = function(itemLink)
-- Return the map ID and level of the specified keystone 'itemLink'. If
-- 'itemLink' is not a keystone item link, return 'nil'.
if itemLink == nil then
return
end
local mapId, level = select(3, itemLink:find("|Hkeystone:180653:(%d+):(%d+):"))
if mapId == nil then
local bonusIds = select(3, itemLink:find("|Hitem:180653:(.+)"))
if bonusIds == nil then
return
end
local _
mapId, _, level = select(15, strsplit(":", bonusIds))
if mapId == nil then
return
end
end
return tonumber(mapId), tonumber(level)
end
-- trigger: BAG_UPDATE_DELAYED, CHALLENGE_MODE_START, CHALLENGE_MODE_COMPLETED, WA_DEFERRED_KEYSTONE_CHECK, ITEM_CHANGED, OPTIONS
function(event, ...)
local aura_env = aura_env
if event == "CHALLENGE_MODE_COMPLETED" then
-- The keystone changes after this event is fired. Schedule an update.
C_Timer.After(1, function() WeakAuras.ScanEvents("WA_DEFERRED_KEYSTONE_CHECK") end)
return false
elseif event == "ITEM_CHANGED" then
-- Parse the keystone info, if any, from the new item link.
local newItemLink = select(2, ...)
local mapId, level = aura_env.getKeystoneInfoFromItemLink(newItemLink)
if mapId == nil then
return false
end
aura_env.keystoneMapId, aura_env.keystoneLevel = mapId, level
return true
else
local previousKeystoneMapId = aura_env.keystoneMapId
local previousKeystoneLevel = aura_env.keystoneLevel
aura_env.keystoneMapId = C_MythicPlus.GetOwnedKeystoneChallengeMapID()
aura_env.keystoneLevel = C_MythicPlus.GetOwnedKeystoneLevel()
return (aura_env.keystoneMapId ~= nil
and (event == "OPTIONS"
or aura_env.keystoneMapId ~= previousKeystoneMapId
or aura_env.keystoneLevel ~= previousKeystoneLevel))
end
end
-- untrigger
function()
return aura_env.keystoneMapId == nil
end
-- name
function()
local name = aura_env.nicknames[aura_env.keystoneMapId]
if name == nil or name == "" then
name = C_ChallengeMode.GetMapUIInfo(aura_env.keystoneMapId)
end
return name .. " (" .. aura_env.keystoneLevel .. ")"
end
-- icon
function()
return select(4, C_ChallengeMode.GetMapUIInfo(aura_env.keystoneMapId))
end