-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionsUI.lua
More file actions
811 lines (687 loc) · 35.1 KB
/
OptionsUI.lua
File metadata and controls
811 lines (687 loc) · 35.1 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
local addonName, addon = ...
local function ClearChildren(frame)
if not frame then return end
local children = {frame:GetChildren()}
for i = 1, #children do
children[i]:Hide()
children[i]:SetParent(UIParent)
end
end
local function FormatClassName(className)
if not className then return "" end
if LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[className] then
return LOCALIZED_CLASS_NAMES_MALE[className]
end
local lower = className:lower()
return lower:gsub("^%l", string.upper)
end
-- ═══ Color Dropdown Helper ═══
local colorDropdownCounter = 0
function addon.CreateColorDropdown(parent, anchorFrame, anchorPoint, xOff, yOff, selectedKey, onSelect)
colorDropdownCounter = colorDropdownCounter + 1
local name = "CooldownGlowsColorDD" .. colorDropdownCounter
local dd = CreateFrame("Frame", name, parent, "UIDropDownMenuTemplate")
dd:SetPoint(anchorPoint or "LEFT", anchorFrame, "RIGHT", xOff or 6, yOff or 0)
UIDropDownMenu_SetWidth(dd, 80)
local function UpdateText(key)
local entry = addon.GLOW_COLOR_MAP[key or "default"]
if entry and entry.color then
local r, g, b = entry.color[1], entry.color[2], entry.color[3]
UIDropDownMenu_SetText(dd, string.format("|cff%02x%02x%02x%s|r", r*255, g*255, b*255, entry.name))
else
UIDropDownMenu_SetText(dd, "Default")
end
end
UpdateText(selectedKey)
UIDropDownMenu_Initialize(dd, function()
for _, colorEntry in ipairs(addon.GLOW_COLORS) do
local info = UIDropDownMenu_CreateInfo()
if colorEntry.color then
local r, g, b = colorEntry.color[1], colorEntry.color[2], colorEntry.color[3]
info.text = string.format("|cff%02x%02x%02x%s|r", r*255, g*255, b*255, colorEntry.name)
else
info.text = colorEntry.name
end
info.value = colorEntry.key
info.notCheckable = true
info.func = function()
dd.selectedKey = colorEntry.key
UpdateText(colorEntry.key)
CloseDropDownMenus()
if onSelect then onSelect(colorEntry.key) end
end
UIDropDownMenu_AddButton(info)
end
end)
dd.selectedKey = selectedKey or "default"
return dd
end
-- ═══ Color Swatch for Tracked List ═══
local function CreateColorSwatch(parent, anchorTo, colorKey)
local swatch = CreateFrame("Frame", nil, anchorTo)
local isDefault = (colorKey == nil or colorKey == "default")
local entry = addon.GLOW_COLOR_MAP[colorKey or "default"]
if isDefault then
swatch:SetSize(40, 14)
local text = swatch:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
text:SetPoint("LEFT", 0, 0)
text:SetText("Default")
swatch:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("Color: Default", 1, 1, 1)
GameTooltip:Show()
end)
else
swatch:SetSize(14, 14)
local tex = swatch:CreateTexture(nil, "OVERLAY")
tex:SetAllPoints()
if entry and entry.color then
tex:SetColorTexture(entry.color[1], entry.color[2], entry.color[3], 1)
else
tex:SetColorTexture(1, 1, 1, 1) -- White fallback
end
swatch:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
local name = entry and entry.name or "Unknown"
GameTooltip:SetText("Color: " .. name, 1, 1, 1)
GameTooltip:Show()
end)
end
swatch:SetScript("OnLeave", function() GameTooltip:Hide() end)
return swatch
end
-- ═══════════════════════════════════════════
-- PROFILE CONTENT BUILDER
-- ═══════════════════════════════════════════
local function BuildProfileContent(container, profileKey)
local targetProfile = CooldownGlowsDB[profileKey]
if not targetProfile then return end
local isCurrentPlayer = (profileKey == addon.Class or profileKey == addon.CharKey)
-- ═══ REFRESH TRACKED LIST ═══
local function RefreshTrackedList()
if container.spellContent then ClearChildren(container.spellContent) end
if container.itemContent then ClearChildren(container.itemContent) end
local profile = CooldownGlowsDB[profileKey]
if not profile then return end
-- Render Spells
local spellYOffset = -5
if profile.spells and next(profile.spells) then
local sortedSpells = {}
for spellID, entry in pairs(profile.spells) do
local info = C_Spell.GetSpellInfo(spellID)
table.insert(sortedSpells, {
id = spellID,
duration = addon.GetEntryDuration(entry),
color = addon.GetEntryColor(entry),
button = entry.button,
name = info and info.name or ("Spell " .. spellID),
icon = info and info.iconID or 134400
})
end
table.sort(sortedSpells, function(a, b) return a.name < b.name end)
for _, spell in ipairs(sortedSpells) do
local isActuallyKnown = addon.IsSpellTrackable(spell.id)
if not isCurrentPlayer then isActuallyKnown = true end
local row = CreateFrame("Frame", nil, container.spellContent)
row:SetSize(540, 26)
row:SetPoint("TOPLEFT", 0, spellYOffset)
local highlight = row:CreateTexture(nil, "HIGHLIGHT")
highlight:SetAllPoints()
highlight:SetColorTexture(1, 1, 1, 0.05)
local colorHex = "|cffffffff"
if not isActuallyKnown then colorHex = "|cff666666" end
local nameText = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
nameText:SetPoint("LEFT", 8, 0)
nameText:SetWidth(170)
nameText:SetJustifyH("LEFT")
nameText:SetText(string.format("|T%s:14:14:0:0|t %s%s|r", spell.icon, colorHex, spell.name))
local idText = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
idText:SetPoint("LEFT", nameText, "RIGHT", 5, 0)
idText:SetWidth(55)
idText:SetJustifyH("CENTER")
idText:SetText(string.format("%s%s|r", colorHex, tostring(spell.id)))
local btnText = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
btnText:SetPoint("LEFT", idText, "RIGHT", 5, 0)
btnText:SetWidth(145)
btnText:SetJustifyH("CENTER")
local targetDisplay = spell.button and spell.button or "Missing"
local targetColor = spell.button and colorHex or "|cffff3333"
btnText:SetText(string.format("%s%s|r", targetColor, targetDisplay))
local durText = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
durText:SetPoint("LEFT", btnText, "RIGHT", 5, 0)
durText:SetWidth(35)
durText:SetJustifyH("CENTER")
durText:SetText(string.format("%s%ss|r", colorHex, spell.duration))
local swatch = CreateColorSwatch(container, row, spell.color)
swatch:SetPoint("LEFT", durText, "RIGHT", 8, 0)
local removeBtn = CreateFrame("Button", nil, row)
removeBtn:SetPoint("RIGHT", -5, 0)
removeBtn:SetSize(16, 16)
local editBtn = CreateFrame("Button", nil, row)
editBtn:SetPoint("RIGHT", removeBtn, "LEFT", -5, 0)
editBtn:SetSize(16, 16)
editBtn:SetNormalTexture("Interface\\Buttons\\UI-OptionsButton")
editBtn:SetHighlightTexture("Interface\\Buttons\\UI-OptionsButton", "ADD")
editBtn:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("Edit spell", 1, 1, 1)
GameTooltip:Show()
end)
editBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
editBtn:SetScript("OnClick", function()
addon.ShowSpellHelper(container, profileKey, true)
local h = addon.SpellHelperFrame
if h then
h.isEditing = true
h.idInput:SetText(tostring(spell.id))
h.durInput:SetText(tostring(spell.duration))
h.btnFrameDD.selectedValue = spell.button
UIDropDownMenu_SetText(h.btnFrameDD, spell.button or "")
h.colorDD.selectedKey = spell.color
local entry = addon.GLOW_COLOR_MAP[spell.color or "default"]
if entry and entry.color then
local r, g, b = entry.color[1], entry.color[2], entry.color[3]
UIDropDownMenu_SetText(h.colorDD, string.format("|cff%02x%02x%02x%s|r", r*255, g*255, b*255, entry.name))
else
UIDropDownMenu_SetText(h.colorDD, "Default")
end
h.addBtn:SetText("Save Spell")
h.UpdateSpellPreview(tostring(spell.id))
end
end)
removeBtn:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Up")
removeBtn:SetHighlightTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Highlight")
removeBtn:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("Remove spell", 1, 0.2, 0.2)
GameTooltip:Show()
end)
removeBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
removeBtn:SetScript("OnClick", function()
profile.spells[spell.id] = nil
RefreshTrackedList()
if isCurrentPlayer then
if addon.UpdateTrackableSpells then addon.UpdateTrackableSpells() end
addon.CheckCooldowns()
end
end)
spellYOffset = spellYOffset - 26
end
end
if container.spellContent then container.spellContent:SetHeight(math.abs(spellYOffset) + 5) end
if container.spellEmpty then
if profile.spells and next(profile.spells) then container.spellEmpty:Hide() else container.spellEmpty:Show() end
end
-- Render Items
local itemYOffset = -5
if profile.items and next(profile.items) then
local sortedItems = {}
for itemID, entry in pairs(profile.items) do
local name, _, _, _, _, _, _, _, _, icon = C_Item.GetItemInfo(itemID)
table.insert(sortedItems, {
id = itemID,
duration = addon.GetEntryDuration(entry),
color = addon.GetEntryColor(entry),
button = entry.button,
name = name or ("Item " .. itemID),
icon = icon or 134400
})
end
table.sort(sortedItems, function(a, b) return a.name < b.name end)
for _, item in ipairs(sortedItems) do
local row = CreateFrame("Frame", nil, container.itemContent)
row:SetSize(540, 24)
row:SetPoint("TOPLEFT", 0, itemYOffset)
local colorHex = "|cffccaa00"
local nameText = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
nameText:SetPoint("LEFT", 8, 0)
nameText:SetWidth(170)
nameText:SetJustifyH("LEFT")
nameText:SetText(string.format("|T%s:14:14:0:0|t %s%s|r", item.icon, colorHex, item.name))
local idText = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
idText:SetPoint("LEFT", nameText, "RIGHT", 5, 0)
idText:SetWidth(55)
idText:SetJustifyH("CENTER")
idText:SetText(string.format("%s%s|r", colorHex, tostring(item.id)))
local btnText = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
btnText:SetPoint("LEFT", idText, "RIGHT", 5, 0)
btnText:SetWidth(145)
btnText:SetJustifyH("CENTER")
local targetDisplay = item.button and item.button or "Missing"
local targetColor = item.button and colorHex or "|cffff3333"
btnText:SetText(string.format("%s%s|r", targetColor, targetDisplay))
local durText = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
durText:SetPoint("LEFT", btnText, "RIGHT", 5, 0)
durText:SetWidth(35)
durText:SetJustifyH("CENTER")
durText:SetText(string.format("%s%ss|r", colorHex, item.duration))
local swatch = CreateColorSwatch(container, row, item.color)
swatch:SetPoint("LEFT", durText, "RIGHT", 8, 0)
local removeBtn = CreateFrame("Button", nil, row)
removeBtn:SetPoint("RIGHT", -5, 0)
removeBtn:SetSize(16, 16)
local editBtn = CreateFrame("Button", nil, row)
editBtn:SetPoint("RIGHT", removeBtn, "LEFT", -5, 0)
editBtn:SetSize(16, 16)
editBtn:SetNormalTexture("Interface\\Buttons\\UI-OptionsButton")
editBtn:SetHighlightTexture("Interface\\Buttons\\UI-OptionsButton", "ADD")
editBtn:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("Edit item", 1, 1, 1)
GameTooltip:Show()
end)
editBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
editBtn:SetScript("OnClick", function()
addon.ShowItemHelper(container, profileKey, true)
local h = addon.ItemHelperFrame
if h then
h.isEditing = true
h.idInput:SetText(tostring(item.id))
h.durInput:SetText(tostring(item.duration))
h.btnFrameDD.selectedValue = item.button
UIDropDownMenu_SetText(h.btnFrameDD, item.button or "")
h.colorDD.selectedKey = item.color
local entry = addon.GLOW_COLOR_MAP[item.color or "default"]
if entry and entry.color then
local r, g, b = entry.color[1], entry.color[2], entry.color[3]
UIDropDownMenu_SetText(h.colorDD, string.format("|cff%02x%02x%02x%s|r", r*255, g*255, b*255, entry.name))
else
UIDropDownMenu_SetText(h.colorDD, "Default")
end
h.addBtn:SetText("Save Item")
h.UpdateItemPreview(tostring(item.id))
end
end)
removeBtn:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Up")
removeBtn:SetHighlightTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Highlight")
removeBtn:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("Remove item", 1, 0.2, 0.2)
GameTooltip:Show()
end)
removeBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
removeBtn:SetScript("OnClick", function()
profile.items[item.id] = nil
RefreshTrackedList()
if isCurrentPlayer then
addon.CheckItemCooldowns()
end
end)
itemYOffset = itemYOffset - 26
end
end
if container.itemContent then container.itemContent:SetHeight(math.abs(itemYOffset) + 5) end
if container.itemEmpty then
if profile.items and next(profile.items) then container.itemEmpty:Hide() else container.itemEmpty:Show() end
end
end
container.RefreshTrackedList = RefreshTrackedList
-- ═══ HEADERS AND FRAMES ═══
-- ** Spells Section **
local spellTitle = container:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
spellTitle:SetPoint("TOPLEFT", 5, -5)
spellTitle:SetText("Spells")
local addSpellBtn = CreateFrame("Button", nil, container, "UIPanelButtonTemplate")
addSpellBtn:SetSize(120, 24)
addSpellBtn:SetPoint("RIGHT", container, "TOPRIGHT", -16, -2)
addSpellBtn:SetText("Add Spell")
addSpellBtn:SetScript("OnClick", function()
addon.ShowSpellHelper(container, profileKey)
end)
local spellSep = container:CreateTexture(nil, "ARTWORK")
spellSep:SetHeight(1)
spellSep:SetPoint("TOPLEFT", spellTitle, "BOTTOMLEFT", 0, -10)
spellSep:SetPoint("RIGHT", container, "RIGHT", -16, 0)
spellSep:SetColorTexture(0.4, 0.4, 0.4, 0.4)
local spellColName = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
spellColName:SetPoint("TOPLEFT", spellSep, "BOTTOMLEFT", 10, -6)
spellColName:SetText("|cffccccccName|r")
local spellColID = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
spellColID:SetPoint("LEFT", spellColName, "LEFT", 175, 0)
spellColID:SetText("|cffccccccID|r")
local spellColBtn = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
spellColBtn:SetPoint("LEFT", spellColID, "LEFT", 60, 0)
spellColBtn:SetText("|cffccccccTarget|r")
local spellColDur = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
spellColDur:SetPoint("LEFT", spellColBtn, "LEFT", 150, 0)
spellColDur:SetText("|cffccccccDur.|r")
local spellColColor = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
spellColColor:SetPoint("LEFT", spellColDur, "LEFT", 40, 0)
spellColColor:SetText("|cffccccccColor|r")
local spellColAction = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
spellColAction:SetPoint("RIGHT", spellSep, "RIGHT", -22, -6)
spellColAction:SetText("|cffccccccAction|r")
local spellColSep = container:CreateTexture(nil, "ARTWORK")
spellColSep:SetHeight(1)
spellColSep:SetPoint("TOPLEFT", spellColName, "BOTTOMLEFT", -5, -3)
spellColSep:SetPoint("RIGHT", container, "RIGHT", -16, 0)
spellColSep:SetColorTexture(0.3, 0.3, 0.3, 0.5)
local spellInset = CreateFrame("Frame", nil, container, "InsetFrameTemplate")
spellInset:SetPoint("TOPLEFT", spellColSep, "BOTTOMLEFT", -5, -2)
spellInset:SetPoint("RIGHT", container, "RIGHT", -16, 0)
spellInset:SetHeight(190)
local spellScroll = CreateFrame("ScrollFrame", nil, container, "UIPanelScrollFrameTemplate")
spellScroll:SetPoint("TOPLEFT", spellInset, "TOPLEFT", 5, -5)
spellScroll:SetPoint("BOTTOMRIGHT", spellInset, "BOTTOMRIGHT", -25, 5)
container.spellContent = CreateFrame("Frame", nil, spellScroll)
container.spellContent:SetSize(540, 10)
spellScroll:SetScrollChild(container.spellContent)
container.spellEmpty = spellInset:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
container.spellEmpty:SetPoint("CENTER", 0, 0)
container.spellEmpty:SetText("|cff666666No spells tracked.|r")
container.spellEmpty:Hide()
-- ** Items Section **
local itemTitle = container:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
itemTitle:SetPoint("TOPLEFT", spellInset, "BOTTOMLEFT", 5, -15)
itemTitle:SetText("Items")
local addItemBtn = CreateFrame("Button", nil, container, "UIPanelButtonTemplate")
addItemBtn:SetSize(120, 24)
addItemBtn:SetPoint("RIGHT", spellInset, "BOTTOMRIGHT", 0, -25)
addItemBtn:SetText("Add Item")
addItemBtn:SetScript("OnClick", function()
addon.ShowItemHelper(container, profileKey)
end)
local itemSep = container:CreateTexture(nil, "ARTWORK")
itemSep:SetHeight(1)
itemSep:SetPoint("TOPLEFT", itemTitle, "BOTTOMLEFT", -5, -10)
itemSep:SetPoint("RIGHT", container, "RIGHT", -16, 0)
itemSep:SetColorTexture(0.4, 0.4, 0.4, 0.4)
local itemColName = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
itemColName:SetPoint("TOPLEFT", itemSep, "BOTTOMLEFT", 10, -6)
itemColName:SetText("|cffccccccName|r")
local itemColID = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
itemColID:SetPoint("LEFT", itemColName, "LEFT", 175, 0)
itemColID:SetText("|cffccccccID|r")
local itemColBtn = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
itemColBtn:SetPoint("LEFT", itemColID, "LEFT", 60, 0)
itemColBtn:SetText("|cffccccccTarget|r")
local itemColDur = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
itemColDur:SetPoint("LEFT", itemColBtn, "LEFT", 150, 0)
itemColDur:SetText("|cffccccccDur.|r")
local itemColColor = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
itemColColor:SetPoint("LEFT", itemColDur, "LEFT", 40, 0)
itemColColor:SetText("|cffccccccColor|r")
local itemColAction = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
itemColAction:SetPoint("RIGHT", itemSep, "RIGHT", -22, -6)
itemColAction:SetText("|cffccccccAction|r")
local itemColSep = container:CreateTexture(nil, "ARTWORK")
itemColSep:SetHeight(1)
itemColSep:SetPoint("TOPLEFT", itemColName, "BOTTOMLEFT", -5, -3)
itemColSep:SetPoint("RIGHT", container, "RIGHT", -16, 0)
itemColSep:SetColorTexture(0.3, 0.3, 0.3, 0.5)
local itemInset = CreateFrame("Frame", nil, container, "InsetFrameTemplate")
itemInset:SetPoint("TOPLEFT", itemColSep, "BOTTOMLEFT", -5, -2)
itemInset:SetPoint("BOTTOMRIGHT", container, "BOTTOMRIGHT", -16, 0)
local itemScroll = CreateFrame("ScrollFrame", nil, container, "UIPanelScrollFrameTemplate")
itemScroll:SetPoint("TOPLEFT", itemInset, "TOPLEFT", 5, -5)
itemScroll:SetPoint("BOTTOMRIGHT", itemInset, "BOTTOMRIGHT", -25, 5)
container.itemContent = CreateFrame("Frame", nil, itemScroll)
container.itemContent:SetSize(540, 10)
itemScroll:SetScrollChild(container.itemContent)
container.itemEmpty = itemInset:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
container.itemEmpty:SetPoint("CENTER", 0, 0)
container.itemEmpty:SetText("|cff666666No items tracked.|r")
container.itemEmpty:Hide()
end
-- ═══════════════════════════════════════════
-- MAIN OPTIONS FRAME
-- ═══════════════════════════════════════════
function addon.CreateOptionsFrames()
local f = CreateFrame("Frame", "CooldownGlowsOptionsFrame", UIParent)
f.name = "CooldownGlows"
addon.OptionsFrame = f
-- Title
local title = f:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText("CooldownGlows")
-- ═══ TAB BUTTONS ═══
local TAB_GENERAL = 1
local TAB_CLASS = 2
local TAB_CHAR = 3
local activeTab = TAB_GENERAL
local tabButtons = {}
local tabContainers = {}
local function CreateTab(parent, id, label, xOffset)
local tab = CreateFrame("Button", "CooldownGlowsTab" .. id, parent)
tab:SetSize(140, 28)
tab:SetPoint("TOPLEFT", title, "BOTTOMLEFT", xOffset, -10)
local bg = tab:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0.15, 0.15, 0.15, 0.8)
tab.bg = bg
local border = tab:CreateTexture(nil, "BORDER")
border:SetPoint("BOTTOMLEFT")
border:SetPoint("BOTTOMRIGHT")
border:SetHeight(2)
border:SetColorTexture(0.8, 0.6, 0, 1)
border:Hide()
tab.border = border
local text = tab:CreateFontString(nil, "OVERLAY", "GameFontNormal")
text:SetPoint("CENTER", 0, 0)
text:SetText(label)
tab.text = text
tab:SetScript("OnEnter", function(self)
if activeTab ~= id then
self.bg:SetColorTexture(0.25, 0.25, 0.25, 0.8)
end
end)
tab:SetScript("OnLeave", function(self)
if activeTab ~= id then
self.bg:SetColorTexture(0.15, 0.15, 0.15, 0.8)
end
end)
tabButtons[id] = tab
return tab
end
local function SetActiveTab(id)
activeTab = id
for tabId, btn in pairs(tabButtons) do
if tabId == id then
btn.bg:SetColorTexture(0.2, 0.2, 0.2, 1)
btn.border:Show()
btn.text:SetFontObject("GameFontHighlight")
else
btn.bg:SetColorTexture(0.15, 0.15, 0.15, 0.8)
btn.border:Hide()
btn.text:SetFontObject("GameFontNormal")
end
end
for tabId, container in pairs(tabContainers) do
if tabId == id then
container:Show()
else
container:Hide()
end
end
end
-- Create tab buttons
local classTabLabel = FormatClassName(addon.Class)
local charName = UnitName("player") or "Character"
local tabGeneral = CreateTab(f, TAB_GENERAL, "General", 0)
local tabClass = CreateTab(f, TAB_CLASS, classTabLabel, 145)
local tabChar = CreateTab(f, TAB_CHAR, charName, 290)
tabGeneral:SetScript("OnClick", function() SetActiveTab(TAB_GENERAL) end)
tabClass:SetScript("OnClick", function() SetActiveTab(TAB_CLASS) end)
tabChar:SetScript("OnClick", function() SetActiveTab(TAB_CHAR) end)
-- Active profile badges
local function UpdateTabBadges()
local classActive = addon.ProfileType == "class"
local charActive = addon.ProfileType == "char"
if classActive then
tabClass.text:SetText(classTabLabel .. " |cff00cc00(Active)|r")
else
tabClass.text:SetText(classTabLabel)
end
if charActive then
tabChar.text:SetText(charName .. " |cff00cc00(Active)|r")
else
tabChar.text:SetText(charName)
end
end
-- ═══ TAB CONTAINERS ═══
-- Separator under tabs
local tabSep = f:CreateTexture(nil, "ARTWORK")
tabSep:SetHeight(1)
tabSep:SetPoint("TOPLEFT", tabGeneral, "BOTTOMLEFT", 0, -2)
tabSep:SetPoint("RIGHT", f, "RIGHT", -16, 0)
tabSep:SetColorTexture(0.4, 0.4, 0.4, 0.6)
-- ─── GENERAL TAB ───
local generalContainer = CreateFrame("Frame", nil, f)
generalContainer:SetPoint("TOPLEFT", tabSep, "BOTTOMLEFT", 0, -12)
generalContainer:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -16, 10)
tabContainers[TAB_GENERAL] = generalContainer
local settingsHeader = generalContainer:CreateFontString(nil, "OVERLAY", "GameFontNormal")
settingsHeader:SetPoint("TOPLEFT", 0, 0)
settingsHeader:SetText("General Settings")
local combatOnlyCheckbox = CreateFrame("CheckButton", nil, generalContainer, "UICheckButtonTemplate")
combatOnlyCheckbox:SetPoint("TOPLEFT", settingsHeader, "BOTTOMLEFT", -2, -8)
combatOnlyCheckbox.text:SetText("Only glow during combat")
combatOnlyCheckbox.text:SetFontObject("GameFontHighlightSmall")
combatOnlyCheckbox:SetScript("OnClick", function(self)
if addon.Profile then
addon.Profile.combatOnly = self:GetChecked()
addon.CheckCooldowns()
end
end)
local debugCheckbox = CreateFrame("CheckButton", nil, generalContainer, "UICheckButtonTemplate")
debugCheckbox:SetPoint("TOPLEFT", combatOnlyCheckbox, "BOTTOMLEFT", 0, -4)
debugCheckbox.text:SetText("Enable debug logs")
debugCheckbox.text:SetFontObject("GameFontHighlightSmall")
debugCheckbox:SetScript("OnClick", function(self)
if addon.Profile then
addon.Profile.debug = self:GetChecked()
end
end)
-- Active profile info
local profileInfoSep = generalContainer:CreateTexture(nil, "ARTWORK")
profileInfoSep:SetHeight(1)
profileInfoSep:SetPoint("TOPLEFT", debugCheckbox, "BOTTOMLEFT", 2, -14)
profileInfoSep:SetPoint("RIGHT", generalContainer, "RIGHT", 0, 0)
profileInfoSep:SetColorTexture(0.4, 0.4, 0.4, 0.4)
local profileInfoHeader = generalContainer:CreateFontString(nil, "OVERLAY", "GameFontNormal")
profileInfoHeader:SetPoint("TOPLEFT", profileInfoSep, "BOTTOMLEFT", 0, -12)
profileInfoHeader:SetText("Active Profile")
local profileInfoText = generalContainer:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
profileInfoText:SetPoint("TOPLEFT", profileInfoHeader, "BOTTOMLEFT", 2, -6)
local function UpdateProfileInfo()
if addon.ProfileType == "char" then
local charDisplay = (UnitName("player") or "?") .. "-" .. (GetRealmName() or "?")
profileInfoText:SetText("|cff00cc00Character profile|r: " .. charDisplay .. "\n|cff888888Class profile is overridden.|r")
else
local cObj = C_ClassColor.GetClassColor(addon.Class)
local colorHex = cObj and cObj:GenerateHexColorMarkup() or "|cffffffff"
profileInfoText:SetText("|cff00cc00Class profile|r: " .. colorHex .. FormatClassName(addon.Class) .. "|r\n|cff888888No character profile exists.|r")
end
end
-- ─── CLASS PROFILE TAB ───
local classContainer = CreateFrame("Frame", nil, f)
classContainer:SetPoint("TOPLEFT", tabSep, "BOTTOMLEFT", 0, -12)
classContainer:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -16, 10)
classContainer:Hide()
tabContainers[TAB_CLASS] = classContainer
BuildProfileContent(classContainer, addon.Class)
-- ─── CHARACTER PROFILE TAB ───
local charContainer = CreateFrame("Frame", nil, f)
charContainer:SetPoint("TOPLEFT", tabSep, "BOTTOMLEFT", 0, -12)
charContainer:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -16, 10)
charContainer:Hide()
tabContainers[TAB_CHAR] = charContainer
-- Placeholder for when no char profile exists
local charEmptyPanel = CreateFrame("Frame", nil, charContainer)
charEmptyPanel:SetAllPoints()
local charEmptyText = charEmptyPanel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
charEmptyText:SetPoint("TOP", 0, -20)
charEmptyText:SetText("|cff888888No character profile exists for this character.|nCreate one to override the class profile.|r")
charEmptyText:SetJustifyH("CENTER")
local createCharBtn = CreateFrame("Button", nil, charEmptyPanel, "UIPanelButtonTemplate")
createCharBtn:SetSize(200, 28)
createCharBtn:SetPoint("TOP", charEmptyText, "BOTTOM", 0, -14)
createCharBtn:SetText("Create from Class Profile")
-- Active char profile panel
local charProfilePanel = CreateFrame("Frame", nil, charContainer)
charProfilePanel:SetAllPoints()
charProfilePanel:Hide()
local deleteCharBtn = CreateFrame("Button", nil, charContainer, "UIPanelButtonTemplate")
deleteCharBtn:SetSize(160, 22)
deleteCharBtn:SetPoint("TOPRIGHT", charContainer, "TOPRIGHT", 0, 0)
deleteCharBtn:SetText("Delete Char Profile")
deleteCharBtn:SetFrameLevel(charContainer:GetFrameLevel() + 10)
deleteCharBtn:Hide()
local function RefreshCharTab()
if CooldownGlowsDB[addon.CharKey] then
charEmptyPanel:Hide()
charProfilePanel:Show()
deleteCharBtn:Show()
-- Rebuild profile content
ClearChildren(charProfilePanel)
charProfilePanel.spellContent = nil
charProfilePanel.itemContent = nil
charProfilePanel.emptyText = nil
BuildProfileContent(charProfilePanel, addon.CharKey)
if charProfilePanel.RefreshTrackedList then
charProfilePanel.RefreshTrackedList()
end
else
charEmptyPanel:Show()
charProfilePanel:Hide()
deleteCharBtn:Hide()
end
UpdateTabBadges()
UpdateProfileInfo()
end
createCharBtn:SetScript("OnClick", function()
-- Copy class profile to char profile
CooldownGlowsDB[addon.CharKey] = CopyTable(CooldownGlowsDB[addon.Class])
addon.Profile = CooldownGlowsDB[addon.CharKey]
addon.ProfileType = "char"
-- Wipe stale glow states from old profile
wipe(addon.cdStates)
wipe(addon.itemCdStates)
for btn, timer in pairs(addon.activeTimers) do
timer:Cancel()
addon.HideGlow(btn)
end
wipe(addon.activeTimers)
RefreshCharTab()
addon.CheckCooldowns()
addon.CheckItemCooldowns()
end)
deleteCharBtn:SetScript("OnClick", function()
CooldownGlowsDB[addon.CharKey] = nil
addon.Profile = CooldownGlowsDB[addon.Class]
addon.ProfileType = "class"
-- Wipe stale glow states from old profile
wipe(addon.cdStates)
wipe(addon.itemCdStates)
for btn, timer in pairs(addon.activeTimers) do
timer:Cancel()
addon.HideGlow(btn)
end
wipe(addon.activeTimers)
RefreshCharTab()
addon.CheckCooldowns()
addon.CheckItemCooldowns()
end)
-- ═══ OnShow ═══
f:SetScript("OnShow", function()
if addon.Profile then
if addon.Profile.combatOnly == nil then addon.Profile.combatOnly = false end
combatOnlyCheckbox:SetChecked(addon.Profile.combatOnly)
debugCheckbox:SetChecked(addon.Profile.debug or false)
end
UpdateProfileInfo()
UpdateTabBadges()
-- Refresh class tab
if classContainer.RefreshTrackedList then
if addon.UpdateTrackableSpells then addon.UpdateTrackableSpells() end
classContainer.RefreshTrackedList()
end
-- Refresh char tab
RefreshCharTab()
SetActiveTab(activeTab)
end)
-- ═══ Register ═══
local mainCategory = Settings.RegisterCanvasLayoutCategory(f, "CooldownGlows")
Settings.RegisterAddOnCategory(mainCategory)
addon.category = mainCategory
end