Repository navigation
Expand file tree
/
Copy pathAddonWindow.lua
More file actions
1347 lines (1142 loc) · 48.1 KB
/
Copy pathAddonWindow.lua
File metadata and controls
1347 lines (1142 loc) · 48.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
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 L = addon.L
local frame = CreateFrame("Frame", "Level20Frame", UIParent, "DefaultPanelTemplate")
frame:SetSize(540, 292)
frame:SetPoint("CENTER")
frame:SetMovable(true)
frame:SetClampedToScreen(true)
frame:EnableMouse(true)
frame:SetToplevel(true)
frame:SetFrameStrata("DIALOG")
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnMouseDown", function(self)
self:Raise()
end)
frame:SetScript("OnDragStart", function(self)
self:Raise()
self:StartMoving()
end)
frame:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
local point, _, relativePoint, xOfs, yOfs = self:GetPoint()
Level20DB.windowPoint = point
Level20DB.windowRelativePoint = relativePoint
Level20DB.windowXOfs = xOfs
Level20DB.windowYOfs = yOfs
end)
frame:Hide()
frame:SetTitle(L.ADDON_TITLE)
function addon.SetMainWindowEscapeEnabled(enabled)
local frameName = frame:GetName()
for index = #UISpecialFrames, 1, -1 do
if UISpecialFrames[index] == frameName then
table.remove(UISpecialFrames, index)
end
end
if enabled then
table.insert(UISpecialFrames, frameName)
end
end
addon.SetMainWindowEscapeEnabled(true)
frame.CloseButton = CreateFrame("Button", nil, frame, "UIPanelCloseButtonDefaultAnchors")
local activeTab
local hiddenTabsUnlocked = false
local tabs = {}
local tabOrder = { "info", "settings", "waypoints", "dungeon", "cvars", "routes", "spectatorWarGame", "debug" }
local defaultTabKeys = { info = true, settings = true, waypoints = true, dungeon = true }
local hiddenTabKeys = { routes = true, spectatorWarGame = true, debug = true, cvars = true }
local defaultTabCount = 4
frame.tabPadding = 0
frame.minTabWidth = 64
frame.maxTabWidth = 96
local function CreateTab(parent, id, label, tabKey)
local button = CreateFrame("Button", parent:GetName() .. "Tab" .. id, parent, "PanelTabButtonTemplate")
button:SetID(id)
button:SetText(label)
button.tabKey = tabKey
tabs[tabKey] = button
parent.Tabs[id] = button
return button
end
frame.Tabs = {}
local infoTab = CreateTab(frame, 1, L.TAB_INFO, "info")
infoTab:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 18, -30)
CreateTab(frame, 2, L.TAB_SETTINGS, "settings")
CreateTab(frame, 3, L.TAB_WAYPOINTS, "waypoints")
CreateTab(frame, 4, L.TAB_DUNGEON, "dungeon")
local routesTab = CreateTab(frame, 5, L.TAB_ROUTES, "routes")
local spectatorWarGameTab = CreateTab(frame, 6, L.TAB_SPECTATOR_WARGAME, "spectatorWarGame")
local debugTab = CreateTab(frame, 7, L.TAB_DEBUG, "debug")
local cvarsTab = CreateTab(frame, 8, L.TAB_CVARS, "cvars")
routesTab:Hide()
spectatorWarGameTab:Hide()
debugTab:Hide()
cvarsTab:Hide()
PanelTemplates_SetNumTabs(frame, defaultTabCount)
local infoPanel = CreateFrame("Frame", nil, frame)
infoPanel:SetPoint("TOPLEFT", frame, "TOPLEFT", 20, -40)
infoPanel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -20, 20)
local settingsPanel = CreateFrame("Frame", nil, frame)
settingsPanel:SetPoint("TOPLEFT", infoPanel)
settingsPanel:SetPoint("BOTTOMRIGHT", infoPanel)
local settingsScrollFrame = CreateFrame("ScrollFrame", nil, settingsPanel, "ScrollFrameTemplate")
settingsScrollFrame:SetPoint("TOPLEFT", settingsPanel, "TOPLEFT", 4, -4)
settingsScrollFrame:SetPoint("BOTTOMRIGHT", settingsPanel, "BOTTOMRIGHT", -12, 4)
local settingsContent = CreateFrame("Frame", nil, settingsScrollFrame)
settingsContent:SetSize(1, 1)
settingsScrollFrame:SetScrollChild(settingsContent)
-- settingsScrollFrame.ScrollBar:SetHideIfUnscrollable(true)
settingsScrollFrame:SetScript("OnSizeChanged", function(self, width)
settingsContent:SetWidth(math.max(1, width))
end)
local waypointsPanel = CreateFrame("Frame", nil, frame)
waypointsPanel:SetPoint("TOPLEFT", infoPanel)
waypointsPanel:SetPoint("BOTTOMRIGHT", infoPanel)
local routesPanel = CreateFrame("Frame", nil, frame)
routesPanel:SetPoint("TOPLEFT", infoPanel)
routesPanel:SetPoint("BOTTOMRIGHT", infoPanel)
local dungeonPanel = CreateFrame("Frame", nil, frame)
dungeonPanel:SetPoint("TOPLEFT", infoPanel)
dungeonPanel:SetPoint("BOTTOMRIGHT", infoPanel)
local spectatorWarGamePanel = CreateFrame("Frame", nil, frame)
spectatorWarGamePanel:SetPoint("TOPLEFT", infoPanel)
spectatorWarGamePanel:SetPoint("BOTTOMRIGHT", infoPanel)
local debugPanel = CreateFrame("Frame", nil, frame)
debugPanel:SetPoint("TOPLEFT", infoPanel)
debugPanel:SetPoint("BOTTOMRIGHT", infoPanel)
local debugScrollFrame = CreateFrame("ScrollFrame", nil, debugPanel, "ScrollFrameTemplate")
debugScrollFrame:SetPoint("TOPLEFT", debugPanel, "TOPLEFT", 4, -4)
debugScrollFrame:SetPoint("BOTTOMRIGHT", debugPanel, "BOTTOMRIGHT", -12, 4)
local debugContent = CreateFrame("Frame", nil, debugScrollFrame)
debugContent:SetSize(1, 1)
debugScrollFrame:SetScrollChild(debugContent)
debugScrollFrame:SetScript("OnSizeChanged", function(self, width)
debugContent:SetWidth(math.max(1, width))
end)
local cvarsPanel = CreateFrame("Frame", nil, frame)
cvarsPanel:SetPoint("TOPLEFT", infoPanel)
cvarsPanel:SetPoint("BOTTOMRIGHT", infoPanel)
local cvarsScrollFrame = CreateFrame("ScrollFrame", nil, cvarsPanel, "ScrollFrameTemplate")
cvarsScrollFrame:SetPoint("TOPLEFT", cvarsPanel, "TOPLEFT", 4, -4)
cvarsScrollFrame:SetPoint("BOTTOMRIGHT", cvarsPanel, "BOTTOMRIGHT", -12, 4)
local cvarsContent = CreateFrame("Frame", nil, cvarsScrollFrame)
cvarsContent:SetSize(1, 1)
cvarsScrollFrame:SetScrollChild(cvarsContent)
cvarsScrollFrame:SetScript("OnSizeChanged", function(self, width)
cvarsContent:SetWidth(math.max(1, width))
end)
local function ResizeScrollContentToChildren(content, bottomPadding)
local contentTop = content:GetTop()
if not contentTop then
return
end
local height = 1
for _, child in ipairs({ content:GetChildren() }) do
if child:IsShown() then
local childBottom = child:GetBottom()
if childBottom then
height = math.max(height, contentTop - childBottom + (bottomPadding or 0))
end
end
end
content:SetHeight(math.ceil(height))
end
local function UpdateSettingsContentHeight()
ResizeScrollContentToChildren(settingsContent, 6)
settingsScrollFrame.ScrollBar:Update()
end
local function UpdateDebugContentHeight()
ResizeScrollContentToChildren(debugContent, 6)
debugScrollFrame.ScrollBar:Update()
end
local function UpdateCVarsContentHeight()
ResizeScrollContentToChildren(cvarsContent, 6)
cvarsScrollFrame.ScrollBar:Update()
end
local function CreateInfoRow(parent, label, previous)
local row = CreateFrame("Frame", nil, parent)
row:SetSize(330, 24)
if previous then
row:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 0, -8)
else
row:SetPoint("TOPLEFT", parent, "TOPLEFT", 0, 0)
end
row.label = row:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row.label:SetPoint("LEFT", row, "LEFT", 0, 0)
row.label:SetWidth(120)
row.label:SetJustifyH("LEFT")
row.label:SetText(label)
row.value = row:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
row.value:SetPoint("LEFT", row.label, "RIGHT", 12, 0)
row.value:SetPoint("RIGHT", row, "RIGHT", 0, 0)
row.value:SetJustifyH("LEFT")
row.value:SetText(L.UNKNOWN)
return row
end
local function CreateSectionFrame(parent, title, width, height)
local section = CreateFrame("Frame", nil, parent, "BackdropTemplate")
section:SetSize(width, height)
section:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 10,
insets = { left = 3, right = 3, top = 3, bottom = 3 },
})
section:SetBackdropColor(0.05, 0.05, 0.07, 0.35)
section:SetBackdropBorderColor(0.35, 0.35, 0.4, 1)
section.title = section:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
section.title:SetPoint("TOP", section, "TOP", 0, -12)
section.title:SetTextColor(1.0, 0.82, 0.0)
section.title:SetShadowColor(0, 0, 0, 1)
section.title:SetShadowOffset(1, -1)
section.title:SetText(title)
section.divider = section:CreateTexture(nil, "ARTWORK")
section.divider:SetHeight(1)
section.divider:SetPoint("TOPLEFT", section, "TOPLEFT", 12, -30)
section.divider:SetPoint("TOPRIGHT", section, "TOPRIGHT", -12, -30)
section.divider:SetColorTexture(1.0, 0.82, 0.0, 0.22)
return section
end
local accountTypeRow = CreateInfoRow(infoPanel, L.ACCOUNT_TYPE)
local subscriptionRow = CreateInfoRow(infoPanel, L.SUBSCRIPTION, accountTypeRow)
local xpGainRow = CreateInfoRow(infoPanel, L.XP_GAIN, subscriptionRow)
local chromieTimeRow = CreateInfoRow(infoPanel, L.CHROMIE_TIME, xpGainRow)
local shadowlandsRow = CreateInfoRow(infoPanel, L.SHADOWLANDS_STATE, chromieTimeRow)
local versionStatusLabel = infoPanel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
versionStatusLabel:SetPoint("TOPRIGHT", infoPanel, "TOPRIGHT", 0, 0)
versionStatusLabel:SetJustifyH("RIGHT")
versionStatusLabel:SetText(L.UNKNOWN)
local groupDataButton = CreateFrame("Button", nil, infoPanel, "UIPanelButtonTemplate")
groupDataButton:SetSize(140, 24)
groupDataButton:SetPoint("TOPLEFT", shadowlandsRow, "BOTTOMLEFT", 0, -12)
groupDataButton:SetText(L.GROUP_TRINKETS_BUTTON)
groupDataButton:SetScript("OnClick", function()
addon.GroupData.ShowWindow()
end)
local waypointData = {
{ labelKey = "WAYPOINT_CHROMIE", faction = "Alliance", mapID = 84, x = 56.26, y = 17.32 },
{ labelKey = "WAYPOINT_CHROMIE", faction = "Horde", mapID = 85, x = 40.82, y = 80.16 },
{ labelKey = "WAYPOINT_XP_STOP_BEHSTEN", faction = "Alliance", mapID = 84, x = 87.70, y = 36.09 },
{ labelKey = "WAYPOINT_XP_STOP_SLAHTZ", faction = "Horde", mapID = 85, x = 74.26, y = 44.32 },
{ labelKey = "WAYPOINT_LOREWALKER_CHO", faction = "Alliance", mapID = 84, x = 64.23, y = 16.12 },
{ labelKey = "WAYPOINT_LOREWALKER_CHO", faction = "Horde", mapID = 85, x = 54.25, y = 56.60 },
}
local function SetWaypoint(waypoint)
if not C_Map.CanSetUserWaypointOnMap(waypoint.mapID) then
print(L.CANNOT_SET_WAYPOINT)
return
end
local point = UiMapPoint.CreateFromCoordinates(waypoint.mapID, waypoint.x / 100, waypoint.y / 100)
C_Map.SetUserWaypoint(point)
C_SuperTrack.SetSuperTrackedUserWaypoint(true)
print(string.format(L.WAYPOINT_SET, L[waypoint.labelKey], waypoint.x, waypoint.y))
end
local function CreateWaypointButton(parent, waypoint)
local button = CreateFrame("Button", nil, parent, "UIPanelButtonTemplate")
button:SetSize(250, 24)
button:SetText(L[waypoint.labelKey])
button:SetScript("OnClick", function()
SetWaypoint(waypoint)
end)
return button
end
local waypointButtons = {}
local function RefreshWaypointButtons()
local faction = UnitFactionGroup("player")
local row = 0
for _, button in ipairs(waypointButtons) do
button:Hide()
end
for _, waypoint in ipairs(waypointData) do
if waypoint.faction == faction then
row = row + 1
local button = waypointButtons[row] or CreateWaypointButton(waypointsPanel, waypoint)
waypointButtons[row] = button
button:ClearAllPoints()
button:SetPoint("TOP", waypointsPanel, "TOP", 0, -((row - 1) * 34))
button:SetText(L[waypoint.labelKey])
button:SetScript("OnClick", function()
SetWaypoint(waypoint)
end)
button:Show()
end
end
end
local clearWaypointButton = CreateFrame("Button", nil, waypointsPanel, "UIPanelButtonTemplate")
clearWaypointButton:SetSize(250, 24)
clearWaypointButton:SetPoint("TOP", waypointsPanel, "TOP", 0, -114)
clearWaypointButton:SetText(L.CLEAR_WAYPOINT)
clearWaypointButton:SetScript("OnClick", function()
C_Map.ClearUserWaypoint()
print(L.WAYPOINT_CLEARED)
end)
local routesSection = CreateSectionFrame(routesPanel, L.ROUTE_OUTLAND, 500, 196)
routesSection:SetPoint("TOPLEFT", routesPanel, "TOPLEFT", 0, 0)
local routeFactionRow = CreateInfoRow(routesSection, L.ROUTE_FACTION_LABEL)
routeFactionRow:SetPoint("TOPLEFT", routesSection, "TOPLEFT", 12, -38)
routeFactionRow:SetWidth(470)
routeFactionRow.value:SetPoint("RIGHT", routeFactionRow, "RIGHT", 0, 0)
local routeMapRow = CreateInfoRow(routesSection, L.ROUTE_CURRENT_MAP_LABEL, routeFactionRow)
routeMapRow:SetWidth(470)
routeMapRow.value:SetPoint("RIGHT", routeMapRow, "RIGHT", 0, 0)
local routeDetectedPhaseRow = CreateInfoRow(routesSection, L.ROUTE_DETECTED_PHASE_LABEL, routeMapRow)
routeDetectedPhaseRow:SetWidth(470)
routeDetectedPhaseRow.value:SetPoint("RIGHT", routeDetectedPhaseRow, "RIGHT", 0, 0)
local routeNextStepRow = CreateInfoRow(routesSection, L.ROUTE_NEXT_STEP_LABEL, routeDetectedPhaseRow)
routeNextStepRow:SetWidth(470)
routeNextStepRow.value:SetPoint("RIGHT", routeNextStepRow, "RIGHT", 0, 0)
local routeStartButton = CreateFrame("Button", nil, routesSection, "UIPanelButtonTemplate")
routeStartButton:SetSize(220, 24)
routeStartButton:SetPoint("TOPLEFT", routeNextStepRow, "BOTTOMLEFT", 0, -10)
routeStartButton:SetText(L.ROUTE_START)
local debugRouteTaxiNodeDiffRow
local selectedRouteID = addon.Routes and addon.Routes.GetDefaultRouteID and addon.Routes.GetDefaultRouteID() or nil
routeStartButton:SetScript("OnClick", function()
if addon.Routes and addon.Routes.Toggle then
addon.Routes.Toggle(selectedRouteID)
end
addon.RefreshRoutesPanel()
end)
function addon.RefreshRoutesPanel(updateDiffBaseline)
if not addon.Routes or not addon.Routes.GetPanelState then
return
end
local routeState = addon.Routes.GetPanelState(selectedRouteID)
routesSection.title:SetText(routeState.title or L.ROUTE_OUTLAND)
routeFactionRow.value:SetText(routeState.faction or L.UNKNOWN)
routeMapRow.value:SetText(routeState.mapText or L.UNKNOWN)
routeDetectedPhaseRow.value:SetText(routeState.phaseText or L.UNKNOWN)
routeNextStepRow.value:SetText(routeState.nextStepText or L.UNKNOWN)
routeStartButton:SetText(routeState.active and L.ROUTE_STOP or L.ROUTE_START)
routeStartButton:SetEnabled(routeState.active or routeState.canStart)
if debugRouteTaxiNodeDiffRow and addon.Routes.GetDebugTaxiNodeDiff then
debugRouteTaxiNodeDiffRow.value:SetText(addon.Routes.GetDebugTaxiNodeDiff(updateDiffBaseline))
end
end
local spectatorWarGameControls = {}
local spectatorWarGameDropdownWidth = 330
local function CreateSpectatorWarGameRadio(rootDescription, option, isSelected, setSelected)
local radio = rootDescription:CreateRadio(option.label, isSelected, setSelected, option.value)
radio:AddInitializer(function(button)
local fontString = button.fontString or button.Text
if fontString then
fontString:SetWidth(spectatorWarGameDropdownWidth - 32)
fontString:SetWordWrap(false)
fontString:SetText(option.label)
end
end)
return radio
end
local function GetSpectatorWarGameLeaderLabel(value)
return value and value ~= "" and value or L.SPECTATOR_WARGAME_SELECT_FRIEND
end
local function GetSpectatorWarGameArenaLabel(value)
if not value or not addon.GetSpectatorWarGameArenaOptions then
return nil
end
for _, option in ipairs(addon.GetSpectatorWarGameArenaOptions()) do
if option.value == value then
return option.label
end
end
return nil
end
local function CreateSpectatorWarGameFriendDropdown(parent, label, dbKey, previous)
local row = CreateFrame("Frame", nil, parent)
row:SetSize(430, 30)
if previous then
row:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 0, -10)
else
row:SetPoint("TOPLEFT", parent, "TOPLEFT", 22, -18)
end
row.Text = row:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row.Text:SetPoint("LEFT", row, "LEFT", 0, 0)
row.Text:SetWidth(90)
row.Text:SetJustifyH("LEFT")
row.Text:SetText(label)
row.Dropdown = CreateFrame("DropdownButton", nil, row, "WowStyle1DropdownTemplate")
row.Dropdown:SetPoint("LEFT", row.Text, "RIGHT", 8, 0)
row.Dropdown:SetWidth(spectatorWarGameDropdownWidth)
if row.Dropdown.SetSelectionText then
row.Dropdown:SetSelectionText(function()
return GetSpectatorWarGameLeaderLabel(Level20DB[dbKey])
end)
end
local function IsSelected(value)
return Level20DB[dbKey] == value
end
local function SetSelected(value)
Level20DB[dbKey] = value
addon.RefreshSpectatorWarGamePanel()
end
row.Dropdown:SetupMenu(function(dropdown, rootDescription)
rootDescription:SetTag("LEVEL20_SPECTATOR_WARGAME_" .. dbKey)
rootDescription:SetMinimumWidth(spectatorWarGameDropdownWidth)
local options = addon.GetSpectatorWarGameBNetFriendOptions and addon.GetSpectatorWarGameBNetFriendOptions() or {}
if #options == 0 then
rootDescription:CreateTitle(L.SPECTATOR_WARGAME_NO_BNET_FRIENDS)
return
end
for _, option in ipairs(options) do
CreateSpectatorWarGameRadio(rootDescription, option, IsSelected, SetSelected)
end
end)
function row:Refresh()
local value = GetSpectatorWarGameLeaderLabel(Level20DB[dbKey])
if self.Dropdown.SetDefaultText then
self.Dropdown:SetDefaultText(value)
end
end
table.insert(spectatorWarGameControls, row)
return row
end
local function CreateSpectatorWarGameArenaDropdown(parent, previous)
local row = CreateFrame("Frame", nil, parent)
row:SetSize(430, 30)
row:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 0, -10)
row.Text = row:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row.Text:SetPoint("LEFT", row, "LEFT", 0, 0)
row.Text:SetWidth(90)
row.Text:SetJustifyH("LEFT")
row.Text:SetText(L.SPECTATOR_WARGAME_ARENA)
row.Dropdown = CreateFrame("DropdownButton", nil, row, "WowStyle1DropdownTemplate")
row.Dropdown:SetPoint("LEFT", row.Text, "RIGHT", 8, 0)
row.Dropdown:SetWidth(spectatorWarGameDropdownWidth)
if row.Dropdown.SetSelectionText then
row.Dropdown:SetSelectionText(function()
return GetSpectatorWarGameArenaLabel(Level20DB.spectatorWarGameArenaID) or L.SPECTATOR_WARGAME_SELECT_ARENA
end)
end
local function IsSelected(value)
return Level20DB.spectatorWarGameArenaID == value
end
local function SetSelected(value)
Level20DB.spectatorWarGameArenaID = value
addon.RefreshSpectatorWarGamePanel()
end
row.Dropdown:SetupMenu(function(dropdown, rootDescription)
rootDescription:SetTag("LEVEL20_SPECTATOR_WARGAME_ARENA")
rootDescription:SetMinimumWidth(spectatorWarGameDropdownWidth)
local options = addon.GetSpectatorWarGameArenaOptions and addon.GetSpectatorWarGameArenaOptions() or {}
if #options == 0 then
rootDescription:CreateTitle(L.SPECTATOR_WARGAME_NO_ARENAS)
return
end
for _, option in ipairs(options) do
CreateSpectatorWarGameRadio(rootDescription, option, IsSelected, SetSelected)
end
end)
function row:Refresh()
local value = GetSpectatorWarGameArenaLabel(Level20DB.spectatorWarGameArenaID) or L.SPECTATOR_WARGAME_SELECT_ARENA
if self.Dropdown.Text then
self.Dropdown.Text:SetWidth(spectatorWarGameDropdownWidth - 38)
end
if self.Dropdown.OverrideText then
self.Dropdown:OverrideText(value)
elseif self.Dropdown.SetDefaultText then
self.Dropdown:SetDefaultText(value)
end
end
table.insert(spectatorWarGameControls, row)
return row
end
local spectatorWarGameLeaderARow = CreateSpectatorWarGameFriendDropdown(spectatorWarGamePanel, L.SPECTATOR_WARGAME_LEADER_A, "spectatorWarGameLeaderA")
local spectatorWarGameLeaderBRow = CreateSpectatorWarGameFriendDropdown(spectatorWarGamePanel, L.SPECTATOR_WARGAME_LEADER_B, "spectatorWarGameLeaderB", spectatorWarGameLeaderARow)
local spectatorWarGameArenaRow = CreateSpectatorWarGameArenaDropdown(spectatorWarGamePanel, spectatorWarGameLeaderBRow)
local spectatorWarGameStartButton = CreateFrame("Button", nil, spectatorWarGamePanel, "UIPanelButtonTemplate")
spectatorWarGameStartButton:SetSize(180, 24)
spectatorWarGameStartButton:SetPoint("TOPLEFT", spectatorWarGameArenaRow, "BOTTOMLEFT", 98, -14)
spectatorWarGameStartButton:SetText(L.SPECTATOR_WARGAME_START_MATCH)
spectatorWarGameStartButton:SetScript("OnClick", function()
if not Level20DB.spectatorWarGameLeaderA or not Level20DB.spectatorWarGameLeaderB or not Level20DB.spectatorWarGameArenaID then
print(L.SPECTATOR_WARGAME_SELECT_REQUIRED)
return
end
addon.OpenSpectatorWarGameCommand(Level20DB.spectatorWarGameLeaderA, Level20DB.spectatorWarGameLeaderB, Level20DB.spectatorWarGameArenaID)
end)
local spectatorWarGameRefreshButton = CreateFrame("Button", nil, spectatorWarGamePanel, "UIPanelButtonTemplate")
spectatorWarGameRefreshButton:SetSize(180, 24)
spectatorWarGameRefreshButton:SetPoint("LEFT", spectatorWarGameStartButton, "RIGHT", 8, 0)
spectatorWarGameRefreshButton:SetText(L.SPECTATOR_WARGAME_REFRESH_FRIENDS)
spectatorWarGameRefreshButton:SetScript("OnClick", function()
addon.RefreshSpectatorWarGamePanel()
end)
function addon.RefreshSpectatorWarGamePanel()
local availableLeaders = {}
local options = addon.GetSpectatorWarGameBNetFriendOptions and addon.GetSpectatorWarGameBNetFriendOptions() or {}
for _, option in ipairs(options) do
availableLeaders[option.value] = true
end
local availableArenas = {}
local arenaOptions = addon.GetSpectatorWarGameArenaOptions and addon.GetSpectatorWarGameArenaOptions() or {}
for _, option in ipairs(arenaOptions) do
availableArenas[option.value] = true
end
if Level20DB.spectatorWarGameArenaID and not availableArenas[Level20DB.spectatorWarGameArenaID] then
Level20DB.spectatorWarGameArenaID = nil
end
if not Level20DB.spectatorWarGameArenaID and arenaOptions[1] then
Level20DB.spectatorWarGameArenaID = arenaOptions[1].value
end
for _, control in ipairs(spectatorWarGameControls) do
if control.Refresh then
control:Refresh()
end
end
local hasBothLeaders = availableLeaders[Level20DB.spectatorWarGameLeaderA]
and availableLeaders[Level20DB.spectatorWarGameLeaderB]
and Level20DB.spectatorWarGameLeaderA ~= Level20DB.spectatorWarGameLeaderB
local hasArena = Level20DB.spectatorWarGameArenaID and availableArenas[Level20DB.spectatorWarGameArenaID]
spectatorWarGameStartButton:SetEnabled(hasBothLeaders and hasArena and true or false)
end
local spectatorWarGameEventFrame = CreateFrame("Frame")
spectatorWarGameEventFrame:RegisterEvent("BN_FRIEND_LIST_SIZE_CHANGED")
spectatorWarGameEventFrame:RegisterEvent("BN_FRIEND_INFO_CHANGED")
spectatorWarGameEventFrame:RegisterEvent("BN_FRIEND_ACCOUNT_ONLINE")
spectatorWarGameEventFrame:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE")
spectatorWarGameEventFrame:SetScript("OnEvent", function()
if spectatorWarGamePanel:IsShown() then
addon.RefreshSpectatorWarGamePanel()
end
end)
local function GetAccountTypeText()
if IsTrialAccount() then
return L.ACCOUNT_TRIAL
end
if IsVeteranTrialAccount() then
return L.ACCOUNT_VETERAN
end
return L.ACCOUNT_STANDARD
end
local function GetSubscriptionText()
if addon.GroupData and addon.GroupData.HasActiveSubscription and not addon.GroupData.HasActiveSubscription() then
return L.SUBSCRIPTION_INACTIVE
end
return L.SUBSCRIPTION_ACTIVE
end
local function GetXPGainText()
return IsXPUserDisabled() and L.XP_DISABLED or L.XP_ENABLED
end
local function GetChromieTimeText()
local chromieText = addon.GroupData and addon.GroupData.GetChromieTimeText and addon.GroupData.GetChromieTimeText() or L.UNKNOWN
local warModeEnabled = C_PvP and C_PvP.IsWarModeDesired and C_PvP.IsWarModeDesired() or false
local lorewalkingActive = addon.IsLorewalkingActive and addon.IsLorewalkingActive() or false
return addon.GroupData and addon.GroupData.FormatChromieStatusText and addon.GroupData.FormatChromieStatusText(chromieText, warModeEnabled, lorewalkingActive) or chromieText
end
function addon.RefreshInfoPanel()
accountTypeRow.value:SetText(GetAccountTypeText())
subscriptionRow.value:SetText(GetSubscriptionText())
xpGainRow.value:SetText(GetXPGainText())
chromieTimeRow.value:SetText(GetChromieTimeText())
shadowlandsRow.value:SetText(addon.GetShadowlandsStateText())
versionStatusLabel:SetText(addon.GetVersionStatusText and addon.GetVersionStatusText() or L.UNKNOWN)
local red, green, blue = 1, 1, 1
if addon.GetVersionStatusColor then
red, green, blue = addon.GetVersionStatusColor()
end
versionStatusLabel:SetTextColor(red, green, blue)
end
local DUNGEON_SECTION_WIDTH = 244
local DUNGEON_SECTION_HEIGHT = 196
local DUNGEON_SECTION_GAP = 12
local DUNGEON_SECTION_INSET = 12
local DUNGEON_ROW_WIDTH = 220
local DUNGEON_BUTTON_WIDTH = 220
local DUNGEON_BUTTON_HEIGHT = 24
local DUNGEON_ROW_BUTTON_GAP = 12
local DUNGEON_BUTTON_GAP = 8
local dungeonRunSection = CreateSectionFrame(dungeonPanel, L.DUNGEON_CHALLENGE_RUN_SECTION, DUNGEON_SECTION_WIDTH, DUNGEON_SECTION_HEIGHT)
dungeonRunSection:SetPoint("TOPLEFT", dungeonPanel, "TOPLEFT", 0, 0)
local dungeonLoggingSection = CreateSectionFrame(dungeonPanel, L.DUNGEON_CHALLENGE_LOGGING_SECTION, DUNGEON_SECTION_WIDTH, DUNGEON_SECTION_HEIGHT)
dungeonLoggingSection:SetPoint("TOPLEFT", dungeonRunSection, "TOPRIGHT", DUNGEON_SECTION_GAP, 0)
local dungeonStatusRow = CreateInfoRow(dungeonRunSection, L.DUNGEON_CHALLENGE_STATUS_LABEL)
dungeonStatusRow:SetPoint("TOPLEFT", dungeonRunSection, "TOPLEFT", DUNGEON_SECTION_INSET, -34)
dungeonStatusRow:SetWidth(DUNGEON_ROW_WIDTH)
dungeonStatusRow.value:SetPoint("RIGHT", dungeonStatusRow, "RIGHT", 0, 0)
local dungeonTimerRow = CreateInfoRow(dungeonRunSection, L.DUNGEON_CHALLENGE_TIMER_LABEL, dungeonStatusRow)
dungeonTimerRow:SetWidth(DUNGEON_ROW_WIDTH)
dungeonTimerRow.value:SetPoint("RIGHT", dungeonTimerRow, "RIGHT", 0, 0)
local dungeonCombatLogRow = CreateInfoRow(dungeonLoggingSection, L.DUNGEON_CHALLENGE_COMBAT_LOG_LABEL)
dungeonCombatLogRow:SetPoint("TOPLEFT", dungeonLoggingSection, "TOPLEFT", DUNGEON_SECTION_INSET, -34)
dungeonCombatLogRow:SetWidth(DUNGEON_ROW_WIDTH)
dungeonCombatLogRow.label:SetWidth(128)
dungeonCombatLogRow.value:SetPoint("RIGHT", dungeonCombatLogRow, "RIGHT", 0, 0)
local dungeonAdvancedCombatLogRow = CreateInfoRow(dungeonLoggingSection, L.DUNGEON_CHALLENGE_ADVANCED_COMBAT_LOG_LABEL, dungeonCombatLogRow)
dungeonAdvancedCombatLogRow:SetWidth(DUNGEON_ROW_WIDTH)
dungeonAdvancedCombatLogRow.label:SetWidth(128)
dungeonAdvancedCombatLogRow.value:SetPoint("RIGHT", dungeonAdvancedCombatLogRow, "RIGHT", 0, 0)
local resetDungeonTimerButton = CreateFrame("Button", nil, dungeonRunSection, "UIPanelButtonTemplate")
resetDungeonTimerButton:SetSize(DUNGEON_BUTTON_WIDTH, DUNGEON_BUTTON_HEIGHT)
resetDungeonTimerButton:SetPoint("TOPLEFT", dungeonTimerRow, "BOTTOMLEFT", 0, -DUNGEON_ROW_BUTTON_GAP)
resetDungeonTimerButton:SetScript("OnClick", function()
local challenge = addon.DungeonChallenge
local isStarted = challenge and challenge.IsTimerStarted and challenge.IsTimerStarted()
local isStopped = challenge and challenge.IsTimerStopped and challenge.IsTimerStopped()
if not isStarted then
challenge.startTimer()
elseif isStopped then
challenge.resetTimer()
else
challenge.completeRun()
end
addon.RefreshDungeonPanel()
end)
local guildStartDungeonTimerButton = CreateFrame("Button", nil, dungeonRunSection, "UIPanelButtonTemplate")
guildStartDungeonTimerButton:SetSize(DUNGEON_BUTTON_WIDTH, DUNGEON_BUTTON_HEIGHT)
guildStartDungeonTimerButton:SetPoint("TOPLEFT", resetDungeonTimerButton, "BOTTOMLEFT", 0, -DUNGEON_BUTTON_GAP)
guildStartDungeonTimerButton:SetText(L.DUNGEON_CHALLENGE_GUILD_START_SEND)
guildStartDungeonTimerButton:SetScript("OnClick", function()
if addon.DungeonChallenge.SendGuildStartCommand() then
print(L.DUNGEON_CHALLENGE_GUILD_START_SENT)
else
print(L.DUNGEON_CHALLENGE_GUILD_START_FAILED)
end
addon.RefreshDungeonPanel()
end)
local toggleCombatLogButton = CreateFrame("Button", nil, dungeonLoggingSection, "UIPanelButtonTemplate")
toggleCombatLogButton:SetSize(DUNGEON_BUTTON_WIDTH, DUNGEON_BUTTON_HEIGHT)
toggleCombatLogButton:SetPoint("TOPLEFT", dungeonAdvancedCombatLogRow, "BOTTOMLEFT", 0, -DUNGEON_ROW_BUTTON_GAP)
local toggleAdvancedCombatLogButton = CreateFrame("Button", nil, dungeonLoggingSection, "UIPanelButtonTemplate")
toggleAdvancedCombatLogButton:SetSize(DUNGEON_BUTTON_WIDTH, DUNGEON_BUTTON_HEIGHT)
toggleAdvancedCombatLogButton:SetPoint("TOPLEFT", toggleCombatLogButton, "BOTTOMLEFT", 0, -DUNGEON_BUTTON_GAP)
local function FormatDuration(seconds)
seconds = math.max(0, math.floor(seconds or 0))
return string.format("%d:%02d", math.floor(seconds / 60), seconds % 60)
end
function addon.RefreshDungeonPanel()
local challenge = addon.DungeonChallenge
local isActive = challenge and challenge.ShouldUse and challenge.ShouldUse()
local isStarted = challenge and challenge.IsTimerStarted and challenge.IsTimerStarted()
local isStopped = challenge and challenge.IsTimerStopped and challenge.IsTimerStopped()
dungeonStatusRow.value:SetText(isActive and L.STATE_ENABLED or L.STATE_DISABLED)
dungeonTimerRow.value:SetText(FormatDuration(challenge and challenge.GetElapsedTime and challenge.GetElapsedTime() or 0))
dungeonCombatLogRow.value:SetText(challenge and challenge.GetCombatLogStatusText and challenge.GetCombatLogStatusText() or L.UNKNOWN)
dungeonAdvancedCombatLogRow.value:SetText(challenge and challenge.GetAdvancedCombatLogStatusText and challenge.GetAdvancedCombatLogStatusText() or L.UNKNOWN)
if not isStarted then
resetDungeonTimerButton:SetText(L.DUNGEON_CHALLENGE_START_RUN)
elseif isStopped then
resetDungeonTimerButton:SetText(L.DUNGEON_CHALLENGE_RESET_TIMER)
else
resetDungeonTimerButton:SetText(L.DUNGEON_CHALLENGE_COMPLETE_RUN)
end
resetDungeonTimerButton:SetEnabled(isActive and not InCombatLockdown())
guildStartDungeonTimerButton:SetEnabled(not InCombatLockdown() and IsInGuild())
toggleCombatLogButton:SetText(challenge and challenge.GetCombatLogToggleLabel and challenge.GetCombatLogToggleLabel() or L.DUNGEON_CHALLENGE_COMBAT_LOG_START)
toggleCombatLogButton:SetEnabled(challenge and challenge.CanControlCombatLog and challenge.CanControlCombatLog())
toggleAdvancedCombatLogButton:SetText(challenge and challenge.GetAdvancedCombatLogToggleLabel and challenge.GetAdvancedCombatLogToggleLabel() or L.DUNGEON_CHALLENGE_ADVANCED_COMBAT_LOG_START)
toggleAdvancedCombatLogButton:SetEnabled(challenge and challenge.CanControlAdvancedCombatLog and challenge.CanControlAdvancedCombatLog())
end
local dungeonPanelRefreshElapsed = 0
dungeonPanel:SetScript("OnUpdate", function(_, elapsed)
if activeTab ~= "dungeon" then
return
end
dungeonPanelRefreshElapsed = dungeonPanelRefreshElapsed + elapsed
if dungeonPanelRefreshElapsed >= 1 then
dungeonPanelRefreshElapsed = 0
addon.RefreshDungeonPanel()
end
end)
local function ShowTab(tab)
local availableTabs = hiddenTabsUnlocked and hiddenTabKeys or defaultTabKeys
if tabs[tab] and availableTabs[tab] then
activeTab = tab
else
activeTab = hiddenTabsUnlocked and "cvars" or "info"
end
PanelTemplates_SetTab(frame, tabs[activeTab]:GetID())
infoPanel:SetShown(activeTab == "info")
settingsPanel:SetShown(activeTab == "settings")
waypointsPanel:SetShown(activeTab == "waypoints")
routesPanel:SetShown(activeTab == "routes")
dungeonPanel:SetShown(activeTab == "dungeon")
spectatorWarGamePanel:SetShown(activeTab == "spectatorWarGame")
debugPanel:SetShown(activeTab == "debug")
cvarsPanel:SetShown(activeTab == "cvars")
if activeTab == "info" then
addon.RefreshInfoPanel()
elseif activeTab == "settings" then
addon.RefreshWindow()
UpdateSettingsContentHeight()
elseif activeTab == "waypoints" then
RefreshWaypointButtons()
elseif activeTab == "routes" then
addon.RefreshRoutesPanel()
elseif activeTab == "dungeon" then
addon.RefreshDungeonPanel()
elseif activeTab == "spectatorWarGame" then
addon.RefreshSpectatorWarGamePanel()
elseif activeTab == "debug" then
addon.RefreshWindow()
UpdateDebugContentHeight()
elseif activeTab == "cvars" then
addon.RefreshDebugCVarCheckboxes()
UpdateCVarsContentHeight()
end
end
local function SetHiddenTabMode(enabled)
hiddenTabsUnlocked = enabled and true or false
local visibleTabs = hiddenTabsUnlocked and hiddenTabKeys or defaultTabKeys
local previousTab
PanelTemplates_SetNumTabs(frame, #tabOrder)
for _, tabKey in ipairs(tabOrder) do
local tab = tabs[tabKey]
local shown = visibleTabs[tabKey] and true or false
tab:SetShown(shown)
tab:ClearAllPoints()
if shown then
if previousTab then
tab:SetPoint("TOPLEFT", previousTab, "TOPRIGHT", 3, 0)
else
tab:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 18, -30)
end
previousTab = tab
end
end
end
frame:HookScript("OnHide", function()
SetHiddenTabMode(false)
end)
for _, tabKey in ipairs(tabOrder) do
tabs[tabKey]:SetScript("OnClick", function(self)
ShowTab(self.tabKey)
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB)
end)
end
local function ReportCompletionBannerResult(ok, err)
if ok then
print(L.DUNGEON_CHALLENGE_COMPLETION_COMMAND)
else
print(L.DUNGEON_CHALLENGE_COMPLETION_ERROR:format(tostring(err or "unknown error")))
end
end
local function CreateCheckbox(parent, label, tooltip, onClick)
local checkbox = CreateFrame("CheckButton", nil, parent, "MinimalCheckboxTemplate")
checkbox:SetHitRectInsets(0, -340, 0, 0)
checkbox.Text = checkbox:CreateFontString(nil, "OVERLAY", "GameFontNormal")
checkbox.Text:SetPoint("LEFT", checkbox, "RIGHT", 4, 0)
checkbox.Text:SetText(label)
checkbox.Text:SetJustifyH("LEFT")
checkbox:SetScript("OnClick", function(self)
onClick(self:GetChecked())
addon.RefreshWindow()
end)
checkbox:SetScript("OnEnter", function(self)
if tooltip then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(label, 1, 1, 1)
GameTooltip_AddNormalLine(GameTooltip, tooltip)
GameTooltip:Show()
end
end)
checkbox:SetScript("OnLeave", GameTooltip_Hide)
return checkbox
end
local enemyForcesModeOptions = {
{
mode = addon.ENEMY_FORCES_MODE_DISABLED,
label = L.DUNGEON_CHALLENGE_ENEMY_FORCES_MODE_DISABLED,
},
{
mode = addon.ENEMY_FORCES_MODE_REQUIRED,
label = L.DUNGEON_CHALLENGE_ENEMY_FORCES_MODE_REQUIRED,
},
{
mode = addon.ENEMY_FORCES_MODE_UNLIMITED,
label = L.DUNGEON_CHALLENGE_ENEMY_FORCES_MODE_UNLIMITED,
},
}
local function GetEnemyForcesModeLabel(mode)
for _, option in ipairs(enemyForcesModeOptions) do
if option.mode == mode then
return option.label
end
end
return L.DUNGEON_CHALLENGE_ENEMY_FORCES_MODE_DISABLED
end
local function NormalizeEnemyForcesMode(mode)
if mode == addon.ENEMY_FORCES_MODE_REQUIRED or mode == addon.ENEMY_FORCES_MODE_UNLIMITED then
return mode
end
return addon.ENEMY_FORCES_MODE_DISABLED
end
local function GetSelectedEnemyForcesMode()
return NormalizeEnemyForcesMode(Level20DB.enemyForcesMode)
end
local function SetSelectedEnemyForcesMode(mode)
Level20DB.enemyForcesMode = NormalizeEnemyForcesMode(mode)
if addon.DungeonChallenge and addon.DungeonChallenge.refresh then
addon.DungeonChallenge.refresh(Level20DB.showDungeonChallengeFrame)
end
end
local function CreateEnemyForcesModeDropdown(parent)
local row = CreateFrame("Frame", nil, parent)
row:SetSize(430, 26)
row.Text = row:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row.Text:SetPoint("LEFT", row, "LEFT", 0, 0)
row.Text:SetWidth(170)
row.Text:SetJustifyH("LEFT")
row.Text:SetText(L.DUNGEON_CHALLENGE_ENEMY_FORCES_SETTING_LABEL)
row.Dropdown = CreateFrame("DropdownButton", nil, row, "WowStyle1DropdownTemplate")
row.Dropdown:SetPoint("LEFT", row.Text, "RIGHT", 8, 0)
row.Dropdown:SetWidth(180)
if row.Dropdown.SetSelectionText then
row.Dropdown:SetSelectionText(function()
return GetEnemyForcesModeLabel(GetSelectedEnemyForcesMode())
end)
end
local function IsSelected(mode)
return GetSelectedEnemyForcesMode() == mode
end
local function SetSelected(mode)
SetSelectedEnemyForcesMode(mode)
addon.RefreshWindow()
end
row.Dropdown:SetupMenu(function(dropdown, rootDescription)
rootDescription:SetTag("LEVEL20_ENEMY_FORCES_MODE")
for _, option in ipairs(enemyForcesModeOptions) do
rootDescription:CreateRadio(option.label, IsSelected, SetSelected, option.mode)
end
end)
row:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(L.DUNGEON_CHALLENGE_ENEMY_FORCES_SETTING_LABEL, 1, 1, 1)
GameTooltip_AddNormalLine(GameTooltip, L.DUNGEON_CHALLENGE_ENEMY_FORCES_SETTING_TOOLTIP)
GameTooltip:Show()
end)
row:SetScript("OnLeave", GameTooltip_Hide)
row.Dropdown:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(L.DUNGEON_CHALLENGE_ENEMY_FORCES_SETTING_LABEL, 1, 1, 1)
GameTooltip_AddNormalLine(GameTooltip, L.DUNGEON_CHALLENGE_ENEMY_FORCES_SETTING_TOOLTIP)
GameTooltip:Show()
end)
row.Dropdown:SetScript("OnLeave", GameTooltip_Hide)
function row:Refresh()
local label = GetEnemyForcesModeLabel(GetSelectedEnemyForcesMode())
if self.Dropdown.SetDefaultText then
self.Dropdown:SetDefaultText(label)
end
end
return row
end
toggleCombatLogButton:SetScript("OnClick", function()
addon.DungeonChallenge.ToggleCombatLog()
addon.RefreshDungeonPanel()
if addon.RefreshCombatLogWarning then
addon.RefreshCombatLogWarning()
end
end)
toggleAdvancedCombatLogButton:SetScript("OnClick", function()
addon.DungeonChallenge.ToggleAdvancedCombatLog()
addon.RefreshDungeonPanel()
if addon.RefreshCombatLogWarning then
addon.RefreshCombatLogWarning()
end