-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebuffFilter.lua
More file actions
1397 lines (1285 loc) · 59 KB
/
DebuffFilter.lua
File metadata and controls
1397 lines (1285 loc) · 59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local AddonName = "DebuffFilter"
local DebuffFilter = LibStub:NewLibrary(AddonName, 8)
local MAX_TARGET_DEBUFFS = 16
local MAX_TARGET_BUFFS = 32
local AURA_START_Y = 32
local AURA_START_X = 5
local mabs, pairs, mfloor = math.abs, pairs, math.floor
local tinsert, tsort, tostring = table.insert, table.sort, tostring
local UnitBuff, UnitDebuff, UnitIsEnemy = _G.UnitBuff, _G.UnitDebuff, _G.UnitIsEnemy
local UnitIsUnit, UnitIsOwnerOrControllerOfUnit, UnitIsFriend = _G.UnitIsUnit, _G.UnitIsOwnerOrControllerOfUnit, _G.UnitIsFriend
local IsAddOnLoaded = C_AddOns and C_AddOns.IsAddOnLoaded or IsAddOnLoaded
local GetAddOnInfo = C_AddOns and C_AddOns.GetAddOnInfo or GetAddOnInfo
local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetadata
local playerClass = select(2, UnitClass("player"))
local lastTime, fontName = 0
local defaults = {
profile = {
hiddenBuffs = {},
selfSize = 21,
otherSize = 20,
auraWidth = 122,
verticalSpace = 1,
horizontalSpace = 3,
customHighlights = {},
customHighlightColors = {},
customSizes = {},
sortBySize = false,
sortbyDispellable = false,
highlightAll = false,
enablePrioritySort = false,
customHighlightPriorities = {},
customShowOwnOnly = {},
removeDuplicates = {},
focusBarPosX = 0,
focusBarPosY = 0,
targetBarPosX = 0,
targetBarPosY = 0,
targetCastBarSize = 1,
focusCastBarSize = 1,
}
}
function DebuffFilter:AddCustomHighlightOptions()
local new_args = {}
for _, buff in ipairs(self.db.profile.customHighlights) do
local buffName = tonumber(buff) and GetSpellInfo(buff) .. " (" .. buff .. ")" or buff
local customSize = self.db.profile.customSizes[buff] or {}
self.db.profile.customSizes[buff] = customSize
customSize.enabled = customSize.enabled or false
customSize.ownSize = customSize.ownSize or self.db.profile.selfSize
customSize.otherSize = customSize.otherSize or self.db.profile.otherSize
new_args["highlight_" .. buff] = {
type = "group",
name = buffName,
args = {
delete = {
order = 1,
type = "execute",
width = "0.5",
name = "Delete",
func = function()
local cur_index = 0
for i, value in ipairs(self.db.profile.customHighlights) do
if value == buff then
cur_index = i
break
end
end
if cur_index > 0 then
table.remove(self.db.profile.customHighlights, cur_index)
self.db.profile.customHighlightColors[buff] = nil
self.db.profile.customSizes[buff] = nil
self.options.args.highlightBuffs.args.buffList.args = self:AddCustomHighlightOptions()
end
end
},
color = {
order = 2,
type = "color",
name = "Color",
get = function(info)
local color = self.db.profile.customHighlightColors[buff]
if not color then
color = { r = 1, g = 1, b = 1, a = 1 }
self.db.profile.customHighlightColors[buff] = color
end
return color.r, color.g, color.b, color.a
end,
set = function(info, r, g, b, a)
self.db.profile.customHighlightColors[buff] = { r = r, g = g, b = b, a = a }
TargetFrame_UpdateAuras(TargetFrame)
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end,
},
customSizeToggle = {
order = 3,
type = "toggle",
width = "full",
name = "Enable custom sizing",
get = function(info)
return self.db.profile.customSizes[buff].enabled
end,
set = function(info, val)
self.db.profile.customSizes[buff].enabled = val
if val == false then
self.db.profile.customSizes[buff] = {
ownSize = self.db.profile.selfSize,
otherSize = self.db.profile.otherSize
}
end
end,
},
ownAuraSize = {
order = 4,
type = "range",
width = 1.2,
name = "Personal aura size",
desc = "Change this aura's size when cast by you",
min = 17,
max = 34,
step = 1,
get = function(info)
local size = self.db.profile.customSizes[buff].ownSize
if not size then
size = self.db.profile.selfSize
self.db.profile.customSizes[buff].ownSize = size
end
return size
end,
set = function(info, val)
self.db.profile.customSizes[buff].ownSize = val
TargetFrame_UpdateAuras(TargetFrame)
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end,
hidden = function()
return not self.db.profile.customSizes[buff].enabled
end,
},
otherAuraSize = {
order = 4.5,
type = "range",
width = 1.2,
name = "Other's aura size",
desc = "Change this aura's size when cast by others",
min = 17,
max = 34,
step = 1,
get = function(info)
local size = self.db.profile.customSizes[buff].otherSize
if not size then
size = self.db.profile.otherSize
self.db.profile.customSizes[buff].otherSize = size
end
return size
end,
set = function(info, val)
self.db.profile.customSizes[buff].otherSize = val
TargetFrame_UpdateAuras(TargetFrame)
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end,
hidden = function()
return not self.db.profile.customSizes[buff].enabled
end,
},
priority = {
order = 5,
type = "range",
width = 2,
name = "Priority",
desc = "Set the priority of the aura",
min = 0,
max = 100,
step = 1,
get = function(info)
local priority = self.db.profile.customHighlightPriorities[buff]
if not priority then
priority = 0
self.db.profile.customHighlightPriorities[buff] = priority
end
return priority
end,
set = function(info, val)
self.db.profile.customHighlightPriorities[buff] = val
TargetFrame_UpdateAuras(TargetFrame)
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end,
hidden = function()
return not self.db.profile.enablePrioritySort
end,
},
separator = {
order = 6,
type = "description",
name = "\n",
width = "full"
},
ownOnly = {
order = 7,
type = "toggle",
name = "Show own buff only",
desc = "Hides the aura when it is not applied by you",
get = function(info)
return self.db.profile.customShowOwnOnly[buff]
end,
set = function(info, val)
self.db.profile.customShowOwnOnly[buff] = val
end,
},
removeDuplicates = {
order = 8,
type = "toggle",
name = "Hide duplicate auras",
desc = "Hides duplicate effects of this aura",
get = function(info)
return self.db.profile.removeDuplicates[buff]
end,
set = function(info, val)
self.db.profile.removeDuplicates[buff] = val
end,
},
spellTitle = {
order = 0.5,
type = "description",
name = buffName,
fontSize = "medium",
width = "full",
},
},
}
end
return new_args
end
local function updateCastbarPosition(bar, val, xPos)
if not bar:IsShown() then
bar:SetAlpha(1)
bar:Show()
end
local a, b, c, d, e = bar:GetPoint()
bar:ClearAllPoints()
if xPos then
bar:SetPoint(a, b, c, val, e)
else
bar:SetPoint(a, b, c, d, val)
end
lastTime = GetTime()
C_Timer.After(3, function()
if (GetTime() - lastTime) > 2 then
bar:SetAlpha(0)
bar:Hide()
end
end)
end
function DebuffFilter:SetupOptions()
self.db = LibStub("AceDB-3.0"):New("DebuffFilterDB", defaults, true)
self.options = {
type = "group",
childGroups = "tab",
plugins = {},
args = {
author = {
name = "|cff4693E6Author:|r Xyz",
type = "description"
},
version = {
name = "|cff4693E6Version:|r " .. GetAddOnMetadata("DebuffFilter", "Version") .. "\n",
type = "description"
},
moreoptions = {
name = "Hide Auras",
type = "group",
order = 1,
args = {
buffNameInput = {
order = 1,
width = 1.5,
name = "Add (De)Buff By Name / Spell Id",
desc = "Type the name or spell id of a (de)buff to hide",
type = "input",
set = function(info, val)
if tonumber(val) then
if not GetSpellInfo(val) then
return
end
val = tostring(val)
end
for _, value in ipairs(self.db.profile.hiddenBuffs) do
if value == val then
return
end
end
tinsert(self.db.profile.hiddenBuffs, val);
tsort(self.db.profile.hiddenBuffs)
TargetFrame_UpdateAuras(TargetFrame);
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end,
},
buffList = {
order = 3,
width = 1,
name = "Hidden Auras:",
type = "multiselect",
values = function()
local list = {}
for _, value in pairs(self.db.profile.hiddenBuffs) do
local spellName = GetSpellInfo(value)
if spellName then
list[value] = spellName .. " (" .. value .. ")"
else
list[value] = value
end
end
return list
end,
get = function(info, val)
return true;
end,
set = function(info, val)
for index, spellID in ipairs(self.db.profile.hiddenBuffs) do
if spellID == val then
table.remove(self.db.profile.hiddenBuffs, index)
break
end
end
end,
confirm = function(info, val, v2)
local spellName = GetSpellInfo(val) or val
return "Delete " .. spellName .. " (" .. val .. ")?"
end
},
},
},
sizeoptions = {
name = "General Settings",
type = "group",
order = 2,
args = {
fancySliders = {
order = 1,
type = "group",
inline = false,
name = "Resizer",
args = {
selfSize = {
order = 1,
width = 2,
name = "My Debuffs/Buffs size",
desc = "Resize your own (de)buffs displayed on target",
type = "range",
min = 17,
max = 34,
step = 1,
get = function(info, val)
return self.db.profile.selfSize
end,
set = function(info, val)
self.db.profile.selfSize = val
TargetFrame_UpdateAuras(TargetFrame);
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end
},
otherSize = {
order = 2,
width = 2,
name = "Others Debuffs/Buffs size",
desc = "Resize the (de)buffs casted by others that are displayed on target",
type = "range",
min = 17,
max = 34,
step = 1,
get = function(info, val)
return self.db.profile.otherSize
end,
set = function(info, val)
self.db.profile.otherSize = val
TargetFrame_UpdateAuras(TargetFrame);
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end
},
auraWidth = {
order = 3,
width = 2,
name = "Aura row width",
desc = "How many auras do you want per row?",
type = "range",
min = 108,
max = 178,
step = 14,
get = function(info, val)
return self.db.profile.auraWidth
end,
set = function(info, val)
self.db.profile.auraWidth = val
TargetFrame_UpdateAuras(TargetFrame);
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end
},
verticalSpacing = {
order = 4,
width = 2,
name = "Vertical spacing",
desc = "The spacing between aura rows",
type = "range",
min = 1,
max = 50,
step = 1,
get = function(info, val)
return self.db.profile.verticalSpace
end,
set = function(info, val)
self.db.profile.verticalSpace = val
TargetFrame_UpdateAuras(TargetFrame);
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end
},
horizontalSpacing = {
order = 5,
width = 2,
name = "Horizontal spacing",
desc = "The spacing between auras",
type = "range",
min = 3,
max = 35,
step = 1,
get = function(info, val)
return self.db.profile.horizontalSpace
end,
set = function(info, val)
self.db.profile.horizontalSpace = val
TargetFrame_UpdateAuras(TargetFrame);
if FocusFrame then
TargetFrame_UpdateAuras(FocusFrame)
end
end
},
},
},
fancyCheckboxes = {
order = 2,
type = "group",
inline = false,
name = "Sorting options",
args = {
sortBySize = {
order = 1,
type = "toggle",
name = "Sort auras by size",
desc = "Recommended when using a different size per aura",
get = function()
return self.db.profile.sortBySize
end,
set = function(_, value)
self.db.profile.sortBySize = value
end,
},
sortbyDispellable = {
order = 2,
type = "toggle",
name = "Sort by dispellable",
desc = "Shows dispellable buffs first, unless size or priority sorting is enabled",
get = function()
return self.db.profile.sortbyDispellable
end,
set = function(_, value)
self.db.profile.sortbyDispellable = value
end,
},
highlightAll = {
order = 3,
type = "toggle",
name = "Highlight magic buffs",
desc = "Shows a glowing border on all dispellable magic buffs",
get = function()
return self.db.profile.highlightAll
end,
set = function(_, value)
self.db.profile.highlightAll = value
end,
},
enablePrioritySort = {
order = 4,
type = "toggle",
name = "Enable priority slider",
desc = "When enabled 'auras-specific customizations' will display an extra slider",
get = function()
return self.db.profile.enablePrioritySort
end,
set = function(_, value)
self.db.profile.enablePrioritySort = value
end,
},
},
},
fancyCastBar = {
order = 3,
type = "group",
inline = false,
name = "Castbar settings",
args = {
targetSpellbarPosX = {
order = 1,
width = 1.5,
name = "Target spellbar horizontal position",
desc = "Set horizontal & vertical to 0 for default behaviour",
type = "range",
min = -300,
max = 300,
step = 1,
get = function(info, val)
return self.db.profile.targetBarPosX
end,
set = function(info, val)
self.db.profile.targetBarPosX = val
updateCastbarPosition(TargetFrameSpellBar, val, true)
end
},
targetSpellbarPosY = {
order = 2,
width = 1.5,
name = "Target spellbar vertical position",
desc = "Set horizontal & vertical to 0 for default behaviour",
type = "range",
min = -300,
max = 300,
step = 1,
get = function(info, val)
return self.db.profile.targetBarPosY
end,
set = function(info, val)
self.db.profile.targetBarPosY = val
updateCastbarPosition(TargetFrameSpellBar, val, false)
end
},
focusSpellbarPosX = {
order = 3,
width = 1.5,
name = "Focus spellbar horizontal position",
desc = "Set horizontal & vertical to 0 for default behaviour",
type = "range",
min = -300,
max = 300,
step = 1,
get = function(info, val)
return self.db.profile.focusBarPosX
end,
set = function(info, val)
self.db.profile.focusBarPosX = val
updateCastbarPosition(FocusFrameSpellBar, val, true)
end
},
focusSpellbarPosY = {
order = 4,
width = 1.5,
name = "Focus spellbar vertical position",
desc = "Set horizontal & vertical to 0 for default behaviour",
type = "range",
min = -300,
max = 300,
step = 1,
get = function(info, val)
return self.db.profile.focusBarPosY
end,
set = function(info, val)
self.db.profile.focusBarPosY = val
updateCastbarPosition(FocusFrameSpellBar, val, false)
end
},
targetSpellbarScale = {
order = 5,
width = 1.5,
name = "Target spellbar size",
desc = "Change the scale of the castbar",
type = "range",
min = 0.7,
max = 3,
step = 0.05,
get = function(info, val)
return self.db.profile.targetCastBarSize
end,
set = function(info, val)
self.db.profile.targetCastBarSize = val
TargetFrameSpellBar:SetScale(self.db.profile.targetCastBarSize)
if not TargetFrameSpellBar:IsShown() then
TargetFrameSpellBar:SetAlpha(1)
TargetFrameSpellBar:Show()
end
end
},
focusSpellbarScale = {
order = 6,
width = 1.5,
name = "Focus spellbar size",
desc = "Change the scale of the castbar",
type = "range",
min = 0.7,
max = 3,
step = 0.05,
get = function(info, val)
return self.db.profile.focusCastBarSize
end,
set = function(info, val)
self.db.profile.focusCastBarSize = val
FocusFrameSpellBar:SetScale(self.db.profile.focusCastBarSize)
if not FocusFrameSpellBar:IsShown() then
FocusFrameSpellBar:SetAlpha(1)
FocusFrameSpellBar:Show()
end
end
},
},
},
},
},
highlightBuffs = {
type = "group",
name = "Aura-specific customization",
childGroups = "tree",
order = 3,
args = {
buffNameInput = {
order = 1,
width = 1.5,
name = "Add (De)Buff By Name / Spell Id",
desc = "Type the name or spell id of a (de)buff to customize",
type = "input",
set = function(info, val)
if tonumber(val) then
if not GetSpellInfo(val) then
return
end
val = tostring(val)
end
for _, value in ipairs(self.db.profile.customHighlights) do
if value == val then
return
end
end
tinsert(self.db.profile.customHighlights, val)
tsort(self.db.profile.customHighlights)
self.db.profile.customHighlightColors[val] = { r = 1, g = 1, b = 1, a = 0 }
self.options.args.highlightBuffs.args.buffList.args = self:AddCustomHighlightOptions()
end,
},
buffList = {
order = 2,
width = 1,
name = "Aura List",
type = "group",
args = DebuffFilter:AddCustomHighlightOptions()
},
},
},
},
}
local options = {
name = "DebuffFilter",
type = "group",
args = {
load = {
name = "Load configuration",
desc = "Load configuration options",
type = "execute",
func = function()
HideUIPanel(SettingsPanel)
LibStub("AceConfigDialog-3.0"):Open("DebuffFilter")
end,
},
},
}
self.options.plugins.profiles = { profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) }
LibStub("AceConfig-3.0"):RegisterOptionsTable(AddonName .. "_blizz", options)
LibStub("AceConfigDialog-3.0"):AddToBlizOptions(AddonName .. "_blizz", "|cff4693E6DebuffFilter|r")
LibStub("AceConfig-3.0"):RegisterOptionsTable(AddonName, self.options)
LibStub("AceConsole-3.0"):RegisterChatCommand("dbf", function()
HideUIPanel(SettingsPanel)
LibStub("AceConfigDialog-3.0"):Open("DebuffFilter")
end)
end
function DebuffFilter:Blacklisted(value)
value = tostring(value)
for _, blockedName in pairs(self.db.profile.hiddenBuffs) do
if blockedName == value then
return true
end
end
return false
end
local function adjustCastbar(frame)
local parentFrame = frame:GetParent()
local yOffset, xOffset = parentFrame.largestAura or 0
local spellbarAnchor = parentFrame.spellbarAnchor
local barPosX = parentFrame == TargetFrame and DebuffFilter.db.profile.targetBarPosX or parentFrame == FocusFrame and DebuffFilter.db.profile.focusBarPosX
local barPosY = parentFrame == TargetFrame and DebuffFilter.db.profile.targetBarPosY or parentFrame == FocusFrame and DebuffFilter.db.profile.focusBarPosY
if (barPosX and barPosX ~= 0) or (barPosY and barPosY ~= 0) then
spellbarAnchor = parentFrame
end
if frame.boss then
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", parentFrame, "BOTTOMLEFT", barPosX ~= 0 and barPosX or 25, barPosY ~= 0 and barPosY or 10 - yOffset)
elseif parentFrame.haveToT then
if parentFrame.buffsOnTop or parentFrame.auraRows <= 1 then
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", parentFrame, "BOTTOMLEFT", barPosX ~= 0 and barPosX or 25, barPosY ~= 0 and barPosY or -25)
else
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", spellbarAnchor, "BOTTOMLEFT", barPosX ~= 0 and barPosX or 20, barPosY ~= 0 and barPosY or -15 - yOffset)
end
elseif parentFrame.haveElite then
if parentFrame.buffsOnTop or parentFrame.auraRows <= 1 then
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", parentFrame, "BOTTOMLEFT", barPosX ~= 0 and barPosX or 25, barPosY ~= 0 and barPosY or -5)
else
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", spellbarAnchor, "BOTTOMLEFT", barPosX ~= 0 and barPosX or 20, barPosY ~= 0 and barPosY or -15 - yOffset)
end
else
if not parentFrame.buffsOnTop and parentFrame.auraRows > 0 then
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", spellbarAnchor, "BOTTOMLEFT", barPosX ~= 0 and barPosX or 20, barPosY ~= 0 and barPosY or -15 - yOffset)
else
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", parentFrame, "BOTTOMLEFT", barPosX ~= 0 and barPosX or 25, barPosY ~= 0 and barPosY or 7 - yOffset)
end
end
end
local PLAYER_UNITS = {
player = true,
vehicle = true,
pet = true,
};
local function ShouldAuraBeLarge(caster)
if not caster then
return false;
end
for token, value in pairs(PLAYER_UNITS) do
if UnitIsUnit(caster, token) then
return value;
end
end
end
local function safeSetPoint(frame, point, relativeTo, relativePoint, x, y)
if not frame or not relativeTo then return end
local current = relativeTo
while current do
if current == frame then
print("Circular dependency detected. Bugsack error?")
frame:ClearAllPoints()
frame:SetPoint(point, relativeTo:GetParent(), relativePoint, x, y)
return
end
local _, parent = current:GetPoint()
current = parent
end
frame:ClearAllPoints()
frame:SetPoint(point, relativeTo, relativePoint, x, y)
end
local function UpdateBuffAnchor(self, buffName, numDebuffs, anchorBuff, size, offsetX, offsetY, mirrorVertically, newRow)
--For mirroring vertically
local point, relativePoint;
local startY, auraOffsetY;
if (mirrorVertically) then
point = "BOTTOM";
relativePoint = "TOP";
startY = -15;
if (self.threatNumericIndicator:IsShown()) then
startY = startY + self.threatNumericIndicator:GetHeight();
end
offsetY = -offsetY;
auraOffsetY = -DebuffFilter.db.profile.verticalSpace;
else
point = "TOP";
relativePoint = "BOTTOM";
startY = AURA_START_Y;
auraOffsetY = DebuffFilter.db.profile.verticalSpace;
end
buffName:ClearAllPoints()
if anchorBuff == nil then
if (UnitIsFriend("player", self.unit) or numDebuffs == 0) then
-- unit is friendly or there are no debuffs...buffs start on top
buffName:SetPoint(point .. "LEFT", self, relativePoint .. "LEFT", AURA_START_X, startY);
else
safeSetPoint(buffName, point .. "LEFT", self.debuffz, relativePoint .. "LEFT", 0, -offsetY);
end
self.buffz:ClearAllPoints()
self.buffz:SetPoint(point .. "LEFT", buffName, point .. "LEFT", 0, 0);
self.buffz:SetPoint(relativePoint .. "LEFT", buffName, relativePoint .. "LEFT", 0, -auraOffsetY);
self.spellbarAnchor = buffName;
elseif newRow then
buffName:SetPoint(point .. "LEFT", anchorBuff, relativePoint .. "LEFT", 0, -offsetY);
self.buffz:ClearAllPoints()
self.buffz:SetPoint(relativePoint .. "LEFT", buffName, relativePoint .. "LEFT", 0, -auraOffsetY);
self.spellbarAnchor = buffName;
else
buffName:SetPoint(point .. "LEFT", anchorBuff, point .. "RIGHT", offsetX, 0);
end
-- Resize
buffName:SetWidth(size);
buffName:SetHeight(size);
end
local function UpdateDebuffAnchor(self, debuffName, numBuffs, anchorDebuff, size, offsetX, offsetY, mirrorVertically, newRow)
local isFriend = UnitIsFriend("player", self.unit);
--For mirroring vertically
local point, relativePoint;
local startY, auraOffsetY;
if (mirrorVertically) then
point = "BOTTOM";
relativePoint = "TOP";
startY = -15;
if (self.threatNumericIndicator:IsShown()) then
startY = startY + self.threatNumericIndicator:GetHeight();
end
offsetY = -offsetY;
auraOffsetY = -DebuffFilter.db.profile.verticalSpace;
else
point = "TOP";
relativePoint = "BOTTOM";
startY = AURA_START_Y;
auraOffsetY = DebuffFilter.db.profile.verticalSpace;
end
debuffName:ClearAllPoints()
if anchorDebuff == nil then
if (isFriend and numBuffs > 0) then
-- unit is friendly and there are buffs...debuffs start on bottom
debuffName:SetPoint(point .. "LEFT", self.buffz, relativePoint .. "LEFT", 0, -offsetY);
else
-- unit is not friendly or there are no buffs...debuffs start on top
debuffName:SetPoint(point .. "LEFT", self, relativePoint .. "LEFT", AURA_START_X, startY);
end
self.debuffz:ClearAllPoints()
self.debuffz:SetPoint(point .. "LEFT", debuffName, point .. "LEFT", 0, 0);
self.debuffz:SetPoint(relativePoint .. "LEFT", debuffName, relativePoint .. "LEFT", 0, -auraOffsetY);
if ((isFriend) or (not isFriend and numBuffs == 0)) then
self.spellbarAnchor = debuffName;
end
elseif newRow then
debuffName:SetPoint(point .. "LEFT", anchorDebuff, relativePoint .. "LEFT", 0, -offsetY);
self.debuffz:ClearAllPoints()
self.debuffz:SetPoint(relativePoint .. "LEFT", debuffName, relativePoint .. "LEFT", 0, -auraOffsetY);
if ((isFriend) or (not isFriend and numBuffs == 0)) then
self.spellbarAnchor = debuffName;
end
else
debuffName:SetPoint(point .. "LEFT", anchorDebuff, point .. "RIGHT", offsetX, 0);
end
-- Resize
debuffName:SetWidth(size);
debuffName:SetHeight(size);
local debuffFrame = _G[debuffName:GetName() .. "Border"];
if debuffFrame then
debuffFrame:SetWidth(size + 2);
debuffFrame:SetHeight(size + 2);
end
end
local function GetFramePosition(frame)
if not frame then
return 0, 0, 0
end
local left = frame:GetLeft() or 0
local bottom = frame:GetBottom() or 0
local top = frame:GetTop() or 0
return left, top, bottom
end
local function sizeSorter(a, b)
return a.size > b.size
end
local function typeSort(a, b)
if playerClass == "ROGUE" and (a.dispelType == "" and b.dispelType ~= "") then
return true
elseif playerClass == "ROGUE" and (a.dispelType ~= "" and b.dispelType == "") then
return false
elseif a.dispelType == "Magic" and b.dispelType ~= "Magic" then
return true
elseif a.dispelType ~= "Magic" and b.dispelType == "Magic" then
return false
else
return a.index < b.index
end
end
local function prioritySort(a, b)
return a.prio > b.prio
end
local function auraSortBySize(frame, auraName, numAuras, numOppositeAuras, updateFunc, offsetX, mirrorAurasVertically)
local LARGE_AURA_SIZE = DebuffFilter.db.profile.selfSize
local SMALL_AURA_SIZE = DebuffFilter.db.profile.otherSize
local maxRowWidth = DebuffFilter.db.profile.auraWidth
local yDistance = DebuffFilter.db.profile.verticalSpace
local offsetY = yDistance
local size, biggestAura
local rowWidth = 0
local anchorRowAura, lastBuff = nil, nil
local firstBuffonRow = 1
local haveTargetofTarget = frame.totFrame and frame.totFrame:IsShown()
local totFrameX, totFrameTop, totFrameBottom = GetFramePosition(frame.totFrame)
local currentX, currentY
local auras, processedSpellIDs = {}, {}
for i = 1, numAuras do
local filter
if updateFunc == UpdateBuffAnchor then
filter = "HELPFUL"
else
filter = "HARMFUL"
end
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(frame.unit, i, filter)
if name then
local customSize = DebuffFilter.db.profile.customSizes[tostring(spellId)] or DebuffFilter.db.profile.customSizes[name]
if customSize then
size = ShouldAuraBeLarge(unitCaster) and customSize.ownSize or customSize.otherSize
else
if unitCaster and ShouldAuraBeLarge(unitCaster) then
size = LARGE_AURA_SIZE
else
size = SMALL_AURA_SIZE
end
end
if debuffType == nil then
debuffType = "GG"
end
local priority = DebuffFilter.db.profile.customHighlightPriorities[name] or 0
tinsert(auras, { size = size,
name = name,
dbf = _G[auraName .. i],
dispelType = debuffType,
prio = priority,
source = unitCaster,
index = i,
spellId = spellId
})
end
end