-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.lua
More file actions
720 lines (610 loc) · 25 KB
/
Copy pathOptions.lua
File metadata and controls
720 lines (610 loc) · 25 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
local HRF = CleanRaidFrames
local ROW_HEIGHT = 48
local SETTINGS_ROW_HEIGHT = 40
local ROW_SPACING = 8
local ICON_SIZE = 28
local SECTION_GAP = 18
local SUBTITLE_GAP = 8
local SIDE_PAD = 16
local CONTENT_PAD = 4
local COLOR_ACTIVE_R, COLOR_ACTIVE_G, COLOR_ACTIVE_B = 1, 1, 1
local COLOR_DISABLED_R, COLOR_DISABLED_G, COLOR_DISABLED_B = 0.5, 0.5, 0.5
local HIGHLIGHT_R, HIGHLIGHT_G, HIGHLIGHT_B = 1.0, 0.82, 0.0
local GHOST_ALPHA = 0.35
local panel, scroll, content, scrollBar
local header, hint, testButton, resetAllButton
local buffsSection, defensiveSection, ccSection, pureCCSection, dispelSection
local buffsHint, buffListSubtitle
local buffsDisabledNotice
local dropIndicator
local rowPool = {}
local activeRows = {}
local dragState = { active = false }
local dragUpdater
local suppressRefresh = false
local function spellName(id)
local info = C_Spell and C_Spell.GetSpellInfo and C_Spell.GetSpellInfo(id)
if type(info) == "table" and info.name then return info.name end
if type(info) == "string" then return info end
return "Spell " .. tostring(id)
end
local function spellTexture(id)
return C_Spell and C_Spell.GetSpellTexture and C_Spell.GetSpellTexture(id) or nil
end
local function setLabelEnabled(fs, enabled)
if not fs then return end
if enabled then
fs:SetTextColor(COLOR_ACTIVE_R, COLOR_ACTIVE_G, COLOR_ACTIVE_B)
else
fs:SetTextColor(COLOR_DISABLED_R, COLOR_DISABLED_G, COLOR_DISABLED_B)
end
end
local function makeLabel(parent, text)
local fs = parent:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
fs:SetText(text)
setLabelEnabled(fs, true)
return fs
end
local function updateGlowEnabled(glowCheck, showCheck)
local enabled = showCheck:GetChecked() == true
if enabled then
glowCheck:Enable()
else
glowCheck:Disable()
end
setLabelEnabled(glowCheck.text, enabled)
end
local function createSwatch(parent)
local swatch = CreateFrame("Button", nil, parent, "BackdropTemplate")
swatch:SetSize(22, 22)
swatch:SetBackdrop({
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 10,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
swatch:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
swatch.fill = swatch:CreateTexture(nil, "BACKGROUND")
swatch.fill:SetPoint("TOPLEFT", 3, -3)
swatch.fill:SetPoint("BOTTOMRIGHT", -3, 3)
swatch.fill:SetColorTexture(1, 1, 1, 1)
function swatch:SetColor(r, g, b)
self.fill:SetVertexColor(r, g, b)
end
return swatch
end
local function openColorPicker(r, g, b, onApply)
if not ColorPickerFrame or not ColorPickerFrame.SetupColorPickerAndShow then return end
local info = {
swatchFunc = function()
local nr, ng, nb = ColorPickerFrame:GetColorRGB()
onApply(nr, ng, nb)
end,
cancelFunc = function(previous)
if type(previous) == "table" then
onApply(previous.r or r, previous.g or g, previous.b or b)
else
onApply(r, g, b)
end
end,
hasOpacity = false,
r = r, g = g, b = b,
}
ColorPickerFrame:SetupColorPickerAndShow(info)
end
local function styleContainer(frame)
frame:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 10,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
frame:SetBackdropColor(0, 0, 0, 0.35)
frame:SetBackdropBorderColor(0.25, 0.25, 0.25, 1)
end
local function ensureDropIndicator()
if dropIndicator then return dropIndicator end
dropIndicator = content:CreateTexture(nil, "OVERLAY")
dropIndicator:SetColorTexture(HIGHLIGHT_R, HIGHLIGHT_G, HIGHLIGHT_B, 1)
dropIndicator:SetHeight(2)
dropIndicator:Hide()
return dropIndicator
end
local function cursorY()
local _, y = GetCursorPosition()
return y / UIParent:GetEffectiveScale()
end
-- Returns the 1-based insertion index (1..n+1) based on cursor Y relative to active rows.
local function computeInsertionIndex()
local n = #activeRows
if n == 0 then return 1 end
local y = cursorY()
if y >= activeRows[1]:GetTop() then return 1 end
for i, r in ipairs(activeRows) do
local mid = (r:GetTop() + r:GetBottom()) * 0.5
if y >= mid then return i end
end
return n + 1
end
local function positionDropIndicator(insertIndex)
if not dropIndicator then return end
local n = #activeRows
if n == 0 then
dropIndicator:Hide()
return
end
dropIndicator:ClearAllPoints()
if insertIndex <= 1 then
dropIndicator:SetPoint("BOTTOMLEFT", activeRows[1], "TOPLEFT", 0, 2)
dropIndicator:SetPoint("BOTTOMRIGHT", activeRows[1], "TOPRIGHT", 0, 2)
elseif insertIndex > n then
dropIndicator:SetPoint("TOPLEFT", activeRows[n], "BOTTOMLEFT", 0, -2)
dropIndicator:SetPoint("TOPRIGHT", activeRows[n], "BOTTOMRIGHT", 0, -2)
else
local above = activeRows[insertIndex - 1]
dropIndicator:SetPoint("TOPLEFT", above, "BOTTOMLEFT", 0, -math.floor(ROW_SPACING / 2))
dropIndicator:SetPoint("TOPRIGHT", above, "BOTTOMRIGHT", 0, -math.floor(ROW_SPACING / 2))
end
dropIndicator:Show()
end
local function onDragUpdate()
if not dragState.active then return end
dragState.insertIndex = computeInsertionIndex()
positionDropIndicator(dragState.insertIndex)
end
local function ensureDragUpdater()
if dragUpdater then return end
dragUpdater = CreateFrame("Frame")
dragUpdater:Hide()
dragUpdater:SetScript("OnUpdate", onDragUpdate)
end
local function applyGhost(row)
row:SetAlpha(GHOST_ALPHA)
end
local function clearGhost(row)
row:SetAlpha(1)
end
local function startDrag(row)
if dragState.active then return end
local index
for i, r in ipairs(activeRows) do
if r == row then index = i; break end
end
if not index then return end
dragState.active = true
dragState.row = row
dragState.startIndex = index
dragState.insertIndex = index
dragState.specId = row._specId
dragState.spellId = row._spellId
applyGhost(row)
ensureDropIndicator()
ensureDragUpdater()
positionDropIndicator(index)
dragUpdater:Show()
end
local function stopDrag()
if not dragState.active then return end
if dragUpdater then dragUpdater:Hide() end
if dropIndicator then dropIndicator:Hide() end
local row = dragState.row
if row then clearGhost(row) end
local specId = dragState.specId
local spellId = dragState.spellId
local insertIndex = dragState.insertIndex or dragState.startIndex
local startIndex = dragState.startIndex
-- Convert insertion index to final 1-based position after removal.
local finalPos = insertIndex
if insertIndex > startIndex then finalPos = insertIndex - 1 end
local changed = finalPos ~= startIndex
dragState.active = false
dragState.row = nil
if changed and specId and spellId and HRF.MoveTo then
HRF.MoveTo(specId, spellId, finalPos)
end
if HRF._optionsRefresh then HRF._optionsRefresh() end
end
local function acquireRow(parent)
local row = table.remove(rowPool)
if row then
row:SetParent(parent)
row:Show()
return row
end
row = CreateFrame("Frame", nil, parent, "BackdropTemplate")
row:SetHeight(ROW_HEIGHT)
styleContainer(row)
row:EnableMouse(true)
row:RegisterForDrag("LeftButton")
row:SetScript("OnDragStart", function(self) startDrag(self) end)
row:SetScript("OnDragStop", stopDrag)
row:SetScript("OnMouseUp", function(self, button)
if button == "LeftButton" and dragState.active and dragState.row == self then
stopDrag()
end
end)
row:SetScript("OnEnter", function(self)
if not dragState.active then
self:SetBackdropBorderColor(HIGHLIGHT_R, HIGHLIGHT_G, HIGHLIGHT_B, 1)
end
end)
row:SetScript("OnLeave", function(self)
if not dragState.active or dragState.row ~= self then
self:SetBackdropBorderColor(0.25, 0.25, 0.25, 1)
end
end)
row.position = row:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
row.position:SetPoint("LEFT", row, "LEFT", 10, 0)
row.position:SetWidth(24)
row.position:SetJustifyH("CENTER")
row.iconFrame = CreateFrame("Frame", nil, row, "BackdropTemplate")
row.iconFrame:SetSize(ICON_SIZE + 6, ICON_SIZE + 6)
row.iconFrame:SetPoint("LEFT", row.position, "RIGHT", 4, 0)
row.iconFrame:SetBackdrop({
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 10,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
row.iconFrame:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
row.icon = row.iconFrame:CreateTexture(nil, "ARTWORK")
row.icon:SetSize(ICON_SIZE, ICON_SIZE)
row.icon:SetPoint("CENTER", row.iconFrame, "CENTER", 0, 0)
row.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
row.label = row:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row.label:SetPoint("LEFT", row.iconFrame, "RIGHT", 8, 0)
row.label:SetJustifyH("LEFT")
row.showLabel = makeLabel(row, "Enable:")
row.showCheck = CreateFrame("CheckButton", nil, row, "UICheckButtonTemplate")
row.showCheck:SetSize(22, 22)
row.showCheck.text = row.showLabel
row.glowLabel = makeLabel(row, "Glow:")
row.glowCheck = CreateFrame("CheckButton", nil, row, "UICheckButtonTemplate")
row.glowCheck:SetSize(22, 22)
row.glowCheck.text = row.glowLabel
row.glowCheck:SetPoint("RIGHT", row, "RIGHT", -14, 0)
row.glowLabel:SetPoint("RIGHT", row.glowCheck, "LEFT", -4, 0)
row.showCheck:SetPoint("RIGHT", row.glowLabel, "LEFT", -14, 0)
row.showLabel:SetPoint("RIGHT", row.showCheck, "LEFT", -4, 0)
row.label:SetPoint("RIGHT", row.showLabel, "LEFT", -10, 0)
return row
end
local function releaseRow(row)
row:Hide()
row:ClearAllPoints()
row.showCheck:SetScript("OnClick", nil)
row.glowCheck:SetScript("OnClick", nil)
row._specId = nil
row._spellId = nil
rowPool[#rowPool + 1] = row
end
local function clearRows()
for _, row in ipairs(activeRows) do releaseRow(row) end
for i = #activeRows, 1, -1 do activeRows[i] = nil end
end
local SLIDER_MIN = 10
local SLIDER_MAX = 100
local SLIDER_STEP = 5
local SLIDER_STEPS = (SLIDER_MAX - SLIDER_MIN) / SLIDER_STEP
local function addSizeSlider(parent, sectionKey, anchor)
local sizeLabel = makeLabel(parent, "Size:")
sizeLabel:SetPoint("LEFT", anchor, "RIGHT", 14, 0)
local slider = CreateFrame("Frame", nil, parent, "MinimalSliderWithSteppersTemplate")
slider:SetSize(130, 32)
slider:SetPoint("LEFT", sizeLabel, "RIGHT", 6, 0)
local currentPercent = math.floor(HRF.GetSectionScale(sectionKey) * 100 + 0.5)
currentPercent = math.max(SLIDER_MIN, math.min(SLIDER_MAX, currentPercent))
local formatters = {
[MinimalSliderWithSteppersMixin.Label.Right] = function(value)
return string.format("%d%%", value)
end,
}
slider:Init(currentPercent, SLIDER_MIN, SLIDER_MAX, SLIDER_STEPS, formatters)
slider:RegisterCallback(MinimalSliderWithSteppersMixin.Event.OnValueChanged, function(_, value)
HRF.SetSectionScale(sectionKey, value / 100)
end)
return sizeLabel, slider
end
-- Builds: title, "General Settings" subtitle, and a settings-row container with the
-- Enable checkbox, Highlight Color label + swatch, optional Glow checkbox, and size field.
local function buildSectionShell(parent, title, sectionKey, opts)
opts = opts or {}
local hasGlow = opts.hasGlow ~= false
local titleFS = parent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
titleFS:SetText(title)
local subtitle = parent:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
subtitle:SetText("General Settings")
subtitle:SetPoint("TOPLEFT", titleFS, "BOTTOMLEFT", 0, -SUBTITLE_GAP)
local row = CreateFrame("Frame", nil, parent, "BackdropTemplate")
row:SetHeight(SETTINGS_ROW_HEIGHT)
row:SetPoint("TOPLEFT", subtitle, "BOTTOMLEFT", 0, -6)
row:SetPoint("RIGHT", parent, "RIGHT", -CONTENT_PAD, 0)
styleContainer(row)
local showLabel = makeLabel(row, "Enable:")
showLabel:SetPoint("LEFT", row, "LEFT", 16, 0)
local showCheck = CreateFrame("CheckButton", nil, row, "UICheckButtonTemplate")
showCheck:SetSize(22, 22)
showCheck.text = showLabel
showCheck:SetPoint("LEFT", showLabel, "RIGHT", 4, 0)
local colorLabel = makeLabel(row, "Highlight Color:")
colorLabel:SetPoint("LEFT", showCheck, "RIGHT", 16, 0)
local swatch = createSwatch(row)
swatch:SetPoint("LEFT", colorLabel, "RIGHT", 6, 0)
swatch:SetScript("OnClick", function()
if not swatch:IsEnabled() then return end
local r, g, b = HRF.GetSectionColor(sectionKey)
openColorPicker(r, g, b, function(nr, ng, nb)
HRF.SetSectionColor(sectionKey, nr, ng, nb)
swatch:SetColor(nr, ng, nb)
end)
end)
local function updateSwatchEnabled(enabled)
if enabled then
swatch:Enable()
swatch.fill:SetDesaturated(false)
swatch:SetAlpha(1)
else
swatch:Disable()
swatch.fill:SetDesaturated(true)
swatch:SetAlpha(0.5)
end
end
local glowCheck, glowLabel
local anchorAfterColor = swatch
if hasGlow then
glowLabel = makeLabel(row, "Glow:")
glowLabel:SetPoint("LEFT", swatch, "RIGHT", 16, 0)
glowCheck = CreateFrame("CheckButton", nil, row, "UICheckButtonTemplate")
glowCheck:SetSize(22, 22)
glowCheck.text = glowLabel
glowCheck:SetPoint("LEFT", glowLabel, "RIGHT", 4, 0)
anchorAfterColor = glowCheck
end
local sizeLabel, sizeSlider = addSizeSlider(row, sectionKey, anchorAfterColor)
showCheck:SetScript("OnClick", function(self)
local on = self:GetChecked() == true
HRF.SetSectionShow(sectionKey, on)
setLabelEnabled(colorLabel, on)
updateSwatchEnabled(on)
if glowCheck then
if on then glowCheck:Enable() else glowCheck:Disable() end
setLabelEnabled(glowLabel, on)
end
end)
if glowCheck then
glowCheck:SetScript("OnClick", function(self)
HRF.SetSectionGlow(sectionKey, self:GetChecked())
end)
end
return {
key = sectionKey,
title = titleFS,
subtitle = subtitle,
row = row,
showCheck = showCheck,
glowCheck = glowCheck,
glowLabel = glowLabel,
colorLabel = colorLabel,
swatch = swatch,
updateSwatchEnabled = updateSwatchEnabled,
sizeSlider = sizeSlider,
}
end
local function refreshSection(section)
local key = section.key
local showOn = HRF.GetSectionShow(key)
section.showCheck:SetChecked(showOn)
setLabelEnabled(section.colorLabel, showOn)
if section.updateSwatchEnabled then
section.updateSwatchEnabled(showOn)
end
if section.glowCheck then
local glowOn = HRF.GetSectionGlow(key)
section.glowCheck:SetChecked(glowOn)
if showOn then
section.glowCheck:Enable()
else
section.glowCheck:Disable()
end
if section.glowLabel then
setLabelEnabled(section.glowLabel, showOn)
end
end
local r, g, b = HRF.GetSectionColor(key)
section.swatch:SetColor(r, g, b)
if section.sizeSlider then
local percent = math.floor(HRF.GetSectionScale(key) * 100 + 0.5)
percent = math.max(SLIDER_MIN, math.min(SLIDER_MAX, percent))
section.sizeSlider:SetValue(percent)
end
end
local function refresh()
if dragState.active then return end
clearRows()
if testButton and HRF.IsTestModeOn then
testButton:SetText(HRF.IsTestModeOn() and "Test mode: ON" or "Test mode: OFF")
end
local specId = HRF.GetActiveSpec and HRF.GetActiveSpec()
local specName = specId and HRF.SPEC_NAMES[specId] or nil
local tracked = specId and HRF.IsTrackedSpec(specId) or false
refreshSection(defensiveSection)
refreshSection(ccSection)
refreshSection(pureCCSection)
refreshSection(dispelSection)
if tracked then
refreshSection(buffsSection)
end
local anchorAfterBuffs
if not tracked then
header:SetText("Healer Raid Frames")
hint:SetText("Switch to a supported healing specialization to configure its buff list.\nSupported: Discipline / Holy Priest, Holy Paladin, Restoration Shaman,\nMistweaver Monk, Restoration Druid, Preservation Evoker, Augmentation Evoker.")
-- Collapse the whole Healer Buff Display section into a gray disabled notice.
buffsSection.subtitle:Hide()
buffsSection.row:Hide()
buffListSubtitle:Hide()
buffsHint:SetText("")
buffsHint:Hide()
buffsDisabledNotice:ClearAllPoints()
buffsDisabledNotice:SetPoint("TOPLEFT", buffsSection.title, "BOTTOMLEFT", 0, -SUBTITLE_GAP)
buffsDisabledNotice:Show()
anchorAfterBuffs = buffsDisabledNotice
else
header:SetText("Healer Raid Frames: " .. specName)
hint:SetText("")
buffsDisabledNotice:Hide()
buffsSection.subtitle:Show()
buffsSection.row:Show()
buffsHint:Show()
buffListSubtitle:Show()
buffsHint:SetText("Display buffs on the raid frame in the top right corner. Glow adds a proc glow. "
.. "Drag rows to change order. Top to bottom maps to right to left. "
.. "Only the first " .. tostring(HRF.MAX_HIGHLIGHT_SLOTS) .. " buffs are shown.")
buffListSubtitle:ClearAllPoints()
buffListSubtitle:SetPoint("TOPLEFT", buffsSection.row, "BOTTOMLEFT", 0, -SECTION_GAP)
buffsHint:ClearAllPoints()
buffsHint:SetPoint("TOPLEFT", buffListSubtitle, "BOTTOMLEFT", 0, -6)
buffsHint:SetPoint("RIGHT", content, "RIGHT", -CONTENT_PAD, 0)
local spec = HRF.GetSpecConfig(specId)
local order = spec and spec.order or {}
local previous
for index, spellId in ipairs(order) do
local row = acquireRow(content)
row:ClearAllPoints()
if previous then
row:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 0, -ROW_SPACING)
row:SetPoint("TOPRIGHT", previous, "BOTTOMRIGHT", 0, -ROW_SPACING)
else
row:SetPoint("TOPLEFT", buffsHint, "BOTTOMLEFT", 0, -SUBTITLE_GAP)
row:SetPoint("RIGHT", content, "RIGHT", -CONTENT_PAD, 0)
end
row._specId = specId
row._spellId = spellId
row.position:SetText(tostring(index))
row.icon:SetTexture(spellTexture(spellId) or 134400)
row.label:SetText(spellName(spellId) .. " |cff888888(" .. spellId .. ")|r")
row.showCheck:SetChecked(spec.show[spellId] == true)
row.glowCheck:SetChecked(spec.glow[spellId] == true)
updateGlowEnabled(row.glowCheck, row.showCheck)
row.showCheck:SetScript("OnClick", function(self)
suppressRefresh = true
HRF.SetShow(specId, spellId, self:GetChecked())
suppressRefresh = false
updateGlowEnabled(row.glowCheck, row.showCheck)
end)
row.glowCheck:SetScript("OnClick", function(self)
suppressRefresh = true
HRF.SetGlow(specId, spellId, self:GetChecked())
suppressRefresh = false
end)
activeRows[#activeRows + 1] = row
previous = row
end
anchorAfterBuffs = previous or buffListSubtitle
end
defensiveSection.title:ClearAllPoints()
defensiveSection.title:SetPoint("TOPLEFT", anchorAfterBuffs, "BOTTOMLEFT", 0, -SECTION_GAP)
C_Timer.After(0, function()
if not content then return end
local bottom = dispelSection.row:GetBottom()
local top = content:GetTop()
if bottom and top then
content:SetHeight(math.max(top - bottom + CONTENT_PAD * 2, 1))
end
end)
end
HRF._optionsRefresh = refresh
local function build()
panel = CreateFrame("Frame")
panel.name = "Clean Raid Frames"
scroll = CreateFrame("ScrollFrame", nil, panel, "UIPanelScrollFrameTemplate")
scroll:SetPoint("TOPLEFT", panel, "TOPLEFT", SIDE_PAD, -SIDE_PAD)
scroll:SetPoint("BOTTOMRIGHT", panel, "BOTTOMRIGHT", -SIDE_PAD - 16, SIDE_PAD)
if scroll.ScrollBar then scroll.ScrollBar:Hide() end
if scroll.scrollBarHideable ~= nil then scroll.scrollBarHideable = 1 end
scrollBar = CreateFrame("EventFrame", nil, panel, "MinimalScrollBar")
scrollBar:SetPoint("TOPLEFT", scroll, "TOPRIGHT", 6, 0)
scrollBar:SetPoint("BOTTOMLEFT", scroll, "BOTTOMRIGHT", 6, 0)
content = CreateFrame("Frame", nil, scroll)
content:SetSize(1, 1)
scroll:SetScrollChild(content)
if ScrollUtil and ScrollUtil.InitScrollFrameWithScrollBar then
ScrollUtil.InitScrollFrameWithScrollBar(scroll, scrollBar)
end
scroll:HookScript("OnSizeChanged", function(self, width)
content:SetWidth(math.max(width or 0, 1))
end)
header = content:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
header:SetPoint("TOPLEFT", content, "TOPLEFT", CONTENT_PAD, -CONTENT_PAD)
header:SetText("Healer Raid Frames")
testButton = CreateFrame("Button", nil, content, "UIPanelButtonTemplate")
testButton:SetSize(140, 22)
testButton:SetPoint("RIGHT", content, "RIGHT", -CONTENT_PAD, 0)
testButton:SetPoint("TOP", header, "TOP", 0, 0)
testButton:SetScript("OnClick", function(self)
if HRF.ToggleTestMode then
local on = HRF.ToggleTestMode()
self:SetText(on and "Test mode: ON" or "Test mode: OFF")
end
end)
testButton:SetText((HRF.IsTestModeOn and HRF.IsTestModeOn()) and "Test mode: ON" or "Test mode: OFF")
resetAllButton = CreateFrame("Button", nil, content, "UIPanelButtonTemplate")
resetAllButton:SetSize(140, 22)
resetAllButton:SetText("Reset to Defaults")
resetAllButton:SetPoint("TOP", testButton, "BOTTOM", 0, -6)
resetAllButton:SetPoint("RIGHT", content, "RIGHT", -CONTENT_PAD, 0)
resetAllButton:SetScript("OnClick", function()
HRF.ResetAllDefaults()
refresh()
end)
hint = content:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
hint:SetPoint("TOPLEFT", header, "BOTTOMLEFT", 0, -8)
hint:SetPoint("RIGHT", testButton, "LEFT", -8, 0)
hint:SetJustifyH("LEFT")
hint:SetJustifyV("TOP")
hint:SetText("")
buffsSection = buildSectionShell(content, "Healer Buff Display (Top Right Corner)", "highlight", { hasGlow = false })
buffsSection.title:SetPoint("TOPLEFT", hint, "BOTTOMLEFT", 0, -SECTION_GAP)
-- Shown in place of the buff controls when the player is not in a healing spec.
buffsDisabledNotice = content:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
buffsDisabledNotice:SetText("Healer Buff Display disabled. No Heal Spec active.")
buffsDisabledNotice:SetTextColor(COLOR_DISABLED_R, COLOR_DISABLED_G, COLOR_DISABLED_B)
buffsDisabledNotice:SetJustifyH("LEFT")
buffsDisabledNotice:Hide()
buffListSubtitle = content:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
buffListSubtitle:SetText("Buff Settings")
-- Section hint sits under the "Buff Settings" subtitle in yellow so it reads as an instruction.
buffsHint = content:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
buffsHint:SetJustifyH("LEFT")
buffsHint:SetJustifyV("TOP")
buffsHint:SetTextColor(1, 0.82, 0)
defensiveSection = buildSectionShell(content, "Defensive Buff Icons (Top Left Corner)", "defensive")
ccSection = buildSectionShell(content, "Dispellable CC Debuff Icon (Bottom Left Corner, Slot 1)", "cc")
ccSection.title:ClearAllPoints()
ccSection.title:SetPoint("TOPLEFT", defensiveSection.row, "BOTTOMLEFT", 0, -SECTION_GAP)
pureCCSection = buildSectionShell(content, "Non-Dispellable CC Debuff Icon (Bottom Left Corner, Slot 2)", "pureCC")
pureCCSection.title:ClearAllPoints()
pureCCSection.title:SetPoint("TOPLEFT", ccSection.row, "BOTTOMLEFT", 0, -SECTION_GAP)
dispelSection = buildSectionShell(content, "Dispellable Debuff Icon (Bottom Left Corner, Slot 3)", "dispel")
dispelSection.title:ClearAllPoints()
dispelSection.title:SetPoint("TOPLEFT", pureCCSection.row, "BOTTOMLEFT", 0, -SECTION_GAP)
panel:SetScript("OnShow", refresh)
if Settings and Settings.RegisterCanvasLayoutCategory then
local category = Settings.RegisterCanvasLayoutCategory(panel, panel.name)
Settings.RegisterAddOnCategory(category)
HRF.settingsCategoryID = category:GetID()
end
end
local function onEvent(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == "CleanRaidFrames" then
if HRF.EnsureInitialized then HRF.EnsureInitialized() end
build()
self:UnregisterEvent("ADDON_LOADED")
end
end
local loader = CreateFrame("Frame")
loader:RegisterEvent("ADDON_LOADED")
loader:SetScript("OnEvent", onEvent)
if HRF.Subscribe then
HRF.Subscribe(function()
if suppressRefresh then return end
if panel and panel:IsShown() and not dragState.active then refresh() end
end)
end