/
config.lua
7501 lines (7020 loc) · 239 KB
/
config.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
local Config = {}
local AceDialog, AceRegistry, AceGUI, SML, registered, options
local playerClass = select(2, UnitClass("player"))
local modifyUnits, globalConfig = {}, {}
local L = ShadowUF.L
ShadowUF.Config = Config
--[[
The part that makes configuration a pain when you actually try is it gets unwieldly when you're adding special code to deal with
showing help for certain cases, swapping tabs etc that makes it work smoothly.
I'm going to have to split it out into separate files for each type to clean everything up but that takes time and I have other things
I want to get done with first.
-- dated 2009
In reality, this will never be cleaned up because jesus christ, I am not refactoring 7,000 lines of configuration.
*** HERE BE DRAGONS ***
]]
local unitCategories = {
player = {"player", "pet"},
general = {"target", "targettarget", "targettargettarget", "focus", "focustarget", "pettarget"},
party = {"party", "partypet", "partytarget", "partytargettarget", "party"},
raid = {"raid", "raidpet"},
raidmisc = {"maintank", "maintanktarget", "maintanktargettarget", "mainassist", "mainassisttarget", "mainassisttargettarget"},
boss = {"boss", "bosstarget", "bosstargettarget"},
arena = {"arena", "arenapet", "arenatarget", "arenatargettarget"},
battleground = {"battleground", "battlegroundpet", "battlegroundtarget", "battlegroundtargettarget"}
}
local UNIT_DESC = {
["boss"] = L["Boss units are for only certain fights, such as Blood Princes or the Gunship battle, you will not see them for every boss fight."],
["mainassist"] = L["Main Assists's are set by the Blizzard Main Assist system or mods that use it."],
["maintank"] = L["Main Tank's are set through the Raid frames, or through selecting the Tank role."],
["battleground"] = L["Currently used in battlegrounds for showing flag carriers."],
["battlegroundpet"] = L["Current pet used by a battleground unit."],
["battlegroundtarget"] = L["Current target of a battleground unit."],
["battlegroundtargettarget"] = L["Current target of target of a battleground unit."]
}
local PAGE_DESC = {
["general"] = L["General configuration to all enabled units."],
["enableUnits"] = L["Various units can be enabled through this page, such as raid or party targets."],
["hideBlizzard"] = L["Hiding and showing various aspects of the default UI such as the player buff frames."],
["units"] = L["Configuration to specific unit frames."],
["visibility"] = L["Disabling unit modules in various instances."],
["tags"] = L["Advanced tag management, allows you to add your own custom tags."],
["filter"] = L["Simple aura filtering by whitelists and blacklists."],
}
local INDICATOR_NAMES = {["questBoss"] = L["Quest Boss"], ["leader"] = L["Leader / Assist"], ["lfdRole"] = L["Class Role"], ["masterLoot"] = L["Master Looter"], ["pvp"] = L["PvP Flag"], ["raidTarget"] = L["Raid Target"], ["ready"] = L["Ready Status"], ["role"] = L["Raid Role"], ["status"] = L["Combat Status"], ["class"] = L["Class Icon"], ["resurrect"] = L["Resurrect Status"], ["phase"] = L["Other Party/Phase Status"], ["petBattle"] = L["Pet Battle"], ["arenaSpec"] = L["Arena Spec"]}
local AREA_NAMES = {["arena"] = L["Arenas"],["none"] = L["Everywhere else"], ["party"] = L["Party instances"], ["pvp"] = L["Battleground"], ["raid"] = L["Raid instances"]}
local INDICATOR_DESC = {
["leader"] = L["Crown indicator for group leader or assistants."], ["lfdRole"] = L["Role the unit is playing."],
["masterLoot"] = L["Bag indicator for master looters."], ["pvp"] = L["PVP flag indicator, Horde for Horde flagged pvpers and Alliance for Alliance flagged pvpers."],
["raidTarget"] = L["Raid target indicator."], ["ready"] = L["Ready status of group members."], ["phase"] = L["Shows when a party member is in a different phase or another group."],
["questBoss"] = L["Shows that a NPC is a boss for a quest."], ["petBattle"] = L["Shows what kind of pet the unit is for pet battles."],
["role"] = L["Raid role indicator, adds a shield indicator for main tanks and a sword icon for main assists."], ["status"] = L["Status indicator, shows if the unit is currently in combat. For the player it will also show if you are rested."], ["class"] = L["Class icon for players."],
["arenaSpec"] = L["Talent spec of your arena opponents."]
}
local TAG_GROUPS = {["classification"] = L["Classifications"], ["health"] = L["Health"], ["misc"] = L["Miscellaneous"], ["playerthreat"] = L["Player threat"], ["power"] = L["Power"], ["status"] = L["Status"], ["threat"] = L["Threat"], ["raid"] = L["Raid"], ["classspec"] = L["Class Specific"], ["classtimer"] = L["Class Timer"]}
local pointPositions = {["BOTTOM"] = L["Bottom"], ["TOP"] = L["Top"], ["LEFT"] = L["Left"], ["RIGHT"] = L["Right"], ["TOPLEFT"] = L["Top Left"], ["TOPRIGHT"] = L["Top Right"], ["BOTTOMLEFT"] = L["Bottom Left"], ["BOTTOMRIGHT"] = L["Bottom Right"], ["CENTER"] = L["Center"]}
local positionList = {["C"] = L["Center"], ["RT"] = L["Right Top"], ["RC"] = L["Right Center"], ["RB"] = L["Right Bottom"], ["LT"] = L["Left Top"], ["LC"] = L["Left Center"], ["LB"] = L["Left Bottom"], ["BL"] = L["Bottom Left"], ["BC"] = L["Bottom Center"], ["BR"] = L["Bottom Right"], ["TR"] = L["Top Right"], ["TC"] = L["Top Center"], ["TL"] = L["Top Left"]}
local unitOrder = {}
for order, unit in pairs(ShadowUF.unitList) do unitOrder[unit] = order end
local fullReload = {["bars"] = true, ["auras"] = true, ["backdrop"] = true, ["font"] = true, ["classColors"] = true, ["powerColors"] = true, ["healthColors"] = true, ["xpColors"] = true, ["omnicc"] = true}
local quickIDMap = {}
-- Helper functions
local function getPageDescription(info)
return PAGE_DESC[info[#(info)]]
end
local function getFrameName(unit)
if( unit == "raidpet" or unit == "raid" or unit == "party" or unit == "maintank" or unit == "mainassist" or unit == "boss" or unit == "arena" ) then
return string.format("#SUFHeader%s", unit)
end
return string.format("#SUFUnit%s", unit)
end
local anchorList = {}
local function getAnchorParents(info)
local unit = info[2]
for k in pairs(anchorList) do anchorList[k] = nil end
if( ShadowUF.Units.childUnits[unit] ) then
anchorList["$parent"] = string.format(L["%s member"], L.units[ShadowUF.Units.childUnits[unit]])
return anchorList
end
anchorList["UIParent"] = L["Screen"]
-- Don't let a frame anchor to a frame thats anchored to it already (Stop infinite loops-o-doom)
local currentName = getFrameName(unit)
for _, unitID in pairs(ShadowUF.unitList) do
if( unitID ~= unit and ShadowUF.db.profile.positions[unitID] and ShadowUF.db.profile.positions[unitID].anchorTo ~= currentName ) then
anchorList[getFrameName(unitID)] = string.format(L["%s frames"], L.units[unitID] or unitID)
end
end
return anchorList
end
local function selectDialogGroup(group, key)
AceDialog.Status.ShadowedUF.children[group].status.groups.selected = key
AceRegistry:NotifyChange("ShadowedUF")
end
local function selectTabGroup(group, subGroup, key)
AceDialog.Status.ShadowedUF.children[group].status.groups.selected = subGroup
AceDialog.Status.ShadowedUF.children[group].children[subGroup].status.groups.selected = key
AceRegistry:NotifyChange("ShadowedUF")
end
local function hideAdvancedOption(info)
return not ShadowUF.db.profile.advanced
end
local function hideBasicOption(info)
return ShadowUF.db.profile.advanced
end
local function isUnitDisabled(info)
local unit = info[#(info)]
local enabled = ShadowUF.db.profile.units[unit].enabled
for _, visibility in pairs(ShadowUF.db.profile.visibility) do
if( visibility[unit] ) then
enabled = visibility[unit]
break
end
end
return not enabled
end
local function mergeTables(parent, child)
for key, value in pairs(child) do
if( type(parent[key]) == "table" ) then
parent[key] = mergeTables(parent[key], value)
elseif( type(value) == "table" ) then
parent[key] = CopyTable(value)
elseif( parent[key] == nil ) then
parent[key] = value
end
end
return parent
end
local function getName(info)
local key = info[#(info)]
if( ShadowUF.modules[key] and ShadowUF.modules[key].moduleName ) then
return ShadowUF.modules[key].moduleName
end
return LOCALIZED_CLASS_NAMES_MALE[key] or INDICATOR_NAMES[key] or L.units[key] or TAG_GROUPS[key] or L[key]
end
local function getUnitOrder(info)
return unitOrder[info[#(info)]]
end
local function isModifiersSet(info)
if( info[2] ~= "global" ) then return false end
for k in pairs(modifyUnits) do return false end
return true
end
-- These are for setting simple options like bars.texture = "Default" or locked = true
local function set(info, value)
local cat, key = string.split(".", info.arg)
if( key == "$key" ) then key = info[#(info)] end
if( not key ) then
ShadowUF.db.profile[cat] = value
else
ShadowUF.db.profile[cat][key] = value
end
if( cat and fullReload[cat] ) then
ShadowUF.Layout:CheckMedia()
ShadowUF.Layout:Reload()
end
end
local function get(info)
local cat, key = string.split(".", info.arg)
if( key == "$key" ) then key = info[#(info)] end
if( not key ) then
return ShadowUF.db.profile[cat]
else
return ShadowUF.db.profile[cat][key]
end
end
local function setColor(info, r, g, b, a)
local color = get(info) or {}
color.r, color.g, color.b, color.a = r, g, b, a
set(info, color)
end
local function getColor(info)
local color = get(info) or {}
return color.r, color.g, color.b, color.a
end
-- These are for setting complex options like units.player.auras.buffs.enabled = true or units.player.portrait.enabled = true
local function setVariable(unit, moduleKey, moduleSubKey, key, value)
local configTable = unit == "global" and globalConfig or ShadowUF.db.profile.units[unit]
-- For setting options like units.player.auras.buffs.enabled = true
if( moduleKey and moduleSubKey and configTable[moduleKey][moduleSubKey] ) then
configTable[moduleKey][moduleSubKey][key] = value
ShadowUF.Layout:Reload(unit)
-- For setting options like units.player.portrait.enabled = true
elseif( moduleKey and not moduleSubKey and configTable[moduleKey] ) then
configTable[moduleKey][key] = value
ShadowUF.Layout:Reload(unit)
-- For setting options like units.player.height = 50
elseif( not moduleKey and not moduleSubKey ) then
configTable[key] = value
ShadowUF.Layout:Reload(unit)
end
end
local function specialRestricted(unit, moduleKey, moduleSubKey, key)
if( ShadowUF.fakeUnits[unit] and ( key == "colorAggro" or key == "aggro" or moduleKey == "incHeal" or moduleKey == "healAbsorb" or moduleKey == "incAbsorb" or moduleKey == "castBar" ) ) then
return true
elseif( moduleKey == "healthBar" and unit == "player" and key == "reaction" ) then
return true
end
end
local function setDirectUnit(unit, moduleKey, moduleSubKey, key, value)
if( unit == "global" ) then
for unit in pairs(modifyUnits) do
if( not specialRestricted(unit, moduleKey, moduleSubKey, key) ) then
setVariable(unit, moduleKey, moduleSubKey, key, value)
end
end
setVariable("global", moduleKey, moduleSubKey, key, value)
else
setVariable(unit, moduleKey, moduleSubKey, key, value)
end
end
local function setUnit(info, value)
local unit = info[2]
-- auras, buffs, enabled / text, 1, text / portrait, enabled
local moduleKey, moduleSubKey, key = string.split(".", info.arg)
if( not moduleSubKey ) then key = moduleKey moduleKey = nil end
if( moduleSubKey and not key ) then key = moduleSubKey moduleSubKey = nil end
if( moduleSubKey == "$parent" ) then moduleSubKey = info[#(info) - 1] end
if( moduleKey == "$parent" ) then moduleKey = info[#(info) - 1] end
if( moduleSubKey == "$parentparent" ) then moduleSubKey = info[#(info) - 2] end
if( moduleKey == "$parentparent" ) then moduleKey = info[#(info) - 2] end
if( tonumber(moduleSubKey) ) then moduleSubKey = tonumber(moduleSubKey) end
setDirectUnit(unit, moduleKey, moduleSubKey, key, value)
end
local function getVariable(unit, moduleKey, moduleSubKey, key)
local configTbl = unit == "global" and globalConfig or ShadowUF.db.profile.units[unit]
if( moduleKey and moduleSubKey ) then
return configTbl[moduleKey][moduleSubKey] and configTbl[moduleKey][moduleSubKey][key]
elseif( moduleKey and not moduleSubKey ) then
return configTbl[moduleKey] and configTbl[moduleKey][key]
end
return configTbl[key]
end
local function getUnit(info)
local moduleKey, moduleSubKey, key = string.split(".", info.arg)
if( not moduleSubKey ) then key = moduleKey moduleKey = nil end
if( moduleSubKey and not key ) then key = moduleSubKey moduleSubKey = nil end
if( moduleSubKey == "$parent" ) then moduleSubKey = info[#(info) - 1] end
if( moduleKey == "$parent" ) then moduleKey = info[#(info) - 1] end
if( moduleSubKey == "$parentparent" ) then moduleSubKey = info[#(info) - 2] end
if( moduleKey == "$parentparent" ) then moduleKey = info[#(info) - 2] end
if( tonumber(moduleSubKey) ) then moduleSubKey = tonumber(moduleSubKey) end
return getVariable(info[2], moduleKey, moduleSubKey, key)
end
-- Tag functions
local function getTagName(info)
local tag = info[#(info)]
if( ShadowUF.db.profile.tags[tag] and ShadowUF.db.profile.tags[tag].name ) then
return ShadowUF.db.profile.tags[tag].name
end
return ShadowUF.Tags.defaultNames[tag] or tag
end
local function getTagHelp(info)
local tag = info[#(info)]
return ShadowUF.Tags.defaultHelp[tag] or ShadowUF.db.profile.tags[tag] and ShadowUF.db.profile.tags[tag].help
end
-- Module functions
local function hideRestrictedOption(info)
local unit = type(info.arg) == "number" and info[#(info) - info.arg] or info[2]
local key = info[#(info)]
if( ShadowUF.modules[key] and ShadowUF.modules[key].moduleClass and ShadowUF.modules[key].moduleClass ~= playerClass ) then
return true
elseif( ( key == "incHeal" and not ShadowUF.modules.incHeal ) or ( key == "incAbsorb" and not ShadowUF.modules.incAbsorb ) or ( key == "healAbsorb" and not ShadowUF.modules.healAbsorb ) ) then
return true
-- Non-standard units do not support color by aggro or incoming heal
elseif( key == "colorAggro" or key == "incHeal" or key == "incAbsorb" or key == "aggro" ) then
return string.match(unit, "%w+target" )
-- Fall back for indicators, no variable table so it shouldn't be shown
elseif( info[#(info) - 1] == "indicators" ) then
if( ( unit == "global" and not globalConfig.indicators[key] ) or ( unit ~= "global" and not ShadowUF.db.profile.units[unit].indicators[key] ) ) then
return true
end
-- Fall back, no variable table so it shouldn't be shown
elseif( ( unit == "global" and not globalConfig[key] ) or ( unit ~= "global" and not ShadowUF.db.profile.units[unit][key] ) ) then
return true
end
return false
end
local function getModuleOrder(info)
local key = info[#(info)]
return key == "healthBar" and 1 or key == "powerBar" and 2 or key == "castBar" and 3 or 4
end
-- Expose these for modules
Config.getAnchorParents = getAnchorParents
Config.hideAdvancedOption = hideAdvancedOption
Config.isUnitDisabled = isUnitDisabled
Config.selectDialogGroup = selectDialogGroup
Config.selectTabGroup = selectTabGroup
Config.getName = getName
Config.getUnitOrder = getUnitOrder
Config.isModifiersSet = isModifiersSet
Config.set = set
Config.get = get
Config.setUnit = setUnit
Config.setVariable = setVariable
Config.getUnit = getUnit
Config.getVariable = getVariable
Config.hideRestrictedOption = hideRestrictedOption
Config.hideBasicOption = hideBasicOption
--------------------
-- GENERAL CONFIGURATION
---------------------
local function loadGeneralOptions()
SML = SML or LibStub:GetLibrary("LibSharedMedia-3.0")
local MediaList = {}
local function getMediaData(info)
local mediaType = info[#(info)]
MediaList[mediaType] = MediaList[mediaType] or {}
for k in pairs(MediaList[mediaType]) do MediaList[mediaType][k] = nil end
for _, name in pairs(SML:List(mediaType)) do
MediaList[mediaType][name] = name
end
return MediaList[mediaType]
end
local barModules = {}
for key, module in pairs(ShadowUF.modules) do
if( module.moduleHasBar ) then
barModules["$" .. key] = module.moduleName
end
end
local addTextParent = {
order = 4,
type = "group",
inline = true,
name = function(info) return barModules[info[#(info)]] or string.sub(info[#(info)], 2) end,
hidden = function(info)
for _, text in pairs(ShadowUF.db.profile.units.player.text) do
if( text.anchorTo == info[#(info)] ) then
return false
end
end
return true
end,
args = {},
}
local addTextLabel = {
order = function(info) return tonumber(string.match(info[#(info)], "(%d+)")) end,
type = "description",
width = "",
fontSize = "medium",
hidden = function(info)
local id = tonumber(string.match(info[#(info)], "(%d+)"))
if( not getVariable("player", "text", nil, id) ) then return true end
return getVariable("player", "text", id, "anchorTo") ~= info[#(info) - 1]
end,
name = function(info)
return getVariable("player", "text", tonumber(string.match(info[#(info)], "(%d+)")), "name")
end,
}
local addTextSep = {
order = function(info) return tonumber(string.match(info[#(info)], "(%d+)")) + 0.75 end,
type = "description",
width = "full",
hidden = function(info)
local id = tonumber(string.match(info[#(info)], "(%d+)"))
if( not getVariable("player", "text", nil, id) ) then return true end
return getVariable("player", "text", id, "anchorTo") ~= info[#(info) - 1]
end,
name = "",
}
local addText = {
order = function(info) return info[#(info)] + 0.5 end,
type = "execute",
width = "half",
name = L["Delete"],
hidden = function(info)
local id = tonumber(info[#(info)])
if( not getVariable("player", "text", nil, id) ) then return true end
return getVariable("player", "text", id, "anchorTo") ~= info[#(info) - 1]
end,
disabled = function(info)
local id = tonumber(info[#(info)])
for _, unit in pairs(ShadowUF.unitList) do
if( ShadowUF.db.profile.units[unit].text[id] and ShadowUF.db.profile.units[unit].text[id].default ) then
return true
end
end
return false
end,
confirmText = L["Are you sure you want to delete this text? All settings for it will be deleted."],
confirm = true,
func = function(info)
local id = tonumber(info[#(info)])
for _, unit in pairs(ShadowUF.unitList) do
table.remove(ShadowUF.db.profile.units[unit].text, id)
end
addTextParent.args[info[#(info)]] = nil
ShadowUF.Layout:Reload()
end,
}
local function validateSpell(info, spell)
if( spell and spell ~= "" and not GetSpellInfo(spell) ) then
return string.format(L["Invalid spell \"%s\" entered."], spell or "")
end
return true
end
local function setRange(info, spell)
ShadowUF.db.profile.range[info[#(info)] .. playerClass] = spell and spell ~= "" and spell or nil
ShadowUF.Layout:Reload()
end
local function getRange(info)
local spell = ShadowUF.db.profile.range[info[#(info)] .. playerClass]
return spell and spell ~= "" and spell or ShadowUF.modules.range[info[#(info)]][playerClass]
end
local function rangeWithIcon(info)
local name = getRange(info)
local text = L["Spell Name"]
if( string.match(info[#(info)], "Alt") ) then
text = L["Alternate Spell Name"]
end
local icon = select(3, GetSpellInfo(name))
if( not icon ) then
icon = "Interface\\Icons\\Inv_misc_questionmark"
end
return "|T" .. icon .. ":18:18:0:0|t " .. text
end
local textData = {}
local function writeTable(tbl)
local data = ""
for key, value in pairs(tbl) do
local valueType = type(value)
-- Wrap the key in brackets if it's a number
if( type(key) == "number" ) then
key = string.format("[%s]", key)
-- Wrap the string with quotes if it has a space in it
elseif( string.match(key, "[%p%s%c]") or string.match(key, "^[0-9]+$") ) then
key = string.format("['%s']", string.gsub(key, "'", "\\'"))
end
-- foo = {bar = 5}
if( valueType == "table" ) then
data = string.format("%s%s=%s;", data, key, writeTable(value))
-- foo = true / foo = 5
elseif( valueType == "number" or valueType == "boolean" ) then
data = string.format("%s%s=%s;", data, key, tostring(value))
-- foo = "bar"
else
data = string.format("%s%s='%s';", data, key, string.gsub(tostring(value), "'", "\\'"))
end
end
return "{" .. data .. "}"
end
local layoutData = {positions = true, visibility = true, modules = false}
local layoutManager = {
type = "group",
order = 7,
name = L["Layout manager"],
childGroups = "tab",
hidden = hideAdvancedOption,
args = {
import = {
order = 1,
type = "group",
name = L["Import"],
hidden = false,
args = {
help = {
order = 1,
type = "group",
inline = true,
name = function(info) return layoutData.error and L["Error"] or L["Help"] end,
args = {
help = {
order = 1,
type = "description",
name = function(info)
if( ShadowUF.db:GetCurrentProfile() == "Import Backup" ) then
return L["Your active layout is the profile used for import backup, this cannot be overwritten by an import. Change your profiles to something else and try again."]
end
return layoutData.error or L["You can import another Shadowed Unit Frame users configuration by entering the export code they gave you below. This will backup your old layout to \"Import Backup\".|n|nIt will take 30-60 seconds for it to load your layout when you paste it in, please by patient."]
end
},
},
},
positions = {
order = 2,
type = "toggle",
name = L["Import unit frame positions"],
set = function(info, value) layoutData[info[#(info)]] = value end,
get = function(info) return layoutData[info[#(info)]] end,
width = "double",
},
visibility = {
order = 3,
type = "toggle",
name = L["Import visibility settings"],
set = function(info, value) layoutData[info[#(info)]] = value end,
get = function(info) return layoutData[info[#(info)]] end,
width = "double",
},
import = {
order = 5,
type = "input",
name = L["Code"],
multiline = true,
width = "full",
get = false,
disabled = function() return ShadowUF.db:GetCurrentProfile() == "Import Backup" end,
set = function(info, import)
local layout, err = loadstring(string.format([[return %s]], import))
if( err ) then
layoutData.error = string.format(L["Failed to import layout, error:|n|n%s"], err)
return
end
layout = layout()
-- Strip position settings
if( not layoutData.positions ) then
layout.positions = nil
end
-- Strip visibility settings
if( not layoutData.visibility ) then
layout.visibility = nil
end
-- Strip any units we don't have included by default
for unit in pairs(layout.units) do
if( not ShadowUF.defaults.profile.units[unit] ) then
layout.units[unit] = nil
end
end
-- Check if we need move over the visibility and positions info
layout.positions = layout.positions or CopyTable(ShadowUF.db.profile.positions)
layout.visibility = layout.visibility or CopyTable(ShadowUF.db.profile.positions)
-- Now backup the profile
local currentLayout = ShadowUF.db:GetCurrentProfile()
ShadowUF.layoutImporting = true
ShadowUF.db:SetProfile("Import Backup")
ShadowUF.db:CopyProfile(currentLayout)
ShadowUF.db:SetProfile(currentLayout)
ShadowUF.db:ResetProfile()
ShadowUF.layoutImporting = nil
-- Overwrite everything we did import
ShadowUF:LoadDefaultLayout()
for key, data in pairs(layout) do
if( type(data) == "table" ) then
ShadowUF.db.profile[key] = CopyTable(data)
else
ShadowUF.db.profile[key] = data
end
end
ShadowUF:ProfilesChanged()
end,
},
},
},
export = {
order = 2,
type = "group",
name = L["Export"],
hidden = false,
args = {
help = {
order = 1,
type = "group",
inline = true,
name = L["Help"],
args = {
help = {
order = 1,
type = "description",
name = L["After you hit export, you can give the below code to other Shadowed Unit Frames users and they will get your exact layout."],
},
},
},
doExport = {
order = 2,
type = "execute",
name = L["Export"],
func = function(info)
layoutData.export = writeTable(ShadowUF.db.profile)
end,
},
export = {
order = 3,
type = "input",
name = L["Code"],
multiline = true,
width = "full",
set = false,
get = function(info) return layoutData[info[#(info)]] end,
},
},
},
},
}
options.args.general = {
type = "group",
childGroups = "tab",
name = L["General"],
args = {
general = {
type = "group",
order = 1,
name = L["General"],
set = set,
get = get,
args = {
general = {
order = 1,
type = "group",
inline = true,
name = L["General"],
args = {
locked = {
order = 1,
type = "toggle",
name = L["Lock frames"],
desc = L["Enables configuration mode, letting you move and giving you example frames to setup."],
set = function(info, value)
set(info, value)
ShadowUF.modules.movers:Update()
end,
arg = "locked",
},
sep = {
order = 1.5,
type = "description",
name = "",
width = "full",
hidden = hideAdvancedOption,
},
advanced = {
order = 2,
type = "toggle",
name = L["Advanced"],
desc = L["Enabling advanced settings will give you access to more configuration options. This is meant for people who want to tweak every single thing, and should not be enabled by default as it increases the options."],
arg = "advanced",
},
omnicc = {
order = 2.5,
type = "toggle",
name = L["Disable OmniCC"],
desc = L["Disables showing OmniCC timers in all Shadowed Unit Frame auras."],
arg = "omnicc",
hidden = hideAdvancedOption,
},
hideCombat = {
order = 3,
type = "toggle",
name = L["Hide tooltips in combat"],
desc = L["Prevents unit tooltips from showing while in combat."],
arg = "tooltipCombat",
},
auraBorder = {
order = 5,
type = "select",
name = L["Aura border style"],
desc = L["Style of borders to show for all auras."],
values = {["dark"] = L["Dark"], ["light"] = L["Light"], ["blizzard"] = L["Blizzard"], [""] = L["None"]},
arg = "auras.borderType",
},
statusbar = {
order = 6,
type = "select",
name = L["Bar texture"],
dialogControl = "LSM30_Statusbar",
values = getMediaData,
arg = "bars.texture",
},
spacing = {
order = 7,
type = "range",
name = L["Bar spacing"],
desc = L["How much spacing should be provided between all of the bars inside a unit frame, negative values move them farther apart, positive values bring them closer together. 0 for no spacing."],
min = -10, max = 10, step = 0.05, softMin = -5, softMax = 5,
arg = "bars.spacing",
hidden = hideAdvancedOption,
},
},
},
backdrop = {
order = 2,
type = "group",
inline = true,
name = L["Background/border"],
args = {
backgroundColor = {
order = 1,
type = "color",
name = L["Background color"],
hasAlpha = true,
set = setColor,
get = getColor,
arg = "backdrop.backgroundColor",
},
borderColor = {
order = 2,
type = "color",
name = L["Border color"],
hasAlpha = true,
set = setColor,
get = getColor,
arg = "backdrop.borderColor",
},
sep = {
order = 3,
type = "description",
name = "",
width = "full",
},
background = {
order = 4,
type = "select",
name = L["Background"],
dialogControl = "LSM30_Background",
values = getMediaData,
arg = "backdrop.backgroundTexture",
},
border = {
order = 5,
type = "select",
name = L["Border"],
dialogControl = "LSM30_Border",
values = getMediaData,
arg = "backdrop.borderTexture",
},
inset = {
order = 5.5,
type = "range",
name = L["Inset"],
desc = L["How far the background should be from the unit frame border."],
min = -10, max = 10, step = 1,
hidden = hideAdvancedOption,
arg = "backdrop.inset",
},
sep2 = {
order = 6,
type = "description",
name = "",
width = "full",
hidden = hideAdvancedOption,
},
edgeSize = {
order = 7,
type = "range",
name = L["Edge size"],
desc = L["How large the edges should be."],
hidden = hideAdvancedOption,
min = 0, max = 20, step = 1,
arg = "backdrop.edgeSize",
},
tileSize = {
order = 8,
type = "range",
name = L["Tile size"],
desc = L["How large the background should tile"],
hidden = hideAdvancedOption,
min = 0, max = 20, step = 1,
arg = "backdrop.tileSize",
},
clip = {
order = 9,
type = "range",
name = L["Clip"],
desc = L["How close the frame should clip with the border."],
hidden = hideAdvancedOption,
min = 0, max = 20, step = 1,
arg = "backdrop.clip",
},
},
},
font = {
order = 3,
type = "group",
inline = true,
name = L["Font"],
args = {
color = {
order = 1,
type = "color",
name = L["Default color"],
desc = L["Default font color, any color tags inside individual tag texts will override this."],
hasAlpha = true,
set = setColor,
get = getColor,
arg = "font.color",
hidden = hideAdvancedOption,
},
sep = {order = 1.25, type = "description", name = "", hidden = hideAdvancedOption},
font = {
order = 1.5,
type = "select",
name = L["Font"],
dialogControl = "LSM30_Font",
values = getMediaData,
arg = "font.name",
},
size = {
order = 2,
type = "range",
name = L["Size"],
min = 1, max = 50, step = 1, softMin = 1, softMax = 20,
arg = "font.size",
},
outline = {
order = 3,
type = "select",
name = L["Outline"],
values = {["OUTLINE"] = L["Thin outline"], ["THICKOUTLINE"] = L["Thick outline"], ["MONOCHROMEOUTLINE"] = L["Monochrome Outline"], [""] = L["None"]},
arg = "font.extra",
hidden = hideAdvancedOption,
},
},
},
bar = {
order = 4,
type = "group",
inline = true,
name = L["Bars"],
hidden = hideAdvancedOption,
args = {
override = {
order = 0,
type = "toggle",
name = L["Override color"],
desc = L["Forces a static color to be used for the background of all bars"],
set = function(info, value)
if( value and not ShadowUF.db.profile.bars.backgroundColor ) then
ShadowUF.db.profile.bars.backgroundColor = {r = 0, g = 0, b = 0}
elseif( not value ) then
ShadowUF.db.profile.bars.backgroundColor = nil
end
ShadowUF.Layout:Reload()
end,
get = function(info)
return ShadowUF.db.profile.bars.backgroundColor and true or false
end,
},
color = {
order = 1,
type = "color",
name = L["Background color"],
desc = L["This will override all background colorings for bars including custom set ones."],
set = setColor,
get = function(info)
if( not ShadowUF.db.profile.bars.backgroundColor ) then
return {r = 0, g = 0, b = 0}
end
return getColor(info)
end,
disabled = function(info) return not ShadowUF.db.profile.bars.backgroundColor end,
arg = "bars.backgroundColor",
},
sep = { order = 2, type = "description", name = "", width = "full"},
barAlpha = {
order = 3,
type = "range",
name = L["Bar alpha"],
desc = L["Alpha to use for bar."],
arg = "bars.alpha",
min = 0, max = 1, step = 0.05,
isPercent = true
},
backgroundAlpha = {
order = 4,
type = "range",
name = L["Background alpha"],
desc = L["Alpha to use for bar backgrounds."],
arg = "bars.backgroundAlpha",
min = 0, max = 1, step = 0.05,
isPercent = true
},
},
},
},
},
color = {
order = 2,
type = "group",
name = L["Colors"],
args = {
health = {
order = 1,
type = "group",
inline = true,
name = L["Health"],
set = setColor,
get = getColor,
args = {
green = {
order = 1,
type = "color",
name = L["High health"],
desc = L["Health bar color used as the transitional color for 100% -> 50% on players, as well as when your pet is happy."],
arg = "healthColors.green",
},
yellow = {
order = 2,
type = "color",
name = L["Half health"],
desc = L["Health bar color used as the transitional color for 100% -> 0% on players, as well as when your pet is mildly unhappy."],
arg = "healthColors.yellow",
},
red = {
order = 3,
type = "color",
name = L["Low health"],
desc = L["Health bar color used as the transitional color for 50% -> 0% on players, as well as when your pet is very unhappy."],
arg = "healthColors.red",
},
friendly = {
order = 4,
type = "color",
name = L["Friendly"],
desc = L["Health bar color for friendly units."],
arg = "healthColors.friendly",
},
neutral = {
order = 5,