-
Notifications
You must be signed in to change notification settings - Fork 0
/
layout.lua
1226 lines (1096 loc) · 33.9 KB
/
layout.lua
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
--[[
* review health-tags (death)
* pet-update-fix?
* mana-color (tiny-bars)
* bigger in 10-man
* indicate hostile raidmembers
* combo-points
* fix warlock pet vehicle
* boss-hp-tags
--]]
local name, ns = ...
local oUF = ns.oUF or _G[ assert( GetAddOnMetadata(name, "X-oUF"), "X-oUF metadata missing in parent addon.")]
assert( oUF, "Unable to locate oUF." )
local LSM = LibStub("LibSharedMedia-3.0")
local _TEXTURE = LSM:Fetch("statusbar", "Perl v2")
local defaultfont = LSM:Fetch("font", "Arial Narrow")
local cbfont = LSM:Fetch("font", "Tw_Cen_MT_Bold")
local bigfont = LSM:Fetch("font", "Diablo")
local colors = setmetatable({
health = {.45, .73, .27},
power = setmetatable({
['MANA'] = {.27, .53, .73},
['RAGE'] = {.73, .27, .27},
}, {__index = oUF.colors.power}),
}, {__index = oUF.colors})
local menu = function(self)
local unit = self.unit:sub(1, -2)
local cunit = self.unit:gsub("^%l", string.upper)
if(cunit == 'Vehicle') then
cunit = 'Pet'
end
if(unit == "party" or unit == "partypet") then
ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor", 0, 0)
elseif(_G[cunit.."FrameDropDown"]) then
ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0)
end
end
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
-- AbbreviateLargeNumbers
local siValueShort = function(val)
if(val >= 1e7) then
return ("%dm"):format(round(val / 1e6))
elseif(val >= 1e6) then
return ("%sm"):format(round(val / 1e6, 1))
elseif(val >= 1e4) then
return ("%dk"):format(round(val / 1e3))
elseif(val >= 1e3) then
return ("%sk"):format(round(val / 1e3, 1))
else
return val
end
end
local siValue = function(val)
if(val >= 1e7) then
return ("%dm"):format(round(val / 1e6))
elseif(val >= 1e6) then
return ("%sm"):format(round(val / 1e6, 1))
elseif(val >= 1e5) then
return ("%dk"):format(round(val / 1e3))
else
return val
end
end
local function makeHealthTag(name, func)
oUF.Tags.Methods[name] = func
oUF.Tags.Events[name] = oUF.Tags.Events.missinghp
end
oUF.Tags.Methods["profalbert:dead"] = function(u)
if UnitHasIncomingResurrection(u) then
if unit == "player" then
return string.format('Rez %s', ResurrectGetOfferer())
end
return 'Rezzing'
elseif(UnitIsDead(u)) then
return 'Dead'
elseif(UnitIsGhost(u)) then
return 'Ghost'
end
end
oUF.Tags.Events["profalbert:dead"] = "UNIT_HEALTH INCOMING_RESURRECT_CHANGED"
local function healthOrAFK(unit, orig)
if(not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return end
local min, max = UnitHealth(unit), UnitHealthMax(unit)
if UnitIsAFK(unit) then
if min == max then
return AFK
else
return ("|cff000000%s/%s|r"):format(siValue(min), siValue(max))
end
else
return ("%s/%s"):format(siValue(min), siValue(max))
end
end
makeHealthTag("profalbert:Health", healthOrAFK)
local function missinghp(unit)
if(not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return end
local current = UnitHealthMax(unit) - UnitHealth(unit)
if(current > 0) then
return ("|cffff8080-%s|r"):format(siValue(current))
end
end
makeHealthTag("profalbert:missinghp", missinghp)
local function perhp(unit)
if(not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return end
local val = UnitHealth(unit) / UnitHealthMax(unit) * 100
return ("|cffcc3333%s%%|r"):format(round(val, 1))
end
makeHealthTag("profalbert:HealthWithPer", function(unit)
if(not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return end
local min, max = UnitHealth(unit), UnitHealthMax(unit)
if UnitIsAFK(unit) and min == max then
return AFK
else
return ("%s %s"):format(healthOrAFK(unit),perhp(unit))
end
end)
makeHealthTag("profalbert:curhp", function(unit)
if(not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return end
return siValue(UnitHealth(unit))
end)
makeHealthTag("profalbert:maxhp", function(unit)
if(not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return end
return siValue(UnitHealthMax(unit))
end)
makeHealthTag("profalbert:perhp", perhp)
local function hpshort(unit)
if(not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return end
return ("%s/%s"):format(siValueShort(UnitHealth(unit)), siValueShort(UnitHealthMax(unit)))
end
makeHealthTag("profalbert:hpshort", hpshort)
makeHealthTag("profalbert:raidhp", function(unit, origUnit)
if(not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return end
if origUnit then
return hpshort(unit)
else
local min, max = UnitHealth(unit), UnitHealthMax(unit)
if UnitIsAFK(unit) then
if min == max then
return AFK
else
return ("|cff000000%s|r"):format(siValue(min - max))
end
else
return missinghp(unit)
end
end
end)
oUF.Tags.Methods['profalbert:power'] = function(unit)
local min, max = UnitPower(unit), UnitPowerMax(unit)
--if(min == 0 or max == 0 or not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return end
return ("%s/%s"):format(min, max)
--return siValue(min) .. '/' .. siValue(max)
end
oUF.Tags.Events['profalbert:power'] = oUF.Tags.Events.missingpp
oUF.Tags.Methods['profalbert:difficulty'] = function(u)
local l = UnitLevel(u)
return Hex(GetQuestDifficultyColor((l > 0) and l or 99))
end
local function hex(color)
if not color then return "|cffffffff" end
local r = math.floor(color.r * 255)
local g = math.floor(color.g * 255)
local b = math.floor(color.b * 255)
return("|cff%02x%02x%02x"):format(r,g,b)
end
local function raidcolor(unit)
local color = { r = 1, g = 1, b = 1, }
if UnitIsPlayer(unit) then
color = RAID_CLASS_COLORS[select(2, UnitClass(unit))] or white
else
color = FACTION_BAR_COLORS[UnitReaction("player", unit)]
end
return hex(color)
end
oUF.Tags.Methods["profalbert:raidcolor"] = raidcolor
oUF.Tags.Methods["profalbert:name"] = function(unit, originalUnit)
if not originalUnit then
return UnitName(unit)
end
if unit == "vehicle" or unit:match("pet") then
return ("%s%s|r's %s%s"):format(raidcolor(originalUnit) or "", UnitName(originalUnit) or "", raidcolor(unit) or "", UnitName(unit) or "")
else
return UnitName(unit)
end
end
oUF.Tags.Events["profalbert:name"] = "UNIT_NAME_UPDATE UNIT_ENTERING_VEHICLE UNIT_ENTERED_VEHICLE UNIT_EXITING_VEHICLE UNIT_EXITED_VEHICLE PARTY_MEMBERS_CHANGED"
local PreUpdateHealth = function(health, unit)
health.colorReaction = not UnitIsPlayer(unit) and not UnitIsUnit(unit, "pet") and not UnitIsUnit(unit, "vehicle")
end
local PostUpdateHealth = function(health, unit, min, max)
local self = health:GetParent()
if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then
health:SetStatusBarColor(.3, .3, .3)
end
if(UnitIsDead(unit)) then
health:SetValue(0)
elseif(UnitIsGhost(unit)) then
health:SetValue(0)
end
end
local PostUpdatePower = function(power, unit,min, max)
if(UnitIsDead(unit) or UnitIsGhost(unit)) then
power:SetValue(0)
end
end
local backdrop = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
tile = true,
tileSize = 16,
insets = {
left = -1.5,
right = -1.5,
top = -1.5,
bottom = -1.5
},
}
local function getBoundedHeight(height)
if height < 11 then
return 11
elseif height > 13 then
return 13
else
return height
end
end
local function getFontStringHeight(parent)
if parent.GetHeight then
local height = parent:GetHeight()
return getBoundedHeight(height)
else
return 10
end
end
local function getFontString(parent, font)
local fs = parent:CreateFontString(nil, "OVERLAY")
local height = getFontStringHeight(parent)
fs:SetFont(font or defaultfont, height)
fs:SetShadowColor(0,0,0)
fs:SetShadowOffset(0.8, -0.8)
fs:SetTextColor(1,1,1)
fs:SetJustifyH("LEFT")
fs:SetWordWrap(false)
return fs
end
local function applyPoints(self, points)
if not points then return end
for _, v in ipairs(points) do
self:SetPoint(unpack(v))
end
end
local function makeCommon(self, settings)
self.menu = menu
self:SetScript("OnEnter", UnitFrame_OnEnter)
self:SetScript("OnLeave", UnitFrame_OnLeave)
self:RegisterForClicks"anyup"
self:SetAttribute("*type2", "menu")
self:SetBackdrop(backdrop)
self:SetBackdropColor(0, 0, 0, 1)
self:SetBackdropBorderColor(.3, .3, .3, 1)
self:SetSize(settings["initial-width"] or 240, settings["initial-height"] or 60)
end
local function makeRaidIcons(self)
local icon = self:CreateTexture(nil, "OVERLAY")
icon:SetHeight(16)
icon:SetWidth(16)
icon:SetPoint("CENTER", self, "TOP")
self.RaidIcon = icon
end
local function makeBlankBar(self, height)
local bb = CreateFrame("StatusBar", nil, self)
bb:SetHeight(height)
bb:SetPoint("TOPLEFT")
bb:SetPoint("TOPRIGHT")
self.Info = bb
return bb
end
local function makeHealComm(self)
self.HealCommBar = CreateFrame('StatusBar', nil, self.Health)
self.HealCommBar:SetHeight(0)
self.HealCommBar:SetWidth(0)
self.HealCommBar:SetStatusBarTexture(self.Health:GetStatusBarTexture():GetTexture())
self.HealCommBar:SetStatusBarColor(0, 1, 0, 0.5)
self.HealCommBar:SetPoint('LEFT', self.Health, 'LEFT')
-- optional flag to show overhealing
self.allowHealCommOverflow = true
end
local function makeAbsorbBar(self, height, anchors)
local Absorb = CreateFrame("StatusBar", nil, self)
Absorb:SetHeight(height or 20)
Absorb:SetStatusBarTexture(_TEXTURE)
Absorb:SetPoint("LEFT")
Absorb:SetPoint("RIGHT")
Absorb:SetPoint("BOTTOM", self, "TOP")
Absorb:SetStatusBarColor(.3, .3, .3)
local Value = getFontString(Absorb)
Value:SetPoint("CENTER", Absorb, "CENTER")
Absorb.Value = Value
self.Absorb = Absorb
end
local function makeHealthBar(self, height, anchors) -- above, portrait, right)
local Health = CreateFrame("StatusBar", nil, self)
Health:SetHeight(height or 20)
Health:SetStatusBarTexture(_TEXTURE)
Health:SetPoint("TOP")
--Health:SetPoint("BOTTOM")
Health:SetPoint("LEFT")
Health:SetPoint("RIGHT")
applyPoints(Health, anchors)
Health.frequentUpdates = true
Health.colorDisconnected = true
Health.colorTapping = true
Health.colorHappiness = true
Health.colorSmooth = true
-- Health.colorReaction = true -- does not behave as desired
Health.PostUpdate = PostUpdateHealth
Health.PreUpdate = PreUpdateHealth
Health.colorTapping = true
Health.colorDisconnected = true
self.Health = Health
-- Health bar background
local HealthBackground = Health:CreateTexture(nil, "BORDER")
HealthBackground:SetAllPoints(Health)
HealthBackground:SetAlpha(.5)
HealthBackground:SetTexture(_TEXTURE)
Health.bg = HealthBackground
return Health
end
local function makeHealthValue(self, tag, point)
local HealthPoints = getFontString(self.Health)
if point then
HealthPoints:SetPoint(unpack(point))
else
HealthPoints:SetPoint("CENTER")
end
HealthPoints.frequentUpdates = true
self:Tag(HealthPoints, tag)
self.Health.value = HealthPoints
end
local function doBanzai(self, unit, aggro)
if aggro == 1 then
self.BanzaiFrame:Show()
else
self.BanzaiFrame:Hide()
end
end
local function makeBanzai(self)
local frame = CreateFrame('Frame', nil, self)
local border = LSM:Fetch("border", "Tooltip enlarged")
local backdrop = {
edgeFile = border,
edgeSize = 10
}
local height = math.ceil(self:GetHeight() / 10)
local diff = height or 5
frame:SetPoint("TOPLEFT", self, "TOPLEFT", -diff, diff)
frame:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", diff, -diff)
frame:SetBackdrop(backdrop)
frame:SetBackdropBorderColor(1, 0, 0)
frame:SetFrameLevel(self:GetFrameLevel() - 1)
frame.SetVertexColor = frame.SetBackdropBorderColor
--frame:Hide()
self.Threat = frame
--self.BanzaiFrame = frame
--self.ignoreBanzai = false
--self.Banzai = doBanzai
end
local function makeLeader(self)
local Leader = self:CreateTexture(nil, "OVERLAY")
Leader:SetSize(16, 16)
Leader:SetPoint("TOPLEFT", self, "TOPLEFT", -8, 8)
self.Leader = Leader
return Leader
end
local function makeRange(self)
self.SpellRange = {
insideAlpha = 1,
outsideAlpha = 0.6,
}
end
local function makeResting(self)
local resting = self.Health:CreateTexture(nil, "OVERLAY") -- use self.Health so that it comes before the portrait
resting:SetHeight(16)
resting:SetWidth(16)
resting:SetPoint("BOTTOMLEFT", self, -8, -8)
resting:SetTexture("Interface\\CharacterFrame\\UI-StateIcon")
resting:SetTexCoord(0.09, 0.43, 0.08, 0.42)
self.Resting = resting
end
local function Portrait(self)
local portrait = CreateFrame("PlayerModel", nil, self)
portrait:SetBackdropColor(0, 0, 0, .7)
portrait:SetWidth(34)
portrait:SetHeight(34)
if self.unit == "target" then
portrait:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT")
else
portrait:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT")
end
local fallback = portrait:CreateTexture()
fallback:SetAllPoints(portrait)
portrait.fallback = fallback
self.Portrait2 = portrait
return portrait
end
local DoPower = function(self, anchors)
-- Power bar
local Power = CreateFrame("StatusBar", nil, self)
Power:SetHeight(12)
Power:SetStatusBarTexture(_TEXTURE)
Power:SetPoint("LEFT")
Power:SetPoint("RIGHT")
Power:SetPoint("BOTTOM")
applyPoints(Power, anchors)
Power.colorPower = true
Power.frequentUpdates = true
self.Power = Power
-- Power bar background
local PowerBackground = Power:CreateTexture(nil, "BORDER")
PowerBackground:SetAllPoints(Power)
PowerBackground:SetAlpha(.5)
PowerBackground:SetTexture(_TEXTURE)
Power.bg = PowerBackground
return Power
end
local function makePowerValue(self, tag)
local PowerPoints = getFontString(self.Power)
PowerPoints:SetPoint("CENTER")
PowerPoints:SetJustifyH("CENTER")
self:Tag(PowerPoints, tag or '[profalbert:power]')
self.Power.value = PowerPoints
self.Power.PostUpdate = PostUpdatePower
end
local function makePortrait(self)
local portrait = Portrait(self)
if self.unit == "target" then -- do it on the right for the target
self.Health:SetPoint("RIGHT", portrait, "LEFT")
self.Power:SetPoint("RIGHT", portrait, "LEFT")
else
self.Health:SetPoint("LEFT", portrait, "RIGHT")
self.Power:SetPoint("LEFT", portrait, "RIGHT")
end
end
local function makeInfoText(self, tag)
local Name = getFontString(self.Info)
Name:SetPoint("LEFT", self.Info, "LEFT")
Name:SetPoint("RIGHT", self.Info, "RIGHT")
self:Tag(Name, tag ) -- '[profalbert:difficulty][level][shortclassification] [raidcolor][name]'
self.Name = Name
end
local hptags = {
player = '[profalbert:dead][profalbert:Health]',
pet = "[profalbert:dead][profalbert:hpshort]",
target = '[profalbert:dead][offline][profalbert:HealthWithPer]',
targettarget = "[profalbert:dead][profalbert:curhp] [profalbert:perhp]",
focus = '[profalbert:dead][offline][profalbert:hpshort]',
focustarget = "[profalbert:dead][profalbert:curhp] [profalbert:perhp]",
party = '[profalbert:dead][offline][profalbert:Health] [profalbert:missinghp]',
partytarget = "[dead][profalbert:curhp] [profalbert:perhp]",
partypet = '[profalbert:dead][profalbert:Health]',
raid = "[profalbert:dead][offline][profalbert:raidhp]",
boss = "[profalbert:dead][profalbert:HealthWithPer]",
maintank = "[profalbert:dead][offline][profalbert:curhp] [profalbert:missinghp]",
}
hptags.vehicle = hptags.pet
do
local function getTag(self, key)
local key2 = key:gsub("%d+","")
return rawget(self, key2) or "[profalbert:Health]"
end
setmetatable(hptags, { __index = getTag, } )
end
local function Shared(self, settings, unit, isSingle)
local unit = unit or self.unit
makeCommon(self, settings)
makeRaidIcons(self)
self.ignoreBanzai = true
local bbheight = settings["bb-height"] or settings["initial-height"] - settings["hp-height"] - settings["pp-height"]
local bb = makeBlankBar(self, bbheight)
if settings["info-tag"] then
makeInfoText(self, settings["info-tag"])
end
local anchors = {
{ "TOP", bb, "BOTTOM", },
}
local Health = makeHealthBar(self, settings["hp-height"] or 25, anchors)
if unit then
makeHealthValue(self, hptags[unit], settings["hp-point"])
end
anchors[1] = { "TOP", Health, "BOTTOM", }
local Power = DoPower(self, anchors)
if settings["pp-tag"] then
makePowerValue(self, settings["pp-tag"])
end
end
--[[local Shared = function(self, settings)
makeCommon(self, settings)
local bb = makeBlankBar(self)
local Health = makeHealthBar(self)
makeLeader(self)
end--]]
--[[local function makeHealthOnly(self)
makeCommon(self)
local bb = makeBlankBar(self)
local points = {
{ "TOP", bb, "BOTTOM", },
{ "BOTTOM", },
}
local Health = makeHealthBar(self, points)
end--]]
local makeBuffs = function(self, settings)
-- Buffs
local Buffs = CreateFrame("Frame", nil, self)
Buffs:SetPoint'LEFT'
Buffs:SetPoint'RIGHT'
Buffs:SetHeight(16)
Buffs.size = 16
for k,v in pairs(settings) do
Buffs[k] = v
end
self.Buffs = Buffs
return Buffs
end
local function makeDebuffs(self, settings)
-- Debuffs
local Debuffs = CreateFrame("Frame", nil, self)
--Debuffs:SetPoint'LEFT'
--Debuffs:SetPoint'RIGHT'
Debuffs:SetPoint("TOPLEFT", self, "TOPRIGHT",1.5,0)
Debuffs.initialAnchor = "TOPLEFT"
Debuffs["growth-x"] = "RIGHT"
Debuffs["growth-y"] = "DOWN"
Debuffs:SetHeight(settings.size * settings.y)
Debuffs:SetWidth(settings.size * settings.x)
Debuffs.size = settings.size
Debuffs.showDebuffType = true
Debuffs.num = settings.x * settings.y
self.Debuffs = Debuffs
end
local big = {
["initial-width"] = 140,
["initial-height"] = 48,
["hp-height"] = 22,
["pp-height"] = 12,
["pp-tag"] = '[profalbert:power]',
["info-tag"] = '[profalbert:difficulty][level][shortclassification] [profalbert:raidcolor][profalbert:name]',
["buffs"] = {
num = 6,
initialAnchor = "TOPLEFT",
["growth-y"] = "DOWN",
["growth-x"] = "RIGHT",
size = 16,
},
["debuffs"] = {
x = 2,
y = 3,
size = 20,
},
}
local small = {
["initial-width"] = 80,
["initial-height"] = 30,
["hp-height"] = 16,
["pp-height"] = 4,
["hp-point"] = { "CENTER" },
["info-tag"] = '[profalbert:raidcolor][profalbert:name]',
}
local focus = {
["initial-width"] = 90,
["initial-height"] = 35,
["hp-height"] = 18,
["pp-height"] = 4,
["hp-point"] = { "CENTER" },
["info-tag"] = '[profalbert:difficulty][level][shortclassification] [profalbert:raidcolor][profalbert:name]',
["buffs"] = {
num = 4,
initialAnchor = "TOPLEFT",
["growth-y"] = "DOWN",
["growth-x"] = "RIGHT",
size = 12,
},
["debuffs"] = {
x = 1,
y = 3,
size = 12,
},
}
local raid = {
["initial-width"] = 60,
["initial-height"] = 30,
["hp-height"] = 18,
["pp-height"] = 3,
["info-tag"] = small["info-tag"],
["debuffs"] = {
x = 1,
y = 3,
size = 10,
},
}
local function makeEarthShieldIcon(self)
local spellName, _, texture = GetSpellInfo(974)
local shieldFrame = CreateFrame('Frame', nil, self)
shieldFrame:SetHeight(10)
shieldFrame:SetWidth(10)
shieldFrame:SetPoint("LEFT", self, "LEFT", -5, 0)
local shieldIcon = shieldFrame:CreateTexture(nil, "OVERLAY")
shieldIcon:SetTexture(texture)
shieldIcon:SetAllPoints(shieldFrame)
shieldIcon:Hide()
shieldFrame:RegisterEvent("UNIT_AURA")
shieldFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
shieldFrame:SetScript("OnEvent", function(self)
local unit = self:GetParent().unit
if unit and UnitAura(self:GetParent().unit, spellName) then
shieldIcon:Show()
else
shieldIcon:Hide()
end
end)
end
local makePetTTL
do
local function updatePetFrame(self)
local time = GetPetTimeRemaining()
local ttl = self.ttl
if not time then
ttl:SetText("")
self:Hide()
else
if time > 1000000 then
ttl:SetText("")
return
elseif time > 20000 then
ttl:SetTextColor(0, 1, 0) -- green
elseif time > 10000 then
ttl:SetTextColor(1, 1, 0) -- yellow
else
ttl:SetTextColor(1, 0, 0) -- red
end
ttl:SetText(("%.1f"):format(time/1000))
end
end
local function onPetEvent(self)
if GetPetTimeRemaining() then
self:Show()
else
self:Hide()
end
end
function makePetTTL(self)
local ttl = getFontString(self)
ttl:SetPoint("BOTTOM", self, "TOP")
local petupdateFrame = CreateFrame("Frame")
petupdateFrame:Hide()
petupdateFrame:SetScript("OnUpdate", updatePetFrame)
petupdateFrame:RegisterEvent("UNIT_PET")
petupdateFrame:SetScript("OnEvent", onPetEvent)
petupdateFrame.ttl = ttl
end
end
local function makeMasterlooter(self)
local masterlooter = self:CreateTexture(nil, "OVERLAY")
masterlooter:SetHeight(16)
masterlooter:SetWidth(16)
masterlooter:SetPoint("TOPRIGHT", self, "TOPRIGHT", 8, 8)
self.MasterLooter = masterlooter
end
-- lfd-role, raid-targets, readycheck
local function makeLFDRole(self)
local lfdrole = self.Health:CreateTexture(nil, "OVERLAY")
lfdrole:SetHeight(16)
lfdrole:SetWidth(16)
lfdrole:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", -8, -8)
self.LFDRole = lfdrole
end
local function makeReadyCheck(self)
local readycheck = self.Health:CreateTexture(nil, "OVERLAY")
readycheck:SetHeight(16)
readycheck:SetWidth(16)
readycheck:SetPoint("TOPLEFT", self, "RIGHT", -8, 8)
self.ReadyCheck = readycheck
end
local _, playerClass = UnitClass("player")
local function makeDebuffHighlighting(self)
self.DebuffHighlightBackdrop = true -- oUF_DebuffHighlight Support, using the backdrop
local unfiltered = (playerClass == "ROGUE" or playerClass == "WARRIOR")
self.DebuffHighlightFilter = not unfiltered -- only show debuffs I can cure, if I can cure any
end
local function makeQuestIcon(self)
local frame = CreateFrame('Frame', nil, self)
local icon = frame:CreateTexture(nil, "OVERLAY")
icon:SetTexture[[Interface\TargetingFrame\PortraitQuestBadge]]
icon:SetAllPoints(frame)
local size = 16 -- min(self:GetHeight(), self:GetWidth()) / 2
frame:SetWidth(size)
frame:SetHeight(size)
frame:SetPoint("RIGHT", self, "TOPRIGHT")
frame:SetFrameLevel(self:GetFrameLevel() + 1)
frame:Hide()
self.QuestIcon = frame
end
local function makeResComm(self)
local frame = CreateFrame('Frame', nil, self)
local icon = frame:CreateTexture(nil, "OVERLAY")
icon:SetTexture[[Interface\RaidFrame\Raid-Icon-Rez]]
icon:SetAllPoints(frame)
local size = min(self:GetHeight(), self:GetWidth()) / 2
frame:SetWidth(size)
frame:SetHeight(size)
frame:SetPoint("CENTER", self.Health, "CENTER")
frame:SetFrameLevel(self:GetFrameLevel() + 1)
frame:Hide()
self.ResurrectIcon = frame
end
local function makePhaseIcon(self)
local frame = CreateFrame('Frame', nil, self)
local icon = frame:CreateTexture(nil, "OVERLAY")
icon:SetTexture[[Interface\TargetingFrame\UI-PhasingIcon]]
icon:SetAllPoints(frame)
local size = min(self:GetHeight(), self:GetWidth()) / 2
frame:SetWidth(size)
frame:SetHeight(size)
frame:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 5, -5)
frame:SetFrameLevel(self:GetFrameLevel() + 1)
frame:Hide()
self.PhaseIcon = frame
-- forcing updates as UNIT_PHASE is not always fired correctly
local helperFrame = CreateFrame('Frame')
helperFrame:SetScript("OnUpdate", function()
if not UnitExists(self.unit) or not self:IsShown() then
frame:Hide()
return
end
frame:ForceUpdate()
end)
end
local function makeBackground(self)
local wbBackground = self:CreateTexture(nil, "BORDER")
wbBackground:SetAllPoints(self)
wbBackground:SetAlpha(.5)
wbBackground:SetTexture(_TEXTURE)
self.bg = wbBackground
end
local class = select(2, UnitClass('player'))
local function makeClassSpecific(self)
if class == "WARLOCK" then
-- Warlock Spec Bars
if select(2, UnitClass("player")) == "WARLOCK" then
local wb = CreateFrame("Frame", "TukuiWarlockSpecBars", self)
wb:SetHeight(8)
wb:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 4)
wb:SetWidth(self:GetWidth())
wb:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 0, 4)
wb[1] = CreateFrame("StatusBar", "TukuiWarlockSpecBars1", wb)
wb[1]:SetStatusBarTexture(_TEXTURE)
makeBackground(wb[1])
wb[1]:SetPoint("LEFT", wb, "LEFT", 0, 0)
wb[1]:SetPoint("BOTTOMLEFT", wb, "BOTTOMLEFT")
wb[1]:SetPoint("TOPLEFT", wb, "TOPLEFT")
wb[1]:SetWidth(self:GetWidth() / 4)
for i = 2, 4 do
wb[i] = CreateFrame("StatusBar", "TukuiWarlockSpecBars"..i, wb)
wb[i]:SetStatusBarTexture(_TEXTURE)
wb[i]:SetPoint("TOPLEFT", wb[i-1], "TOPRIGHT", 1, 0)
wb[i]:SetPoint("BOTTOMLEFT", wb[i-1], "BOTTOMRIGHT", 1, 0)
makeBackground(wb[i])
end
self.WarlockSpecBars = wb
end
end
end
local function makeComboPoints(self)
if class=="DRUID" or class=="ROGUE" then
-- Druid/rogue combo points
local cpoints = {}
for i = 1, MAX_COMBO_POINTS do
cpoints[i] = self.Power:CreateTexture(nil, 'OVERLAY')
cpoints[i]:SetSize(15,19)
end
cpoints[3]:SetPoint("TOP", self, "BOTTOM", 0, -1)
cpoints[2]:SetPoint("RIGHT", cpoints[3], 'LEFT', -10)
cpoints[1]:SetPoint("RIGHT", cpoints[2], 'LEFT', -10)
cpoints[4]:SetPoint("LEFT", cpoints[3], 'RIGHT', 10)
cpoints[5]:SetPoint("LEFT", cpoints[4], 'RIGHT', 10)
self.CPoints = cpoints
end
end
local UnitSpecific = {
target = function(self, ...)
local settings = CopyTable(big)
settings["hp-point"] = { "RIGHT" },
Shared(self, settings, ...)
makePortrait(self)
local buffs = makeBuffs(self, settings.buffs)
buffs:SetPoint("TOP", self, "BOTTOM")
makeDebuffs(self, settings.debuffs)
makeComboPoints(self)
makePhaseIcon(self)
makeQuestIcon(self)
end,
targettarget = function(self, ...)
local settings = CopyTable(small)
settings["hp-point"] = { "RIGHT", }
Shared(self, settings, ...)
--DoAuras(self)
makePhaseIcon(self)
end,
player = function(self, ...)
local settings = CopyTable(big)
settings["hp-point"] = nil
Shared(self, settings, ...)
--[[self.Health.value:ClearAllPoints()
self.Health.value:SetPoint("RIGHT")--]]
makePortrait(self)
makeResting(self)
makeLeader(self)
makeMasterlooter(self)
makeLFDRole(self)
makeReadyCheck(self)
makeDebuffHighlighting(self)
makeBanzai(self)
makeHealComm(self)
makeResComm(self)
makeClassSpecific(self)
makeComboPoints(self)
makeAbsorbBar(self)
RuneFrame:ClearAllPoints()
RuneFrame:SetPoint("BOTTOM", self, "TOP", 0, 5)
--DoPower(self)
-- self:RegisterEvent("PLAYER_UPDATE_RESTING", PLAYER_UPDATE_RESTING)
end,
focus = function(self, ...)
Shared(self, focus, ...)
makeRange(self)
local buffs = makeBuffs(self, focus.buffs)
buffs:SetPoint("TOP", self, "BOTTOM")
makeDebuffs(self, focus.debuffs)
makeDebuffHighlighting(self)
end,
focustarget = function(self, ...)
local settings = CopyTable(small)
settings["hp-point"] = { "RIGHT", }
Shared(self, settings, ...)
end,
party = function(self, ...)
Shared(self, big, ...)
makePortrait(self)
makeLeader(self)
makeRange(self)
makeMasterlooter(self)
makeLFDRole(self)
makeDebuffs(self, big.debuffs)
makeDebuffHighlighting(self)
makeBanzai(self)
makeHealComm(self)
makeResComm(self)
makePhaseIcon(self)
makeQuestIcon(self)
end,
pet = function(self, ...)
local settings = CopyTable(small)
Shared(self, settings, ...)
makeDebuffHighlighting(self)
makeBanzai(self)
makePetTTL(self)
makeHealComm(self)
makePhaseIcon(self)
end,
raid = function(self, ...)
Shared(self, raid, ...)
self.Health.colorReaction = true
makeLeader(self)
makeRange(self)
makeEarthShieldIcon(self)
makeMasterlooter(self)
makeReadyCheck(self)
makeDebuffs(self, raid.debuffs)
makeDebuffHighlighting(self)
makeBanzai(self)
makeHealComm(self)
makeResComm(self)
makeLFDRole(self)
makePhaseIcon(self)
end,
maintank = function(self, ...)
local settings = CopyTable(small)
settings["hp-point"] = { "RIGHT", }