-
Notifications
You must be signed in to change notification settings - Fork 0
/
Options.lua
1161 lines (1100 loc) · 30.9 KB
/
Options.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
-- OmniBar by Jordon
local addonName, addon = ...
local CLASS_ICON_TCOORDS = CLASS_ICON_TCOORDS
local CLASS_SORT_ORDER = CLASS_SORT_ORDER
local CreateFrame = CreateFrame
local DELETE = DELETE
local GENERAL = GENERAL
local GetAddOnMetadata = GetAddOnMetadata
local GetSpecializationInfoByID = GetSpecializationInfoByID
local GetSpellInfo = GetSpellInfo
local GetSpellTexture = GetSpellTexture
local LOCALIZED_CLASS_NAMES_MALE = LOCALIZED_CLASS_NAMES_MALE
local LibStub = LibStub
local MAX_CLASSES = MAX_CLASSES
local NO = NO
local OmniBar_CreateIcon = OmniBar_CreateIcon
local OmniBar_IsSpellEnabled = OmniBar_IsSpellEnabled
local OmniBar_LoadPosition = OmniBar_LoadPosition
local OmniBar_OnEvent = OmniBar_OnEvent
local OmniBar_Position = OmniBar_Position
local OmniBar_SavePosition = OmniBar_SavePosition
local SecondsToTime = SecondsToTime
local Spell = Spell
local StaticPopupDialogs = StaticPopupDialogs
local StaticPopup_Show = StaticPopup_Show
local UIParent = UIParent
local WOW_PROJECT_CLASSIC = 2
local WOW_PROJECT_ID = 1
local WOW_PROJECT_MAINLINE = 1
local YES = YES
local format = format
local nop = nop
local OmniBar = LibStub("AceAddon-3.0"):GetAddon("OmniBar")
local L = LibStub("AceLocale-3.0"):GetLocale("OmniBar")
local MAX_ARENA_SIZE = addon.MAX_ARENA_SIZE or 0
local LOCALIZED_CLASS_NAMES_MALE_WITH_GENERAL = {}
for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do
LOCALIZED_CLASS_NAMES_MALE_WITH_GENERAL[k] = v
end
LOCALIZED_CLASS_NAMES_MALE_WITH_GENERAL["GENERAL"] = GENERAL
local CLASS_SORT_ORDER_WITH_GENERAL = {}
for k,v in pairs(CLASS_SORT_ORDER) do
CLASS_SORT_ORDER_WITH_GENERAL[k] = v
end
CLASS_SORT_ORDER_WITH_GENERAL[0] = "GENERAL"
local points = {
TOPLEFT = L["Top Left"],
TOP = L["Top"],
TOPRIGHT = L["Top Right"],
LEFT = L["Left"],
CENTER = L["Center"],
RIGHT = L["Right"],
BOTTOMLEFT = L["Bottom Left"],
BOTTOM = L["Bottom"],
BOTTOMRIGHT = L["Bottom Right"],
}
local tooltip = CreateFrame("GameTooltip", "OmniBarTooltip", UIParent, "GameTooltipTemplate")
local function GetSpellTooltipText(spellID)
tooltip:SetOwner(UIParent, "ANCHOR_NONE")
tooltip:SetSpellByID(spellID)
local lines = tooltip:NumLines()
if lines < 1 then return end
local line = _G["OmniBarTooltipTextLeft"..lines]:GetText()
if not line then return end
tooltip:Hide()
return line
end
local function IsSpellEnabled(info)
local spellID = tonumber(info[#info])
local key = info[2]
return OmniBar_IsSpellEnabled(_G[key], spellID)
end
StaticPopupDialogs["OMNIBAR_DELETE"] = {
text = DELETE.." \"%s\"",
button1 = YES,
button2 = NO,
OnAccept = function(self, data)
OmniBar:Delete(data)
OmniBar:OnEnable()
end,
timeout = 0,
whileDead = true,
}
function OmniBar:ToggleLock(button)
self.db.profile.bars[button.arg].locked = not self.db.profile.bars[button.arg].locked
OmniBar_Position(_G[button.arg])
self.options.args.bars.args[button.arg].args.lock.name = self.db.profile.bars[button.arg].locked and L["Unlock"] or L["Lock"]
end
local function GetBars(key)
local bars = {}
for k in pairs(OmniBar.db.profile.bars) do if k ~= key then bars[k] = OmniBar.db.profile.bars[k].name end end
return bars
end
local function GetSpells()
local spells = {
uncheck = {
name = L["Uncheck All"],
type = "execute",
func = function(info)
local key = info[#info-2]
local bar = _G[key]
bar.settings.spells = {}
OmniBar:Refresh(true)
end,
order = 1,
},
check = {
name = L["Check Default Spells"],
type = "execute",
func = function(info)
local key = info[#info-2]
local bar = _G[key]
bar.settings.spells = nil
OmniBar:Refresh(true)
end,
order = 2,
},
checkAll = {
name = "Check All Spells",
type = "execute",
func = function(info)
local key = info[#info-2]
local bar = _G[key]
bar.settings.spells = {}
for k,v in pairs(addon.Cooldowns) do
if (not v.parent) then
bar.settings.spells[k] = true
end
end
OmniBar:Refresh(true)
end,
order = 3,
},
}
local descriptions = {}
for i = 0, MAX_CLASSES do
spells[CLASS_SORT_ORDER_WITH_GENERAL[i]] = {
name = LOCALIZED_CLASS_NAMES_MALE_WITH_GENERAL[CLASS_SORT_ORDER_WITH_GENERAL[i]],
type = "group",
args = {},
hidden = function(info)
local bar = info[#info-2]
local class = info[#info]
if info.options.args.bars.args[bar] and info.options.args.bars.args[bar].args.spells.args[class].args then
return next(info.options.args.bars.args[bar].args.spells.args[class].args) == nil
else
return false
end
end,
icon = "Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes",
iconCoords = CLASS_ICON_TCOORDS[CLASS_SORT_ORDER_WITH_GENERAL[i]]
}
if i == 0 then
spells[CLASS_SORT_ORDER_WITH_GENERAL[i]]["icon"] = "Interface\\Icons\\Trade_Engineering"
spells[CLASS_SORT_ORDER_WITH_GENERAL[i]]["iconCoords"] = nil
spells[CLASS_SORT_ORDER_WITH_GENERAL[i]]["order"] = 0
end
for spellID, spell in pairs(addon.Cooldowns) do
if spell.class and spell.class == CLASS_SORT_ORDER_WITH_GENERAL[i] then
local spellName = GetSpellInfo(spellID)
if spellName then
local spellTexture = OmniBar:GetSpellTexture(spellID) or ""
if string.len(spellName) > 25 then
spellName = string.sub(spellName, 0, 22) .. "..."
end
local desc = GetSpellDescription(spellID)
descriptions[spellID] = desc and desc or ""
spells[CLASS_SORT_ORDER_WITH_GENERAL[i]].args[tostring(spellID)] = {
type = "toggle",
get = IsSpellEnabled,
width = "full",
hidden = nop,
arg = spellID,
desc = function()
local duration = type(spell.duration) == "number" and spell.duration or spell.duration.default
local spellDesc = descriptions[spellID] or ""
local extra = "\n\n|cffffd700 "..L["Spell ID"].."|r "..spellID..
"\n\n|cffffd700 "..L["Cooldown"].."|r "..SecondsToTime(duration)
return spellDesc..extra
end,
name = function()
return format("|T%s:20|t %s", spellTexture, spellName)
end,
}
end
end
end
end
return spells
end
function OmniBar:AddBarToOptions(key, refresh)
local trackUnits = {
ENEMY = "All Enemies",
GROUP = "Group Members",
PLAYER = PLAYER,
TARGET = TARGET,
FOCUS = FOCUS,
party1 = PARTY .. " 1",
party2 = PARTY .. " 2",
party3 = PARTY .. " 3",
party4 = PARTY .. " 4",
}
local trackUnitsOrder = {
"ENEMY",
"PLAYER",
"TARGET",
"FOCUS",
"GROUP",
"party1",
"party2",
"party3",
"party4",
}
for i = 1, MAX_ARENA_SIZE do
local unit = "arena" .. i
trackUnits[unit] = ARENA .. " " .. i
tinsert(trackUnitsOrder, unit)
end
self.options.args.bars.args[key] = {
name = self.db.profile.bars[key].name,
type = "group",
order = self.index + 1,
childGroups = "tab",
get = function(info)
local option = info[#info]
return self.db.profile.bars[key][option]
end,
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self:Refresh()
end,
args = {
settings = {
name = L["Settings"],
type = "group",
order = 10,
args = {
name = {
name = L["Name"],
desc = L["Set the name of the bar"],
type = "input",
width = "double",
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self.options.args.bars.args[key].name = state
local f = _G[key.."AnchorText"]
f:SetText(state)
local width = f:GetWidth() + 28
_G[key.."Anchor"]:SetSize(width, 30)
self:Refresh()
end,
order = 1,
},
trackUnit = {
name = "Track",
type = "select",
values = trackUnits,
--sorting = trackUnitsOrder,
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self:Refresh(true)
end,
order = 2,
},
lb1 = {
name = "",
type = "description",
order = 3,
},
center = {
name = L["Center Lock"],
desc = L["Keep the bar centered horizontally"],
width = "normal",
type = "toggle",
order = 4,
},
showUnused = {
name = L["Show Unused Icons"],
desc = L["Icons will always remain visible"],
width = "normal",
type = "toggle",
order = 5,
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self:Refresh(true)
end,
},
adaptive = {
name = L["As Enemies Appear"],
desc = L["Only show unused icons for arena opponents or enemies you target while in combat"],
disabled = function()
return (not self.db.profile.bars[key].showUnused) or self.db.profile.bars[key].trackUnit ~= "ENEMY"
end,
width = "normal",
type = "toggle",
order = 6,
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self:Refresh(true)
end,
},
growUpward = {
name = L["Grow Rows Upward"],
desc = L["Toggle the grow direction of the icons"],
width = "normal",
type = "toggle",
order = 7,
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
OmniBar_Position(_G[key])
end,
},
cooldownCount = {
name = L["Countdown Count"],
desc = L["Allow Blizzard and other addons to display countdown text on the icons"],
width = "normal",
type = "toggle",
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self:Refresh(true)
end,
order = 8,
},
border = {
name = L["Show Border"],
desc = L["Draw a border around the icons"],
width = "normal",
type = "toggle",
order = 9,
},
highlightTarget = {
name = L["Highlight Target"],
desc = L["Draw a border around your target"],
width = "normal",
type = "toggle",
order = 10,
disabled = function()
return self.db.profile.bars[key].trackUnit ~= "ENEMY"
end,
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self:Refresh(true)
end,
},
names = {
name = L["Show Names"],
desc = L["Show the player name of the spell"],
width = "normal",
type = "toggle",
order = 11,
},
multiple = {
name = L["Track Multiple Players"],
desc = L["If another player is detected using the same ability, a duplicate icon will be created and tracked separately"],
width = "normal",
disabled = function()
return self.db.profile.bars[key].trackUnit ~= "ENEMY"
end,
type = "toggle",
order = 16,
},
glow = {
name = L["Glow Icons"],
desc = L["Display a glow animation around an icon when it is activated"],
width = "normal",
type = "toggle",
order = 17,
},
tooltips = {
name = L["Show Tooltips"],
desc = L["Show spell information when mousing over the icons (the bar must be unlocked)"],
width = "normal",
type = "toggle",
order = 18,
},
lb2 = {
name = "",
type = "description",
order = 19,
},
align = {
name = L["Alignment"],
desc = L["Set the alignment of the icons to the anchor"],
type = "select",
values = {
CENTER = L["Center"],
LEFT = L["Left"],
RIGHT = L["Right"],
},
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self:Refresh(true)
end,
order = 20,
},
lb5 = {
name = "",
type = "description",
order = 21,
},
size = {
name = L["Size"],
desc = L["Set the size of the icons"],
type = "range",
min = 1,
max = 100,
step = 1,
order = 100,
width = "double",
},
sizeDesc = {
name = L["Set the size of the icons"] .. "\n",
type = "description",
order = 101,
},
columns = {
name = L["Columns"],
desc = L["Set the maximum icons per row"],
type = "range",
min = 1,
max = 100,
step = 1,
order = 102,
width = "double",
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
OmniBar_Position(_G[key])
end,
},
columnsDesc = {
name = L["Set the maximum icons per row"] .. "\n",
type = "description",
order = 103,
},
maxIcons = {
name = L["Icon Limit"],
desc = L["Set the maximum number of icons displayed on the bar"],
type = "range",
min = 1,
max = 500,
step = 1,
order = 104,
width = "double",
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self:Refresh(true)
end,
},
maxIconsDesc = {
name = L["Set the maximum number of icons displayed on the bar"] .. "\n",
type = "description",
order = 105,
},
padding = {
name = L["Padding"],
desc = L["Set the space between icons"],
type = "range",
min = 0,
max = 100,
step = 1,
order = 106,
width = "double",
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
OmniBar_Position(_G[key])
end,
},
paddingDesc = {
name = L["Set the space between icons"] .. "\n",
type = "description",
order = 107,
},
unusedAlpha = {
name = L["Unused Icon Transparency"],
desc = L["Set the transparency of unused icons"],
isPercent = true,
type = "range",
min = 0,
max = 1,
step = 0.01,
order = 108,
width = "double",
},
unusedAlphaDesc = {
name = L["Set the transparency of unused icons"] .. "\n",
type = "description",
order = 109,
},
},
},
position = {
name = L["Position"],
type = "group",
order = 11,
get = function(info)
local option = info[#info]
return self.db.profile.bars[key].position[option]
end,
set = function(info, state)
local option = info[#info]
local set = {}
set[option] = state
OmniBar_SavePosition(_G[key], set)
OmniBar_LoadPosition(_G[key])
end,
args = {
reset = {
name = L["Reset"],
desc = L["Reset the position of the bar"],
type = "execute",
func = function()
OmniBar_SavePosition(_G[key], {
point = "CENTER",
relativeTo = "UIParent",
relativePoint = "CENTER",
xOfs = 0,
yOfs = 0,
frameStrata = "MEDIUM",
})
OmniBar_LoadPosition(_G[key])
end,
order = 1,
},
lb3 = {
name = "",
type = "description",
order = 2,
},
point = {
name = L["Point"],
desc = L["Set the point of the bar that will anchor"],
type = "select",
values = points,
order = 3,
},
lb4 = {
name = "",
type = "description",
order = 4,
},
relativeTo = {
type = "input",
width = "double",
name = L["Relative To"],
desc = L["Set the name of the frame the bar will attach to"],
order = 5,
},
relativePoint = {
name = L["Relative Point"],
desc = L["Set the point of the frame to attach the bar"],
type = "select",
values = points,
order = 7,
},
lb6 = {
name = "",
type = "description",
order = 8,
},
xOfs = {
type = "range",
name = L["X"],
desc = L["Set the X offset of the bar"],
min = -2560,
max = 2560,
bigStep = 4,
order = 9,
},
yOfs = {
type = "range",
name = L["Y"],
desc = L["Set the Y offset of the bar"],
min = -1600,
max = 1600,
bigStep = 5,
order = 10,
},
lb7 = {
name = "",
type = "description",
order = 11,
},
frameStrata = {
name = L["Frame Strata"],
desc = L["Set the strata of the bar"],
type = "select",
values = {
BACKGROUND = L["Background"],
LOW = L["Low"],
MEDIUM = L["Medium"],
HIGH = L["High"],
DIALOG = L["Dialog"],
FULLSCREEN = L["Fullscreen"],
FULLSCREEN_DIALOG = L["Fullscreen Dialog"],
TOOLTIP = L["Tooltip"],
},
order = 12,
},
},
},
visibility = {
name = L["Visibility"],
type = "group",
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
OmniBar_OnEvent(_G[key], "PLAYER_ENTERING_WORLD")
end,
order = 12,
args = {
battleground = {
name = L["Show in Battlegrounds"],
desc = L["Show the icons in battlegrounds"],
width = "double",
type = "toggle",
order = 13,
},
world = {
name = L["Show in World"],
desc = L["Show the icons in the world"],
width = "double",
type = "toggle",
order = 15,
},
},
},
spells = {
name = L["Spells"],
type = "group",
order = 13,
arg = key,
args = GetSpells(),
set = function(info, state)
local spellID = tonumber(info[#info])
-- set default spells explicitly
if (not self.db.profile.bars[key].spells) then
self.db.profile.bars[key].spells = {}
for k,v in pairs(addon.Cooldowns) do
if v.default then
self.db.profile.bars[key].spells[k] = true
end
end
end
self.db.profile.bars[key].spells[spellID] = state
OmniBar_CreateIcon(_G[key])
self:Refresh(true)
end,
},
lock = {
type = "execute",
name = self.db.profile.bars[key].locked and L["Unlock"] or L["Lock"],
desc = L["Lock the bar to prevent dragging"],
arg = key,
func = "ToggleLock",
handler = OmniBar,
order = 1,
},
delete = {
type = "execute",
name = L["Delete"],
desc = L["Delete the bar"],
func = function()
local popup = StaticPopup_Show("OMNIBAR_DELETE", self.db.profile.bars[key].name)
if popup then popup.data = key end
end,
arg = key,
order = 2,
},
},
}
self.options.args.bars.args[key].args.spells.args.copy = {
name = "Copy From: ",
desc = "Copies spells from the selected OmniBar",
type = "select",
width = "normal",
values = GetBars(key),
set = function(info, state)
local key = info[#info-2]
local dst = _G[key]
local src = _G[state]
if (not src.settings.spells) then
dst.settings.spells = nil
return
end
dst.settings.spells = {}
for k,v in pairs(src.settings.spells) do
dst.settings.spells[k] = v
end
OmniBar:Refresh(true)
end,
order = 3,
}
if WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC then
self.options.args.bars.args[key].args.settings.args.highlightFocus = {
name = L["Highlight Focus"],
desc = L["Draw a border around your focus"],
width = "normal",
type = "toggle",
order = 10,
disabled = function()
return self.db.profile.bars[key].trackUnit ~= "ENEMY"
end,
set = function(info, state)
local option = info[#info]
self.db.profile.bars[key][option] = state
self:Refresh(true)
end,
}
self.options.args.bars.args[key].args.visibility.args.arena = {
name = L["Show in Arena"],
desc = L["Show the icons in arena"],
width = "double",
type = "toggle",
order = 11,
}
end
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
self.options.args.bars.args[key].args.visibility.args.ratedBattleground = {
name = L["Show in Rated Battlegrounds"],
desc = L["Show the icons in rated battlegrounds"],
width = "double",
type = "toggle",
order = 12,
}
self.options.args.bars.args[key].args.visibility.args.scenario = {
name = L["Show in Scenarios"],
desc = L["Show the icons in scenarios"],
width = "double",
type = "toggle",
order = 14,
}
end
if refresh then LibStub("AceConfigRegistry-3.0"):NotifyChange("OmniBar") end
end
local specIDs = {
62, 63, 64, 65, 66, 70, 71, 72, 73, 102, 103, 104, 105,
250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260,
261, 262, 263, 264, 265, 266, 267, 268, 269, 270
}
local customSpellInfo = {
spellId = {
order = 1,
type = "description",
name = function(info)
local spellId = info[#info-1]
return "|cffffd700 ".."Spell ID".."|r ".. spellId .."\n"
end,
},
delete = {
type = "execute",
name = L["Delete"],
desc = L["Delete the cooldown"],
func = function(info)
local spellId = info[#info-1]
spellId = tonumber(spellId)
OmniBar.db.global.cooldowns[spellId] = nil
addon.Cooldowns[spellId] = nil
OmniBar:AddCustomSpells()
info.options.args.customSpells.args[info[#info-1]] = nil
OmniBar:OnEnable() -- to refresh the bar spells tab
LibStub("AceConfigRegistry-3.0"):NotifyChange("OmniBar")
end,
order = 2,
},
lb = {
name = "",
type = "header",
order = 3,
},
duration = {
name = L["Duration"],
width = "double",
desc = L["Set the duration of the cooldown"],
type = "range",
min = 1,
softMax = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC and 1200 or 600,
step = 1,
order = 4,
set = function(info, state)
local spellId = info[#info-1]
spellId = tonumber(spellId)
OmniBar.db.global.cooldowns[spellId].duration.default = state
OmniBar:AddCustomSpells()
end,
get = function(info)
local spellId = info[#info-1]
spellId = tonumber(spellId)
return OmniBar.db.global.cooldowns[spellId].duration.default
end,
},
charges = {
order = 6,
type = "range",
min = 1,
max = 10,
step = 1,
name = L["Charges"],
desc = L["Set the charges of the cooldown"],
set = function(info, state)
local option = info[#info]
local spellId = info[#info-1]
spellId = tonumber(spellId)
if state == 1 then state = nil end
OmniBar.db.global.cooldowns[spellId][option] = state
OmniBar:AddCustomSpells()
end,
get = function(info)
local option = info[#info]
local spellId = info[#info-1]
spellId = tonumber(spellId)
local value = OmniBar.db.global.cooldowns[spellId][option]
if not value then return 1 end
return OmniBar.db.global.cooldowns[spellId][option]
end,
},
class = {
name = L["Class"],
desc = L["Set the class of the cooldown"],
type = "select",
values = LOCALIZED_CLASS_NAMES_MALE_WITH_GENERAL,
order = 5,
set = function(info, state)
local option = info[#info]
local spellId = info[#info-1]
spellId = tonumber(spellId)
OmniBar.db.global.cooldowns[spellId].specID = nil
OmniBar.db.global.cooldowns[spellId].duration = { default = OmniBar.db.global.cooldowns[spellId].duration.default }
OmniBar.db.global.cooldowns[spellId][option] = state
OmniBar:OnEnable() -- to refresh the bar spells tab
OmniBar:AddCustomSpells()
end,
},
icon = {
name = "Icon",
desc = "Set the icon of the cooldown",
type = "input",
get = function(info)
local spellId = info[#info-1]
return tostring(OmniBar:GetSpellTexture(spellId))
end,
set = function(info, state)
local option = info[#info]
local spellId = info[#info-1]
OmniBar.db.global.cooldowns[tonumber(spellId)][option] = tonumber(state)
OmniBar:OnEnable() -- to refresh the bar spells tab
OmniBar:AddCustomSpells()
end,
},
}
local customSpells = {
spellId = {
name = L["Spell ID"],
type = "input",
set = function(info, state)
local spellId = tonumber(state)
local name = GetSpellInfo(spellId)
if OmniBar.db.global.cooldowns[spellId] then return end
if spellId and name then
OmniBar.db.global.cooldowns[spellId] = addon.Cooldowns[spellId] or { custom = true, duration = { default = 30 } , class = "GENERAL" }
local duration
-- If it's a child convert it
if OmniBar.db.global.cooldowns[spellId].parent then
-- If the child has a custom duration, save it so we can restore it after we copy from parent
if OmniBar.db.global.cooldowns[spellId].duration then
duration = OmniBar.db.global.cooldowns[spellId].duration
end
OmniBar.db.global.cooldowns[spellId] = OmniBar:CopyCooldown(addon.Cooldowns[OmniBar.db.global.cooldowns[spellId].parent])
-- Restore child's duration
if duration then
OmniBar.db.global.cooldowns[spellId].duration = duration
end
end
-- convert duration to array
if type(OmniBar.db.global.cooldowns[spellId].duration) == "number" then
OmniBar.db.global.cooldowns[spellId].duration = { default = OmniBar.db.global.cooldowns[spellId].duration }
end
OmniBar:AddCustomSpells()
OmniBar.options.args.customSpells.args[tostring(spellId)] = {
name = name,
type = "group",
childGroups = "tab",
args = customSpellInfo,
icon = OmniBar:GetSpellTexture(spellId),
}
OmniBar:OnEnable() -- to refresh the bar spells tab
LibStub("AceConfigRegistry-3.0"):NotifyChange("OmniBar")
end
end,
},
}
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
for i = 1, #specIDs do
local specID = specIDs[i]
local _, name, _, icon = GetSpecializationInfoByID(specID)
customSpellInfo["spec"..specID] = {
name = format("|T%s:20|t %s", icon, name),
hidden = function(info)
local spellId = info[#info-1]
spellId = tonumber(spellId)
local specID = info[#info]:gsub("spec", "")
specID = tonumber(specID)
if not specID then return end
if OmniBar.db.global.cooldowns[spellId].class ~= select(6, GetSpecializationInfoByID(specID)) then return true end
end,
desc = "",
type = "group",
args = {
enabled = {
name = L["Enabled"],
desc = L["Enable the cooldown for this specialization"],
type = "toggle",
order = 1,
get = function(info)
local option = info[#info]
local spellId = info[#info-2]
spellId = tonumber(spellId)
local specID = info[#info-1]:gsub("spec", "")
specID = tonumber(specID)
if not OmniBar.db.global.cooldowns[spellId].specID then return true end
for i = 1, #OmniBar.db.global.cooldowns[spellId].specID do
if OmniBar.db.global.cooldowns[spellId].specID[i] == specID then return true end
end
return false
end,
set = function(info, state)
local option = info[#info]
local spellId = info[#info-2]
spellId = tonumber(spellId)
local specID = info[#info-1]:gsub("spec", "")
specID = tonumber(specID)
-- check all specs first
if not OmniBar.db.global.cooldowns[spellId].specID then
OmniBar.db.global.cooldowns[spellId].specID = {}
for i = 1, #specIDs do
if OmniBar.db.global.cooldowns[spellId].class == select(6, GetSpecializationInfoByID(specIDs[i])) then
table.insert(OmniBar.db.global.cooldowns[spellId].specID, specIDs[i])
end
end
end