forked from sylvanaar/addon-control-panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathACP.lua
2204 lines (1798 loc) · 61.3 KB
/
ACP.lua
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
--==============
-- Global Variables
--==============
ACP = {}
ACP_LINEHEIGHT = 16
ACP.CheckEvents = 0
ACP.TAGS = {
PART_OF = "X-Part-Of",
INTERFACE_MIN = "X-Min-Interface",
INTERFACE_MIN_ORG = "X-Since-Interface",
INTERFACE_MAX = "X-Max-Interface",
INTERFACE_MAX_ORG = "X-Compatible-With",
CHILD_OF = "X-Child-Of",
}
-- Handle various annoying special case names
function ACP:SpecialCaseName(name)
local partof = GetAddOnMetadata(name, ACP.TAGS.PART_OF)
if partof == nil then
partof = GetAddOnMetadata(name, ACP.TAGS.CHILD_OF)
end
if partof ~= nil then
return partof .. "_" .. name
end
if name == "DBM-Core" then
return "DBM"
elseif name:match("DBM%-") then
return name:gsub("DBM%-", "DBM_")
elseif name:match("CT_") then
return name:gsub("CT_", "CT-")
elseif name:sub(1, 1) == "+" or name:sub(1, 1) == "!" or name:sub(1, 1) == "_" then
return name:sub(2, -1)
elseif name == "ShadowedUF_Options" then
return "ShadowedUnitFrames_Options"
elseif name == "FB_TrackingFrame" then
return "FishingBuddy_TrackingFrame"
elseif name:match("WeakAuras") then
return name:gsub("WeakAuras(%w+)", "WeakAuras_%1")
end
return name
end
--==============
-- Localization
--==============
local DEFAULT = "Default"
local TITLES = "Titles"
local ACE2 = "Ace2"
local AUTHOR = "Author"
local SEPARATE_LOD_LIST = "Separate LOD List"
local GROUP_BY_NAME = "Group By Name"
if (GetLocale() == "zhCN") then
DEFAULT = "默认"
TITLES = "名称"
ACE2 = "Ace2"
AUTHOR = "作者"
SEPARATE_LOD_LIST = "按需求加载"
GROUP_BY_NAME = "按名称分组"
elseif (GetLocale() == "zhTW") then
DEFAULT = "預設"
TITLES = "名稱"
ACE2 = "Ace2"
AUTHOR = "作者"
SEPARATE_LOD_LIST = "隨需求載入"
GROUP_BY_NAME = "以名稱分組"
elseif (GetLocale() == "koKR") then
DEFAULT = "기본"
TITLES = "제목"
ACE2 = "Ace2"
AUTHOR = "제작자"
SEPARATE_LOD_LIST = "LOD 목록 분리"
GROUP_BY_NAME = "이름별 분류"
elseif (GetLocale() == "frFR") then
DEFAULT = "Défaut"
TITLES = "Titres"
ACE2 = "Ace2"
AUTHOR = "Auteur"
SEPARATE_LOD_LIST = "Liste LOD séparée"
GROUP_BY_NAME = "Groupement par nom"
elseif (GetLocale() == "esES") then
DEFAULT = "Por Defecto"
TITLES = "T?tulos"
ACE2 = "Ace2"
AUTHOR = "Autor"
SEPARATE_LOD_LIST = "Lista CaD por separado"
GROUP_BY_NAME = "Agrupar por nombre"
elseif (GetLocale() == "ruRU") then
DEFAULT = "По умолчанию"
TITLES = "Заголовкам"
ACE2 = "Ace2"
AUTHOR = "Автор"
SEPARATE_LOD_LIST = "Отдел. список ЗПТ"
GROUP_BY_NAME = "Группир. по имени"
end
--==============
-- Locale
--==============
local L = setmetatable({}, {
__index = function(t, k)
error("Locale key " .. tostring(k) .. " is not provided.")
end
})
--==============
-- Special Tables
--==============
--[[
masterAddonList : master list of sorted addons.
It should be in the following structures:
masterAddonList = {
addon1Index,
addon2Index,
{
addon3Index,
addon4Index,
...
['category'] = "Category1Name"
},
addon5Index,
{
addon6Index,
addon7Index,
['category'] = "Category2Name"
},
}
This list is used to build sortedAddonList, which is the list used in the FauxScrollFrame.
NEW: addonIndex can now be number or string, where string is the addon name,
so you can directly insert the Blizzard addon names to the list.
--]]
local masterAddonList = {}
ACP.masterAddonList = masterAddonList
--[[
sortedAddonList : list of addonIndexes, which is used by the FauxScrollFrame.
It should be in the following structure:
sortedAddonList = {
addon1Index,
addon2Index,
"Category1Name",
addon3Index,
addon4Index,
...,
addon5Index,
"Category2Name",
addon6Index,
addon7Index,
...,
}
- If type(addonIndex) == 'string', it will be shown in the panel as a category header.
- The collapse state will be retrieved from the saved variables: collapsedAddons.
- If addonIndex > GetNumAddOns(), it''s a Blizzard addon, the index references to ACP_BLIZZARD_ADDONS[addonIndex - GetNumAddOns()].
- otherwise, addonIndex is the index used in GetAddOnInfo().
This list will be rebuilt whenever use expanded/collapsed a category, or when user changed the sorting criteria.
--]]
local sortedAddonList = {}
ACP.sortedAddonList = sortedAddonList
--[[
addonListBuilders : a table of functions used to build masterAddonList
To define your own sorting criteria, check the default builder functions as examples.
Note if you create the build function in an external scope, you cannot access to the ACP local variables,
i.e. masterAddonList and ACP_BLIZZARD_ADDONS, but they can be accessed through ACP. e.g.:
function MyExternalBuilder()
local masterAddonList = ACP.masterAddonList
local bzAddons = ACP.ACP_BLIZZARD_ADDONS
(Now build the masterAddonList)
end
When you have defined your own builder function, simple add them to the table by:
ACP.addonListBuilders["MyExternalBuilder"] = MyExternalBuilder
After everything is done, the custom defined function can be accessed from the ACP sorter drop down menu.
]]
local addonListBuilders = {}
ACP.addonListBuilders = addonListBuilders
--
-- Decorator Pattern Text Colorization Functions
-- Same as crayonlib
--
local CLR = {}
CLR.COLOR_NONE = nil
function CLR:Colorize(hexColor, text)
if text == nil then text = "" end
if hexColor == CLR.COLOR_NONE then
return text
end
return "|cff" .. tostring(hexColor or 'ffffff') .. tostring(text) .. "|r"
end
function CLR:GetHexColor(color)
return string.format("%02x%02x%02x", color.r * 255, color.g * 255, color.b * 255)
end
--
-- Colors used
--
function CLR:Label(txt) return CLR:Colorize('ffff7f', txt) end
function CLR:ActiveEmbed(txt) return CLR:Colorize('80ff80', txt) end
function CLR:Addon(txt) return CLR:Colorize('7f7fff', txt) end
function CLR:On(txt) return CLR:Colorize('00ff00', txt) end
function CLR:Off(txt) return CLR:Colorize('ff0000', txt) end
function CLR:Bool(b, txt) if b then return CLR:On(txt) else return CLR:Off(txt) end end
function CLR:AddonStatus(addon, txt)
local color = ACP:GetAddonStatus(addon)
return CLR:Colorize(color, txt)
end
local function formattitle(title)
return title:gsub("Lib: ", "|cff66ccffLib|r: "):gsub(" |cff7fff7f %-Ace2%-|r", ""):gsub("%-Ace2%-", ""):trim()
end
-- From modmenutufu
local reasons = {}
local function getreason(r)
if not reasons[r] then reasons[r] = _G["ADDON_" .. r] end
return reasons[r]
end
function ACP:IsAddonCompatibleWithCurrentIntefaceVersion(addon)
local build = select(4, GetBuildInfo())
local addonnum = tonumber(addon)
if not addonnum or (addonnum and (addonnum == 0 or addonnum > GetNumAddOns())) then
return true -- Get to the choppa!
end
local max_supported = GetAddOnMetadata(addonnum, ACP.TAGS.INTERFACE_MAX) or
GetAddOnMetadata(addonnum, ACP.TAGS.INTERFACE_MAX_ORG)
local min_supported = GetAddOnMetadata(addonnum, ACP.TAGS.INTERFACE_MIN) or
GetAddOnMetadata(addonnum, ACP.TAGS.INTERFACE_MIN_ORG)
--print("Min: "..tostring(min_supported).." Max: "..tostring(max_supported))
if max_supported then
max_supported = tonumber(max_supported) and (tonumber(max_supported) >= build) or false
end
if min_supported then
min_supported = tonumber(min_supported) and (tonumber(min_supported) <= build) or false
end
return max_supported, min_supported
end
function ACP:GetAddonCompatibilitySummary(addon)
local high, low = self:IsAddonCompatibleWithCurrentIntefaceVersion(addon)
if low == false then
return false
elseif high == false then
return false
elseif high or low then
return true
end
return nil -- Compatibility not specified
end
function ACP:GetAddonStatus(addon)
local addon = addon
-- Hi, i'm Mr Kludge! Whats your name?
local addonnum = tonumber(addon)
if addonnum and (addonnum == 0 or addonnum > GetNumAddOns()) then
return -- Get to the choppa!
end
local high, low = self:IsAddonCompatibleWithCurrentIntefaceVersion(addon)
if (low == false) then
return "FF0000", getreason("INCOMPATIBLE")
end
if (high == false) then
return "FF0000", getreason("INTERFACE_VERSION")
end
local name, title, notes, loadable, reason, security, newVersion = GetAddOnInfo(addon)
if reason == "MISSING" and type(addon) == "string" then
addon = self:ResolveLibraryName(addon) or addon
end
local loaded = IsAddOnLoaded(addon)
local isondemand = IsAddOnLoadOnDemand(addon)
local enabled = GetAddOnEnableState(UnitName("player"), addon) > 0;
local color, note
if reason == "DISABLED" then color, note = "9d9d9d", getreason(reason) -- Grey
elseif reason == "NOT_DEMAND_LOADED" then color, note = "0070dd", getreason(reason) -- Blue
elseif reason and not loaded then color, note = "ff8000", getreason(reason) -- Orange
elseif loadable and isondemand and not loaded and enabled then color, note = "1eff00", L["Loadable OnDemand"] -- Green
elseif loaded and not enabled then color, note = "a335ee", L["Disabled on reloadUI"] -- Purple
elseif reason == "MISSING" then color, note = "ff0000", getreason(reason)
else
color = CLR.COLOR_NONE
note = ""
end
return color, note
end
--==============
-- Reference to tables in saved variables
--==============
local savedVar
local collapsedAddons
--==============
-- Local Variables
--==============
local cache = setmetatable({}, {
__mode = 'k'
})
local function acquire()
local t = next(cache) or {}
cache[t] = nil
return t
end
local function reclaim(t)
for k in pairs(t) do
t[k] = nil
end
cache[t] = true
end
local ACP_ADDON_NAME = "ACP"
local ACP_FRAME_NAME = "ACP_AddonList"
local playerClass = nil
local ACP_SET_SIZE = 25
local ACP_MAXADDONS = 20
local ACP_DefaultSet = {}
local ACP_DEFAULT_SET = 0
local ACP_BLIZZARD_ADDONS = {
"Blizzard_AchievementUI",
"Blizzard_ArchaeologyUI",
"Blizzard_ArenaUI",
"Blizzard_AuctionUI",
"Blizzard_AuthChallengeUI",
"Blizzard_BarbershopUI",
"Blizzard_BattlefieldMinimap",
"Blizzard_BindingUI",
"Blizzard_BlackMarketUI",
"Blizzard_Calendar",
"Blizzard_ChallengesUI",
"Blizzard_ClientSavedVariables",
"Blizzard_CombatLog",
"Blizzard_CombatText",
"Blizzard_CompactRaidFrames",
"Blizzard_CUFProfiles",
"Blizzard_DebugTools",
"Blizzard_EncounterJournal",
"Blizzard_GarrisonUI",
"Blizzard_GlyphUI",
"Blizzard_GMChatUI",
"Blizzard_GMSurveyUI",
"Blizzard_GuildBankUI",
"Blizzard_GuildControlUI",
"Blizzard_GuildUI",
"Blizzard_InspectUI",
"Blizzard_ItemAlterationUI",
"Blizzard_ItemSocketingUI",
"Blizzard_ItemUpgradeUI",
"Blizzard_LookingForGuildUI",
"Blizzard_MacroUI",
"Blizzard_MovePad",
"Blizzard_ObjectiveTracker",
"Blizzard_PetBattleUI",
"Blizzard_PetJournal",
"Blizzard_PVPUI",
"Blizzard_QuestChoice",
"Blizzard_RaidUI",
"Blizzard_StoreUI",
"Blizzard_TalentUI",
"Blizzard_TimeManager",
"Blizzard_TokenUI",
"Blizzard_TradeSkillUI",
"Blizzard_TrainerUI",
"Blizzard_VoidStorageUI",
}
local NUM_BLIZZARD_ADDONS = #ACP_BLIZZARD_ADDONS
ACP.ACP_BLIZZARD_ADDONS = ACP_BLIZZARD_ADDONS
local enabledList -- Used to prevent recursive loop in EnableAddon.
local function ParseVersion(version)
if type(version) == "string" then
version = version:gsub("@project%-version@", CLR:Colorize("ffa0a0", "DEBUG")):trim()
end
return version
end
local function toggle(flag)
if flag then
return nil
else
return true
end
end
local function GetAddonIndex(addon, noerr)
if type(addon) == 'number' then
return addon
elseif type(addon) == 'string' then
local addonIndex = ACP_BLIZZARD_ADDONS[addon]
if addonIndex then
return addonIndex + GetNumAddOns()
else
if addon == "" then return nil end
for i=1,GetNumAddOns() do
local name = ACP:SpecialCaseName(GetAddOnInfo(i))
if name:lower() == ACP:SpecialCaseName(addon):lower() then
return i
end
end
if not noerr then
error("Cannot find addon " .. tostring(addon))
end
end
else
if not noerr then
error("GetAddonIndex(): addon must be of type number of string.")
end
end
end
function ACP:ToggleRecursion(val)
if val == nil then
savedVar.NoRecurse = not savedVar.NoRecurse
else
savedVar.NoRecurse = not val
end
local frame = _G[ACP_FRAME_NAME .. "_NoRecurse"]
frame:SetChecked(not savedVar.NoRecurse)
-- ACP:Print(L["Recursive Enable is now %s"]:format(CLR:Bool(not savedVar.NoRecurse, tostring(not savedVar.NoRecurse))))
end
function ACP:OnLoad(this)
self.L = L
self.frame = _G[ACP_FRAME_NAME]
self.frame:SetMovable(true)
-- Make sure we are properly scaled.
self.frame:SetScale(UIParent:GetEffectiveScale());
for i=1,ACP_MAXADDONS do
local button = _G[ACP_FRAME_NAME .. "Entry" .. i .. "LoadNow"]
button:SetText(L["Load"])
end
_G[ACP_FRAME_NAME .. "DisableAll"]:SetText(L["Disable All"])
_G[ACP_FRAME_NAME .. "EnableAll"]:SetText(L["Enable All"])
_G[ACP_FRAME_NAME .. "SetButton"]:SetText(L["Sets"])
_G[ACP_FRAME_NAME .. "_ReloadUI"]:SetText(L["ReloadUI"])
_G[ACP_FRAME_NAME .. "BottomClose"]:SetText(L["Close"])
UIPanelWindows[ACP_FRAME_NAME] = {
area = "center",
pushable = 0,
whileDead = 1
}
StaticPopupDialogs["ACP_RELOADUI"] = {
text = L["Reload your User Interface?"],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = function()
ReloadUI()
end,
timeout = 0,
hideOnEscape = 1,
exclusive = 1,
whileDead = 1,
preferredIndex = 3,
}
StaticPopupDialogs["ACP_RELOADUI_START"] = {
text = L["ACP: Some protected addons aren't loaded. Reload now?"],
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = function(this)
ReloadUI()
end,
OnCancel = function(this, data, reason)
ACP_Data.reloadRequired = nil
end,
timeout = 10,
hideOnEscape = 1,
exclusive = 1,
whileDead = 1,
preferredIndex = 3,
}
StaticPopupDialogs["ACP_SAVESET"] = {
text = L["Save the current addon list to [%s]?"],
button1 = YES,
button2 = CANCEL,
OnAccept = function(this)
self:SaveSet(self.savingSet)
CloseDropDownMenus(1)
end,
timeout = 0,
hideOnEscape = 1,
whileDead = 1,
exclusive = 1,
preferredIndex = 3,
}
local function OnRenameSet(this)
local popup;
if this:GetParent():GetName() == "UIParent" then
popup = this
else
popup = this:GetParent()
end
local text = _G[popup:GetName() .. "EditBox"]:GetText()
if text == "" then
text = nil
end
self:RenameSet(self.renamingSet, text)
popup:Hide()
end
StaticPopupDialogs["ACP_RENAMESET"] = {
text = L["Enter the new name for [%s]:"],
button1 = YES,
button2 = CANCEL,
OnAccept = OnRenameSet,
EditBoxOnEnterPressed = OnRenameSet,
EditBoxOnEscapePressed = function(this)
this:GetParent():Hide()
end,
timeout = 0,
hideOnEscape = 1,
exclusive = 1,
whileDead = 1,
hasEditBox = 1,
preferredIndex = 3,
}
for i,v in ipairs(ACP_BLIZZARD_ADDONS) do
ACP_BLIZZARD_ADDONS[v] = i
end
local title = "Addon Control Panel"
local version = GetAddOnMetadata(ACP_ADDON_NAME, "Version")
if version then
version = ParseVersion(version)
title = title .. " (" .. version .. ")"
end
ACP_AddonListHeaderTitle:SetText(title)
this:RegisterEvent("ADDON_LOADED")
this:RegisterForDrag("LeftButton");
local _
playerClass, _ = UnitClass("player")
SlashCmdList["ACP"] = self.SlashHandler
SLASH_ACP1 = "/acp"
end
local eventLibrary, bugeventreged
function ACP:OnEvent(this, event, arg1, arg2, arg3)
if event == "ADDON_LOADED" and arg1 == "ACP" then
if not ACP_Data then ACP_Data = {} end
savedVar = ACP_Data
savedVar.ProtectedAddons = savedVar.ProtectedAddons or {
["ACP"] = true
}
if not savedVar.collapsed then
savedVar.collapsed = {}
end
collapsedAddons = savedVar.collapsed
if not savedVar.sorter then
ACP:SetMasterAddonBuilder(GROUP_BY_NAME)
else
ACP:ReloadAddonList()
end
if savedVar.NoChildren == nil then
savedVar.NoChildren = true
end
for i=1,GetNumAddOns() do
if IsAddOnLoaded(i) then
local name = GetAddOnInfo(i)
if name ~= ACP_ADDON_NAME then
table.insert(ACP_DefaultSet, name)
end
end
end
if savedVar.scale then self.frame:SetScale(savedVar.scale) end
self:MakeFrameScalable(self.frame, -46, 16)
self:ToggleRecursion(not savedVar.NoRecurse)
_G[ACP_FRAME_NAME .. "_NoRecurseText"]:SetText(L["Recursive"])
this:RegisterEvent("PLAYER_ENTERING_WORLD")
elseif event == "PLAYER_ALIVE" then
for k,v in pairs(savedVar.ProtectedAddons) do
if type(k) == "number" then savedVar.ProtectedAddons[k] = nil end
if not v then savedVar.ProtectedAddons[k] = nil end
end
local reloadRequired = false
for k,v in pairs(savedVar.ProtectedAddons) do
local name, title, notes, loadable, reason, security, newVersion = GetAddOnInfo(k)
local enabled = GetAddOnEnableState(UnitName("player"), name) > 0;
if reason == 'MISSING' then
savedVar.ProtectedAddons[k] = nil
elseif (not enabled) or enabled == 0 then
EnableAddOn(k, UnitName("player"))
reloadRequired = true
end
end
if reloadRequired then
if savedVar.reloadRequired then
savedVar.reloadRequired = nil
else
savedVar.reloadRequired = true
end
else
savedVar.reloadRequired = nil
end
if savedVar.reloadRequired then
StaticPopup_Show("ACP_RELOADUI_START");
end
elseif event == "PLAYER_ENTERING_WORLD" then
this:UnregisterEvent("PLAYER_ENTERING_WORLD")
this:RegisterEvent("PLAYER_ALIVE")
GameMenuButtonAddons:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION);
HideUIPanel(GameMenuFrame);
ShowUIPanel(ACP_AddonList);
end)
-- ACP:ProcessBugSack("session")
end
if event == "ADDON_LOADED" then
ACP:ADDON_LOADED(arg1)
end
end
function ACP:ResolveLibraryName(id)
local a, name
for a=1,GetNumAddOns() do
local n = GetAddOnInfo(a)
if n == id then
name = n
elseif GetAddOnMetadata(a, "X-AceLibrary-" .. id) then
name = name or n
end
end
return name
end
local ACP_NORECURSE = "norecurse"
local ACP_ADD_SET_D = "addset"
local ACP_REM_SET_D = "removeset"
local ACP_DISABLEALL = "disableall"
local ACP_RESTOREDEFAULT = "default"
local ACP_COMMANDS = { ACP_NOCHILDREN, ACP_NORECURSE, ACP_ADD_SET_D, ACP_REM_SET_D, ACP_DISABLEALL, ACP_RESTOREDEFAULT }
function ACP.SlashHandler(msg)
if type(msg) == "string" and msg:len() > 0 then
if msg == ACP_NOCHILDREN then
savedVar.NoChildren = not savedVar.NoChildren
ACP:Print(L["LoD Child Enable is now %s"]:format(CLR:Bool(not savedVar.NoChildren, tostring(not savedVar.NoChildren))))
return
end
if msg == ACP_NORECURSE then
ACP:ToggleRecursion()
ACP:Print(L["Recursive Enable is now %s"]:format(CLR:Bool(not savedVar.NoRecurse, tostring(not savedVar.NoRecurse))))
return
end
if msg == ACP_DISABLEALL then
ACP:DisableAllAddons()
return
end
if msg:find("^"..ACP_ADD_SET_D) then
local set = msg:sub(ACP_ADD_SET_D:len(), -1):match("%d+")
set = tonumber(set)
if type(set) == "number" then
ACP:LoadSet(set)
return
end
end
if msg:find("^"..ACP_REM_SET_D) then
local set = msg:sub(ACP_REM_SET_D:len(), -1):match("%d+")
set = tonumber(set)
if type(set) == "number" then
ACP:UnloadSet(set)
return
end
end
if msg == ACP_RESTOREDEFAULT then
ACP:DisableAll_OnClick()
ACP:LoadSet(0)
return
end
ACP:ShowSlashCommands()
end
ACP:ToggleUI()
end
function ACP:ShowSlashCommands()
ACP:Print("Valid commands: " .. table.concat(ACP_COMMANDS, ", "))
end
addonListBuilders[DEFAULT] = function()
for k in pairs(masterAddonList) do
masterAddonList[k] = nil
end
local numAddons = GetNumAddOns()
for i=1,numAddons do
table.insert(masterAddonList, i)
end
for i=1,NUM_BLIZZARD_ADDONS do
table.insert(masterAddonList, numAddons + i)
end
end
addonListBuilders[TITLES] = function()
for k in pairs(masterAddonList) do
masterAddonList[k] = nil
end
local numAddons = GetNumAddOns()
for i=1,numAddons do
table.insert(masterAddonList, i)
end
-- Sort the addon list by Ace2 Categories.
table.sort(masterAddonList, function(a, b)
local _, nameA = GetAddOnInfo(a)
local _, nameB = GetAddOnInfo(b)
return formattitle(nameA) < formattitle(nameB)
end)
for i=1,NUM_BLIZZARD_ADDONS do
table.insert(masterAddonList, numAddons + i)
end
end
addonListBuilders[ACE2] = function()
local t = {}
local numAddons = GetNumAddOns()
for i=1,numAddons do
table.insert(t, i)
end
-- Sort the addon list by Ace2 Categories.
table.sort(t, function(a, b)
local catA = GetAddOnMetadata(a, "X-Category")
local catB = GetAddOnMetadata(b, "X-Category")
if catA == catB then
local nameA = GetAddOnInfo(a)
local nameB = GetAddOnInfo(b)
return nameA < nameB
else
return tostring(catA) < tostring(catB)
end
end)
-- Insert the category titles into the list.
local prevCategory = ""
for i,addonIndex in ipairs(t) do
local category = GetAddOnMetadata(addonIndex, "X-Category")
if not category then
category = "Undefined"
end
if category ~= prevCategory then
table.insert(t, i, category)
end
prevCategory = category
end
table.insert(t, "Blizzard")
for i=1,NUM_BLIZZARD_ADDONS do
table.insert(t, numAddons + i)
end
-- Now build the masterAddonList.
for k in pairs(masterAddonList) do
masterAddonList[k] = nil
end
local list = masterAddonList
local currPos = list
for i,addon in ipairs(t) do
if type(addon) == 'string' then
local t = {}
t.category = addon
table.insert(list, t)
currPos = t
else
table.insert(currPos, addon)
end
end
end
addonListBuilders[AUTHOR] = function()
local t = {}
local numAddons = GetNumAddOns()
for i=1,numAddons do
table.insert(t, i)
end
-- Sort the addon list by Ace2 Categories.
table.sort(t, function(a, b)
local catA = GetAddOnMetadata(a, "Author")
local catB = GetAddOnMetadata(b, "Author")
if catA == catB then
local nameA = GetAddOnInfo(a)
local nameB = GetAddOnInfo(b)
return nameA < nameB
else
return tostring(catA) < tostring(catB)
end
end)
-- Insert the category titles into the list.
local prevCategory = ""
for i,addonIndex in ipairs(t) do
local category = GetAddOnMetadata(addonIndex, "Author")
if not category then
category = "Unknown"
end
if category ~= prevCategory then
table.insert(t, i, category)
end
prevCategory = category
end
table.insert(t, "Blizzard")
for i=1,NUM_BLIZZARD_ADDONS do
table.insert(t, numAddons + i)
end
-- Now build the masterAddonList.
for k in pairs(masterAddonList) do
masterAddonList[k] = nil
end
local list = masterAddonList
local currPos = list
for i,addon in ipairs(t) do
if type(addon) == 'string' then
local t = {}
t.category = addon
table.insert(list, t)
currPos = t
else
table.insert(currPos, addon)
end
end
end
addonListBuilders[SEPARATE_LOD_LIST] = function()
for k in pairs(masterAddonList) do
masterAddonList[k] = nil
end
local numAddons = GetNumAddOns()
local name
local lods = {}
lods.category = "Load On Demand Addons"
local nonlods = {}
nonlods.category = "Standard Addons"
local blizz = {}
blizz.category = "Blizzard Addons"
local pos = 1
for i=1,numAddons do
name = GetAddOnInfo(i)
if not IsAddOnLoadOnDemand(name) then
table.insert(nonlods, i)
else
table.insert(lods, i)
end
end
for i=1,NUM_BLIZZARD_ADDONS do
table.insert(blizz, numAddons + i)
end
table.insert(masterAddonList, nonlods)
table.insert(masterAddonList, lods)
table.insert(masterAddonList, blizz)
end
addonListBuilders[GROUP_BY_NAME] = function()
local t = {}
local numAddons = GetNumAddOns()
for i=1,numAddons do
table.insert(t, i)
end
local libs = {}
libs.category = "Libraries"
-- Sort the addon list by Ace2 Categories.
table.sort(t, function(a, b)
local nameA = GetAddOnInfo(a)
local nameB = GetAddOnInfo(b)
local catA, catB