-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.lua
More file actions
1780 lines (1543 loc) · 61.4 KB
/
Options.lua
File metadata and controls
1780 lines (1543 loc) · 61.4 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
--[[
QuestTogether Options Panel (Esc > Options > AddOns)
]]
local QuestTogether = _G.QuestTogether
QuestTogether.announcementControls = QuestTogether.announcementControls or {}
QuestTogether.whereToAnnounceControls = QuestTogether.whereToAnnounceControls or {}
QuestTogether.questPlateControls = QuestTogether.questPlateControls or {}
QuestTogether.miscControls = QuestTogether.miscControls or {}
QuestTogether.homeControls = QuestTogether.homeControls or {}
QuestTogether.profileControls = QuestTogether.profileControls or {}
QuestTogether.profileUIState = QuestTogether.profileUIState or {}
local function SafeText(value, fallback)
return QuestTogether:SafeToString(value, fallback or "")
end
local function IsFrameMutable(frame)
if QuestTogether and QuestTogether.CanAccessForeignFrame then
return QuestTogether:CanAccessForeignFrame(frame)
end
if not frame then
return false
end
if frame.IsForbidden and frame:IsForbidden() then
return false
end
return true
end
local QUEST_PLATE_PREVIEW_SCALE = 1.35
local QUEST_PLATE_PREVIEW_FRAME_HEIGHT = 195
local QUEST_PLATE_PREVIEW_BAR_VISUAL_SCALE = 1.25
local QUEST_PLATE_PREVIEW_RANDOM_NAMES = {
"Koda Bug",
"Rue Angel",
"Pi Floof",
"Sammy Bear",
"Cinder Kitten",
"Lilly Pig",
"Booker Bean",
"Piper Hippo",
"Wifebeast",
"Husblebee",
}
local NAMEPLATE_STYLE_MODERN = Enum and Enum.NamePlateStyle and Enum.NamePlateStyle.Modern or 1
local NAMEPLATE_STYLE_BLOCK = Enum and Enum.NamePlateStyle and Enum.NamePlateStyle.Block or 3
local NAMEPLATE_STYLE_HEALTH_FOCUS = Enum and Enum.NamePlateStyle and Enum.NamePlateStyle.HealthFocus or 4
local NAMEPLATE_STYLE_LEGACY = Enum and Enum.NamePlateStyle and Enum.NamePlateStyle.Legacy or 6
local NAMEPLATE_SIZE_MEDIUM = Enum and Enum.NamePlateSize and Enum.NamePlateSize.Medium or 2
local NAMEPLATE_INFO_PERCENT = Enum and Enum.NamePlateInfoDisplay and Enum.NamePlateInfoDisplay.CurrentHealthPercent or 1
local NAMEPLATE_INFO_VALUE = Enum and Enum.NamePlateInfoDisplay and Enum.NamePlateInfoDisplay.CurrentHealthValue or 2
local NAMEPLATE_PREVIEW_SCALES = {
[1] = { horizontal = 0.75, vertical = 0.8 },
[2] = { horizontal = 1.0, vertical = 1.0 },
[3] = { horizontal = 1.25, vertical = 1.25 },
[4] = { horizontal = 1.4, vertical = 1.4 },
[5] = { horizontal = 1.6, vertical = 1.6 },
}
local function HasBit(mask, bitValue)
if type(mask) ~= "number" or type(bitValue) ~= "number" or bitValue <= 0 then
return false
end
if bit and bit.band then
return bit.band(mask, bitValue) ~= 0
end
if bit32 and bit32.band then
return bit32.band(mask, bitValue) ~= 0
end
local remainder = mask % (bitValue * 2)
return remainder >= bitValue
end
local function GetNumericCVarValue(cvarName, fallbackValue)
if not (QuestTogether and QuestTogether.API and type(QuestTogether.API.GetCVar) == "function") then
return fallbackValue
end
local rawValue = QuestTogether.API.GetCVar(cvarName)
local numericValue = QuestTogether:SafeToNumber(rawValue)
if numericValue == nil then
return fallbackValue
end
return numericValue
end
local function AnchorPreviewFillTexture(texture, healthBar)
if not (texture and healthBar and texture.ClearAllPoints and texture.SetPoint) then
return
end
local fillTexture = healthBar.GetStatusBarTexture and healthBar:GetStatusBarTexture() or nil
if not fillTexture then
return
end
texture:ClearAllPoints()
texture:SetPoint("TOPLEFT", fillTexture, "TOPLEFT", 0, 0)
texture:SetPoint("BOTTOMLEFT", fillTexture, "BOTTOMLEFT", 0, 0)
texture:SetPoint("TOPRIGHT", fillTexture, "TOPRIGHT", 0, 0)
texture:SetPoint("BOTTOMRIGHT", fillTexture, "BOTTOMRIGHT", 0, 0)
end
local function GetRandomQuestPlatePreviewName()
local totalNames = #QUEST_PLATE_PREVIEW_RANDOM_NAMES
if totalNames <= 0 then
return "Quest Mob"
end
if not (math and type(math.random) == "function") then
return QUEST_PLATE_PREVIEW_RANDOM_NAMES[1]
end
local randomIndex = math.random(totalNames)
if type(randomIndex) ~= "number" or randomIndex < 1 or randomIndex > totalNames then
randomIndex = 1
end
return QUEST_PLATE_PREVIEW_RANDOM_NAMES[randomIndex]
end
local function ApplyAnnouncementGroupIcon(texture, iconType)
if not texture then
return
end
if iconType == "world" and texture.SetAtlas then
texture:SetAtlas("worldquest-icon", true)
texture:SetTexCoord(0, 1, 0, 1)
return
end
if iconType == "bonus" and texture.SetAtlas then
texture:SetAtlas("Bonus-Objective-Star", true)
texture:SetTexCoord(0, 1, 0, 1)
return
end
if iconType == "quest" then
texture:SetTexture("Interface\\GossipFrame\\AvailableQuestIcon")
texture:SetTexCoord(0, 1, 0, 1)
return
end
if QuestTogether.NAMEPLATE_QUEST_ICON_ATLAS and texture.SetAtlas then
texture:SetAtlas(QuestTogether.NAMEPLATE_QUEST_ICON_ATLAS, true)
texture:SetTexCoord(0, 1, 0, 1)
return
end
texture:SetTexture(QuestTogether.NAMEPLATE_QUEST_ICON_TEXTURE)
if QuestTogether.NAMEPLATE_QUEST_ICON_TEX_COORDS then
local coords = QuestTogether.NAMEPLATE_QUEST_ICON_TEX_COORDS
texture:SetTexCoord(coords.left, coords.right, coords.top, coords.bottom)
else
texture:SetTexCoord(0, 1, 0, 1)
end
end
local function CreateAnnouncementGroupHeader(parent, text, iconType, x, y, width)
local icon = parent:CreateTexture(nil, "ARTWORK")
icon:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y)
icon:SetSize(16, 16)
ApplyAnnouncementGroupIcon(icon, iconType)
local label = parent:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
label:SetPoint("LEFT", icon, "RIGHT", 8, 0)
label:SetText(text)
local divider = parent:CreateTexture(nil, "BORDER")
divider:SetPoint("TOPLEFT", icon, "BOTTOMLEFT", 0, -8)
divider:SetSize(width or 620, 1)
divider:SetColorTexture(1, 1, 1, 0.12)
return label
end
local function CreateCheckbox(parent, optionKey, labelText, tooltipText, x, y)
local checkbox = CreateFrame("CheckButton", nil, parent, "UICheckButtonTemplate")
checkbox:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y)
local label = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetPoint("LEFT", checkbox, "RIGHT", 6, 0)
label:SetText(labelText)
checkbox.Label = label
if tooltipText and tooltipText ~= "" then
checkbox.tooltipText = tooltipText
end
checkbox:SetScript("OnClick", function(self)
QuestTogether:SetOption(optionKey, self:GetChecked() == true)
QuestTogether:RefreshOptionsWindow()
end)
return checkbox
end
local function ClampColorComponent(value, fallback)
local numberValue = QuestTogether:SafeToNumber(value)
if not numberValue then
return fallback
end
if numberValue < 0 then
return 0
end
if numberValue > 1 then
return 1
end
return numberValue
end
local function ColorsNearlyEqual(left, right)
return math.abs((left or 0) - (right or 0)) < 0.001
end
local function GetColorOption(optionKey, fallbackColor)
local configuredColor = QuestTogether:GetOption(optionKey)
if type(configuredColor) ~= "table" then
return {
r = fallbackColor.r,
g = fallbackColor.g,
b = fallbackColor.b,
}
end
return {
r = ClampColorComponent(configuredColor.r, fallbackColor.r),
g = ClampColorComponent(configuredColor.g, fallbackColor.g),
b = ClampColorComponent(configuredColor.b, fallbackColor.b),
}
end
local function IsColorOptionAtDefault(optionKey, fallbackColor)
local current = GetColorOption(optionKey, fallbackColor)
return ColorsNearlyEqual(current.r, fallbackColor.r)
and ColorsNearlyEqual(current.g, fallbackColor.g)
and ColorsNearlyEqual(current.b, fallbackColor.b)
end
local function CreateColorSwatch(parent, optionKey, labelText, tooltipText, fallbackColor, x, y)
local swatchButton = CreateFrame("Button", nil, parent)
swatchButton:SetSize(22, 22)
swatchButton:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y)
local border = swatchButton:CreateTexture(nil, "BORDER")
border:SetAllPoints()
border:SetColorTexture(0, 0, 0, 1)
swatchButton.Border = border
local colorTexture = swatchButton:CreateTexture(nil, "ARTWORK")
colorTexture:SetPoint("TOPLEFT", swatchButton, "TOPLEFT", 1, -1)
colorTexture:SetPoint("BOTTOMRIGHT", swatchButton, "BOTTOMRIGHT", -1, 1)
swatchButton.ColorTexture = colorTexture
local label = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetPoint("LEFT", swatchButton, "RIGHT", 8, 0)
label:SetText(labelText)
if tooltipText and tooltipText ~= "" then
swatchButton.tooltipText = tooltipText
end
local function SetColorOption(r, g, b)
QuestTogether:SetOption(optionKey, {
r = ClampColorComponent(r, fallbackColor.r),
g = ClampColorComponent(g, fallbackColor.g),
b = ClampColorComponent(b, fallbackColor.b),
})
QuestTogether:RefreshOptionsWindow()
end
swatchButton:SetScript("OnClick", function()
if not (ColorPickerFrame and ColorPickerFrame.SetupColorPickerAndShow) then
QuestTogether:Print("Color picker is unavailable right now.")
return
end
local currentColor = GetColorOption(optionKey, fallbackColor)
local previousColor = {
r = currentColor.r,
g = currentColor.g,
b = currentColor.b,
}
local info = {}
info.r = currentColor.r
info.g = currentColor.g
info.b = currentColor.b
info.hasOpacity = false
info.swatchFunc = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
SetColorOption(r, g, b)
end
info.cancelFunc = function()
SetColorOption(previousColor.r, previousColor.g, previousColor.b)
end
ColorPickerFrame:SetupColorPickerAndShow(info)
end)
local startingColor = GetColorOption(optionKey, fallbackColor)
swatchButton.ColorTexture:SetColorTexture(startingColor.r, startingColor.g, startingColor.b, 1)
return swatchButton
end
local function CreateDropdown(parent, titleText, tooltipText, x, y, width, initializeMenu)
local title = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
title:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y)
title:SetText(titleText)
local dropdown = CreateFrame("Frame", nil, parent, "UIDropDownMenuTemplate")
dropdown:SetPoint("TOPLEFT", title, "BOTTOMLEFT", -16, -2)
dropdown.initializeMenu = initializeMenu
dropdown.title = title
if tooltipText and tooltipText ~= "" then
dropdown.tooltipText = tooltipText
end
UIDropDownMenu_SetWidth(dropdown, width or 180)
UIDropDownMenu_Initialize(dropdown, initializeMenu)
return dropdown
end
local function CreateScrollablePanelContent(parent, minimumHeight)
local scrollFrame = CreateFrame("ScrollFrame", nil, parent, "UIPanelScrollFrameTemplate")
scrollFrame:SetPoint("TOPLEFT", parent, "TOPLEFT", 0, 0)
scrollFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", -28, 0)
local content = CreateFrame("Frame", nil, scrollFrame)
content:SetSize(672, minimumHeight or 600)
scrollFrame:SetScrollChild(content)
scrollFrame:SetScript("OnSizeChanged", function(_, width)
content:SetWidth(math.max(672, width - 8))
end)
return scrollFrame, content
end
local function CreateOptionDropdown(parent, titleText, tooltipText, x, y, width, values, getLabel, optionKey, currentValueGetter)
return CreateDropdown(
parent,
titleText,
tooltipText,
x,
y,
width,
function(_, level)
for _, value in ipairs(values) do
local info = UIDropDownMenu_CreateInfo()
info.text = getLabel(value)
info.func = function()
QuestTogether:SetOption(optionKey, value)
QuestTogether:RefreshOptionsWindow()
CloseDropDownMenus()
end
info.checked = currentValueGetter() == value
UIDropDownMenu_AddButton(info, level)
end
end
)
end
local function CreateShowProgressForDropdown(parent, x, y)
return CreateOptionDropdown(
parent,
"Show Announcements For",
"Choose whether to display grouped players only, or grouped plus nearby players with visible nameplates.",
x,
y,
200,
QuestTogether.showProgressForOrder,
function(value)
return QuestTogether:GetShowProgressForLabel(value)
end,
"showProgressFor",
function()
return QuestTogether:GetOption("showProgressFor")
end
)
end
local function CreateChatLogDestinationDropdown(parent, x, y)
return CreateOptionDropdown(
parent,
"Chat Log Destination",
"Choose whether QuestTogether chat logs print to your main chat frame or a dedicated QuestTogether chat frame.",
x,
y,
190,
QuestTogether.chatLogDestinationOrder,
function(value)
return QuestTogether:GetChatLogDestinationLabel(value)
end,
"chatLogDestination",
function()
return QuestTogether:GetOption("chatLogDestination")
end
)
end
local function CreateNameplateIconStyleDropdown(parent, x, y)
return CreateOptionDropdown(
parent,
"Quest Icon Style",
"Choose where to place the quest icon on the nameplate.",
x,
y,
140,
QuestTogether.nameplateQuestIconStyleOrder,
function(styleKey)
return QuestTogether:GetNameplateQuestIconStyleLabel(styleKey)
end,
"nameplateQuestIconStyle",
function()
return QuestTogether:GetNameplateQuestIconStyle()
end
)
end
local CHECKBOX_OPTION_KEYS = {
"announceAccepted",
"announceCompleted",
"announceReadyToTurnIn",
"announceRemoved",
"announceProgress",
"announceWorldQuestAreaEnter",
"announceWorldQuestAreaLeave",
"announceWorldQuestProgress",
"announceWorldQuestCompleted",
"announceBonusObjectiveAreaEnter",
"announceBonusObjectiveAreaLeave",
"announceBonusObjectiveProgress",
"announceBonusObjectiveCompleted",
"showChatBubbles",
"hideMyOwnChatBubbles",
"showChatLogs",
"mirrorChatLogsToMainChat",
"nameplateQuestIconEnabled",
"nameplateQuestHealthColorEnabled",
"emoteOnQuestCompletion",
"emoteOnNearbyPlayerQuestCompletion",
}
local function RefreshCheckboxOptions(controls)
if type(controls) ~= "table" then
return
end
for _, optionKey in ipairs(CHECKBOX_OPTION_KEYS) do
local control = controls[optionKey]
if control then
control:SetChecked(QuestTogether:GetOption(optionKey))
end
end
end
local function RefreshDropdownControl(dropdown, labelText)
UIDropDownMenu_Initialize(dropdown, dropdown.initializeMenu)
UIDropDownMenu_SetText(dropdown, labelText)
end
local function SetLabeledControlShown(control, shown)
if not control then
return
end
if control.SetShown then
control:SetShown(shown)
end
if control.Label and control.Label.SetShown then
control.Label:SetShown(shown)
end
if control.title and control.title.SetShown then
control.title:SetShown(shown)
end
end
local function RefreshQuestPlatesPreview(controls)
if type(controls) ~= "table" then
return
end
local previewFrame = controls.previewFrame
local previewUnitFrame = controls.previewUnitFrame
if not IsFrameMutable(previewUnitFrame) or not previewUnitFrame.healthBar then
return
end
if previewUnitFrame.SetScale then
previewUnitFrame:SetScale(QUEST_PLATE_PREVIEW_SCALE)
end
local nameplateStyle = GetNumericCVarValue("nameplateStyle", NAMEPLATE_STYLE_MODERN)
local nameplateSize = GetNumericCVarValue("nameplateSize", NAMEPLATE_SIZE_MEDIUM)
local infoDisplayMask = GetNumericCVarValue("nameplateInfoDisplay", 0)
local scaleData = NAMEPLATE_PREVIEW_SCALES[nameplateSize] or NAMEPLATE_PREVIEW_SCALES[NAMEPLATE_SIZE_MEDIUM]
local horizontalScale = scaleData.horizontal or 1
local verticalScale = scaleData.vertical or 1
local largeHealthBar = nameplateStyle == NAMEPLATE_STYLE_MODERN
or nameplateStyle == NAMEPLATE_STYLE_BLOCK
or nameplateStyle == NAMEPLATE_STYLE_HEALTH_FOCUS
local nameInsideHealthBar = nameplateStyle == NAMEPLATE_STYLE_MODERN or nameplateStyle == NAMEPLATE_STYLE_BLOCK
local barWidth = math.max(120, math.floor((230 * horizontalScale * QUEST_PLATE_PREVIEW_BAR_VISUAL_SCALE) + 0.5))
local barHeight =
math.max(8, math.floor(((largeHealthBar and 20 or 10) * verticalScale * QUEST_PLATE_PREVIEW_BAR_VISUAL_SCALE) + 0.5))
local nameFontSize = math.max(10, math.floor((12 * verticalScale) + 0.5))
local healthContainer = previewUnitFrame.HealthBarsContainer
if healthContainer and healthContainer.SetSize then
healthContainer:SetSize(barWidth, barHeight)
healthContainer:ClearAllPoints()
healthContainer:SetPoint("CENTER", previewUnitFrame, "CENTER", 0, nameInsideHealthBar and 0 or -6)
end
if previewUnitFrame.SetSize then
local frameWidth = barWidth + 140
local frameHeight = math.max(72, barHeight + (nameInsideHealthBar and 34 or 50))
previewUnitFrame:SetSize(frameWidth, frameHeight)
end
if previewFrame and previewUnitFrame.ClearAllPoints and previewUnitFrame.SetPoint then
previewUnitFrame:ClearAllPoints()
previewUnitFrame:SetPoint("CENTER", previewFrame, "CENTER", 0, 0)
end
local nameLabel = previewUnitFrame.name
local healthText = previewUnitFrame.questPreviewHealthText
if nameLabel then
local fontPath, _, fontFlags = nameLabel:GetFont()
if fontPath and nameLabel.SetFont then
nameLabel:SetFont(fontPath, nameFontSize, fontFlags)
end
nameLabel:ClearAllPoints()
if nameLabel.SetDrawLayer then
nameLabel:SetDrawLayer("OVERLAY", 7)
end
if nameLabel.SetJustifyH then
nameLabel:SetJustifyH("LEFT")
end
if nameLabel.SetWidth then
nameLabel:SetWidth(math.max(40, barWidth - 72))
end
if nameInsideHealthBar and healthContainer then
nameLabel:SetPoint("LEFT", healthContainer, "LEFT", 6, 0)
elseif healthContainer then
nameLabel:SetPoint("BOTTOMLEFT", healthContainer, "TOPLEFT", 6, 2)
else
nameLabel:SetPoint("TOP", previewUnitFrame, "TOP", 0, 0)
end
if nameplateStyle == NAMEPLATE_STYLE_LEGACY and nameLabel.SetTextColor then
nameLabel:SetTextColor(1, 0, 0, 1)
elseif nameLabel.SetTextColor then
nameLabel:SetTextColor(1, 1, 1, 1)
end
end
local healthBar = previewUnitFrame.healthBar
local baseFill = previewUnitFrame.questPreviewBaseFillTexture
local tintOverlay = previewUnitFrame.questPreviewTintTexture
local tintHighlight = previewUnitFrame.questPreviewTintHighlight
if healthBar and healthBar.SetMinMaxValues and healthBar.SetValue then
healthBar:SetMinMaxValues(0, 100)
healthBar:SetValue(100)
end
if baseFill then
AnchorPreviewFillTexture(baseFill, healthBar)
baseFill:Show()
end
if tintOverlay then
AnchorPreviewFillTexture(tintOverlay, healthBar)
end
if tintHighlight then
AnchorPreviewFillTexture(tintHighlight, healthBar)
end
local tintEnabled = QuestTogether:GetOption("nameplateQuestHealthColorEnabled") == true
local enemyBarColor = { r = 0.82, g = 0.14, b = 0.14 }
local previewBarColor = enemyBarColor
if tintEnabled then
previewBarColor = GetColorOption("nameplateQuestHealthColor", QuestTogether.NAMEPLATE_QUEST_HEALTH_COLOR)
end
if baseFill and baseFill.SetVertexColor then
baseFill:SetVertexColor(previewBarColor.r, previewBarColor.g, previewBarColor.b, 1)
end
-- For preview accuracy keep the fill opaque and avoid additive tints.
if tintOverlay and tintOverlay.Hide then
tintOverlay:Hide()
end
if tintHighlight and tintHighlight.Hide then
tintHighlight:Hide()
end
if healthText then
if healthText.SetDrawLayer then
healthText:SetDrawLayer("OVERLAY", 7)
end
if healthText.SetJustifyH then
healthText:SetJustifyH("RIGHT")
end
healthText:ClearAllPoints()
if nameInsideHealthBar and healthContainer then
healthText:SetPoint("RIGHT", healthContainer, "RIGHT", -6, 0)
elseif healthContainer then
healthText:SetPoint("BOTTOMRIGHT", healthContainer, "TOPRIGHT", -6, 2)
end
local showPercent = HasBit(infoDisplayMask, NAMEPLATE_INFO_PERCENT)
local showValue = HasBit(infoDisplayMask, NAMEPLATE_INFO_VALUE)
if showPercent or showValue then
if showPercent and showValue then
healthText:SetText("241 K 100%")
elseif showValue then
healthText:SetText("241 K")
else
healthText:SetText("100%")
end
healthText:Show()
else
healthText:Hide()
end
end
local previewIconFrame = controls.previewIconFrame
local previewIcon = controls.previewIconTexture
if not previewIconFrame or controls.previewIconOwner ~= previewUnitFrame then
local iconParent = previewFrame or previewUnitFrame
previewIconFrame = CreateFrame("Frame", nil, iconParent)
previewIconFrame:SetFrameStrata("HIGH")
local parentFrameLevel = 0
if healthContainer and healthContainer.GetFrameLevel and QuestTogether.SafeToNumber then
parentFrameLevel = QuestTogether:SafeToNumber(healthContainer:GetFrameLevel()) or 0
elseif iconParent and iconParent.GetFrameLevel and QuestTogether.SafeToNumber then
parentFrameLevel = QuestTogether:SafeToNumber(iconParent:GetFrameLevel()) or 0
end
previewIconFrame:SetFrameLevel(parentFrameLevel + 30)
previewIcon = previewIconFrame:CreateTexture(nil, "OVERLAY")
previewIcon:SetAllPoints()
previewIconFrame.Icon = previewIcon
controls.previewIconFrame = previewIconFrame
controls.previewIconTexture = previewIcon
controls.previewIconOwner = previewUnitFrame
end
local showIcon = QuestTogether:GetOption("nameplateQuestIconEnabled") == true
if showIcon then
ApplyAnnouncementGroupIcon(previewIcon, "nameplatePreview")
if QuestTogether.ApplyNameplateQuestIconStyle then
QuestTogether:ApplyNameplateQuestIconStyle(previewIconFrame, previewUnitFrame)
else
previewIconFrame:ClearAllPoints()
previewIconFrame:SetPoint("BOTTOM", previewUnitFrame.HealthBarsContainer, "TOP", 0, 11)
end
previewIconFrame:Show()
else
previewIconFrame:Hide()
end
if IsFrameMutable(previewFrame) and previewFrame.Preview then
previewFrame.Preview:SetText("Previewing - Quest Mob")
end
end
function QuestTogether:RefreshOptionsWindow()
self:RefreshHomeWindow()
self:RefreshAnnouncementsWindow()
self:RefreshWhereToAnnounceWindow()
self:RefreshQuestPlatesWindow()
self:RefreshMiscWindow()
end
function QuestTogether:RefreshHomeWindow()
if not self.optionsFrame then
return
end
local controls = self.homeControls
if type(controls) ~= "table" then
return
end
local activeProfile = SafeText(self:GetCurrentProfileKey() or self.activeProfileKey or "Unknown", "Unknown")
local showProgressForLabel = self:GetShowProgressForLabel(self:GetOption("showProgressFor"))
local chatLogsEnabled = self:GetOption("showChatLogs") and "On" or "Off"
local chatLogDestination = self:GetChatLogDestinationLabel(self:GetOption("chatLogDestination"))
if self:GetOption("chatLogDestination") == "separate" and self:GetOption("mirrorChatLogsToMainChat") == true then
chatLogDestination = chatLogDestination .. " + Main Chat When Docked"
end
local chatBubblesEnabled = self:GetOption("showChatBubbles") and "On" or "Off"
local questIconEnabled = self:GetOption("nameplateQuestIconEnabled") and "On" or "Off"
local questIconStyle = self:GetNameplateQuestIconStyleLabel(self:GetNameplateQuestIconStyle())
local questTintEnabled = self:GetOption("nameplateQuestHealthColorEnabled") and "On" or "Off"
if controls.statusText then
controls.statusText:SetText(
string.format(
"Active profile: %s\nShow progress for: %s\nChat logs: %s (%s)\nChat bubbles: %s\nQuest icon: %s (%s)\nQuest health tint: %s",
activeProfile,
SafeText(showProgressForLabel, "Unknown"),
chatLogsEnabled,
SafeText(chatLogDestination, "Unknown"),
chatBubblesEnabled,
questIconEnabled,
SafeText(questIconStyle, "Unknown"),
questTintEnabled
)
)
end
if controls.openHudEditMode then
local bubblesEnabled = self:GetOption("showChatBubbles") == true
controls.openHudEditMode:SetEnabled(bubblesEnabled)
controls.openHudEditMode:SetAlpha(bubblesEnabled and 1 or 0.5)
end
end
function QuestTogether:RefreshWhereToAnnounceWindow()
if not self.whereToAnnounceFrame then
return
end
local controls = self.whereToAnnounceControls
RefreshCheckboxOptions(controls)
if controls.chatLogDestinationDropdown then
RefreshDropdownControl(
controls.chatLogDestinationDropdown,
self:GetChatLogDestinationLabel(self:GetOption("chatLogDestination"))
)
end
local showBubbleControls = self:GetOption("showChatBubbles")
if controls.hideMyOwnChatBubbles then
controls.hideMyOwnChatBubbles:SetShown(showBubbleControls)
if controls.hideMyOwnChatBubbles.Label then
controls.hideMyOwnChatBubbles.Label:SetShown(showBubbleControls)
end
end
if controls.personalBubbleEditHint then
controls.personalBubbleEditHint:SetShown(showBubbleControls)
end
if controls.openHudEditMode then
controls.openHudEditMode:SetShown(showBubbleControls)
end
local showChatLogControls = self:GetOption("showChatLogs")
local showMirrorChatLogControl = showChatLogControls and self:GetOption("chatLogDestination") == "separate"
if controls.chatLogDestinationDropdown then
if UIDropDownMenu_EnableDropDown and UIDropDownMenu_DisableDropDown then
if showChatLogControls then
UIDropDownMenu_EnableDropDown(controls.chatLogDestinationDropdown)
else
UIDropDownMenu_DisableDropDown(controls.chatLogDestinationDropdown)
end
end
controls.chatLogDestinationDropdown:SetAlpha(showChatLogControls and 1 or 0.5)
if controls.chatLogDestinationDropdown.title then
controls.chatLogDestinationDropdown.title:SetAlpha(showChatLogControls and 1 or 0.5)
end
end
if controls.mirrorChatLogsToMainChat then
SetLabeledControlShown(controls.mirrorChatLogsToMainChat, showMirrorChatLogControl)
end
end
function QuestTogether:RefreshQuestPlatesWindow()
if not self.questPlatesFrame then
return
end
local controls = self.questPlateControls
RefreshCheckboxOptions(controls)
if controls.nameplateQuestIconStyleDropdown then
RefreshDropdownControl(
controls.nameplateQuestIconStyleDropdown,
self:GetNameplateQuestIconStyleLabel(self:GetNameplateQuestIconStyle())
)
end
if not controls.nameplateQuestHealthColor then
return
end
local color = GetColorOption("nameplateQuestHealthColor", self.NAMEPLATE_QUEST_HEALTH_COLOR)
controls.nameplateQuestHealthColor.ColorTexture:SetColorTexture(color.r, color.g, color.b, 1)
if controls.resetNameplateQuestHealthColor then
if IsColorOptionAtDefault("nameplateQuestHealthColor", self.NAMEPLATE_QUEST_HEALTH_COLOR) then
controls.resetNameplateQuestHealthColor:Hide()
else
controls.resetNameplateQuestHealthColor:Show()
end
end
RefreshQuestPlatesPreview(controls)
end
function QuestTogether:RefreshMiscWindow()
if not self.miscFrame then
return
end
RefreshCheckboxOptions(self.miscControls)
end
function QuestTogether:RefreshAnnouncementsWindow()
if not self.announcementsFrame then
return
end
RefreshCheckboxOptions(self.announcementControls)
if self.announcementControls.showProgressForDropdown then
RefreshDropdownControl(
self.announcementControls.showProgressForDropdown,
self:GetShowProgressForLabel(self:GetOption("showProgressFor"))
)
end
end
local function RegisterSubcategory(parentCategory, frame, categoryName)
if not (Settings and Settings.RegisterCanvasLayoutSubcategory and parentCategory and frame) then
return nil
end
local subcategory = nil
local ok, categoryOrError =
pcall(Settings.RegisterCanvasLayoutSubcategory, parentCategory, frame, categoryName, categoryName)
if ok then
subcategory = categoryOrError
end
if not subcategory then
-- Older signatures omit the extra name parameter.
ok, categoryOrError = pcall(Settings.RegisterCanvasLayoutSubcategory, parentCategory, frame, categoryName)
if ok then
subcategory = categoryOrError
end
end
if not subcategory then
return nil
end
if Settings.RegisterAddOnCategory then
Settings.RegisterAddOnCategory(subcategory)
end
return subcategory
end
local function OpenSettingsCategory(category)
if not (Settings and Settings.OpenToCategory and category and category.GetID) then
return false
end
Settings.OpenToCategory(category:GetID())
return true
end
local function BuildProfileKeyList(excludedKey)
local profileKeys = QuestTogether:GetProfileKeys()
local filtered = {}
for _, profileKey in ipairs(profileKeys) do
if profileKey ~= excludedKey then
filtered[#filtered + 1] = profileKey
end
end
return filtered
end
function QuestTogether:RefreshProfilesWindow()
if not self.profilesFrame then
return
end
local controls = self.profileControls
local uiState = self.profileUIState or {}
self.profileUIState = uiState
local currentProfileKey = self:GetCurrentProfileKey()
local allProfileKeys = self:GetProfileKeys()
local nonActiveProfileKeys = BuildProfileKeyList(currentProfileKey)
if not uiState.copyFromProfileKey or uiState.copyFromProfileKey == currentProfileKey then
uiState.copyFromProfileKey = nonActiveProfileKeys[1]
end
if not uiState.deleteProfileKey or uiState.deleteProfileKey == currentProfileKey then
uiState.deleteProfileKey = nonActiveProfileKeys[1]
end
RefreshDropdownControl(controls.currentProfileDropdown, currentProfileKey or "None")
RefreshDropdownControl(controls.copyFromProfileDropdown, uiState.copyFromProfileKey or "No Other Profiles")
RefreshDropdownControl(controls.deleteProfileDropdown, uiState.deleteProfileKey or "No Other Profiles")
local canCopy = uiState.copyFromProfileKey ~= nil
local canDelete = uiState.deleteProfileKey ~= nil
if UIDropDownMenu_EnableDropDown and UIDropDownMenu_DisableDropDown then
if canCopy then
UIDropDownMenu_EnableDropDown(controls.copyFromProfileDropdown)
else
UIDropDownMenu_DisableDropDown(controls.copyFromProfileDropdown)
end
if canDelete then
UIDropDownMenu_EnableDropDown(controls.deleteProfileDropdown)
else
UIDropDownMenu_DisableDropDown(controls.deleteProfileDropdown)
end
end
controls.copyButton:SetEnabled(canCopy)
controls.deleteButton:SetEnabled(canDelete)
local characterKey = SafeText(self.activeCharacterKey or self:GetCurrentCharacterKey() or "Unknown", "Unknown")
controls.profileSummary:SetText(
string.format(
"Character: %s\nActive profile: %s\nSaved profiles: %d",
characterKey,
SafeText(currentProfileKey, ""),
#allProfileKeys
)
)
end
function QuestTogether:InitializeProfilesWindow(parentCategory)
if self.profilesFrame then
return
end
local frame = CreateFrame("Frame", "QuestTogetherProfilesPanel")
frame.name = "Profiles"
frame.parent = "QuestTogether"
local _, content = CreateScrollablePanelContent(frame, 560)
local title = content:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", content, "TOPLEFT", 16, -16)
title:SetText("QuestTogether Profiles")
local description = content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
description:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
description:SetWidth(640)
description:SetJustifyH("LEFT")
description:SetText(
"QuestTogether now defaults each character to its own profile. Use this page to switch, copy, create, reset, or delete profiles."
)
local currentProfileDropdown = CreateDropdown(
content,
"Current Profile",
"Switch this character to another profile.",
16,
-92,
240,
function(_, level)
local currentProfileKey = QuestTogether:GetCurrentProfileKey()
for _, profileKey in ipairs(QuestTogether:GetProfileKeys()) do
local info = UIDropDownMenu_CreateInfo()
info.text = profileKey
info.checked = profileKey == currentProfileKey
info.func = function()
local ok, err = QuestTogether:SetActiveProfile(profileKey)
if not ok then
QuestTogether:Print(SafeText(err, "Unknown error"))
end
QuestTogether:RefreshProfilesWindow()
CloseDropDownMenus()
end
UIDropDownMenu_AddButton(info, level)
end
end
)
local copyFromDropdown = CreateDropdown(
content,
"Copy Into Current Profile",
"Pick another profile, then click Copy.",
16,
-160,
240,
function(_, level)
local currentProfileKey = QuestTogether:GetCurrentProfileKey()
for _, profileKey in ipairs(BuildProfileKeyList(currentProfileKey)) do
local info = UIDropDownMenu_CreateInfo()
info.text = profileKey
info.checked = QuestTogether.profileUIState.copyFromProfileKey == profileKey
info.func = function()
QuestTogether.profileUIState.copyFromProfileKey = profileKey
QuestTogether:RefreshProfilesWindow()