-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathTestMode.lua
More file actions
7004 lines (6177 loc) · 294 KB
/
Copy pathTestMode.lua
File metadata and controls
7004 lines (6177 loc) · 294 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 = ...
local L = DF.L
-- ============================================================
-- FRAMES TEST MODE MODULE
-- Contains test mode data, functions, and test panel
-- ============================================================
-- ============================================================
-- TEST MODE DATA
-- ============================================================
DF.TestData = {
units = {
{name = "Tankerino", class = "WARRIOR", role = "TANK", specID = 73, health = 1.0, maxHealth = 100000, absorb = 0.20, healAbsorb = 0, healPrediction = 0.15, status = nil, outOfRange = false, isLeader = true, raidTarget = 8, dispelType = nil, centerStatus = nil, isMainTank = true, isAFK = false, isPhased = false, inVehicle = false, hasMyBuff = true, reducedMaxPct = 0.20}, -- Skull marker, leader, main tank, has HoT
{name = "Healsworth", class = "PRIEST", role = "HEALER", specID = 257, health = 0.95, maxHealth = 85000, absorb = 0.10, healAbsorb = 0, healPrediction = 0.05, status = nil, outOfRange = false, isAssist = true, raidTarget = nil, dispelType = "Magic", centerStatus = "summon", isMainAssist = true, isAFK = false, isPhased = false, inVehicle = false, hasMyBuff = false, reducedMaxPct = 0}, -- Assistant, main assist, summon pending
{name = "Мишок", class = "MAGE", role = "DAMAGER", specID = 63, health = 0.60, maxHealth = 75000, absorb = 0, healAbsorb = 0.15, healPrediction = 0.15, status = nil, outOfRange = true, raidTarget = 1, dispelType = "Curse", centerStatus = nil, isAFK = true, isPhased = false, inVehicle = false, hasMyBuff = true, reducedMaxPct = 0}, -- Star marker, AFK, has HoT
{name = "Alexandrosthegreat", class = "PALADIN", role = "DAMAGER", specID = 70, health = 0, maxHealth = 90000, absorb = 0, healAbsorb = 0, healPrediction = 0, status = "Dead", outOfRange = false, raidTarget = nil, dispelType = nil, centerStatus = "resurrect", isAFK = false, isPhased = false, inVehicle = false, hasMyBuff = false, reducedMaxPct = 0}, -- Dead unit, being resurrected
{name = "Xx", class = "ROGUE", role = "DAMAGER", specID = 260, health = 0.30, maxHealth = 70000, absorb = 0.05, healAbsorb = 0.12, healPrediction = 0.25, status = nil, outOfRange = false, raidTarget = nil, dispelType = "Poison", centerStatus = nil, isAFK = false, isPhased = true, inVehicle = true, hasMyBuff = true, reducedMaxPct = 0.45}, -- Phased, in vehicle, has HoT
},
-- Test aura data - expanded for testing layouts
buffs = {
{icon = "Interface\\Icons\\Spell_Holy_PowerWordShield", name = "Power Word: Shield", duration = 30, stacks = 0},
{icon = "Interface\\Icons\\Spell_Nature_Rejuvenation", name = "Rejuvenation", duration = 12, stacks = 0},
{icon = "Interface\\Icons\\Spell_Holy_Renew", name = "Renew", duration = 15, stacks = 3},
{icon = "Interface\\Icons\\Spell_Holy_BlessingOfProtection", name = "Blessing of Protection", duration = 10, stacks = 0},
{icon = "Interface\\Icons\\Spell_Nature_Regenerate", name = "Regrowth", duration = 12, stacks = 0},
{icon = "Interface\\Icons\\Spell_Holy_Restoration", name = "Restoration", duration = 8, stacks = 0},
{icon = "Interface\\Icons\\Spell_Holy_GreaterHeal", name = "Greater Heal", duration = 6, stacks = 2},
{icon = "Interface\\Icons\\Spell_Nature_LightningShield", name = "Lightning Shield", duration = 600, stacks = 9},
{icon = "Interface\\Icons\\Spell_Holy_SealOfRighteousness", name = "Seal of Righteousness", duration = 0, stacks = 0},
{icon = "Interface\\Icons\\Spell_Magic_GreaterBlessingOfKings", name = "Blessing of Kings", duration = 0, stacks = 0},
},
debuffs = {
{icon = "Interface\\Icons\\Spell_Shadow_ShadowWordPain", name = "Shadow Word: Pain", duration = 18, stacks = 0, debuffType = "Magic"},
{icon = "Interface\\Icons\\Spell_Nature_NullifyPoison", name = "Deadly Poison", duration = 8, stacks = 2, debuffType = "Poison"},
{icon = "Interface\\Icons\\Spell_Shadow_CurseOfTongues", name = "Curse of Tongues", duration = 30, stacks = 0, debuffType = "Curse"},
{icon = "Interface\\Icons\\Ability_Rogue_Garrote", name = "Garrote", duration = 18, stacks = 0, debuffType = nil},
{icon = "Interface\\Icons\\Spell_Shadow_UnholyFrenzy", name = "Disease", duration = 21, stacks = 0, debuffType = "Disease"},
{icon = "Interface\\Icons\\Spell_Fire_Immolation", name = "Immolate", duration = 15, stacks = 0, debuffType = "Magic"},
{icon = "Interface\\Icons\\Ability_Druid_Rake", name = "Rake", duration = 15, stacks = 0, debuffType = nil},
{icon = "Interface\\Icons\\Spell_Nature_Slow", name = "Slow", duration = 12, stacks = 0, debuffType = "Magic"},
{icon = "Interface\\Icons\\Ability_Creature_Disease_05", name = "Plague", duration = 24, stacks = 3, debuffType = "Disease"},
{icon = "Interface\\Icons\\Spell_Shadow_Possession", name = "Fear", duration = 8, stacks = 0, debuffType = "Magic"},
},
-- Boss debuffs (Private Auras) - these simulate what boss mechanics look like
bossDebuffs = {
{icon = "Interface\\Icons\\Spell_Shadow_ShadesOfDarkness", name = "Ethereal Shackles", duration = 8, debuffType = "Magic"},
{icon = "Interface\\Icons\\Spell_Fire_FelFlameBreath", name = "Searing Brand", duration = 12, debuffType = "Magic"},
{icon = "Interface\\Icons\\Ability_Warlock_ShadowFlame", name = "Shadow Burn", duration = 6, debuffType = nil},
{icon = "Interface\\Icons\\Spell_Shadow_DevouringPlague", name = "Devouring Void", duration = 10, debuffType = "Magic"},
},
animationTimer = nil,
animationPhase = 0,
}
-- Get test unit data for a frame index
-- For party: index 0 = player, 1-4 = party members
-- For raid: index 1-40 = raid members
function DF:GetTestUnitData(index, isRaid, isBoss)
local db = isRaid and DF:GetRaidDB() or DF:GetDB()
-- Friendly Boss NPC test data (for pinned frame boss mode).
-- Boss NPCs don't have classes or roles — we return a minimal fake unit
-- so the frame renders a health bar with a readable name.
if isBoss then
local bossNames = {
"Fiery Treant", "Charred Bramble", "Smoldering Sapling", "Ember Root",
"Blazing Thorn", "Ashen Oak", "Cinder Vine", "Glowing Grove",
}
local i = index
local basePercent = (0.9 - (i - 1) * 0.08) -- slight descending stagger
if basePercent < 0.25 then basePercent = 0.25 end
local result = {
index = index,
name = bossNames[i] or ("Friendly Boss " .. i),
class = nil,
role = nil,
specID = 0,
healthPercent = basePercent,
maxHealth = 500000,
currentHealth = math.floor(basePercent * 500000),
powerPercent = 0,
absorbPercent = 0,
healAbsorbPercent = 0,
healPredictionPercent = 0,
status = nil,
outOfRange = false,
isLeader = false,
raidTarget = nil,
dispelType = nil,
centerStatus = nil,
hasMyBuff = false,
isMainTank = false,
isMainAssist = false,
isAFK = false,
isPhased = false,
inVehicle = false,
}
-- Animate health if enabled on either DB
if db.testAnimateHealth and DF.TestData.animationPhase then
local phase = DF.TestData.animationPhase
local offset = (i * 0.13) % 1
local wave = math.sin((phase + offset) * math.pi * 2)
result.healthPercent = math.max(0.1, math.min(1, basePercent + wave * 0.15))
result.currentHealth = math.floor(result.healthPercent * result.maxHealth)
end
return result
end
-- For raid frames, generate deterministic test data
if isRaid then
local testNames = {
"Tankadin", "Healbot", "Magefire", "Stabbymc", "Huntard",
"Shammywow", "Dkfrost", "Warlockz", "Monkbrew", "Priestess",
"Druidtree", "Palaheals", "Rogueshadow", "Warriorfury", "Huntermark",
"Magearcane", "Warlockaff", "Shamanrest", "Monkmist", "Priestshadow",
"Dkblood", "Demonhunter", "Evokerdev", "Tankwarrior", "Tankdruid",
"Holypriest", "Discpriest", "Restoshaman", "Mistweaver", "Holypaladin",
"Boomkin", "Feral", "Enhance", "Elemental", "Retribution",
"Windwalker", "Havoc", "Devastation", "Arms", "Assassination"
}
local testClasses = {
"PALADIN", "PRIEST", "MAGE", "ROGUE", "HUNTER",
"SHAMAN", "DEATHKNIGHT", "WARLOCK", "MONK", "PRIEST",
"DRUID", "PALADIN", "ROGUE", "WARRIOR", "HUNTER",
"MAGE", "WARLOCK", "SHAMAN", "MONK", "PRIEST",
"DEATHKNIGHT", "DEMONHUNTER", "EVOKER", "WARRIOR", "DRUID",
"PRIEST", "PRIEST", "SHAMAN", "MONK", "PALADIN",
"DRUID", "DRUID", "SHAMAN", "SHAMAN", "PALADIN",
"MONK", "DEMONHUNTER", "EVOKER", "WARRIOR", "ROGUE"
}
local testRoles = {
"TANK", "HEALER", "DAMAGER", "DAMAGER", "DAMAGER",
"HEALER", "DAMAGER", "DAMAGER", "TANK", "HEALER",
"HEALER", "HEALER", "DAMAGER", "DAMAGER", "DAMAGER",
"DAMAGER", "DAMAGER", "HEALER", "HEALER", "DAMAGER",
"TANK", "DAMAGER", "DAMAGER", "TANK", "TANK",
"HEALER", "HEALER", "HEALER", "HEALER", "HEALER",
"DAMAGER", "DAMAGER", "DAMAGER", "DAMAGER", "DAMAGER",
"DAMAGER", "DAMAGER", "DAMAGER", "DAMAGER", "DAMAGER"
}
-- Spec IDs matching each class/role for accurate melee/ranged separation
local testSpecs = {
66, -- 1 PALADIN/TANK - Protection
257, -- 2 PRIEST/HEALER - Holy
63, -- 3 MAGE/DAMAGER - Fire (ranged)
260, -- 4 ROGUE/DAMAGER - Outlaw (melee)
254, -- 5 HUNTER/DAMAGER - Marksmanship (ranged)
264, -- 6 SHAMAN/HEALER - Restoration
251, -- 7 DEATHKNIGHT/DPS - Frost (melee)
265, -- 8 WARLOCK/DAMAGER - Affliction (ranged)
268, -- 9 MONK/TANK - Brewmaster
256, -- 10 PRIEST/HEALER - Discipline
105, -- 11 DRUID/HEALER - Restoration
65, -- 12 PALADIN/HEALER - Holy
259, -- 13 ROGUE/DAMAGER - Assassination (melee)
71, -- 14 WARRIOR/DAMAGER - Arms (melee)
255, -- 15 HUNTER/DAMAGER - Survival (melee)
64, -- 16 MAGE/DAMAGER - Frost (ranged)
266, -- 17 WARLOCK/DAMAGER - Demonology (ranged)
264, -- 18 SHAMAN/HEALER - Restoration
270, -- 19 MONK/HEALER - Mistweaver
258, -- 20 PRIEST/DAMAGER - Shadow (ranged)
250, -- 21 DEATHKNIGHT/TANK - Blood
577, -- 22 DEMONHUNTER/DPS - Havoc (melee)
1467, -- 23 EVOKER/DAMAGER - Devastation (ranged)
73, -- 24 WARRIOR/TANK - Protection
104, -- 25 DRUID/TANK - Guardian
257, -- 26 PRIEST/HEALER - Holy
256, -- 27 PRIEST/HEALER - Discipline
264, -- 28 SHAMAN/HEALER - Restoration
270, -- 29 MONK/HEALER - Mistweaver
65, -- 30 PALADIN/HEALER - Holy
102, -- 31 DRUID/DAMAGER - Balance (ranged)
103, -- 32 DRUID/DAMAGER - Feral (melee)
263, -- 33 SHAMAN/DAMAGER - Enhancement (melee)
262, -- 34 SHAMAN/DAMAGER - Elemental (ranged)
70, -- 35 PALADIN/DAMAGER - Retribution (melee)
269, -- 36 MONK/DAMAGER - Windwalker (melee)
577, -- 37 DEMONHUNTER/DPS - Havoc (melee)
1473, -- 38 EVOKER/DAMAGER - Augmentation (ranged)
72, -- 39 WARRIOR/DAMAGER - Fury (melee)
261, -- 40 ROGUE/DAMAGER - Subtlety (melee)
}
local testHealthPercents = {
0.95, 0.88, 0.72, 0.65, 0.80,
0.92, 0.58, 0.75, 0.85, 0.70,
0.90, 0.82, 0.68, 0.55, 0.78,
0.88, 0.62, 0.95, 0.72, 0.60,
0.98, 0.75, 0.82, 0.90, 0.85,
0.78, 0.92, 0.65, 0.88, 0.70,
0.82, 0.75, 0.68, 0.95, 0.58,
0.85, 0.72, 0.80, 0.65, 0.90
}
local testPowerPercents = {
0.85, 0.92, 0.78, 0.65, 0.70,
0.88, 0.55, 0.82, 0.95, 0.72,
0.80, 0.68, 0.90, 0.75, 0.85,
0.62, 0.95, 0.70, 0.88, 0.78,
0.92, 0.65, 0.85, 0.72, 0.80,
0.90, 0.75, 0.82, 0.68, 0.95,
0.78, 0.85, 0.70, 0.88, 0.62,
0.80, 0.92, 0.75, 0.68, 0.85
}
local i = index
local baseHealth = testHealthPercents[i] or 0.75
local basePower = testPowerPercents[i] or 0.80
-- Determine if this frame should be dead (frames 9, 17, 29)
local isDead = (i == 9 or i == 17 or i == 29)
-- Determine dispel type - pattern designed to overlap with some OOR frames
-- OOR frames are 3, 7, 11, 15, 19, 23, 27, 31, 35, 39
-- This pattern gives dispels to frames: 1,6,11,16,21,26,31,36 (Magic), 3,8,13,18,23,28,33,38 (Curse), 5,10,15,20,25,30,35,40 (Poison)
local dispelType = nil
if not isDead then -- Dead frames don't show dispels
if i % 5 == 1 then
dispelType = "Magic"
elseif i % 5 == 3 then
dispelType = "Curse"
elseif i % 5 == 0 then
dispelType = "Poison"
elseif i % 7 == 0 then
dispelType = "Disease" -- Frames 7, 14, 21, 28, 35
end
end
local result = {
index = index, -- Include index for test mode features
name = testNames[i] or ("Player" .. i),
class = testClasses[i] or "WARRIOR",
role = testRoles[i] or "DAMAGER",
specID = testSpecs[i] or 0,
healthPercent = isDead and 0 or baseHealth,
maxHealth = 100000,
currentHealth = isDead and 0 or math.floor(baseHealth * 100000),
powerPercent = isDead and 0 or basePower,
absorbPercent = isDead and 0 or ((i % 3 == 0) and 0.15 or ((i % 5 == 0) and 0.10 or 0)),
reducedMaxPct = isDead and 0 or ((i % 7 == 0) and 0.30 or ((i % 11 == 0) and 0.15 or 0)),
healAbsorbPercent = isDead and 0 or ((i % 7 == 0) and 0.15 or 0),
healPredictionPercent = isDead and 0 or ((i % 2 == 0) and 0.12 or ((i % 3 == 1) and 0.08 or 0)), -- Show heal prediction on some frames
status = isDead and "Dead" or nil,
outOfRange = (i % 4 == 3) and not isDead, -- Every 4th frame starting at 3, but not dead frames
isLeader = (i == 1),
raidTarget = (i <= 8) and i or nil,
dispelType = dispelType,
centerStatus = isDead and "resurrect" or ((i == 2 or i == 6) and "summon" or nil), -- Dead get resurrect, frames 2 and 6 get summon
hasMyBuff = (i % 3 == 1) and not isDead, -- Every 3rd frame starting at 1 (1, 4, 7, 10...), but not dead
-- New icon states
isMainTank = (i == 1 or i == 25), -- First frame and frame 25
isMainAssist = (i == 2 or i == 26), -- Second frame and frame 26
isAFK = (i == 3 or i == 15), -- Frames 3 and 15
isPhased = (i == 4 or i == 20), -- Frames 4 and 20
inVehicle = (i == 5 or i == 30), -- Frames 5 and 30
}
-- Apply animation if enabled
if db.testAnimateHealth and DF.TestData.animationPhase then
local phase = DF.TestData.animationPhase
local offset = (i * 0.15) % 1
local wave = math.sin((phase + offset) * math.pi * 2)
result.healthPercent = math.max(0.1, math.min(1, baseHealth + wave * 0.15))
result.currentHealth = math.floor(result.healthPercent * result.maxHealth)
end
return result
end
-- Party test data (original logic)
local data = DF.TestData.units[index + 1]
if not data then return nil end
local result = {
index = index, -- Include index for test mode features
name = data.name,
class = data.class,
role = data.role,
specID = data.specID or 0,
healthPercent = data.health,
maxHealth = data.maxHealth,
currentHealth = math.floor(data.health * data.maxHealth),
powerPercent = 0.8, -- Default power for party
absorbPercent = data.absorb,
reducedMaxPct = data.reducedMaxPct or 0,
healAbsorbPercent = data.healAbsorb,
healPredictionPercent = data.healPrediction or 0,
status = data.status,
outOfRange = data.outOfRange,
isLeader = data.isLeader,
isAssist = data.isAssist,
raidTarget = data.raidTarget,
dispelType = data.dispelType,
centerStatus = data.centerStatus,
hasMyBuff = data.hasMyBuff,
-- New icon states
isMainTank = data.isMainTank,
isMainAssist = data.isMainAssist,
isAFK = data.isAFK,
isPhased = data.isPhased,
inVehicle = data.inVehicle,
}
-- Don't animate dead or offline units
if data.status then
result.healthPercent = 0
result.currentHealth = 0
result.absorbPercent = 0
result.healAbsorbPercent = 0
result.healPredictionPercent = 0
return result
end
-- Apply animation if enabled (only for alive units) - health only, not absorbs
if db.testAnimateHealth and DF.TestData.animationPhase then
local phase = DF.TestData.animationPhase
local offset = (index * 0.2) % 1
local wave = math.sin((phase + offset) * math.pi * 2)
result.healthPercent = 0.65 + (wave * 0.35)
result.currentHealth = math.floor(result.healthPercent * result.maxHealth)
-- Note: Absorbs use static values from test data, not animated
end
return result
end
-- Start test mode animation
function DF:StartTestAnimation()
if DF.TestData.animationTimer then return end
DF.TestData.animationPhase = 0
DF.TestData.animationTimer = C_Timer.NewTicker(0.05, function()
DF.TestData.animationPhase = (DF.TestData.animationPhase + 0.02) % 1
-- Update party test frames (lightweight - health only)
if DF.testMode then
for i = 0, 4 do
local frame = DF.testPartyFrames[i]
if frame and frame:IsShown() then
DF:UpdateTestFrameHealthOnly(frame, i)
end
end
end
-- Update raid test frames (lightweight - health only)
if DF.raidTestMode then
local db = DF:GetRaidDB()
local testFrameCount = db.raidTestFrameCount or 10
for i = 1, testFrameCount do
local frame = DF.testRaidFrames[i]
if frame and frame:IsShown() then
DF:UpdateTestFrameHealthOnly(frame, i)
end
end
end
-- Update pinned test frames (mock non-secure frames — same for
-- both player-mode and boss-mode pinned sets). Lightweight.
if DF.PinnedFrames and DF.PinnedFrames.IsTestModeActive
and DF.PinnedFrames:IsTestModeActive() then
for setIndex = 1, 2 do
local pool = DF.PinnedFrames.testFrames[setIndex]
if pool then
for i = 1, #pool do
local f = pool[i]
if f and f:IsShown() and f.dfTestIndex then
DF:UpdateTestFrameHealthOnly(f, f.dfTestIndex)
end
end
end
end
end
end)
end
-- Lightweight animation update - updates health and repositions bars
function DF:UpdateTestFrameHealthOnly(frame, index)
if not frame or not frame.healthBar then return end
local isRaid = frame.isRaidFrame
local isBoss = frame.isPinnedBossFrame
local testData = DF:GetTestUnitData(index, isRaid, isBoss)
if not testData then return end
local db = DF:GetFrameDB(frame)
-- Dead or offline units should always show 0 health - no animation
if testData.status then
frame.healthBar:SetValue(0)
frame.testAnimatedHealth = 0
if frame.healthText and frame.healthText:IsShown() then
frame.healthText:SetText("")
end
return
end
-- Calculate animated health (alive units only)
local baseHealth = testData.healthPercent or testData.health or 0.75
local phase = DF.TestData.animationPhase or 0
local variation = math.sin(phase * math.pi * 2 + (index or 0)) * 0.15
local health = math.max(0.1, math.min(1.0, baseHealth + variation))
-- Store animated health for bar updates
frame.testAnimatedHealth = health
-- Update health bar
frame.healthBar:SetValue(health)
-- Re-evaluate health fade threshold with animated health value
if db.healthFadeEnabled then
local healthPct = health * 100
local threshold = db.healthFadeThreshold or 100
local isAbove = (healthPct >= threshold - 0.5)
if isAbove and db.hfCancelOnDispel and frame.dfDispelOverlay and frame.dfDispelOverlay:IsShown() then
isAbove = false
end
if not db.oorEnabled then
frame:SetAlpha(isAbove and (db.healthFadeAlpha or 0.5) or 1.0)
end
end
-- Update missing health bar if enabled
if frame.missingHealthBar then
local backgroundMode = db.backgroundMode or "BACKGROUND"
if backgroundMode == "MISSING_HEALTH" or backgroundMode == "BOTH" then
local missingHealth = 1 - health -- In test mode, we can calculate directly
frame.missingHealthBar:SetMinMaxValues(0, 1)
frame.missingHealthBar:SetValue(missingHealth)
-- Handle color mode
local colorMode = db.missingHealthColorMode or "CUSTOM"
local r, g, b, a
if colorMode == "PERCENT" then
local color = DF:GetHealthGradientColor(health, db, testData.class, "missingHealthColor")
if color then
r, g, b = color.r, color.g, color.b
else
r, g, b = 0.5, 0, 0
end
a = db.missingHealthGradientAlpha or 0.8
elseif colorMode == "CLASS" and testData.class then
local classColor = DF:GetClassColor(testData.class)
if classColor then
r, g, b = classColor.r, classColor.g, classColor.b
else
r, g, b = 0.5, 0, 0
end
a = db.missingHealthClassAlpha or 0.8
else
local missingColor = db.missingHealthColor or {r = 0.5, g = 0, b = 0, a = 0.8}
r, g, b, a = missingColor.r, missingColor.g, missingColor.b, missingColor.a or 0.8
end
frame.missingHealthBar:SetStatusBarColor(r, g, b, a)
-- Handle texture
local texture = db.missingHealthTexture
if not texture or texture == "" then
texture = db.healthTexture or "Interface\\TargetingFrame\\UI-StatusBar"
end
frame.missingHealthBar:SetStatusBarTexture(texture)
frame.missingHealthBar:Show()
else
frame.missingHealthBar:Hide()
end
end
-- Update health bar color if using PERCENT (gradient) mode
-- Only update RGB, alpha is managed by UpdateTestFrame
-- Skip if aggro color override is active
if db.healthColorMode == "PERCENT" and not frame.dfAggroActive then
local color = DF:GetHealthGradientColor(health, db, testData.class)
if color then
frame.healthBar:SetStatusBarColor(color.r, color.g, color.b)
end
end
-- Update health text if visible
if frame.healthText and frame.healthText:IsShown() then
local maxHP = testData.maxHealth or 100000
local currentHP = math.floor(maxHP * health)
local deficit = currentHP - maxHP
local pct = health * 100
local format = db.healthTextFormat or "DEFICIT"
local abbreviate = db.healthTextAbbreviate
local function FormatVal(val)
if abbreviate then
return DF:FormatNumber(val)
end
return tostring(val)
end
local text = ""
if format == "CURRENT" then
text = FormatVal(currentHP)
elseif format == "PERCENT" then
text = string.format("%.0f%%", pct)
elseif format == "DEFICIT" then
if deficit < 0 then
text = FormatVal(deficit)
else
text = ""
end
elseif format == "CURRENT_MAX" or format == "CURRENTMAX" then
text = FormatVal(currentHP) .. "/" .. FormatVal(maxHP)
elseif format == "CURRENT_PERCENT" then
text = FormatVal(currentHP) .. " " .. string.format("%.0f%%", pct)
end
frame.healthText:SetText(text)
end
-- Update bars to follow animated health (use animated health value)
local animatedTestData = {}
for k, v in pairs(testData) do
animatedTestData[k] = v
end
animatedTestData.healthPercent = health
-- Update absorb bars if enabled
if db.testShowAbsorbs then
DF:UpdateTestAbsorb(frame, animatedTestData)
DF:UpdateTestHealAbsorb(frame, animatedTestData)
end
-- Update heal prediction if enabled
if db.testShowHealPrediction ~= false then
DF:UpdateTestHealPrediction(frame, animatedTestData)
end
-- Update dispel gradient if it's tracking health
if frame.dfDispelOverlay and frame.dfDispelOverlay.gradientTracksHealth then
frame.dfDispelOverlay.gradient:SetMinMaxValues(0, 1)
frame.dfDispelOverlay.gradient:SetValue(health)
end
end
-- Stop test mode animation
function DF:StopTestAnimation()
if DF.TestData.animationTimer then
DF.TestData.animationTimer:Cancel()
DF.TestData.animationTimer = nil
end
end
-- Update a frame with test data (works for both party and raid)
function DF:UpdateTestFrame(frame, index, applyLayout)
if not frame or not frame.healthBar then return end
local isRaid = frame.isRaidFrame
local isBoss = frame.isPinnedBossFrame
local testData = DF:GetTestUnitData(index, isRaid, isBoss)
if not testData then return end
local db = DF:GetFrameDB(frame)
-- Set dfInRange for test mode - this is used by ApplyAuraLayout and other systems
-- If testShowOutOfRange is enabled and this unit is marked as out of range, set false
-- Otherwise set true (in range)
local isTestOutOfRange = db.testShowOutOfRange and testData.outOfRange and not testData.status
frame.dfInRange = not isTestOutOfRange
-- Store applyLayout flag for UpdateTestAuras to use
frame.dfTestApplyLayout = applyLayout
-- Update health bar (use 0-1 range for test mode)
frame.healthBar:SetMinMaxValues(0, 1)
local healthValue = testData.healthPercent
if db.smoothBars and Enum and Enum.StatusBarInterpolation then
frame.healthBar:SetValue(healthValue, Enum.StatusBarInterpolation.ExponentialEaseOut)
else
frame.healthBar:SetValue(healthValue)
end
frame.dfTestReducedMaxPct = testData.reducedMaxPct or 0
if DF.UpdateReducedMaxHealth then DF:UpdateReducedMaxHealth(frame) end
-- Update missing health bar if enabled
if frame.missingHealthBar then
local backgroundMode = db.backgroundMode or "BACKGROUND"
if backgroundMode == "MISSING_HEALTH" or backgroundMode == "BOTH" then
local missingHealth = 1 - healthValue -- In test mode, we can calculate directly
frame.missingHealthBar:SetMinMaxValues(0, 1)
if db.smoothBars and Enum and Enum.StatusBarInterpolation then
frame.missingHealthBar:SetValue(missingHealth, Enum.StatusBarInterpolation.ExponentialEaseOut)
else
frame.missingHealthBar:SetValue(missingHealth)
end
-- Handle color mode
local colorMode = db.missingHealthColorMode or "CUSTOM"
local r, g, b, a
-- Check for dead/offline with custom dead color (same as Core.lua)
local isDeadOrOfflineForColor = testData.status == "Dead" or testData.status == "Offline"
local useDeadColor = isDeadOrOfflineForColor and db.fadeDeadFrames and db.fadeDeadUseCustomColor
if useDeadColor then
-- Use custom dead color (same as background uses)
local c = db.fadeDeadBackgroundColor or {r = 0.3, g = 0, b = 0}
r, g, b = c.r, c.g, c.b
a = db.fadeDeadBackground or 0.4
elseif colorMode == "PERCENT" then
local color = DF:GetHealthGradientColor(healthValue, db, testData.class, "missingHealthColor")
if color then
r, g, b = color.r, color.g, color.b
else
r, g, b = 0.5, 0, 0
end
a = db.missingHealthGradientAlpha or 0.8
elseif colorMode == "CLASS" and testData.class then
local classColor = DF:GetClassColor(testData.class)
if classColor then
r, g, b = classColor.r, classColor.g, classColor.b
else
r, g, b = 0.5, 0, 0
end
a = db.missingHealthClassAlpha or 0.8
else
local missingColor = db.missingHealthColor or {r = 0.5, g = 0, b = 0, a = 0.8}
r, g, b, a = missingColor.r, missingColor.g, missingColor.b, missingColor.a or 0.8
end
frame.missingHealthBar:SetStatusBarColor(r, g, b, a)
-- Handle texture
local texture = db.missingHealthTexture
if not texture or texture == "" then
texture = db.healthTexture or "Interface\\TargetingFrame\\UI-StatusBar"
end
frame.missingHealthBar:SetStatusBarTexture(texture)
frame.missingHealthBar:Show()
else
frame.missingHealthBar:Hide()
end
end
-- Update health text with proper formatting
local format = db.healthTextFormat or "PERCENT"
local currentHealth = testData.currentHealth
local maxHealth = testData.maxHealth
local deficit = maxHealth - currentHealth
local abbreviate = db.healthTextAbbreviate
local function FormatValue(val)
if abbreviate then
if AbbreviateNumbers then
return AbbreviateNumbers(val)
elseif AbbreviateLargeNumbers then
return AbbreviateLargeNumbers(val)
end
-- Manual abbreviation fallback when abbreviate is true
if val >= 1000000 then
return string.format("%.1fM", val / 1000000)
elseif val >= 1000 then
return string.format("%.0fK", val / 1000)
end
end
-- No abbreviation - return full number with comma formatting
return tostring(val)
end
local pctFmt = db.healthTextHidePercent and "%.0f" or "%.0f%%"
if format == "PERCENT" then
frame.healthText:SetFormattedText(pctFmt, healthValue * 100)
elseif format == "CURRENT" then
frame.healthText:SetText(FormatValue(currentHealth))
elseif format == "CURRENTMAX" then
frame.healthText:SetText(FormatValue(currentHealth) .. "/" .. FormatValue(maxHealth))
elseif format == "DEFICIT" then
if deficit > 0 then
frame.healthText:SetText("-" .. FormatValue(deficit))
else
frame.healthText:SetText("")
end
elseif format == "NONE" then
frame.healthText:SetText("")
else
frame.healthText:SetFormattedText(pctFmt, healthValue * 100)
end
-- Update name
local displayName = testData.name
if displayName then
local maxLen = db.nameTextLength or 0
local truncMode = db.nameTextTruncateMode or "ELLIPSIS"
if maxLen > 0 and DF:UTF8Len(displayName) > maxLen then
if truncMode == "CUT" then
displayName = DF:UTF8Sub(displayName, 1, maxLen)
else
displayName = DF:UTF8Sub(displayName, 1, maxLen) .. "..."
end
end
end
frame.nameText:SetText(displayName)
-- Determine if this frame should show out-of-range effects
-- OOR takes priority over dead fade (they should never multiply)
local isOutOfRange = db.testShowOutOfRange and testData.outOfRange
-- Calculate per-element alphas for out-of-range
local healthBarAlpha = 1.0
local backgroundAlpha = 1.0
local nameAlpha = 1.0
local healthTextAlpha = 1.0
local aurasAlpha = 1.0
local iconsAlpha = 1.0
local powerBarAlpha = 1.0
local dispelAlpha = 1.0
local targetedSpellAlpha = 1.0
if isOutOfRange then
if db.oorEnabled then
-- Element-specific alpha mode
healthBarAlpha = db.oorHealthBarAlpha or 0.55
backgroundAlpha = db.oorBackgroundAlpha or 0.55
nameAlpha = db.oorNameTextAlpha or 0.55
healthTextAlpha = db.oorHealthTextAlpha or 0.55
aurasAlpha = db.oorAurasAlpha or 0.55
iconsAlpha = db.oorIconsAlpha or 0.55
powerBarAlpha = db.oorPowerBarAlpha or 0.55
dispelAlpha = db.oorDispelOverlayAlpha or 0.55
targetedSpellAlpha = db.oorTargetedSpellAlpha or 0.5
else
-- Simple frame-level alpha mode
local alpha = db.rangeFadeAlpha or db.rangeAlpha or 0.55
healthBarAlpha = alpha
backgroundAlpha = alpha
nameAlpha = alpha
healthTextAlpha = alpha
aurasAlpha = alpha
iconsAlpha = alpha
powerBarAlpha = alpha
dispelAlpha = alpha
targetedSpellAlpha = alpha
end
end
-- Store alpha values for use by UpdateTestIcons and UpdateTestPowerBar
frame.dfTestOORAlphas = {
icons = iconsAlpha,
power = powerBarAlpha,
dispel = dispelAlpha,
targetedSpell = targetedSpellAlpha,
}
-- Check if this is a dead/offline unit for dead fade handling
local isDeadOrOffline = testData.status == "Dead" or testData.status == "Offline"
local applyDeadFade = isDeadOrOffline and db.fadeDeadFrames and not isOutOfRange
-- Store dead fade alphas for use by UpdateTestIcons and UpdateTestPowerBar
-- OOR takes priority: skip dead fade storage when out of range
if applyDeadFade then
frame.dfTestDeadFadeAlphas = {
icons = db.fadeDeadIcons or 1.0,
power = db.fadeDeadPowerBar or 0.4,
auras = db.fadeDeadAuras or 1.0,
}
else
frame.dfTestDeadFadeAlphas = nil
end
-- Health-based fading (above threshold): only when in range, alive, and option enabled
local healthPct = (testData.healthPercent or 1) * 100
local threshold = db.healthFadeThreshold or 100
local isAboveHealthThreshold = not isOutOfRange and not applyDeadFade
and db.healthFadeEnabled
and (healthPct >= threshold - 0.5)
if isAboveHealthThreshold and db.hfCancelOnDispel and frame.dfDispelOverlay and frame.dfDispelOverlay:IsShown() then
isAboveHealthThreshold = false
end
if isAboveHealthThreshold then
local hfAlpha = db.healthFadeAlpha or 0.5
healthBarAlpha = hfAlpha
backgroundAlpha = hfAlpha
nameAlpha = hfAlpha
healthTextAlpha = hfAlpha
aurasAlpha = hfAlpha
iconsAlpha = hfAlpha
powerBarAlpha = hfAlpha
dispelAlpha = hfAlpha
targetedSpellAlpha = hfAlpha
frame.dfTestHealthFadeAlphas = {
icons = iconsAlpha,
power = powerBarAlpha,
dispel = dispelAlpha,
targetedSpell = targetedSpellAlpha,
}
else
frame.dfTestHealthFadeAlphas = nil
end
-- Update name color with appropriate alpha
-- Priority: OOR > dead fade > health-based fade
local finalNameAlpha = nameAlpha
if not isOutOfRange and applyDeadFade then
finalNameAlpha = db.fadeDeadName or 1.0
end
if db.nameTextUseClassColor then
local classColor = DF:GetClassColor(testData.class)
if classColor then
frame.nameText:SetTextColor(classColor.r, classColor.g, classColor.b, finalNameAlpha)
end
else
local c = db.nameTextColor or {r=1, g=1, b=1}
frame.nameText:SetTextColor(c.r, c.g, c.b, finalNameAlpha)
end
-- Update health bar color based on mode
-- Use RGB only (no alpha in SetStatusBarColor) so we can control alpha externally
-- Skip if aggro color override is active
local classColorAlpha = db.classColorAlpha or 1.0
if not frame.dfAggroActive then
if db.healthColorMode == "CLASS" then
local classColor = DF:GetClassColor(testData.class)
if classColor then
frame.healthBar:SetStatusBarColor(classColor.r, classColor.g, classColor.b)
end
elseif db.healthColorMode == "PERCENT" then
local color = DF:GetHealthGradientColor(healthValue, db, testData.class)
if color then
frame.healthBar:SetStatusBarColor(color.r, color.g, color.b)
end
elseif db.healthColorMode == "CUSTOM" then
local c = db.healthColor or {r=0, g=1, b=0}
frame.healthBar:SetStatusBarColor(c.r, c.g, c.b)
end
end
-- Apply combined alpha to health bar texture (classColorAlpha * OOR alpha)
-- Dead fade overrides health bar alpha if applicable
if frame.healthBar then
local tex = frame.healthBar:GetStatusBarTexture()
if tex then
local finalAlpha = classColorAlpha * healthBarAlpha
if applyDeadFade then
finalAlpha = db.fadeDeadHealthBar or 0.4
end
tex:SetAlpha(finalAlpha)
end
end
-- Update background color and texture
local bgMode = db.backgroundColorMode or "CUSTOM"
local bgTexture = db.backgroundTexture or "Solid"
-- Determine background color for dead fade
local deadBgColor = nil
local deadBgAlpha = db.fadeDeadBackground or 0.4
if applyDeadFade and db.fadeDeadUseCustomColor then
deadBgColor = db.fadeDeadBackgroundColor or {r = 0.3, g = 0, b = 0}
end
if frame.background then
-- In test mode, ALWAYS force-apply the texture to avoid cache inconsistencies
-- Test mode doesn't update as frequently so performance is not a concern
if bgTexture == "Solid" or bgTexture == "" then
-- Solid color mode - use SetColorTexture
frame.dfCurrentBgTexture = "Solid"
if applyDeadFade and deadBgColor then
-- Dead fade with custom color
frame.background:SetColorTexture(deadBgColor.r, deadBgColor.g, deadBgColor.b, deadBgAlpha)
elseif applyDeadFade then
-- Dead fade without custom color - use normal color but with dead fade alpha
if bgMode == "CUSTOM" then
local c = db.backgroundColor or {r=0.1, g=0.1, b=0.1, a=0.8}
frame.background:SetColorTexture(c.r, c.g, c.b, deadBgAlpha)
elseif bgMode == "CLASS" then
local classColor = DF:GetClassColor(testData.class)
if classColor then
frame.background:SetColorTexture(classColor.r, classColor.g, classColor.b, deadBgAlpha)
else
frame.background:SetColorTexture(0, 0, 0, deadBgAlpha)
end
else
frame.background:SetColorTexture(0, 0, 0, deadBgAlpha)
end
elseif bgMode == "CUSTOM" then
local c = db.backgroundColor or {r=0.1, g=0.1, b=0.1, a=0.8}
-- Multiply configured alpha by OOR alpha
local finalAlpha = (c.a or 0.8) * backgroundAlpha
frame.background:SetColorTexture(c.r, c.g, c.b, finalAlpha)
elseif bgMode == "CLASS" then
local classColor = DF:GetClassColor(testData.class)
local bgAlpha = db.backgroundClassAlpha or 0.3
local finalAlpha = bgAlpha * backgroundAlpha
if classColor then
frame.background:SetColorTexture(classColor.r, classColor.g, classColor.b, finalAlpha)
else
frame.background:SetColorTexture(0, 0, 0, 0.8 * backgroundAlpha)
end
else
frame.background:SetColorTexture(0, 0, 0, 0.8 * backgroundAlpha)
end
else
-- Textured background
-- ALWAYS apply the texture in test mode (no caching) to ensure it's set correctly
frame.background:SetTexture(bgTexture)
frame.background:SetHorizTile(false)
frame.background:SetVertTile(false)
frame.dfCurrentBgTexture = bgTexture
-- For textured backgrounds, SetAlpha MUST be 1.0 so vertex color alpha works
frame.background:SetAlpha(1.0)
-- Control alpha ONLY via SetVertexColor
if applyDeadFade and deadBgColor then
-- Dead fade with custom color
frame.background:SetVertexColor(deadBgColor.r, deadBgColor.g, deadBgColor.b, deadBgAlpha)
elseif applyDeadFade then
-- Dead fade without custom color - use normal color but with dead fade alpha
if bgMode == "CUSTOM" then
local c = db.backgroundColor or {r=0.1, g=0.1, b=0.1, a=0.8}
frame.background:SetVertexColor(c.r, c.g, c.b, deadBgAlpha)
elseif bgMode == "CLASS" then
local classColor = DF:GetClassColor(testData.class)
if classColor then
frame.background:SetVertexColor(classColor.r, classColor.g, classColor.b, deadBgAlpha)
else
frame.background:SetVertexColor(0, 0, 0, deadBgAlpha)
end
else
frame.background:SetVertexColor(0, 0, 0, deadBgAlpha)
end
elseif bgMode == "CUSTOM" then
local c = db.backgroundColor or {r=0.1, g=0.1, b=0.1, a=0.8}
local finalAlpha = (c.a or 0.8) * backgroundAlpha
frame.background:SetVertexColor(c.r, c.g, c.b, finalAlpha)
elseif bgMode == "CLASS" then
local classColor = DF:GetClassColor(testData.class)
local bgAlpha = db.backgroundClassAlpha or 0.3
local finalAlpha = bgAlpha * backgroundAlpha
if classColor then
frame.background:SetVertexColor(classColor.r, classColor.g, classColor.b, finalAlpha)
else
frame.background:SetVertexColor(0, 0, 0, 0.8 * backgroundAlpha)
end
else
frame.background:SetVertexColor(0, 0, 0, 0.8 * backgroundAlpha)
end
end
end
-- Frame-level alpha when not using element-specific OOR (same as live UpdateFrameAppearance)
if not db.oorEnabled then
if isOutOfRange then
frame:SetAlpha(db.rangeFadeAlpha or db.rangeAlpha or 0.55)
elseif isAboveHealthThreshold then
frame:SetAlpha(db.healthFadeAlpha or 0.5)
else
frame:SetAlpha(1)
end
else
frame:SetAlpha(1)
end
-- Apply alpha to health text
if frame.healthText then
if db.healthTextUseClassColor then
local classColor = DF:GetClassColor(testData.class)
if classColor then
frame.healthText:SetTextColor(classColor.r, classColor.g, classColor.b, healthTextAlpha)
end
else
local htc = db.healthTextColor or {r=1, g=1, b=1}
frame.healthText:SetTextColor(htc.r, htc.g, htc.b, healthTextAlpha)
end
end
-- Update absorb bars
if db.testShowAbsorbs then
DF:UpdateTestAbsorb(frame, testData)
DF:UpdateTestHealAbsorb(frame, testData)
else
if frame.dfAbsorbBar then frame.dfAbsorbBar:Hide() end
if frame.dfHealAbsorbBar then frame.dfHealAbsorbBar:Hide() end
if frame.absorbOvershieldGlow then frame.absorbOvershieldGlow:Hide() end
if frame.healAbsorbOvershieldGlow then frame.healAbsorbOvershieldGlow:Hide() end
-- Hide attached textures used for ATTACHED mode test display
if frame.absorbAttachedTexture then frame.absorbAttachedTexture:Hide() end
if frame.healAbsorbAttachedTexture then frame.healAbsorbAttachedTexture:Hide() end
-- Hide overflow bar
if frame.absorbOverflowBar then frame.absorbOverflowBar:Hide() end
end
-- Update heal prediction (check test mode setting)
if db.testShowHealPrediction ~= false then
DF:UpdateTestHealPrediction(frame, testData)
else