-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleUnitFrames.lua
More file actions
10710 lines (9736 loc) · 339 KB
/
SimpleUnitFrames.lua
File metadata and controls
10710 lines (9736 loc) · 339 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
---@class SimpleUnitFrames : AceAddon
---@field db AceDB Database instance (AceDB-3.0)
---@field frames table<integer, Frame> Array of spawned unit frames
---@field isBuildingOptions boolean Flag for options window state
---@field performanceLib table|nil Optional PerformanceLib integration
---@field sufEventBus table|nil Optional event bus for internal addon events
local addonName = "SUF"
local addonId = "SimpleUnitFrames"
---Get oUF library reference
---@return table oUF library instance
local function GetOuf()
local global
if C_AddOns and C_AddOns.GetAddOnMetadata then
global = C_AddOns.GetAddOnMetadata(addonId, "X-oUF")
else
global = GetAddOnMetadata(addonId, "X-oUF")
end
if global and _G[global] then
return _G[global]
end
return _G.oUF
end
local AceAddon = LibStub("AceAddon-3.0")
local AceDB = LibStub("AceDB-3.0")
local AceGUI = LibStub("AceGUI-3.0")
local LibDualSpec = LibStub("LibDualSpec-1.0", true)
local LSM = LibStub("LibSharedMedia-3.0", true)
local LibSerialize = LibStub("LibSerialize", true)
local LibDeflate = LibStub("LibDeflate", true)
local LDB = LibStub("LibDataBroker-1.1", true)
local LibDBIcon = LibStub("LibDBIcon-1.0", true)
local LibTranslit = LibStub("LibTranslit-1.0", true)
local LibCustomGlow = LibStub("LibCustomGlow-1.0", true)
local LibRangeCheck = LibStub("LibRangeCheck-3.0", true)
---@type SimpleUnitFrames
local addon = AceAddon:NewAddon("SimpleUnitFrames", "AceEvent-3.0", "AceConsole-3.0")
---@type string
local DEFAULT_TEXTURE = "Interface\\TargetingFrame\\UI-StatusBar"
---@type string
local DEFAULT_FONT = STANDARD_TEXT_FONT
local ICON_PATH = "Interface\\AddOns\\SimpleUnitFrames\\Media\\AddonIcon"
local DATATEXT_SLOT_ORDER = { "left", "center", "right" }
local function ChatMsg(message)
if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
DEFAULT_CHAT_FRAME:AddMessage(message)
else
print(message)
end
end
local defaults = {
profile = {
media = {
statusbar = "Blizzard",
font = "Friz Quadrata TT",
globalStatusbarOverride = true,
globalFontOverride = true,
accentColor = { 0.74, 0.58, 0.99 },
},
optionsUI = {
sectionState = {},
unitSubTabs = {},
searchShowCounts = true,
searchKeyboardHints = true,
tutorialSeen = false,
installFlowSeen = false,
},
fontSizes = {
name = 12,
level = 10,
health = 11,
power = 10,
cast = 10,
},
units = {
player = {
fontSizes = { name = 12, level = 10, health = 11, power = 10, cast = 10 },
media = { statusbar = "Blizzard", font = "Friz Quadrata TT" },
showResting = true,
showPvp = true,
portrait = { mode = "none", size = 36, showClass = false, motion = false, position = "LEFT" },
castbar = {
enabled = true,
anchor = "BELOW_CLASSPOWER",
gap = 8,
offsetY = 0,
},
},
target = {
fontSizes = { name = 12, level = 10, health = 11, power = 10, cast = 10 },
media = { statusbar = "Blizzard", font = "Friz Quadrata TT" },
showResting = false,
showPvp = true,
portrait = { mode = "none", size = 36, showClass = false, motion = false, position = "LEFT" },
castbar = {
enabled = true,
anchor = "BELOW_FRAME",
gap = 2,
offsetY = 0,
},
},
tot = {
fontSizes = { name = 11, level = 9, health = 10, power = 9, cast = 9 },
media = { statusbar = "Blizzard", font = "Friz Quadrata TT" },
showResting = false,
showPvp = true,
portrait = { mode = "none", size = 28, showClass = false, motion = false, position = "LEFT" },
castbar = {
enabled = true,
anchor = "BELOW_FRAME",
gap = 2,
offsetY = 0,
},
},
focus = {
fontSizes = { name = 12, level = 10, health = 11, power = 10, cast = 10 },
media = { statusbar = "Blizzard", font = "Friz Quadrata TT" },
showResting = false,
showPvp = true,
portrait = { mode = "none", size = 32, showClass = false, motion = false, position = "LEFT" },
},
focustarget = {
fontSizes = { name = 11, level = 9, health = 10, power = 9, cast = 9 },
media = { statusbar = "Blizzard", font = "Friz Quadrata TT" },
showResting = false,
showPvp = false,
portrait = { mode = "none", size = 24, showClass = false, motion = false, position = "LEFT" },
castbar = {
enabled = true,
anchor = "BELOW_FRAME",
gap = 2,
offsetY = 0,
},
},
pet = {
fontSizes = { name = 11, level = 9, health = 10, power = 9, cast = 9 },
media = { statusbar = "Blizzard", font = "Friz Quadrata TT" },
showResting = false,
showPvp = false,
portrait = { mode = "none", size = 28, showClass = false, motion = false, position = "LEFT" },
},
party = {
fontSizes = { name = 11, level = 9, health = 10, power = 9, cast = 9 },
media = { statusbar = "Blizzard", font = "Friz Quadrata TT" },
showResting = false,
showPvp = true,
auraSize = 22,
auras = {
enabled = true,
numBuffs = 6,
numDebuffs = 0,
spacingX = 4,
spacingY = 4,
maxCols = 6,
initialAnchor = "BOTTOMLEFT",
growthX = "RIGHT",
growthY = "UP",
sortMethod = "DEFAULT",
sortDirection = "ASC",
onlyShowPlayer = false,
showStealableBuffs = true,
},
portrait = { mode = "none", size = 26, showClass = false, motion = false, position = "LEFT" },
castbar = {
enabled = true,
anchor = "ABOVE_FRAME",
gap = 2,
offsetY = 0,
},
},
raid = {
fontSizes = { name = 10, level = 8, health = 9, power = 8, cast = 8 },
media = { statusbar = "Blizzard", font = "Friz Quadrata TT" },
showResting = false,
showPvp = false,
portrait = { mode = "none", size = 22, showClass = false, motion = false, position = "LEFT" },
castbar = {
enabled = true,
anchor = "ABOVE_FRAME",
gap = 2,
offsetY = 0,
},
},
boss = {
fontSizes = { name = 12, level = 10, health = 11, power = 10, cast = 10 },
media = { statusbar = "Blizzard", font = "Friz Quadrata TT" },
showResting = false,
showPvp = false,
portrait = { mode = "none", size = 30, showClass = false, motion = false, position = "LEFT" },
},
},
tags = {
player = { name = "[raidcolor][name]", level = "[level]", health = "[curhp]", power = "[curpp]" },
target = { name = "[raidcolor][name]", level = "[level]", health = "[curhp]", power = "[curpp]" },
tot = { name = "[raidcolor][name]", level = "[level]", health = "[curhp]", power = "[curpp]" },
focus = { name = "[raidcolor][name]", level = "[level]", health = "[curhp]", power = "[curpp]" },
pet = { name = "[name]", level = "[level]", health = "[curhp]", power = "[curpp]" },
party = { name = "[raidcolor][name]", level = "[level]", health = "[curhp]", power = "[curpp]" },
raid = { name = "[raidcolor][name]", level = "[level]", health = "[curhp]", power = "[curpp]" },
boss = { name = "[name]", level = "[level]", health = "[curhp]", power = "[curpp]" },
},
sizes = {
player = { width = 220, height = 36 },
target = { width = 220, height = 36 },
tot = { width = 160, height = 28 },
focus = { width = 200, height = 32 },
pet = { width = 160, height = 26 },
party = { width = 160, height = 26 },
raid = { width = 120, height = 22 },
boss = { width = 200, height = 30 },
},
powerHeight = 8,
classPowerHeight = 8,
classPowerSpacing = 2,
castbarHeight = 16,
castbar = {
iconEnabled = true,
iconPosition = "LEFT",
iconSize = 20,
iconGap = 2,
showShield = true,
showSafeZone = true,
safeZoneAlpha = 0.35,
showSpark = true,
showDirectionIndicator = false,
showChannelTicks = false,
channelTickWidth = 2,
showEmpowerPips = true,
showLatencyText = false,
latencyWarnMs = 120,
latencyHighMs = 220,
spellMaxChars = 18,
timeDecimals = 1,
showDelay = true,
colorProfile = "UUF",
},
powerBgAlpha = 0.35,
mainBarsBackground = {
enabled = true,
texture = "Blizzard",
color = { 0.05, 0.05, 0.05 },
alpha = 0.40,
},
visibility = {
hideVehicle = true,
hidePetBattle = true,
hideOverride = true,
hidePossess = true,
hideExtra = true,
-- Indicator glow controls
enablePartyLeaderGlow = true,
enableThreatIndicatorGlow = true,
enableTargetSelectionGlow = true,
},
indicators = {
version = 1,
size = 24,
offsetX = 10,
offsetY = -7,
},
party = {
showPlayerInParty = true,
showPlayerWhenSolo = false,
spacing = 15,
},
boss = {
spacing = 15,
},
absorbValueTag = "[suf:absorbs:abbr]",
performance = {
enabled = true,
optionsAutoRefresh = true,
},
enhancements = {
stickyWindows = true,
stickyRange = 15,
translitNames = false,
translitMarker = "",
castbarNonInterruptibleGlow = true,
uiOpenAnimation = true,
uiOpenAnimationDuration = 0.18,
uiOpenAnimationOffsetY = 12,
pixelSnapWindows = true,
},
blizzardFrames = {
player = true,
pet = true,
target = true,
tot = true,
focus = true,
party = true,
raid = true,
boss = true,
},
blizzardSkin = {
enabled = false,
intensity = "subtle",
labMode = false,
aggressiveRecursive = false,
aggressiveReassertHooks = false,
character = true,
spellbook = true,
collections = true,
questlog = true,
lfg = true,
map = true,
calendar = true,
professions = true,
dressup = true,
gossip = true,
merchant = true,
mail = true,
economy = true,
friends = true,
guild = true,
housing = true,
achievement = true,
encounter = true,
},
movers = {},
databars = {
enabled = true,
positionMode = "ANCHOR",
anchor = "TOP",
offsetX = 0,
offsetY = -2,
width = 520,
height = 10,
showText = true,
showXP = true,
showReputation = true,
showPetXP = true,
showRestedOverlay = true,
showQuestXPOverlay = true,
xpFade = {
enabled = false,
showOnHover = true,
showInCombat = true,
fadeInDuration = 0.2,
fadeOutDuration = 0.3,
fadeOutAlpha = 0.0,
fadeOutDelay = 0.5,
},
},
datatext = {
enabled = true,
refreshRate = 1.0,
positionMode = "ANCHOR",
panel = {
width = 520,
height = 20,
anchor = "TOP",
offsetX = 0,
offsetY = -14,
backdrop = true,
mouseover = false,
},
slots = {
left = "FPS",
center = "Time",
right = "Memory",
},
},
plugins = {
raidDebuffs = {
enabled = true,
size = 18,
glow = true,
glowMode = "ALL",
},
auraWatch = {
enabled = true,
size = 10,
numBuffs = 3,
numDebuffs = 3,
showDebuffType = true,
customSpellList = "",
replaceDefaults = false,
},
fader = {
enabled = false,
minAlpha = 0.45,
maxAlpha = 1.0,
smooth = 0.2,
combat = true,
hover = true,
playerTarget = true,
actionTarget = false,
unitTarget = false,
casting = false,
},
units = {
party = {
useGlobal = true,
raidDebuffs = {
enabled = true,
size = 18,
glow = true,
glowMode = "ALL",
},
auraWatch = {
enabled = true,
size = 10,
numBuffs = 3,
numDebuffs = 3,
showDebuffType = true,
customSpellList = "",
replaceDefaults = false,
},
fader = {
enabled = false,
minAlpha = 0.45,
maxAlpha = 1.0,
smooth = 0.2,
combat = true,
hover = true,
playerTarget = true,
actionTarget = false,
unitTarget = false,
casting = false,
},
},
raid = {
useGlobal = true,
raidDebuffs = {
enabled = true,
size = 18,
glow = true,
glowMode = "ALL",
},
auraWatch = {
enabled = true,
size = 10,
numBuffs = 3,
numDebuffs = 3,
showDebuffType = true,
customSpellList = "",
replaceDefaults = false,
},
fader = {
enabled = false,
minAlpha = 0.45,
maxAlpha = 1.0,
smooth = 0.2,
combat = true,
hover = true,
playerTarget = true,
actionTarget = false,
unitTarget = false,
casting = false,
},
},
},
},
minimap = {
hide = false,
minimapPos = 220,
},
customTrackers = {
bars = {},
autoLearn = {
enabled = false,
learnSpells = true,
learnItems = true,
learnOnlyKnownSpells = false,
excludeNPCSpells = false,
includeItemSpells = true,
targetBarID = "",
},
},
debug = {
enabled = false,
showPanel = false,
timestamp = true,
maxMessages = 500,
systems = {
General = true,
Performance = true,
ClickCasting = true,
Events = false,
Frames = false,
AbsorbEvents = false,
IncomingText = false,
},
},
},
}
local UNIT_TYPE_ORDER = {
"player",
"target",
"tot",
"focus",
"pet",
"party",
"raid",
"boss",
}
local MODULE_COPY_RESET_KEYS = {
{ value = "castbar", text = "Castbar" },
{ value = "fader", text = "Frame Fader (Group Units)" },
{ value = "aurawatch", text = "AuraWatch (Group Units)" },
}
local UNIT_LABELS = {
player = "Player",
target = "Target",
tot = "TargetOfTarget",
focus = "Focus",
pet = "Pet",
party = "Party",
raid = "Raid",
boss = "Boss",
}
local GROUP_UNIT_TYPES = {
party = true,
raid = true,
}
local DEFAULT_UNIT_CASTBAR = {
enabled = true,
showText = true,
showTime = true,
reverseFill = false,
widthPercent = 100,
anchor = "BELOW_FRAME",
gap = 8,
offsetY = 0,
colorProfile = "GLOBAL",
}
local DEFAULT_UNIT_LAYOUT = {
version = 3,
secondaryToFrame = 0,
classToSecondary = 0,
}
local DEFAULT_UNIT_TARGET_GLOW = {
enabled = false,
color = { 0.95, 0.85, 0.25, 0.92 },
inset = 3,
}
local DEFAULT_UNIT_POWER_PREDICTION = {
enabled = false,
height = 3,
opacity = 0.70,
color = { 1.00, 0.90, 0.25 },
}
local DEFAULT_UNIT_AURA_LAYOUT = {
enabled = true,
numBuffs = 8,
numDebuffs = 8,
spacingX = 4,
spacingY = 4,
maxCols = 8,
initialAnchor = "BOTTOMLEFT",
growthX = "RIGHT",
growthY = "UP",
sortMethod = "DEFAULT",
sortDirection = "ASC",
onlyShowPlayer = false,
showStealableBuffs = true,
}
local DEFAULT_PARTY_AURA_LAYOUT = {
enabled = true,
numBuffs = 6,
numDebuffs = 0,
spacingX = 4,
spacingY = 4,
maxCols = 6,
initialAnchor = "BOTTOMLEFT",
growthX = "RIGHT",
growthY = "UP",
sortMethod = "DEFAULT",
sortDirection = "ASC",
onlyShowPlayer = false,
showStealableBuffs = true,
}
local DEFAULT_UNIT_MAIN_BARS_BACKGROUND = {
useGlobal = true,
enabled = true,
texture = "Blizzard",
color = { 0.05, 0.05, 0.05 },
alpha = 0.40,
}
local DEFAULT_AURAWATCH_WATCHED = {
[17] = { enabled = true, anyUnit = true, point = "TOPLEFT", xOffset = 1, yOffset = -1 }, -- Power Word: Shield
[774] = { enabled = true, anyUnit = true, point = "TOP", xOffset = 0, yOffset = -1 }, -- Rejuvenation
[139] = { enabled = true, anyUnit = true, point = "TOPRIGHT", xOffset = -1, yOffset = -1 }, -- Renew
[1022] = { enabled = true, anyUnit = true, point = "BOTTOMLEFT", xOffset = 1, yOffset = 1 }, -- Blessing of Protection
[6940] = { enabled = true, anyUnit = true, point = "BOTTOM", xOffset = 0, yOffset = 1 }, -- Blessing of Sacrifice
[33206] = { enabled = true, anyUnit = true, point = "BOTTOMRIGHT", xOffset = -1, yOffset = 1 }, -- Pain Suppression
}
local ELVUI_IMPORTED_AURA_FILTERS = {
IMPORTANTCC = {
label = "ImportantCC",
desc = "ElvUI-inspired important crowd control auras.",
spells = {
118, 3355, 33786, 51514, 853, 408, 5246, 8122, 217832, 179057, 5211, 20066, 6789, 30283, 119381, 31661,
},
},
CLASSDEBUFFS = {
label = "ClassDebuffs",
desc = "ElvUI-inspired class priority debuffs.",
spells = {
55078, 194310, 204598, 207771, 164812, 164815, 155722, 1079, 217200, 210824, 123725, 228287, 343527, 335467, 34914, 589,
703, 1943, 188389, 316099, 980, 146739, 157736, 388539, 262115,
},
},
}
local HasVisibleClassPower
local INCOMING_VALUE_FEATURE_ENABLED = false
local DEFAULT_HEAL_PREDICTION = {
enabled = true,
incoming = {
enabled = true,
split = false,
valueMode = "SAFE",
showValueText = false,
valuePlaceholder = "~",
valueFontSize = 10,
valueColor = { 0.35, 0.95, 0.45 },
valueOffsetX = 2,
valueOffsetY = 0,
opacity = 0.40,
height = 1.00,
colorAll = { 0.35, 0.95, 0.45 },
colorPlayer = { 0.35, 0.95, 0.45 },
colorOther = { 0.20, 0.75, 0.35 },
},
absorbs = {
enabled = true,
opacity = 0.75,
height = 1.00,
color = { 1.00, 0.95, 0.20 },
position = "RIGHT",
showGlow = true,
glowOpacity = 0.95,
},
healAbsorbs = {
enabled = true,
opacity = 0.55,
height = 1.00,
color = { 0.95, 0.25, 0.25 },
position = "RIGHT",
showGlow = true,
glowOpacity = 0.95,
},
}
-- Apply health color curve configuration
-- Made a module function for UI access
function addon:ApplyHealthCurve(frame, config)
if not frame or not frame.Health then
self:DebugLog("ColorCurve", "ApplyHealthCurve: frame or Health missing", 2)
return
end
if not self or not self.oUF or not self.oUF.colors or not self.oUF.colors.health then
self:DebugLog("ColorCurve", ("ApplyHealthCurve: oUF check failed (self=%s oUF=%s colors=%s health=%s)"):format(
self and "yes" or "nil",
self and self.oUF and "yes" or "nil",
self and self.oUF and self.oUF.colors and "yes" or "nil",
self and self.oUF and self.oUF.colors and self.oUF.colors.health and "yes" or "nil"
), 1)
return
end
local healthConfig = config or DEFAULT_HEALTH_PREDICTION or {}
self:DebugLog("ColorCurve", ("ApplyHealthCurve called: frame=%s config.smooth=%s"):format(
frame:GetName() or "unknown",
tostring(healthConfig.smooth)
), 2)
if healthConfig.smooth and healthConfig.gradientColors then
-- Convert custom gradient colors to ColorMixin curve
local curveData = {}
-- Critical (0% HP) - defaults to red
local color0 = healthConfig.gradientColors[0] or { 1, 0, 0 }
curveData[0.0] = CreateColor(color0[1] or 1, color0[2] or 0, color0[3] or 0, color0[4] or 1)
-- Warning (50% HP) - defaults to yellow
local color50 = healthConfig.gradientColors[0.5] or { 1, 1, 0 }
curveData[0.5] = CreateColor(color50[1] or 1, color50[2] or 1, color50[3] or 0, color50[4] or 1)
-- Healthy (100% HP) - defaults to green
local color100 = healthConfig.gradientColors[1] or { 0, 1, 0 }
curveData[1.0] = CreateColor(color100[1] or 0, color100[2] or 1, color100[3] or 0, color100[4] or 1)
local ok = pcall(self.oUF.colors.health.SetCurve, self.oUF.colors.health, curveData)
self:DebugLog("ColorCurve", ("Custom gradient curve set: ok=%s"):format(tostring(ok)), 2)
else
-- Reset to default curve (red → yellow → green)
local ok = pcall(self.oUF.colors.health.SetCurve, self.oUF.colors.health, {
[0.0] = CreateColor(1, 0, 0),
[0.5] = CreateColor(1, 1, 0),
[1.0] = CreateColor(0, 1, 0),
})
self:DebugLog("ColorCurve", ("Default curve set: ok=%s hasCurve=%s"):format(
tostring(ok),
self.oUF.colors.health:GetCurve() and "yes" or "nil"
), 2)
end
end
local CASTBAR_COLOR_PROFILES = {
Blizzard = {
casting = { 1.00, 0.70, 0.00 },
channeling = { 0.20, 0.60, 1.00 },
complete = { 0.00, 1.00, 0.00 },
failed = { 1.00, 0.10, 0.10 },
nonInterruptible = { 0.75, 0.75, 0.75 },
background = { 0.00, 0.00, 0.00, 0.55 },
},
UUF = {
casting = { 0.95, 0.82, 0.24 },
channeling = { 0.31, 0.78, 0.98 },
complete = { 0.24, 0.90, 0.24 },
failed = { 0.96, 0.25, 0.25 },
nonInterruptible = { 0.66, 0.66, 0.66 },
background = { 0.02, 0.02, 0.02, 0.65 },
},
HighContrast = {
casting = { 1.00, 0.90, 0.10 },
channeling = { 0.10, 0.85, 1.00 },
complete = { 0.10, 1.00, 0.25 },
failed = { 1.00, 0.15, 0.15 },
nonInterruptible = { 0.85, 0.85, 0.85 },
background = { 0.00, 0.00, 0.00, 0.72 },
},
}
local PERF_EVENT_PRIORITY = {
UNIT_HEALTH = 2,
UNIT_POWER_UPDATE = 2,
UNIT_MAXHEALTH = 2,
UNIT_HEAL_PREDICTION = 2,
UNIT_ABSORB_AMOUNT_CHANGED = 2,
UNIT_HEAL_ABSORB_AMOUNT_CHANGED = 2,
UNIT_MAXPOWER = 2,
UNIT_DISPLAYPOWER = 3,
UNIT_AURA = 3,
UNIT_THREAT_SITUATION_UPDATE = 3,
UNIT_THREAT_LIST_UPDATE = 3,
UNIT_SPELLCAST_START = 2,
UNIT_SPELLCAST_CHANNEL_START = 2,
UNIT_SPELLCAST_EMPOWER_START = 2,
UNIT_SPELLCAST_STOP = 4,
UNIT_SPELLCAST_CHANNEL_STOP = 4,
UNIT_SPELLCAST_EMPOWER_STOP = 4,
UNIT_SPELLCAST_DELAYED = 4,
UNIT_SPELLCAST_CHANNEL_UPDATE = 4,
UNIT_SPELLCAST_EMPOWER_UPDATE = 4,
UNIT_SPELLCAST_FAILED = 4,
UNIT_SPELLCAST_INTERRUPTED = 4,
UNIT_SPELLCAST_INTERRUPTIBLE = 4,
UNIT_SPELLCAST_NOT_INTERRUPTIBLE = 4,
PLAYER_TOTEM_UPDATE = 3,
RUNE_POWER_UPDATE = 3,
UNIT_PORTRAIT_UPDATE = 4,
UNIT_NAME_UPDATE = 4,
UNIT_FACTION = 4,
UNIT_FLAGS = 4,
UNIT_CONNECTION = 4,
RAID_TARGET_UPDATE = 4,
GROUP_ROSTER_UPDATE = 4,
PLAYER_ROLES_ASSIGNED = 4,
}
local PERF_DIRTY_PRIORITY = {
[1] = 4,
[2] = 3,
[3] = 2,
[4] = 1,
}
local EVENT_COALESCE_CONFIG = {
UNIT_HEALTH = { delay = 0.18, priority = 3 },
UNIT_HEAL_PREDICTION = { delay = 0.14, priority = 3 },
UNIT_ABSORB_AMOUNT_CHANGED = { delay = 0.12, priority = 3 },
UNIT_HEAL_ABSORB_AMOUNT_CHANGED = { delay = 0.12, priority = 3 },
UNIT_POWER_UPDATE = { delay = 0.20, priority = 4 },
UNIT_MAXHEALTH = { delay = 0.12, priority = 2 },
UNIT_MAXPOWER = { delay = 0.12, priority = 2 },
UNIT_DISPLAYPOWER = { delay = 0.12, priority = 3 },
UNIT_THREAT_SITUATION_UPDATE = { delay = 0.14, priority = 3 },
UNIT_THREAT_LIST_UPDATE = { delay = 0.16, priority = 4 },
UNIT_SPELLCAST_START = { delay = 0.05, priority = 2 },
UNIT_SPELLCAST_CHANNEL_START = { delay = 0.05, priority = 2 },
UNIT_SPELLCAST_EMPOWER_START = { delay = 0.05, priority = 2 },
UNIT_SPELLCAST_STOP = { delay = 0.08, priority = 4 },
UNIT_SPELLCAST_CHANNEL_STOP = { delay = 0.08, priority = 4 },
UNIT_SPELLCAST_EMPOWER_STOP = { delay = 0.08, priority = 4 },
UNIT_SPELLCAST_DELAYED = { delay = 0.12, priority = 4 },
UNIT_SPELLCAST_CHANNEL_UPDATE = { delay = 0.10, priority = 4 },
UNIT_SPELLCAST_EMPOWER_UPDATE = { delay = 0.10, priority = 4 },
UNIT_SPELLCAST_FAILED = { delay = 0.08, priority = 4 },
UNIT_SPELLCAST_INTERRUPTED = { delay = 0.08, priority = 4 },
UNIT_SPELLCAST_INTERRUPTIBLE = { delay = 0.10, priority = 4 },
UNIT_SPELLCAST_NOT_INTERRUPTIBLE = { delay = 0.10, priority = 4 },
UNIT_AURA = { delay = 0.22, priority = 3 },
PLAYER_TOTEM_UPDATE = { delay = 0.05, priority = 3 },
RUNE_POWER_UPDATE = { delay = 0.05, priority = 3 },
UNIT_PORTRAIT_UPDATE = { delay = 0.20, priority = 4 },
UNIT_NAME_UPDATE = { delay = 0.15, priority = 4 },
UNIT_FACTION = { delay = 0.15, priority = 4 },
UNIT_FLAGS = { delay = 0.10, priority = 4 },
UNIT_CONNECTION = { delay = 0.10, priority = 4 },
RAID_TARGET_UPDATE = { delay = 0.05, priority = 4 },
GROUP_ROSTER_UPDATE = { delay = 0.12, priority = 4 },
PLAYER_ROLES_ASSIGNED = { delay = 0.12, priority = 4 },
}
local NON_UNIT_EVENT_TARGETS = {
PLAYER_TOTEM_UPDATE = { "player" },
RUNE_POWER_UPDATE = { "player" },
PLAYER_FLAGS_CHANGED = { "player" },
}
local UNIT_SCOPED_EVENTS = {
UNIT_HEALTH = true,
UNIT_POWER_UPDATE = true,
UNIT_MAXHEALTH = true,
UNIT_HEAL_PREDICTION = true,
UNIT_ABSORB_AMOUNT_CHANGED = true,
UNIT_HEAL_ABSORB_AMOUNT_CHANGED = true,
UNIT_MAXPOWER = true,
UNIT_DISPLAYPOWER = true,
UNIT_AURA = true,
UNIT_THREAT_SITUATION_UPDATE = true,
UNIT_THREAT_LIST_UPDATE = true,
UNIT_SPELLCAST_START = true,
UNIT_SPELLCAST_CHANNEL_START = true,
UNIT_SPELLCAST_EMPOWER_START = true,
UNIT_SPELLCAST_STOP = true,
UNIT_SPELLCAST_CHANNEL_STOP = true,
UNIT_SPELLCAST_EMPOWER_STOP = true,
UNIT_SPELLCAST_DELAYED = true,
UNIT_SPELLCAST_CHANNEL_UPDATE = true,
UNIT_SPELLCAST_EMPOWER_UPDATE = true,
UNIT_SPELLCAST_FAILED = true,
UNIT_SPELLCAST_INTERRUPTED = true,
UNIT_SPELLCAST_INTERRUPTIBLE = true,
UNIT_SPELLCAST_NOT_INTERRUPTIBLE = true,
UNIT_PORTRAIT_UPDATE = true,
UNIT_NAME_UPDATE = true,
UNIT_FACTION = true,
UNIT_FLAGS = true,
UNIT_CONNECTION = true,
}
local function ResolveUnitType(unit)
if unit == "player" then
return "player"
elseif unit == "target" then
return "target"
elseif unit == "targettarget" then
return "tot"
elseif unit == "focus" then
return "focus"
elseif unit == "pet" then
return "pet"
elseif unit and unit:match("^party") then
return "party"
elseif unit and unit:match("^raid") then
return "raid"
elseif unit and unit:match("^boss") then
return "boss"
end
return "player"
end
local function ResolveStyleUnitType(frame, unitToken)
if type(unitToken) == "string" and unitToken ~= "" then
return ResolveUnitType(unitToken)
end
local parentFrame = frame and frame.GetParent and frame:GetParent()
local parentName = parentFrame and parentFrame.GetName and parentFrame:GetName()
if type(parentName) == "string" then
if parentName:find("SUF_Party", 1, true) then
return "party"
elseif parentName:find("SUF_Raid", 1, true) then
return "raid"
end
end
local frameName = frame and frame.GetName and frame:GetName()
if type(frameName) == "string" then
if frameName:find("party", 1, true) then
return "party"
elseif frameName:find("raid", 1, true) then
return "raid"
end
end
return "player"
end
local function IsInDelveFollowerPartyContext()
local inWalkInParty = false
if C_PartyInfo and C_PartyInfo.IsPartyWalkIn then
local okWalkIn, walkIn = pcall(C_PartyInfo.IsPartyWalkIn)
inWalkInParty = okWalkIn and walkIn and true or false
end
if not inWalkInParty and C_LFGInfo and C_LFGInfo.IsInLFGFollowerDungeon then
local okFollower, followerDungeon = pcall(C_LFGInfo.IsInLFGFollowerDungeon)
inWalkInParty = okFollower and followerDungeon and true or false
end
return inWalkInParty
end
local function IsInInstanceContext()
if not IsInInstance then
return false, nil
end
local ok, inInstance, instanceType = pcall(IsInInstance)
if not ok then
return false, nil
end
return inInstance and true or false, instanceType
end
local function IsInAnyPartyOrRaid()
local inGroup = (IsInGroup and IsInGroup()) or false
local inRaid = (IsInRaid and IsInRaid()) or false
local instanceCategory = _G.LE_PARTY_CATEGORY_INSTANCE
if instanceCategory then
if not inGroup and IsInGroup then
inGroup = IsInGroup(instanceCategory) or false
end
if not inRaid and IsInRaid then
inRaid = IsInRaid(instanceCategory) or false
end
end
if not inGroup and GetNumSubgroupMembers then
local homeSubgroupCount = tonumber(GetNumSubgroupMembers()) or 0
if homeSubgroupCount > 0 then
inGroup = true
elseif instanceCategory then
local instanceSubgroupCount = tonumber(GetNumSubgroupMembers(instanceCategory)) or 0
if instanceSubgroupCount > 0 then
inGroup = true
end
end
end
if not inGroup then
if IsInDelveFollowerPartyContext() then
inGroup = true
end
end
if not inGroup and UnitExists then
for index = 1, 4 do
if UnitExists("party" .. index) then
inGroup = true
break
end
end
end
if not inRaid and UnitExists and UnitExists("raid1") then
inRaid = true
end
return inGroup, inRaid
end
local function CreateFontString(parent, size, outline)
local font = parent:CreateFontString(nil, "OVERLAY")
font:SetFont(DEFAULT_FONT, size, outline or "")
font:SetJustifyH("LEFT")
font:SetJustifyV("MIDDLE")
return font
end
local function CreateStatusBar(parent, height)
local bar = CreateFrame("StatusBar", nil, parent)
bar:SetHeight(height)
local tex = bar.GetStatusBarTexture and bar:GetStatusBarTexture()
local layer, subLevel
if tex and tex.GetDrawLayer then