-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.lua
More file actions
2214 lines (1972 loc) · 86.8 KB
/
Copy pathOptions.lua
File metadata and controls
2214 lines (1972 loc) · 86.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 L = _G.QuestTogether.Translate
--[[
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.groupsControls = QuestTogether.groupsControls 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 L("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
function QuestTogether:GetSettingsTooltipParent()
return UIParent
end
function QuestTogether:CreateSettingsTooltipFrame(parent)
return CreateFrame("Frame", nil, parent, "BackdropTemplate")
end
function QuestTogether:HideSettingsTooltip(owner)
if owner and rawget(self, "settingsTooltipOwner") ~= owner then return end
self.settingsTooltipPendingHide = true
local tooltip = rawget(self, "settingsTooltip")
if self.LibChev.CanMutateOwnedRegion(tooltip) then
tooltip:Hide()
tooltip:SetScript("OnUpdate", nil)
self.settingsTooltipOwner, self.settingsTooltipPendingHide = nil, nil
end
end
function QuestTogether:ShowSettingsTooltip(owner, title, text)
if self:IsRuntimeRestricted() or not self.LibChev.CanMutateOwnedRegion(owner) or not owner:IsVisible() then
self:HideSettingsTooltip()
return false
end
local tooltip = rawget(self, "settingsTooltip")
if not tooltip then
local parent = self:GetSettingsTooltipParent()
if not self:CanAccessForeignFrame(parent) then return false end
tooltip = self:CreateSettingsTooltipFrame(parent)
if not self.LibChev.CanMutateOwnedRegion(tooltip) then return false end
self.settingsTooltip = tooltip
tooltip:Hide()
tooltip:SetFrameStrata("TOOLTIP")
tooltip:SetFrameLevel(100)
tooltip:SetClampedToScreen(true)
tooltip:SetBackdrop({ bgFile = "Interface\\Buttons\\WHITE8X8", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 12 })
tooltip:SetBackdropColor(0.04, 0.05, 0.07, 0.97)
tooltip.title = tooltip:CreateFontString(nil, "OVERLAY", "GameFontNormal")
tooltip.title:SetPoint("TOPLEFT", 12, -12)
tooltip.title:SetWidth(296)
tooltip.title:SetJustifyH("LEFT")
tooltip.title:SetWordWrap(true)
tooltip.text = tooltip:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
tooltip.text:SetPoint("TOPLEFT", tooltip.title, "BOTTOMLEFT", 0, -8)
tooltip.text:SetWidth(296)
tooltip.text:SetJustifyH("LEFT")
tooltip.text:SetWordWrap(true)
end
if not self.LibChev.CanMutateOwnedRegion(tooltip)
or not self.LibChev.CanMutateOwnedRegion(tooltip.title)
or not self.LibChev.CanMutateOwnedRegion(tooltip.text) then return false end
tooltip.title:SetText(title)
tooltip.text:SetText(text)
tooltip:SetSize(320, tooltip.title:GetStringHeight() + tooltip.text:GetStringHeight() + 32)
tooltip:ClearAllPoints()
tooltip:SetPoint("TOPLEFT", owner, "TOPRIGHT", 8, 0)
self.settingsTooltipOwner, self.settingsTooltipPendingHide = owner, nil
local elapsedSinceCheck = 0
tooltip:SetScript("OnUpdate", function(_, elapsed)
elapsedSinceCheck = elapsedSinceCheck + elapsed
if elapsedSinceCheck < 0.1 then return end
elapsedSinceCheck = 0
local current = rawget(self, "settingsTooltipOwner")
if self.settingsTooltipPendingHide or self:IsRuntimeRestricted()
or not self.LibChev.CanMutateOwnedRegion(current) or not current:IsVisible() then
self:HideSettingsTooltip()
end
end)
tooltip:Show()
return true
end
-- Only attach to controls created by this addon. No shared GameTooltip state.
function QuestTogether:AttachSettingsTooltip(control, title, text)
assert(type(text) == "string" and text ~= "", "settings controls require explanatory tooltip text")
control:EnableMouse(true)
if control.SetMotionScriptsWhileDisabled then control:SetMotionScriptsWhileDisabled(true) end
control:HookScript("OnEnter", function() self:ShowSettingsTooltip(control, title, text) end)
control:HookScript("OnLeave", function() self:HideSettingsTooltip(control) end)
control:HookScript("OnHide", function() self:HideSettingsTooltip(control) end)
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:SetWidth(math.max(360, 600 - x))
label:SetJustifyH("LEFT")
label:SetWordWrap(true)
label:SetMaxLines(2)
label:SetText(labelText)
checkbox.Label = label
checkbox:SetHitRectInsets(0, -(math.max(360, 600 - x) + 6), 0, 0)
QuestTogether:AttachSettingsTooltip(checkbox, labelText, tooltipText)
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
function QuestTogether:CreateProfileOptionEditCallback(optionKey)
local profile = self.db and self.db.profile
local editToken = {}
self.profileOptionEditToken = editToken
return function(value)
-- A picker can outlive a profile switch, copy/reset, or another picker.
-- Table identity also catches replacement of a profile with the same name.
if type(profile) ~= "table" or not self.db or self.db.profile ~= profile
or self.profileOptionEditToken ~= editToken then
return false
end
return self:SetOption(optionKey, value)
end
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)
swatchButton:SetHitRectInsets(0, -120, 0, 0)
QuestTogether:AttachSettingsTooltip(swatchButton, labelText, tooltipText)
swatchButton:SetScript("OnClick", function()
if not (ColorPickerFrame and ColorPickerFrame.SetupColorPickerAndShow) then
QuestTogether:Print(L("Color picker is unavailable right now."))
return
end
local applyOption = QuestTogether:CreateProfileOptionEditCallback(optionKey)
local function SetColorOption(r, g, b)
if applyOption({
r = ClampColorComponent(r, fallbackColor.r),
g = ClampColorComponent(g, fallbackColor.g),
b = ClampColorComponent(b, fallbackColor.b),
}) then
QuestTogether:RefreshOptionsWindow()
end
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
QuestTogether:AttachSettingsTooltip(dropdown, titleText, tooltipText)
if dropdown.Button then QuestTogether:AttachSettingsTooltip(dropdown.Button, titleText, 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
function QuestTogether:ApplyOptionsDropdownSelection(optionKey, value)
-- This choice opens/closes native chat windows. A stale Settings dropdown
-- must recheck restrictions just like the minimap and chat context menus.
if optionKey == "chatLogDestination" and self:IsRuntimeRestricted() then return false end
if not self:SetOption(optionKey, value) then return false end
self:RefreshOptionsWindow()
return true
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()
if QuestTogether:ApplyOptionsDropdownSelection(optionKey, value) then
CloseDropDownMenus()
end
end
info.checked = currentValueGetter() == value
UIDropDownMenu_AddButton(info, level)
end
end
)
end
local function CreateShowProgressForDropdown(parent, x, y)
return CreateOptionDropdown(
parent,
L("Show Announcements For"),
L("Party Only shows announcements from your group. Party and Nearby also includes players within your Nearby Range or visible nearby. Looking-for-partners announcements reach the whole zone."),
x,
y,
200,
QuestTogether.showProgressForOrder,
function(value)
return QuestTogether:GetShowProgressForLabel(value)
end,
"showProgressFor",
function()
return QuestTogether:GetOption("showProgressFor")
end
)
end
local function CreateQTChatScopeDropdown(parent, x, y)
return CreateOptionDropdown(parent, L("QT Chat Scope"),
L("Global shows all received QT chat. Zone Only shows players whose recent shared location is in your zone; unknown or stale locations are hidden."),
x, y, 200, { "zone_only", "global" },
function(value) return value == "zone_only" and L("Zone Only") or L("Global") end,
"qtChatScope", function() return QuestTogether:GetOption("qtChatScope") end)
end
local function CreateChatLogDestinationDropdown(parent, x, y)
return CreateOptionDropdown(
parent,
L("Chat Log Destination"),
L("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, playerPlates)
return CreateOptionDropdown(
parent,
playerPlates and L("Player Icon Style") or L("Quest Icon Style"),
L("Choose where to place the icon on the nameplate."),
x,
y,
140,
QuestTogether.nameplateQuestIconStyleOrder,
function(styleKey)
return QuestTogether:GetNameplateQuestIconStyleLabel(styleKey)
end,
playerPlates and "nameplatePlayerIconStyle" or "nameplateQuestIconStyle",
function()
return playerPlates and QuestTogether:GetNameplatePlayerIconStyle()
or QuestTogether:GetNameplateQuestIconStyle()
end
)
end
local CHECKBOX_OPTION_KEYS = {
"announceQuestPartners",
"stopLookingForPartnersOnJoin",
"announceAccepted",
"announceCompleted",
"announceReadyToTurnIn",
"announceRemoved",
"announceProgress",
"announceWorldQuestAreaEnter",
"announceWorldQuestAreaLeave",
"announceWorldQuestProgress",
"announceWorldQuestCompleted",
"announceBonusObjectiveAreaEnter",
"announceBonusObjectiveAreaLeave",
"announceBonusObjectiveProgress",
"announceBonusObjectiveCompleted",
"showChatBubbles",
"hideMyOwnChatBubbles",
"showChatLogs",
"showQTChat",
"announceToNonQTParty",
"mirrorChatLogsToMainChat",
"nameplateQuestIconEnabled",
"nameplatePlayerIconEnabled",
"nameplateQuestHealthColorEnabled",
"emoteOnQuestCompletion",
"emoteOnNearbyPlayerQuestCompletion",
"emoteOnLevelUp",
"emoteOnNearbyPlayerLevelUp",
"autoAcceptPartyShareRequests",
"autoInviteFriends",
"autoInviteWhileLFG",
"lookingForQuestPartners",
"showMinimapButton",
"sharePlayerLocation",
"showPlayerLocations",
"onlyShowQuestPartners",
}
local function RefreshCheckboxOptions(controls, addon)
if type(controls) ~= "table" then
return
end
addon = addon or QuestTogether
for _, optionKey in ipairs(CHECKBOX_OPTION_KEYS) do
local control = controls[optionKey]
if control then
control:SetChecked(addon: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
if controls.playerPlates then
nameLabel:SetTextColor(0.22, 0.80, 0.22, 1)
else
nameLabel:SetTextColor(1, 0, 0, 1)
end
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 = not controls.playerPlates
and QuestTogether:GetOption("nameplateQuestHealthColorEnabled") == true
local enemyBarColor = { r = 0.82, g = 0.14, b = 0.14 }
local previewBarColor = controls.playerPlates and { r = 0.22, g = 0.80, b = 0.22 } or 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(
controls.playerPlates and "nameplatePlayerIconEnabled" or "nameplateQuestIconEnabled"
) == true
if showIcon then
if controls.playerPlates then
QuestTogether:SetNameplateIconKind(previewIconFrame, "player")
else
ApplyAnnouncementGroupIcon(previewIcon, "nameplatePreview")
end
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(
controls.playerPlates and L("Previewing - QuestTogether Player") or L("Previewing - Quest Mob")
)
end
end
function QuestTogether:RefreshOptionsWindow()
self:RefreshHomeWindow()
self:RefreshAnnouncementsWindow()
self:RefreshWhereToAnnounceWindow()
self:RefreshQuestPlatesWindow()
self:RefreshQuestPlatesWindow(true)
self:RefreshGroupsWindow()
self:RefreshPlayerLocationsWindow()
end
function QuestTogether:RefreshPlayerLocationsWindow()
if self.playerLocationsFrame then RefreshCheckboxOptions(self.playerLocationsControls, self) end
end
-- Summarize saved choices; the prominent runtime state distinguishes these
-- preferences from features currently running. No native player data is read.
function QuestTogether:GetHomeStatusGroups()
local function OnOff(key) return self:GetOption(key) and L("On") or L("Off") end
local function Line(label, value) return label .. ": " .. value end
local destination = self:GetChatLogDestinationLabel(self:GetOption("chatLogDestination"))
if self:GetOption("chatLogDestination") == "separate" and self:GetOption("mirrorChatLogsToMainChat") then
destination = destination .. L(" + Main Chat When Docked")
end
local general = Line(L("QuestTogether"), self.isEnabled and L("Enabled") or L("Disabled"))
.. "\n" .. Line(L("Active profile"), SafeText(self:GetCurrentProfileKey() or self.activeProfileKey, L("Unknown")))
.. "\n" .. Line(L("Version"), SafeText(self:GetAddonVersion(), L("Unknown")))
local update = self:GetAvailableAddonUpdate()
if update then general = general .. "\n" .. Line(L("Newer version detected"), SafeText(update)) end
if not self.isEnabled then general = general .. "\n" .. L("Saved preferences below apply when QuestTogether is enabled.") end
local locations = L("Off")
if self:GetOption("showPlayerLocations") then
locations = self:GetOption("onlyShowQuestPartners") and L("Questing partners only") or L("All QuestTogether players")
end
local invites = {}
if self:GetOption("autoInviteFriends") then invites[#invites + 1] = L("Friends who request to join") end
if self:GetOption("autoInviteWhileLFG") then invites[#invites + 1] = L("Other requests while looking for partners") end
local inviteText = #invites > 0 and table.concat(invites, "; ") or L("Ask first")
return {
{ title = L("General"), categoryKey = "profilesCategory", text = general },
{ title = L("Finding Partners"), categoryKey = "groupsCategory", text =
Line(L("Looking for Questing Partners"), OnOff("lookingForQuestPartners")) .. "\n"
.. Line(L("Automatic invitations"), inviteText) },
{ title = L("Player Locations"), categoryKey = "playerLocationsCategory", text =
Line(L("Share my location"), OnOff("sharePlayerLocation")) .. "\n"
.. Line(L("Show player locations"), locations) },
{ title = L("Quest Sharing"), categoryKey = "groupsCategory", text =
self:GetOption("autoAcceptPartyShareRequests") and L("Automatically approve party share requests") or L("Ask before sharing quests") },
{ title = L("Announcements"), categoryKey = "whereToAnnounceCategory", text =
Line(L("Show progress for"), SafeText(self:GetShowProgressForLabel(self:GetOption("showProgressFor")), L("Unknown"))) .. "\n"
.. Line(L("Chat logs"), self:GetOption("showChatLogs") and SafeText(destination) or L("Off")) .. "\n"
.. Line(L("Chat bubbles"), OnOff("showChatBubbles")) .. "\n"
.. Line(L("Party chat for non-QT members"), OnOff("announceToNonQTParty")) },
{ title = L("Quest Plates"), categoryKey = "questPlatesCategory", text =
Line(L("Quest icons"), OnOff("nameplateQuestIconEnabled")) .. "\n"
.. Line(L("Quest health tint"), OnOff("nameplateQuestHealthColorEnabled")) },
{ title = L("Player Plates"), categoryKey = "playerPlatesCategory", text =
Line(L("QuestTogether icons"), OnOff("nameplatePlayerIconEnabled")) },
}
end
function QuestTogether:RefreshHomeWindow()
if not self.optionsFrame then
return
end
local controls = self.homeControls
RefreshCheckboxOptions(controls, self)
if type(controls) ~= "table" then
return
end
if controls.statusGroups then
local groups = self:GetHomeStatusGroups()
local height = 36
for i, group in ipairs(groups) do
local row = controls.statusGroups[i]
row.text:SetText(group.text)
row.button:SetText(group.title .. " >")
row.categoryKey = group.categoryKey
local rowHeight = 26 + row.text:GetStringHeight()
row.frame:SetHeight(rowHeight)
height = height + rowHeight + 12
end
controls.statusPanel:SetHeight(math.max(304, height))
-- Include wrapped introduction/tips and the controls below both panels.
controls.content:SetHeight(math.max(304, height) + controls.description:GetStringHeight()
+ controls.tipsText:GetStringHeight() + 300)
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
if controls.qtChatScopeDropdown then
RefreshDropdownControl(controls.qtChatScopeDropdown, self:GetOption("qtChatScope") == "zone_only" and L("Zone Only") or L("Global"))
end
local showBubbleControls = self:GetOption("showChatBubbles") and true or false
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(playerPlates)
if not self[playerPlates and "playerPlatesFrame" or "questPlatesFrame"] then
return
end
local controls = self[playerPlates and "playerPlateControls" or "questPlateControls"]
RefreshCheckboxOptions(controls)
if controls.nameplateQuestIconStyleDropdown then
RefreshDropdownControl(
controls.nameplateQuestIconStyleDropdown,
self:GetNameplateQuestIconStyleLabel(
playerPlates and self:GetNameplatePlayerIconStyle() or self:GetNameplateQuestIconStyle()
)
)
end
if not controls.nameplateQuestHealthColor then
RefreshQuestPlatesPreview(controls)
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