-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathElementAppearance.lua
More file actions
1282 lines (1057 loc) · 44.2 KB
/
Copy pathElementAppearance.lua
File metadata and controls
1282 lines (1057 loc) · 44.2 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, DF = ...
-- ============================================================
-- ELEMENT APPEARANCE SYSTEM
-- Centralized color AND alpha management for all frame elements
-- Each element has a single function that determines its full appearance
-- based on all relevant factors (OOR, dead, aggro, settings, etc.)
--
-- This replaces the separate color/alpha functions to prevent flickering
-- and conflicts from multiple functions trying to set appearance.
--
-- Priority Order for determining appearance:
-- 1. Aggro Override (health bar only)
-- 2. Dead/Offline State
-- 3. Health Threshold Fading (above configurable health threshold)
-- 4. Out of Range (OOR) - element-specific or frame-level
-- 5. Normal Settings
--
-- Integration Points:
-- - Range timer (Range.lua) calls UpdateRangeAppearance every 0.2s
-- (which skips per-element updates in standard OOR mode for performance)
-- - ApplyDeadFade/ResetDeadFade (Colors.lua) delegate here
-- - UpdateUnitFrame (Update.lua) calls for unit changes
-- - Settings hooks call for live updates
-- ============================================================
-- Local caching for performance
local pairs, ipairs = pairs, ipairs
local UnitInRange = UnitInRange
local UnitIsDeadOrGhost = UnitIsDeadOrGhost
local UnitIsConnected = UnitIsConnected
local UnitExists = UnitExists
local UnitIsUnit = UnitIsUnit
local UnitClass = UnitClass
local IsInGroup = IsInGroup
local IsInRaid = IsInRaid
local CreateColor = CreateColor
local issecretvalue = issecretvalue -- nil pre-Midnight, function in Midnight+
-- ============================================================
-- PERFORMANCE FIX: Reusable ColorMixin objects
-- SetVertexColorFromBoolean needs ColorMixin objects, but creating
-- them every call (5x/sec per frame) causes massive memory allocation.
-- We reuse the same objects and just update their values.
-- ============================================================
local reusableInRangeColor = CreateColor(1, 1, 1, 1)
local reusableOutOfRangeColor = CreateColor(1, 1, 1, 1)
-- ============================================================
-- PERFORMANCE FIX: Default color tables
-- These are used as fallbacks when db values are nil
-- Avoids creating new tables on every call (called 5x/sec per frame)
-- ============================================================
local DEFAULT_COLOR_GRAY = {r = 0.5, g = 0.5, b = 0.5}
local DEFAULT_COLOR_HEALTH = {r = 0.2, g = 0.8, b = 0.2}
local DEFAULT_COLOR_DEAD_BG = {r = 0.3, g = 0, b = 0}
local DEFAULT_COLOR_BACKGROUND = {r = 0.1, g = 0.1, b = 0.1, a = 0.8}
local DEFAULT_COLOR_WHITE = {r = 1, g = 1, b = 1}
-- ============================================================
-- HELPER FUNCTIONS
-- ============================================================
-- Check if frame is a DandersFrames frame (process all our frames)
local function IsDandersFrame(frame)
return frame and frame.dfIsDandersFrame
end
-- Get the appropriate database for this frame
local function GetDB(frame)
return frame.isRaidFrame and DF:GetRaidDB() or DF:GetDB()
end
-- Get current range status for a unit
-- Returns a boolean (may be secret from UnitInRange fallback)
-- Downstream callers must use SetAlphaFromBoolean for secret-safe alpha.
local function GetInRange(frame)
-- Use cached value from Range.lua if available
-- May be a secret boolean from UnitInRange (classes without friendly spells)
local inRange = frame.dfInRange
if issecretvalue and issecretvalue(inRange) then
return inRange -- Secret boolean, pass through for SetAlphaFromBoolean
end
if inRange ~= nil then
return inRange
end
-- Fallback for frames not yet updated by range timer
local unit = frame.unit
if not unit then return true end
if not UnitExists(unit) then
return true
elseif UnitIsUnit(unit, "player") then
return true -- Player is always in range
end
-- Default to in-range if no cached value yet
return true
end
-- Apply OOR alpha to any UI element (Frame, Texture, or FontString)
-- inRange may be a secret boolean from UnitInRange fallback (DK/DH/Hunter/Warrior).
-- SetAlphaFromBoolean handles secret booleans natively (Midnight+ API).
local function ApplyOORAlpha(element, inRange, inAlpha, oorAlpha)
if not element then return end
if element.SetAlphaFromBoolean then
element:SetAlphaFromBoolean(inRange, inAlpha, oorAlpha)
else
element:SetAlpha(inRange and inAlpha or oorAlpha)
end
end
-- Check if unit is dead or offline
local function IsDeadOrOffline(frame)
local unit = frame.unit
if not unit or not UnitExists(unit) then return false end
return UnitIsDeadOrGhost(unit) or not UnitIsConnected(unit)
end
-- Check if unit is specifically offline (not just dead)
local function IsOffline(frame)
local unit = frame.unit
if not unit or not UnitExists(unit) then return false end
return not UnitIsConnected(unit)
end
-- Check if health threshold fade is enabled
local function IsHealthFadeEnabled(db)
return db and db.healthFadeEnabled
end
-- Get class color for a unit
local function GetClassColor(frame)
local unit = frame.unit
if not unit or not UnitExists(unit) then
return DEFAULT_COLOR_GRAY
end
local _, class = UnitClass(unit)
return DF:GetClassColor(class)
end
-- ============================================================
-- HEALTH BAR APPEARANCE
-- Handles: color mode, dead/offline, aggro, OOR alpha
-- We apply color via the texture's SetVertexColor to avoid secret value issues
-- ============================================================
function DF:UpdateHealthBarAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.healthBar then return end
local db = GetDB(frame)
if not db then return end
-- Skip during test mode (test mode handles its own appearance)
if DF.testMode or DF.raidTestMode then return end
local unit = frame.unit
local deadOrOffline = IsDeadOrOffline(frame)
local offline = IsOffline(frame)
local inRange = GetInRange(frame)
local aggroActive = frame.dfAggroActive and frame.dfAggroColor
-- Get the texture - this is what we apply colors to
local tex = frame.healthBar:GetStatusBarTexture()
if not tex then return end
-- ========================================
-- DETERMINE ALPHA
-- ========================================
local colorMode = db.healthColorMode or "CLASS"
local alpha
if colorMode == "CUSTOM" then
local c = db.healthColor
alpha = (c and c.a) or 1.0
else
alpha = db.classColorAlpha or 1.0
end
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadHealthBar or 1
end
-- ========================================
-- APPLY COLOR
-- Skip when Aura Designer health bar color indicator is active.
-- AD owns the bar color while its indicator is applied; normal
-- color updates (UNIT_HEALTH, form shifts, etc.) must not
-- overwrite it. Alpha is still applied below so OOR/dead fade
-- continues to work.
-- ========================================
local adHealthBarActive = frame.dfAD and frame.dfAD.healthbar
if adHealthBarActive then
-- AD owns the color — don't touch it
elseif aggroActive then
-- Priority 1: Aggro override
local c = frame.dfAggroColor
tex:SetVertexColor(c.r, c.g, c.b)
elseif deadOrOffline then
-- Priority 2: Dead/Offline gray
if offline then
tex:SetVertexColor(0.5, 0.5, 0.5)
else
tex:SetVertexColor(0.3, 0.3, 0.3)
end
else
-- Priority 3: Normal color based on mode
if colorMode == "PERCENT" then
-- PERCENT mode: Use UnitHealthPercent with curve - returns ColorMixin
local curve = DF:GetCurveForUnit(unit, db)
if curve and unit and UnitHealthPercent then
local color = UnitHealthPercent(unit, true, curve)
if color then
tex:SetVertexColor(color:GetRGB())
else
-- Fallback to class color
local classColor = GetClassColor(frame)
tex:SetVertexColor(classColor.r, classColor.g, classColor.b)
end
else
-- Fallback to class color
local classColor = GetClassColor(frame)
tex:SetVertexColor(classColor.r, classColor.g, classColor.b)
end
elseif colorMode == "CLASS" then
local classColor = GetClassColor(frame)
tex:SetVertexColor(classColor.r, classColor.g, classColor.b)
elseif colorMode == "CUSTOM" then
local c = db.healthColor or DEFAULT_COLOR_HEALTH
tex:SetVertexColor(c.r, c.g, c.b)
else
-- Default fallback
tex:SetVertexColor(0, 0.8, 0)
end
end
-- ========================================
-- APPLY ALPHA
-- ========================================
if db.oorEnabled then
-- Element-specific OOR mode
local oorAlpha = db.oorHealthBarAlpha or 0.2
ApplyOORAlpha(tex, inRange, alpha, oorAlpha)
else
-- Frame-level OOR mode - just apply alpha
tex:SetAlpha(alpha)
end
end
-- ============================================================
-- MISSING HEALTH BAR APPEARANCE
-- Handles: dead/offline custom color override
-- ============================================================
function DF:UpdateMissingHealthBarAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.missingHealthBar then return end
-- Skip during test mode
if DF.testMode or DF.raidTestMode then return end
local unit = frame.unit
if not unit then return end
-- OOR alpha for element-specific mode
local db = GetDB(frame)
if db and db.oorEnabled then
local inRange = GetInRange(frame)
local oorAlpha = db.oorMissingHealthAlpha or 0.2
ApplyOORAlpha(frame.missingHealthBar, inRange, 1.0, oorAlpha)
end
-- SetMissingHealthBarValue handles the dead color override internally
DF.SetMissingHealthBarValue(frame.missingHealthBar, unit, frame)
end
-- ============================================================
-- BACKGROUND APPEARANCE
-- Handles: color mode, textured vs solid, dead/offline, OOR alpha
-- ============================================================
function DF:UpdateBackgroundAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.background then return end
local db = GetDB(frame)
if not db then return end
-- Skip during test mode
if DF.testMode or DF.raidTestMode then return end
-- Skip if actively adjusting background color in options (prevents flicker)
if DF.isAdjustingBackgroundColor then return end
-- Handle backgroundMode visibility
local backgroundMode = db.backgroundMode or "BACKGROUND"
if backgroundMode == "MISSING_HEALTH" then
-- Only missing health bar visible, hide solid background
frame.background:SetAlpha(0)
return
end
-- For "BACKGROUND" or "BOTH", continue with normal background rendering
local unit = frame.unit
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
-- Check if using textured background
local bgTexture = db.backgroundTexture or "Solid"
local isTexturedBg = bgTexture ~= "Solid" and bgTexture ~= ""
-- ========================================
-- DETERMINE COLOR
-- ========================================
local r, g, b = 0.1, 0.1, 0.1 -- Default dark
local baseAlpha = 0.8
local bgMode = db.backgroundColorMode or "CUSTOM"
-- Check for dead custom color override (COLOR only, alpha handled separately)
local useDeadColor = deadOrOffline and db.fadeDeadFrames and db.fadeDeadUseCustomColor
if useDeadColor then
-- Use custom dead COLOR (alpha is handled in next section)
local c = db.fadeDeadBackgroundColor or DEFAULT_COLOR_DEAD_BG
r, g, b = c.r, c.g, c.b
baseAlpha = 0.8
elseif bgMode == "CLASS" and unit and UnitExists(unit) then
local classColor = GetClassColor(frame)
r, g, b = classColor.r, classColor.g, classColor.b
baseAlpha = db.backgroundClassAlpha or 0.3
elseif bgMode == "CUSTOM" then
local c = db.backgroundColor or DEFAULT_COLOR_BACKGROUND
r, g, b = c.r, c.g, c.b
baseAlpha = c.a or 0.8
else
-- Fallback - use default background color (BLIZZARD/BLACK migrated to CUSTOM in v3.2.x)
local c = db.backgroundColor or DEFAULT_COLOR_BACKGROUND
r, g, b = c.r, c.g, c.b
baseAlpha = c.a or 0.8
end
-- ========================================
-- DETERMINE ALPHA
-- ========================================
local finalAlpha = baseAlpha
if deadOrOffline and db.fadeDeadFrames then
finalAlpha = db.fadeDeadBackground or 1
end
-- ========================================
-- APPLY APPEARANCE
-- ========================================
if db.oorEnabled then
-- Element-specific OOR mode
local oorBgAlpha = db.oorBackgroundAlpha or 0.1
if isTexturedBg then
-- Textured background: use SetVertexColor for color+alpha
frame.background:SetAlpha(1.0) -- Keep frame alpha at 1
if frame.background.SetVertexColorFromBoolean then
-- PERF: Reuse color objects instead of creating new ones
reusableInRangeColor:SetRGBA(r, g, b, finalAlpha)
reusableOutOfRangeColor:SetRGBA(r, g, b, oorBgAlpha)
frame.background:SetVertexColorFromBoolean(inRange, reusableInRangeColor, reusableOutOfRangeColor)
else
local effectiveAlpha = inRange and finalAlpha or oorBgAlpha
frame.background:SetVertexColor(r, g, b, effectiveAlpha)
end
else
-- Solid background: use SetColorTexture + ApplyOORAlpha
frame.background:SetColorTexture(r, g, b, 1.0)
ApplyOORAlpha(frame.background, inRange, finalAlpha, oorBgAlpha)
end
else
-- Frame-level OOR mode
if isTexturedBg then
frame.background:SetAlpha(1.0)
frame.background:SetVertexColor(r, g, b, finalAlpha)
else
frame.background:SetColorTexture(r, g, b, 1.0)
frame.background:SetAlpha(finalAlpha)
end
end
end
-- ============================================================
-- NAME TEXT APPEARANCE
-- Handles: color (class or custom), dead/offline, OOR alpha
-- ============================================================
function DF:UpdateNameTextAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.nameText then return end
-- Skip test frames - they handle their own appearance in TestMode.lua
if frame.dfIsTestFrame then return end
local db = GetDB(frame)
if not db then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
-- ========================================
-- DETERMINE COLOR
-- ========================================
local r, g, b = 1, 1, 1 -- Default white
local baseAlpha = 1.0 -- From color picker
if db.nameTextUseClassColor then
-- Class color always applies, even when dead/offline
local classColor = GetClassColor(frame)
r, g, b = classColor.r, classColor.g, classColor.b
elseif deadOrOffline then
-- Gray for dead/offline (only when not using class color)
r, g, b = 0.5, 0.5, 0.5
else
local c = db.nameTextColor or DEFAULT_COLOR_WHITE
r, g, b = c.r, c.g, c.b
baseAlpha = c.a or 1.0
end
-- ========================================
-- DETERMINE ALPHA
-- All alpha goes through SetAlpha/SetAlphaFromBoolean,
-- never through SetTextColor's alpha channel.
-- ========================================
local alpha = baseAlpha
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadName or 1.0
end
-- ========================================
-- APPLY APPEARANCE
-- Color always uses alpha=1.0; opacity is controlled
-- solely via SetAlpha so it works with SetAlphaFromBoolean.
-- ========================================
frame.nameText:SetTextColor(r, g, b, 1.0)
if db.oorEnabled then
local oorAlpha = db.oorNameTextAlpha or 1
ApplyOORAlpha(frame.nameText, inRange, alpha, oorAlpha)
else
frame.nameText:SetAlpha(alpha)
end
end
-- ============================================================
-- HEALTH TEXT APPEARANCE
-- ============================================================
function DF:UpdateHealthTextAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.healthText then return end
local db = GetDB(frame)
if not db then return end
-- Skip during test mode
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
-- ========================================
-- DETERMINE COLOR
-- ========================================
local r, g, b = 1, 1, 1 -- Default white
local baseAlpha = 1.0 -- From color picker
if db.healthTextUseClassColor then
local classColor = GetClassColor(frame)
r, g, b = classColor.r, classColor.g, classColor.b
else
local c = db.healthTextColor or DEFAULT_COLOR_WHITE
r, g, b = c.r, c.g, c.b
baseAlpha = c.a or 1.0
end
-- ========================================
-- DETERMINE ALPHA
-- All alpha goes through SetAlpha/SetAlphaFromBoolean.
-- ========================================
local alpha = baseAlpha
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadHealthBar or 1 -- Health text follows health bar alpha
end
-- ========================================
-- APPLY APPEARANCE
-- Color always uses alpha=1.0; opacity is controlled
-- solely via SetAlpha so it works with SetAlphaFromBoolean.
-- ========================================
frame.healthText:SetTextColor(r, g, b, 1.0)
if db.oorEnabled then
local oorAlpha = db.oorHealthTextAlpha or 0.25
ApplyOORAlpha(frame.healthText, inRange, alpha, oorAlpha)
else
frame.healthText:SetAlpha(alpha)
end
end
-- ============================================================
-- STATUS TEXT APPEARANCE
-- ============================================================
function DF:UpdateStatusTextAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.statusText then return end
local db = GetDB(frame)
if not db then return end
-- Skip during test mode
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
-- Status text color (usually white)
local c = db.statusTextColor or DEFAULT_COLOR_WHITE
local r, g, b = c.r, c.g, c.b
local baseAlpha = c.a or 1.0
local alpha = baseAlpha
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadStatusText or 1.0
end
-- Color always uses alpha=1.0; opacity via SetAlpha
frame.statusText:SetTextColor(r, g, b, 1.0)
frame.statusText:SetAlpha(alpha)
end
-- ============================================================
-- PARTY INDEX TEXT APPEARANCE
-- ============================================================
function DF:UpdatePartyIndexTextAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.partyIndexText then return end
local db = GetDB(frame)
if not db then return end
if db.partyIndexTextEnabled == false then
frame.partyIndexText:Hide()
return
end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
local r, g, b = 1, 1, 1
local baseAlpha = 1.0
if db.partyIndexTextUseClassColor then
local classColor = GetClassColor(frame)
r, g, b = classColor.r, classColor.g, classColor.b
elseif deadOrOffline then
r, g, b = 0.5, 0.5, 0.5
else
local c = db.partyIndexTextColor or DEFAULT_COLOR_WHITE
r, g, b = c.r, c.g, c.b
baseAlpha = c.a or 1.0
end
local alpha = baseAlpha
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadName or 1.0
end
frame.partyIndexText:SetTextColor(r, g, b, 1.0)
if db.oorEnabled then
local oorAlpha = db.oorNameTextAlpha or 1
ApplyOORAlpha(frame.partyIndexText, inRange, alpha, oorAlpha)
else
frame.partyIndexText:SetAlpha(alpha)
end
end
-- ============================================================
-- POWER BAR APPEARANCE
-- ============================================================
function DF:UpdatePowerBarAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.dfPowerBar then return end
local db = GetDB(frame)
if not db then return end
-- Skip during test mode
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
-- Power bar color is typically set by UpdateUnitFrame based on power type
-- Here we just handle alpha
local alpha = 1.0
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadPowerBar or 0
end
if db.oorEnabled then
local oorAlpha = db.oorPowerBarAlpha or 0.2
ApplyOORAlpha(frame.dfPowerBar, inRange, alpha, oorAlpha)
else
frame.dfPowerBar:SetAlpha(alpha)
end
end
-- ============================================================
-- BUFF ICONS APPEARANCE
-- ============================================================
function DF:UpdateBuffIconsAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.buffIcons then return end
local db = GetDB(frame)
if not db then return end
-- Skip during test mode
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
local alpha = 1.0
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadAuras or 1.0
end
if db.oorEnabled then
local oorAlpha = db.oorAurasAlpha or 0.2
for _, icon in ipairs(frame.buffIcons) do
if icon then
ApplyOORAlpha(icon, inRange, alpha, oorAlpha)
end
end
else
for _, icon in ipairs(frame.buffIcons) do
if icon then
icon:SetAlpha(alpha)
end
end
end
end
-- ============================================================
-- DEBUFF ICONS APPEARANCE
-- ============================================================
function DF:UpdateDebuffIconsAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.debuffIcons then return end
local db = GetDB(frame)
if not db then return end
-- Skip during test mode
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
local alpha = 1.0
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadAuras or 1.0
end
if db.oorEnabled then
local oorAlpha = db.oorAurasAlpha or 0.2
for _, icon in ipairs(frame.debuffIcons) do
if icon then
ApplyOORAlpha(icon, inRange, alpha, oorAlpha)
end
end
else
for _, icon in ipairs(frame.debuffIcons) do
if icon then
icon:SetAlpha(alpha)
end
end
end
end
-- ============================================================
-- ICON APPEARANCE (Role, Leader, Raid Target, Ready Check, Center Status)
-- These icons don't change color, just alpha
-- ============================================================
function DF:UpdateRoleIconAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.roleIcon then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
local alpha = db.roleIconAlpha or 1.0
if deadOrOffline and db.fadeDeadFrames then
alpha = (db.fadeDeadIcons or 1.0) * (db.roleIconAlpha or 1.0)
end
if db.oorEnabled then
local oorAlpha = db.oorIconsAlpha or 0.5
ApplyOORAlpha(frame.roleIcon, inRange, alpha, oorAlpha)
else
frame.roleIcon:SetAlpha(alpha)
end
end
function DF:UpdateLeaderIconAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.leaderIcon then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
local alpha = db.leaderIconAlpha or 1.0
if deadOrOffline and db.fadeDeadFrames then
alpha = (db.fadeDeadIcons or 1.0) * (db.leaderIconAlpha or 1.0)
end
if db.oorEnabled then
local oorAlpha = db.oorIconsAlpha or 0.5
ApplyOORAlpha(frame.leaderIcon, inRange, alpha, oorAlpha)
else
frame.leaderIcon:SetAlpha(alpha)
end
end
function DF:UpdateRaidTargetIconAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.raidTargetIcon then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
local alpha = db.raidTargetIconAlpha or 1.0
if deadOrOffline and db.fadeDeadFrames then
alpha = (db.fadeDeadIcons or 1.0) * (db.raidTargetIconAlpha or 1.0)
end
if db.oorEnabled then
local oorAlpha = db.oorIconsAlpha or 0.5
ApplyOORAlpha(frame.raidTargetIcon, inRange, alpha, oorAlpha)
else
frame.raidTargetIcon:SetAlpha(alpha)
end
end
function DF:UpdateReadyCheckIconAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.readyCheckIcon then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
local alpha = db.readyCheckIconAlpha or 1.0
if deadOrOffline and db.fadeDeadFrames then
alpha = (db.fadeDeadIcons or 1.0) * (db.readyCheckIconAlpha or 1.0)
end
if db.oorEnabled then
local oorAlpha = db.oorIconsAlpha or 0.5
ApplyOORAlpha(frame.readyCheckIcon, inRange, alpha, oorAlpha)
else
frame.readyCheckIcon:SetAlpha(alpha)
end
end
function DF:UpdateCenterStatusIconAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.centerStatusIcon then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
local alpha = 1.0
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadIcons or 1.0
end
if db.oorEnabled then
local oorAlpha = db.oorIconsAlpha or 0.5
ApplyOORAlpha(frame.centerStatusIcon, inRange, alpha, oorAlpha)
else
frame.centerStatusIcon:SetAlpha(alpha)
end
end
-- ============================================================
-- DISPEL OVERLAY APPEARANCE
-- ============================================================
function DF:UpdateDispelOverlayAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.dfDispelOverlay then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local deadOrOffline = IsDeadOrOffline(frame)
local inRange = GetInRange(frame)
local overlay = frame.dfDispelOverlay
local alpha = 1.0
if deadOrOffline and db.fadeDeadFrames then
alpha = db.fadeDeadBackground or 1
end
if db.oorEnabled then
local oorAlpha = db.oorDispelOverlayAlpha or 0.2
ApplyOORAlpha(overlay.gradient, inRange, alpha, oorAlpha)
ApplyOORAlpha(overlay.borderTop, inRange, alpha, oorAlpha)
ApplyOORAlpha(overlay.borderBottom, inRange, alpha, oorAlpha)
ApplyOORAlpha(overlay.borderLeft, inRange, alpha, oorAlpha)
ApplyOORAlpha(overlay.borderRight, inRange, alpha, oorAlpha)
ApplyOORAlpha(overlay.icon, inRange, alpha, oorAlpha)
if DF.ApplyDispelOverlayAppearance then
DF:ApplyDispelOverlayAppearance(frame)
end
else
if overlay.gradient then overlay.gradient:SetAlpha(alpha) end
if overlay.borderTop then overlay.borderTop:SetAlpha(alpha) end
if overlay.borderBottom then overlay.borderBottom:SetAlpha(alpha) end
if overlay.borderLeft then overlay.borderLeft:SetAlpha(alpha) end
if overlay.borderRight then overlay.borderRight:SetAlpha(alpha) end
if overlay.icon then overlay.icon:SetAlpha(alpha) end
end
end
-- ============================================================
-- MY BUFF INDICATOR APPEARANCE
-- ============================================================
function DF:UpdateMyBuffIndicatorAppearance(frame)
if DF.ApplyMyBuffIndicatorAppearance then
DF:ApplyMyBuffIndicatorAppearance(frame)
end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
if not frame.dfMyBuffOverlay or not frame.dfMyBuffOverlay:IsShown() then return end
end
-- ============================================================
-- MISSING BUFF ICON APPEARANCE
-- ============================================================
function DF:UpdateMissingBuffAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.missingBuffFrame then return end
-- PERF: Skip if missing buff frame isn't visible
if not frame.missingBuffFrame:IsShown() then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local inRange = GetInRange(frame)
local alpha = 1.0
if db.oorEnabled then
local oorAlpha = db.oorMissingBuffAlpha or 0.5
ApplyOORAlpha(frame.missingBuffIcon, inRange, alpha, oorAlpha)
ApplyOORAlpha(frame.missingBuffBorderLeft, inRange, alpha, oorAlpha)
ApplyOORAlpha(frame.missingBuffBorderRight, inRange, alpha, oorAlpha)
ApplyOORAlpha(frame.missingBuffBorderTop, inRange, alpha, oorAlpha)
ApplyOORAlpha(frame.missingBuffBorderBottom, inRange, alpha, oorAlpha)
else
frame.missingBuffIcon:SetAlpha(alpha)
if frame.missingBuffBorderLeft then frame.missingBuffBorderLeft:SetAlpha(alpha) end
if frame.missingBuffBorderRight then frame.missingBuffBorderRight:SetAlpha(alpha) end
if frame.missingBuffBorderTop then frame.missingBuffBorderTop:SetAlpha(alpha) end
if frame.missingBuffBorderBottom then frame.missingBuffBorderBottom:SetAlpha(alpha) end
end
end
-- ============================================================
-- ABSORB BAR APPEARANCE
-- ============================================================
function DF:UpdateAbsorbBarAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.dfAbsorbBar then return end
-- PERF: Skip if absorb bar isn't visible
if not frame.dfAbsorbBar:IsShown() then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local inRange = GetInRange(frame)
if db.oorEnabled then
local oorAlpha = db.oorAbsorbBarAlpha or 0.5
ApplyOORAlpha(frame.dfAbsorbBar, inRange, 1.0, oorAlpha)
end
end
-- ============================================================
-- HEAL ABSORB BAR APPEARANCE
-- ============================================================
function DF:UpdateHealAbsorbBarAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.dfHealAbsorbBar then return end
if not frame.dfHealAbsorbBar:IsShown() then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local inRange = GetInRange(frame)
if db.oorEnabled then
local oorAlpha = db.oorAbsorbBarAlpha or 0.5
ApplyOORAlpha(frame.dfHealAbsorbBar, inRange, 1.0, oorAlpha)
end
end
-- ============================================================
-- HEAL PREDICTION BAR APPEARANCE
-- ============================================================
function DF:UpdateHealPredictionBarAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.dfHealPredictionBar then return end
if not frame.dfHealPredictionBar:IsShown() then return end
local db = GetDB(frame)
if not db then return end
if DF.testMode or DF.raidTestMode then return end
local inRange = GetInRange(frame)
if db.oorEnabled then
local oorAlpha = db.oorAbsorbBarAlpha or 0.5
ApplyOORAlpha(frame.dfHealPredictionBar, inRange, 1.0, oorAlpha)
end
end
-- ============================================================
-- DEFENSIVE ICON APPEARANCE
-- ============================================================
function DF:UpdateDefensiveIconAppearance(frame)
if not IsDandersFrame(frame) then return end
if not frame.defensiveIcon then return end