-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathgui.lua
More file actions
1336 lines (1168 loc) · 41.5 KB
/
Copy pathgui.lua
File metadata and controls
1336 lines (1168 loc) · 41.5 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 _, MySlot = ...
local L = MySlot.L
local RegEvent = MySlot.regevent
local MAX_PROFILES_COUNT = 100
local IMPORT_BACKUP_COUNT = 3
local f = CreateFrame("Frame", nil, UIParent, BackdropTemplateMixin and "BackdropTemplate" or nil)
f:SetWidth(650)
f:SetHeight(600)
f:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
tile = true,
tileSize = 32,
edgeSize = 32,
insets = {left = 8, right = 8, top = 10, bottom = 10}
})
f:SetBackdropColor(0, 0, 0)
f:SetPoint("CENTER", 0, 0)
f:SetToplevel(true)
f:EnableMouse(true)
f:SetMovable(true)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", f.StartMoving)
f:SetScript("OnDragStop", f.StopMovingOrSizing)
f:SetScript("OnKeyDown", function (_, key)
if key == "ESCAPE" then
f:Hide()
end
end)
f:Hide()
MySlot.MainFrame = f
-- {{{ Import progress bar
-- Shown while a large profile is restored. RecoverData now runs across frames
-- (MySlot:RunAsync) so it can't trip the "script ran too long" watchdog on big
-- profiles (notably WoW Classic Era 1.15, which has a stricter script budget).
local progressFrame = CreateFrame("Frame", nil, UIParent, BackdropTemplateMixin and "BackdropTemplate" or nil)
progressFrame:SetSize(360, 70)
progressFrame:SetPoint("CENTER", 0, 0)
progressFrame:SetFrameStrata("FULLSCREEN_DIALOG")
progressFrame:SetToplevel(true)
progressFrame:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
tile = true,
tileSize = 32,
edgeSize = 32,
insets = {left = 8, right = 8, top = 8, bottom = 8}
})
progressFrame:SetBackdropColor(0, 0, 0)
progressFrame:Hide()
local progressText = progressFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
progressText:SetPoint("TOP", 0, -14)
local progressBar = CreateFrame("StatusBar", nil, progressFrame)
progressBar:SetSize(320, 18)
progressBar:SetPoint("BOTTOM", 0, 16)
progressBar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
progressBar:SetStatusBarColor(0.2, 0.6, 1.0)
progressBar:SetMinMaxValues(0, 1)
progressBar:SetValue(0)
local progressBg = progressBar:CreateTexture(nil, "BACKGROUND")
progressBg:SetAllPoints(progressBar)
progressBg:SetColorTexture(0, 0, 0, 0.6)
local function ShowImportProgress()
progressBar:SetValue(0)
progressText:SetText(L["Importing..."])
progressFrame:Show()
end
local function SetImportProgress(frac)
frac = frac or 0
if frac < 0 then frac = 0 elseif frac > 1 then frac = 1 end
progressBar:SetValue(frac)
progressText:SetText(("%s %d%%"):format(L["Importing..."], math.floor(frac * 100 + 0.5)))
end
local function HideImportProgress(ok)
progressFrame:Hide()
if ok == false then
MySlot:Print(L["Import failed"])
end
end
-- }}}
local menuFrame = CreateFrame("Frame", nil, UIParent, "UIDropDownMenuTemplate")
-- title
do
local t = f:CreateTexture(nil, "ARTWORK")
t:SetTexture("Interface/DialogFrame/UI-DialogBox-Header")
t:SetWidth(256)
t:SetHeight(64)
t:SetPoint("TOP", f, 0, 12)
f.texture = t
end
do
local t = f:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
t:SetText(L["Myslot"])
t:SetPoint("TOP", f.texture, 0, -14)
end
local exportEditbox
-- options
do
local b = CreateFrame("Button", nil, f, "GameMenuButtonTemplate")
b:SetWidth(100)
b:SetHeight(25)
b:SetPoint("BOTTOMRIGHT", -145, 15)
b:SetText(OPTIONS)
b:SetScript("OnClick", function()
Settings.OpenToCategory(MySlot.settingcategory.ID)
end)
end
-- close
do
local b = CreateFrame("Button", nil, f, "GameMenuButtonTemplate")
b:SetWidth(100)
b:SetHeight(25)
b:SetPoint("BOTTOMRIGHT", -40, 15)
b:SetText(CLOSE)
b:SetScript("OnClick", function() f:Hide() end)
end
local function CreateSettingMenu(opt, onChanged)
local tableref = function (name)
if name == "action" then
return opt.ignoreActionBars
end
-- if name == "binding" then
-- return opt.ignoreBindings
-- end
if name == "macro" then
return opt.ignoreMacros
end
end
local childchecked = function (self)
return tableref(self.arg1)[self.arg2]
end
local childclicked = function (self)
local t = tableref(self.arg1)
t[self.arg2] = not t[self.arg2]
UIDropDownMenu_RefreshAll(menuFrame)
if onChanged then
onChanged()
end
end
local parentchecked = function (self)
local t = tableref(self.arg1)
for _, v in pairs(t) do
if v then
return true
end
end
return false
end
local parentclicked = function (self)
local checkedany = parentchecked(self)
local t = tableref(self.arg1)
for i in pairs(t) do
t[i] = not checkedany
end
UIDropDownMenu_RefreshAll(menuFrame)
if onChanged then
onChanged()
end
end
opt.ignoreActionBars = opt.ignoreActionBars or {
[1] = false,
[2] = false,
[3] = false,
[4] = false,
[5] = false,
[6] = false,
[7] = false,
[8] = false,
[9] = false,
[10] = false,
[11] = false,
[12] = false,
[13] = false,
[14] = false,
[15] = false,
}
opt.ignoreBinding = false
-- opt.ignoreBindings = opt.ignoreBindings or {}
opt.ignoreMacros = opt.ignoreMacros or {
["ACCOUNT"] = false,
["CHARACTOR"] = false,
}
opt.ignorePetActionBar = false
opt.ignoreCooldownManager = false
opt.ignoreClickBindings = false
-- https://warcraft.wiki.gg/wiki/Action_slot
local actionbarlist = {
{
text = L["Main Action Bar Page"] .. " 1",
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = 1,
checked = childchecked,
func = childclicked,
},
{
text = L["Main Action Bar Page"] .. " 2",
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = 2,
checked = childchecked,
func = childclicked,
},
{
text = OPTION_SHOW_ACTION_BAR:format(2), -- MultiBarBottomLeft
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = BOTTOMLEFT_ACTIONBAR_PAGE,
checked = childchecked,
func = childclicked,
},
{
text = OPTION_SHOW_ACTION_BAR:format(3), -- MultiBarBottomRight
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = BOTTOMRIGHT_ACTIONBAR_PAGE,
checked = childchecked,
func = childclicked,
},
{
text = OPTION_SHOW_ACTION_BAR:format(4), -- MultiBarRight
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = RIGHT_ACTIONBAR_PAGE,
checked = childchecked,
func = childclicked,
},
{
text = OPTION_SHOW_ACTION_BAR:format(5), -- MultiBarLeft
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = LEFT_ACTIONBAR_PAGE,
checked = childchecked,
func = childclicked,
},
}
if MULTIBAR_5_ACTIONBAR_PAGE then
table.insert(actionbarlist, {
text = OPTION_SHOW_ACTION_BAR:format(6),
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = MULTIBAR_5_ACTIONBAR_PAGE,
checked = childchecked,
func = childclicked,
})
end
if MULTIBAR_6_ACTIONBAR_PAGE then
table.insert(actionbarlist, {
text = OPTION_SHOW_ACTION_BAR:format(7),
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = MULTIBAR_6_ACTIONBAR_PAGE,
checked = childchecked,
func = childclicked,
})
end
if MULTIBAR_7_ACTIONBAR_PAGE then
table.insert(actionbarlist, {
text = OPTION_SHOW_ACTION_BAR:format(8),
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = MULTIBAR_7_ACTIONBAR_PAGE,
checked = childchecked,
func = childclicked,
})
end
-- 10.0
if select(4, GetBuildInfo()) > 100000 then
table.insert(actionbarlist, {
text = L["Skyriding Bar"],
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = 11,
checked = childchecked,
func = childclicked,
})
end
for i = 1, 4 do
-- local _, _, _, spell = GetShapeshiftFormInfo(i)
-- TODO better name
-- if spell then
table.insert(actionbarlist, {
text = L["Stance Action Bar"] .. " " .. i,
isNotRadio = true,
keepShownOnClick = true,
arg1 = "action",
arg2 = 6 + i,
checked = childchecked,
func = childclicked,
})
-- end
end
local menu = {
{
text = ACTIONBARS_LABEL,
hasArrow = true,
notCheckable = false,
isNotRadio = true,
keepShownOnClick = true,
menuList = actionbarlist,
func = parentclicked,
checked = parentchecked,
arg1 = "action",
}, -- 1
{
text = L["Key Binding"],
notCheckable = false,
isNotRadio = true,
keepShownOnClick = true,
func = function ()
opt.ignoreBinding = not opt.ignoreBinding
if onChanged then
onChanged()
end
end,
checked = function ()
return opt.ignoreBinding
end,
}, -- 2
{
text = MACRO,
hasArrow = true,
notCheckable = false,
isNotRadio = true,
keepShownOnClick = true,
func = parentclicked,
checked = parentchecked,
arg1 = "macro",
menuList = {
{
text = GENERAL_MACROS,
isNotRadio = true,
keepShownOnClick = true,
arg1 = "macro",
arg2 = "ACCOUNT",
checked = childchecked,
func = childclicked,
},
{
text = CHARACTER_SPECIFIC_MACROS:format(""),
isNotRadio = true,
keepShownOnClick = true,
arg1 = "macro",
arg2 = "CHARACTOR",
checked = childchecked,
func = childclicked,
},
}
}, -- 3
{
text = PET .. " " .. ACTIONBARS_LABEL,
notCheckable = false,
isNotRadio = true,
keepShownOnClick = true,
func = function ()
opt.ignorePetActionBar = not opt.ignorePetActionBar
if onChanged then
onChanged()
end
end,
checked = function ()
return opt.ignorePetActionBar
end,
}, -- 4
{
text = L["Cooldown Manager"],
notCheckable = false,
isNotRadio = true,
keepShownOnClick = true,
func = function ()
opt.ignoreCooldownManager = not opt.ignoreCooldownManager
if onChanged then
onChanged()
end
end,
checked = function ()
return opt.ignoreCooldownManager
end,
}, -- 5
{
text = L["Click Cast Bindings"],
notCheckable = false,
isNotRadio = true,
keepShownOnClick = true,
func = function ()
opt.ignoreClickBindings = not opt.ignoreClickBindings
if onChanged then
onChanged()
end
end,
checked = function ()
return opt.ignoreClickBindings
end,
}, -- 6
}
-- Some categories are retail-only; drop their entries where the client
-- doesn't support them (e.g. Classic) so we never offer an option that
-- can't apply.
local unsupported = {}
if not MySlot:IsCooldownManagerSupported() then
unsupported[L["Cooldown Manager"]] = true
end
if not MySlot:IsClickBindingSupported() then
unsupported[L["Click Cast Bindings"]] = true
end
if not MySlot:IsPetActionBarSupported() then
unsupported[PET .. " " .. ACTIONBARS_LABEL] = true
end
for i = #menu, 1, -1 do
if menu[i].text and unsupported[menu[i].text] then
table.remove(menu, i)
end
end
return menu
end
local function AllSettingMenuIgnored(opt)
if not opt then
return false
end
if not opt.ignoreActionBars then
return false
end
for _, v in pairs(opt.ignoreActionBars) do
if not v then
return false
end
end
if not opt.ignoreBinding then
return false
end
if not opt.ignoreMacros then
return false
end
for _, v in pairs(opt.ignoreMacros) do
if not v then
return false
end
end
if MySlot:IsPetActionBarSupported() and not opt.ignorePetActionBar then
return false
end
if MySlot:IsCooldownManagerSupported() and not opt.ignoreCooldownManager then
return false
end
if MySlot:IsClickBindingSupported() and not opt.ignoreClickBindings then
return false
end
return true
end
local function DrawMenu(root, menuData)
for _, m in ipairs(menuData) do
if m.isTitle then
root:CreateTitle(m.text)
else
local c = root:CreateCheckbox(m.text, m.checked, function ()
end, {
arg1 = m.arg1,
arg2 = m.arg2,
})
c:SetResponder(function(data, menuInputData, menu)
m.func({
arg1 = m.arg1,
arg2 = m.arg2,
})
-- Your handler here...
return MenuResponse.Refresh;
end)
if m.menuList then
DrawMenu(c, m.menuList)
end
end
end
end
-- Always use the modern Menu API (Blizzard_Menu ships on every flavor, 1.x ->
-- retail), so the import/export popups match the loadout dropdown's look.
local EasyMenu = function (settings, owner)
MenuUtil.CreateContextMenu(owner or UIParent, function(ownerRegion, rootDescription)
DrawMenu(rootDescription, settings)
end)
end
-- import
do
local actionOpt = {}
local clearOpt = {}
local forceImport = false
local b = CreateFrame("Button", nil, f, "GameMenuButtonTemplate")
b:SetWidth(125)
b:SetHeight(25)
b:SetPoint("BOTTOMLEFT", 200, 15)
b:SetText(L["Import"])
b:SetScript("OnClick", function()
local msg = MySlot:Import(exportEditbox:GetText(), {
force = forceImport,
})
if not msg then
return
end
StaticPopupDialogs["MYSLOT_MSGBOX"].OnAccept = function()
StaticPopup_Hide("MYSLOT_MSGBOX")
MySlot:Print(L["Starting backup..."])
local backup = MySlot:Export(actionOpt)
if not backup then
MySlot:Print(L["Backup failed"])
if not forceImport then
return
end
end
if backup then
table.insert(MyslotExports["backups"], { value = backup, time = time() })
while #MyslotExports["backups"] > IMPORT_BACKUP_COUNT do
table.remove(MyslotExports["backups"], 1)
end
end
MySlot:Clear("MACRO", clearOpt.ignoreMacros)
MySlot:Clear("ACTION", clearOpt.ignoreActionBars)
if clearOpt.ignoreBinding then
MySlot:Clear("BINDING")
end
if clearOpt.removeCooldownManager then
MySlot:Clear("COOLDOWNMANAGER")
end
if clearOpt.ignoreClickBindings then
MySlot:Clear("CLICKBINDING")
end
ShowImportProgress()
MySlot:RunAsync(function()
MySlot:RecoverData(msg, {
actionOpt = actionOpt,
clearOpt = clearOpt,
})
end, SetImportProgress, HideImportProgress)
end
StaticPopup_Show("MYSLOT_MSGBOX")
end)
local ba = CreateFrame("Button", nil, f, "GameMenuButtonTemplate")
ba:SetWidth(25)
ba:SetHeight(25)
ba:SetPoint("LEFT", b, "RIGHT", 0, 0)
ba:RegisterForClicks("LeftButtonUp", "RightButtonUp")
do
local icon = ba:CreateTexture(nil, 'ARTWORK')
icon:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
icon:SetPoint('CENTER', 1, 0)
icon:SetSize(16, 16)
end
local settings = {
{
isTitle = true,
text = "|cffff0000" .. L["IGNORE"] .. "|r" .. L[" during Import"],
notCheckable = true,
}
}
tAppendAll(settings, CreateSettingMenu(actionOpt))
local clearbegin = #settings + 1
tAppendAll(settings, {
{
isTitle = true,
text = "|cffff0000" .. L["CLEAR"] .. "|r" .. L[" before Import"],
notCheckable = true,
}
})
-- Pet Action Bar and Cooldown Manager have no per-category clear here (pet
-- isn't supported yet; cooldown is offered as an explicit "Remove all" below),
-- so drop them by identity rather than by position to stay robust against any
-- future change to CreateSettingMenu's entry order.
local clearMenu = CreateSettingMenu(clearOpt)
local clearExcludedText = {
[PET .. " " .. ACTIONBARS_LABEL] = true,
[L["Cooldown Manager"]] = true,
}
for i = #clearMenu, 1, -1 do
if clearMenu[i].text and clearExcludedText[clearMenu[i].text] then
table.remove(clearMenu, i)
end
end
tAppendAll(settings, clearMenu)
-- Cooldown Manager "remove all" only makes sense on clients that have it.
if MySlot:IsCooldownManagerSupported() then
tAppendAll(settings, {
{
text = L["Cooldown Manager"],
notCheckable = false,
isNotRadio = true,
keepShownOnClick = true,
func = function ()
clearOpt.removeCooldownManager = not clearOpt.removeCooldownManager
end,
checked = function ()
return clearOpt.removeCooldownManager
end,
},
})
end
local clearend = #settings
tAppendAll(settings, {
{
isTitle = true,
text = OTHER,
notCheckable = true,
},
{
text = L["Force Import"],
isNotRadio = true,
keepShownOnClick = true,
checked = function()
return forceImport
end,
func = function()
forceImport = not forceImport
end
}
})
local settingswithoutclear = {}
tAppendAll(settingswithoutclear, settings)
for i = clearend, clearbegin, -1 do
table.remove(settingswithoutclear, i)
end
ba:SetScript("OnClick", function(self, button)
EasyMenu(MyslotSettings.allowclearonimport and settings or settingswithoutclear, self);
end)
end
local infolabel
-- export
do
local actionOpt = {}
local b = CreateFrame("Button", nil, f, "GameMenuButtonTemplate")
b:SetWidth(125)
b:SetHeight(25)
b:SetPoint("BOTTOMLEFT", 40, 15)
b:SetText(L["Export"])
local function UpdateExportButtonState()
if AllSettingMenuIgnored(actionOpt) then
b:Disable()
else
b:Enable()
end
end
b:SetScript("OnClick", function()
local s = MySlot:Export(actionOpt)
exportEditbox:SetText(s)
infolabel.ShowUnsaved()
end)
local ba = CreateFrame("Button", nil, f, "GameMenuButtonTemplate")
ba:SetWidth(25)
ba:SetHeight(25)
ba:SetPoint("LEFT", b, "RIGHT", 0, 0)
ba:RegisterForClicks("LeftButtonUp", "RightButtonUp")
do
local icon = ba:CreateTexture(nil, 'ARTWORK')
icon:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
icon:SetPoint('CENTER', 1, 0)
icon:SetSize(16, 16)
end
local settings = {
{
isTitle = true,
text = "|cffff0000" .. L["IGNORE"] .. "|r" .. L[" during Export"],
notCheckable = true,
}
}
tAppendAll(settings, CreateSettingMenu(actionOpt, UpdateExportButtonState))
UpdateExportButtonState()
ba:SetScript("OnClick", function(self, button)
EasyMenu(settings, self);
end)
end
RegEvent("ADDON_LOADED", function()
do
local t = CreateFrame("Frame", nil, f, BackdropTemplateMixin and "BackdropTemplate" or nil)
t:SetWidth(600)
t:SetHeight(455)
t:SetPoint("TOPLEFT", f, 25, -75)
t:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true,
tileEdge = true,
tileSize = 16,
edgeSize = 16,
insets = { left = -2, right = -2, top = -2, bottom = -2 },
})
t:SetBackdropColor(0, 0, 0, 0)
local s = CreateFrame("ScrollFrame", nil, t, "UIPanelScrollFrameTemplate")
s:SetWidth(560)
s:SetHeight(440)
s:SetPoint("TOPLEFT", 10, -10)
local edit = CreateFrame("EditBox", nil, s)
s.cursorOffset = 0
edit:SetWidth(550)
s:SetScrollChild(edit)
edit:SetAutoFocus(false)
edit:EnableMouse(true)
edit:SetMaxLetters(99999999)
edit:SetMultiLine(true)
edit:SetFontObject(GameTooltipText)
edit:SetScript("OnEscapePressed", edit.ClearFocus)
edit:SetScript("OnMouseUp", function()
edit:HighlightText(0, -1)
end)
-- edit:SetScript("OnTextChanged", function()
-- infolabel:SetText(L["Unsaved"])
-- end)
edit:SetScript("OnTextSet", function()
edit.savedtxt = edit:GetText()
infolabel:SetText("")
end)
edit:SetScript("OnChar", function(self, c)
infolabel.ShowUnsaved()
end)
t:SetScript("OnMouseDown", function()
edit:SetFocus()
end)
exportEditbox = edit
end
do
-- Gold "binding button" look (UIMenuButtonStretchTemplate, the same family
-- as the keybinding selector). The menu itself is opened via
-- MenuUtil.CreateContextMenu on click, so its border matches the
-- import/export popups exactly.
local t = CreateFrame("Button", nil, f, "UIMenuButtonStretchTemplate")
t:SetPoint("TOPLEFT", f, 25, -45)
t:SetSize(240, 26)
-- Scroll icon on the left, downward dropdown arrow on the right.
do
local icon = t:CreateTexture(nil, "OVERLAY")
icon:SetTexture("Interface\\Icons\\inv_scroll_03")
icon:SetSize(18, 18)
icon:SetPoint("LEFT", t, "LEFT", 6, 0)
local arrow = t:CreateTexture(nil, "OVERLAY")
arrow:SetPoint("RIGHT", t, "RIGHT", -6, 0)
local atlas
for _, name in ipairs({ "common-dropdown-classic-a-buttonDown", "common-dropdown-a-buttonDown" }) do
if C_Texture and C_Texture.GetAtlasInfo and C_Texture.GetAtlasInfo(name) then
atlas = name
break
end
end
if atlas then
arrow:SetAtlas(atlas)
arrow:SetSize(16, 16)
else
-- Rotate the right-pointing expand arrow to point down.
arrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
arrow:SetSize(16, 16)
arrow:SetRotation(-math.pi / 2)
end
end
-- This template ships no text region, so add a left-aligned label of our
-- own, sitting between the scroll icon and the arrow.
local label = t:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetPoint("LEFT", t, "LEFT", 28, 0)
label:SetPoint("RIGHT", t, "RIGHT", -22, 0)
label:SetJustifyH("LEFT")
label:SetWordWrap(false)
-- Drives the gold button's label (selected loadout name). When nothing is
-- selected, show a greyed placeholder instead of an empty bar.
local function setButtonText(s)
if s and s ~= "" then
label:SetText(s)
label:SetTextColor(1, 0.82, 0)
else
label:SetText(L["Select a profile"])
label:SetTextColor(0.5, 0.5, 0.5)
end
end
do
local tt = t:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
tt:SetPoint("BOTTOMLEFT", t, "TOPLEFT", 20, 0)
tt.ShowUnsaved = function()
tt:SetText(YELLOW_FONT_COLOR:WrapTextInColorCode(L["Unsaved"]))
end
infolabel = tt
end
if not MyslotExports then
MyslotExports = {}
end
if not MyslotExports["exports"] then
MyslotExports["exports"] = {}
end
if not MyslotExports["backups"] then
MyslotExports["backups"] = {}
end
local exports = MyslotExports["exports"]
local backups = MyslotExports["backups"]
-- Currently selected loadout, identified by its storage index in
-- `exports`. The modern dropdown has no built-in selection model for our
-- index-as-identity scheme, so we track it ourselves and drive the text.
local selectedIdx
local function setSelected(idx)
selectedIdx = idx
setButtonText(idx and exports[idx] and exports[idx].name or "")
end
local function selectLoadout(idx)
setSelected(idx)
local v = exports[idx] and exports[idx].value or ""
exportEditbox:SetText(v)
end
-- Nothing is selected on load, so show the greyed placeholder immediately.
setSelected(nil)
local create = function(name)
if #exports >= MAX_PROFILES_COUNT then
MySlot:Print(L["Too many profiles, please delete before create new one."])
return
end
local txt = {
name = name,
class = select(2, UnitClass("player")),
}
table.insert(exports, txt)
return true
end
local save = function(force)
local c = selectedIdx
local v = exportEditbox:GetText()
if not force and v == "" then
return
end
if (not c) or (not exports[c]) then
local n = date()
if not create(n) then
return
end
c = #exports
setSelected(c)
end
exports[c].value = v
infolabel:SetText("")
end
-- Localized, class-colored label for a class group header. token may be
-- false/nil for the legacy/unknown group.
local function classHeaderText(token)
if not token then
return OTHER
end
local name = (LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[token]) or token
local color = RAID_CLASS_COLORS and RAID_CLASS_COLORS[token]
if color then
if color.WrapTextInColorCode then
return color:WrapTextInColorCode(name)
elseif color.colorStr then
return "|c" .. color.colorStr .. name .. "|r"
end
end
return name
end
local SORT_MODES = {
{ value = "date", text = L["By date"] },
{ value = "name", text = L["By name"] },
{ value = "class", text = L["By class"] },
}
-- Inline icon prefix so menu items carry the scroll icons the original
-- UIDropDownMenu put in the check slot (inv_scroll_03 for loadouts,
-- inv_scroll_04 for the pre-import backup).
local function withIcon(texture, text)
return ("|T%s:16:16|t %s"):format(texture, text)
end
-- Rebuilt every time the dropdown opens. A nil menu response is treated
-- as CloseAll, so both the filter checkbox and the sort radios explicitly
-- return MenuResponse.Refresh to reorder the list in place rather than
-- closing the menu (CreateRadio has no default Refresh; CreateCheckbox's
-- default varies, so we are explicit for cross-version safety).
local function generator(_, root)
root:CreateCheckbox(L["Only my class"], function()