-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathIceStackCounter.lua
203 lines (182 loc) · 6.39 KB
/
IceStackCounter.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
local validUnits = {"player", "target", "focus", "pet", "vehicle", "targettarget", "main hand weapon", "off hand weapon"}
local buffOrDebuff = {"buff", "debuff", "charges", "spell count"}
local GetSpellCharges = GetSpellCharges
if not GetSpellCharges and C_Spell then
GetSpellCharges = function(spellID)
local spellChargeInfo = C_Spell.GetSpellCharges(spellID)
if spellChargeInfo then
return spellChargeInfo.currentCharges, spellChargeInfo.maxCharges, spellChargeInfo.cooldownStartTime, spellChargeInfo.cooldownDuration, spellChargeInfo.chargeModRate
end
end
end
local GetSpellCount = GetSpellCount
if not GetSpellCount and C_Spell then
GetSpellCount = C_Spell.GetSpellCastCount
end
-- OVERRIDE
function IceStackCounter_GetOptions(frame, opts)
opts["customHeader"] = {
type = 'header',
name = L["Aura settings"],
order = 30.1,
}
opts["auraTarget"] = {
type = 'select',
values = validUnits,
name = L["Unit to track"],
desc = L["Select which unit that this bar should be looking for buffs/debuffs on"],
get = function(info)
return IceHUD:GetSelectValue(info, frame.moduleSettings.auraTarget)
end,
set = function(info, v)
frame.moduleSettings.auraTarget = info.option.values[v]
frame.unit = info.option.values[v]
frame:Redraw()
IceHUD:NotifyOptionsChange()
end,
disabled = function()
return not frame.moduleSettings.enabled or frame.moduleSettings.auraType == "charges" or frame.moduleSettings.auraType == "spell count"
end,
order = 30.4,
}
opts["auraType"] = {
type = 'select',
values = buffOrDebuff,
name = L["Buff or debuff?"],
desc = L["Whether we are tracking a buff or debuff"],
get = function(info)
return IceHUD:GetSelectValue(info, frame.moduleSettings.auraType)
end,
set = function(info, v)
frame.moduleSettings.auraType = info.option.values[v]
frame:Redraw()
end,
disabled = function()
return not frame.moduleSettings.enabled or frame.unit == "main hand weapon" or frame.unit == "off hand weapon"
end,
order = 30.5,
}
opts["auraName"] = {
type = 'input',
name = L["Aura to track"],
desc = function()
if IceHUD.GetPlayerAuraBySpellID then
return L["Which buff/debuff this counter will be tracking. Can use the name or spell id. \n\nRemember to press ENTER after filling out this box with the name you want or it will not save."]
else
return L["Which buff/debuff this counter will be tracking. \n\nRemember to press ENTER after filling out this box with the name you want or it will not save."]
end
end,
get = function()
return frame.moduleSettings.auraName
end,
set = function(info, v)
frame.moduleSettings.auraName = v
frame:Redraw()
end,
disabled = function()
return not frame.moduleSettings.enabled or frame.unit == "main hand weapon" or frame.unit == "off hand weapon"
end,
usage = "<which aura to track>",
order = 30.6,
}
opts["trackOnlyMine"] = {
type = 'toggle',
name = L["Only track auras by me"],
desc = L["Checking this means that only buffs or debuffs that the player applied will trigger this bar"],
get = function()
return frame.moduleSettings.onlyMine
end,
set = function(info, v)
frame.moduleSettings.onlyMine = v
frame:Redraw()
end,
disabled = function()
return not frame.moduleSettings.enabled or frame.unit == "main hand weapon" or frame.unit == "off hand weapon"
or frame.moduleSettings.auraType == "charges" or frame.moduleSettings.auraType == "spell count"
end,
order = 30.7,
}
opts["maxCount"] = {
type = 'input',
name = L["Maximum applications"],
desc = L["How many total applications of this buff/debuff can be applied. For example, only 5 sunders can ever be on a target, so this would be set to 5 for tracking Sunder.\n\nRemember to press ENTER after filling out this box with the name you want or it will not save."],
get = function()
return tostring(frame.moduleSettings.maxCount)
end,
set = function(info, v)
if not v or not tonumber(v) or tonumber(v) <= 0 then
v = 5
end
frame.moduleSettings.maxCount = tonumber(v)
frame:Redraw()
end,
disabled = function()
return not frame.moduleSettings.enabled or frame.moduleSettings.auraType == "charges"
end,
usage = "<the maximum number of valid applications>",
order = 30.9,
}
end
function IceStackCounter_GetMaxCount(frame)
if frame.moduleSettings.auraType == "charges" then
local _, max = GetSpellCharges(frame.moduleSettings.auraName)
return max or 1
else
return tonumber(frame.moduleSettings.maxCount)
end
end
function IceStackCounter_GetDefaultSettings(defaults)
defaults["maxCount"] = 5
defaults["auraTarget"] = "player"
defaults["auraName"] = ""
defaults["onlyMine"] = true
defaults["auraType"] = "buff"
end
function IceStackCounter_Enable(frame)
frame:RegisterEvent("UNIT_AURA", "UpdateCustomCount")
frame:RegisterEvent("UNIT_PET", "UpdateCustomCount")
if IceHUD.EventExistsPlayerPetChanged then
frame:RegisterEvent("PLAYER_PET_CHANGED", "UpdateCustomCount")
end
if FocusUnit then
frame:RegisterEvent("PLAYER_FOCUS_CHANGED", "UpdateCustomCount")
end
frame:RegisterEvent("PLAYER_DEAD", "UpdateCustomCount")
frame:RegisterEvent("SPELL_UPDATE_CHARGES", "UpdateCustomCount")
frame.unit = frame.moduleSettings.auraTarget or "player"
if not tonumber(frame.moduleSettings.maxCount) or tonumber(frame.moduleSettings.maxCount) <= 0 then
frame.moduleSettings.maxCount = 5
frame:Redraw()
end
end
function IceStackCounter_GetCount(frame)
if not frame.moduleSettings.auraName then
return
end
local points
if IceHUD.IceCore:IsInConfigMode() then
points = tonumber(frame.moduleSettings.maxCount)
else
if frame.moduleSettings.auraType == "charges" then
points = GetSpellCharges(frame.moduleSettings.auraName) or 0
elseif frame.moduleSettings.auraType == "spell count" then
points = GetSpellCount(frame.moduleSettings.auraName) or 0
else
points = IceHUD:GetAuraCount(frame.moduleSettings.auraType == "buff" and "HELPFUL" or "HARMFUL",
frame.unit, frame.moduleSettings.auraName, frame.moduleSettings.onlyMine, true)
end
end
frame.lastPoints = points
if (points == 0) then
points = nil
end
return points
end
function IceStackCounter_UseTargetAlpha(frame)
if frame.moduleSettings.auraType == "charges" then
return IceStackCounter_GetCount(frame) ~= IceStackCounter_GetMaxCount(frame) or frame.target or frame.combat
else
return frame.lastPoints ~= nil and frame.lastPoints > 0
end
end