forked from Dicebar/Raven
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBars.lua
More file actions
3836 lines (3706 loc) · 124 KB
/
Bars.lua
File metadata and controls
3836 lines (3706 loc) · 124 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
-- Raven is an addon to monitor auras and cooldowns, providing timer bars and icons plus helpful notifications.
-- Bars.lua supports mapping auras to bars and grouping bars into multiple moveable frames.
-- It has special case code for tooltips, test bars, shaman totems, and death knight runes.
-- There are no exported functions at this time other than those called to initialize and update bars.
local MOD = Raven
local SHIM = MOD.SHIM
local L = LibStub("AceLocale-3.0"):GetLocale("Raven")
local LSPELL = MOD.LocalSpellNames
local media = LibStub("LibSharedMedia-3.0")
local wc = { r = 1, g = 1, b = 1, a = 1 }
local rc = { r = 1, g = 0, b = 0, a = 1 }
local vc = { r = 1, g = 0, b = 0, a = 0 }
local zc = { r = 1, g = 1, b = 1, a = 0 }
local gc = { r = 0.5, g = 0.5, b = 0.5, a = 0.5 }
local hidden = false
local detectedBar = {}
local headerBar = {}
local groupIDs = {}
local settingsTemplate = {} -- settings are initialized from default bar group template
local activeSpells = {} -- temporary table used for finding ghost bars
local defaultNotificationIcon = "Interface\\Icons\\Spell_Nature_WispSplode"
local defaultBrokerIcon = "Interface\\Icons\\Inv_Misc_Book_03"
local defaultValueIcon = "Interface\\Icons\\Inv_Jewelry_Ring_03"
local defaultTestIcon = "Interface\\Icons\\Spell_Nature_RavenForm"
local frequentBars = {} -- bars tagged for frequent updates
local prefixRaidTargetIcon = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_"
local testColors = { "Blue1", "Cyan", "Green1", "Yellow1", "Orange1", "Red1", "Pink", "Purple1", "Brown1", "Gray" }
local tabardIcon
local units = { player = true, target = true, focus = true, pet = true, targettarget = true, focustarget = true, pettarget = true, mouseover = true }
-- Saved variables don't handle being set to nil properly so need to use alternate value to indicate an option has been turned off
local Off = 0 -- value used to designate an option is turned off
local function IsOff(value)
return value == nil or value == Off
end -- return true if option is turned off
local function IsOn(value)
return value ~= nil and value ~= Off
end -- return true if option is turned on
local colorTemplate = { timeColor = 0, iconColor = 0, labelColor = 0, backdropColor = 0, backdropFill = 0, borderColor = 0 } -- colors in default fonts and textures
local function DefaultColor(c)
return not c or not next(c) or ((c.r == 1) and (c.g == 1) and (c.b == 1) and (c.a == 1))
end
local defaultLabels = { 0, 1, 10, 30, "1m", "2m", "5m" }
function MOD:GetTimelineLabels()
return defaultLabels
end
MOD.BarGroupTemplate = { -- default bar group settings
enabled = true,
locked = true,
merged = false,
linkSettings = false,
linkBars = false,
checkCondition = false,
noMouse = false,
iconMouse = true,
barColors = "Spell",
bgColors = "Normal",
iconColors = "None",
combatTips = true,
casterTips = true,
spellTips = false,
casterLabels = false,
spellLabels = false,
anchorTips = "DEFAULT",
useDefaultDimensions = true,
useDefaultFontsAndTextures = true,
useDefaultColors = true,
useDefaultTimeFormat = false,
strata = "MEDIUM",
sor = "A",
reverseSort = false,
timeSort = true,
playerSort = false,
configuration = 1,
anchor = false,
anchorX = 0,
anchorY = 0,
anchorLastBar = false,
anchorRow = false,
anchorColumn = true,
anchorEmpty = false,
growDirection = true,
fillBars = false,
segmentBars = false,
wrap = 0,
wrapDirection = false,
snapCenter = false,
maxBars = 0,
segmentCount = 10,
segmentOverride = false,
segmentSpacing = 1,
segmentHideEmpty = false,
segmentAdvanced = false,
segmentCurve = 0,
segmentRotate = 0,
segmentTexture = false,
segmentFadePartial = false,
segmentShrinkWidth = false,
segmentShrinkHeight = false,
segmentGradient = false,
segmentGradientAll = false,
disableBGSFX = false,
customizeSFX = false,
shineColor = false,
sparkleColor = false,
glowColor = false,
expireFGBG = false,
flashPeriod = 1.2,
flashPercent = 50,
combatTextExcludesBG = false,
shineStart = false,
sparkleStart = false,
pulseStart = false,
glowStart = false,
flashStart = false,
desatStart = false,
shineExpiring = false,
sparkleExpiring = false,
pulseExpiring = false,
glowExpiring = false,
flashExpiring = false,
desatExpiring = false,
startEffectTime = 5,
endEffectTime = 5,
delayTime = 0,
combatStart = false,
combatCriticalStart = false,
expireMSBT = false,
criticalMSBT = false,
combatEnd = false,
combatCriticalEnd = false,
combatReady = false,
combatCriticalReady = false,
shineReady = false,
sparkleReady = false,
pulseReady = false,
glowReady = false,
flashReady = false,
desaturateReadyIcon = false,
shineEnd = false,
sparkleEnd = false,
pulseEnd = false,
splash = false,
ghost = false,
hide = false,
fade = false,
bgNormalAlpha = 1,
bgCombatAlpha = 1,
mouseAlpha = 1,
fadeAlpha = 1,
testTimers = 10,
testStatic = 0,
testLoop = false,
soundSpellStart = false,
soundSpellEnd = false,
soundSpellExpire = false,
soundSpellReady = false,
soundAltStart = "None",
soundAltEnd = "None",
soundAltExpire = "None",
soundAltReady = "None",
labelOffset = 0,
labelInset = 0,
labelWrap = false,
labelCenter = false,
labelAlign = "MIDDLE",
labelAdjust = true,
labelAuto = true,
labelWidth = 100,
timeOffset = 0,
timeInset = 0,
timeAlign = "normal",
timeIcon = false,
iconOffset = 0,
iconInset = 0,
iconHide = false,
iconAlign = "CENTER",
flashTime = 5,
expirePercentage = 0,
expireMinimum = 0,
colorExpiring = false,
clockReverse = true,
expireColor = false,
expireLabelColor = false,
expireTimeColor = false,
tickColor = false,
combatColorStart = false,
combatColorEnd = false,
combatColorReady = false,
colorMSBT = false,
spellExpireTimes = false,
spellExpireColors = false,
desaturate = false,
desaturateFriend = false,
disableAlpha = false,
timelineWidth = 225,
timelineHeight = 25,
timelineDuration = 300,
timelineExp = 3,
timelineHide = false,
timelineAlternate = true,
timelineSwitch = 2,
timelineTexture = "Blizzard",
timelineAlpha = 1,
timelineColor = false,
timelineLabels = false,
timelineBorderTexture = "None",
timelineBorderWidth = 4,
timelineBorderOffset = 1,
timelineBorderColor = false,
timelineSplash = true,
timelineSplashX = 0,
timelineSplashY = 0,
timelinePercent = 50,
timelineOffset = 0,
timelineDelta = 0,
stripeFullWidth = false,
stripeWidth = 500,
stripeHeight = 30,
stripeInset = 0,
stripeOffset = 0,
stripeTexture = "Blizzard",
stripeBarInset = 4,
stripeBarOffset = 0,
stripeColor = false,
stripeAltColor = false,
stripeCheckCondition = false,
stripeCondition = false,
stripeBorderTexture = "None",
stripeBorderWidth = 4,
stripeBorderOffset = 1,
stripeBorderColor = false,
showSolo = true,
showParty = true,
showRaid = true,
showCombat = true,
showOOC = true,
showStealth = true,
showFocusTarget = true,
showInstance = true,
showNotInstance = true,
showArena = true,
showBattleground = true,
showPetBattle = false,
showOnTaxi = true,
showSpecialization = "",
showResting = true,
showMounted = true,
showVehicle = true,
showFriend = true,
showEnemy = true,
showNeutral = true,
showBlizz = true,
showNotBlizz = true,
detectBuffs = false,
detectDebuffs = false,
detectAllBuffs = false,
detectAllDebuffs = false,
filterDebuffTypes = false,
detectDispellable = false,
detectInflictable = false,
detectNPCDebuffs = false,
detectVehicleDebuffs = false,
detectBossDebuffs = false,
detectEffectDebuffs = false,
detectAlertDebuffs = false,
detectPoison = false,
detectCurse = false,
detectMagic = false,
detectDisease = false,
detectOtherDebuffs = false,
excludeDebuffTypes = true,
excludeDispellable = false,
excludeInflictable = false,
excludeNPCDebuffs = false,
excludeVehicleDebuffs = false,
excludeBossDebuffs = false,
excludeEffectDebuffs = false,
excludeAlertDebuffs = true,
excludePoison = false,
excludeCurse = false,
excludeMagic = false,
excludeDisease = false,
excludeOtherDebuffs = false,
noHeaders = false,
noTargets = false,
noLabels = false,
headerGaps = false,
targetFirst = false,
targetAlpha = 1,
replay = false,
replayTime = 5,
detectBuffTypes = false,
detectCastable = false,
detectStealable = false,
detectMagicBuffs = false,
detectEffectBuffs = false,
detectAlertBuffs = false,
detectWeaponBuffs = false,
detectNPCBuffs = false,
detectVehicleBuffs = false,
detectBossBuffs = false,
detectEnrageBuffs = false,
detectTracking = false,
detectResources = false,
detectMountBuffs = false,
detectTabardBuffs = false,
detectMinionBuffs = false,
detectOtherBuffs = false,
excludeBuffTypes = true,
excludeCastable = false,
excludeStealable = false,
excludeMagicBuffs = false,
excludeEffectBuffs = false,
excludeAlertBuffs = true,
excludeWeaponBuffs = false,
excludeNPCBuffs = false,
excludeVehicleBuffs = false,
excludeBossBuffs = false,
excludeEnrageBuffs = false,
excludeTracking = true,
excludeResources = false,
excludeMountBuffs = false,
excludeTabardBuffs = false,
excludeMinionBuffs = true,
excludeOtherBuffs = false,
detectCooldowns = false,
detectBuffsMonitor = "player",
detectBuffsCastBy = "player",
detectDebuffsMonitor = "player",
detectDebuffsCastBy = "player",
detectCooldownsBy = "player",
detectSpellCooldowns = true,
detectTrinketCooldowns = true,
detectInternalCooldowns = true,
includeTotems = false,
detectSpellEffectCooldowns = true,
detectSpellAlertCooldowns = false,
detectPotionCooldowns = true,
detectOtherCooldowns = true,
detectRuneCooldowns = false,
detectGlobalCooldown = true,
detectSharedGrimoires = true,
detectSharedInfernals = true,
setDuration = false,
setOnlyLongDuration = false,
uniformDuration = 120,
checkDuration = false,
minimumDuration = true,
filterDuration = 120,
checkTimeLeft = false,
minimumTimeLeft = true,
filterTimeLeft = 120,
showNoDuration = false,
showOnlyNoDuration = false,
showNoDurationBackground = false,
readyReverse = false,
noDurationFirst = false,
timeFormat = 6,
timeSpaces = false,
timeCase = false,
filterBuff = true,
filterBuffLink = true,
filterBuffSpells = false,
filterBuffTable = nil,
filterBuffSpells2 = false,
filterBuffTable2 = nil,
filterBuffSpells3 = false,
filterBuffTable3 = nil,
filterBuffSpells4 = false,
filterBuffTable4 = nil,
filterBuffSpells5 = false,
filterBuffTable5 = nil,
filterDebuff = true,
filterDebuffLink = true,
filterDebuffSpells = false,
filterDebuffTable = nil,
filterDebuffSpells2 = false,
filterDebuffTable2 = nil,
filterDebuffSpells3 = false,
filterDebuffTable3 = nil,
filterDebuffSpells4 = false,
filterDebuffTable4 = nil,
filterDebuffSpells5 = false,
filterDebuffTable5 = nil,
filterCooldown = true,
filterCooldownLink = true,
filterCooldownSpells = false,
filterCooldownTable = nil,
filterCooldownSpells2 = false,
filterCooldownTable2 = nil,
filterCooldownSpells3 = false,
filterCooldownTable3 = nil,
filterCooldownSpells4 = false,
filterCooldownTable4 = nil,
filterCooldownSpells5 = false,
filterCooldownTable5 = nil,
showBuff = false,
showDebuff = false,
showCooldown = false,
filterBuffBars = false,
filterDebuffBars = false,
filterCooldownBars = false,
selectAll = true,
selectPlayer = false,
selectPet = false,
selectBoss = false,
selectDispel = false,
selectSteal = false,
selectPoison = false,
selectCurse = false,
selectMagic = false,
selectDisease = false,
selectEnrage = false,
}
MOD.BarGroupLayoutTemplate = { -- all the bar group settings involved in layout configuration
barWidth = 0,
barHeight = 0,
iconSize = 0,
scale = 0,
spacingX = 0,
spacingY = 0,
iconOffsetX = 0,
iconOffsetY = 0,
useDefaultDimensions = 0,
configuration = 0,
growDirection = 0,
wrap = 0,
wrapDirection = 0,
snapCenter = 0,
segmentBars = 0,
fillBars = 0,
maxBars = 0,
segmentCount = 0,
segmentOverride = 0,
segmentSpacing = 0,
segmentHideEmpty = 0,
segmentFadePartial = 0,
segmentShrinkWidth = 0,
segmentShrinkHeight = 0,
segmentGradient = 0,
segmentGradientAll = 0,
segmentAdvanced = 0,
segmentCurve = 0,
segmentRotate = 0,
segmentTexture = 0,
labelOffset = 0,
labelInset = 0,
labelWrap = 0,
labelCenter = 0,
labelAlign = 0,
labelAdjust = 0,
labelAuto = 0,
labelWidth = 0,
timeOffset = 0,
timeInset = 0,
timeAlign = 0,
timeIcon = 0,
iconOffset = 0,
iconInset = 0,
iconHide = 0,
iconAlign = 0,
hideIcon = 0,
hideClock = 0,
hideBar = 0,
hideSpark = 0,
hideValue = 0,
hideLabel = 0,
hideCount = 0,
showTooltips = 0,
timelineWidth = 0,
timelineHeight = 0,
timelineDuration = 0,
timelineExp = 0,
timelineHide = 0,
timelineAlternate = 0,
timelineSwitch = 0,
timelineTexture = 0,
timelineAlpha = 0,
timelineColor = 0,
timelineLabels = 0,
timelineBorderTexture = 0,
timelineBorderWidth = 0,
timelineBorderOffset = 0,
timelineBorderColor = 0,
timelineSplash = 0,
timelineSplashX = 0,
timelineSplashY = 0,
timelinePercent = 0,
timelineOffset = 0,
timelineDelta = 0,
stripeFullWidth = 0,
stripeWidth = 0,
stripeHeight = 0,
stripeInset = 0,
stripeOffset = 0,
stripeTexture = 0,
stripeBarInset = 0,
stripeBarOffset = 0,
stripeColor = 0,
stripeAltColor = 0,
stripeCheckCondition = 0,
stripeCondition = 0,
stripeBorderTexture = 0,
stripeBorderWidth = 0,
stripeBorderOffset = 0,
stripeBorderColor = 0,
}
-- Check for active tooltip for a bar and update once per second
local function BarTooltipUpdate()
if MOD.tooltipBar and MOD.Bar_OnUpdate then
MOD.Bar_OnUpdate(MOD.tooltipBar)
end
end
-- Initialize bar groups from those specified in the profile after, for example, a reloadUI or reset profile
function MOD:InitializeBars()
local bgs = MOD.Nest_GetBarGroups()
if bgs then
for _, bg in pairs(bgs) do
MOD.Nest_DeleteBarGroup(bg)
end
end -- first remove any bar groups represented in the graphics library
for _, bg in pairs(MOD.db.profile.BarGroups) do -- then set up the ones specified in the profile
if IsOn(bg) then
for n, k in pairs(MOD.db.global.Defaults) do -- add default settings for layout, fonts and textures
if bg[n] == nil then -- only add ones not already set in the bar group's profile
if colorTemplate[n] then
bg[n] = MOD.CopyColor(k)
else
bg[n] = k
end -- colors must be handled specially
end
end
for n, k in pairs(MOD.BarGroupTemplate) do
if bg[n] == nil then
bg[n] = k
end
end -- add additional default values from the bar group template
MOD:InitializeBarGroup(bg, 0, 0)
if not bg.auto then
for _, bar in pairs(bg.bars) do
bar.startReady = nil
end
end -- remove extra settings in custom bars
end
end
MOD:UpdateAllBarGroups() -- this is done last to get all positions updated correctly
MOD.tooltipBar = nil -- set when showing a tooltip for a bar
C_Timer.NewTicker(0.5, BarTooltipUpdate) -- update tooltips for bars when hovering over them
end
-- Finalize bar groups prior to logout, stripping out all values that match current defaults
function MOD:FinalizeBars()
for bn, bg in pairs(MOD.db.profile.BarGroups) do
if IsOn(bg) then
bg.cache = nil -- delete bar group cache contents
for n, k in pairs(MOD.db.global.Defaults) do
if bg[n] == k then
bg[n] = nil
end
end -- remove default settings for layout, fonts and textures
for n, k in pairs(MOD.BarGroupTemplate) do
if bg[n] == k then
bg[n] = nil
end
end -- remove defaults from the bar group template
for n in pairs(colorTemplate) do
if DefaultColor(bg[n]) then
bg[n] = nil
end
end -- detect basic colors set to defaults
else
MOD.db.profile.BarGroups[bn] = nil -- okay to delete these since no default bar groups
end
end
end
-- Raven is disabled so hide all features
function MOD:HideBars()
if not hidden then
for _, bp in pairs(MOD.db.profile.BarGroups) do
if IsOn(bp) then
MOD:ReleaseBarGroup(bp)
end
end
hidden = true
end
end
-- Initialize bar group settings by adding default values if necessary
function MOD:InitializeSettings()
for n, k in pairs(MOD.BarGroupTemplate) do
settingsTemplate[n] = k
end -- initialize the settings template from bar group defaults
for n, k in pairs(MOD.db.global.Defaults) do
settingsTemplate[n] = k
end -- add default settings for layout-fonts-textures
settingsTemplate.enabled = nil
settingsTemplate.locked = nil
settingsTemplate.merged = nil
settingsTemplate.linkSettings = nil
settingsTemplate.linkBars = nil
for _, settings in pairs(MOD.db.global.Settings) do
for n, k in pairs(settingsTemplate) do
if settings[n] == nil then
settings[n] = k
end
end -- add missing defaults from settings template
for n in pairs(colorTemplate) do
if settings[n] == nil then
settings[n] = MOD.CopyColor(wc)
end
end -- default basic colors
end
end
-- Remove default values from bar group settings
function MOD:FinalizeSettings()
for _, settings in pairs(MOD.db.global.Settings) do
for n, k in pairs(settingsTemplate) do
if settings[n] == k then
settings[n] = nil
end
end -- remove values still set to defaults
for n in pairs(colorTemplate) do
if DefaultColor(settings[n]) then
settings[n] = nil
end
end -- detect basic colors set to defaults
end
end
-- Show tooltip when entering a bar group anchor
local function Anchor_OnEnter(anchor, bgName)
if GetCVar("UberTooltips") == "1" then
GameTooltip_SetDefaultAnchor(GameTooltip, anchor)
else
GameTooltip:SetOwner(anchor, "ANCHOR_BOTTOMLEFT")
end
local bg, bgType, attachment = MOD.Nest_GetBarGroup(bgName), L["Custom Bar Group"], nil
if bg then
if MOD.Nest_GetBarGroupAttribute(bg, "isAuto") then
bgType = L["Auto Bar Group"]
end
attachment = MOD.Nest_GetBarGroupAttribute(bg, "attachment")
end
GameTooltip:AddDoubleLine("Raven", bgType)
if attachment then
GameTooltip:AddLine(L["Anchor attached"] .. attachment .. '"')
GameTooltip:AddLine(L["Anchor left click 1"])
else
GameTooltip:AddLine(L["Anchor left click 2"])
end
GameTooltip:AddLine(L["Anchor right click"])
GameTooltip:AddLine(L["Anchor shift left click"])
GameTooltip:AddLine(L["Anchor shift right click"])
GameTooltip:AddLine(L["Anchor alt left click"])
GameTooltip:AddLine(L["Anchor alt right click"])
GameTooltip:Show()
end
-- Hide tooltip when leaving a bar group anchor
local function Anchor_OnLeave(anchor, bgName)
GameTooltip:Hide()
end
-- Callback function for tracking location of the bar group
local function Anchor_Moved(anchor, bgName)
local bp = MOD.db.profile.BarGroups[bgName]
if IsOn(bp) then
local bg = MOD.Nest_GetBarGroup(bgName)
if bg then
bp.pointX, bp.pointXR, bp.pointY, bp.pointYT, bp.pointW, bp.pointH = MOD.Nest_GetAnchorPoint(bg) -- returns fractions from display edge
if bp.anchor then
bp.anchor = false
end -- no longer anchored to other bar groups
if bp.linkSettings then
local settings = MOD.db.global.Settings[bp.name] -- when updating a bar group with linked settings always overwrite position
if settings then
settings.pointX = bp.pointX
settings.pointXR = bp.pointXR
settings.pointY = bp.pointY
settings.pointYT = bp.pointYT
settings.pointW = bp.pointW
settings.pointH = bp.pointH
settings.anchor = bp.anchor
end
end
Anchor_OnLeave(anchor) -- turn off tooltip while moving the anchor
MOD.updateOptions = true -- if options panel is open then update it in case viewing position info
end
return
end
end
-- Callback function for when a bar group anchor is clicked with a modifier key down
-- Shift left click is test bars, right click is "toggle lock and hide",
local function Anchor_Clicked(anchor, bgName, button)
local shiftLeftClick = (button == "LeftButton") and IsShiftKeyDown()
local shiftRightClick = (button == "RightButton") and IsShiftKeyDown()
local altLeftClick = (button == "LeftButton") and IsAltKeyDown()
local altRightClick = (button == "RightButton") and IsAltKeyDown()
local rightClick = (button == "RightButton")
local bp = MOD.db.profile.BarGroups[bgName]
if IsOn(bp) then
if shiftLeftClick then -- test bars
MOD:TestBarGroup(bp)
elseif shiftRightClick then -- toggle grow up/down
bp.growDirection = not bp.growDirection
elseif altLeftClick then -- toggle options menu
MOD:OptionsPanel()
elseif altRightClick then -- cycle through configurations
if bp.configuration > MOD.Nest_MaxBarConfiguration then -- special case order for cycling icon configurations
local c, i = bp.configuration, MOD.Nest_MaxBarConfiguration + 1
if c == i then
c = i + 2
elseif c == (i + 1) then
c = i + 3
elseif c == (i + 2) then
c = i + 1
elseif c == (i + 3) then
c = i
elseif c == (i + 4) then
c = i + 5
elseif c == (i + 5) then
c = i + 4
end
bp.configuration = c
else
bp.configuration = bp.configuration + 1
if bp.configuration == (MOD.Nest_MaxBarConfiguration + 1) then
bp.configuration = 1
end
end
elseif rightClick then -- lock and hide
bp.locked = true
end
MOD:UpdateBarGroup(bp)
MOD.updateOptions = true -- if options panel is open then update it in case viewing configuration info
MOD:ForceUpdate()
return
end
end
-- Update linked settings. If dir is true then update the shared settings, otherwise update the bar group.
-- Also, if dir is true, create a linked settings table if one doesn't yet exist.
local function UpdateLinkedSettings(bp, dir)
local settings = MOD.db.global.Settings[bp.name]
if not settings then
if not dir then
return
end
settings = {}
MOD.db.global.Settings[bp.name] = settings
end
local p, q = settings, bp
if dir then
p = q
q = settings
end
for n in pairs(settingsTemplate) do
q[n] = p[n]
end -- copy every setting in the template
q.pointX = p.pointX
q.pointXR = p.pointXR
q.pointY = p.pointY
q.pointYT = p.pointYT -- always copy the location
q.pointW = p.pointW
q.pointH = p.pointH
if p.fgColor then
q.fgColor = MOD.CopyColor(p.fgColor)
else
q.fgColor = nil
end -- foreground and background custom colors must be hand copied
if p.bgColor then
q.bgColor = MOD.CopyColor(p.bgColor)
else
q.bgColor = nil
end
if p.iconBorderColor then
q.iconBorderColor = MOD.CopyColor(p.iconBorderColor)
else
q.iconBorderColor = nil
end
end
-- Update linked custom bars. If dir is true then update the shared bars, otherwise update the ones in the bar group.
-- Also, if dir is true, create a linked custom bars table if one doesn't yet exist.
local function UpdateLinkedBars(bp, dir)
if bp.auto then
return
end -- only applies to custom bar groups
local customBars = MOD.db.global.CustomBars[bp.name]
if not customBars then
if not dir then
return
end
customBars = {}
MOD.db.global.CustomBars[bp.name] = customBars
end
local p, q = customBars, bp.bars
if dir then
p = q
q = customBars
end
table.wipe(q) -- remove old bars from destination
for k, b in pairs(p) do
q[k] = MOD.CopyTable(b)
end -- deep copy each bar in the source
end
-- Update a linked filter list. If dir is true then update the shared list, otherwise update the bar group's list.
-- Also, if dir is true, create a linked filter list if one doesn't yet exist.
local function UpdateLinkedFilter(bp, dir, filterType)
local shared = MOD.db.global["Filter" .. filterType]
local bgname = "filter" .. filterType .. "List"
if not shared[bp.name] then
if not dir or not bp[bgname] or not next(bp[bgname], nil) then
return
end
shared[bp.name] = {}
end
if not bp[bgname] then
bp[bgname] = {}
end
local p, q = shared[bp.name], bp[bgname]
if dir then
p = bp[bgname]
q = shared[bp.name]
end
for _, v in pairs(q) do
if not p[v] then
q[v] = nil
end
end -- delete any keys in q not in p
for _, v in pairs(p) do
if not q[v] then
q[v] = v
end
end -- copy everything from p to q
end
-- Initialize a bar group from a shared filter list, if any.
-- This function is called whenever filterLink is changed.
function MOD:InitializeFilterList(bp, filterType)
if bp and bp["filter" .. filterType] and bp["filter" .. filterType .. "Link"] then
UpdateLinkedFilter(bp, false, filterType) -- use the shared settings, if any, for a linked layout
end
end
-- Get spell associated with a bar
function MOD:GetAssociatedSpellForBar(bar)
local bt = bar.barType
if bt == "Notification" then
local sp = bar.notifySpell
if not sp and not bar.unconditional and bar.action then
sp = MOD:GetConditionSpell(bar.action)
end
return sp
elseif bt == "Value" then
return bar.spell
end
return bar.action
end
-- Get icon for the spell associated with a bar, returns nil if none found
function MOD:GetIconForBar(bar)
local sp = MOD:GetAssociatedSpellForBar(bar)
if sp then
return MOD:GetIcon(sp)
end
return nil
end
-- Get color for the spell associated with a bar, returns nil if none found
function MOD:GetSpellColorForBar(bar)
local c = bar.color -- get override if one is set
local spc = nil
local sp = MOD:GetAssociatedSpellForBar(bar)
if sp then
spc = MOD:GetColor(sp, bar.spellID)
end -- associated spell's color, if any
if bar.barType == "Notification" then -- special case for notifications which can use an associated spell color
if bar.notColor then
return c
end -- not allowed to get color from associated spell
return spc or c -- prefer the associated spell color instead of the override color
end
return c or spc -- all other bar types only use color from associated spell if no override is set
end
-- Set the bar's current spell color using an override if not linked (note bar.colorLink uses inverted value from expected)
function MOD:SetSpellColorForBar(bar, r, g, b, a)
local c = bar.color -- check if using an override
if c then
c.r = r
c.g = g
c.b = b
c.a = a
return
end
local bt = bar.barType
local typeCheck = (bt == "Buff") or (bt == "Debuff") or (bt == "Cooldown")
if typeCheck and not bar.colorLink then -- set the shared color for bars with the same associated spell
local sp = MOD:GetAssociatedSpellForBar(bar)
if sp then
c = MOD:GetColor(sp, bar.spellID)
end
if c then
c.r = r
c.g = g
c.b = b
c.a = a
return
end
c = { r = r, g = g, b = b, a = a }
if sp then
MOD:SetColor(sp, c)
else
bar.color = c
end
else
bar.color = { r = r, g = g, b = b, a = a } -- create an override
end
end
-- Reset the bar's override color
function MOD:ResetSpellColorForBar(bar)
bar.color = nil
local bt = bar.barType
local typeCheck = (bt == "Buff") or (bt == "Debuff") or (bt == "Cooldown")
if typeCheck and not bar.colorLink then -- also reset the shared color for bars with the same associated spell
local sp = MOD:GetAssociatedSpellForBar(bar)
if sp then
MOD:ResetColor(sp)
end
end
end
-- Either link or decouple the bar's color from the color cache for it's associated spell
function MOD:LinkSpellColorForBar(bar)
local c = MOD:GetSpellColorForBar(bar)
if not bar.colorLink then -- link to the color cache, copying current setting, if any, to the color cache
if c and bar.color then
local d = bar.color
c.r = d.r
c.g = d.g
c.b = d.b
c.a = d.a
end
bar.color = nil -- delete override to revert back to color cache or default for bar type
else -- decouple from the color cached, copying current setting, if any, to a new override
if c then
bar.color = { r = c.r, g = c.g, b = c.b, a = c.a }
end
end
end
-- Get the right color for the bar based on bar group settings
local function GetColorForBar(bg, bar, btype)
local bt, c = bar.barType, nil
local scheme = bg.barColors
if scheme == "Spell" then
c = MOD:GetSpellColorForBar(bar)
elseif scheme == "Class" then
c = MOD.ClassColors[MOD.myClass] or wc
elseif scheme == "Custom" then
c = bg.fgColor or wc
end
if not c then -- get the best default color for this bar type
local cc = not bg.useDefaultColors -- indicates the bar group has overrides for standard colors
c = cc and bg.buffColor or MOD.db.global.DefaultBuffColor -- use this as default in case unrecognized bar type
if bt == "Debuff" then
c = cc and bg.debuffColor or MOD.db.global.DefaultDebuffColor
if btype then
if btype == "Poison" then
c = cc and bg.poisonColor or MOD.db.global.DefaultPoisonColor
end
if btype == "Curse" then
c = cc and bg.curseColor or MOD.db.global.DefaultCurseColor
end
if btype == "Magic" then
c = cc and bg.magicColor or MOD.db.global.DefaultMagicColor
end
if btype == "Disease" then
c = cc and bg.diseaseColor or MOD.db.global.DefaultDiseaseColor