-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConfig.lua
More file actions
1953 lines (1799 loc) · 62.3 KB
/
Config.lua
File metadata and controls
1953 lines (1799 loc) · 62.3 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
--[[
**********************************************************************
MagicMarker best friend for raid marking. See README.txt for
more details.
**********************************************************************
This file is part of MagicMarker, a World of Warcraft Addon
MagicMarker is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MagicMarker is distributed in the hope that it will be useful, WITHOUT
but ANY WARRANTY without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with MagicMarker. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************
]]
local CONFIG_VERSION = 14
local format = string.format
local sub = string.sub
local strmatch = strmatch
local tonumber = tonumber
local tolower = strlower
local UnitGUID = UnitGUID
local LibStub = LibStub
local ipairs = ipairs
local pairs = pairs
local select = select
local tinsert = tinsert
local tconcat = table.concat
local tostring = tostring
local tsort = table.sort
local next = next
local gsub = gsub
local type = type
local GetRealZoneText = GetRealZoneText
local IsInInstance = IsInInstance
local UnitCreatureFamily = UnitCreatureFamily
local UnitCreatureType = UnitCreatureType
local UnitPowerMax = UnitPowerMax
local UnitClassification = UnitClassification
local GetBindingKey = GetBindingKey
local SetBinding = SetBinding
local GetBindingAction = GetBindingAction
local GetBindingText = GetBindingText
local SetBindings = SetBindings
local GetCurrentBindingSet = GetCurrentBindingSet
local SaveBindings = SaveBindings or AttemptToSaveBindings
local KEY_BOUND = KEY_BOUND
local KEY_UNBOUND_ERROR = KEY_UNBOUND_ERROR
local _G = _G
local mod = LibStub("AceAddon-3.0"):GetAddon("MagicMarker")
local MagicMarker = mod
local L = LibStub("AceLocale-3.0"):GetLocale("MagicMarker", false)
local R = LibStub("AceConfigRegistry-3.0")
local C = LibStub("AceConfigDialog-3.0")
local DBOpt = LibStub("AceDBOptions-3.0")
local BabbleZone = LibStub("LibBabble-Zone-3.0")
local ZoneReverse = BabbleZone:GetReverseLookupTable()
local ZoneLookup = BabbleZone:GetUnstrictLookupTable()
BabbleZone = nil
local MobNotesDB
local options, cmdoptions, standardZoneOptions, standardMobOptions
local lastRaidIconType
local db
local mobdata
local configBuilt
-- Config UI name => ID
local CONFIG_MAP = {}
-- ID => Config UI name
local ACT_LIST = { "TANK", "CC" }
local CC_LIST = {
"00NONE", "SHEEP", "BANISH", "SHACKLE", "HIBERNATE", "TRAP", "KITE",
"MC", "FEAR", "SAP", "ENSLAVE", "ROOT",
"CYCLONE", "TURNUNDEAD", "SCAREBEAST", "SEDUCE", "TURNEVIL", "BLIND", "BURN",
"HEX", "REPENTANCE", "BINDELEMENTAL"
}
local AVAILABLE_CC = {
[7] = true, -- KITE
[19] = true, -- BURN
}
do
local ccids = LibStub("MagicComm-1.0").spellIdToCCID
for spellid in pairs(ccids) do
AVAILABLE_CC[ccids[spellid]] = true
end
end
local PRI_LIST = { "P1", "P2", "P3", "P4", "P5", "P6" }
local CCPRI_LIST = { "P1", "P2", "P3", "P4", "P5", "P0" }
local RT_LIST = { "Star", "Circle", "Diamond", "Triangle", "Moon", "Square", "Cross", "Skull", "None" }
local ccDropdown, ccpriDropdown, priDropdown, catDropdown, raidIconDropdown, logLevelsDropdown
local dungeon_tiers = {
wotlk = {
["Ahn'kahet:TheOldKingdom"] = true,
["Azjol-Nerub"] = true,
["Drak'TharonKeep"] = true,
["Gundrak"] = true,
["HallsofLightning"] = true,
["HallsofReflection"] = true,
["HallsofStone"] = true,
["IcecrownCitadel"] = true,
["Naxxramas"] = true,
["PitofSaron"] = true,
["TheCullingofStratholme"] = true,
["TheEyeofEternity"] = true,
["TheForgeofSouls"] = true,
["TheNexus"] = true,
["TheObsidianSanctum"] = true,
["TheOculus"] = true,
["TheVioletHold"] = true,
["TrialoftheChampion"] = true,
["TrialoftheCrusader"] = true,
["Ulduar"] = true,
["UtgardeKeep"] = true,
["UtgardePinnacle"] = true,
["VaultofArchavon"] = true,
},
bc = {
["AuchenaiCrypts"] = true,
["BlackTemple"] = true,
["Gruul'sLair"] = true,
["HellfireRamparts"] = true,
["HyjalSummit"] = true,
["Karazhan"] = true,
["Magisters'Terrace"] = true,
["Magtheridon'sLair"] = true,
["Mana-Tombs"] = true,
["OldHillsbradFoothills"] = true,
["SerpentshrineCavern"] = true,
["SethekkHalls"] = true,
["ShadowLabyrinth"] = true,
["SunwellPlateau"] = true,
["TempestKeep"] = true,
["TheArcatraz"] = true,
["TheBlackMorass"] = true,
["TheBloodFurnace"] = true,
["TheBotanica"] = true,
["TheMechanar"] = true,
["TheShatteredHalls"] = true,
["TheSlavePens"] = true,
["TheSteamvault"] = true,
["TheUnderbog"] = true,
["Zul'Aman"] = true,
},
cata = {
["BaradinHold"] = true,
["BlackrockCaverns"] = true,
["BlackwingDescent"] = true,
["GrimBatol"] = true,
["HallsofOrigination"] = true,
["LostCityoftheTol'vir"] = true,
["TheBastionOfTwilight"] = true,
["TheBastionofTwilight"] = true,
["TheStonecore"] = true,
["TheVortexPinnacle"] = true,
["ThroneoftheFourWinds"] = true,
["ThroneoftheTides"] = true,
["Firelands"] = true,
}
}
function mod:GetCCID(ccname)
return CONFIG_MAP[ccname]
end
function mod:GetIconTexture(id)
return format("Interface\\AddOns\\MagicMarker\\Textures\\%s.tga",
sub(RT_LIST[id], 2))
end
-- KeybindHelper code from Xinhuan's addon IPopBar. Thanks for letting me use it!
local KeybindHelper = {}
do
local t = {}
function KeybindHelper:MakeKeyBindingTable(...)
for k in pairs(t) do
t[k] = nil
end
for i = 1, select("#", ...) do
local key = select(i, ...)
if key ~= "" then
tinsert(t, key)
end
end
return t
end
function KeybindHelper:GetKeybind(info)
return tconcat(self:MakeKeyBindingTable(GetBindingKey(info.arg)), ", ")
end
function KeybindHelper:SetKeybind(info, key)
if key == "" then
local t = self:MakeKeyBindingTable(GetBindingKey(info.arg))
for i = 1, #t do
SetBinding(t[i])
end
else
local oldAction = GetBindingAction(key)
if (oldAction ~= "" and oldAction ~= info.arg) then
mod:SetStatusText(format(KEY_UNBOUND_ERROR, GetBindingText(oldAction, "BINDING_NAME_")), true)
else
mod:SetStatusText(KEY_BOUND, true)
end
SetBinding(key, info.arg)
end
SaveBindings(GetCurrentBindingSet())
end
end
local updateStatusTimer
function mod:SetStatusText(text, update)
local frame = C.OpenFrames["Magic Marker"]
if frame then
frame:SetStatusText(text)
if updateStatusTimer then
self:CancelTimer(updateStatusTimer, true)
end
if update then
updateStatustimer = self:ScheduleTimer("SetStatusText", 10, format(L["Active profile: %s"], self.db:GetCurrentProfile()))
else
updateStatustimer = false
end
end
end
local function GetMobName(arg)
return mobdata[arg[#arg - 2]] and mobdata[arg[#arg - 2]].mobs[arg[#arg - 1]].name
end
local function GetMobDesc(arg)
return mobdata[arg[#arg - 2]] and mobdata[arg[#arg - 2]].mobs[arg[#arg - 1]].desc
end
local function GetMobNote(arg)
local note, desc
if not MobNotesDB then
if _G.MobNotesDB then
MobNotesDB = _G.MobNotesDB
note = MobNotesDB[GetMobName(arg)]
end
end
local desc = GetMobDesc(arg)
if note and desc then
return note .. "\n" .. desc
elseif desc then
return desc
else
return note or "N/A"
end
end
function mod:NoMobNote(arg)
return not ((MobNotesDB and MobNotesDB[GetMobName(arg)]) or GetMobDesc(arg))
end
function mod:ToggleConfigDialog()
if C.OpenFrames["Magic Marker"] then
C:Close("Magic Marker")
else
C:Open("Magic Marker")
self:SetStatusText(format(L["Active profile: %s"], self.db:GetCurrentProfile()))
end
end
do
local temp, maxcc
ccDropdown = {}
priDropdown = {}
ccpriDropdown = {}
catDropdown = {}
raidIconDropdown = {}
logLevelsDropdown = {}
CONFIG_MAP.NUMCC = #CC_LIST - 1
maxcc = CONFIG_MAP.NUMCC + 1
for num, txt in ipairs(CC_LIST) do
if num <= maxcc and AVAILABLE_CC[num] then
ccDropdown[txt] = L[txt]
end
CONFIG_MAP[txt] = num
end
for num, txt in ipairs(PRI_LIST) do
priDropdown[txt] = L[txt]
CONFIG_MAP[txt] = num
end
for num, txt in ipairs(CCPRI_LIST) do
ccpriDropdown[txt] = L[txt]
CONFIG_MAP[txt] = num
end
for num, txt in ipairs(ACT_LIST) do
catDropdown[txt] = L[txt]
CONFIG_MAP[txt] = num
end
for num, txt in ipairs(RT_LIST) do
temp = num .. txt
raidIconDropdown[temp] = L[txt]
CONFIG_MAP[temp] = num
RT_LIST[num] = temp
end
for logname, id in pairs(mod.logLevels) do
logLevelsDropdown[id] = L[logname]
end
-- command line / dropdown options
cmdoptions = {
type = "group",
name = L["Magic Marker"],
handler = mod,
args = {
versions = {
type = "execute",
name = L["Query raid for their MagicMarker versions."],
func = "QueryAddonVersions",
},
config = {
type = "execute",
name = L["Toggle configuration dialog"],
func = "ToggleConfigDialog",
},
toggle = {
type = "execute",
name = L["Toggle Magic Marker event handling"],
func = "ToggleMagicMarker",
},
tmpl = {
type = "group",
name = L["Raid group target templates"],
args = {}
},
about = {
type = "execute",
name = L["About Magic Marker"],
func = "AboutMagicMarker"
},
reset = {
type = "execute",
name = L["Reset raid icon cache"] .. ".",
func = "ResetMarkData",
},
assignments = {
type = "execute",
name = L["Report the raid icon assignments to raid/party chat"] .. ".",
func = "ReportRaidMarks"
},
cache = {
type = "group",
name = L["Raid mark layout caching"],
args = {
save = {
type = "execute",
name = L["Save party/raid mark layout"] .. ".",
func = "CacheRaidMarks",
},
load = {
type = "execute",
name = L["Load party/raid mark layout"] .. ".",
func = "MarkRaidFromCache",
},
}
}
}
}
local expansions
if mod:IsClassic() then
expansions = {
vanilla = { name = L["Classic"], type = "group", args = {}, order = 10 },
zones = { name = L["Outdoor Zones"], type = "group", args = {}, order = 100 },
}
elseif mod:IsBurningCrusadeClassic() then
expansions = {
bc = { name = L["Burning Crusade"], type = "group", args = {}, order = 60 },
vanilla = { name = L["Classic"], type = "group", args = {}, order = 70 },
zones = { name = L["Outdoor Zones"], type = "group", args = {}, order = 100 },
}
elseif mod:IsWrathClassic() then
expansions = {
wotlk = { name = L["Wrath of the Lich King"], type = "group", args = {}, order = 50 },
bc = { name = L["Burning Crusade"], type = "group", args = {}, order = 60 },
vanilla = { name = L["Vanilla"], type = "group", args = {}, order = 70 },
zones = { name = L["Outdoor Zones"], type = "group", args = {}, order = 100 },
}
else
expansions = {
bfa = { name = L["Battle for Azeroth"], type = "group", args = {}, order = 10 },
legion = { name = L["Legion"], type = "group", args = {}, order = 20 },
wod = { name = L["Warlords of Draenor"], type = "group", args = {}, order = 30 },
cata = { name = L["Cataclysm"], type = "group", args = {}, order = 40 },
wotlk = { name = L["Wrath of the Lich King"], type = "group", args = {}, order = 50 },
bc = { name = L["Burning Crusade"], type = "group", args = {}, order = 60 },
vanilla = { name = L["Vanilla"], type = "group", args = {}, order = 70 },
zones = { name = L["Outdoor Zones"], type = "group", args = {}, order = 100},
}
end
options = {
type = "group",
name = L["Magic Marker"],
childGroups = "tab",
args = {
mobs = {
type = "group",
name = L["Mob Database"],
args = expansions,
order = 300,
cmdHidden = true,
dropdownHidden = true,
},
categories = {
childGroups = "tree",
type = "group",
name = L["Raid Target Settings"],
order = 1,
cmdHidden = true,
dropdownHidden = true,
args = {
cc = {
childGroups = "tree",
type = "group",
name = L["CC"],
order = 2,
args = {}
},
}
},
ccprio = {
type = "group",
name = L["CC"] .. " " .. L["Priority"],
order = 2,
cmdHidden = true,
dropdownHidden = true,
handler = mod,
set = "SetCCPrio",
get = "GetCCPrio",
args = {
addcc = {
type = "execute",
name = L["Add new crowd control"],
func = "AddNewCC",
order = 300,
hidden = "IsHiddenAddCC",
},
ccheader = {
type = "header",
name = "",
order = 999
},
ccinfo = {
type = "description",
name = "",
order = 1000
},
}
},
options = {
type = "group",
name = L["Options"],
order = 0,
handler = mod,
set = "SetProfileParam",
get = "GetProfileParam",
cmdHidden = true,
dropdownHidden = true,
args = {
keybindings = {
type = "group",
name = L["Key Bindings"],
order = 100,
handler = KeybindHelper,
get = "GetKeybind",
set = "SetKeybind",
args = {
bindingHeader = {
type = "header",
name = L["Key Bindings"],
order = 100,
},
}
},
commsettings = {
type = "group",
name = L["Data Sharing"],
order = 2,
args = {
header = {
type = "header",
name = L["Data Sharing"],
order = 0,
},
acceptRaidMarks = {
type = "toggle",
width = "full",
name = L["Accept raid mark broadcast messages"],
desc = L["MARKBROADHELPTEXT"],
order = 10,
},
acceptMobData = {
type = "toggle",
width = "full",
name = L["Accept mobdata broadcast messages"],
desc = L["MOBBROADHELPTEXT"],
order = 15,
},
acceptCCPrio = {
type = "toggle",
width = "full",
name = L["Accept CC priority broadcast messages"],
desc = L["CCBROADHELPTEXT"],
order = 10,
},
mobDataBehavior = {
type = "select",
name = L["Mobdata data import behavior"],
desc = L["IMPORTHELPTEXT"],
values = {
L["Merge - local priority"],
L["Merge - remote priority"],
L["Replace with remote data"],
},
disabled = function()
return not db or not db.acceptMobData
end
},
broadcastHeader = {
type = "header",
name = L["Data Broadcasting"],
order = 200
},
broadcastTargets = {
type = "execute",
name = L["Broadcast raid target settings to the raid group."],
order = 1000,
width = "full",
func = "BroadcastRaidTargets",
handler = mod,
disabled = not mod:IsValidMarker()
},
broadcastMobs = {
type = "execute",
name = L["Broadcast all zone data to the raid group."],
desc = L["BROADALLHELP"],
order = 1001,
width = "full",
func = "BroadcastAllZones",
handler = mod,
disabled = not mod:IsValidMarker()
},
broadcastCCPrio = {
type = "execute",
name = L["Broadcast crowd control priority settings to the raid group."],
order = 1002,
width = "full",
func = "BroadcastCCPriorities",
handler = mod,
disabled = not mod:IsValidMarker()
},
},
},
settings = {
type = "group",
name = L["General Options"],
order = 1,
args = {
generalHeader = {
type = "header",
name = L["General Options"],
order = 1,
},
logLevel = {
type = "select",
name = L["Log level"],
desc = L["LOGLEVELHELP"],
values = logLevelsDropdown,
order = 2,
},
autolearncc = {
name = L["Auto learn CC"],
desc = L["CCAUTOHELPTEXT"],
type = "toggle",
order = 70,
},
filterdead = {
name = L["Ignore dead people"],
desc = L["FILTERDEADHELP"],
type = "toggle",
order = 74,
},
minTankTargets = {
name = L["Minimum # of tank targets"],
desc = L["MINTANKHELP"],
type = "range",
min = 0,
max = 8,
step = 1,
order = 50,
},
modifier = {
name = L["Smart Mark Modifier"],
desc = L["SMARTMARKMODHELP"],
type = "select",
order = 20,
disabled = function()
return GetBindingKey("MAGICMARKSMARTMARK") ~= nil
end,
values = {
ALT = L["Alt"],
SHIFT = L["Shift"],
CTRL = L["Control"],
}
},
markHeader = {
type = "header",
name = L["Marking Behavior"],
order = 100,
},
honorMarks = {
name = L["Honor pre-existing raid icons"],
desc = L["HONORHELPTEXT"],
type = "toggle",
order = 110,
width = "full",
},
honorRaidMarks = {
name = L["Preserve raid group icons"],
desc = L["NOREUSEHELPTEXT"],
type = "toggle",
order = 120,
width = "full",
},
burnDownIsTank = {
name = L["Count Burn Down target as tanked mobs"],
desc = L["BURN DOWN HELP"],
type = "toggle",
order = 120,
width = "full",
},
noCombatRemark = {
name = L["Preserve raid icons on units in combat"],
desc = L["IN COMBAT UNIT HELP TEXT"],
type = "toggle",
order = 125,
width = "full",
},
battleMarking = {
name = L["Enable target re-prioritization during combat"],
desc = L["INCOMBATHELPTEXT"],
type = "toggle",
order = 130,
width = "full",
hidden = true, -- disabled for now, it's confusing as hell
},
resetRaidIcons = {
name = L["Reset raid icons when resetting the cache"],
desc = L["RESETICONHELPTEXT"],
type = "toggle",
order = 130,
width = "full",
},
},
},
},
},
}
}
standardZoneOptions = {
optionHeader = {
type = "header",
name = L["Zone Options"],
order = 1
},
targetMark = {
width = "full",
type = "toggle",
name = L["Enable auto-marking on target change"],
handler = mod,
set = "SetZoneConfig",
get = "GetZoneConfig",
order = 20,
},
mm = {
width = "full",
type = "toggle",
name = L["Enable Magic Marker in this zone"],
handler = mod,
set = "SetZoneConfig",
get = "GetZoneConfig",
order = 10,
},
broadcastMobs = {
type = "execute",
name = L["Broadcast zone data to the raid group."],
order = 1001,
width = "full",
func = function(var)
mod:BroadcastZoneData(var[#var - 1])
end,
disabled = not mod:IsValidMarker()
},
deletehdr = {
type = "header",
name = "",
order = 99
},
}
standardMobOptions = {
header = {
name = GetMobName,
type = "header",
order = 0
},
priority = {
name = L["TANK"] .. " " .. L["Priority"],
type = "select",
values = priDropdown,
order = 2,
},
ccpriority = {
name = L["CC"] .. " " .. L["Priority"],
type = "select",
values = ccpriDropdown,
order = 3,
disabled = "IsIgnored",
},
category = {
name = L["Category"],
type = "select",
values = catDropdown,
order = 4,
disabled = "IsIgnored",
},
ccnum = {
name = L["Max # to Crowd Control"],
desc = L["MAXCCHELP"],
type = "range",
min = 1,
max = 8,
step = 1,
order = 4,
hidden = "IsIgnoredCC",
},
ccheader = {
name = L["CC"] .. " " .. L["Config"],
type = "header",
disabled = "IsIgnoredCC",
order = 40
},
ccinfo = {
type = "description",
name = L["CCHELPTEXT"],
order = 50,
disabled = "IsIgnoredCC",
},
mobnotes = {
name = GetMobNote,
type = "description",
order = 20,
hidden = "NoMobNote",
},
mobnoteheader = {
name = L["Mob Notes"],
type = "header",
order = 15,
hidden = "NoMobNote",
},
deletehdr = {
type = "header",
name = "",
order = 10000
},
ccopt = {
type = "multiselect",
name = "",
order = 51,
disabled = "IsIgnoredCC",
values = ccDropdown,
}
}
for num = 1, CONFIG_MAP.NUMCC do
options.args.ccprio.args["ccopt" .. num] = {
name = format("%s #%d", L["CC"], num),
type = "select",
width = "full",
values = ccDropdown,
order = 100 + num,
hidden = "IsHiddenCC",
dialogControl = "MMCCPrio",
}
end
end
function mod:SetProfileParam(var, value)
local varName = var[#var]
db[varName] = value
if self.hasSpam then
self:spam("Setting parameter %s to %s.", varName, tostring(value))
end
if varName == "logLevel" then
self:SetLogLevel(value)
end
end
function mod:GetProfileParam(var)
local varName = var[#var]
if self.hasSpam then
self:spam("Getting parameter %s as %s.", varName, tostring(db[varName]))
end
return db[varName]
end
function mod:GetMarkForCategory(category)
if category == 1 then
return db.targetdata.TANK or {}
end
return db.targetdata[CC_LIST[category]] or {}
end
function mod:IsUnitIgnored(pri)
return pri == CONFIG_MAP.P6
end
local function getID(value)
return tonumber(strmatch(value, "%d+"))
end
local function uniqList(list, id, newValue, empty, max)
local addEmpty = false
list[id] = newValue
local currentPos = 1
local seen_value = {}
for iter = 1, max do
if list[iter] and not seen_value[list[iter]] and list[iter] ~= empty then
list[currentPos] = list[iter]
currentPos = currentPos + 1
seen_value[list[iter]] = true
end
end
for iter = currentPos, max do
list[iter] = nil
end
return list
end
function mod:SetRaidTargetConfig(info, value)
local type = info[#info - 1]
local id = getID(info[#info])
value = CONFIG_MAP[value]
db.targetdata[type] = uniqList(db.targetdata[type] or {}, id, value, 9, 8)
end
function mod:GetRaidTargetConfig(info)
local type = info[#info - 1]
local id = getID(info[#info]) or 9
if not db.targetdata[type] then
return nil
end
lastRaidIconType = type
return RT_LIST[db.targetdata[type][id]]
end
function mod:GetCCPrio(info)
local var = info[#info]
local value = CC_LIST[db.ccprio[getID(var)] or 1]
if value == CC_LIST['00NONE'] then
value = nil
end
if self.hasSpam then
self:spam("Get %s as %s", var, tostring(value))
end
return value
end
function mod:SetCCPrio(info, value)
local var = info[#info]
db.ccprio = uniqList(db.ccprio or {}, getID(var), CONFIG_MAP[value], 1, CONFIG_MAP.NUMCC)
mod:UpdateUsedCCMethods()
if self.hasSpam then
self:spam("Set %s to %s", var, tostring(value))
end
end
function mod:UpdateUsedCCMethods()
local unused = L["Unused Crowd Control Methods"]
local used = {}
local sorted = {}
local first = true
if db.ccprio then
for _, id in pairs(db.ccprio) do
used[id] = true
end
end
for id = 2, CONFIG_MAP.NUMCC + 1 do
if not used[id] and AVAILABLE_CC[id] then
sorted[#sorted + 1] = L[CC_LIST[id]]
end
end
tsort(sorted)
if next(sorted) then
for id = 1, #sorted do
if first then
unused = unused .. ": " .. sorted[id]
first = false
else
unused = unused .. ", " .. sorted[id]
end
end
options.args.ccprio.args.ccinfo.name = unused
else
options.args.ccprio.args.ccinfo.name = ""
end
end
function mod:SetMobConfig(info, value, state)
local var = info[#info]
local mob = info[#info - 1]
local region = info[#info - 2]
if var ~= "ccnum" then
value = CONFIG_MAP[value]
end
local mobhash = mobdata[region].mobs[mob]
if var == "ccopt" then
if value == CONFIG_MAP['00NONE'] then
mobhash.ccopt = nil
else
local ccopt = mobhash.ccopt or {}
ccopt[value] = state or nil
if not next(ccopt) then
mobhash.ccopt = nil
else
mobhash.ccopt = ccopt
end
end
if self.hasSpam then
self:spam("|cffffff00SetMobConfig:|r %s/%s/%s[%s] => %s", region, mob, var, CC_LIST[value], tostring(state))
end
else
mobhash[var] = value
if self.hasSpam then
self:spam("|cffffff00SetMobConfig:|r %s/%s/%s => %s", region, mob, var, tostring(value))
end
end
if mobhash.new then
mobhash.new = nil
-- Remove the "new" mark
self:GetZoneConfigHash(mobdata[region], region).args[region].plugins.mobList[mob].name = mobhash.name
end
self:QueueData_Add(region, mob, mobhash)
end
function mod:GetMobConfig(info, key)
local var = info[#info]
local mob = info[#info - 1]
local region = info[#info - 2]
local value = mobdata[region].mobs[mob][var]
if var == "ccopt" then
if not value then
if key == '00NONE' then
value = true
end
elseif value then
value = mobdata[region].mobs[mob].ccopt[CONFIG_MAP[key]]
end
if self.hasSpam then
self:spam("GetMobConfig: %s/%s/%s[%s] => %s", region, mob, var, key, tostring(value))