Repository navigation
Expand file tree
/
Copy pathUnitFrames.lua
More file actions
1928 lines (1737 loc) · 74.1 KB
/
Copy pathUnitFrames.lua
File metadata and controls
1928 lines (1737 loc) · 74.1 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
-------------------------------------------------------------------------------
-- BlackwellUI for Azeroth Survivors - UnitFrames.lua
-- Copyright (c) 2026 Pierre (Blackwellcode). All rights reserved. See LICENSE.
-- Cyberpunk HUD Unit Frames:
-- - Hero & Target frames (210 x 46): tall 35px health bar + 6px sleek power bar
-- - Player class-colored or cyber-accent health bar with dark slate backdrop
-- - In-bar Typography: Name on LEFT, HP & Percent (HP | %) on RIGHT
-- - Target reaction-colored (Hostile red, Neutral yellow, Friendly green)
-- - Pet & Target of Target mini frames (110 x 24)
-- - Dynamic Encounter stack for 20 active elites, guardians, and bosses
-- - Clean Blizzard frame suppression
-- Lua 5.0 / WoW 1.12.1: no '#', no '%', no string methods.
-------------------------------------------------------------------------------
local B = BlackwellUI
local L = B.L
local mod = {}
mod.label = "Unit Frames"
mod.alwaysActive = true
-- Blizzard unit frames are suppressed via OnShow; turning it off takes a /reload.
mod.reloadOnToggle = true
mod.hint = "Hero, target, target of target and the elites & bosses list."
mod.fontList = {}
local HEALTH_TEXT_VALUES = {
{ value = "both", label = "Value and percent" },
{ value = "percent", label = "Percent" },
{ value = "value", label = "Current value" },
{ value = "curmax", label = "Current / max" },
{ value = "none", label = "Hidden" },
}
mod.options = {
{ type = "section", label = "Hero & target" },
{ type = "range", key = "heroWidth", label = "Hero width", min = 160, max = 320, step = 10, default = 210, format = "%d px" },
{ type = "range", key = "heroHeight", label = "Hero height", min = 40, max = 80, step = 2, default = 46, format = "%d px" },
{ type = "range", key = "targetWidth", label = "Target width", min = 160, max = 320, step = 10, default = 210, format = "%d px" },
{ type = "range", key = "targetHeight", label = "Target height", min = 40, max = 80, step = 2, default = 46, format = "%d px" },
{ type = "range", key = "fontSize", label = "Text size", hint = "Added to the global text size.", min = -3, max = 4, step = 1, default = 0, format = "%d" },
{ type = "choice", key = "healthText", label = "Health text", default = "both", values = HEALTH_TEXT_VALUES },
{ type = "toggle", key = "shortNumbers", label = "Short numbers", hint = "Shows 12.5K instead of 12500.", default = true },
{ type = "toggle", key = "showNames", label = "Show names", default = true },
{ type = "toggle", key = "showLevel", label = "Show level and badges", default = true },
{ type = "toggle", key = "showPowerBar", label = "Show power bars", default = true },
{ type = "toggle", key = "showShieldBar", label = "Show shield bar", default = true },
{ type = "toggle", key = "showXpBar", label = "Show XP bar", default = true },
{ type = "toggle", db = "colorHealthByClass", label = "Class-coloured health", default = true },
{ type = "toggle", key = "customHealthColor", label = "Custom health colour", hint = "Used when class-coloured health is off, instead of the accent.", default = false },
{ type = "color", key = "healthColor", label = "Health colour", default = { r = 0.20, g = 0.80, b = 0.20 }, depends = "customHealthColor" },
{ type = "toggle", key = "showDebuffs", label = "Target debuff bars", default = true },
{ type = "range", key = "maxDebuffs", label = "Max debuff bars", min = 1, max = 6, step = 1, default = 6, format = "%d", depends = "showDebuffs" },
{ type = "toggle", key = "showToT", label = "Target of target", default = true },
{ type = "toggle", key = "showPet", label = "Pet frame", default = true },
{ type = "section", label = "Elites & bosses" },
{ type = "range", key = "encWidth", label = "Width", min = 180, max = 400, step = 10, default = 260, format = "%d px" },
{ type = "range", key = "encMaxRows", label = "Max rows", min = 1, max = 20, step = 1, default = 20, format = "%d" },
{ type = "range", key = "encRowHeight", label = "Row height", min = 12, max = 28, step = 1, default = 18, format = "%d px" },
{ type = "toggle", key = "encShowTags", label = "Show kind tags", hint = "[BOSS], [GUARD], [ELITE] in front of the name.", default = true },
{ type = "choice", key = "encHealthText", label = "Health text", default = "curmaxpct", values = {
{ value = "curmaxpct", label = "Current / max (percent)" },
{ value = "both", label = "Value and percent" },
{ value = "percent", label = "Percent" },
{ value = "value", label = "Current value" },
{ value = "none", label = "Hidden" },
} },
{ type = "section", label = "Enemy colours" },
{ type = "note", label = "Target frame, elites & bosses list and nameplates use these colours." },
{ type = "color", key = "colorBoss", label = "Boss", default = { r = 0.86, g = 0.20, b = 0.20 } },
{ type = "color", key = "colorFinal", label = "Final boss", default = { r = 0.86, g = 0.16, b = 0.42 } },
{ type = "color", key = "colorGuardian", label = "Rare guardian", default = { r = 1.00, g = 0.78, b = 0.15 } },
{ type = "color", key = "colorElite", label = "Elite", default = { r = 0.25, g = 0.60, b = 1.00 } },
{ type = "color", key = "colorNormal", label = "Normal enemy", default = { r = 0.58, g = 0.42, b = 0.92 } },
{ type = "section", label = "Party" },
{ type = "toggle", key = "showParty", label = "Party frames", default = true },
{ type = "range", key = "partyWidth", label = "Party frame width", min = 90, max = 200, step = 5, default = 130, format = "%d px", depends = "showParty" },
{ type = "range", key = "partySpacing", label = "Party spacing", min = 0, max = 20, step = 1, default = 6, format = "%d px", depends = "showParty" },
}
local MAX_ENCOUNTER_ROWS = 20
local ENC_WIDTH = 260
local MAX_TARGET_DEBUFFS = 6
local DEBUFF_BAR_WIDTH = 208
local DEBUFF_BAR_HEIGHT = 16
local lastTickDamage = {
["rend"] = 450,
["deep wounds"] = 890,
["corruption"] = 1240,
["shadow word: pain"] = 720,
["immolate"] = 980,
["moonfire"] = 560,
["serpent sting"] = 340,
["thunder clap"] = 620,
}
local debuffTimers = {}
local DEBUFF_DURATIONS = {
["rend"] = 15,
["deep wounds"] = 12,
["corruption"] = 18,
["shadow word: pain"] = 18,
["immolate"] = 15,
["moonfire"] = 12,
["serpent sting"] = 15,
["insect swarm"] = 12,
["rip"] = 16,
["garrote"] = 18,
["deadly poison"] = 12,
["thunder clap"] = 30,
["demoralizing shout"] = 30,
["curse of agony"] = 24,
["siphon life"] = 30,
["gouge"] = 5.5,
["kidney shot"] = 6,
["blind"] = 10,
["hamstring"] = 15,
["frostbolt"] = 9,
["cone of cold"] = 8,
["blizzard"] = 8,
["chilled"] = 5,
}
local function ParsePeriodicDamage(msg)
if not msg or msg == "" then return end
-- Pattern 1 (EN): "X suffers 450 Fire damage from your Immolation."
local _, _, dmg, spell = string.find(msg, "suffers (%d+).-damage from your ([^%.]+)")
if dmg and spell then
local d = tonumber(dmg)
if d then
lastTickDamage[string.lower(spell)] = d
return
end
end
-- Pattern 2 (EN): "suffers 450 ... from your Rend"
local _, _, dmg2, spell2 = string.find(msg, "suffers (%d+).-from your ([^%.]+)")
if dmg2 and spell2 then
local d = tonumber(dmg2)
if d then
lastTickDamage[string.lower(spell2)] = d
return
end
end
-- Pattern 3 (DE): "X erleidet 450 Feuerschaden durch Euer/Eure/Euren Feuerbrand."
local _, _, dmgDe, spellDe = string.find(msg, "erleidet (%d+).-durch Euer.- ([^%.]+)")
if dmgDe and spellDe then
local d = tonumber(dmgDe)
if d then
lastTickDamage[string.lower(spellDe)] = d
return
end
end
-- Pattern 4 (DE): "X erleidet 450 Schaden von Eurem Feuerbrand."
local _, _, dmgDe2, spellDe2 = string.find(msg, "erleidet (%d+).-von Euer.- ([^%.]+)")
if dmgDe2 and spellDe2 then
local d = tonumber(dmgDe2)
if d then
lastTickDamage[string.lower(spellDe2)] = d
return
end
end
end
local function GetSpellTickDamage(name)
if not name then return nil end
local lowerName = string.lower(name)
local val = lastTickDamage[lowerName]
if not val then
for k, v in pairs(lastTickDamage) do
if string.find(lowerName, k, 1, true) or string.find(k, lowerName, 1, true) then
val = v
break
end
end
end
if not val and type(AZS_METER) == "table" then
for i = 1, table.getn(AZS_METER) do
local item = AZS_METER[i]
if type(item) == "table" and item.name and string.lower(item.name) == lowerName then
if item.dps and item.dps > 0 then
val = math.floor(tonumber(item.dps) + 0.5)
end
break
end
end
end
return val
end
local function GetOrInitDebuffTimer(name, now)
local key = name and string.lower(name) or "default"
if not debuffTimers[key] then
local dur = DEBUFF_DURATIONS[key] or 15
debuffTimers[key] = { start = now, dur = dur }
end
return debuffTimers[key]
end
local debuffScanTooltip = nil
local function GetTargetDebuffName(index, tex)
local name = nil
if not debuffScanTooltip then
debuffScanTooltip = CreateFrame("GameTooltip", "BUI_TargetDebuffScanTooltip", UIParent, "GameTooltipTemplate")
debuffScanTooltip:SetOwner(UIParent, "ANCHOR_NONE")
end
if debuffScanTooltip.SetUnitDebuff then
debuffScanTooltip:ClearLines()
debuffScanTooltip:SetUnitDebuff("target", index)
local fs = getglobal("BUI_TargetDebuffScanTooltipTextLeft1")
if fs and fs.GetText then
name = fs:GetText()
end
end
if (not name or name == "") and tex then
local _, _, file = string.find(tex, "[^\\]+$")
if file then
name = string.gsub(file, "^Ability_", "")
name = string.gsub(name, "^Spell_", "")
name = string.gsub(name, "_", " ")
end
end
return name or ("Debuff " .. tostring(index))
end
local DEBUFF_TYPE_COLORS = {
["Curse"] = { r = 0.65, g = 0.20, b = 0.95 },
["Disease"] = { r = 0.65, g = 0.40, b = 0.10 },
["Magic"] = { r = 0.20, g = 0.65, b = 1.00 },
["Poison"] = { r = 0.15, g = 0.75, b = 0.20 },
["none"] = { r = 0.85, g = 0.20, b = 0.25 },
}
local function GetDebuffBarColor(debuffType, name)
if debuffType and DEBUFF_TYPE_COLORS[debuffType] then
return DEBUFF_TYPE_COLORS[debuffType]
end
if name then
local s = string.lower(name)
if string.find(s, "fire") or string.find(s, "burn") or string.find(s, "immolat") or string.find(s, "flame") then
return { r = 1.00, g = 0.45, b = 0.10 }
elseif string.find(s, "frost") or string.find(s, "ice") or string.find(s, "chill") or string.find(s, "cold") then
return { r = 0.25, g = 0.75, b = 1.00 }
elseif string.find(s, "shadow") or string.find(s, "pain") or string.find(s, "curse") or string.find(s, "dark") then
return { r = 0.65, g = 0.20, b = 0.95 }
elseif string.find(s, "thunder") or string.find(s, "nature") or string.find(s, "lightning") then
return { r = 0.30, g = 0.75, b = 0.95 }
elseif string.find(s, "poison") or string.find(s, "venom") or string.find(s, "toxin") then
return { r = 0.15, g = 0.75, b = 0.20 }
elseif string.find(s, "shout") or string.find(s, "roar") then
return { r = 0.85, g = 0.50, b = 0.18 }
end
end
return DEBUFF_TYPE_COLORS["none"]
end
local POWER_COLORS = {
[0] = { r = 0.00, g = 0.55, b = 1.00 }, -- Mana
[1] = { r = 0.90, g = 0.20, b = 0.20 }, -- Rage
[2] = { r = 1.00, g = 0.50, b = 0.25 }, -- Focus
[3] = { r = 1.00, g = 0.85, b = 0.10 }, -- Energy
}
local REACTION_COLORS = {
hostile = { r = 0.80, g = 0.15, b = 0.15 }, -- Red
neutral = { r = 0.85, g = 0.75, b = 0.15 }, -- Yellow
friendly = { r = 0.20, g = 0.80, b = 0.25 }, -- Green
tapped = { r = 0.55, g = 0.55, b = 0.55 }, -- Grey
}
-------------------------------------------------------------------------------
-- Style & option helpers
-------------------------------------------------------------------------------
-- Defaults that differ per style: the round frames are one health bar
-- without power / xp / shield lines. Sizes and positions stay those of the
-- classic layout in both styles.
local STYLE_DEFAULTS = {
showPowerBar = { sharp = true, round = false },
showXpBar = { sharp = true, round = false },
showShieldBar = { sharp = true, round = false },
}
local function Opt(key, default)
local sd = STYLE_DEFAULTS[key]
if sd then
if B:IsRound() then default = sd.round else default = sd.sharp end
end
return B:ModOpt("unitframes", key, default)
end
local function OptColor(key, def)
local c = Opt(key, def)
if type(c) == "table" and c.r then return c.r, c.g, c.b end
return def.r, def.g, def.b
end
-- Font strings of this module remember their base size for the text size option.
local function Font(parent, size, justify)
local fs = B:Font(parent, size, justify)
table.insert(mod.fontList, { fs = fs, size = size })
return fs
end
-- Corner radius for a panel that can shrink to minHeight: capped at half
-- of it, else the round panel's centre strip gets a negative height.
local function PanelRadius(minHeight)
local rad = (B.db and B.db.cornerRadius) or 10
local cap = math.floor(minHeight / 2)
if rad > cap then rad = cap end
if rad < 0 then rad = 0 end
return rad
end
-- Inset that keeps square bar corners inside a round corner: r * (1 - 1/sqrt 2).
local function RoundInset(radius)
local p = math.ceil(radius * 0.3)
if p < 2 then p = 2 end
return p
end
-- Background in the active style; returns the inner padding for the bars.
local function FramePanel(f, minHeight, alpha)
if B:IsRound() then
local rad = PanelRadius(minHeight)
B:Panel(f, rad)
return RoundInset(rad)
end
B:Backdrop(f, alpha)
return 1
end
-- Thin bar: RoundBar with round caps in the round style, StatusBar in sharp.
local function ThinBar(parent, height, r, g, b)
if B:IsRound() then
local bar = B:RoundBar(parent, height)
if r then
bar.buiR, bar.buiG, bar.buiB = r, g, b
bar:SetFillColor(r, g, b)
end
return bar
end
local sb = B:Bar(parent, nil, r, g, b)
sb:SetHeight(height)
return sb
end
-- Value / colour setters that work on both StatusBars and RoundBars.
local function SetBarFill(bar, v)
if type(bar.SetFill) == "function" then
bar:SetFill(v)
else
bar:SetValue(v)
end
end
local function SetBarRGB(bar, r, g, b)
if type(bar.SetFillColor) == "function" then
bar.buiR, bar.buiG, bar.buiB = r, g, b
bar:SetFillColor(r, g, b)
else
B:SetBarColor(bar, r, g, b)
end
end
local function FormatNumber(v, short)
if short then return B:Short(v) end
return string.format("%d", math.floor((tonumber(v) or 0) + 0.5))
end
-- mode: "both" (12K | 52%), "percent", "value", "curmax" (12K / 20K),
-- "curmaxpct" (12K / 20K (52%)), "none".
local function FormatHealth(cur, max, pct, mode, short)
local pctInt = math.floor((pct or 0) * 100 + 0.5)
if mode == "none" then
return ""
elseif mode == "percent" then
return string.format("%d%%", pctInt)
elseif mode == "value" then
return FormatNumber(cur, short)
elseif mode == "curmax" then
return FormatNumber(cur, short) .. " / " .. FormatNumber(max, short)
elseif mode == "curmaxpct" then
return string.format("%s / %s (%d%%)", FormatNumber(cur, short), FormatNumber(max, short), pctInt)
end
return string.format("%s | %d%%", FormatNumber(cur, short), pctInt)
end
-- Frame layout presets. sharpHpOff: health height = frame height - off with
-- the power bar shown (the old fixed layout); powerH: round power bar height.
local LAYOUT_BIG = { sharpHpOff = 11, sharpPowerGap = 2, powerH = 4 }
local LAYOUT_SMALL = { sharpHpOff = 7, sharpPowerGap = 1, powerH = 3 }
local LAYOUT_PARTY = { sharpHpOff = 10, sharpPowerGap = 1, powerH = 4 }
-- Stacks health, power and the thin xp / shield slot inside a frame whose
-- health bar is anchored at the top (TOPLEFT/TOPRIGHT, inset f.buiPad).
local function LayoutStack(f, h, cfg, showPower, slot)
local round = B:IsRound()
local hpH
if round then
hpH = h - 2 * (f.buiPad or 3)
if showPower then hpH = hpH - cfg.powerH - 2 end
if slot then hpH = hpH - 4 end
elseif showPower then
hpH = h - cfg.sharpHpOff
else
hpH = h - 2
if slot then hpH = hpH - 3 end
end
if hpH < 6 then hpH = 6 end
f:SetHeight(h)
f.hpBar:SetHeight(hpH)
local below = f.hpBar
if f.pBar then
local gap = round and 2 or cfg.sharpPowerGap
f.pBar:ClearAllPoints()
f.pBar:SetPoint("TOPLEFT", f.hpBar, "BOTTOMLEFT", 0, -gap)
f.pBar:SetPoint("TOPRIGHT", f.hpBar, "BOTTOMRIGHT", 0, -gap)
if showPower then
f.pBar:Show()
below = f.pBar
else
f.pBar:Hide()
end
end
local slotGap = round and 2 or 1
local slotBars = { f.shBar, f.xpBar }
for i = 1, 2 do
local sb = slotBars[i]
if sb then
sb:ClearAllPoints()
sb:SetPoint("TOPLEFT", below, "BOTTOMLEFT", 0, -slotGap)
sb:SetPoint("TOPRIGHT", below, "BOTTOMRIGHT", 0, -slotGap)
end
end
end
-------------------------------------------------------------------------------
-- Round style: the health bar is the frame. It fills the whole frame with
-- the frame's corner radius; name, level / status and the health value sit
-- inside it, as in the classic layout. Power, xp and shield lines are off by
-- default and, when switched on, run as thin lines along the bottom edge.
-------------------------------------------------------------------------------
local function FullBar(f, w, h, showPower, showSlot, big)
f:SetWidth(w)
f:SetHeight(h)
local rad = (B.db and B.db.cornerRadius) or 10
if rad > h / 2 then rad = math.floor(h / 2) end
local pad = 10
if rad > pad then pad = rad end
f.hpBar:ClearAllPoints()
f.hpBar:SetPoint("TOPLEFT", f, "TOPLEFT", 0, 0)
f.hpBar:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 0, 0)
B:SetBarRadius(f.hpBar, rad)
B:SetBarTrackColor(f.hpBar, 0, 0, 0, 0.35)
f.nameText:ClearAllPoints()
f.hpText:ClearAllPoints()
f.hpText:SetPoint("RIGHT", f, "RIGHT", -pad, 0)
f.hpText:SetJustifyH("RIGHT")
local sub = f.lvlText or f.badgeText
if big and h >= 34 then
-- Two text rows: name on top, level / status below.
f.nameText:SetPoint("TOPLEFT", f, "TOPLEFT", pad, -6)
if sub then
sub:ClearAllPoints()
sub:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", pad, 6)
sub:SetJustifyH("LEFT")
end
else
f.nameText:SetPoint("LEFT", f, "LEFT", pad, 0)
if sub then
sub:ClearAllPoints()
sub:SetPoint("LEFT", f.nameText, "RIGHT", 4, 0)
end
end
-- Room for the health text: "12.5K | 85%" on big frames, "85%" on small.
if big then
f.nameText:SetWidth(w - 2 * pad - 90)
else
f.nameText:SetWidth(w - 2 * pad - 36)
end
f.nameText:SetJustifyH("LEFT")
-- Optional thin lines inside the bottom edge.
local y = 3
if f.pBar then
f.pBar:ClearAllPoints()
f.pBar:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", rad, y)
f.pBar:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -rad, y)
if showPower then
f.pBar:Show()
y = y + 4
else
f.pBar:Hide()
end
end
local slotBars = { f.shBar, f.xpBar }
for i = 1, 2 do
local sb = slotBars[i]
if sb then
sb:ClearAllPoints()
sb:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", rad, y)
sb:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -rad, y)
if not showSlot then sb:Hide() end
end
end
end
-- Health text: one string in the sharp style, split into "current / max"
-- (left) and percent (right) on the round cards.
local function SetHealthTexts(f, cur, max, pct, mode, short)
if not f.hpLeft then
f.hpText:SetText(FormatHealth(cur, max, pct, mode, short))
return
end
local pctText = string.format("%d%%", math.floor((pct or 0) * 100 + 0.5))
if mode == "none" then
f.hpLeft:SetText("")
f.hpText:SetText("")
elseif mode == "percent" then
f.hpLeft:SetText("")
f.hpText:SetText(pctText)
elseif mode == "value" then
f.hpLeft:SetText(FormatNumber(cur, short))
f.hpText:SetText("")
elseif mode == "curmax" then
f.hpLeft:SetText(FormatNumber(cur, short) .. " / " .. FormatNumber(max, short))
f.hpText:SetText("")
else
f.hpLeft:SetText(FormatNumber(cur, short) .. " / " .. FormatNumber(max, short))
f.hpText:SetText(pctText)
end
end
-- Hover tint in a normal layer: this engine draws the HIGHLIGHT layer all
-- the time, not only under the mouse. Shown from OnEnter, hidden on OnLeave.
local function HoverTint(owner, region, alpha)
local hl = owner:CreateTexture(nil, "OVERLAY")
B:Solid(hl, 1, 1, 1, alpha or 0.12)
hl:SetAllPoints(region or owner)
hl:Hide()
return hl
end
-- Left click targets the unit, right click opens the game's own unit menu
-- (raid target icons, invite, trade ...). The stock frames stay hidden, but
-- their dropdowns are initialised by the game and still work.
local function OpenUnitMenu(menuName)
local dd = menuName and getglobal(menuName)
if dd and type(ToggleDropDownMenu) == "function" then
ToggleDropDownMenu(1, nil, dd, "cursor")
end
end
local function UnitClick(unit, button, menuName)
if B.unlocked or not unit or not UnitExists(unit) then return end
if button == "RightButton" then
if menuName then OpenUnitMenu(menuName) end
elseif not UnitIsUnit(unit, "target") then
TargetUnit(unit)
end
end
-- For plain frames (no OnClick): mouse-up carries the button in arg1.
local function MakeUnitClickable(f, unit, menuName)
f.unitId = unit
f.unitMenu = menuName
f:EnableMouse(true)
f:SetScript("OnMouseUp", function()
UnitClick(this.unitId, arg1, this.unitMenu)
end)
end
-- Raid target icon on the top edge, on its own frame above the bars.
local RAID_ICON_TEXTURE = "Interface\\TargetingFrame\\UI-RaidTargetingIcons"
local function AddRaidIcon(f, size)
local holder = CreateFrame("Frame", nil, f)
holder:SetWidth(size)
holder:SetHeight(size)
holder:SetPoint("CENTER", f, "TOP", 0, 0)
holder:SetFrameLevel(f:GetFrameLevel() + 10)
local tex = holder:CreateTexture(nil, "OVERLAY")
tex:SetAllPoints(holder)
tex:SetTexture(RAID_ICON_TEXTURE)
holder:Hide()
f.raidIcon = holder
f.raidIconTex = tex
end
-- index 1..8 (star .. skull) or nil. The atlas is a 4 x 4 grid.
local function SetRaidIcon(f, index)
local holder = f and f.raidIcon
if not holder then return end
index = tonumber(index)
if not index or index < 1 or index > 8 then
holder:Hide()
return
end
if type(SetRaidTargetIconTexture) == "function" then
SetRaidTargetIconTexture(f.raidIconTex, index)
else
local col = math.mod(index - 1, 4)
local row = math.floor((index - 1) / 4)
f.raidIconTex:SetTexCoord(col * 0.25, (col + 1) * 0.25, row * 0.25, (row + 1) * 0.25)
end
holder:Show()
end
local function SuppressBlizzardFrame(f)
if not f then return end
f:Hide()
f:SetAlpha(0)
f:ClearAllPoints()
f:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 500, 500)
f:SetScript("OnShow", function()
this:Hide()
end)
end
function mod:HideBlizzardFrames()
SuppressBlizzardFrame(PlayerFrame)
SuppressBlizzardFrame(TargetFrame)
SuppressBlizzardFrame(ComboFrame)
SuppressBlizzardFrame(PetFrame)
SuppressBlizzardFrame(TargetofTargetFrame)
SuppressBlizzardFrame(PartyMemberFrame1)
SuppressBlizzardFrame(PartyMemberFrame2)
SuppressBlizzardFrame(PartyMemberFrame3)
SuppressBlizzardFrame(PartyMemberFrame4)
SuppressBlizzardFrame(PartyMemberFrame1PetFrame)
SuppressBlizzardFrame(PartyMemberFrame2PetFrame)
SuppressBlizzardFrame(PartyMemberFrame3PetFrame)
SuppressBlizzardFrame(PartyMemberFrame4PetFrame)
end
function mod:Create()
local root = CreateFrame("Frame", "BUI_UnitFrames", UIParent)
root:SetAllPoints(UIParent)
self.frame = root
-- Frames are built once: a style switch needs /reload.
local round = B:IsRound()
self.round = round
self:HideBlizzardFrames()
---------------------------------------------------------------------------
-- 1. Hero Frame (210 x 46)
---------------------------------------------------------------------------
local hero = CreateFrame("Frame", "BUI_HeroFrame", root)
BUI_PlayerFrame = hero
hero:SetWidth(210)
hero:SetHeight(46)
-- Round style: round panel, bars inset so they stay inside its corners.
local bigPad = FramePanel(hero, 40, 0.90)
hero.buiPad = bigPad
-- Health Bar (208 x 35) - Dominates frame
local hpBar = B:Bar(hero, nil, 0.2, 0.8, 0.2)
hpBar:SetPoint("TOPLEFT", hero, "TOPLEFT", bigPad, -bigPad)
hpBar:SetPoint("TOPRIGHT", hero, "TOPRIGHT", -bigPad, -bigPad)
hpBar:SetHeight(35)
hero.hpBar = hpBar
-- Player Name (inside Health Bar, TOPLEFT aligned)
local nameText = Font(hpBar, 11, "LEFT")
nameText:SetPoint("TOPLEFT", hpBar, "TOPLEFT", 6, round and -2 or -3)
nameText:SetWidth(110)
nameText:SetHeight(14)
nameText:SetTextColor(1, 1, 1)
hero.nameText = nameText
-- Health Text (inside Health Bar, RIGHT aligned, e.g. "270 | 100%")
local hpText = Font(hpBar, 11, "RIGHT")
hpText:SetPoint("RIGHT", hpBar, "RIGHT", -6, 0)
hpText:SetWidth(90)
hpText:SetHeight(16)
hpText:SetTextColor(1, 1, 1)
hero.hpText = hpText
-- Level badge (inside Health Bar, BOTTOMLEFT aligned)
local lvlText = Font(hpBar, 8, "LEFT")
lvlText:SetPoint("BOTTOMLEFT", hpBar, "BOTTOMLEFT", 6, round and 2 or 4)
lvlText:SetWidth(60)
lvlText:SetHeight(12)
B:Accent(lvlText, "text")
hero.lvlText = lvlText
-- Power Bar (208 x 6) Mana / Rage / Energy; thin round-capped bar in the round style
local pBar = ThinBar(hero, round and LAYOUT_BIG.powerH or 6, 0.0, 0.55, 1.0)
pBar:SetPoint("TOPLEFT", hpBar, "BOTTOMLEFT", 0, -2)
pBar:SetPoint("TOPRIGHT", hpBar, "BOTTOMRIGHT", 0, -2)
hero.pBar = pBar
local pText = Font(pBar, 8, "CENTER")
pText:SetPoint("CENTER", pBar, "CENTER", 0, 0)
-- The round power bar is too thin to carry a number.
if round then pText:Hide() end
hero.pText = pText
-- Shield Bar (absorb indicator overlay on power bar bottom)
local shBar = ThinBar(hero, 2, 0.25, 0.70, 1.00)
shBar:SetPoint("TOPLEFT", pBar, "BOTTOMLEFT", 0, -1)
shBar:SetPoint("TOPRIGHT", pBar, "BOTTOMRIGHT", 0, -1)
shBar:Hide()
hero.shBar = shBar
-- XP Bar (2px Cyber Accent at bottom)
local xpBar = ThinBar(hero, 2)
xpBar:SetPoint("TOPLEFT", pBar, "BOTTOMLEFT", 0, -1)
xpBar:SetPoint("TOPRIGHT", pBar, "BOTTOMRIGHT", 0, -1)
hero.xpBar = xpBar
-- Shield and XP share the slot: the shield draws on top while it is up.
if shBar.SetFrameLevel and xpBar.GetFrameLevel then
shBar:SetFrameLevel(xpBar:GetFrameLevel() + 1)
end
MakeUnitClickable(hero, "player", "PlayerFrameDropDown")
AddRaidIcon(hero, 18)
B:RegisterMover(hero, "hero", L["Hero Frame"], "BOTTOM", "BOTTOM", -220, 140)
self.hero = hero
---------------------------------------------------------------------------
-- 2. Target Frame (210 x 46)
---------------------------------------------------------------------------
local tgt = CreateFrame("Frame", "BUI_TargetFrame", root)
tgt:SetWidth(210)
tgt:SetHeight(46)
tgt.buiPad = FramePanel(tgt, 40, 0.90)
-- Target Health Bar (208 x 35)
local tgtHpBar = B:Bar(tgt, nil, 0.8, 0.2, 0.2)
tgtHpBar:SetPoint("TOPLEFT", tgt, "TOPLEFT", tgt.buiPad, -tgt.buiPad)
tgtHpBar:SetPoint("TOPRIGHT", tgt, "TOPRIGHT", -tgt.buiPad, -tgt.buiPad)
tgtHpBar:SetHeight(35)
tgt.hpBar = tgtHpBar
-- Target Name (inside Health Bar, TOPLEFT aligned)
local tgtNameText = Font(tgtHpBar, 11, "LEFT")
tgtNameText:SetPoint("TOPLEFT", tgtHpBar, "TOPLEFT", 6, round and -2 or -3)
tgtNameText:SetWidth(115)
tgtNameText:SetHeight(14)
tgtNameText:SetTextColor(1, 1, 1)
tgt.nameText = tgtNameText
-- Target Badge (boss/elite/enraged status inside Health Bar, BOTTOMLEFT aligned)
local badgeText = Font(tgtHpBar, 8, "LEFT")
badgeText:SetPoint("BOTTOMLEFT", tgtHpBar, "BOTTOMLEFT", 6, round and 2 or 4)
badgeText:SetWidth(100)
badgeText:SetHeight(12)
tgt.badgeText = badgeText
-- Target HP Text (inside Health Bar, RIGHT aligned, e.g. "118K | 52%")
local tgtHpText = Font(tgtHpBar, 11, "RIGHT")
tgtHpText:SetPoint("RIGHT", tgtHpBar, "RIGHT", -6, 0)
tgtHpText:SetWidth(90)
tgtHpText:SetHeight(16)
tgtHpText:SetTextColor(1, 1, 1)
tgt.hpText = tgtHpText
-- Target Power Bar (208 x 6)
local tgtPBar = ThinBar(tgt, round and LAYOUT_BIG.powerH or 6, 0.0, 0.55, 1.0)
tgtPBar:SetPoint("TOPLEFT", tgtHpBar, "BOTTOMLEFT", 0, -2)
tgtPBar:SetPoint("TOPRIGHT", tgtHpBar, "BOTTOMRIGHT", 0, -2)
tgt.pBar = tgtPBar
-- Target Debuff Bars (Stacked above Target Frame, matching center Buff Bars)
-- 16px high aura bars with 16x16 icon on left, Name on left, Tick damage in center, Time/stacks on right
local debuffBars = {}
for i = 1, MAX_TARGET_DEBUFFS do
local r = CreateFrame("Button", "BUI_TargetDebuffBar" .. i, tgt)
r:SetWidth(DEBUFF_BAR_WIDTH)
r:SetHeight(DEBUFF_BAR_HEIGHT)
r:SetPoint("BOTTOMLEFT", tgt, "TOPLEFT", 1, 4 + (i - 1) * 18)
r:EnableMouse(true)
-- Square Icon tile on the left (16x16)
local iconFrame = CreateFrame("Frame", nil, r)
iconFrame:SetWidth(DEBUFF_BAR_HEIGHT)
iconFrame:SetHeight(DEBUFF_BAR_HEIGHT)
iconFrame:SetPoint("LEFT", r, "LEFT", 0, 0)
-- Square black frame only in the sharp style.
if not round then
B:Border(iconFrame, 0, 0, 0, 1)
end
local icon = iconFrame:CreateTexture(nil, "ARTWORK")
icon:SetAllPoints(iconFrame)
icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
r.icon = icon
-- Status bar on the right of the icon
local bar = B:Bar(r, nil)
bar:ClearAllPoints()
bar:SetPoint("TOPLEFT", iconFrame, "TOPRIGHT", 2, 0)
bar:SetPoint("BOTTOMRIGHT", r, "BOTTOMRIGHT", 0, 0)
bar:EnableMouse(false)
r.bar = bar
-- Debuff Name on the left
local nameFs = Font(bar, 9, "LEFT")
nameFs:SetPoint("LEFT", bar, "LEFT", 4, 0)
nameFs:SetWidth(95)
nameFs:SetHeight(12)
r.nameFs = nameFs
-- Tick Damage in the center
local centerFs = Font(bar, 10, "CENTER")
centerFs:SetPoint("CENTER", bar, "CENTER", 0, 0)
centerFs:SetTextColor(1.0, 0.85, 0.20)
r.centerFs = centerFs
-- Time / Stacks on the right
local timeFs = Font(bar, 9, "RIGHT")
timeFs:SetPoint("RIGHT", bar, "RIGHT", -4, 0)
timeFs:SetWidth(44)
timeFs:SetHeight(12)
r.timeFs = timeFs
r.debuffIndex = i
r:SetScript("OnEnter", function()
if UnitExists("target") and this.debuffIndex then
GameTooltip:SetOwner(this, "ANCHOR_TOP")
if type(GameTooltip.SetUnitDebuff) == "function" then
GameTooltip:SetUnitDebuff("target", this.debuffIndex)
end
if this.tickDmg and this.tickDmg > 0 then
GameTooltip:AddLine(string.format(L["Tick Damage: %d"], this.tickDmg), 1.0, 0.85, 0.20)
end
GameTooltip:Show()
end
end)
r:SetScript("OnLeave", function() GameTooltip:Hide() end)
r:Hide()
debuffBars[i] = r
end
tgt.debuffBars = debuffBars
tgt.debuffs = debuffBars
MakeUnitClickable(tgt, "target", "TargetFrameDropDown")
AddRaidIcon(tgt, 18)
tgt:Hide()
B:RegisterMover(tgt, "target", "Target Frame", "BOTTOM", "BOTTOM", 220, 140)
self.target = tgt
---------------------------------------------------------------------------
-- 3. Target of Target Frame (110 x 24)
---------------------------------------------------------------------------
local tot = CreateFrame("Frame", "BUI_TargetTargetFrame", tgt)
tot:SetWidth(110)
tot:SetHeight(24)
tot:SetPoint("TOPLEFT", tgt, "TOPRIGHT", 6, 0)
tot.buiPad = FramePanel(tot, 24, 0.90)
local totHpBar = B:Bar(tot, nil, 0.8, 0.2, 0.2)
totHpBar:SetPoint("TOPLEFT", tot, "TOPLEFT", tot.buiPad, -tot.buiPad)
totHpBar:SetPoint("TOPRIGHT", tot, "TOPRIGHT", -tot.buiPad, -tot.buiPad)
totHpBar:SetHeight(17)
tot.hpBar = totHpBar
local totName = Font(totHpBar, 9, "LEFT")
totName:SetPoint("LEFT", totHpBar, "LEFT", 4, 0)
totName:SetWidth(60)
totName:SetHeight(12)
tot.nameText = totName
local totPct = Font(totHpBar, 9, "RIGHT")
totPct:SetPoint("RIGHT", totHpBar, "RIGHT", -4, 0)
totPct:SetWidth(38)
totPct:SetHeight(12)
tot.hpText = totPct
local totPBar = ThinBar(tot, 3, 0.0, 0.55, 1.0)
totPBar:SetPoint("TOPLEFT", totHpBar, "BOTTOMLEFT", 0, -1)
totPBar:SetPoint("TOPRIGHT", totHpBar, "BOTTOMRIGHT", 0, -1)
tot.pBar = totPBar
MakeUnitClickable(tot, "targettarget", nil)
tot:Hide()
self.tot = tot
---------------------------------------------------------------------------
-- 4. Pet Frame (110 x 24)
---------------------------------------------------------------------------
local pet = CreateFrame("Frame", "BUI_PetFrame", hero)
pet:SetWidth(110)
pet:SetHeight(24)
pet:SetPoint("TOPRIGHT", hero, "BOTTOMRIGHT", 0, -8)
pet.buiPad = FramePanel(pet, 24, 0.90)
local petHpBar = B:Bar(pet, nil, 0.2, 0.8, 0.2)
petHpBar:SetPoint("TOPLEFT", pet, "TOPLEFT", pet.buiPad, -pet.buiPad)
petHpBar:SetPoint("TOPRIGHT", pet, "TOPRIGHT", -pet.buiPad, -pet.buiPad)
petHpBar:SetHeight(17)
pet.hpBar = petHpBar
local petName = Font(petHpBar, 9, "LEFT")
petName:SetPoint("LEFT", petHpBar, "LEFT", 4, 0)
petName:SetWidth(60)
petName:SetHeight(12)
pet.nameText = petName
local petPct = Font(petHpBar, 9, "RIGHT")
petPct:SetPoint("RIGHT", petHpBar, "RIGHT", -4, 0)
petPct:SetWidth(38)
petPct:SetHeight(12)
pet.hpText = petPct
local petPBar = ThinBar(pet, 3, 1.0, 0.50, 0.25)
petPBar:SetPoint("TOPLEFT", petHpBar, "BOTTOMLEFT", 0, -1)
petPBar:SetPoint("TOPRIGHT", petHpBar, "BOTTOMRIGHT", 0, -1)
pet.pBar = petPBar
MakeUnitClickable(pet, "pet", "PetFrameDropDown")
pet:Hide()
self.pet = pet
---------------------------------------------------------------------------
-- 5. Encounter / Elite & Boss Frame (ENC_WIDTH x dynamic)
---------------------------------------------------------------------------
local enc = CreateFrame("Frame", "BUI_EncounterFrame", root)
enc:SetWidth(ENC_WIDTH)
enc:SetHeight(130)
FramePanel(enc, 40, 0.88)
enc.header = B:Header(enc, L["ELITES & BOSSES"], 18)
local rows = {}
for i = 1, MAX_ENCOUNTER_ROWS do
local r = CreateFrame("Button", nil, enc)
r:SetWidth(ENC_WIDTH - 8)
r:SetHeight(18)
r:SetPoint("TOPLEFT", enc, "TOPLEFT", 4, -22 - (i - 1) * 21)
local bar = B:Bar(r, nil, 0.8, 0.2, 0.2)
bar:SetAllPoints(r)
bar:EnableMouse(false)
r.bar = bar
local badgeFs = Font(bar, 9, "LEFT")
badgeFs:SetPoint("LEFT", bar, "LEFT", 3, 0)
badgeFs:SetWidth(40)
badgeFs:SetHeight(12)
r.badgeFs = badgeFs
local rHpFs = Font(bar, 9, "RIGHT")
rHpFs:SetPoint("RIGHT", bar, "RIGHT", -3, 0)
rHpFs:SetWidth(100)
rHpFs:SetHeight(12)
r.hpFs = rHpFs
local rNameFs = Font(bar, 9, "LEFT")
rNameFs:SetPoint("LEFT", badgeFs, "RIGHT", 3, 0)
rNameFs:SetPoint("RIGHT", rHpFs, "LEFT", -3, 0)
rNameFs:SetHeight(12)
r.nameFs = rNameFs
-- Hover highlight (normal layer on the bar, shown from OnEnter)
r.hl = HoverTint(bar, bar, 0.12)
r:EnableMouse(true)
r:RegisterForClicks("LeftButtonUp", "RightButtonUp")
r:SetScript("OnClick", function()
local uName = this.unitName
if uName and uName ~= "" then
ClearTarget()
TargetByName(uName, true)
if not UnitExists("target") then
TargetByName(uName, false)
end
B:Tick()
end
end)
r:SetScript("OnEnter", function()
if this.hl then this.hl:Show() end
if this.unitName then
GameTooltip:SetOwner(this, "ANCHOR_TOP")
GameTooltip:ClearLines()
GameTooltip:AddLine(this.unitName, 1, 1, 1)
if this.unitHp and this.unitHpm then
GameTooltip:AddLine(string.format(L["Health: %d / %d (%d%%)"], this.unitHp, this.unitHpm, this.unitPct or 0), 1, 0.82, 0)
end
GameTooltip:AddLine(L["Click to target"], 0, 0.9, 1)
GameTooltip:Show()
end
end)
r:SetScript("OnLeave", function()
if this.hl then this.hl:Hide() end
GameTooltip:Hide()