-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathOptions.lua
More file actions
2806 lines (2748 loc) · 131 KB
/
Copy pathOptions.lua
File metadata and controls
2806 lines (2748 loc) · 131 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
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local BigDebuffs = LibStub("AceAddon-3.0"):GetAddon("BigDebuffs")
local L = LibStub("AceLocale-3.0"):GetLocale("BigDebuffs")
local LibSharedMedia = LibStub("LibSharedMedia-3.0")
local GetSpellTexture = C_Spell and C_Spell.GetSpellTexture or GetSpellTexture
local GetSpellInfo = C_Spell and C_Spell.GetSpellInfo or GetSpellInfo
local GetAddOnMetadata = C_AddOns.GetAddOnMetadata
local function GetSpellName(id)
if C_Spell and C_Spell.GetSpellName then
return C_Spell.GetSpellName(id)
else
return GetSpellInfo(id)
end
end
-- A trimmed EditBox widget with no confirm ("okay") button. Stock AceGUI
-- EditBoxes only commit their value (and trigger a full options panel
-- rebuild) when Enter is pressed or the checkmark is clicked; anything typed
-- but not yet confirmed is lost the moment a sibling widget (e.g. a select
-- dropdown) triggers that rebuild. This widget instead calls the option's
-- `set` directly on every keystroke, so the backing value is always current
-- and no explicit confirmation step is needed.
do
local AceGUI = LibStub("AceGUI-3.0")
local WidgetType = "BigDebuffsLiveEditBox"
if not AceGUI:GetWidgetVersion(WidgetType) then
local function Control_OnEnter(frame) frame.obj:Fire("OnEnter") end
local function Control_OnLeave(frame) frame.obj:Fire("OnLeave") end
local function EditBox_OnEscapePressed(frame) AceGUI:ClearFocus() end
local function EditBox_OnEnterPressed(frame)
local self = frame.obj
self:Fire("OnEnterPressed", frame:GetText())
end
local function EditBox_OnFocusGained(frame) AceGUI:SetFocus(frame.obj) end
local function EditBox_OnTextChanged(frame)
local self = frame.obj
local value = frame:GetText()
if tostring(value) ~= tostring(self.lasttext) then
self.lasttext = value
self:Fire("OnTextChanged", value)
-- Commit immediately, bypassing AceConfigDialog's Enter-only
-- ActivateControl path so no full panel rebuild happens
-- while typing (which would steal keyboard focus).
local user = self:GetUserDataTable()
local option = user and user.option
if option and type(option.set) == "function" then
option.set(nil, value)
end
end
end
local methods = {
["OnAcquire"] = function(self)
self:SetWidth(200)
self:SetDisabled(false)
self:SetLabel()
self:SetText()
self:SetMaxLetters(0)
end,
["OnRelease"] = function(self) self:ClearFocus() end,
["SetDisabled"] = function(self, disabled)
self.disabled = disabled
if disabled then
self.editbox:EnableMouse(false)
self.editbox:ClearFocus()
self.editbox:SetTextColor(0.5, 0.5, 0.5)
self.label:SetTextColor(0.5, 0.5, 0.5)
else
self.editbox:EnableMouse(true)
self.editbox:SetTextColor(1, 1, 1)
self.label:SetTextColor(1, .82, 0)
end
end,
["SetText"] = function(self, text)
self.lasttext = text or ""
self.editbox:SetText(text or "")
self.editbox:SetCursorPosition(0)
end,
["GetText"] = function(self) return self.editbox:GetText() end,
["SetLabel"] = function(self, text)
if text and text ~= "" then
self.label:SetText(text)
self.label:Show()
self.editbox:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 7, -18)
self:SetHeight(44)
self.alignoffset = 30
else
self.label:SetText("")
self.label:Hide()
self.editbox:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 7, 0)
self:SetHeight(26)
self.alignoffset = 12
end
end,
["SetMaxLetters"] = function(self, num) self.editbox:SetMaxLetters(num or 0) end,
["ClearFocus"] = function(self)
self.editbox:ClearFocus()
self.frame:SetScript("OnShow", nil)
end,
["SetFocus"] = function(self) self.editbox:SetFocus() end,
["HighlightText"] = function(self, from, to) self.editbox:HighlightText(from, to) end,
}
local function Constructor()
local num = AceGUI:GetNextWidgetNum(WidgetType)
local frame = CreateFrame("Frame", nil, UIParent)
frame:Hide()
local editbox = CreateFrame("EditBox", "AceGUI-3.0"..WidgetType..num, frame, "InputBoxTemplate")
editbox:SetAutoFocus(false)
editbox:SetFontObject(ChatFontNormal)
editbox:SetScript("OnEnter", Control_OnEnter)
editbox:SetScript("OnLeave", Control_OnLeave)
editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
editbox:SetScript("OnTextChanged", EditBox_OnTextChanged)
editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
editbox:SetTextInsets(0, 0, 3, 3)
editbox:SetMaxLetters(256)
editbox:SetPoint("BOTTOMLEFT", 6, 0)
editbox:SetPoint("BOTTOMRIGHT")
editbox:SetHeight(19)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
label:SetPoint("TOPLEFT", 0, -2)
label:SetPoint("TOPRIGHT", 0, -2)
label:SetJustifyH("LEFT")
label:SetHeight(18)
local widget = {
editbox = editbox,
label = label,
frame = frame,
type = WidgetType,
}
for method, func in pairs(methods) do
widget[method] = func
end
editbox.obj = widget
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(WidgetType, Constructor, 1)
end
end
-- A Button that reserves the same header space a labeled EditBox/Dropdown
-- does (and shares their alignoffset), so it lines up with the input row
-- instead of sitting higher, centred on its own shorter, label-less height.
do
local AceGUI = LibStub("AceGUI-3.0")
local WidgetType = "BigDebuffsAlignedButton"
if not AceGUI:GetWidgetVersion(WidgetType) then
local function Button_OnClick(frame, ...)
AceGUI:ClearFocus()
PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
frame.obj:Fire("OnClick", ...)
end
local function Control_OnEnter(frame) frame.obj:Fire("OnEnter") end
local function Control_OnLeave(frame) frame.obj:Fire("OnLeave") end
local methods = {
["OnAcquire"] = function(self)
self:SetWidth(200)
self:SetHeight(44)
self:SetDisabled(false)
self:SetText()
end,
["SetText"] = function(self, text) self.text:SetText(text) end,
["SetDisabled"] = function(self, disabled)
self.disabled = disabled
if disabled then self.button:Disable() else self.button:Enable() end
end,
}
local function Constructor()
local num = AceGUI:GetNextWidgetNum(WidgetType)
local frame = CreateFrame("Frame", nil, UIParent)
frame:Hide()
local button = CreateFrame("Button", "AceGUI30"..WidgetType..num, frame, "UIPanelButtonTemplate")
button:EnableMouse(true)
button:SetScript("OnClick", Button_OnClick)
button:SetScript("OnEnter", Control_OnEnter)
button:SetScript("OnLeave", Control_OnLeave)
button:SetPoint("BOTTOMLEFT", 0, 0)
button:SetPoint("BOTTOMRIGHT", 0, 0)
button:SetHeight(19)
local text = button:GetFontString()
text:ClearAllPoints()
text:SetPoint("TOPLEFT", 15, -1)
text:SetPoint("BOTTOMRIGHT", -15, 1)
text:SetJustifyV("MIDDLE")
local widget = {
button = button,
text = text,
frame = frame,
alignoffset = 30, -- matches the labeled EditBox/Dropdown offset
type = WidgetType,
}
for method, func in pairs(methods) do
widget[method] = func
end
button.obj = widget
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(WidgetType, Constructor, 1)
end
end
-- A full-width, globally named status line. Explains live (as the user types
-- a Spell ID) why the Add Spell button is disabled - e.g. that the ID is
-- already tracked - instead of leaving a greyed-out button with no reason.
do
local AceGUI = LibStub("AceGUI-3.0")
local WidgetType = "BigDebuffsStatusLabel"
if not AceGUI:GetWidgetVersion(WidgetType) then
local methods = {
["OnAcquire"] = function(self)
self:SetHeight(18)
self:SetText("")
end,
["SetText"] = function(self, text) self.fontstring:SetText(text or "") end,
-- AceConfigDialog calls this on every render after creation, which
-- would otherwise reset the fontstring to its font object's default
-- (white) colour - reapply the warning colour each time.
["SetFontObject"] = function(self, font)
self.fontstring:SetFontObject(font)
self.fontstring:SetTextColor(1, 0.5, 0.2)
end,
}
local function Constructor()
local num = AceGUI:GetNextWidgetNum(WidgetType)
local frame = CreateFrame("Frame", "AceGUI30"..WidgetType..num, UIParent)
frame:Hide()
local fontstring = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
fontstring:SetPoint("TOPLEFT", 4, 0)
fontstring:SetPoint("TOPRIGHT", -4, 0)
fontstring:SetJustifyH("LEFT")
fontstring:SetTextColor(1, 0.5, 0.2)
local widget = {
fontstring = fontstring,
frame = frame,
type = WidgetType,
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(WidgetType, Constructor, 1)
end
end
local WarningDebuffs = {}
if WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC then
for i = 1, #BigDebuffs.WarningDebuffs do
local id = BigDebuffs.WarningDebuffs[i]
local name = GetSpellName(id)
if name then
WarningDebuffs[name] = {
type = "toggle",
get = function(info) local key = info[#info-2] return BigDebuffs.db.profile[key].warningList[id] end,
set = function(info, value)
local key = info[#info-2]
BigDebuffs.db.profile[key].warningList[id] = value BigDebuffs:Refresh()
end,
name = name,
desc = function()
local s = Spell:CreateFromSpellID(id)
local spellDesc = s:GetSpellDescription() or ""
local extra =
"\n\n|cffffd700"..L["Spell ID"].."|r "..id..
"\n------------------\n"..
L["Show this debuff if present while BigDebuffs are displayed"]
return spellDesc..extra
end,
}
end
end
end
local order = {
immunities = 1,
immunities_spells = 2,
cc = 3,
buffs_defensive = 4,
buffs_offensive = 5,
debuffs_offensive = 6,
buffs_other = 7,
roots = 8,
buffs_speed_boost = 9,
}
local SpellNames = {}
local SpellIcons = {}
-- Categories offered in the category dropdown (localized), in display order
local categorySorting = {
"immunities", "immunities_spells", "cc", "interrupts",
"buffs_defensive", "buffs_offensive", "debuffs_offensive",
"buffs_other", "roots", "buffs_speed_boost",
}
local categoryValues = {}
for _, key in ipairs(categorySorting) do categoryValues[key] = L[key] end
-- Preset spells that other spells link to as a parent (shared ranks) must not
-- be re-mapped to a different ID, or their children would be orphaned.
local parentIDs = {}
for _, s in pairs(BigDebuffs.BaseSpells) do
if s.parent then parentIDs[s.parent] = true end
end
-- Build the options card for a single spell (preset or custom). The card is
-- keyed by spellID and reads its effective category from BigDebuffs.Spells so
-- category overrides and custom spells are reflected the moment they change.
local function BuildSpellCard(spellID, spell, isCustom)
local raidFrames = spell.type == "cc" or
spell.type == "roots" or
spell.type == "special" or
spell.type == "interrupts" or
spell.type == "debuffs_offensive"
return {
type = "group",
get = function(info)
local name = info[#info]
return BigDebuffs.db.profile.spells[spellID] and BigDebuffs.db.profile.spells[spellID][name]
end,
set = function(info, value)
local name = info[#info]
BigDebuffs.db.profile.spells[spellID] = BigDebuffs.db.profile.spells[spellID] or {}
BigDebuffs.db.profile.spells[spellID][name] = value
BigDebuffs:Refresh()
end,
name = function(info)
local name = SpellNames[spellID] or GetSpellName(spellID)
SpellNames[spellID] = name
return name
end,
icon = function()
local icon = SpellIcons[spellID] or GetSpellTexture(spellID)
SpellIcons[spellID] = icon
return icon
end,
desc = function()
local s = Spell:CreateFromSpellID(spellID)
local spellDesc = s:GetSpellDescription() or ""
local extra = "\n\n|cffffd700"..L["Spell ID"].."|r "..spellID
return spellDesc..extra
end,
args = {
spellId = {
order = 0,
type = "input",
name = L["Spell ID"],
desc = function()
local s = BigDebuffs.Spells[spellID]
if s and s.replacedFrom then
local baseName = GetSpellName(s.replacedFrom) or "?"
return L["Replaces preset"]..": "..baseName.." ("..s.replacedFrom..")"
.."\n\n"..L["Change the spell ID this entry tracks (enter the original ID to reset)"]
end
return L["Change the spell ID this entry tracks (enter the original ID to reset)"]
end,
width = "relative",
relWidth = 0.5,
disabled = function()
if isCustom then return false end
local s = BigDebuffs.Spells[spellID]
local baseKey = (s and s.replacedFrom) or spellID
return parentIDs[baseKey] and true or false
end,
get = function() return tostring(spellID) end,
validate = function(_, value)
local n = tonumber(value)
if not n then return L["Please enter a number"] end
if not GetSpellName(n) then return L["No spell exists with that ID"] end
if n ~= spellID and BigDebuffs.Spells[n] then return L["That spell is already tracked"] end
return true
end,
set = function(_, value)
local newID = tonumber(value)
if not newID or newID == spellID then return end
local sp = BigDebuffs.db.profile.spells
if isCustom then
local cs = BigDebuffs.db.profile.customSpells
cs[newID] = cs[spellID]
cs[spellID] = nil
else
local s = BigDebuffs.Spells[spellID]
local baseID = (s and s.replacedFrom) or spellID
local repl = BigDebuffs.db.profile.spellReplacements
if newID == baseID then
repl[baseID] = nil
else
repl[baseID] = newID
end
end
-- Move per-spell overrides to the new effective ID
if sp[spellID] then
sp[newID] = sp[spellID]
sp[spellID] = nil
end
BigDebuffs:BuildSpellList()
BigDebuffs:RefreshSpellOptions()
BigDebuffs:Refresh()
end,
},
category = {
order = 1,
type = "select",
name = L["Category"],
desc = L["Change which category this spell belongs to"],
width = "relative",
relWidth = 0.5,
values = categoryValues,
sorting = categorySorting,
get = function()
local s = BigDebuffs.Spells[spellID]
return s and s.type
end,
set = function(_, value)
if isCustom then
local c = BigDebuffs.db.profile.customSpells
c[spellID] = c[spellID] or {}
c[spellID].type = value
else
local ov = BigDebuffs.db.profile.spells
ov[spellID] = ov[spellID] or {}
local base = BigDebuffs.BaseSpells[spellID]
if base and base.type == value then
ov[spellID].type = nil
else
ov[spellID].type = value
end
end
BigDebuffs:BuildSpellList()
BigDebuffs:RefreshSpellOptions()
BigDebuffs:Refresh()
end,
},
visibility = {
order = 2,
type = "group",
name = L["Visibility"],
inline = true,
get = function(info)
local name = info[#info]
local value = (BigDebuffs.db.profile.spells[spellID] and
BigDebuffs.db.profile.spells[spellID][name]) or
(not BigDebuffs.Spells[spellID]["no"..name] and 1)
return value and value == 1
end,
set = function(info, value)
local name = info[#info]
BigDebuffs.db.profile.spells[spellID] = BigDebuffs.db.profile.spells[spellID] or {}
value = value and 1 or 0
BigDebuffs.db.profile.spells[spellID][name] = value
-- unset if default visibility
local no = BigDebuffs.Spells[spellID]["no"..name]
if (value == 1 and not no) or
(value == 0 and no) then
BigDebuffs.db.profile.spells[spellID][name] = nil
end
BigDebuffs:Refresh()
end,
args = {
raidFrames = raidFrames and {
type = "toggle",
name = L["Raid Frames"],
desc = L["Show this spell on the raid frames"],
width = "full",
order = 1,
} or nil,
unitFrames = {
type = "toggle",
name = L["Unit Frames"],
desc = L["Show this spell on the unit frames"],
width = "full",
order = 2
},
nameplates = {
type = "toggle",
name = "Nameplates",
desc = L["Show this spell on nameplates"],
width = "full",
order = 3
},
},
},
priority = {
type = "group",
inline = true,
name = L["Priority"],
args = {
customPriority = {
name = L["Custom Priority"],
type = "toggle",
order = 2,
set = function(info, value)
BigDebuffs.db.profile.spells[spellID] = BigDebuffs.db.profile.spells[spellID] or {}
BigDebuffs.db.profile.spells[spellID].customPriority = value
if not value then
BigDebuffs.db.profile.spells[spellID].priority = nil
end
BigDebuffs:Refresh()
end,
},
priority = {
name = L["Priority"],
desc = L["Higher priority spells will take precedence regardless of duration"],
type = "range",
min = 1,
max = 100,
step = 1,
order = 3,
disabled = function()
return not BigDebuffs.db.profile.spells[spellID] or
not BigDebuffs.db.profile.spells[spellID].customPriority
end,
get = function(info)
-- Pull the category priority
return BigDebuffs.db.profile.spells[spellID] and
BigDebuffs.db.profile.spells[spellID].priority and
BigDebuffs.db.profile.spells[spellID].priority or
BigDebuffs.db.profile.priority[spell.type]
end,
},
},
},
size = raidFrames and {
name = L["Size"],
type = "group",
inline = true,
args = {
customSize = {
name = L["Custom Size"],
type = "toggle",
order = 4,
set = function(info, value)
local name = info[#info]
BigDebuffs.db.profile.spells[spellID] = BigDebuffs.db.profile.spells[spellID] or {}
BigDebuffs.db.profile.spells[spellID].customSize = value
if not value then
BigDebuffs.db.profile.spells[spellID].size = nil
end
BigDebuffs:Refresh()
end,
},
size = {
type = "range",
isPercent = true,
name = L["Size"],
desc = L["Set the custom size of this spell"],
get = function(info)
-- Pull the category size
return BigDebuffs.db.profile.spells[spellID] and
BigDebuffs.db.profile.spells[spellID].size and
BigDebuffs.db.profile.spells[spellID].size/100 or
BigDebuffs.db.profile.raidFrames[string.lower(spell.type)]/100
end,
set = function(info, value)
local name = info[#info]
BigDebuffs.db.profile.spells[spellID] = BigDebuffs.db.profile.spells[spellID] or {}
BigDebuffs.db.profile.spells[spellID][name] = value*100
BigDebuffs:Refresh()
end,
disabled = function() return not BigDebuffs.db.profile.spells[spellID] or
not BigDebuffs.db.profile.spells[spellID].customSize end,
min = 0,
max = 1,
step = 0.01,
order = 5,
},
},
} or nil,
duration = isCustom and {
order = 6,
type = "input",
name = L["Duration"],
desc = L["Override the icon timer duration in seconds (leave empty to use the spell default)"],
get = function()
local c = BigDebuffs.db.profile.customSpells[spellID]
return (c and c.duration) and tostring(c.duration) or ""
end,
set = function(_, value)
local c = BigDebuffs.db.profile.customSpells[spellID]
if c then
local n = tonumber(value)
c.duration = (n and n > 0) and n or nil
end
BigDebuffs:BuildSpellList()
BigDebuffs:Refresh()
end,
validate = function(_, value)
if value == "" or tonumber(value) then return true end
return L["Please enter a number"]
end,
} or nil,
remove = isCustom and {
order = 7,
type = "execute",
name = L["Remove Spell"],
desc = L["Remove this custom spell"],
width = "full",
confirm = true,
func = function()
BigDebuffs.db.profile.customSpells[spellID] = nil
BigDebuffs.db.profile.spells[spellID] = nil
BigDebuffs:BuildSpellList()
BigDebuffs:RefreshSpellOptions()
BigDebuffs:Refresh()
end,
} or nil,
},
}
end
-- Pending values for the "add custom spell" form
local pendingID
local pendingType = "cc"
-- Returns nil if the pending ID can be added, or an explanatory message if
-- not (blank field, no such spell, or already tracked - and where).
local function GetPendingSpellIssue()
if not pendingID then return nil end
if not GetSpellName(pendingID) then
return L["No spell exists with that ID"]
end
local existing = BigDebuffs.Spells[pendingID]
if existing then
local catName = L[existing.type] or existing.type
return L["Already tracked"].." ("..catName.."). "..L["Edit its category card above instead of adding it again."]
end
return nil
end
local function IsPendingSpellValid()
return pendingID ~= nil and GetPendingSpellIssue() == nil
end
-- The currently rendered "Add Spell" exec option and status label (rebuilt
-- fresh by BuildSpellOptions on every panel refresh), kept so
-- SyncAddSpellForm can find the matching live widgets below.
local currentAddExecOption
local currentAddStatusOption
-- The Spell ID field commits on every keystroke without forcing a panel
-- refresh (see BigDebuffsLiveEditBox above), so the Add Spell button's
-- disabled state and the status message - normally only re-checked on a
-- full redraw - would go stale while typing. Update them directly on the
-- live widgets instead.
local function SyncAddSpellForm()
local issue = GetPendingSpellIssue()
local disabled = pendingID == nil or issue ~= nil
local AceGUI = LibStub("AceGUI-3.0")
if currentAddExecOption then
for i = 1, AceGUI:GetWidgetCount("BigDebuffsAlignedButton") do
local frame = _G["AceGUI30BigDebuffsAlignedButton"..i]
if frame and frame.obj and frame:IsVisible() then
local user = frame.obj:GetUserDataTable()
if user and user.option == currentAddExecOption then
frame.obj:SetDisabled(disabled)
end
end
end
end
if currentAddStatusOption then
for i = 1, AceGUI:GetWidgetCount("BigDebuffsStatusLabel") do
local frame = _G["AceGUI30BigDebuffsStatusLabel"..i]
if frame and frame.obj and frame:IsVisible() then
local user = frame.obj:GetUserDataTable()
if user and user.option == currentAddStatusOption then
frame.obj:SetText(issue)
end
end
end
end
end
-- Tracks whether the Custom Spells tab title is currently drawn highlighted
-- (green) so the tab bar can be refreshed when the selection changes
-- (see the tab colour sync below)
local customTabHighlighted = true
local tabSyncPending = false
-- Assemble the whole Spells tab: presets grouped by their (effective) category,
-- plus a Custom Spells page for adding, editing and removing user spells.
function BigDebuffs:BuildSpellOptions()
local groups = {}
for spellID, spell in pairs(BigDebuffs.Spells) do
if not spell.parent and not spell.custom then
local t = spell.type
groups[t] = groups[t] or {
name = L[t] or t,
type = "group",
order = order[t] or 50,
args = {},
}
groups[t].args["spell"..spellID] = BuildSpellCard(spellID, spell, false)
end
end
local custom = {
name = function()
local status = LibStub("AceConfigDialog-3.0"):GetStatusTable("BigDebuffs", { "spells" })
local selected = status and status.groups and status.groups.selected
customTabHighlighted = selected ~= "custom"
if customTabHighlighted then
return "|cff20ff20"..L["Custom Spells"].."|r"
end
return L["Custom Spells"]
end,
type = "group",
order = 100,
args = {
add = {
order = 1,
type = "group",
inline = true,
name = L["Add Custom Spell"],
args = {
desc = {
order = 0,
type = "description",
name = L["Add a spell by its ID and assign it a category. Use this to track debuffs the presets are missing."].."\n",
},
id = {
order = 1,
type = "input",
dialogControl = "BigDebuffsLiveEditBox",
name = L["Spell ID"],
get = function() return pendingID and tostring(pendingID) or "" end,
set = function(_, value)
pendingID = tonumber(value)
SyncAddSpellForm()
end,
validate = function(_, value)
local n = tonumber(value)
if not n then return L["Please enter a number"] end
if not GetSpellName(n) then return L["No spell exists with that ID"] end
if BigDebuffs.Spells[n] then return L["That spell is already tracked"] end
return true
end,
},
category = {
order = 2,
type = "select",
name = L["Category"],
values = categoryValues,
sorting = categorySorting,
get = function() return pendingType end,
set = function(_, value) pendingType = value end,
},
exec = {
order = 3,
type = "execute",
dialogControl = "BigDebuffsAlignedButton",
name = L["Add Spell"],
disabled = function() return not IsPendingSpellValid() end,
func = function()
if not IsPendingSpellValid() then return end
BigDebuffs.db.profile.customSpells[pendingID] = { type = pendingType or "cc" }
pendingID = nil
BigDebuffs:BuildSpellList()
BigDebuffs:RefreshSpellOptions()
BigDebuffs:Refresh()
end,
},
status = {
order = 4,
type = "description",
dialogControl = "BigDebuffsStatusLabel",
name = function() return GetPendingSpellIssue() or "" end,
},
},
},
noneDesc = {
order = 2,
type = "description",
name = L["No custom spells added yet."],
hidden = function() return next(BigDebuffs.db.profile.customSpells) ~= nil end,
},
},
}
currentAddExecOption = custom.args.add.args.exec
currentAddStatusOption = custom.args.add.args.status
for spellID in pairs(BigDebuffs.db.profile.customSpells) do
local spell = BigDebuffs.Spells[spellID]
if spell then
custom.args["custom"..spellID] = BuildSpellCard(spellID, spell, true)
end
end
groups.custom = custom
groups.importexport = BigDebuffs:GetImportExportOptions()
-- Keep the Custom Spells tab title highlighted while it is not the active
-- sub-tab. The tab bar is only rebuilt on a full panel refresh, not when a
-- sub-tab is clicked, so every sub-tab carries a hidden checker that requests
-- a refresh when the drawn colour no longer matches the current selection.
for key, group in pairs(groups) do
group.args._tabColorSync = {
order = -1000,
type = "description",
name = "",
hidden = function()
local shouldHighlight = key ~= "custom"
if customTabHighlighted ~= shouldHighlight and not tabSyncPending then
tabSyncPending = true
C_Timer.After(0, function()
tabSyncPending = false
LibStub("AceConfigRegistry-3.0"):NotifyChange("BigDebuffs")
end)
end
return true
end,
}
end
return groups
end
-- Rebuild the Spells tab in place and refresh the open panel
function BigDebuffs:RefreshSpellOptions()
if not self.options then return end
self.options.args.spells.args = self:BuildSpellOptions()
LibStub("AceConfigRegistry-3.0"):NotifyChange("BigDebuffs")
end
function BigDebuffs:SetupOptions()
self.options = {
name = "BigDebuffs",
descStyle = "inline",
type = "group",
plugins = {},
childGroups = "tab",
args = {
vers = {
order = 1,
type = "description",
name = "|cffffd700"..L["Version"].."|r "..GetAddOnMetadata("BigDebuffs", "Version").."\n",
cmdHidden = true
},
desc = {
order = 2,
type = "description",
name = "|cffffd700 "..L["Author"].."|r Jordon\n",
cmdHidden = true
},
test = {
type = "execute",
name = L["Toggle Test Mode"],
order = 3,
func = "Test",
handler = BigDebuffs,
},
raidFrames = {
name = L["Raid Frames"],
type = "group",
disabled = function(info) return info[2] and not self.db.profile[info[1]].enabled end,
order = 10,
get = function(info) local name = info[#info] return self.db.profile.raidFrames[name] end,
set = function(info, value)
local name = info[#info]
self.db.profile.raidFrames[name] = value
self:Refresh()
end,
args = {
enabled = {
type = "toggle",
width = "normal",
disabled = false,
name = L["Enabled"],
desc = L["Enable BigDebuffs on raid frames"],
order = 1,
},
hideBliz = {
type = "toggle",
width = "normal",
name = L["Hide Other Debuffs"],
hidden = function() return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE end,
set = function(info, value)
if value then
self.db.profile.raidFrames.redirectBliz = false
end
self.db.profile.raidFrames.hideBliz = value
self:Refresh()
end,
desc = L["Hides other debuffs when BigDebuffs are displayed"],
order = 2,
},
redirectBliz = {
type = "toggle",
width = "normal",
name = L["Redirect Other Debuffs"],
hidden = function() return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE end,
set = function(info, value)
if value then
self.db.profile.raidFrames.hideBliz = false
end
self.db.profile.raidFrames.redirectBliz = value
self:Refresh()
end,
desc = L["Redirects other debuffs to the BigDebuffs anchor"],
order = 3,
},
showAllClassBuffs = {
type = "toggle",
width = "normal",
name = L["Show All Class Buffs"],
desc = L["Show all the buffs our class can apply"],
hidden = function() return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE end,
order = 4,
},
increaseBuffs = {
type = "toggle",
width = "normal",
name = L["Increase Maximum Buffs"],
desc = L["Sets the maximum buffs to 6"],
hidden = function() return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE end,
order = 5,
},
cooldownCount = {
type = "toggle",
width = "normal",
name = L["Cooldown Count"],
desc = L["Allow Blizzard and other addons to display countdown text on the icons"],
order = 6,
},
cooldownFont = {
type = "select",
name = L["Font"],
desc = L["Select font for cd timers"],
order = 7,
values = function()
local fonts, newFonts = LibSharedMedia:List("font"), {}
for k, v in pairs(fonts) do
newFonts[v] = v
end
return newFonts
end,
},
cooldownFontSize = {
type = "range",
name = L["Font Size"],
desc = L["Set the cd timers font size"],
min = 1,
max = 30,
step = 1,
order = 8,
},
cooldownFontEffect = {
type = "select",
name = L["Font Effect"],
desc = L["Set the cd timers font effect"],
values = {
["MONOCHROME"] = "MONOCHROME",
["OUTLINE"] = "OUTLINE",
["THICKOUTLINE"] = "THICKOUTLINE",
[""] = "NONE",
},
order = 9,
},
maxDebuffs = {
type = "range",
name = L["Max Debuffs"],
desc = L["Set the maximum number of debuffs displayed"],
min = 1,
max = 20,
step = 1,
order = 10,
},
wrapAt = {
type = "range",
name = L["Wrap After"],
desc = L["Begin a new row or column after this many debuffs"],
min = 0,
max = 10,
step = 1,
order = 11,
},
anchor = {
name = L["Anchor"],