This repository has been archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.lua
1216 lines (1092 loc) · 41.6 KB
/
lib.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
--[[
To Do:
Clean up Harmony bar... its functioning so hooray for that!
Clean up Shard bar... again functioning so yay!
]]
--
local addon, ns = ...
local cfg = ns.cfg
local cast = ns.cast
local lib = CreateFrame("Frame")
local _, playerClass = UnitClass("player")
oUF.colors.power['MANA'] = {0.0, 0.56, 1.0}
oUF.colors.power['RAGE'] = {1.0, 0, 0}
oUF.colors.power['FOCUS'] = {1.0, 0.75, 0.25}
oUF.colors.power['ENERGY'] = {0.65, 0.65, 0.35}
oUF.colors.power['ENERGY'] = {0.65, 0.65, 0.35}
oUF.colors.power['RUNIC_POWER'] = {0.44, 0.44, 0.44}
oUF.colors.power['AMMOSLOT'] = {0.8, 0.6, 0}
oUF.colors.power['FUEL'] = {0, 0.55, 0.5}
oUF.colors.power['POWER_TYPE_STEAM'] = {0.55, 0.57, 0.61}
oUF.colors.power['POWER_TYPE_PYRITE'] = {0.6, 0.09, 0.17}
oUF.colors.power['POWER_TYPE_HEAT'] = {0.9, 0.45, 0.1}
oUF.colors.power['POWER_TYPE_OOZE'] = {0.1, 0.1, 0.9}
oUF.colors.power['POWER_TYPE_BLOOD_POWER'] = {0.9, 0.1, 0.1}
local _, pType = UnitPowerType("player")
local pcolor = oUF.colors.power[pType] or {.3, .45, .65}
oUF.colors.runes = {{196 / 255, 30 / 255, 58 / 255}; {173 / 255, 217 / 255, 25 / 255}; {35 / 255, 127 / 255, 255 / 255}; {178 / 255, 53 / 255, 240 / 255}; }
-- FUNCTIONS
local retVal = function(f, val1, val2, val3)
if f.mystyle == "player" or f.mystyle == "target" then
return val1
elseif f.mystyle == "raid" or f.mystyle == "party" then
return val3
else
return val2
end
end
--status bar filling fix (from oUF_Mono)
local fixStatusbar = function(b)
b:GetStatusBarTexture():SetHorizTile(false)
b:GetStatusBarTexture():SetVertTile(false)
end
--backdrop table
local backdrop_tab = {
bgFile = cfg.backdrop_texture,
edgeFile = cfg.backdrop_edge_texture,
tile = false,
tileSize = 0,
edgeSize = 5,
insets = {
left = 3,
right = 3,
top = 3,
bottom = 3,
},
}
-- backdrop func
lib.gen_backdrop = function(f)
f:SetBackdrop(backdrop_tab);
f:SetBackdropColor(0, 0, 0, 1)
f:SetBackdropBorderColor(0, 0, 0, 0.8)
end
lib.gen_castbackdrop = function(f)
f:SetBackdrop(backdrop_tab);
f:SetBackdropColor(0, 0, 0, 0.6)
f:SetBackdropBorderColor(0, 0, 0, 1)
end
lib.gen_totemback = function(f)
f:SetBackdrop(backdrop_tab);
f:SetBackdropColor(0, 0, 0, 0.6)
f:SetBackdropBorderColor(0, 0, 0, 0.8)
end
lib.gen_classback = function(f)
f:SetBackdrop(backdrop_tab);
f:SetBackdropColor(0, 0, 0, 0.2)
f:SetBackdropBorderColor(0, 0, 0, 0.7)
end
-- Right Click Menu
lib.spawnMenu = 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") 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)
elseif unit == "raid" then
FriendsDropDown.unit = self.unit
FriendsDropDown.id = self.id
FriendsDropDown.initialize = RaidFrameDropDown_Initialize
ToggleDropDownMenu(1, nil, FriendsDropDown, "cursor")
end
end
--fontstring func
lib.gen_fontstring = function(f, name, size, outline)
local fs = f:CreateFontString(nil, "OVERLAY")
fs:SetFont(name, size, outline)
fs:SetShadowColor(0, 0, 0, 0.8)
fs:SetShadowOffset(1, -1)
return fs
end
--gen healthbar func
lib.gen_hpbar = function(f)
--statusbar
local s = CreateFrame("StatusBar", nil, f)
s:SetStatusBarTexture(cfg.statusbar_texture)
s:GetStatusBarTexture():SetHorizTile(true)
s:SetHeight(retVal(f, 24, 24, 20))
s:SetWidth(f:GetWidth())
s:SetPoint("TOP", 0, 0)
s:SetFrameLevel(6)
--helper
local h = CreateFrame("Frame", nil, s)
h:SetFrameLevel(5)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_backdrop(h)
--bg
local b = s:CreateTexture(nil, "BACKGROUND")
b:SetTexture(cfg.statusbar_texture)
b:SetAllPoints(s)
b:SetVertexColor(1, 0.1, 0.1, 1)
f.Health = s
f.Health.bg2 = b
end
--gen hp strings func
lib.gen_hpstrings = function(f, unit)
--creating helper frame here so our font strings don't inherit healthbar parameters
local h = CreateFrame("Frame", nil, f)
h:SetAllPoints(f.Health)
h:SetFrameLevel(15)
local fontsize
if f.mystyle == "player" then fontsize = 36
elseif f.mystyle == "target" then fontsize = 18
elseif f.mystyle == "raid" or f.mystyle == "party" then fontsize = 15
else fontsize = 16
end
local name = lib.gen_fontstring(f.Health, cfg.font, retVal(f, 18, 16, 15), "THINOUTLINE")
if f.mystyle == "player" then
name:SetPoint("RIGHT", f.Health, "RIGHT", 0, 0)
name:SetJustifyH("RIGHT")
elseif f.mystyle == "raid" or f.mystyle == "party" then
name:SetPoint("LEFT", f.Health, "LEFT", 0, 2)
name:SetJustifyH("LEFT")
else
name:SetPoint("LEFT", f.Health, "TOPLEFT", 2, 1)
name:SetJustifyH("LEFT")
end
local hpval = lib.gen_fontstring(f.Health, cfg.font, fontsize, "THINOUTLINE")
if f.mystyle == "player" then
hpval:SetPoint("LEFT", f.Health, "LEFT", 2, 0)
hpval:SetJustifyH("LEFT")
elseif f.mystyle == "raid" or f.mystyle == "party" then
hpval:SetPoint("RIGHT", f.Health, "RIGHT", 6, -8)
hpval:SetJustifyH("LEFT")
else
hpval:SetPoint("RIGHT", f.Health, "TOPRIGHT", retVal(f, 2, -3, -3), retVal(f, -12, -10, -17))
end
if f.mystyle == "player" then
name:SetPoint("RIGHT", f, "RIGHT", 0, -12)
elseif f.mystyle == "raid" or f.mystyle == "party" then
name:SetPoint("CENTER", f, "CENTER", 0, 6)
elseif f.mystyle == "target" or f.mystyle == "pet" then
name:SetPoint("RIGHT", f, "RIGHT", 0, -12)
else
name:SetPoint("RIGHT", hpval, "LEFT", -2, 0)
end
if f.mystyle == "player" then
f:Tag(name, "[karma:pp]")
elseif f.mystyle == "target" then
f:Tag(name, "[karma:level] [karma:color][name]")
elseif f.mystyle == "raid" or f.mystyle == "party" then
f:Tag(name, "[karma:color][name]")
else
f:Tag(name, "[karma:color][name]")
end
if f.mystyle == "player" then
f:Tag(hpval, "[karma:color][karma:hp]")
else
f:Tag(hpval, retVal(f, "[karma:hp]", "[karma:hp]", "[karma:raidhp]"))
end
local level
if f.mystyle == "player" then level = lib.gen_fontstring(f.Health, cfg.font, fontsize / 2, "THINOUTLINE")
elseif f.mystyle == "target" then level = lib.gen_fontstring(f.Health, cfg.font, 12, "THINOUTLINE")
elseif f.mystyle == "party" then level = lib.gen_fontstring(f.Health, cfg.font, 12, "THINOUTLINE")
end
if f.mystyle == "player" and cfg.ShowPlayerName then
level:SetPoint("TOPRIGHT", f.Health, "TOPRIGHT", 0, 10)
level:SetJustifyH("RIGHT")
elseif f.mystyle == "target" and cfg.ShowTargetPower then
level:SetPoint("BOTTOMRIGHT", f.Health, "BOTTOMRIGHT", 22, -14)
level:SetJustifyH("RIGHT")
elseif f.mystyle == "party" then
level:SetPoint("TOPRIGHT", f.Health, "TOPRIGHT", 8, 4)
level:SetJustifyH("RIGHT")
end
if f.mystyle == "player" and cfg.ShowPlayerName then
f:Tag(level, "[karma:level] [karma:color][name]")
elseif f.mystyle == "target" and cfg.ShowTargetPower then
f:Tag(level, "[karma:pp]")
elseif f.mystyle == "party" then
f:Tag(level, "[karma:level]")
end
end
--gen powerbar func
lib.gen_ppbar = function(f)
--statusbar
local s = CreateFrame("StatusBar", nil, f)
s:SetStatusBarTexture(cfg.powerbar_texture)
s:GetStatusBarTexture():SetHorizTile(true)
s:SetWidth(f:GetWidth())
s:SetHeight(retVal(f, 12, 10, 10))
if f.mystyle == "target" or f.mystyle == "tot" or f.mystyle == "focustarget" then
s:SetPoint("BOTTOM", f, "BOTTOM", -4, 0)
else
s:SetPoint("BOTTOM", f, "BOTTOM", 4, 0)
end s:SetFrameLevel(4)
s:SetFrameLevel(4)
--helper
local h = CreateFrame("Frame", nil, s)
h:SetFrameLevel(3)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_backdrop(h)
--bg
local b = s:CreateTexture(nil, "BACKGROUND")
b:SetTexture(cfg.powerbar_texture)
b:SetAllPoints(s)
f.Power = s
f.Power.bg = b
end
--gen combat and LFD icons
lib.gen_InfoIcons = function(f)
local h = CreateFrame("Frame", nil, f)
h:SetAllPoints(f)
h:SetFrameLevel(10)
--combat icon
if f.mystyle == 'player' then
f.CombatIndicator = h:CreateTexture(nil, 'OVERLAY')
f.CombatIndicator:SetSize(16, 16)
f.CombatIndicator:SetPoint('LEFT', -4, -12)
f.CombatIndicator:SetTexture([[Interface\Addons\oUF_Karma\media\combat]])
end
-- rest icon
if f.mystyle == 'player' then
f.RestingIndicator = h:CreateTexture(nil, 'OVERLAY')
f.RestingIndicator:SetSize(24, 24)
f.RestingIndicator:SetPoint('TOPLEFT', -8, 16)
f.RestingIndicator:SetTexture([[Interface\Addons\oUF_Karma\media\resting]])
f.RestingIndicator:SetAlpha(0.75)
end
--Leader icon
li = h:CreateTexture(nil, "OVERLAY")
li:SetPoint("TOPLEFT", f, -4, 10)
li:SetSize(16, 16)
f.LeaderIndicator = li
--Assist icon
ai = h:CreateTexture(nil, "OVERLAY")
ai:SetPoint("TOPLEFT", f, 0, 8)
ai:SetSize(12, 12)
f.AssistantIndicator = ai
--ML icon
local ml = h:CreateTexture(nil, 'OVERLAY')
ml:SetSize(16, 16)
ml:SetPoint('LEFT', f.LeaderIndicator, 'RIGHT')
f.MasterLooterIndicator = ml
end
-- LFG Role Indicator
lib.gen_LFDRole = function(f)
local lfdi = lib.gen_fontstring(f.Health, cfg.smallfont, 10, "THINOUTLINE")
lfdi:SetPoint('BOTTOM', f.Health, 'TOP', 0, 4)
f:Tag(lfdi, "[karma:lfdrole]")
end
-- phase icon
lib.addPhaseIcon = function(self)
local picon = self.Health:CreateTexture(nil, 'OVERLAY')
picon:SetPoint('TOPRIGHT', self, 'TOPRIGHT', 40, 8)
picon:SetSize(16, 16)
self.PhaseIndicator = picon
end
-- quest icon
lib.addQuestIcon = function(self)
local qicon = self.Health:CreateTexture(nil, 'OVERLAY')
qicon:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 8)
qicon:SetSize(16, 16)
self.QuestIndicator = qicon
end
--gen raid mark icons
lib.gen_RaidMark = function(f)
local h = CreateFrame("Frame", nil, f)
h:SetAllPoints(f)
h:SetFrameLevel(10)
h:SetAlpha(0.8)
local ri = h:CreateTexture(nil, 'OVERLAY', h)
ri:SetPoint("CENTER", f, "TOP", 0, 2)
local size = retVal(f, 16, 13, 12)
ri:SetSize(size, size)
f.RaidTargetIndicator = ri
end
--gen hilight texture
lib.gen_highlight = function(f)
local OnEnter = function(f)
UnitFrame_OnEnter(f)
f.Highlight:Show()
end
local OnLeave = function(f)
UnitFrame_OnLeave(f)
f.Highlight:Hide()
end
f:SetScript("OnEnter", OnEnter)
f:SetScript("OnLeave", OnLeave)
local hl = f.Health:CreateTexture(nil, "OVERLAY")
hl:SetAllPoints(f.Health)
hl:SetTexture(cfg.highlight_texture)
hl:SetVertexColor(.5, .5, .5, .1)
hl:SetBlendMode("ADD")
hl:Hide()
f.Highlight = hl
end
-- Create Target Border
function lib.CreateTargetBorder(self)
local glowBorder = {edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 2}
self.TargetBorder = CreateFrame("Frame", nil, self)
self.TargetBorder:SetPoint("TOPLEFT", self.Health, "TOPLEFT", -4, 4)
self.TargetBorder:SetPoint("BOTTOMRIGHT", self.Health, "BOTTOMRIGHT", 5, -8)
self.TargetBorder:SetBackdrop(glowBorder)
self.TargetBorder:SetFrameLevel(2)
self.TargetBorder:SetBackdropBorderColor(1.0, 1.0, 0.1, 0.6)
self.TargetBorder:Hide()
end
-- Raid Frames Target Highlight Border
function lib.ChangedTarget(self, event, unit)
if UnitIsUnit('target', self.unit) then
self.TargetBorder:Show()
else
self.TargetBorder:Hide()
end
end
-- Create Raid Threat Status Border
function lib.CreateThreatBorder(self)
local glowBorder = {edgeFile = cfg.backdrop_edge_texture, edgeSize = 5}
self.Thtborder = CreateFrame("Frame", nil, self)
self.Thtborder:SetPoint("TOPLEFT", self, "TOPLEFT", -8, 9)
self.Thtborder:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 9, -8)
self.Thtborder:SetBackdrop(glowBorder)
self.Thtborder:SetFrameLevel(1)
self.Thtborder:Hide()
end
-- Raid Frames Threat Highlight
function lib.UpdateThreat(self, event, unit)
if (self.unit ~= unit) then return end
local status = UnitThreatSituation(unit)
unit = unit or self.unit
if status and status > 1 then
local r, g, b = GetThreatStatusColor(status)
self.Thtborder:Show()
self.Thtborder:SetBackdropBorderColor(r, g, b, 1)
else
self.Thtborder:SetBackdropBorderColor(r, g, b, 0)
self.Thtborder:Hide()
end
end
--gen castbar
local PostCastStart = function(castbar, unit)
if unit ~= 'player' then
if castbar.interrupt then
castbar.Backdrop:SetBackdropBorderColor(1, .9, .4)
castbar.Backdrop:SetBackdropColor(1, .9, .4)
else
castbar.Backdrop:SetBackdropBorderColor(0, 0, 0)
castbar.Backdrop:SetBackdropColor(0, 0, 0)
end
end
end
local CustomTimeText = function(castbar, duration)
if castbar.casting then
castbar.Time:SetFormattedText("%.1f / %.1f", duration, castbar.max)
elseif castbar.channeling then
castbar.Time:SetFormattedText("%.1f / %.1f", castbar.max - duration, castbar.max)
end
end
--gen castbar
lib.gen_castbar = function(f)
if not cfg.Castbars then return end
local cbColor = {95 / 255, 182 / 255, 255 / 255}
local s = CreateFrame("StatusBar", "oUF_karmaCastbar" .. f.mystyle, f)
s:SetHeight(16)
s:SetWidth(f:GetWidth() - 30)
if f.mystyle == "player" then
s:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 0, -31)
elseif f.mystyle == "target" then
s:SetPoint("BOTTOM", f, "TOP", 15, 48)
elseif f.mystyle == "focus" then
s:SetPoint("BOTTOM", f, "TOP", 15, 10)
elseif f.mystyle == "boss" then
s:SetPoint("BOTTOM", f, "TOP", 15, 15)
else
s:SetPoint("BOTTOM", f, "TOP", 15, 42)
end
s:SetStatusBarTexture(cfg.statusbar_texture)
s:SetStatusBarColor(95 / 255, 182 / 255, 255 / 255, 1)
s:SetFrameLevel(1)
--color
s.CastingColor = cbColor
s.CompleteColor = {20 / 255, 208 / 255, 0 / 255}
s.FailColor = {255 / 255, 12 / 255, 0 / 255}
s.ChannelingColor = cbColor
--helper
local h = CreateFrame("Frame", nil, s)
h:SetFrameLevel(0)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_castbackdrop(h)
--spark
sp = s:CreateTexture(nil, "OVERLAY")
sp:SetTexture(spark)
sp:SetBlendMode("ADD")
sp:SetVertexColor(1, 1, 1, 1)
sp:SetHeight(s:GetHeight() * 2.5)
sp:SetWidth(s:GetWidth() / 18)
--spell text
local txt = lib.gen_fontstring(s, cfg.font, 16, "THINOUTLINE")
txt:SetPoint("LEFT", 2, 10)
txt:SetJustifyH("LEFT")
--time
local t = lib.gen_fontstring(s, cfg.font, 18, 'THINOUTLINE')
t:SetPoint("RIGHT", -2, 0)
txt:SetPoint("RIGHT", t, "LEFT", -5, 0)
--icon
local i = s:CreateTexture(nil, "ARTWORK")
i:SetSize(24, 24)
i:SetPoint("BOTTOMRIGHT", s, "BOTTOMLEFT", -6, 0)
i:SetTexCoord(0.1, 0.9, 0.1, 0.9)
--helper2 for icon
local h2 = CreateFrame("Frame", nil, s)
h2:SetFrameLevel(0)
h2:SetPoint("TOPLEFT", i, "TOPLEFT", -5, 5)
h2:SetPoint("BOTTOMRIGHT", i, "BOTTOMRIGHT", 5, -5)
lib.gen_backdrop(h2)
if f.mystyle == "player" then
--latency (only for player unit)
local z = s:CreateTexture(nil, "OVERLAY")
z:SetTexture(cfg.statusbar_texture)
z:SetVertexColor(1, 0.1, 0, .6)
z:SetPoint("TOPRIGHT")
z:SetPoint("BOTTOMRIGHT")
s:SetFrameLevel(1)
s.SafeZone = z
-- custom latency display
local l = lib.gen_fontstring(s, cfg.font, 10, "THINOUTLINE")
l:SetPoint("CENTER", -2, 17)
l:SetJustifyH("RIGHT")
l:Hide()
s.Lag = l
-- f:RegisterEvent("UNIT_SPELLCAST_SENT", cast.OnCastSent) --removed with 8.0
end
s.OnUpdate = cast.OnCastbarUpdate
s.PostCastStart = cast.PostCastStart
s.PostChannelStart = cast.PostCastStart
s.PostCastStop = cast.PostCastStop
s.PostChannelStop = cast.PostChannelStop
s.PostCastFailed = cast.PostCastFailed
s.PostCastInterrupted = cast.PostCastFailed
f.Castbar = s
f.Castbar.Text = txt
f.Castbar.Time = t
f.Castbar.Icon = i
f.Castbar.Spark = sp
end
-- mirror castbar!
lib.gen_mirrorcb = function(f)
for _, bar in pairs({'MirrorTimer1', 'MirrorTimer2', 'MirrorTimer3', }) do
for i, region in pairs({_G[bar]:GetRegions()}) do
if (region.GetTexture and region:GetTexture() == 'SolidTexture') then
region:Hide()
end
end
_G[bar .. 'Border']:Hide()
_G[bar]:SetParent(UIParent)
_G[bar]:SetScale(1)
_G[bar]:SetHeight(16)
_G[bar]:SetWidth(280)
_G[bar]:SetBackdropColor(.1, .1, .1)
_G[bar .. 'Background'] = _G[bar]:CreateTexture(bar .. 'Background', 'BACKGROUND', _G[bar])
_G[bar .. 'Background']:SetTexture(cfg.statusbar_texture)
_G[bar .. 'Background']:SetAllPoints(bar)
_G[bar .. 'Background']:SetVertexColor(.15, .15, .15, .75)
_G[bar .. 'Text']:SetFont(cfg.font, 14)
_G[bar .. 'Text']:ClearAllPoints()
_G[bar .. 'Text']:SetPoint('CENTER', MirrorTimer1StatusBar, 0, 1)
_G[bar .. 'StatusBar']:SetAllPoints(_G[bar])
--glowing borders
local h = CreateFrame("Frame", nil, _G[bar])
h:SetFrameLevel(0)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_backdrop(h)
end
end
-- Post Create Icon Function
local myPostCreateIcon = function(self, button)
self.showDebuffType = true
self.disableCooldown = true
button.cd.noOCC = true
button.cd.noCooldownCount = true
button.icon:SetTexCoord(.07, .93, .07, .93)
button.icon:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0)
button.icon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 0, 0)
button.overlay:SetTexture(cfg.debuffBorder)
button.overlay:SetTexCoord(0, 1, 0, 1)
button.overlay.Hide = function(self)self:SetVertexColor(0.3, 0.3, 0.3) end
button.time = lib.gen_fontstring(button, cfg.smallfont, 12, "OUTLINE")
button.time:SetPoint("BOTTOM", button, 2, -6)
button.time:SetJustifyH('CENTER')
button.time:SetVertexColor(1, 1, 1)
button.count = lib.gen_fontstring(button, cfg.smallfont, 15, "OUTLINE")
button.count:ClearAllPoints()
button.count:SetPoint("TOPRIGHT", button, 5, 3)
button.count:SetJustifyH('RIGHT')
button.count:SetVertexColor(1, 1, 1)
--helper
local h = CreateFrame("Frame", nil, button)
h:SetFrameLevel(0)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_backdrop(h)
end
-- Post Update Icon Function
local myPostUpdateIcon = function(self, unit, icon, index, offset, filter, isDebuff)
local _, _, _, _, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, icon.filter)
if duration and duration > 0 then
icon.time:Show()
icon.timeLeft = expirationTime
icon:SetScript("OnUpdate", CreateBuffTimer)
else
icon.time:Hide()
icon.timeLeft = math.huge
icon:SetScript("OnUpdate", nil)
end
-- Desaturate non-Player Debuffs
if (unit == "target") then
if (icon.filter == "HARMFUL") then
if (unitCaster == 'player' or unitCaster == 'vehicle') then
icon.icon:SetDesaturated(nil)
elseif (not UnitPlayerControlled(unit)) then -- If Unit is Player Controlled don't desaturate debuffs
icon:SetBackdropColor(0, 0, 0)
icon.overlay:SetVertexColor(0.3, 0.3, 0.3)
icon.icon:SetDesaturated(1)
end
end
end
-- Right Click Cancel Buff/Debuff
icon:SetScript('OnMouseUp', function(self, mouseButton)
if mouseButton == 'RightButton' then
CancelUnitBuff('player', index)
end end)
icon.first = true
end
local FormatTime = function(s)
local day, hour, minute = 86400, 3600, 60
if s >= day then
return format("%dd", floor(s / day + 0.5)), s % day
elseif s >= hour then
return format("%dh", floor(s / hour + 0.5)), s % hour
elseif s >= minute then
if s <= minute * 5 then
return format("%d:%02d", floor(s / 60), s % minute), s - floor(s)
end
return format("%dm", floor(s / minute + 0.5)), s % minute
elseif s >= minute / 12 then
return floor(s + 0.5), (s * 100 - floor(s * 100)) / 100
end
return format("%.1f", s), (s * 100 - floor(s * 100)) / 100
end
-- Create Buff/Debuff Timer Function
function CreateBuffTimer(self, elapsed)
self.elapsed = (self.elapsed or 0) + elapsed
if self.elapsed >= 0.1 then
if not self.first then
self.timeLeft = self.timeLeft - self.elapsed
else
self.timeLeft = self.timeLeft - GetTime()
self.first = false
end
if self.timeLeft > 0 and self.timeLeft <= 60 * 15 then -- Show time between 0 and 15 min
local time = FormatTime(self.timeLeft)
self.time:SetText(time)
if self.timeLeft >= 6 and self.timeLeft <= 60 * 5 then -- if Between 5 min and 6sec
self.time:SetTextColor(0.95, 0.95, 0.95)
elseif self.timeLeft > 3 and self.timeLeft < 6 then -- if Between 6sec and 3sec
self.time:SetTextColor(0.95, 0.70, 0)
elseif self.timeLeft <= 3 then -- Below 3sec
self.time:SetTextColor(0.9, 0.05, 0.05)
else
self.time:SetTextColor(0.95, 0.95, 0.95)-- Fallback Color
end
else
self.time:Hide()
end
self.elapsed = 0
end
end
-- Generates the Buffs
lib.createBuffs = function(f)
b = CreateFrame("Frame", nil, f)
b.onlyShowPlayer = cfg.buffsOnlyShowPlayer
if f.mystyle == "target" then
b:SetPoint("TOPLEFT", f, "TOPRIGHT", 12, 0)
b.initialAnchor = "TOPLEFT"
b["growth-x"] = "RIGHT"
b["growth-y"] = "DOWN"
b.size = 20
b.num = 10
b.spacing = 5
b:SetHeight((b.size + b.spacing) * 4)
b:SetWidth(f:GetWidth())
elseif f.mystyle == "player" then
b:SetPoint("TOPRIGHT", f, "TOPLEFT", -5, 0)
b.initialAnchor = "TOPRIGHT"
b["growth-x"] = "LEFT"
b["growth-y"] = "DOWN"
b.size = 20
b.num = 40
b.spacing = 5
b:SetHeight((b.size + b.spacing) * 4)
b:SetWidth(f:GetWidth())
else
b.num = 0
end
b.PostCreateIcon = myPostCreateIcon
b.PostUpdateIcon = myPostUpdateIcon
f.Buffs = b
end
-- Generates the Debuffs
lib.createDebuffs = function(f)
b = CreateFrame("Frame", nil, f)
b.size = 24
b.num = 40
b.onlyShowPlayer = cfg.debuffsOnlyShowPlayer
b.spacing = 5
b:SetHeight((b.size + b.spacing) * 5)
b:SetWidth(f:GetWidth())
b:SetPoint("TOPLEFT", f.Power, "BOTTOMLEFT", 0, -5)
b.initialAnchor = "TOPLEFT"
b["growth-x"] = "RIGHT"
b["growth-y"] = "DOWN"
b.PostCreateIcon = myPostCreateIcon
b.PostUpdateIcon = myPostUpdateIcon
f.Debuffs = b
end
-- raid post update
lib.PostUpdateRaidFrame = function(Health, unit, min, max)
local disconnnected = not UnitIsConnected(unit)
local dead = UnitIsDead(unit)
local ghost = UnitIsGhost(unit)
if disconnnected or dead or ghost then
Health:SetValue(max)
if (disconnnected) then
Health:SetStatusBarColor(0, 0, 0, 0.6)
elseif (ghost) then
Health:SetStatusBarColor(1, 1, 1, 0.6)
elseif (dead) then
Health:SetStatusBarColor(1, 0, 0, 0.7)
end
else
Health:SetValue(min)
if (unit == 'vehicle') then
Health:SetStatusBarColor(22 / 255, 106 / 255, 44 / 255)
end
end
if not UnitInRange(unit) then
Health.bg2:SetVertexColor(.6, 0.3, 0.3, 1)
else
Health.bg2:SetVertexColor(1, 0.1, 0.1, 1)
end
end
-- runebar
lib.genRunes = function(self)
if playerClass ~= "DEATHKNIGHT" then return end
local runeFrame = CreateFrame("Frame", nil, self)
runeFrame:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5)
runeFrame:SetHeight(4)
runeFrame:SetWidth(self:GetWidth())
runeFrame:SetFrameLevel(4)
for i = 1, 6 do
local rune = CreateFrame("StatusBar", nil, runeFrame)
rune:SetSize((self.Health:GetWidth() / 6) - 6, 6)
rune:SetStatusBarTexture(cfg.statusbar_texture)
rune:SetFrameLevel(4)
local h = CreateFrame("Frame", nil, rune)
h:SetFrameLevel(1)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_totemback(h)
if (i == 1) then
rune:SetPoint("BOTTOMLEFT", self.Health, "TOPLEFT", 3, 6)
else
rune:SetPoint("TOPLEFT", runeFrame[i - 1], "TOPRIGHT", 6, 0)
end
runeFrame[i] = rune
end
self.Runes = runeFrame
end
-- Class specific powers
lib.gen_AltPowerBar = function(self)
local AdditionalPower = CreateFrame("StatusBar", "AdditionalPowerBar", self.Power)
AdditionalPower:SetHeight(6)
AdditionalPower:SetWidth(self.Power:GetWidth() - 20)
AdditionalPower:SetPoint("TOP", self.Power, "BOTTOM", 0, 0)
AdditionalPower:SetFrameLevel(2)
AdditionalPower:SetStatusBarTexture(cfg.statusbar_texture)
AdditionalPower:SetStatusBarColor(.117, .55, 1)
AdditionalPower.bg = AdditionalPower:CreateTexture(nil, "BORDER")
AdditionalPower.bg:SetTexture(cfg.statusbar_texture)
AdditionalPower.bg:SetVertexColor(1, 0.1, 0.1, 1)
AdditionalPower.bg:SetPoint("TOPLEFT", AdditionalPower, "TOPLEFT", 0, 0)
AdditionalPower.bg:SetPoint("BOTTOMRIGHT", AdditionalPower, "BOTTOMRIGHT", 0, 0)
local h = CreateFrame("Frame", nil, AdditionalPower)
h:SetFrameLevel(1)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_backdrop(h)
self.AdditionalPower = AdditionalPower
self.AdditionalPower.bg = AdditionalPower.bg
end
-- Runebar
lib.genRunes = function(self)
if playerClass ~= "DEATHKNIGHT" then return end
local Runes = CreateFrame("Frame", nil, self)
Runes:SetPoint('CENTER', self.Health, 'TOP', 2, 1)
Runes:SetHeight(8)
Runes:SetWidth(self.Health:GetWidth())
for i = 1, 6 do
Runes[i] = CreateFrame("StatusBar", self:GetName() .. "_Runes" .. i, self)
Runes[i]:SetHeight(8)
Runes[i]:SetWidth((self.Health:GetWidth() / 6) - 5)
Runes[i]:SetStatusBarTexture(cfg.statusbar_texture)
Runes[i]:SetFrameLevel(10)
Runes[i]:SetStatusBarColor(70 / 255, 180 / 255, 210 / 255)
Runes[i].bg = Runes[i]:CreateTexture(nil, "BORDER")
Runes[i].bg:SetTexture(cfg.statusbar_texture)
Runes[i].bg:SetPoint("TOPLEFT", Runes[i], "TOPLEFT", 0, 0)
Runes[i].bg:SetPoint("BOTTOMRIGHT", Runes[i], "BOTTOMRIGHT", 0, 0)
Runes[i].bg.multiplier = 0.2
local h = CreateFrame("Frame", nil, Runes[i])
h:SetFrameLevel(1)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_classback(h)
if (i == 1) then
Runes[i]:SetPoint("BOTTOMLEFT", self.Health, "TOPLEFT", 0, 8)
else
Runes[i]:SetPoint('TOPLEFT', Runes[i - 1], 'TOPRIGHT', 1, 0)
end
end
self.Runes = Runes
end
-- Class Power
lib.gen_Classbar = function(self)
local maxPower, color
if playerClass == "MAGE" then
maxPower = 4
color = {0.15, 0.55, 0.8}
elseif playerClass == "MONK" then
maxPower = 6
color = {0.9, 0.99, 0.9}
elseif playerClass == "PALADIN" then
maxPower = 5
color = {0.9, 0.95, 0.33}
elseif playerClass == "WARLOCK" then
maxPower = 5
color = {0.86, 0.22, 1}
end
if maxPower ~= nil then
local ClassIcons = CreateFrame("Frame", nil, self)
ClassIcons:SetPoint('BOTTOM', self.Health, 'TOP', 0, 1)
ClassIcons:SetHeight(8)
ClassIcons:SetWidth(self.Health:GetWidth())
ClassIcons:SetFrameLevel(10)
for i = 1, maxPower do
ClassIcons[i] = CreateFrame("StatusBar", self:GetName() .. playerClass .. i, self)
ClassIcons[i]:SetHeight(8)
ClassIcons[i]:SetWidth((ClassIcons:GetWidth() / maxPower) - 2.5)
ClassIcons[i]:SetStatusBarTexture(cfg.statusbar_texture)
ClassIcons[i]:SetStatusBarColor(color[1], color[2], color[3])
ClassIcons[i]:SetFrameLevel(11)
local h = CreateFrame("Frame", nil, ClassIcons[i])
h:SetFrameLevel(10)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_classback(h)
if (i == 1) then
ClassIcons[i]:SetPoint("BOTTOMLEFT", self.Health, "TOPLEFT", 0, 8)
else
ClassIcons[i]:SetPoint('TOPLEFT', ClassIcons[i - 1], "TOPRIGHT", 3, 0)
end
end
self.ClassPower = ClassIcons
end
end
-- Combo points
lib.RogueComboPoints = function(self)
if (playerClass == "ROGUE" or playerClass == "DRUID") then
local combo = CreateFrame("Frame", nil, self)
combo:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -5)
combo:SetHeight(8)
combo:SetWidth(self:GetWidth())
for i = 1, 8 do
combo[i] = CreateFrame("StatusBar", self:GetName() .. "_CPoints" .. i, self)
combo[i]:SetHeight(8)
combo[i]:SetStatusBarTexture(cfg.statusbar_texture)
combo[i]:SetFrameLevel(10)
combo[i].bg = combo[i]:CreateTexture(nil, "BORDER")
combo[i].bg:SetTexture(cfg.statusbar_texture)
combo[i].bg:SetPoint("TOPLEFT", combo[i], "TOPLEFT", 0, 0)
combo[i].bg:SetPoint("BOTTOMRIGHT", combo[i], "BOTTOMRIGHT", 0, 0)
combo[i].bg.multiplier = 0.3
local h = CreateFrame("Frame", nil, combo[i])
h:SetFrameLevel(1)
h:SetPoint("TOPLEFT", -5, 5)
h:SetPoint("BOTTOMRIGHT", 5, -5)
lib.gen_classback(h)
if (i == 1) then
combo[i]:SetPoint("BOTTOMLEFT", self.Health, "TOPLEFT", 0, 8)
else
combo[i]:SetPoint('TOPLEFT', combo[i - 1], 'TOPRIGHT', 3, 0)
end
end
combo[1]:SetStatusBarColor(.3, .9, .3)
combo[2]:SetStatusBarColor(.3, .9, .3)
combo[3]:SetStatusBarColor(.3, .9, .3)
combo[4]:SetStatusBarColor(.9, .9, 0)
combo[5]:SetStatusBarColor(.9, .3, .3)
combo[6]:SetStatusBarColor(.9, .3, .3)
combo[7]:SetStatusBarColor(.9, .3, .3)
combo[8]:SetStatusBarColor(.9, .3, .3)
self.FailCPoints = combo
end
end
-- ReadyCheck
lib.ReadyCheck = function(self)
if cfg.RCheckIcon then
rCheck = self.Health:CreateTexture(nil, "OVERLAY")
rCheck:SetSize(14, 14)
rCheck:SetPoint("BOTTOMLEFT", self.Health, "TOPRIGHT", -13, -12)
self.ReadyCheckIndicator = rCheck
end
end
-- raid debuffs
lib.raidDebuffs = function(f)
if cfg.showRaidDebuffs then
local raid_debuffs = {
debuffs = {
-- Any Zone
["Viper Sting"] = 12, -- Viper Sting
["Wound Poison"] = 9, -- Wound Poison
["Mortal Strike"] = 8, -- Mortal Strike
["Furious Attacks"] = 8, -- Furious Attacks
["Aimed Shot"] = 8, -- Aimed Shot
["Counterspell"] = 10, -- Counterspell
["Blind"] = 10, -- Blind
["Cyclone"] = 10, -- Cyclone
["Polymorph"] = 7, -- Polymorph
["Entangling Roots"] = 7, -- Entangling Roots
["Freezing Trap"] = 7, -- Freezing Trap
["Crippling Poison"] = 6, -- Crippling Poison
["Hamstring"] = 5, -- Hamstring
["Wing Clip"] = 5, -- Wing Clip
["Fear"] = 3, -- Fear
["Psychic Scream"] = 3, -- Psychic Scream
["Howl of Terror"] = 3, -- Howl of Terror
-- Naxxramas
["Locust Swarm"] = 12,
["Necrotic Poison"] = 12,
["Web Wrap"] = 12,
["Jagged Knife"] = 12,
["Mutating Injection"] = 12,
["Detonate Mana"] = 12,
["Frost Blast"] = 12,
["Chains of Kel'Thuzad"] = 12,
-- Ulduar
["Slag Pot"] = 12,
["Gravity Bomb"] = 12,
["Light Bomb"] = 12,
["Fusion Punch"] = 12,
["Static Disruption"] = 12,
["Stone Grip"] = 12,
["Crunch Armor"] = 12,
["Flash Freeze"] = 12,
["Unbalancing Strike"] = 12,