-
Notifications
You must be signed in to change notification settings - Fork 7
/
functions.lua
1248 lines (1042 loc) · 42.8 KB
/
functions.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 _, ns = ...
local lum, core, api, cfg, m, G, oUF = ns.lum, ns.core, ns.api, ns.cfg, ns.m,
ns.G, ns.oUF
local filters, debuffs, watchers = ns.filters, ns.debuffs, ns.watchers
local UnitAura, UnitPowerType = UnitAura, UnitPowerType
local font = m.fonts.font
-- -----------------------------------
-- > Health bar
-- -----------------------------------
local onPostUpdateHealth = function(health, unit, min, max)
local self = health.__owner
local frame = self.mystyle
if cfg.units[frame].health.gradientColored then
local color = CreateColor(oUF:ColorGradient(min, max, 1, 0, 0, 1, 1, 0,
unpack(api:RaidColor(unit))))
health:SetStatusBarColor(color:GetRGB())
end
-- Class colored text
if cfg.units[frame].health.classColoredText then
self.Name:SetTextColor(unpack(api:RaidColor(unit)))
end
end
function lum:CreateHealthBar(self, frameType)
if not self.cfg.health.show then return end
local health = CreateFrame("StatusBar", nil, self)
health:SetHeight(self.cfg.height - cfg.frames[frameType].health.margin -
self.cfg.power.height)
health:SetWidth(self.cfg.width)
health:SetPoint("TOP")
health:SetStatusBarTexture(m.textures.status_texture)
health:SetStatusBarColor(unpack(cfg.colors.health))
health:GetStatusBarTexture():SetHorizTile(false)
health.bg = health:CreateTexture(nil, "BACKGROUND")
health.bg:SetAllPoints(health)
health.bg:SetAlpha(0.05)
health.bg:SetTexture(m.textures.bg_texture)
health.Smooth = self.cfg.health.smooth
health.PostUpdate = onPostUpdateHealth
if self.cfg.health.classColored then health.colorClass = true end
if self.cfg.health.reactionColored then health.colorReaction = true end
health.colorDisconnected = true
health.colorTapping = true
self.Health = health
return self.Health
end
-- -----------------------------------
-- > Power bar
-- -----------------------------------
-- Color the Druid Moonkin Power bar acording to Eclipse state
local LUNAR_POWER_COLOR = oUF.colors.power["LUNAR_POWER"]
local SOLAR_COLOR = {255 / 255, 224 / 255, 93 / 255}
local LUNAR_COLOR = {66 / 255, 82 / 255, 244 / 255}
local WRATH_SPELL_ID = 190984
local STARFIRE_SPELL_ID = 194153
local shouldCastWrath = false
local shouldCastStarfire = false
local eclipse = 0 -- 1 = Solar, 2 = Lunar
local function SetDruidSolarPowerColor(self)
local frame = self.mystyle
if frame ~= "playerplate" then return end
-- local charges, maxCharges, chargeStart, chargeDuration = GetSpellCharges(spellID)
local UpdatePower = function(self, ...)
local wrathCount = GetSpellCount(WRATH_SPELL_ID)
local starfireCount = GetSpellCount(STARFIRE_SPELL_ID)
-- We have charges on both spells
if wrathCount > 0 and starfireCount > 0 then
if wrathCount < starfireCount then
shouldCastWrath = true
shouldCastStarfire = false
eclipse = 2
self.Power:SetStatusBarColor(unpack(SOLAR_COLOR))
elseif starfireCount < wrathCount then
shouldCastWrath = false
shouldCastStarfire = true
eclipse = 1
self.Power:SetStatusBarColor(unpack(LUNAR_COLOR))
else -- they have the same count so we are are not in eclipse (un-empowered)
shouldCastWrath = false
shouldCastStarfire = false
eclipse = 0
self.Power:SetStatusBarColor(unpack(LUNAR_POWER_COLOR))
end
elseif wrathCount == 0 and starfireCount == 0 then -- Eclipse State
shouldCastWrath = false
shouldCastStarfire = false
if eclipse == 1 then
self.Power:SetStatusBarColor(unpack(SOLAR_COLOR))
elseif eclipse == 2 then
self.Power:SetStatusBarColor(unpack(LUNAR_COLOR))
else
self.Power:SetStatusBarColor(unpack(LUNAR_POWER_COLOR))
end
else -- One spell has zero charges, cast the non zero one to eclipse
if wrathCount > 0 then
shouldCastWrath = true
shouldCastStarfire = false
eclipse = 2
self.Power:SetStatusBarColor(unpack(SOLAR_COLOR))
else
shouldCastWrath = false
shouldCastStarfire = true
eclipse = 1
self.Power:SetStatusBarColor(unpack(LUNAR_COLOR))
end
end
end
if G.playerClass == "DRUID" then
UpdatePower(self)
self:RegisterEvent("UNIT_POWER_UPDATE", UpdatePower)
self:RegisterEvent("SPELLS_CHANGED", UpdatePower, true)
self:RegisterEvent("PLAYER_LOGIN", UpdatePower, true)
self:RegisterEvent("PLAYER_ENTERING_WORLD", UpdatePower, true)
end
end
function lum:CreateMaxPowerWarningGlow(self)
local frame = self.Backdrop or self
local glow = frame:CreateTexture(nil, "BACKGROUND", nil, -8)
glow:SetSize(frame:GetWidth() * 1.4, 24)
glow:SetTexture("Interface\\GLUES\\Models\\UI_Draenei\\GenericGlow64")
glow:SetBlendMode("BLEND")
glow:SetPoint("CENTER", frame, "CENTER", 0, 0)
glow:Hide()
self.Power.glow = glow
end
-- BUG: When max power coloring is not updating correctly
local function PostUpdatePowerColor(self, unit)
if self.glow then
local r, g, b = self:GetStatusBarColor()
r, g, b = core:TintColor(r, g, b, 0.3)
self.glow:SetVertexColor(r, g, b, 0.9)
end
-- Fix: Disable this for now till fixed
-- Class Specific
-- if unit == "player" then
-- if G.playerClass == "DRUID" then
-- -- Moonkin Eclipse
-- if shouldCastWrath then
-- self:SetStatusBarColor(unpack(SOLAR_COLOR))
-- elseif shouldCastStarfire then
-- self:SetStatusBarColor(unpack(LUNAR_COLOR))
-- else
-- if eclipse == 1 then
-- self:SetStatusBarColor(unpack(SOLAR_COLOR))
-- elseif eclipse == 2 then
-- self:SetStatusBarColor(unpack(LUNAR_COLOR))
-- else
-- self:SetStatusBarColor(unpack(LUNAR_POWER_COLOR))
-- end
-- end
-- end
-- end
end
local function PostUpdatePower(self, unit, cur, min, max)
local powertype = UnitPowerType("player")
-- Show the glow when power is at max (except for Mana)
if self.glow and powertype ~= 0 then
local playerIsInCombat = UnitAffectingCombat("player")
if cur == max and playerIsInCombat then
self.glow:Show()
else
self.glow:Hide()
end
end
end
function lum:CreatePowerBar(self, frameType)
if not self.cfg.power.show then return end
local power = CreateFrame("StatusBar", nil, self)
power:SetHeight(self.cfg.power.height)
power:SetWidth(self.cfg.width)
power:SetStatusBarTexture(m.textures.status_texture)
power:GetStatusBarTexture():SetHorizTile(false)
power:SetPoint("TOP", self.Health, "BOTTOM", 0, -cfg.frames[frameType].health.margin)
power.bg = power:CreateTexture(nil, "BACKGROUND")
power.bg:SetAllPoints(power)
power.bg:SetTexture(m.textures.bg_texture)
power.bg:SetAlpha(0.15)
power.Smooth = self.cfg.power.smooth
power.frequentUpdates = self.cfg.power.frequentUpdates
power.colorTapping = true
power.colorDisconnected = false
if self.cfg.power.classColored then
power.colorClass = true
else
power.colorPower = true
end
power.PostUpdateColor = PostUpdatePowerColor
power.PostUpdate = PostUpdatePower
self.Power = power
-- Fix: Disable this for now till fixed
-- Class specific
-- SetDruidSolarPowerColor(self)
return self.Power
end
-- ----------------------------------------
-- > Additional Power
-- Power bar for specs like Balance Druid
-- ----------------------------------------
local function AdditionalPowerPostUpdate(self, cur, max)
local frame = self.__owner.mystyle
local powertype = UnitPowerType("player")
if powertype == 0 then return end
if not cfg.units[frame].additionalpower.hideOnFull then return end
-- Hide bar if full
if cur == max or powertype == 0 then
self:Hide()
else
self:Show()
end
-- Hide if dead
local isPlayerDead = UnitIsDead("player") or UnitIsGhost(unit)
print(isPlayerDead)
if isPlayerDead then
self:Hide()
else
self:Show()
end
end
function lum:CreateAdditionalPower(self)
if not self.cfg.additionalpower.show then return end
local gap = -18
local r, g, b = unpack(oUF.colors.power[ADDITIONAL_POWER_BAR_NAME])
local AdditionalPower = CreateFrame("StatusBar", nil, self,
"BackdropTemplate")
AdditionalPower:SetStatusBarTexture(m.textures.status_texture)
AdditionalPower:GetStatusBarTexture():SetHorizTile(false)
AdditionalPower:SetSize(self.cfg.width, self.cfg.additionalpower.height)
AdditionalPower:SetStatusBarColor(r, g, b)
AdditionalPower.frequentUpdates = true
if cfg.units.player.power.show then
AdditionalPower:SetPoint("TOP", self.Health, "BOTTOM", 0, -14)
api:SetBackdrop(AdditionalPower, 1.5, 1.5, 1.5, 1.5)
else
-- If power is not showing position the additional power below health
AdditionalPower:SetPoint("TOP", self.Health, "BOTTOM", 0,
-cfg.frames.main.health.margin)
end
local bg = AdditionalPower:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints(AdditionalPower)
bg:SetTexture(m.textures.bg_texture)
bg:SetVertexColor(r * 0.25, g * 0.25, b * 0.25)
local PowerValue = api:CreateFontstring(AdditionalPower, font,
cfg.fontsize - 3, "THINOUTLINE")
PowerValue:SetPoint("CENTER", AdditionalPower, 0, 0)
PowerValue:SetJustifyH("CENTER")
self:Tag(PowerValue, "[lum:altpower]")
AdditionalPower.bg = bg
AdditionalPower.PostUpdate = AdditionalPowerPostUpdate
self.AdditionalPower = AdditionalPower
end
-- -----------------------------------
-- > Heal Prediction
-- -----------------------------------
function lum:CreateHealPrediction(self)
if not self.Health then return end
local myBar = CreateFrame("StatusBar", nil, self.Health)
myBar:SetPoint("TOP")
myBar:SetPoint("BOTTOM")
myBar:SetPoint("LEFT", self.Health:GetStatusBarTexture(), "RIGHT")
myBar:SetWidth(self.cfg.width)
myBar:SetStatusBarTexture(m.textures.status_texture)
myBar:SetStatusBarColor(125 / 255, 255 / 255, 50 / 255, .4)
local otherBar = CreateFrame("StatusBar", nil, self.Health)
otherBar:SetPoint("TOP")
otherBar:SetPoint("BOTTOM")
otherBar:SetPoint("LEFT", self.Health:GetStatusBarTexture(), "RIGHT")
otherBar:SetWidth(self.cfg.width)
otherBar:SetStatusBarTexture(m.textures.status_texture)
otherBar:SetStatusBarColor(100 / 255, 235 / 255, 200 / 255, .4)
local absorbBar = CreateFrame("StatusBar", nil, self.Health)
absorbBar:SetPoint("TOP")
absorbBar:SetPoint("BOTTOM")
absorbBar:SetPoint("LEFT", self.Health:GetStatusBarTexture(), "RIGHT")
absorbBar:SetWidth(self.cfg.width)
absorbBar:SetStatusBarTexture(m.textures.status_texture)
absorbBar:SetStatusBarColor(18053 / 255, 255 / 255, 205 / 255, .35)
local healAbsorbBar = CreateFrame("StatusBar", nil, self.Health)
healAbsorbBar:SetPoint("TOP")
healAbsorbBar:SetPoint("BOTTOM")
healAbsorbBar:SetPoint("LEFT", self.Health:GetStatusBarTexture(), "RIGHT")
healAbsorbBar:SetWidth(self.cfg.width)
healAbsorbBar:SetStatusBarTexture(m.textures.status_texture)
healAbsorbBar:SetStatusBarColor(183 / 255, 244 / 255, 255 / 255, .35)
-- Register with oUF
self.HealthPrediction = {
myBar = myBar,
otherBar = otherBar,
absorbBar = absorbBar,
healAbsorbBar = healAbsorbBar,
maxOverflow = 1
}
end
-- -----------------------------------
-- > Power Prediction
-- -----------------------------------
-- Fix: Not working for altBar
function lum:CreatePowerPrediction(self)
local mainBar = CreateFrame("StatusBar", nil, self.Power)
mainBar:SetStatusBarTexture(m.textures.status_texture)
mainBar:SetReverseFill(true)
mainBar:SetWidth(self.cfg.width)
if self.Power then
local r, g, b = self.Power:GetStatusBarColor()
mainBar:SetStatusBarColor(r, g, b, 0.4)
mainBar:SetPoint("TOP")
mainBar:SetPoint("BOTTOM")
mainBar:SetPoint("RIGHT", self.Power:GetStatusBarTexture(), "RIGHT")
end
local altBar = CreateFrame("StatusBar", nil, self.AdditionalPower)
altBar:SetStatusBarTexture(m.textures.status_texture)
altBar:SetReverseFill(true)
altBar:SetWidth(self.cfg.width)
if self.AdditionalPower then
local r, g, b = self.AdditionalPower:GetStatusBarColor()
altBar:SetStatusBarColor(r, g, b, 0.4)
altBar:SetPoint("TOP")
altBar:SetPoint("BOTTOM")
altBar:SetPoint("RIGHT", self.AdditionalPower:GetStatusBarTexture(),
"RIGHT")
end
self.PowerPrediction = {
mainBar = mainBar and mainBar,
altBar = altBar and altBar
}
end
-- -----------------------------------
-- > Attack Swing Bar
-- -----------------------------------
function lum:CreateSwing(self)
if not cfg.elements.swing.show[G.playerClass] then return end
local frame = self.mystyle
if not cfg.units.player.castbar.enable or not self.Castbar then return end
if frame ~= "player" then return end
local color = {0.5, 0.9, 1, 1}
local bar = CreateFrame("StatusBar", nil, self)
bar:SetSize(self.Castbar:GetWidth() + self.Castbar:GetHeight() + 2, 2)
bar:SetPoint("TOPLEFT", self.Castbar, "BOTTOMLEFT",
-(self.Castbar:GetHeight() + 2), -2)
local two = CreateFrame("StatusBar", nil, bar)
two:Hide()
two:SetAllPoints()
two:SetStatusBarTexture(m.textures.status_texture)
two:SetStatusBarColor(unpack(color))
api:SetBackdrop(two, 2, 2, 2, 2, {0, 0, 0, 0.8})
local main = CreateFrame("StatusBar", nil, bar)
main:Hide()
main:SetAllPoints()
main:SetStatusBarTexture(m.textures.status_texture)
main:SetStatusBarColor(unpack(color))
api:SetBackdrop(main, 2, 2, 2, 2, {0, 0, 0, 0.8})
local off = CreateFrame("StatusBar", nil, bar)
off:Hide()
off:SetPoint("TOPLEFT", bar, "BOTTOMLEFT", 0, -3)
off:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT", 0, -6)
off:SetStatusBarTexture(m.textures.status_texture)
off:SetStatusBarColor(unpack(color))
api:SetBackdrop(off, 2, 2, 2, 2, {0, 0, 0, 0.8})
self.Swing = bar
self.Swing.Twohand = two
self.Swing.Mainhand = main
self.Swing.Offhand = off
self.Swing.hideOoc = true
end
-- -----------------------------------
-- > Auras
-- -----------------------------------
function lum:SetBuffAuras(self, frame, numAuras, numRows, size, spacing, anchor,
parent, parentAnchor, posX, posY, initialAnchor,
growthX, growthY, showStealableBuffs)
if not cfg.units[frame].auras.buffs.show then return end
local PlayerCustomFilter = function(...)
local spellID = select(13, ...)
if spellID then
if filters["ALL"].buffs[spellID] or
filters[G.playerClass].buffs[spellID] then
return true
end
end
end
local buffs = lum:CreateAura(self, numAuras, numRows, size, spacing)
buffs:SetPoint(anchor, parent, parentAnchor, posX, posY)
buffs.initialAnchor = initialAnchor
buffs["growth-y"] = growthY or "DOWN"
buffs["growth-x"] = growthX or "RIGHT"
buffs.showStealableBuffs = showStealableBuffs
if frame == "playerplate" then buffs.CustomFilter = PlayerCustomFilter end
self.Buffs = buffs
return buffs
end
function lum:SetDebuffAuras(self, frame, numAuras, numRows, size, spacing,
anchor, parent, parentAnchor, posX, posY,
initialAnchor, growthX, growthY, showDebuffType,
onlyShowPlayer)
if not cfg.units[frame].auras.debuffs.show then return end
-- Debuffs filter (Blacklist)
local CustomFilter = function(element, unit, button, name, _, _, _,
duration, _, _, _, _, spellID)
if onlyShowPlayer and not button.isPlayer then return false end
if not debuffs.list[frame] or not spellID then return true end
if debuffs.list[frame][spellID] or duration == 0 then
return false
end
return true
end
local debuffs = lum:CreateAura(self, numAuras, numRows, size, spacing)
debuffs:SetPoint(anchor, parent, parentAnchor, posX, posY)
debuffs.initialAnchor = initialAnchor
debuffs["growth-y"] = growthY or "DOWN"
debuffs["growth-x"] = growthX or "RIGHT"
debuffs.showDebuffType = showDebuffType
debuffs.onlyShowPlayer = onlyShowPlayer
debuffs.CustomFilter = CustomFilter
self.Debuffs = debuffs
return debuffs
end
function lum:SetBarTimerAuras(self, frame, numAuras, numRows, size, spacing,
anchor, parent, parentAnchor, posX, posY,
initialAnchor, growthY)
if not cfg.units[frame].auras.barTimers.show then return end
local PlayerCustomFilter = function(...)
local spellID = select(13, ...)
if spellID then
if filters["ALL"].buffs[spellID] or
filters[G.playerClass].buffs[spellID] then
return true
end
end
end
local TargetCustomFilter = function(element, unit, button, name, _, _, _,
duration, _, _, _, _, spellID)
if spellID then
if (filters[G.playerClass].debuffs[spellID] and button.isPlayer) then
return true
end
end
end
local barTimers = lum:CreateBarTimer(self, numAuras, numRows, size, spacing)
barTimers:SetPoint(anchor, parent, parentAnchor, posX, posY)
barTimers.initialAnchor = "BOTTOMLEFT"
barTimers["growth-y"] = "UP"
if frame == "player" then
barTimers.CustomFilter = PlayerCustomFilter
self.Buffs = barTimers
end
if frame == "target" then
barTimers.CustomFilter = TargetCustomFilter
self.Debuffs = barTimers
end
return barTimers
end
-- -----------------------------------
-- > Spell Watchers (Player Plate)
-- -----------------------------------
local function OnUpdateSpellButton(button, elapsed)
if button.timeLeft then
button.timeLeft = max(button.timeLeft - elapsed, 0)
if button.timeLeft and button.timeLeft > 0 then
button.time:SetFormattedText(core:FormatTime(button.timeLeft))
if button.timeLeft < 6 then
button.time:SetTextColor(0.9, 0.05, 0.05)
elseif button.timeLeft < 60 then
button.time:SetTextColor(1, 1, 0.6)
else
button.time:SetTextColor(0.1, 0.6, 1.0)
end
else
button.time:SetText()
button.icon:SetDesaturated(false)
end
else
button.time:SetText()
end
end
local function PostUpdateSpellWatcher(self, button, expirationTime)
if expirationTime and expirationTime > 0 then
button.timeLeft = expirationTime - GetTime()
button:SetScript("OnUpdate", OnUpdateSpellButton)
else
button.time:SetText()
button:SetScript("OnUpdate", nil)
end
end
local function PostCreateSpellWatcher(self, button)
api:CreateDropShadow(button, 4, 4)
if cfg.elements.spellwatchers.useCustomText then
local count = button.count
count:ClearAllPoints()
count:SetJustifyH("RIGHT")
count:SetPoint("BOTTOM", button, "TOP", 1, 2)
count:SetFont(STANDARD_TEXT_FONT, 14, "THICKOUTLINE")
button.time = button:CreateFontString(nil, "OVERLAY")
button.time:SetFont(m.fonts.font, 16, "THINOUTLINE")
button.time:SetPoint("CENTER", button, 0, 0)
button.time:SetTextColor(1, 1, 0.65)
button.time:SetShadowOffset(1, -1)
button.time:SetShadowColor(0, 0, 0, 1)
button.time:SetJustifyH("CENTER")
end
button.overlay:SetTexture(m.textures.button_border)
-- button.overlay:SetVertexColor(0.05, 0.05, 0.05) -- FIX: Not setting the color...
end
function lum:CreateSpellWatchers(self)
if not cfg.elements.spellwatchers.show then return end
local frame = self.mystyle
local SpellWatchers = CreateFrame("Frame", nil, self)
SpellWatchers:SetSize(cfg.units[frame].width, cfg.units[frame].width / 5 + 4)
SpellWatchers:SetPoint("BOTTOM", self, "TOP", 0, 0)
SpellWatchers.gap = 4
SpellWatchers.spells = watchers
SpellWatchers.PostCreateButton = PostCreateSpellWatcher
if cfg.elements.spellwatchers.useCustomText then
SpellWatchers.disableCooldown = true
SpellWatchers.PostUpdateSpell = PostUpdateSpellWatcher
end
self.SpellWatchers = SpellWatchers
end
-- --------------------------------------------------
-- > Class Power (Combo Points, Holy Power, etc...)
-- --------------------------------------------------
-- Colorize the last power color element
local function SetMaxClassPowerColor(element, max, powerType)
if not element or not max then return end
local color = element.__owner.colors.power.max[powerType]
if element[max] and color then
local r, g, b = color[1], color[2], color[3]
local LastBar = element[max]
LastBar:SetStatusBarColor(r, g, b)
local bg = LastBar.bg
if (bg) then
local mu = bg.multiplier or 1
bg:SetColorTexture(r * mu, g * mu, b * mu)
end
end
end
-- Post Update ClassPower
local function PostUpdateClassPower(element, cur, max, diff, powerType)
local frame = element.__owner.mystyle
if (diff) then
local maxWidth, gap = cfg.units[frame].width, 6
for i = 1, max do
local Bar = element[i]
Bar:SetWidth(((maxWidth / max) - (((max - 1) * gap) / max)))
if (i > 1) then
Bar:ClearAllPoints()
Bar:SetPoint("LEFT", element[i - 1], "RIGHT", gap, 0)
end
end
end
SetMaxClassPowerColor(element, max, powerType)
end
local function CreateClassPower(self)
local frame = self.mystyle
local ClassPower = {}
for i = 1, 10 do
local Bar = CreateFrame("StatusBar", "oUF_LumenClassPower" .. self.unit,
self, "BackdropTemplate")
Bar:SetHeight(cfg.units[frame].classpower.height)
Bar:SetStatusBarTexture(m.textures.status_texture)
api:SetBackdrop(Bar, 1.5, 1.5, 1.5, 1.5)
if (i > 1) then
Bar:SetPoint("LEFT", ClassPower[i - 1], "RIGHT", 6, 0)
else
local pos = cfg.units[frame].classpower.pos
Bar:SetPoint(pos.a1, self, pos.a2, pos.x, pos.y)
end
if (i > 5) then Bar:SetFrameLevel(Bar:GetFrameLevel() + 1) end
local Background = Bar:CreateTexture(nil, "BORDER")
Background:SetAllPoints()
Background:SetTexture(m.textures.bg_texture)
Background.multiplier = 0.2
Bar.bg = Background
ClassPower[i] = Bar
end
ClassPower.PostUpdate = PostUpdateClassPower
self.ClassPower = ClassPower
end
-- Death Knight Runebar
local function CreateRuneBar(self)
local frame = self.mystyle
local Runes = {}
Runes.sortOrder = "asc"
Runes.colorSpec = true
for i = 1, 6 do
local Rune = CreateFrame("StatusBar", "oUF_LumenRuneBar" .. self.unit,
self, "BackdropTemplate")
local numRunes, maxWidth, gap = 6, cfg.units[frame].width, 6
local width = ((maxWidth / numRunes) -
(((numRunes - 1) * gap) / numRunes))
Rune:SetSize(width, cfg.units[frame].classpower.height)
Rune:SetStatusBarTexture(m.textures.status_texture)
api:SetBackdrop(Rune, 1.5, 1.5, 1.5, 1.5)
if (i == 1) then
local pos = cfg.units[frame].classpower.pos
Rune:SetPoint(pos.a1, self, pos.a2, pos.x, pos.y)
else
Rune:SetPoint("LEFT", Runes[i - 1], "RIGHT", gap, 0)
end
local Background = Rune:CreateTexture(nil, "BORDER")
Background:SetAllPoints()
Background:SetTexture(m.textures.bg_texture)
Background.multiplier = 0.2
Rune.bg = Background
Runes[i] = Rune
end
self.Runes = Runes
end
-- Class Power (Combo Points, Runes, etc...)
function lum:CreateClassPower(self)
local frame = self.mystyle
if not self.unit or not frame then return end
if not cfg.units[frame].classpower.show then return end
if G.playerClass == "DEATHKNIGHT" then
CreateRuneBar(self)
else
CreateClassPower(self)
end
end
-- -----------------------------------
-- > Alternative Power
-- Quest or boss special power
-- -----------------------------------
local function AltPowerPostUpdate(self, unit, cur, min, max)
if self.__owner.unit ~= unit then return end
local _, r, g, b = GetUnitPowerBarTextureInfoByID(self.__barID, 2)
if (r == 1 and g == 1 and b == 1) or not b then r, g, b = .2, .8, 1 end
self:SetStatusBarColor(r, g, b)
if cur == max then return end
if cur < max then
if self.isMouseOver then
self.Text:SetFormattedText("(%s%%) %s / %s",
core:NumberToPerc(cur, max),
core:ShortNumber(cur),
core:ShortNumber(max))
else
self.Text:SetText()
end
elseif cur > 0 then
self.Text:SetFormattedText("%s", core:ShortNumber(cur))
else
if self.isMouseOver then
self.Text:SetFormattedText("%s", core:ShortNumber(cur))
else
self.Text:SetText()
end
end
end
local function AlternativePowerOnEnter(self)
if not self:IsVisible() then return end
self.isMouseOver = true
self:ForceUpdate()
_G.GameTooltip_SetDefaultAnchor(_G.GameTooltip, self)
self:UpdateTooltip()
end
local function AlternativePowerOnLeave(self)
self.isMouseOver = nil
self:ForceUpdate()
_G.GameTooltip:Hide()
end
function lum:CreateAlternativePower(self)
if cfg.elements.altpowerbar.show then
local AlternativePower = CreateFrame("StatusBar", nil, self)
AlternativePower:SetStatusBarTexture(m.textures.status_texture)
AlternativePower:SetHeight(18)
AlternativePower:SetWidth(200)
AlternativePower:SetPoint("CENTER", "UIParent", "CENTER", 0, 350)
AlternativePower:GetStatusBarTexture():SetHorizTile(false)
AlternativePower:SetStatusBarColor(.2, .8, 1)
AlternativePower.colorPower = true
api:SetBackdrop(AlternativePower, 2, 2, 2, 2, {0, 0, 0, 0.9})
local bg = AlternativePower:CreateTexture(nil, "BORDER")
bg:SetTexture(m.textures.bg_texture)
bg:SetAllPoints()
bg:SetAlpha(0.2)
AlternativePower.bg = bg
AlternativePower.Text = api:CreateFontstring(AlternativePower, font, 11,
"THINOUTLINE")
AlternativePower.Text:SetPoint("CENTER", 0, 0)
AlternativePower:EnableMouse(true)
AlternativePower:SetScript("OnEnter", AlternativePowerOnEnter)
AlternativePower:SetScript("OnLeave", AlternativePowerOnLeave)
AlternativePower.PostUpdate = AltPowerPostUpdate
self.AlternativePower = AlternativePower
end
end
-- ------------------------------------------
-- > Icon Indicators (Combat, Resting, etc.)
-- ------------------------------------------
function lum:CreatePlayerIconIndicators(self)
if not self.Health then return end
-- Combat indicator
local Combat =
api:CreateFontstring(self, m.fonts.symbols, 18, "THINOUTLINE")
Combat:SetPoint("RIGHT", self, "LEFT", -10, 0)
Combat:SetText("")
Combat:SetTextColor(255 / 255, 26 / 255, 48 / 255, 0.9)
self.CombatIndicator = Combat
-- Resting
if not api:IsPlayerMaxLevel() then
local Resting = api:CreateFontstring(self.Health, font,
cfg.fontsize - 2, "THINOUTLINE")
Resting:SetPoint("CENTER", self.Health, "TOP", 0, 1)
Resting:SetText("zZz")
Resting:SetTextColor(255 / 255, 255 / 255, 255 / 255, 0.80)
self.RestingIndicator = Resting
end
end
function lum:CreateTargetIconIndicators(self)
-- Quest Icon
local QuestIcon = api:CreateFontstring(self.Health, m.fonts.symbols, 18,
"THINOUTLINE")
QuestIcon:SetPoint("LEFT", self.Health, "RIGHT", 8, 0)
QuestIcon:SetText("")
QuestIcon:SetTextColor(238 / 255, 217 / 255, 43 / 255)
self.QuestIndicator = QuestIcon
-- Raid Icons
local RaidIcon = self:CreateTexture(nil, "OVERLAY")
RaidIcon:SetPoint("LEFT", self, "RIGHT", 8, 1)
RaidIcon:SetSize(20, 20)
self.RaidTargetIndicator = RaidIcon
end
-- ------------------------------------------
-- > Party / Raid
-- ------------------------------------------
-- Group Role Indicator
local function UpdateRoleIcon(self, event)
local lfdrole = self.GroupRoleIndicator
local role = UnitGroupRolesAssigned(self.unit)
-- Show roles when testing
if role == "NONE" and cfg.units.party.forceRole then
local rnd = random(1, 3)
role = rnd == 1 and "TANK" or
(rnd == 2 and "HEALER" or (rnd == 3 and "DAMAGER"))
end
if UnitIsConnected(self.unit) and role ~= "NONE" then
lfdrole:SetTexture(cfg.roleIconTextures[role])
lfdrole:SetVertexColor(unpack(cfg.roleIconColor[role]))
else
lfdrole:Hide()
end
end
function lum:CreateGroupRoleIndicator(self)
local roleIcon = self.Health:CreateTexture(nil, "OVERLAY")
roleIcon:SetPoint("LEFT", self, 8, 0)
roleIcon:SetSize(16, 16)
roleIcon.Override = UpdateRoleIcon
self:RegisterEvent("UNIT_CONNECTION", UpdateRoleIcon)
return roleIcon
end
-- ------------------------------------------
-- > Strings
-- ------------------------------------------
-- Name
function lum:CreateNameString(self, font, size, outline, x, y, point, width)
if not self.Health or not self.cfg.name.show then return end
local name = api:CreateFontstring(self.Health, font, size, outline)
name:SetPoint(point, self.Health, x, y)
name:SetJustifyH(point)
name:SetWidth(width)
name:SetHeight(size)
self:Tag(name, "[lum:level] [lum:name]")
self.Name = name
end
-- Party Name
function lum:CreatePartyNameString(self, font, size)
local name = api:CreateFontstring(self.Health, font, size, "THINOUTLINE")
name:SetPoint("TOPRIGHT", self, "TOPRIGHT", -4, -5)
name:SetJustifyH("RIGHT")
self:Tag(name, "[lum:playerstatus] [lum:leader] [lum:name]")
self.Name = name
end
-- Health Value
function lum:CreateHealthValueString(self, font, size, outline, x, y, point)
if not self.Health then return end
local health = self.Health
health.value = api:CreateFontstring(health, font, size, outline)
health.value:SetPoint(point, health, x, y)
health.value:SetJustifyH(point)
health.value:SetTextColor(1, 1, 1)
self:Tag(health.value, "[lum:hpvalue]")
end
-- Health Percent
function lum:CreateHealthPercentString(self, font, size, outline, x, y, point,
layer)
if not self.Health then return end
local health = self.Health
health.percent = api:CreateFontstring(health, font, size, outline, layer)
health.percent:SetPoint(point, health.value, x, y)
health.percent:SetJustifyH("RIGHT")
health.percent:SetTextColor(0.5, 0.5, 0.5, 0.5)
health.percent:SetShadowColor(0, 0, 0, 0)
self:Tag(health.percent, "[lum:hpperc]")
end
-- Power Value
function lum:CreatePowerValueString(self, font, size, outline, x, y, point)
local style = self.mystyle
if not self.Power or not cfg.units[style].power.text.show then return end
local power = self.Power
power.value = api:CreateFontstring(power, font, size, outline)
power.value:SetPoint(point, power, x, y)
power.value:SetJustifyH(point)
self:Tag(power.value, "[lum:powervalue]")
end
-- Classification
function lum:CreateClassificationString(self, font, size)
local clf = api:CreateFontstring(self, font, size, "THINOUTLINE")
clf:SetPoint("LEFT", self, "TOPLEFT", 0, 12)
clf:SetTextColor(1, 1, 1, 1)
self:Tag(clf, "[lum:classification]")
end
-- ------------------------------------------
-- > Addons (Experience, Reputation, etc.)
-- ------------------------------------------
-- oUF_Experience Tooltip
local function UpdateExperienceTooltip(self)
GameTooltip:SetOwner(self, "ANCHOR_NONE")
GameTooltip:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -8)
local isHonor = IsWatchingHonorAsXP()
local cur = (isHonor and UnitHonor or UnitXP)("player")
local max = (isHonor and UnitHonorMax or UnitXPMax)("player")
local per = math.floor(cur / max * 100 + 0.5)
local bars = cur / max * (isHonor and 5 or 20)
local rested = (isHonor and GetHonorExhaustion or GetXPExhaustion)() or 0
rested = math.floor(rested / max * 100 + 0.5)
if isHonor then
GameTooltip:SetText(string.format("Honor Rank %s",
UnitHonorLevel("player")))
GameTooltip:AddLine(string.format("|cffff4444%s / %s Points|r",
BreakUpLargeNumbers(cur),
BreakUpLargeNumbers(max)))
GameTooltip:AddLine(string.format(