-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.lua
More file actions
360 lines (327 loc) · 11.3 KB
/
Copy pathConfig.lua
File metadata and controls
360 lines (327 loc) · 11.3 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
CleanRaidFrames = CleanRaidFrames or {}
local HRF = CleanRaidFrames
HRF.MAX_HIGHLIGHT_SLOTS = 4
HRF.SPEC_NAMES = {
[256] = "Discipline Priest",
[257] = "Holy Priest",
[264] = "Restoration Shaman",
[65] = "Holy Paladin",
[270] = "Mistweaver Monk",
[105] = "Restoration Druid",
[1468] = "Preservation Evoker",
[1473] = "Augmentation Evoker",
}
-- Per-spec ordered defaults. Position 1 = rightmost in the buff row.
-- show/glow booleans are the initial values.
local DEFAULTS = {
[256] = { -- Discipline Priest
{ id = 17, show = true, glow = true }, -- Power Word: Shield
{ id = 194384, show = true, glow = true }, -- Atonement
{ id = 1253593, show = true, glow = true }, -- Void Shield
},
[257] = { -- Holy Priest
{ id = 41635, show = true, glow = true }, -- Prayer of Mending
{ id = 139, show = true, glow = false }, -- Renew
{ id = 77489, show = true, glow = false }, -- Echo of Light
},
[264] = { -- Restoration Shaman
{ id = 974, show = true, glow = true }, -- Earth Shield
{ id = 383648, show = true, glow = true }, -- Earth Shield (alt)
{ id = 61295, show = true, glow = false }, -- Riptide
},
[65] = { -- Holy Paladin
{ id = 53563, show = true, glow = true }, -- Beacon of Light
{ id = 156910, show = true, glow = true }, -- Beacon of Faith
{ id = 1244893, show = true, glow = true }, -- Beacon of the Savior
{ id = 156322, show = true, glow = false }, -- Eternal Flame
},
[270] = { -- Mistweaver Monk
{ id = 119611, show = true, glow = true }, -- Renewing Mist
{ id = 124682, show = true, glow = true }, -- Enveloping Mist
{ id = 115175, show = true, glow = false }, -- Soothing Mist
{ id = 450769, show = true, glow = false }, -- Aspect of Harmony
},
[105] = { -- Restoration Druid
{ id = 33763, show = true, glow = true }, -- Lifebloom
{ id = 774, show = true, glow = false }, -- Rejuvenation
{ id = 155777, show = true, glow = false }, -- Germination
{ id = 8936, show = true, glow = false }, -- Regrowth
{ id = 48438, show = true, glow = false }, -- Wild Growth
},
[1468] = { -- Preservation Evoker
{ id = 366155, show = true, glow = true }, -- Reversion
{ id = 367364, show = true, glow = false }, -- Echo: Reversion
{ id = 355941, show = true, glow = false }, -- Dream Breath
{ id = 376788, show = true, glow = false }, -- Echo: Dream Breath
{ id = 363502, show = true, glow = false }, -- Dream Flight
{ id = 364343, show = true, glow = false }, -- Echo
{ id = 373267, show = true, glow = false }, -- Lifebind
},
[1473] = { -- Augmentation Evoker
{ id = 395152, show = true, glow = true }, -- Ebon Might
{ id = 410089, show = true, glow = true }, -- Prescience
{ id = 360827, show = true, glow = false }, -- Blistering Scales
{ id = 410263, show = true, glow = false }, -- Inferno's Blessing
{ id = 410686, show = true, glow = false }, -- Symbiotic Bloom
{ id = 413984, show = true, glow = false }, -- Shifting Sands
},
}
local DEFAULT_SCALE = 0.35
local MIN_SCALE, MAX_SCALE = 0.10, 1.0
local GLOBAL_DEFAULTS = {
highlightEnabled = true,
highlightColor = { 1.0, 0.82, 0.0 },
highlightScale = DEFAULT_SCALE,
defensive = { show = true, glow = true, color = { 0.0, 0.6, 0.0 }, scale = DEFAULT_SCALE },
cc = { show = true, glow = true, color = { 0.2, 0.6, 1.0 }, scale = 0.50 },
pureCC = { show = true, glow = false, color = { 1.0, 0.0, 0.0 }, scale = 0.50 },
dispel = { show = true, glow = false, color = { 0.6, 0.0, 1.0 }, scale = DEFAULT_SCALE },
}
HRF.SCALE_MIN = MIN_SCALE
HRF.SCALE_MAX = MAX_SCALE
local listeners = {}
function HRF.Subscribe(callback)
listeners[#listeners + 1] = callback
end
local function notify()
for _, cb in ipairs(listeners) do
pcall(cb)
end
end
function HRF.IsTrackedSpec(specId)
return specId ~= nil and DEFAULTS[specId] ~= nil
end
function HRF.GetActiveSpec()
local idx = GetSpecialization and GetSpecialization()
if not idx then return nil end
local id = GetSpecializationInfo and GetSpecializationInfo(idx)
return id
end
local function cloneDefaults(specId)
local src = DEFAULTS[specId]
if not src then return nil end
local order, show, glow = {}, {}, {}
for i, entry in ipairs(src) do
order[i] = entry.id
show[entry.id] = entry.show ~= false
glow[entry.id] = entry.glow == true
end
return { order = order, show = show, glow = glow }
end
local function getSpecDB(specId)
if not specId or not DEFAULTS[specId] then return nil end
local db = CleanRaidFramesDB
if not db then return nil end
db.specs = db.specs or {}
local spec = db.specs[specId]
if not spec then
spec = cloneDefaults(specId)
db.specs[specId] = spec
return spec
end
-- Merge any newly-added default spells into an existing saved profile.
local seen = {}
for _, id in ipairs(spec.order) do seen[id] = true end
for _, entry in ipairs(DEFAULTS[specId]) do
if not seen[entry.id] then
spec.order[#spec.order + 1] = entry.id
if spec.show[entry.id] == nil then spec.show[entry.id] = entry.show ~= false end
if spec.glow[entry.id] == nil then spec.glow[entry.id] = entry.glow == true end
end
end
return spec
end
HRF.GetSpecConfig = getSpecDB
local function copyColor(c)
return { c[1], c[2], c[3] }
end
local function clampScale(v)
if type(v) ~= "number" then return DEFAULT_SCALE end
if v < MIN_SCALE then return MIN_SCALE end
if v > MAX_SCALE then return MAX_SCALE end
return v
end
local function ensureSection(db, key)
local src = GLOBAL_DEFAULTS[key]
local section = db[key]
if type(section) ~= "table" then
section = {
show = src.show,
glow = src.glow,
color = copyColor(src.color),
scale = src.scale,
}
db[key] = section
return section
end
if section.show == nil then section.show = src.show end
if section.glow == nil then section.glow = src.glow end
if type(section.color) ~= "table" or #section.color < 3 then
section.color = copyColor(src.color)
end
section.scale = clampScale(section.scale)
return section
end
function HRF.EnsureInitialized()
CleanRaidFramesDB = CleanRaidFramesDB or {}
local db = CleanRaidFramesDB
db.specs = db.specs or {}
if type(db.highlightColor) ~= "table" or #db.highlightColor < 3 then
db.highlightColor = copyColor(GLOBAL_DEFAULTS.highlightColor)
end
db.highlightScale = clampScale(db.highlightScale)
if db.highlightEnabled == nil then
db.highlightEnabled = GLOBAL_DEFAULTS.highlightEnabled
end
ensureSection(db, "defensive")
ensureSection(db, "cc")
ensureSection(db, "pureCC")
ensureSection(db, "dispel")
end
local function getSectionDB(key)
HRF.EnsureInitialized()
return CleanRaidFramesDB[key]
end
function HRF.GetSectionShow(key)
if key == "highlight" then
HRF.EnsureInitialized()
return CleanRaidFramesDB.highlightEnabled == true
end
local s = getSectionDB(key)
return s ~= nil and s.show == true
end
function HRF.GetSectionGlow(key)
local s = getSectionDB(key)
return s ~= nil and s.glow == true
end
function HRF.GetSectionColor(key)
if key == "highlight" then
HRF.EnsureInitialized()
local c = CleanRaidFramesDB.highlightColor
return c[1], c[2], c[3]
end
local s = getSectionDB(key)
if not s then return 1, 1, 1 end
return s.color[1], s.color[2], s.color[3]
end
function HRF.SetSectionShow(key, value)
if key == "highlight" then
HRF.EnsureInitialized()
CleanRaidFramesDB.highlightEnabled = value and true or false
notify()
return
end
local s = getSectionDB(key)
if not s then return end
s.show = value and true or false
notify()
end
function HRF.SetSectionGlow(key, value)
local s = getSectionDB(key)
if not s then return end
s.glow = value and true or false
notify()
end
function HRF.ResetSection(key)
HRF.EnsureInitialized()
local src = GLOBAL_DEFAULTS[key]
if not src then return end
CleanRaidFramesDB[key] = {
show = src.show,
glow = src.glow,
color = copyColor(src.color),
scale = src.scale,
}
notify()
end
function HRF.ResetHighlightDefaults(specId)
HRF.EnsureInitialized()
CleanRaidFramesDB.highlightEnabled = GLOBAL_DEFAULTS.highlightEnabled
CleanRaidFramesDB.highlightColor = copyColor(GLOBAL_DEFAULTS.highlightColor)
CleanRaidFramesDB.highlightScale = GLOBAL_DEFAULTS.highlightScale
if specId and DEFAULTS[specId] then
local db = CleanRaidFramesDB
db.specs = db.specs or {}
db.specs[specId] = cloneDefaults(specId)
end
notify()
end
function HRF.ResetAllDefaults()
HRF.EnsureInitialized()
local db = CleanRaidFramesDB
db.highlightEnabled = GLOBAL_DEFAULTS.highlightEnabled
db.highlightColor = copyColor(GLOBAL_DEFAULTS.highlightColor)
db.highlightScale = GLOBAL_DEFAULTS.highlightScale
local specId = HRF.GetActiveSpec()
if specId and DEFAULTS[specId] then
db.specs[specId] = cloneDefaults(specId)
end
for _, key in ipairs({ "defensive", "cc", "pureCC", "dispel" }) do
local src = GLOBAL_DEFAULTS[key]
db[key] = {
show = src.show,
glow = src.glow,
color = copyColor(src.color),
scale = src.scale,
}
end
notify()
end
function HRF.GetSectionScale(key)
HRF.EnsureInitialized()
if key == "highlight" then
return clampScale(CleanRaidFramesDB.highlightScale)
end
local s = CleanRaidFramesDB[key]
return s and clampScale(s.scale) or DEFAULT_SCALE
end
function HRF.SetSectionScale(key, value)
HRF.EnsureInitialized()
local v = clampScale(value)
if key == "highlight" then
CleanRaidFramesDB.highlightScale = v
else
local s = CleanRaidFramesDB[key]
if not s then return end
s.scale = v
end
notify()
end
function HRF.SetSectionColor(key, r, g, b)
HRF.EnsureInitialized()
if key == "highlight" then
CleanRaidFramesDB.highlightColor = { r, g, b }
else
local s = getSectionDB(key)
if not s then return end
s.color = { r, g, b }
end
notify()
end
function HRF.SetShow(specId, spellId, value)
local spec = getSpecDB(specId)
if not spec then return end
spec.show[spellId] = value and true or false
notify()
end
function HRF.SetGlow(specId, spellId, value)
local spec = getSpecDB(specId)
if not spec then return end
spec.glow[spellId] = value and true or false
notify()
end
function HRF.MoveTo(specId, spellId, finalPos)
local spec = getSpecDB(specId)
if not spec then return end
local from
for i, v in ipairs(spec.order) do
if v == spellId then from = i; break end
end
if not from then return end
local n = #spec.order
finalPos = math.max(1, math.min(n, finalPos))
if from == finalPos then return end
table.remove(spec.order, from)
table.insert(spec.order, finalPos, spellId)
notify()
end