-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame.lua
1148 lines (946 loc) · 36.1 KB
/
frame.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
local addonName, ns = ...
local LSM = LibStub("LibSharedMedia-3.0")
LSM:Register("statusbar", "Gradient", [[Interface\AddOns\NugHealth\gradient.tga]])
LSM:Register("font", "OpenSans Bold", [[Interface\AddOns\NugHealth\OpenSans-Bold.ttf]], GetLocale() ~= "enUS" and 15)
local pmult = 1
local function pixelperfect(size)
return floor(size/pmult + 0.5)*pmult
end
local FRAMELEVEL = {
BASEFRAME = 0,
HEALTH = 1,
POWER = 1,
BORDER = 2,
BAR = 5,
TEXT = 3,
}
local MakeBorder = function(self, tex, left, right, top, bottom, drawLayer, level)
local t = self:CreateTexture(nil, drawLayer, nil, level)
t:SetTexture(tex)
t:SetPoint("TOPLEFT", self, "TOPLEFT", left, -top)
t:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -right, bottom)
return t
end
local CompositeBorder_Set = function(self, left, right, top, bottom)
local frame = self[5]
local ttop = self[1]
ttop:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, top)
ttop:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", right, 0)
local tright = self[2]
tright:SetPoint("TOPRIGHT", frame, "TOPRIGHT", right, 0)
tright:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT", 0, -bottom)
local tbot = self[3]
tbot:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, -bottom)
tbot:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", -left, 0)
local tleft = self[4]
tleft:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", -left, 0)
tleft:SetPoint("TOPRIGHT", frame, "TOPLEFT", 0, top)
end
local MakeCompositeBorder = function(frame, tex, left, right, top, bottom, drawLayer, level)
local ttop = frame:CreateTexture(nil, drawLayer, nil, level)
ttop:SetTexture(tex)
ttop:SetVertexColor(0,0,0,1)
local tright = frame:CreateTexture(nil, drawLayer, nil, level)
tright:SetTexture(tex)
tright:SetVertexColor(0,0,0,1)
local tbot = frame:CreateTexture(nil, drawLayer, nil, level)
tbot:SetTexture(tex)
tbot:SetVertexColor(0,0,0,1)
local tleft = frame:CreateTexture(nil, drawLayer, nil, level)
tleft:SetTexture(tex)
tleft:SetVertexColor(0,0,0,1)
local border = { ttop, tright, tbot, tleft, frame }
border.parent = frame
border.Set = CompositeBorder_Set
border:Set(left, right, top, bottom)
return border
end
----------------
-- HEAL ABSORB
----------------
local HealAbsorbUpdatePositionVertical = function(self, p, health, parent)
local frameLength = parent.frameLength
self:SetHeight(p*frameLength)
local offset = (health-p)*frameLength
self:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", 0, offset)
self:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", 0, offset)
end
local HealAbsorbUpdatePositionHorizontal = function(self, p, health, parent)
local frameLength = parent.frameLength
self:SetWidth(p*frameLength)
local offset = (health-p)*frameLength
self:SetPoint("TOPLEFT", parent, "TOPLEFT", offset, 0)
self:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", offset, 0)
end
local HealAbsorbSetValue = function(self, p, health)
if p < 0.005 then
self:Hide()
return
end
local parent = self.parent
if p > health then
p = health
end
self:Show()
self:UpdatePosition(p, health, parent)
end
local function CreateHealAbsorb(hp)
local healAbsorb = hp:CreateTexture(nil, "ARTWORK", nil, -5)
healAbsorb:SetHorizTile(true)
healAbsorb:SetVertTile(true)
healAbsorb:SetTexture("Interface\\AddOns\\NugHealth\\shieldtex", "REPEAT", "REPEAT")
healAbsorb:SetVertexColor(0.5,0.1,0.1, 0.65)
healAbsorb:SetBlendMode("ADD")
healAbsorb.UpdatePositionVertical = HealAbsorbUpdatePositionVertical
healAbsorb.UpdatePositionHorizontal = HealAbsorbUpdatePositionHorizontal
healAbsorb.UpdatePosition = HealAbsorbUpdatePositionVertical
healAbsorb.SetValue = HealAbsorbSetValue
return healAbsorb
end
--------------------
-- ABSORB BAR
--------------------
local AbsorbUpdatePositionVertical = function(self, p, health, parent)
local frameLength = parent.frameLength
self:SetHeight(p*frameLength)
local offset = health*frameLength
self:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", 0, offset)
self:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", 0, offset)
end
local AbsorbUpdatePositionHorizontal = function(self, p, health, parent)
local frameLength = parent.frameLength
self:SetWidth(p*frameLength)
local offset = health*frameLength
self:SetPoint("TOPLEFT", parent, "TOPLEFT", offset, 0)
self:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", offset, 0)
end
local AbsorbSetValue = function(self, p, health)
if p + health > 1 then
p = 1 - health
end
if p < 0.005 then
self:Hide()
return
end
local parent = self.parent
self:Show()
self:UpdatePosition(p, health, parent)
end
local function CreateAbsorbBar(hp)
local absorb = hp:CreateTexture(nil, "ARTWORK", nil, -5)
absorb:SetHorizTile(true)
absorb:SetVertTile(true)
absorb:SetTexture("Interface\\AddOns\\NugHealth\\shieldtex", "REPEAT", "REPEAT")
absorb:SetVertexColor(0,0,0, 0.65)
-- absorb:SetBlendMode("ADD")
absorb.UpdatePositionVertical = AbsorbUpdatePositionVertical
absorb.UpdatePositionHorizontal = AbsorbUpdatePositionHorizontal
absorb.UpdatePosition = AbsorbUpdatePositionVertical
absorb.SetValue = AbsorbSetValue
return absorb
end
--------------------
-- INCOMING HEAL
--------------------
local function CreateIncominHealBar(hp)
local hpi = hp:CreateTexture(nil, "ARTWORK", nil, -5)
-- hpi:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
hpi:SetTexture("Interface\\BUTTONS\\WHITE8X8")
hpi:SetVertexColor(0,0,0, 0.5)
hpi.UpdatePositionVertical = AbsorbUpdatePositionVertical
hpi.UpdatePositionHorizontal = AbsorbUpdatePositionHorizontal
hpi.UpdatePosition = AbsorbUpdatePositionVertical
hpi.SetValue = AbsorbSetValue
return hpi
end
local AlignAbsorbVertical = function(self, absorb_height, missing_health_height)
self:SetHeight(absorb_height)
if absorb_height >= missing_health_height then
self:SetPoint("TOPLEFT", self:GetParent(), "TOPLEFT", -3 ,0)
else
self:SetPoint("TOPLEFT", self:GetParent(), "TOPLEFT", -3, -(missing_health_height - absorb_height))
end
end
local AlignAbsorbHorizontal = function(self, absorb_height, missing_health_height)
self:SetWidth(absorb_height)
if absorb_height >= missing_health_height then
self:SetPoint("BOTTOMRIGHT", self:GetParent(), "BOTTOMRIGHT", 0 ,-3)
else
self:SetPoint("BOTTOMRIGHT", self:GetParent(), "BOTTOMRIGHT", -(missing_health_height - absorb_height), -3)
end
end
local CreateAbsorbSideBar_SetValue = function(self, p, h)
if p > 1 then p = 1 end
if p < 0 then p = 0 end
if p <= 0.015 then self:Hide(); return; else self:Show() end
local frameLength = self.parent.frameLength
local missing_health_height = (1-h)*frameLength
local absorb_height = p*frameLength
self:AlignAbsorb(absorb_height, missing_health_height)
end
local function CreateAbsorbSideBar(hp, absorbWidth)
local absorb = CreateFrame("Frame", nil, hp)
absorb:SetParent(hp)
-- absorb:SetPoint("BOTTOMLEFT",self,"BOTTOMLEFT",0,0)
absorb:SetPoint("TOPLEFT",hp,"TOPLEFT",-3,0)
absorb:SetWidth(absorbWidth)
local at = absorb:CreateTexture(nil, "ARTWORK", nil, -4)
at:SetTexture[[Interface\BUTTONS\WHITE8X8]]
at:SetVertexColor(.7, .7, 1, 1)
at:SetAllPoints(absorb)
local atbg = absorb:CreateTexture(nil, "ARTWORK", nil, -5)
atbg:SetTexture[[Interface\BUTTONS\WHITE8X8]]
atbg:SetVertexColor(0,0,0,1)
atbg:SetPoint("TOPLEFT", at, "TOPLEFT", -1,1)
atbg:SetPoint("BOTTOMRIGHT", at, "BOTTOMRIGHT", 1,-1)
absorb.AlignAbsorb = AlignAbsorbVertical
absorb.SetValue = CreateAbsorbSideBar_SetValue
absorb:SetValue(0)
return absorb
end
--------------------
-- HEALTH LOST
--------------------
local HealthLostUpdatePositionVertical = function(self, p, health, parent)
local frameLength = parent.frameLength
self:SetHeight(p*frameLength)
if health then
local offset = health*frameLength
self:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", 0, offset)
self:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", 0, offset)
end
end
local HealthLostUpdatePositionHorizontal = function(self, p, health, parent)
local frameLength = parent.frameLength
self:SetWidth(p*frameLength)
if health then
local offset = health*frameLength
self:SetPoint("TOPLEFT", parent, "TOPLEFT", offset, 0)
self:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", offset, 0)
end
end
local function CreateHealthLostBar(hp)
local hl = hp:CreateTexture(nil, "ARTWORK", nil, -5)
hp.lost = hl
-- hpi:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
hl:SetTexture("Interface\\BUTTONS\\WHITE8X8")
hl:SetVertexColor(1,0,0, 1)
hl.UpdatePositionVertical = HealthLostUpdatePositionVertical
hl.UpdatePositionHorizontal = HealthLostUpdatePositionHorizontal
hl.UpdatePosition = HealthLostUpdatePositionVertical
hl.currentvalue = 0
hl.endvalue = 0
hl.UpdateDiff = function(self, diff)
if diff > 0 then
self:UpdatePosition(diff, nil, self.parent)
self:Show()
else
self:Hide()
end
end
hp:SetScript("OnUpdate", function(self, time)
self._elapsed = (self._elapsed or 0) + time
if self._elapsed < 0.025 then return end
self._elapsed = 0
local hl = self.lost
local diff = hl.currentvalue - hl.endvalue
if diff > 0 then
local d = (diff > 0.1) and diff/15 or 0.006
hl.currentvalue = hl.currentvalue - d
hl:UpdateDiff(diff-d)
end
end)
hl.SetNewHealthTarget = function(self, vp, health)
local diff = self.currentvalue - vp
if diff <= 0 then
self.currentvalue = vp
self.endvalue = vp
self:Hide()
else
self.endvalue = vp
self:UpdatePosition(diff, health, self.parent)
end
end
-- hl.SetValue = function(self, p, health)
-- if p < 0.005 then
-- self:Hide()
-- return
-- end
-- local parent = self.parent
-- if p > health then
-- p = health
-- end
-- self:Show()
-- self:UpdatePosition(p, health, parent)
-- self:SetNewHealthTarget(p)
-- self:_SetValue(p, health)
-- end
-- hl.SetValue = AbsorbSetValue
return hl
end
---------------------------
-- Stagger Spikes
---------------------------
local math_min = math.min
local StaggerSpikeSetModVertical = function(self, mod, averageStagger)
local stagger = self:GetParent()
local frameLength = stagger.frameLength
if mod > 0 then
self:ClearAllPoints()
local mod2 = math_min(0.75, mod)
-- local ah = math_min(averageStagger, 0.75)*frameLength
local ah = averageStagger*frameLength
self:SetPoint("TOPLEFT", stagger, "BOTTOMRIGHT", 0, ah)
self:SetHeight(mod2*frameLength)
self.texture:SetVertexColor(0,1,0)
self:Show()
elseif mod < 0 then
self:ClearAllPoints()
local mod2 = math.max(-0.75, mod)
-- local ah = math_min(averageStagger, 0.75)*frameLength
local ah = averageStagger*frameLength
-- spike bar won't be starting higher than 75% stagger position.
-- it's maximum length is also 75% of frame frameLength
-- and the actual stagger bar itself also extends from 100% to 150% stagger if needed
self:SetPoint("BOTTOMLEFT", stagger, "BOTTOMRIGHT", 0, ah)
self:SetHeight(-mod2*frameLength)
self.texture:SetVertexColor(1,0,0)
self:Show()
else
self:Hide()
end
end
local StaggerSpikeSetModHorizontal = function(self, mod, averageStagger)
local stagger = self:GetParent()
local frameLength = stagger.frameLength
if mod > 0 then
self:ClearAllPoints()
local mod2 = math_min(0.75, mod)
local ah = averageStagger*frameLength
self:SetPoint("TOPRIGHT", stagger, "BOTTOMLEFT", ah, 0)
self:SetWidth(mod2*frameLength)
self.texture:SetVertexColor(0,1,0)
self:Show()
elseif mod < 0 then
self:ClearAllPoints()
local mod2 = math.max(-0.75, mod)
local ah = averageStagger*frameLength
self:SetPoint("TOPLEFT", stagger, "BOTTOMLEFT", ah, 0)
self:SetWidth(-mod2*frameLength)
self.texture:SetVertexColor(1,0,0)
self:Show()
else
self:Hide()
end
end
local function CreateStaggerSpikebar(parent)
local height = pixelperfect(NugHealthDB.height)
local width = pixelperfect(NugHealthDB.width)
local trend_width = pixelperfect(NugHealthDB.spike_width)
local trend = CreateFrame("Frame", nil, parent)
trend:SetFrameLevel(FRAMELEVEL.BAR)
trend:SetWidth(trend_width)
trend:SetHeight(height*0.25)
local ttex = trend:CreateTexture(nil, "ARTWORK", nil, 0)
ttex:SetTexture("Interface\\BUTTONS\\WHITE8X8")
ttex:SetAllPoints()
trend.texture = ttex
local p = pixelperfect(1)
local outline = MakeBorder(trend, "Interface\\BUTTONS\\WHITE8X8", -p, -p, -p, -p, "BACKGROUND", -2)
outline:SetVertexColor(0,0,0,1)
trend.SetMod = StaggerSpikeSetModVertical
return trend
end
------------------
-- Stagger Bar
------------------
local StaggerExtendV = function(self, v)
if v > 1.5 then v = 1.5 end
if v > 1 then
self:SetHeight(self.frameLength*v)
else
self:SetHeight(self.frameLength)
end
end
local StaggerExtendH = function(self, v)
if v > 1.5 then v = 1.5 end
if v > 1 then
self:SetWidth(self.frameLength*v)
else
self:SetWidth(self.frameLength)
end
end
local function AlignStagger(stagger, width, height, orientation)
local stagger_width = pixelperfect(NugHealthDB.stagger_width)
local trend_width = pixelperfect(NugHealthDB.spike_width)
local parent = stagger:GetParent()
stagger:SetOrientation(orientation)
stagger:ClearAllPoints()
if orientation == "VERTICAL" then
stagger.frameLength = height
stagger:SetWidth(stagger_width)
stagger:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT",2,0)
stagger:SetHeight(height)
stagger.Extend = StaggerExtendV
stagger.trend:ClearAllPoints()
stagger.trend:SetWidth(trend_width)
stagger.trend.SetMod = StaggerSpikeSetModVertical
else
stagger.frameLength = width
stagger:SetWidth(width)
stagger:SetPoint("TOPLEFT", parent, "BOTTOMLEFT",0,-2)
stagger:SetHeight(stagger_width)
stagger.Extend = StaggerExtendH
stagger.trend:ClearAllPoints()
stagger.trend:SetHeight(trend_width)
stagger.trend.SetMod = StaggerSpikeSetModHorizontal
end
end
local function CreateStaggerBar(self)
local height = pixelperfect(NugHealthDB.height)
local width = pixelperfect(NugHealthDB.width)
local stagger_width = pixelperfect(NugHealthDB.stagger_width)
local stagger = CreateFrame("StatusBar", nil, self)
stagger:SetWidth(stagger_width)
stagger:SetPoint("BOTTOMLEFT",self,"BOTTOMRIGHT",2,0)
stagger:SetHeight(height)
stagger.frameLength = height
stagger.Extend = StaggerExtendV
stagger:SetStatusBarTexture("Interface\\BUTTONS\\WHITE8X8")
stagger:GetStatusBarTexture():SetDrawLayer("ARTWORK",-2)
stagger:SetOrientation("VERTICAL")
stagger:SetMinMaxValues(0, 1)
stagger:SetValue(0.5)
local p = pixelperfect(1)
local outline = MakeBorder(stagger, "Interface\\BUTTONS\\WHITE8X8", -p*2, -p*2, -p*2, -p*2, "BACKGROUND", -2)
outline:SetVertexColor(0,0,0,1)
local stbg = stagger:CreateTexture(nil,"ARTWORK",nil,-3)
stbg:SetAllPoints(stagger)
stbg:SetTexture("Interface\\BUTTONS\\WHITE8X8")
stagger.bg = stbg
stagger.SetColor = ns.MakeSetColor(0.1)
stagger.Align = AlignStagger
-- stagger:SetScript("OnUpdate", function(self, time)
-- self:SetValue( self.endTime - GetTime())
-- end)
stagger:Hide()
return stagger
end
---------------------
-- Resolve Bar
---------------------
local Resolve_SetValueVertical = function(self, p)
if p > 1 then p = 1 end
if p < 0 then p = 0 end
if p == 0 then self:Hide() else self:Show() end
self:SetHeight(p*self.frameLength)
end
local Resolve_SetValueHorizontal = function(self, p)
if p > 1 then p = 1 end
if p < 0 then p = 0 end
if p == 0 then self:Hide() else self:Show() end
self:SetWidth(p*self.frameLength)
end
local function AlignResolve(resolve, width, height, orientation)
resolve:ClearAllPoints()
local parent = resolve:GetParent()
if orientation == "VERTICAL" then
resolve.frameLength = height
resolve:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT",0,0)
resolve:SetWidth(6)
resolve.SetValue = Resolve_SetValueVertical
else
resolve.frameLength = width
resolve:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT",0,0)
resolve:SetHeight(6)
resolve.SetValue = Resolve_SetValueHorizontal
end
end
local function CreateResolveBar(self)
local resolve = CreateFrame("Frame", nil, self)
resolve:SetPoint("BOTTOMRIGHT",self,"BOTTOMRIGHT",0,0)
resolve:SetWidth(6)
local at = resolve:CreateTexture(nil, "ARTWORK", nil, -4)
at:SetTexture"Interface\\BUTTONS\\WHITE8X8"
-- at:SetVertexColor(.7, .7, 1, 1)
resolve.texture = at
at:SetAllPoints(resolve)
local p = pixelperfect(1)
local outline = MakeBorder(resolve, "Interface\\BUTTONS\\WHITE8X8", -p, -p, -p, -p, "ARTWORK", -5)
outline:SetVertexColor(0,0,0,1)
resolve.frameLength = self:GetHeight()
resolve.SetValue = Resolve_SetValueVertical
resolve:SetValue(0)
resolve.Align = AlignResolve
resolve.SetStatusBarColor = function(self, r,g,b)
self.texture:SetVertexColor(r,g,b)
end
return resolve
end
local function Reconf(self)
-- TODO: Restore glowtex
local db = NugHealthDB
local isVertical = db.healthOrientation == "VERTICAL"
local texpath = LSM:Fetch("statusbar", db.healthTexture)
local healthTextFont = LSM:Fetch("font", "OpenSans Bold")
self.health:SetStatusBarTexture(texpath)
self.health:GetStatusBarTexture():SetDrawLayer("ARTWORK",-6)
self.health.bg:SetTexture(texpath)
-- if not db.fgShowMissing then
-- -- Blizzard's StatusBar SetFillStyle is bad, because even if it reverses direction,
-- -- it still cuts tex coords from the usual direction
-- -- So i'm using custom status bar for health and resolve
-- self.health:SetFillStyle("STANDARD")
-- -- self.resolve:SetFillStyle("STANDARD")
-- -- self.health.SetColor = HealthBarSetColorInverted
-- -- self.resolve.SetColor = HealthBarSetColorInverted
-- -- self.text1.SetColor = Text1_SetColorInverted
-- -- self.text1:SetShadowOffset(0,0)
-- self.health.absorb2:SetVertexColor(0.7,0.7,1, 0.65)
-- self.health.incoming:SetVertexColor(0.3, 1,0.4, 0.4)
-- self.health.absorb2:SetDrawLayer("ARTWORK", -7)
-- self.health.incoming:SetDrawLayer("ARTWORK", -7)
-- else
self.health:SetFillStyle("REVERSE")
-- self.health.SetColor = HealthBarSetColor
-- self.resolve.SetColor = HealthBarSetColor
-- self.text1.SetColor = Text1_SetColor
-- self.text1:SetShadowOffset(1,-1)
self.health.absorb2:SetVertexColor(0,0,0, 0.65)
self.health.incoming:SetVertexColor(0,0,0, 0.4)
self.health.absorb2:SetDrawLayer("ARTWORK", -5)
self.health.incoming:SetDrawLayer("ARTWORK", -5)
-- end
-- Aptechka.FrameSetJob(self,config.HealthBarColor,true)
-- Aptechka.FrameSetJob(self,config.staggerColor,true)
-- Aptechka.FrameSetJob(self,config.UnitNameStatus,true)
-- local nameFont = LSM:Fetch("font", Aptechka.db.profile.nameFontName)
-- local nameFontSize = Aptechka.db.profile.nameFontSize
-- local nameFontOutline = Aptechka.db.profile.nameFontOutline
-- local outline = nameFontOutline == "OUTLINE" and "OUTLINE"
-- self.text1:SetFont(nameFont, nameFontSize, outline)
-- if nameFontOutline == "SHADOW" then
-- self.text1:SetShadowOffset(1,-1)
-- else
-- self.text1:SetShadowOffset(0,0)
-- end
local height = pixelperfect(NugHealthDB.height)
local width = pixelperfect(NugHealthDB.width)
local absorb_width = pixelperfect(NugHealthDB.absorb_width)
local stagger_width = pixelperfect(NugHealthDB.stagger_width)
local trend_width = pixelperfect(NugHealthDB.spike_width)
self:SetWidth(width)
self:SetHeight(height)
-- self.trend:SetWidth(trend_width)
-- self.absorb.maxheight = height
-- self.absorb:SetWidth(absorb_width)
-- self.glowtex:SetWidth(width*hmul)
-- self.glowtex:SetHeight(height*vmul)
local htext = self.health.text
if NugHealthDB.healthText then
htext:Show()
else
htext:Hide()
end
if isVertical then
self.health:SetOrientation("VERTICAL")
-- self.resolve:SetOrientation("VERTICAL")
local frameLength = pixelperfect(db.height)
self.health.frameLength = frameLength
self.health:ClearAllPoints()
self.health:SetPoint("TOPLEFT",self,"TOPLEFT",0,0)
self.health:SetPoint("TOPRIGHT",self,"TOPRIGHT",0,0)
self.health:SetHeight(frameLength)
htext:ClearAllPoints()
htext:SetFont(healthTextFont, NugHealthDB.healthTextSize)
htext:SetPoint("TOP", self.health, "TOP",0, -NugHealthDB.healthTextOffset)
self.stagger:Align(width, height, "VERTICAL")
self.resolve:Align(width, height, "VERTICAL")
self.trend:SetHeight(frameLength)
self.trend:SetWidth(trend_width)
local absorb = self.health.absorb
absorb:ClearAllPoints()
absorb:SetWidth(absorb_width)
absorb.orientation = "VERTICAL"
absorb.AlignAbsorb = AlignAbsorbVertical
-- Aptechka:UNIT_ABSORB_AMOUNT_CHANGED(nil, self.unit)
local flashPool = self.flashPool
flashPool.UpdatePosition = flashPool.UpdatePositionVertical
local hplost = self.health.lost
hplost:ClearAllPoints()
hplost.UpdatePosition = hplost.UpdatePositionVertical
local healAbsorb = self.health.healabsorb
healAbsorb:ClearAllPoints()
healAbsorb.UpdatePosition = healAbsorb.UpdatePositionVertical
local absorb2 = self.health.absorb2
absorb2:ClearAllPoints()
absorb2.UpdatePosition = absorb2.UpdatePositionVertical
local hpi = self.health.incoming
hpi:ClearAllPoints()
hpi.UpdatePosition = hpi.UpdatePositionVertical
else
self.health:SetOrientation("HORIZONTAL")
-- self.resolve:SetOrientation("HORIZONTAL")
local frameLength = pixelperfect(db.width)
self.health.frameLength = frameLength
self.health:ClearAllPoints()
self.health:SetPoint("TOPLEFT",self,"TOPLEFT",0,0)
self.health:SetPoint("BOTTOMLEFT",self,"BOTTOMLEFT",0,0)
self.health:SetWidth(frameLength)
htext:ClearAllPoints()
htext:SetFont(healthTextFont, NugHealthDB.healthTextSize)
htext:SetPoint("RIGHT", self.health, "RIGHT", -NugHealthDB.healthTextOffset, 0)
self.stagger:Align(width, height, "HORIZONTAL")
self.resolve:Align(width, height, "HORIZONTAL")
-- self.resolve:OnPowerTypeChange()
local absorb = self.health.absorb
absorb:ClearAllPoints()
absorb:SetHeight(3)
absorb.orientation = "HORIZONTAL"
absorb.AlignAbsorb = AlignAbsorbHorizontal
local flashPool = self.flashPool
flashPool.UpdatePosition = flashPool.UpdatePositionHorizontal
local hplost = self.health.lost
hplost:ClearAllPoints()
hplost.UpdatePosition = hplost.UpdatePositionHorizontal
local healAbsorb = self.health.healabsorb
healAbsorb:ClearAllPoints()
healAbsorb.UpdatePosition = healAbsorb.UpdatePositionHorizontal
local absorb2 = self.health.absorb2
absorb2:ClearAllPoints()
absorb2.UpdatePosition = absorb2.UpdatePositionHorizontal
local hpi = self.health.incoming
hpi:ClearAllPoints()
hpi.UpdatePosition = hpi.UpdatePositionHorizontal
end
end
function NugHealth.Create(self)
local res = GetCVar("gxWindowedResolution")
if res then
local w,h = string.match(res, "(%d+)x(%d+)")
pmult = (768/h) / UIParent:GetScale()
end
local db = NugHealthDB
local p = pixelperfect(1)
local texture = LSM:Fetch("statusbar", db.healthTexture)
local healthTextFont = LSM:Fetch("font", "OpenSans Bold")
-- local powertexture = LSM:Fetch("statusbar", db.powerTexture)
-- local font = LSM:Fetch("font", Aptechka.db.profile.nameFontName)
-- local fontsize = Aptechka.db.profile.nameFontSize
-- local manabar_width = config.manabarwidth
local outlineSize = pixelperfect(2)
local height = pixelperfect(NugHealthDB.height)
local width = pixelperfect(NugHealthDB.width)
local absorb_width = pixelperfect(NugHealthDB.absorb_width)
local stagger_width = pixelperfect(NugHealthDB.stagger_width)
self:SetWidth(width)
self:SetHeight(height)
self:SetFrameLevel(FRAMELEVEL.BASEFRAME)
self.state = {}
self.ReconfigureUnitFrame = Reconf
self.Resize = Reconf
local outline = MakeCompositeBorder(self, "Interface\\BUTTONS\\WHITE8X8", outlineSize, outlineSize, outlineSize, outlineSize, "BACKGROUND", -2)
-- outline:Set(1,1,1,1)
--------------
-- Resolve
--------------
local resolve = CreateResolveBar(self)
self.resolve = resolve
--------------
-- Stagger
--------------
local stagger = CreateStaggerBar(self)
self.stagger = stagger
--------------
-- Stagger Spikes
--------------
local trend = CreateStaggerSpikebar(stagger)
self.trend = trend
stagger.trend = trend
--------------
-- Health
--------------
-- local hp = CreateFrame("StatusBar", nil, self)
local hp = ns.CreateCustomStatusBar(nil, self, "VERTICAL")
hp:SetFrameLevel(FRAMELEVEL.HEALTH)
hp:SetPoint("TOPLEFT",self,"TOPLEFT",0,0)
hp:SetPoint("TOPRIGHT",self,"TOPRIGHT",0,0)
-- hp:SetPoint("TOPRIGHT",stagger,"TOPRIGHT",0,0)
hp:SetHeight(height)
hp:GetStatusBarTexture():SetDrawLayer("ARTWORK",-6)
hp:SetMinMaxValues(0,100)
hp:SetOrientation("VERTICAL")
hp.parent = self
--hp:SetValue(0)
local hpbg = hp:CreateTexture(nil,"ARTWORK",nil,-8)
hpbg:SetAllPoints(hp)
hpbg:SetTexture(texture)
-- hpbg.SetColor = HealthBarSetColorBG
hp.bg = hpbg
---------------
-- Health Text
---------------
local htext = hp:CreateFontString()
htext:SetFont(healthTextFont, NugHealthDB.healthTextSize)
htext:SetPoint("TOP", hp, "TOP",0, -NugHealthDB.healthTextOffset)
if not NugHealthDB.healthText then htext:Hide() end
hp.text = htext
hp.SetColor = function(self, r,g,b)
self:SetStatusBarColor(r,g,b)
self.bg:SetVertexColor(r*0.2,g*0.2,b*0.2)
self.text:SetTextColor(r*0.2,g*0.2,b*0.2)
end
hp.RestoreColor = function(self)
if NugHealthDB.classcolor then
local _, class = UnitClass("player")
local c = RAID_CLASS_COLORS[class]
self:SetColor(c.r,c.g,c.b)
else
self:SetColor(unpack(NugHealthDB.healthcolor))
end
end
hp:RestoreColor()
----------------------
-- HEALTH LOST EFFECT
----------------------
local flashPool = CreateTexturePool(hp, "ARTWORK", -5)
flashPool.StopEffect = function(self, flash)
flash.ag:Finish()
end
flashPool.UpdatePositionVertical = function(pool, self, p, health, parent)
local frameLength = parent.frameLength
self:SetHeight(-p*frameLength)
local offset = health*frameLength
self:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", 0, offset)
self:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", 0, offset)
end
flashPool.UpdatePositionHorizontal = function(pool, self, p, health, parent)
local frameLength = parent.frameLength
self:SetWidth(-p*frameLength)
local offset = health*frameLength
self:SetPoint("TOPLEFT", parent, "TOPLEFT", offset, 0)
self:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", offset, 0)
end
flashPool.UpdatePosition = flashPool.bUpdatePositionVertical
flashPool.FireEffect = function(self, flash, p, health, frameState, flashId)
--[=[
if p >= 0 then return end
local tex = flash
local hp = tex:GetParent()
local frameLength = hp.frameLength
tex:SetTexture("Interface\\BUTTONS\\WHITE8X8")
-- tex:SetBlendMode("ADD")
tex:SetVertexColor(1,1,1, 1)
tex:Show()
tex:ClearAllPoints()
self:UpdatePosition(tex, p, health, hp)
if not tex.ag then
local bag = tex:CreateAnimationGroup()
-- local ba1 = bag:CreateAnimation("Alpha")
-- ba1:SetFromAlpha(0)
-- ba1:SetToAlpha(0.8)
-- ba1:SetDuration(0.1)
-- ba1:SetOrder(1)
-- local s1 = bag:CreateAnimation("Scale")
-- s1:SetOrigin("LEFT",0,0)
-- s1:SetFromScale(1, 1)
-- s1:SetToScale(0.01, 1)
-- s1:SetDuration(0.3)
-- s1:SetOrder(1)
-- local t1 = bag:CreateAnimation("Translation")
-- t1:SetOffset(10, 0)
-- t1:SetDuration(0.15)
-- t1:SetOrder(1)
local ba2 = bag:CreateAnimation("Alpha")
-- ba2:SetStartDelay(0.1)
ba2:SetFromAlpha(1)
ba2:SetToAlpha(0)
ba2:SetDuration(0.2)
ba2:SetOrder(1)
bag.a2 = ba2
-- local t2 = bag:CreateAnimation("Scale")
-- t2:SetFromScale(1.1, 1)
-- t2:SetToScale(1, 1)
-- t2:SetDuration(0.7)
-- t2:SetOrder(2)
bag.pool = flashPool
bag:SetScript("OnFinished", function(self)
self.pool:Release(self:GetParent())
local frameState = self.state
local id = self.flashId
frameState.flashes[id] = nil
end)
tex.ag = bag
end
tex.ag.state = frameState
tex.ag.flashId = flashId
tex.ag:Play()
return true
]=]
end
self.flashPool = flashPool
--------------------
local lost = CreateHealthLostBar(hp)
lost.parent = hp
hp.lost = lost
--------------------
local absorb = CreateAbsorbSideBar(hp, absorb_width)
absorb.parent = hp
hp.absorb = absorb
-------------------
local absorb2 = CreateAbsorbBar(hp)
absorb2.parent = hp
hp.absorb2 = absorb2
-------------------
local healAbsorb = CreateHealAbsorb(hp)
healAbsorb.parent = hp
hp.healabsorb = healAbsorb
-----------------------
local hpi = CreateIncominHealBar(hp)
hpi.parent = hp
hp.incoming = hpi
self.health = hp
-- self.power = stagger
self.healabsorb = healAbsorb
self.absorb = absorb
self.absorb2 = absorb2
Reconf(self)
self:EnableMouse(false)
self:RegisterForDrag("LeftButton")
self:SetMovable(true)
self:SetScript("OnDragStart",function(self) self:StartMoving() end)
self:SetScript("OnDragStop",function(self)
self:StopMovingOrSizing();
local db = NugHealthDB
db.point, db.frame, db.relative_point, db.x, db.y = self:GetPoint(1)
end)
-- print(self == NugHealth)
-- print(db.point, db.frame, db.relative_point, db.x, db.y)
self:SetPoint(db.point, db.frame, db.relative_point, db.x, db.y)
self:Hide()
return self