forked from Resike/Z-Perl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZPerl_Highlight.lua
2008 lines (1792 loc) · 52.2 KB
/
ZPerl_Highlight.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
-- X-Perl UnitFrames
-- Author: Resike
-- License: GNU GPL v3, 29 June 2007 (see LICENSE.txt)
local playerClass, playerName, playerGUID
local conf
XPerl_RequestConfig(function(new)
conf = new
end, "$Revision: @file-revision@ $")
local _, _, _, clientRevision = GetBuildInfo()
local IsRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
local IsClassic = WOW_PROJECT_ID >= WOW_PROJECT_CLASSIC
local IsVanillaClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local _G = _G
local bit = bit
local cos = cos
local format = format
local math = math
local min = min
local next = next
local pairs = pairs
local random = random
local sin = sin
local strfind = strfind
local tinsert = tinsert
local tremove = tremove
local type = type
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
local CreateFrame = CreateFrame
local GetActiveSpecGroup = GetActiveSpecGroup
local GetNumGroupMembers = GetNumGroupMembers
local GetNumSpecializations = GetNumSpecializations
local GetNumSubgroupMembers = GetNumSubgroupMembers
local GetNumTalents = GetNumTalents
local GetSpellInfo = GetSpellInfo
local GetTalentInfo = GetTalentInfo
local GetTime = GetTime
local GetUnitName = GetUnitName
local IsInRaid = IsInRaid
local UnitAura = UnitAura
local UnitCastingInfo = UnitCastingInfo
local UnitClass = UnitClass
local UnitExists = UnitExists
local UnitGetIncomingHeals = UnitGetIncomingHeals
local UnitGUID = UnitGUID
local UnitHealth = UnitHealth
local UnitHealthMax = UnitHealthMax
local UnitInParty = UnitInParty
local UnitInRaid = UnitInRaid
local UnitIsDead = UnitIsDead
local UnitIsDeadOrGhost = UnitIsDeadOrGhost
local UnitIsGhost = UnitIsGhost
local UnitIsUnit = UnitIsUnit
local UnitName = UnitName
local UnitPlayerOrPetInParty = UnitPlayerOrPetInParty
local UnitPlayerOrPetInRaid = UnitPlayerOrPetInRaid
local SecureButton_GetUnit = SecureButton_GetUnit
local COMBATLOG_OBJECT_AFFILIATION_MINE = COMBATLOG_OBJECT_AFFILIATION_MINE
local COMBATLOG_OBJECT_AFFILIATION_PARTY = COMBATLOG_OBJECT_AFFILIATION_PARTY
local COMBATLOG_OBJECT_AFFILIATION_RAID = COMBATLOG_OBJECT_AFFILIATION_RAID
local COMBATLOG_OBJECT_FOCUS = COMBATLOG_OBJECT_FOCUS
local COMBATLOG_OBJECT_TARGET = COMBATLOG_OBJECT_TARGET
local UIParent = UIParent
local new, del, copy = XPerl_GetReusableTable, XPerl_FreeTable, XPerl_CopyTable
local hotSpells = XPERL_HIGHLIGHT_SPELLS.hotSpells
local pomSpells = XPERL_HIGHLIGHT_SPELLS.pomSpells
local shieldSpells = XPERL_HIGHLIGHT_SPELLS.shieldSpells
local function GetTalentPosition(findName)
for i = 1, GetNumSpecializations() do
for j = 1, GetNumTalents(i) do
local name = GetTalentInfo(i, j)
if (name == findName) then
return i, j
end
end
end
end
local function GetTalentValueByName(name)
if not name then
return 0
end
local group = GetActiveSpecGroup()
local tab, index = GetTalentPosition(name)
if (index) then
local name, iconPath, tier, column, currentRank, maxRank, isExceptional, meetsPrereq = GetTalentInfo(tab, index, nil, nil, group)
return currentRank
end
return 0
end
local function getTalentModifier(self)
if (self.improved) then
local spent = GetTalentValueByName(self.improved.name)
return 1 + (self.improved.percentPerRank * (spent or 0)) / 100
end
return 1
end
local function getRankAmount(self, spellId)
local amount = self.ranks[spellId]
if (amount) then
return amount * self:GetModifier()
end
end
local absorbSpells
if IsRetail then
absorbSpells = {
-- Shield Barrier
--[[[C_Spell.GetSpellInfo(174926) and C_Spell.GetSpellInfo(174926).name] = {
ranks = {
[174926] = 4459 --level 85 (4459 + $SPFR * 0.807)
},
school = "PHYSICAL",
class = "WARRIOR",
GetModifier = getTalentModifier,
GetRankAmount = getRankAmount,
},]]
-- Ice Barrier
[C_Spell.GetSpellInfo(11426) and C_Spell.GetSpellInfo(11426).name] = {
ranks = {
[11426] = 3686 --level 85 (3686 + $SPFR * 0.807)
},
school = "FROST",
class = "MAGE",
GetModifier = getTalentModifier,
GetRankAmount = getRankAmount,
},
-- Power Word: Shield
[C_Spell.GetSpellInfo(17) and C_Spell.GetSpellInfo(17).name] = {
ranks = {
[17] = 3906 --level 85 (3906 + ($SP * 0.418))
},
class = "PRIEST",
targetable = true,
school = "HOLY",
--[[improved = {
name = C_Spell.GetSpellInfo(14748) and C_Spell.GetSpellInfo(14748).name,
ranks = 2,
percentPerRank = 5,
},]]
GetModifier = getTalentModifier,
GetRankAmount = getRankAmount,
},
}
else
absorbSpells = {
-- Shield Barrier
--[[[GetSpellInfo(174926)] = {
ranks = {
[174926] = 4459 --level 85 (4459 + $SPFR * 0.807)
},
school = "PHYSICAL",
class = "WARRIOR",
GetModifier = getTalentModifier,
GetRankAmount = getRankAmount,
},]]
-- Ice Barrier
[GetSpellInfo(11426)] = {
ranks = {
[11426] = 3686 --level 85 (3686 + $SPFR * 0.807)
},
school = "FROST",
class = "MAGE",
GetModifier = getTalentModifier,
GetRankAmount = getRankAmount,
},
-- Power Word: Shield
[GetSpellInfo(17)] = {
ranks = {
[17] = 3906 --level 85 (3906 + ($SP * 0.418))
},
class = "PRIEST",
targetable = true,
school = "HOLY",
--[[improved = {
name = GetSpellInfo(14748),
ranks = 2,
percentPerRank = 5,
},]]
GetModifier = getTalentModifier,
GetRankAmount = getRankAmount,
},
}
end
local colours = {
HOT = {r = 0.2, g = 0.4, b = 0.8, canFlash = true},
POM = {r = 0.8, g = 0.6, b = 0.4},
SHIELD = {r = 0.6, g = 0.1, b = 0.6, canFlash = true},
AGGRO = {r = 0.8, g = 0, b = 0},
HEAL = {r = 0.2, g = 0.8, b = 0.2},
SEL = {r = 0.86, g = 0.82, b = 0.41},
TARGET = {r = 0.7167, g = 0.6833, b = 0.31467} -- Coloured so that colour * 1.2 == SEL colour
}
local xpHigh = CreateFrame("Frame", "XPerl_Highlight", nil, BackdropTemplateMixin and "BackdropTemplate")
xpHigh.list = {}
xpHigh.callbacks = {}
xpHigh.lastExpireCheck = 0
xpHigh.flashers = {}
xpHigh.mendingIcons = {}
xpHigh.shields = {}
-- rotate
-- Positive angle is clockwise rotation
local function rotate(angle)
local hcos = 0.5 * cos(angle)
local mhcos = -hcos
local hsin = 0.5 * sin(angle)
local mhsin = -hsin
local ULx, ULy, LLx, LLy = hcos - mhsin, mhsin + hcos, hcos - hsin, mhsin + mhcos
local URx, URy, LRx, LRy = mhcos - mhsin, hsin + hcos, mhcos - hsin, hsin + mhcos
return ULx + 0.5, ULy + 0.5, LLx + 0.5, LLy + 0.5, URx + 0.5, URy + 0.5, LRx + 0.5, LRy + 0.5
end
function xpHigh:Print(...)
ChatFrame1:AddMessage("|cFFFFFF80"..format(...))
end
-- XPerl_Highlight:Add
function xpHigh:Add(guid, highlightType, duration, source)
if (not guid) then
return
end
if (not strfind(guid, "-")) then
guid = self.lookup and self.lookup[guid]
end
local a = self.list[guid]
if (not a) then
a = new()
self.list[guid] = a
end
if (not duration) then
a[highlightType] = nil
self:Send(guid)
else
if (duration == 0) then
a[highlightType] = 0
self:Send(guid)
else
if (highlightType == "HOTCOUNT") then
a[highlightType] = duration
self:Send(guid)
else
local newEndTime = GetTime() + duration
if (highlightType == "HEAL" and (UnitInRaid(source) or UnitInParty(source))) then
if (source and not UnitIsUnit("player", source)) then
-- We'll query their cast bar and get accurate highlight time info
local spellName, text, texture, startTime, endTime = UnitCastingInfo(source)
if (spellName) then
newEndTime = endTime / 1000
end
--newEndTime = newEndTime + 0.8 -- Add some because other highlights expire 1 sec early
end
end
local current = a[highlightType]
if (not current or current < newEndTime) then
a[highlightType] = newEndTime
self:Send(guid)
end
end
end
end
end
-- xpHigh:TooltipInfo
function xpHigh:TooltipInfo(guid)
local effects = self.list[guid]
if (effects) then
local str = ""
local prefix = XPERL_LOC_STATUSTIP
for k,v in pairs(effects) do
local desc = XPERL_LOC_STATUSTIPLIST[k]
local c = colours[k]
if (desc and c) then
str = str..prefix..format("|c00%02X%02X%02X", 255 * c.r, 255 * c.g, 255 * c.b)..desc.."|r"
prefix = ", "
end
end
if (prefix == ", ") then
GameTooltip:AddLine("\r"..str)
GameTooltip:Show()
end
end
end
-- xpHigh:Remove
function xpHigh:Remove(guid, highlightType)
if (not guid) then
return
end
if (not strfind(guid, "-")) then
guid = self.lookup and self.lookup[guid]
end
local a = self.list[guid]
if (a) then
a[highlightType] = nil
self:Send(guid)
end
end
-- xpHigh:HasEffect
function xpHigh:HasEffect(guid, effect)
if (not guid) then
return
end
if (not strfind(guid, "-")) then
guid = self.lookup and self.lookup[guid]
end
local list = self.list[guid]
if (list) then
return list[effect]
end
end
-- xpHigh:OnUpdate
function xpHigh:OnUpdate(elapsed)
if (self.rosterUpdate) then
self.rosterUpdate = nil
self:RefreshAllAuras() -- New roster, get all
if (not (conf.highlight.enable and (conf.highlight.HOT or conf.highlight.SHIELD or conf.highlight.HEAL))) then
self:SetScript("OnUpdate", nil)
return
end
end
if (self.mendingAnimation) then
self:MendingAnimationOnUpdate(elapsed)
end
if (self.sparkleAreas) then
self:SparkleAreasOnUpdate(elapsed)
end
self.lastExpireCheck = self.lastExpireCheck + elapsed
if (self.lastExpireCheck > 0.2) then
self.lastExpireCheck = 0
else
return
end
-- We expire things 1 second early so people can cast in time for buff to expire
local now = GetTime() -- + 1
for guid, list in pairs(self.list) do
local any
for k, v in pairs(list) do
any = true
if (k ~= "HOTCOUNT") then
if (v > 0) then
if (v <= now) then
self.flashers[guid] = nil
list[k] = nil
self:Send(guid)
elseif (v <= now + 5 and colours[k] and colours[k].canFlash) then
if (not self.flashers[guid]) then
self.flashers[guid] = k
self:Send(guid)
end
end
end
end
end
if (not any) then
self.list[guid] = nil
self.flashers[guid] = nil
end
end
end
-- xpHigh:Query
function xpHigh:SetHighlight(frame, guid)
if (not frame.highlight) then
XPerl_Notice("No .highlight region for "..frame:GetName()..", unit: "..guid)
return
end
local unitid
if (not guid) then
unitid = SecureButton_GetUnit(frame)
if (unitid) then
guid = UnitGUID(unitid)
else
return
end
end
self:OnUpdate(0)
local hotCount, pomActive, hotBar, hotSparks, showShield
if (guid and conf.highlight.enable) then
local r = self.list[guid]
if (r) then
local r1, g1, b1, r2, g2, b2, t1
for k, v in pairs(r) do
if (k == "POM" and conf.highlight.sparkles) then
pomActive = true
elseif (k == "HOTCOUNT") then
hotCount = v
elseif (k == "HOT" and conf.highlight.sparkles) then
hotBar = true
elseif (k == "HOTSPARKS" and conf.highlight.extraSparkles) then
hotSparks = true
else
if (not r1 or t1 == "TARGET") then
if frame == XPerl_Player or frame == XPerl_Player_Pet or frame == XPerl_Target or frame == XPerl_TargetTarget or frame == XPerl_TargetTargetTarget or frame == XPerl_Focus or frame == XPerl_FocusTarget or frame == XPerl_partypet1 or frame == XPerl_partypet2 or frame == XPerl_partypet3 or frame == XPerl_partypet4 or frame == XPerl_partypet5 or strmatch(frame:GetName(), "XPerl_Raid_GrpPetsUnitButton") then
else
t1 = k
r1, g1, b1 = colours[k].r, colours[k].g, colours[k].b
end
else
r2, g2, b2 = colours[k].r, colours[k].g, colours[k].b
break
end
end
end
if (r1) then
frame.highlight.tex:Show()
frame.highlight.tex:SetAlpha(1)
if (frame.highlight.sel) then
r1 = min(r1 * 1.2, 1)
g1 = min(g1 * 1.2, 1)
b1 = min(b1 * 1.2, 1)
end
if (r2) then
if (frame.highlight.sel) then
r2 = min(r2 * 1.2, 1)
g2 = min(g2 * 1.2, 1)
b2 = min(b2 * 1.2, 1)
end
frame.highlight.tex:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, 1), CreateColor(r2, g2, b2, 1))
else
frame.highlight.tex:SetVertexColor(r1, g1, b1)
end
if (self.flashers[guid]) then
XPerl_FrameFlash(frame.highlight.tex)
else
XPerl_FrameFlashStop(frame.highlight.tex)
end
self:ShowHotCount(frame, hotCount)
self:ShowMending(frame, pomActive)
self:ShowHotBar(frame, hotBar)
self:ShowHotSparks(frame, hotSparks)
self:ShowShieldBar(frame, self.shields[guid])
return
end
end
end
self:RemoveHighlight(frame)
self:ShowHotCount(frame, hotCount)
self:ShowMending(frame, pomActive)
self:ShowHotBar(frame, hotBar)
self:ShowHotSparks(frame, hotSparks)
self:ShowShieldBar(frame, self.shields[guid])
end
-- fluctuateOnUpdate
local function fluctuateOnUpdate(self, elapsed)
if (self.fluctuate) then
if (self.fluctuate == "dim" or self.fluctuate == "notbright") then
self.fluctuatingBrightness = self.fluctuatingBrightness - elapsed
if (self.fluctuatingBrightness < 0.5) then
if (self.fluctuate == "dim") then
self.fluctuatingBrightness = 0.5
self.fluctuate = "notdim"
else
self.fluctuatingBrightness = nil
self.fluctuate = nil
end
end
elseif (self.fluctuate == "notdim" or self.fluctuate == "bright") then
self.fluctuatingBrightness = self.fluctuatingBrightness + elapsed
if (self.fluctuatingBrightness >= 1) then
if (self.fluctuate == "notdim") then
self.fluctuatingBrightness = nil
self.fluctuate = nil
else
self.fluctuatingBrightness = 1
self.fluctuate = "notbright"
end
end
end
elseif (random(10) == 1) then
self.fluctuate = random(3) == 2 and "dim" or "bright"
self.fluctuatingBrightness = 1
end
return self.fluctuatingBrightness or 1
end
-- hotBarOnUpdate
local function hotBarOnUpdate(self, elapsed)
local Min, Max = self:GetMinMaxValues()
local val = self:GetValue()
if (self.movementMod) then
val = val - elapsed
if (val <= 0) then
self:Hide()
return
end
self:SetValue(val)
end
local sparkPosition = self:GetWidth() * (val / Max)
self.spark:SetPoint("CENTER", self, "LEFT", sparkPosition, 0)
self.angle = self.angle + elapsed
if (self.angle > 360) then
self.angle = self.angle - 360
end
local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = rotate(self.angle)
self.spark:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy)
self.shine:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy)
local a
if (val < 5) then
if (self.alphaPulse == "in") then
a = self.alpha + elapsed * 2
if (a >= 1) then
a = 1
self.alphaPulse = "out"
end
else
a = self.alpha - elapsed * 2
if (a < 0.3) then
a = 0.3
self.alphaPulse = "in"
end
end
else
a = 1
self.alphaPulse = "out"
end
self.spark:SetVertexColor(1, 1, 1, a * fluctuateOnUpdate(self.spark, elapsed))
self.shine:SetVertexColor(1, 1, 1, a * fluctuateOnUpdate(self.shine, elapsed))
self.alpha = a
end
-- CreateShieldBar
function xpHigh:CreateShieldBar(frame)
local parent = frame.healthBar
if (not parent) then
parent = frame.statsFrame and frame.statsFrame.healthBar
end
if (not parent) then
return
end
local f = CreateFrame("StatusBar", nil, parent, BackdropTemplateMixin and "BackdropTemplate")
frame.highlight.shieldBar = f
f:SetPoint("BOTTOMLEFT")
f:SetPoint("TOPRIGHT", parent, "BOTTOMRIGHT", 0, 4)
f:SetMinMaxValues(0, 0.1)
f:Hide()
f.spark = self:CreateShine(f)
f.shine = self:CreateShine(f)
f.shine:SetPoint("CENTER", f, "LEFT")
f:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
f:GetStatusBarTexture():SetHorizTile(false)
f:GetStatusBarTexture():SetVertTile(false)
f:SetStatusBarColor(1, 0.4, 1)
f:SetScript("OnUpdate", hotBarOnUpdate)
f:SetScript("OnShow", function(self)
self.angle = 0
self.alpha = 1
self.alphaPulse = "out"
end)
end
-- TotalShield
function xpHigh:TotalShield(guid)
local list = self.shields[guid]
if (list) then
local total, maxAmount = 0, 0
for i, s in pairs(list) do
total = total + s.amount
maxAmount = maxAmount + s.maxAmount
end
return total, maxAmount
end
end
-- ShowHotBar
function xpHigh:ShowShieldBar(frame, show)
local h = frame.highlight
if (show and conf.highlight.SHIELD and conf.highlight.sparkles) then
local unit = SecureButton_GetUnit(frame)
local guid = unit and UnitGUID(unit)
if (guid) then
local shield = self.shields[guid]
if (shield) then
if (not h.shieldBar) then
self:CreateShieldBar(frame)
end
h.shieldBar.unit = unit
local cur, max = self:TotalShield(guid)
h.shieldBar:SetMinMaxValues(0, max)
h.shieldBar:SetValue(cur)
h.shieldBar:Show()
return
end
end
end
if (h.shieldBar) then
h.shieldBar:Hide()
h.shieldBar:SetMinMaxValues(0, 0.1)
end
end
-- CreateShine
function xpHigh:CreateShine(parent)
local shine = parent:CreateTexture(nil, "OVERLAY")
shine:SetTexture(166928)
shine:SetBlendMode("ADD")
shine:SetWidth(12)
shine:SetHeight(12)
return shine
end
-- CreateHotBar
function xpHigh:CreateHotBar(frame)
local parent = frame.healthBar
if (not parent) then
parent = frame.statsFrame and frame.statsFrame.healthBar
end
if (not parent) then
return
end
local f = CreateFrame("StatusBar", nil, parent, BackdropTemplateMixin and "BackdropTemplate")
frame.highlight.hotBar = f
f:SetPoint("TOPLEFT")
f:SetPoint("BOTTOMRIGHT", parent, "TOPRIGHT", 0, -4)
f:SetMinMaxValues(0, 0.1)
f:Hide()
f.movementMod = 1
f.spark = self:CreateShine(f)
f.shine = self:CreateShine(f)
f.shine:SetPoint("CENTER", f, "LEFT")
f:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
f:GetStatusBarTexture():SetHorizTile(false)
f:GetStatusBarTexture():SetVertTile(false)
f:SetStatusBarColor(1, 1, 0)
f:SetScript("OnUpdate", hotBarOnUpdate)
f:SetScript("OnShow", function(self)
self.angle = 0
self.alpha = 1
self.alphaPulse = "out"
end)
end
-- GetMyHotTime
function xpHigh:GetMyHotTime(unit)
local maxDur, maxTimeLeft = 0, 0
for i = 1, 40 do
local name, duration, expirationTime
if C_UnitAuras then
local auraData = C_UnitAuras.GetAuraDataByIndex(unit, i, "HELPFUL|PLAYER")
if auraData then
name = auraData.name
duration = auraData.duration
expirationTime = auraData.expirationTime
end
else
local _
name, _, _, _, duration, expirationTime = UnitAura(unit, i, "HELPFUL|PLAYER")
end
if (not name) then
break
end
if (hotSpells[name]) then
local timeLeft = expirationTime - GetTime()
if (timeLeft > maxTimeLeft) then
maxDur, maxTimeLeft = duration, timeLeft
end
end
end
return maxDur, maxTimeLeft
end
-- ShowHotBar
function xpHigh:ShowHotBar(frame, show)
local h = frame.highlight
if (show and conf.highlight.HOT and conf.highlight.sparkles) then
local unit = SecureButton_GetUnit(frame)
if (unit) then
local dur, timeLeft = self:GetMyHotTime(unit)
if (dur and dur > 0) then
if (not h.hotBar) then
self:CreateHotBar(frame)
end
local a, b = h.hotBar:GetMinMaxValues()
if (b > dur) then
-- Changing HOTs shouldn't make the bar jump with varying buff durations, just use the max so far.
dur = b
end
h.hotBar.unit = unit
h.hotBar:SetMinMaxValues(0, dur)
h.hotBar:SetValue(timeLeft)
h.hotBar:Show()
return
end
end
end
if (h.hotBar) then
h.hotBar:Hide()
h.hotBar:SetMinMaxValues(0, 0.1)
end
end
-- xpHigh:CreateHotCount(frame)
function xpHigh:CreateHotCount(frame)
local f = frame.highlight:CreateFontString(nil, "OVERLAY", "NumberFontNormalLarge")
frame.highlight.hot = f
f:SetTextColor(0, 1, 0)
f:Hide()
local sf = _G[frame:GetName().."statsFrame"]
if (sf) then
if (strfind(frame:GetName(), "XPerl_Raid_Grp")) then
f:SetTextHeight(15)
f:SetPoint("TOPLEFT", sf, "TOPLEFT", 3, -3)
else
f:SetPoint("TOPLEFT", sf, "TOPLEFT", 5, -8)
end
else
if (strfind(frame:GetName(), "XPerl_Raid_GrpPets")) then
f:SetTextHeight(15)
f:SetPoint("TOPLEFT", 3, -3)
else
f:SetPoint("CENTER", 0, 0)
end
end
end
-- xpHigh:HasMyHOT(unit)
function xpHigh:HasMyHOT(unit)
for i = 1, 40 do
local name
if C_UnitAuras then
local auraData = C_UnitAuras.GetAuraDataByIndex(unit, i, "HELPFUL|PLAYER")
if auraData then
name = auraData.name
end
else
name = UnitAura(unit, i, "HELPFUL|PLAYER")
end
if not name then
break
end
if hotSpells[name] then
return true
end
end
end
-- ShowHotCount
function xpHigh:ShowHotCount(frame, hotCount, unitid)
local h = frame.highlight
if (conf.highlight.HOTCOUNT) then
if (hotCount and hotCount > 0) then
if (not h.hot) then
self:CreateHotCount(frame)
end
h.hot:SetText(hotCount)
h.hot:Show()
local unit = SecureButton_GetUnit(frame)
if (unit and self:HasMyHOT(unit)) then
h.hot:SetTextColor(0, 1, 0)
else
h.hot:SetTextColor(0.8, 0, 0)
end
return
end
end
if (h.hot) then
h.hot:Hide()
end
end
-- GetMyPomEndTime
function xpHigh:GetMyPomEndTime(unit)
for i = 1, 40 do
local name, expirationTime
if C_UnitAuras then
local auraData = C_UnitAuras.GetAuraDataByIndex(unit, i, "HELPFUL|PLAYER")
if auraData then
name = auraData.name
expirationTime = auraData.expirationTime
end
else
local _
name, _, _, _, _, expirationTime = UnitAura(unit, i, "HELPFUL|PLAYER")
end
if (not name) then
break
end
if (pomSpells[name]) then
return expirationTime
end
end
end
-- ShowMending
function xpHigh:ShowMending(frame, show)
local h = frame.highlight
if (show and conf.highlight.POM and conf.highlight.sparkles) then
if (not h.mending or not h.mending:GetParent():IsShown()) then
self:CreateMendingIcon(frame)
end
if (h.mending) then
local unit = SecureButton_GetUnit(frame)
if (unit) then
h.mending.endTime = self:GetMyPomEndTime(unit) or 30
h.mending:Show()
end
end
return
end
if (h.mending) then
h.mending:Hide()
tinsert(self.mendingIcons, h.mending)
h.mending = nil
end
end
-- mendingOnUpdate
local function mendingOnUpdate(self, elapsed)
if (self.shineMode == "in") then
self.shineAlpha = self.shineAlpha + elapsed
if (self.shineAlpha >= 1) then
self.shineAlpha = 1
self.shineMode = "out"
end
else
self.shineAlpha = self.shineAlpha - elapsed
if (self.shineAlpha <= 0.3) then
self.shineAlpha = 0.3
self.shineMode = "in"
end
end
self.shineAngle = self.shineAngle + elapsed * 3
if (self.shineAngle > 360) then
self.shineAngle = self.shineAngle - 360
end
self.shine:SetTexCoord(rotate(self.shineAngle))
self.shine:SetVertexColor(1, 1, 1, self.shineAlpha)
if (GetTime() > self.endTime - 5) then
self:SetAlpha(self.shineAlpha)
else
self:SetAlpha(1)
end
end
-- CreateMendingIcon
function xpHigh:CreateMendingIcon(frame)
local h = frame.highlight
local p = frame.statsFrame -- or frame
local anchor = "CENTER"
local anchorRel = "TOP"
local anchorRelP = p
local sizeMod = -8
local xOffset, yOffset = 0, 0
if (p) then
p = p.healthBar or p
if (strfind(p:GetName(), "^XPerl_Raid")) then
sizeMod = 0
yOffset = -2
else
sizeMod = 10
yOffset = -4
end
end
if (h and p) then
local icon = h.mending
if (not icon) then
icon = tremove(self.mendingIcons, 1)
h.mending = icon
end
if (icon) then
-- Re-parent
icon:SetParent(p)
icon:ClearAllPoints()
else
icon = CreateFrame("Frame", nil, p, BackdropTemplateMixin and "BackdropTemplate")
h.mending = icon
icon.tex = icon:CreateTexture(nil, "BACKGROUND")
icon.tex:SetAllPoints()
local _, class = UnitClass("player")
if class == "MONK" then
if IsRetail then
local itemInfo = C_Spell.GetSpellInfo(115151)
if itemInfo and itemInfo.iconID then
icon.tex:SetTexture(itemInfo.iconID)
end
else
local _, _, texture = GetSpellInfo(115151)
icon.tex:SetTexture(texture)
end
elseif class == "PALADIN" then
if IsRetail then
local itemInfo = C_Spell.GetSpellInfo(157007)
if itemInfo and itemInfo.iconID then
icon.tex:SetTexture(itemInfo.iconID)
end
else
local _, _, texture = GetSpellInfo(157007)
icon.tex:SetTexture(texture)
end
else
if IsRetail then
local itemInfo = C_Spell.GetSpellInfo(33076)
if itemInfo and itemInfo.iconID then
icon.tex:SetTexture(itemInfo.iconID)
end
else
local _, _, texture = GetSpellInfo(33076)
icon.tex:SetTexture(texture)
end
end
icon.tex:SetTexCoord(0.1, 0.9, 0.1, 0.9)
icon.shine = self:CreateShine(icon)
icon.shine:SetPoint("TOPLEFT", -5, 5)
icon.shine:SetPoint("BOTTOMRIGHT", 5, -5)
end
icon:SetWidth(p:GetHeight() + sizeMod)
icon:SetHeight(p:GetHeight() + sizeMod)
icon:SetPoint(anchor, anchorRelP, anchorRel, xOffset, yOffset)
icon:Hide()
local x1, y1 = icon:GetCenter()
local x2, y2 = frame:GetCenter()
if x1 and x2 and y1 and y2 then
frame.lastPomPosX = x1 - x2
frame.lastPomPosY = y1 - y2
end
icon.shine:Show()
icon.shine:SetVertexColor(1, 1, 1, 0)
icon:SetScript("OnUpdate", mendingOnUpdate)
icon:SetScript("OnShow", function(self)
self.shineAngle = 0