-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.lua
More file actions
2015 lines (1815 loc) · 93.8 KB
/
Copy pathUI.lua
File metadata and controls
2015 lines (1815 loc) · 93.8 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 addonName, Addon = ...
local selectedClass
local selectedSpec
local selectedSpell
local selectedCustomSpell
local selectedVoice
local assignmentOffset = 0
local renameSelectedClass
local renameSelectedSpec
local renameSelectedSpell
local renameSelectedCustomSpell
local renameOffset = 0
local RENAME_ROW_COUNT = 8
local ROW_COUNT = 8
local selectedNoteKey
local selectedNoteVoice
local selectedNoteTTSMode = "default"
local selectedNoteCustomTTS = ""
local noteReminderOffset = 0
local NOTE_ROW_COUNT = 5
local selectedEncounterID
local selectedEncounterDifficulty = 16
local selectedEncounterAlertKey
local selectedEncounterVoice
local encounterAssignmentOffset = 0
local ENCOUNTER_ROW_COUNT = 8
local frame
local contentFrame
local sidebar
local abilityPage
local renamePage
local notePage
local encounterPage
local optionsPage
local activePageKey = "abilities"
local navButtons = {}
local classDropdown
local specDropdown
local abilityDropdown
local voiceDropdown
local channelDropdown
local statusText
local customSpellSelectionText
local renameClassDropdown
local renameSpecDropdown
local renameAbilityDropdown
local renameTextBox
local renameStatusText
local renameCustomSpellSelectionText
local noteVoiceDropdown
local noteTTSModeDropdown
local noteTTSCustomLabel
local noteTTSCustomTextBox
local noteStatusText
local noteSummaryText
local noteScrollText
local encounterDropdown
local encounterDifficultyDropdown
local encounterAlertDropdown
local encounterVoiceDropdown
local encounterStatusText
local helpFrame
local helpRequirementsText
local helpVoiceText
local mainCloseButton
local mainHelpButton
local assignmentRows = {}
local renameRows = {}
local noteRows = {}
local encounterAssignmentRows = {}
local themeCards = {}
local voicePopup
local voiceScrollFrame
local voiceScrollChild
local voiceRows = {}
local voicePreviewToken = 0
local voiceContext
local VOICE_ROW_HEIGHT = 26
local RefreshAssignments
local RefreshRenameOptions
local RefreshRenameRows
local RefreshNoteOptions
local RefreshNoteRows
local RefreshEncounterOptions
local ShowPage
local SetNavButtonSelected
local THEME_ORDER = { "arcane", "bronze", "cyan" }
local THEMES = {
arcane = {
name = "Muted Arcane",
description = "Muted gold headings with deep purple controls and soft neutral text.",
windowBackground = { 0, 0, 0, 1 },
windowBorder = { 0.42, 0.40, 0.42, 1 },
panelBorder = { 0.34, 0.25, 0.46, 1 },
divider = { 0.36, 0.28, 0.48, 0.85 },
controlBackground = { 0.085, 0.065, 0.105, 0.98 },
controlHover = { 0.12, 0.09, 0.15, 0.98 },
buttonBackground = { 0.070, 0.055, 0.090, 0.98 },
buttonHover = { 0.10, 0.08, 0.13, 0.98 },
accent = { 0.43, 0.32, 0.56, 1 },
heading = { 0.82, 0.67, 0.34, 1 },
text = { 0.93, 0.93, 0.96, 1 },
mutedText = { 0.75, 0.74, 0.79, 1 },
selectedBackground = { 0.20, 0.14, 0.045, 0.98 },
selectedText = { 0.88, 0.72, 0.39, 1 },
actionBackground = { 0.075, 0.060, 0.085, 0.98 },
actionHover = { 0.12, 0.09, 0.13, 0.98 },
actionBorder = { 0.76, 0.59, 0.25, 1 },
},
bronze = {
name = "Warm Bronze",
description = "Warm bronze controls with parchment-gold headings and restrained amber highlights.",
windowBackground = { 0.012, 0.010, 0.008, 1 },
windowBorder = { 0.40, 0.31, 0.18, 1 },
panelBorder = { 0.42, 0.30, 0.14, 1 },
divider = { 0.42, 0.30, 0.14, 0.85 },
controlBackground = { 0.13, 0.085, 0.025, 0.98 },
controlHover = { 0.18, 0.12, 0.04, 0.98 },
buttonBackground = { 0.105, 0.070, 0.025, 0.98 },
buttonHover = { 0.15, 0.10, 0.035, 0.98 },
accent = { 0.52, 0.34, 0.12, 1 },
heading = { 0.91, 0.73, 0.36, 1 },
text = { 0.94, 0.91, 0.83, 1 },
mutedText = { 0.78, 0.73, 0.63, 1 },
selectedBackground = { 0.24, 0.15, 0.035, 0.98 },
selectedText = { 0.95, 0.78, 0.40, 1 },
actionBackground = { 0.12, 0.075, 0.022, 0.98 },
actionHover = { 0.18, 0.115, 0.035, 0.98 },
actionBorder = { 0.76, 0.53, 0.18, 1 },
},
cyan = {
name = "Cool Cyan",
description = "Blue-grey controls with cool cyan headings and crisp high-contrast highlights.",
windowBackground = { 0.003, 0.012, 0.017, 1 },
windowBorder = { 0.18, 0.34, 0.40, 1 },
panelBorder = { 0.15, 0.39, 0.48, 1 },
divider = { 0.15, 0.39, 0.48, 0.85 },
controlBackground = { 0.045, 0.105, 0.135, 0.98 },
controlHover = { 0.065, 0.145, 0.18, 0.98 },
buttonBackground = { 0.035, 0.075, 0.095, 0.98 },
buttonHover = { 0.05, 0.11, 0.14, 0.98 },
accent = { 0.10, 0.66, 0.72, 1 },
heading = { 0.24, 0.82, 0.84, 1 },
text = { 0.91, 0.95, 0.97, 1 },
mutedText = { 0.68, 0.77, 0.82, 1 },
selectedBackground = { 0.035, 0.19, 0.23, 0.98 },
selectedText = { 0.28, 0.90, 0.91, 1 },
actionBackground = { 0.025, 0.095, 0.12, 0.98 },
actionHover = { 0.035, 0.14, 0.17, 0.98 },
actionBorder = { 0.13, 0.68, 0.73, 1 },
},
}
local themedButtons = {}
local themedDropdowns = {}
local themedActionButtons = {}
local themedDescriptors = {}
local themedHeadings = {}
local themedPanels = {}
local themedEditBoxes = {}
local themedRemoveButtons = {}
local ApplyTheme
local RefreshThemeCards
local function GetTheme()
local key = Addon.db and Addon.db.theme or "arcane"
return THEMES[key] or THEMES.arcane
end
local function SetTextureColor(texture, color)
texture:SetColorTexture(color[1], color[2], color[3], color[4] or 1)
end
local function SetFontColor(fontString, color)
if fontString and color then
fontString:SetTextColor(color[1], color[2], color[3], color[4] or 1)
end
end
local function RegisterHeading(fontString)
themedHeadings[#themedHeadings + 1] = fontString
SetFontColor(fontString, GetTheme().heading)
return fontString
end
local function RegisterPanel(panel)
themedPanels[#themedPanels + 1] = panel
if panel.SetBackdropBorderColor then
local color = GetTheme().panelBorder
panel:SetBackdropBorderColor(color[1], color[2], color[3], color[4])
end
return panel
end
local function SetControlBorders(control, color)
for _, border in ipairs({ control.borderTop, control.borderBottom, control.borderLeft, control.borderRight }) do
if border then SetTextureColor(border, color) end
end
end
local function CreateControlBorders(control, anchor)
control.borderTop = control:CreateTexture(nil, "ARTWORK")
control.borderBottom = control:CreateTexture(nil, "ARTWORK")
control.borderLeft = control:CreateTexture(nil, "ARTWORK")
control.borderRight = control:CreateTexture(nil, "ARTWORK")
control.borderTop:SetPoint("TOPLEFT", anchor, "TOPLEFT", 0, 0); control.borderTop:SetPoint("TOPRIGHT", anchor, "TOPRIGHT", 0, 0); control.borderTop:SetHeight(1)
control.borderBottom:SetPoint("BOTTOMLEFT", anchor, "BOTTOMLEFT", 0, 0); control.borderBottom:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 0, 0); control.borderBottom:SetHeight(1)
control.borderLeft:SetPoint("TOPLEFT", anchor, "TOPLEFT", 0, 0); control.borderLeft:SetPoint("BOTTOMLEFT", anchor, "BOTTOMLEFT", 0, 0); control.borderLeft:SetWidth(1)
control.borderRight:SetPoint("TOPRIGHT", anchor, "TOPRIGHT", 0, 0); control.borderRight:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 0, 0); control.borderRight:SetWidth(1)
end
local function StyleFlatButton(button, text, primary, selector)
if not button.flatBackground then
button.flatBackground = button:CreateTexture(nil, "BACKGROUND")
button.flatBackground:SetAllPoints()
CreateControlBorders(button, button.flatBackground)
button.flatLabel = button:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
button.flatLabel:SetPoint("LEFT", selector and 13 or 9, 0)
button.flatLabel:SetPoint("RIGHT", selector and -27 or -9, 0)
button.flatLabel:SetJustifyH(selector and "LEFT" or "CENTER")
button:SetFontString(button.flatLabel)
if selector then
button.flatArrow = button:CreateFontString(nil, "ARTWORK", "GameFontNormal")
button.flatArrow:SetPoint("RIGHT", -10, 0)
button.flatArrow:SetText("v")
end
button:SetScript("OnEnter", function(self)
local theme = GetTheme()
SetTextureColor(self.flatBackground, self.flatSelector and theme.controlHover or theme.buttonHover)
end)
button:SetScript("OnLeave", function(self)
local theme = GetTheme()
SetTextureColor(self.flatBackground, self.flatSelector and theme.controlBackground or theme.buttonBackground)
end)
themedButtons[#themedButtons + 1] = button
end
button.flatPrimary = primary and true or false
button.flatSelector = selector and true or false
local theme = GetTheme()
SetTextureColor(button.flatBackground, button.flatSelector and theme.controlBackground or theme.buttonBackground)
SetControlBorders(button, theme.accent)
SetFontColor(button.flatLabel, theme.text)
if button.flatArrow then SetFontColor(button.flatArrow, theme.heading) end
button:SetText(text or "")
return button
end
local function StyleActionButton(button, text)
if not button.actionBackground then
button.actionBackground = button:CreateTexture(nil, "BACKGROUND")
button.actionBackground:SetAllPoints()
button.actionTop = button:CreateTexture(nil, "ARTWORK")
button.actionBottom = button:CreateTexture(nil, "ARTWORK")
button.actionLeft = button:CreateTexture(nil, "ARTWORK")
button.actionRight = button:CreateTexture(nil, "ARTWORK")
button.actionTop:SetPoint("TOPLEFT", 0, 0); button.actionTop:SetPoint("TOPRIGHT", 0, 0); button.actionTop:SetHeight(1)
button.actionBottom:SetPoint("BOTTOMLEFT", 0, 0); button.actionBottom:SetPoint("BOTTOMRIGHT", 0, 0); button.actionBottom:SetHeight(1)
button.actionLeft:SetPoint("TOPLEFT", 0, 0); button.actionLeft:SetPoint("BOTTOMLEFT", 0, 0); button.actionLeft:SetWidth(1)
button.actionRight:SetPoint("TOPRIGHT", 0, 0); button.actionRight:SetPoint("BOTTOMRIGHT", 0, 0); button.actionRight:SetWidth(1)
button.actionLabel = button:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
button.actionLabel:SetPoint("CENTER")
button:SetFontString(button.actionLabel)
button:SetScript("OnEnter", function(self)
SetTextureColor(self.actionBackground, GetTheme().actionHover)
end)
button:SetScript("OnLeave", function(self)
SetTextureColor(self.actionBackground, GetTheme().actionBackground)
end)
themedActionButtons[#themedActionButtons + 1] = button
end
local theme = GetTheme()
SetTextureColor(button.actionBackground, theme.actionBackground)
for _, border in ipairs({ button.actionTop, button.actionBottom, button.actionLeft, button.actionRight }) do
SetTextureColor(border, theme.actionBorder)
end
SetFontColor(button.actionLabel, theme.heading)
button:SetText(text or "")
return button
end
local function StyleFlatDropdown(dropdown, width)
UIDropDownMenu_SetWidth(dropdown, width)
dropdown:SetSize(width + 36, 32)
for _, region in ipairs({ dropdown:GetRegions() }) do region:Hide() end
for _, child in ipairs({ dropdown:GetChildren() }) do child:Hide() end
dropdown.flatBackground = dropdown:CreateTexture(nil, "BACKGROUND")
dropdown.flatBackground:SetPoint("TOPLEFT", 18, -2)
dropdown.flatBackground:SetSize(width, 28)
CreateControlBorders(dropdown, dropdown.flatBackground)
dropdown.flatLabel = dropdown:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
dropdown.flatLabel:SetPoint("LEFT", dropdown.flatBackground, "LEFT", 13, 0)
dropdown.flatLabel:SetPoint("RIGHT", dropdown.flatBackground, "RIGHT", -28, 0)
dropdown.flatLabel:SetJustifyH("LEFT")
dropdown.flatArrow = dropdown:CreateFontString(nil, "ARTWORK", "GameFontNormal")
dropdown.flatArrow:SetPoint("RIGHT", dropdown.flatBackground, "RIGHT", -10, 0)
dropdown.flatArrow:SetText("v")
dropdown.flatButton = CreateFrame("Button", nil, dropdown)
dropdown.flatButton:SetAllPoints(dropdown.flatBackground)
dropdown.flatButton:SetScript("OnEnter", function() SetTextureColor(dropdown.flatBackground, GetTheme().controlHover) end)
dropdown.flatButton:SetScript("OnLeave", function() SetTextureColor(dropdown.flatBackground, GetTheme().controlBackground) end)
dropdown.flatButton:SetScript("OnClick", function()
ToggleDropDownMenu(1, nil, dropdown, dropdown, 18, -2)
end)
themedDropdowns[#themedDropdowns + 1] = dropdown
local theme = GetTheme()
SetTextureColor(dropdown.flatBackground, theme.controlBackground)
SetControlBorders(dropdown, theme.accent)
SetFontColor(dropdown.flatLabel, theme.text)
SetFontColor(dropdown.flatArrow, theme.heading)
end
local function SetDropdownText(dropdown, text)
if not dropdown then return end
local value = text or "Select..."
UIDropDownMenu_SetText(dropdown, value)
if dropdown.flatLabel then dropdown.flatLabel:SetText(value) end
end
local function CreateLabel(parent, text, x, y)
local label = parent:CreateFontString(nil, "ARTWORK", "GameFontNormal")
label:SetPoint("TOPLEFT", x, y)
label:SetText(text)
RegisterHeading(label)
return label
end
local function CreateButton(parent, text, width, x, y, onClick)
local button = CreateFrame("Button", nil, parent)
button:SetSize(width, 26)
button:SetPoint("TOPLEFT", x, y)
if text == "Assign" then
StyleActionButton(button, text)
else
StyleFlatButton(button, text, false, false)
end
button:SetScript("OnClick", onClick)
return button
end
local function StyleDescriptorText(fontString)
if not fontString.themeDescriptorRegistered then
fontString.themeDescriptorRegistered = true
themedDescriptors[#themedDescriptors + 1] = fontString
end
SetFontColor(fontString, GetTheme().mutedText)
return fontString
end
local function CreateRemoveIconButton(parent)
local button = CreateFrame("Button", nil, parent)
button:SetSize(20, 20)
button.bg = button:CreateTexture(nil, "BACKGROUND")
button.bg:SetAllPoints()
button.bg:SetColorTexture(0.14, 0.05, 0.05, 0.95)
button.x = button:CreateFontString(nil, "ARTWORK", "GameFontNormal")
button.x:SetPoint("CENTER", 0, 0)
button.x:SetText("X")
button.x:SetTextColor(1, 0.32, 0.32)
button:SetScript("OnEnter", function(self)
self.bg:SetColorTexture(0.20, 0.06, 0.06, 0.98)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("Remove")
GameTooltip:Show()
end)
button:SetScript("OnLeave", function(self)
self.bg:SetColorTexture(0.14, 0.05, 0.05, 0.95)
GameTooltip:Hide()
end)
themedRemoveButtons[#themedRemoveButtons + 1] = button
return button
end
local function StyleFlatEditBox(editBox)
editBox:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8X8",
edgeFile = "Interface\\Buttons\\WHITE8X8",
edgeSize = 1,
insets = { left = 1, right = 1, top = 1, bottom = 1 },
})
editBox:SetTextInsets(9, 9, 0, 0)
editBox:SetFontObject(GameFontHighlightSmall)
themedEditBoxes[#themedEditBoxes + 1] = editBox
local theme = GetTheme()
editBox:SetBackdropColor(theme.controlBackground[1], theme.controlBackground[2], theme.controlBackground[3], theme.controlBackground[4])
editBox:SetBackdropBorderColor(theme.accent[1], theme.accent[2], theme.accent[3], theme.accent[4])
editBox:SetTextColor(theme.text[1], theme.text[2], theme.text[3], theme.text[4])
end
ApplyTheme = function()
local theme = GetTheme()
for _, button in ipairs(themedButtons) do
SetTextureColor(button.flatBackground, button.flatSelector and theme.controlBackground or theme.buttonBackground)
SetControlBorders(button, theme.accent)
SetFontColor(button.flatLabel, theme.text)
if button.flatArrow then SetFontColor(button.flatArrow, theme.heading) end
end
for _, dropdown in ipairs(themedDropdowns) do
SetTextureColor(dropdown.flatBackground, theme.controlBackground)
SetControlBorders(dropdown, theme.accent)
SetFontColor(dropdown.flatLabel, theme.text)
SetFontColor(dropdown.flatArrow, theme.heading)
end
for _, button in ipairs(themedActionButtons) do
SetTextureColor(button.actionBackground, theme.actionBackground)
for _, border in ipairs({ button.actionTop, button.actionBottom, button.actionLeft, button.actionRight }) do
SetTextureColor(border, theme.actionBorder)
end
SetFontColor(button.actionLabel, theme.heading)
end
for _, fontString in ipairs(themedDescriptors) do SetFontColor(fontString, theme.mutedText) end
for _, fontString in ipairs(themedHeadings) do SetFontColor(fontString, theme.heading) end
for _, panel in ipairs(themedPanels) do
if panel.SetBackdropBorderColor then
panel:SetBackdropBorderColor(theme.panelBorder[1], theme.panelBorder[2], theme.panelBorder[3], theme.panelBorder[4])
end
end
for _, editBox in ipairs(themedEditBoxes) do
editBox:SetBackdropColor(theme.controlBackground[1], theme.controlBackground[2], theme.controlBackground[3], theme.controlBackground[4])
editBox:SetBackdropBorderColor(theme.accent[1], theme.accent[2], theme.accent[3], theme.accent[4])
editBox:SetTextColor(theme.text[1], theme.text[2], theme.text[3], theme.text[4])
end
if frame then
frame:SetBackdropColor(theme.windowBackground[1], theme.windowBackground[2], theme.windowBackground[3], theme.windowBackground[4])
frame:SetBackdropBorderColor(theme.windowBorder[1], theme.windowBorder[2], theme.windowBorder[3], theme.windowBorder[4])
end
if sidebar then
sidebar:SetBackdropColor(theme.windowBackground[1], theme.windowBackground[2], theme.windowBackground[3], theme.windowBackground[4])
sidebar:SetBackdropBorderColor(theme.panelBorder[1], theme.panelBorder[2], theme.panelBorder[3], theme.panelBorder[4])
if sidebar.divider then SetTextureColor(sidebar.divider, theme.divider) end
end
if helpFrame then
helpFrame:SetBackdropColor(theme.windowBackground[1], theme.windowBackground[2], theme.windowBackground[3], theme.windowBackground[4])
helpFrame:SetBackdropBorderColor(theme.panelBorder[1], theme.panelBorder[2], theme.panelBorder[3], theme.panelBorder[4])
end
if voicePopup then
voicePopup:SetBackdropColor(theme.windowBackground[1], theme.windowBackground[2], theme.windowBackground[3], theme.windowBackground[4])
voicePopup:SetBackdropBorderColor(theme.panelBorder[1], theme.panelBorder[2], theme.panelBorder[3], theme.panelBorder[4])
end
for _, button in pairs(navButtons) do SetNavButtonSelected(button, button.selected) end
if mainHelpButton then SetNavButtonSelected(mainHelpButton, false) end
if RefreshThemeCards then RefreshThemeCards() end
end
function Addon:SetTheme(themeKey)
if not THEMES[themeKey] then return false end
self.db.theme = themeKey
ApplyTheme()
return true
end
local function SetMainControlsVisible(visible)
local method = visible and "Show" or "Hide"
if mainCloseButton then mainCloseButton[method](mainCloseButton) end
if mainHelpButton then mainHelpButton[method](mainHelpButton) end
if sidebar then sidebar[method](sidebar) end
end
local function RefreshClassDropdown()
local data = selectedClass and Addon.CLASS_DATA[selectedClass]
SetDropdownText(classDropdown, data and data.name or "Select class")
end
local function RefreshSpecDropdown()
local data = selectedSpec and Addon.SPEC_DATA[selectedSpec]
SetDropdownText(specDropdown, data and data.name or "Select spec")
end
local function RefreshAbilityDropdown()
local data = selectedSpell and Addon:GetSpellData(selectedSpell)
SetDropdownText(abilityDropdown, data and (data.name .. " [" .. data.id .. "]") or "Select class ability")
end
local function RefreshCustomSpellSelection()
if not customSpellSelectionText then return end
local data = selectedCustomSpell and Addon:GetSpellData(selectedCustomSpell)
if data then
customSpellSelectionText:SetText(("Selected: %s [%d]"):format(data.name, data.id))
else
customSpellSelectionText:SetText("No custom spell selected")
end
end
local function SetVoiceButtonText(button, voiceReference)
if button then
button:SetText(voiceReference and Addon:GetVoiceName(voiceReference) or "Select countdown voice")
end
end
local function RefreshVoiceDropdown()
SetVoiceButtonText(voiceDropdown, selectedVoice)
end
local function RefreshChannelDropdown()
if not channelDropdown then return end
local selectedLabel = Addon.db.soundChannel
for _, channel in ipairs(Addon.SOUND_CHANNELS) do
if channel.value == Addon.db.soundChannel then selectedLabel = channel.label end
end
SetDropdownText(channelDropdown, selectedLabel)
end
local function RefreshDropdowns()
RefreshClassDropdown()
RefreshSpecDropdown()
RefreshAbilityDropdown()
RefreshCustomSpellSelection()
RefreshVoiceDropdown()
RefreshChannelDropdown()
end
local function GetRenameText(saved)
if type(saved) == "table" then return saved.text or "" end
return saved or ""
end
local function GetSelectedRenameSpellID()
return renameSelectedCustomSpell or renameSelectedSpell
end
local function RefreshRenameDropdowns()
local class = renameSelectedClass and Addon.CLASS_DATA[renameSelectedClass]
SetDropdownText(renameClassDropdown, class and class.name or "Select class")
local spec = renameSelectedSpec and Addon.SPEC_DATA[renameSelectedSpec]
SetDropdownText(renameSpecDropdown, spec and spec.name or "Select spec")
local spellID = GetSelectedRenameSpellID()
local spell = spellID and Addon:GetSpellData(spellID)
SetDropdownText(renameAbilityDropdown, renameSelectedSpell and spell and (spell.name .. " [" .. spell.id .. "]") or "Select class ability")
if renameCustomSpellSelectionText then
if renameSelectedCustomSpell and spell then
renameCustomSpellSelectionText:SetText(("Selected: %s [%d]"):format(spell.name, spell.id))
else
renameCustomSpellSelectionText:SetText("No custom spell selected")
end
end
if renameTextBox then
local saved = spellID and renameSelectedSpec and Addon:GetAbilityRename(renameSelectedSpec, spellID)
renameTextBox:SetText(GetRenameText(saved))
end
end
RefreshRenameRows = function()
if not renamePage or not renamePage.renameCount then return end
local renames = Addon:GetAbilityRenames()
local maxOffset = math.max(0, #renames - RENAME_ROW_COUNT)
renameOffset = math.min(renameOffset, maxOffset)
for rowIndex = 1, RENAME_ROW_COUNT do
local row = renameRows[rowIndex]
local data = renames[rowIndex + renameOffset]
row.data = data
if data then
row.icon:SetTexture(data.spellIcon)
row.spell:SetText(("%s |cFF888888[%d]|r"):format(data.spellName, data.spellID))
row.spec:SetText(data.specName)
row.replacement:SetText(data.replacement)
row:Show()
else
row:Hide()
end
end
renamePage.renameCount:SetText(("Saved ability renames: %d"):format(#renames))
end
RefreshRenameOptions = function()
RefreshRenameDropdowns()
RefreshRenameRows()
end
local function SetVoiceStatus(message)
local target = voiceContext and voiceContext.statusTarget
if target then target:SetText(message) elseif statusText then statusText:SetText(message) end
end
local function PreviewVoice(voiceID)
if not voiceID or Addon:IsMuteVoice(voiceID) then return end
local maximum = Addon:GetMaximumVoiceNumber(voiceID)
if maximum < 1 then
SetVoiceStatus("That voice is unavailable. Its countdown pack may be disabled.")
return
end
local seconds = math.min(3, maximum)
voicePreviewToken = voicePreviewToken + 1
local token = voicePreviewToken
for number = seconds, 1, -1 do
local countdownNumber = number
C_Timer.After(seconds - countdownNumber, function()
if token == voicePreviewToken then
Addon:PlayVoiceNumber(voiceID, countdownNumber)
end
end)
end
end
local function GetVoicePopupSelection()
if voiceContext and voiceContext.getSelected then
return voiceContext.getSelected()
end
end
local function RefreshVoicePopup()
if not voicePopup or not voiceScrollChild then return end
local voices = {}
if voiceContext and voiceContext.includeDefault then
voices[#voices + 1] = { id = "__NCC_DEFAULT__", name = "Use default countdown", default = true }
end
for _, voice in ipairs(Addon:GetVoiceList()) do voices[#voices + 1] = voice end
local contentWidth = 366
local selectedIndex
local currentSelection = GetVoicePopupSelection()
if voiceContext and voiceContext.includeDefault and currentSelection == nil then
currentSelection = "__NCC_DEFAULT__"
end
for index, voice in ipairs(voices) do
local row = voiceRows[index]
if not row then
row = CreateFrame("Frame", nil, voiceScrollChild)
row:SetSize(contentWidth, VOICE_ROW_HEIGHT)
row.background = row:CreateTexture(nil, "BACKGROUND")
row.background:SetAllPoints()
row.background:SetColorTexture(1, 1, 1, 0.035)
row.check = row:CreateTexture(nil, "ARTWORK")
row.check:SetSize(16, 16)
row.check:SetPoint("LEFT", 4, 0)
row.check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
row.select = CreateFrame("Button", nil, row)
row.select:SetPoint("TOPLEFT", 22, 0)
row.select:SetPoint("BOTTOMRIGHT", -34, 0)
row.select:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD")
row.select.text = row.select:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
row.select.text:SetPoint("LEFT", 4, 0)
row.select.text:SetPoint("RIGHT", -4, 0)
row.select.text:SetJustifyH("LEFT")
row.select:SetScript("OnClick", function(self)
if voiceContext and voiceContext.onSelect then
local selection = self.voiceID == "__NCC_DEFAULT__" and nil or self.voiceID
voiceContext.onSelect(selection)
end
if voicePopup then voicePopup:Hide() end
end)
row.preview = CreateFrame("Button", nil, row)
row.preview:SetSize(24, 24)
row.preview:SetPoint("RIGHT", -4, 0)
row.preview:SetNormalTexture("Interface\\Common\\VoiceChat-Speaker")
row.preview:SetPushedTexture("Interface\\Common\\VoiceChat-Speaker")
row.preview:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square", "ADD")
row.preview:SetScript("OnClick", function(self) PreviewVoice(self.voiceID) end)
row.preview:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("Preview 3, 2, 1")
GameTooltip:Show()
end)
row.preview:SetScript("OnLeave", function() GameTooltip:Hide() end)
voiceRows[index] = row
end
row:ClearAllPoints()
row:SetPoint("TOPLEFT", 0, -((index - 1) * VOICE_ROW_HEIGHT))
row.select.voiceID = voice.id
row.preview.voiceID = voice.id
row.select.text:SetText(voice.name)
row.preview:SetShown(not voice.muted and not voice.default)
if voice.muted then
local theme = GetTheme()
SetFontColor(row.select.text, theme.heading)
row.background:SetColorTexture(theme.selectedBackground[1], theme.selectedBackground[2], theme.selectedBackground[3], 0.70)
elseif voice.default then
SetFontColor(row.select.text, GetTheme().text)
row.background:SetColorTexture(1, 1, 1, 0.055)
else
row.select.text:SetTextColor(1, 1, 1)
row.background:SetColorTexture(1, 1, 1, 0.035)
end
if currentSelection == voice.id then
row.check:Show()
selectedIndex = index
else
row.check:Hide()
end
row:Show()
end
for index = #voices + 1, #voiceRows do voiceRows[index]:Hide() end
local height = math.max(1, #voices * VOICE_ROW_HEIGHT)
voiceScrollChild:SetSize(contentWidth, height)
if voiceScrollFrame.UpdateScrollChildRect then voiceScrollFrame:UpdateScrollChildRect() end
if #voices == 0 then voicePopup.emptyText:Show() else voicePopup.emptyText:Hide() end
if selectedIndex then
C_Timer.After(0, function()
if not voicePopup or not voicePopup:IsShown() then return end
local target = math.max(0, ((selectedIndex - 4) * VOICE_ROW_HEIGHT))
local maximum = voiceScrollFrame:GetVerticalScrollRange() or 0
voiceScrollFrame:SetVerticalScroll(math.min(target, maximum))
end)
else
voiceScrollFrame:SetVerticalScroll(0)
end
end
local function BuildVoicePopup()
voicePopup = CreateFrame("Frame", "NSRTCountdownCompanionVoicePicker", UIParent, "BackdropTemplate")
voicePopup:SetSize(410, 390)
voicePopup:SetFrameStrata("FULLSCREEN_DIALOG")
voicePopup:SetClampedToScreen(true)
voicePopup:EnableMouse(true)
voicePopup:EnableMouseWheel(true)
voicePopup:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8X8",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
tile = false, edgeSize = 24,
insets = { left = 8, right = 8, top = 8, bottom = 8 },
})
voicePopup:SetBackdropColor(0, 0, 0, 1)
voicePopup:SetBackdropBorderColor(1, 1, 1, 1)
RegisterPanel(voicePopup)
local title = voicePopup:CreateFontString(nil, "ARTWORK", "GameFontNormal")
title:SetPoint("TOPLEFT", 16, -13)
title:SetText("Select countdown voice")
RegisterHeading(title)
local hint = voicePopup:CreateFontString(nil, "ARTWORK", "GameFontDisableSmall")
hint:SetPoint("TOPLEFT", 16, -33)
hint:SetPoint("RIGHT", -42, 0)
hint:SetJustifyH("LEFT")
hint:SetText("Select a countdown option or preview a voice")
StyleDescriptorText(hint)
local close = CreateFrame("Button", nil, voicePopup, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", -3, -3)
voiceScrollFrame = CreateFrame("ScrollFrame", nil, voicePopup, "UIPanelScrollFrameTemplate")
voiceScrollFrame:SetPoint("TOPLEFT", 12, -56)
voiceScrollFrame:SetPoint("BOTTOMRIGHT", -30, 12)
voiceScrollFrame:EnableMouseWheel(true)
voiceScrollChild = CreateFrame("Frame", nil, voiceScrollFrame)
voiceScrollChild:SetSize(366, 1)
voiceScrollFrame:SetScrollChild(voiceScrollChild)
voicePopup.emptyText = voicePopup:CreateFontString(nil, "ARTWORK", "GameFontDisable")
voicePopup.emptyText:SetPoint("CENTER", voiceScrollFrame, "CENTER", 0, 0); StyleDescriptorText(voicePopup.emptyText)
voicePopup.emptyText:SetText("No countdown options found")
voicePopup.emptyText:Hide()
local function ScrollVoiceList(delta)
local current = voiceScrollFrame:GetVerticalScroll() or 0
local maximum = voiceScrollFrame:GetVerticalScrollRange() or 0
local target = current - (delta * VOICE_ROW_HEIGHT * 3)
voiceScrollFrame:SetVerticalScroll(math.max(0, math.min(maximum, target)))
end
voicePopup:SetScript("OnMouseWheel", function(_, delta) ScrollVoiceList(delta) end)
voiceScrollFrame:SetScript("OnMouseWheel", function(_, delta) ScrollVoiceList(delta) end)
voicePopup:SetScript("OnShow", function()
RefreshVoicePopup()
voicePopup:Raise()
end)
if UISpecialFrames then table.insert(UISpecialFrames, voicePopup:GetName()) end
voicePopup:Hide()
end
local function ToggleVoicePopup(anchor, getSelected, onSelect, statusTarget, includeDefault)
if not voicePopup then BuildVoicePopup() end
if voicePopup:IsShown() and voiceContext and voiceContext.anchor == anchor then
voicePopup:Hide()
return
end
voiceContext = {
anchor = anchor,
getSelected = getSelected,
onSelect = onSelect,
statusTarget = statusTarget,
includeDefault = includeDefault == true,
}
voicePopup:ClearAllPoints()
voicePopup:SetPoint("TOPRIGHT", anchor, "BOTTOMRIGHT", 0, -4)
voicePopup:Show()
end
RefreshAssignments = function()
if not abilityPage then return end
local assignments = Addon:GetAssignments()
local maxOffset = math.max(0, #assignments - ROW_COUNT)
assignmentOffset = math.min(assignmentOffset, maxOffset)
for rowIndex = 1, ROW_COUNT do
local row = assignmentRows[rowIndex]
local data = assignments[rowIndex + assignmentOffset]
row.data = data
if data then
row.icon:SetTexture(data.spellIcon)
row.spell:SetText(data.spellName .. " |cFF888888[" .. data.spellID .. "]|r")
local className = Addon.CLASS_DATA[data.classFile] and Addon.CLASS_DATA[data.classFile].name or tostring(data.classFile or "Unknown")
row.spec:SetText(className .. " - " .. data.specName)
row.voice:SetText(data.voiceName)
row:Show()
else
row:Hide()
end
end
abilityPage.assignmentCount:SetText(("Player ability assignments: %d"):format(#assignments))
end
local function FormatReminderTime(value)
value = tonumber(value) or 0
local minutes = math.floor(value / 60)
local seconds = value % 60
if math.abs(seconds - math.floor(seconds)) < 0.001 then
return ("%d:%02d"):format(minutes, math.floor(seconds))
end
return ("%d:%04.1f"):format(minutes, seconds)
end
local function GetSelectedNoteReminder()
if not selectedNoteKey then return nil end
for _, reminder in ipairs(Addon:GetCurrentNoteReminders()) do
if reminder.key == selectedNoteKey then return reminder end
end
end
local NOTE_TTS_MODE_LABELS = {
default = "Use NSRT TTS",
mute = "Mute TTS",
custom = "Custom text",
}
local function RefreshNoteTTSControls()
if noteTTSModeDropdown then
SetDropdownText(noteTTSModeDropdown, NOTE_TTS_MODE_LABELS[selectedNoteTTSMode] or NOTE_TTS_MODE_LABELS.default)
end
local custom = selectedNoteTTSMode == "custom"
if noteTTSCustomLabel then noteTTSCustomLabel:SetShown(custom) end
if noteTTSCustomTextBox then
noteTTSCustomTextBox:SetShown(custom)
if custom and noteTTSCustomTextBox:GetText() ~= selectedNoteCustomTTS then
noteTTSCustomTextBox:SetText(selectedNoteCustomTTS or "")
end
end
end
local function GetNoteRowVoiceReference(reminderKey)
local assignment = Addon:GetNoteAssignment(reminderKey)
if assignment and assignment.voice then return Addon:GetVoiceKey(assignment) end
end
local function SaveNoteRowCustomTTS(row)
if not row or not row.data then return end
local text = row.customBox:GetText() or ""
if not text:match("%S") then
noteStatusText:SetText("Enter the custom text NSRT should speak for " .. row.data.label .. ".")
row.customBox:SetFocus()
return
end
local voiceReference = GetNoteRowVoiceReference(row.data.key)
if Addon:SetNoteOverrides(row.data, voiceReference, "custom", text) then
noteStatusText:SetText(("Saved custom TTS for %s: %s."):format(row.data.label, text))
row.customBox:ClearFocus()
RefreshNoteRows()
end
end
local function SetNoteRowTTSMode(row, mode)
if not row or not row.data then return end
mode = mode == "mute" and "mute" or mode == "custom" and "custom" or "default"
row.ttsMode = mode
SetDropdownText(row.ttsDropdown, NOTE_TTS_MODE_LABELS[mode])
if mode == "custom" then
local assignment = Addon:GetNoteAssignment(row.data.key)
row.customBox:SetText(assignment and tostring(assignment.customTTS or "") or "")
row.customBox:Show()
row.customSave:Show()
noteStatusText:SetText("Enter the custom TTS text for " .. row.data.label .. ", then press Enter or Save.")
row.customBox:SetFocus()
return
end
row.customBox:Hide()
row.customSave:Hide()
local voiceReference = GetNoteRowVoiceReference(row.data.key)
if Addon:SetNoteOverrides(row.data, voiceReference, mode, nil) then
noteStatusText:SetText(mode == "mute"
and ("Muted the opening TTS for %s."):format(row.data.label)
or ("Restored NSRT's opening TTS for %s."):format(row.data.label))
RefreshNoteRows()
end
end
local function SetNoteRowCountdown(row, voiceReference)
if not row or not row.data then return end
local assignment = Addon:GetNoteAssignment(row.data.key)
local ttsMode = assignment and Addon:GetNoteTTSMode(row.data.key) or "default"
local customTTS = assignment and assignment.customTTS or nil
if Addon:SetNoteOverrides(row.data, voiceReference, ttsMode, customTTS) then
local label = voiceReference and Addon:GetVoiceName(voiceReference) or "default countdown"
noteStatusText:SetText(("Set %s to %s."):format(row.data.label, label))
RefreshNoteRows()
end
end
RefreshNoteRows = function()
if not notePage then return end
local reminders = Addon:GetCurrentNoteReminders()
local maxOffset = math.max(0, #reminders - NOTE_ROW_COUNT)
noteReminderOffset = math.min(noteReminderOffset, maxOffset)
local assignedCount = 0
for _, reminder in ipairs(reminders) do
if Addon:GetNoteAssignment(reminder.key) then assignedCount = assignedCount + 1 end
end
for rowIndex = 1, NOTE_ROW_COUNT do
local row = noteRows[rowIndex]
local data = reminders[rowIndex + noteReminderOffset]
row.data = data
if data then
local assignment = Addon:GetNoteAssignment(data.key)
local ttsMode = assignment and Addon:GetNoteTTSMode(data.key) or "default"
local voiceReference = assignment and assignment.voice and Addon:GetVoiceKey(assignment) or nil
row.icon:SetTexture(data.icon or 134400)
row.name:SetText(data.label)
local countdownText = data.countdown and (tostring(data.countdown) .. "s countdown") or "|cFFFF6666countdown disabled|r"
row.detail:SetText(("%s • P%s %s • %s • %s"):format(
data.encounterName or ("Encounter " .. tostring(data.encID)),
tostring(data.phase or 1), FormatReminderTime(data.time), data.tag or "", countdownText))
row.ttsMode = ttsMode
SetDropdownText(row.ttsDropdown, NOTE_TTS_MODE_LABELS[ttsMode] or NOTE_TTS_MODE_LABELS.default)
row.countdownButton:SetText(voiceReference and Addon:GetVoiceName(voiceReference) or "Use default countdown")
local custom = ttsMode == "custom"
row.customBox:SetShown(custom)
row.customSave:SetShown(custom)
if custom and not row.customBox:HasFocus() then
row.customBox:SetText(tostring(assignment.customTTS or ""))
end
row.remove:SetShown(assignment ~= nil)
row:Show()
else
row:Hide()
end
end
local sources = Addon:GetLoadedNoteSources()
if #sources == 0 then
noteSummaryText:SetText("No active NSRT shared or personal note is currently loaded.")
if noteScrollText then noteScrollText:SetText("") end
elseif #reminders == 0 then
noteSummaryText:SetText("A note is loaded, but it contains no timed reminders matching this character.")
if noteScrollText then noteScrollText:SetText("") end
else
local sourceNames = {}
for _, source in ipairs(sources) do sourceNames[#sourceNames + 1] = source.name end
noteSummaryText:SetText(("Applicable reminders: %d • Overrides: %d • Source: %s"):format(#reminders, assignedCount, table.concat(sourceNames, ", ")))
if noteScrollText then
local firstShown = noteReminderOffset + 1
local lastShown = math.min(#reminders, noteReminderOffset + NOTE_ROW_COUNT)
if #reminders > NOTE_ROW_COUNT then
noteScrollText:SetText(("Showing %d-%d of %d • Mouse wheel to scroll"):format(firstShown, lastShown, #reminders))