-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
frame.lua
796 lines (693 loc) · 24.1 KB
/
frame.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
local _, helpers = ...
local NugRunning = NugRunning
local LSM = LibStub("LibSharedMedia-3.0")
LSM:Register("statusbar", "Aluminium", [[Interface\AddOns\NugRunning\statusbar.tga]])
LSM:Register("font", "AlegreyaSans-Medium", [[Interface\AddOns\NugRunning\AlegreyaSans-Medium.ttf]], GetLocale() ~= "enUS" and 15)
local apiLevel = math.floor(select(4,GetBuildInfo())/10000)
local UnitSpellHaste = UnitSpellHaste
if apiLevel <= 2 then UnitSpellHaste = function() return 0 end end
if apiLevel == 3 then
local GetCombatRatingBonus = GetCombatRatingBonus
local CR_HASTE_SPELL = CR_HASTE_SPELL
UnitSpellHaste = function() return GetCombatRatingBonus(CR_HASTE_SPELL) end
end
local getStatusbar = function()
if not NugRunningConfig.overrideTexture then
return LSM:Fetch("statusbar", NugRunning.db.textureName)
else return NugRunningConfig.texture end
end
local getFont = function(labelName)
if not NugRunningConfig.overrideFonts then
local s = NugRunning.db[labelName]
return LSM:Fetch("font", s.font), s.size, s.alpha, s.outline
else
local s = NugRunningConfig[labelName]
return s.font, s.size, s.alpha, s.outline
end
end
local pixelperfect = helpers.pixelperfect
NugRunning.TimerBar = {}
local TimerBar = NugRunning.TimerBar
function TimerBar.SetName(self, name)
self.spellText:SetText(name)
end
function TimerBar.SetColor(self,r,g,b)
self.bar:SetStatusBarColor(r,g,b)
self.bar.spark:SetVertexColor(r,g,b)
self.bar.bg:SetVertexColor(r*.5, g*.5, b*.5)
end
function TimerBar.SetIcon(self, icon)
self.icon:SetTexture(icon)
end
function TimerBar.SetCount(self,amount)
if not amount then return end
if self.opts.stackcolor then
local tbl = self.opts.stackcolor
local color = tbl[amount]
if not color then color = tbl[#tbl] end
self:SetColor(unpack(self.opts.stackcolor[amount]))
end
if self.opts.glowstack then
if self.glow then
if amount >= self.opts.glowstack then
if not self.glow:IsPlaying() then self.glow:Play() end
else
self.glow:Stop()
end
end
end
self.stacktext:SetText(amount)
if amount > 1 then self.stacktext:Show()
else self.stacktext:Hide() end
end
function TimerBar.SetTime(self, s,e, fixedoffset, animProgress)
animProgress = animProgress or 1
fixedoffset = fixedoffset or self.fixedoffset
if not fixedoffset then fixedoffset = 0 end
s = s or self.startTime
e = e or self.endTime
self.startTime = s
self.endTime = e
if not self._isMinimized then
s = self.startTime + (fixedoffset*animProgress)
end
self._startTimeModified = s
self.bar:SetMinMaxValues(s,e)
self:UpdateMark()
end
local function getbarpos(timer, time)
local duration = timer.endTime - (timer._startTimeModified or timer.startTime)
if duration == 0 then return 0 end
local progress
if time >= 0 then
progress = time / duration
else
progress = (duration+time) / duration
end
if progress > 1 then progress = 1 end
return progress * timer.bar:GetWidth(), progress
end
helpers.getbarpos = getbarpos
function TimerBar.MoveMark(self, time)
local pos, percent = getbarpos(self, time)
self.mark:SetPoint("CENTER",self.bar,"LEFT",pos,0)
if percent < 0.02 then
self.mark:Hide()
self.mark.texture:Hide()
else
self.mark:Show()
self.mark.texture:Show()
end
end
local function clear_overlay_point(p, self, ticktime)
if type(p) == "string" then
if p == "tick" then
return ticktime
elseif p == "tickend" then
if not ticktime then return nil end
return min(ticktime+self.tickPeriod, self.endTime-self.startTime)
elseif p == "end" then
return self.endTime-self.startTime
elseif p == "gcd" then
return (1.5/(1+(UnitSpellHaste("player")/100)))
end
else return p end
end
function TimerBar.UpdateMark(self, time) -- time - usually closest tick time
if self.timeless then
self.overlay2:Hide()
self.mark:Hide()
self.mark.texture:Hide()
return
end
if self.tickPeriod then
if time then
if time > 0 then
local pos = getbarpos(self, time)
self.mark:SetPoint("CENTER",self.bar,"LEFT",pos,0)
self.mark:Show()
self.mark.texture:Show()
else
self.mark:Hide()
self.mark.texture:Hide()
end
end
elseif self.opts.recast_mark then
local rm = clear_overlay_point(self.opts.recast_mark, self, time)
local pos = getbarpos(self, rm)
self.mark:SetPoint("CENTER",self.bar,"LEFT",pos,0)
self.mark.spark:CatchUp()
self.mark:Show()
self.mark.texture:Show()
else
self.mark:Hide()
self.mark.texture:Hide()
end
local overlay2 = self.opts.overlay
if overlay2 then
local t1 = clear_overlay_point(overlay2[1], self, time)
local t2 = clear_overlay_point(overlay2[2], self, time)
local hastereduced = overlay2[4]
if hastereduced then
local duration = t2 - t1
duration = (duration/(1+(UnitSpellHaste("player")/100)))
t2 = t1 + duration
end
self.overlay2.t1 = t1
self.overlay2.t2 = t2
if not t1 or not t2 then
return -- skip when point contains "tick" or "tickend", but it's not tick update call
end
local pos1 = getbarpos(self, t1)
local pos2 = getbarpos(self, t2)
local alpha = overlay2[3] or 0.2
if pos2 > pos1 then
self.overlay2:SetPoint("TOPLEFT", self.bar, "TOPLEFT", pos1, 0)
self.overlay2:SetPoint("BOTTOMRIGHT", self.bar, "BOTTOMLEFT", pos2, 0)
self.overlay2:SetVertexColor(0,0,0, alpha)
self.overlay2:Show()
else
self.overlay2:Hide()
end
else
self.overlay2:Hide()
end
end
function TimerBar.SetMinMaxCharge(self, min, max)
self.bar:SetMinMaxValues(min,max)
end
function TimerBar.SetCharge(self,val)
self.bar:SetValue(val)
if self.opts.stackcolor then
self:SetColor(unpack(self.opts.stackcolor[val]))
end
if self.opts.glowstack then
if self.glow then
if val >= self.opts.glowstack then
if not self.glow:IsPlaying() then self.glow:Play() end
else
self.glow:Stop()
end
end
end
end
function TimerBar.ToInfinite(self)
self.bar:SetMinMaxValues(0,100)
self.bar:SetValue(100)
self.startTime = GetTime()
self.endTime = self.startTime + 1
self.timeText:SetText("")
self:UpdateMark()
end
function TimerBar.ToGhost(self)
if self._isMinimized then
local scale = self.opts.scale or 1
self:VScale(scale)
end
self:SetColor(0.5,0,0)
self.timeText:SetText("")
self.bar:SetValue(0)
if self.glow:IsPlaying() then self.glow:Stop() end
--self:SetAlpha(0.8)
self.mark:Hide()
self.mark.texture:Hide()
end
do
local hour, minute = 3600, 60
local format = string.format
local ceil = math.ceil
function TimerBar.FormatTime(self, s)
if s >= hour then
return "%dh", ceil(s / hour)
elseif s >= minute*2 then
return "%dm", ceil(s / minute)
elseif s >= 30 then
return "%ds", floor(s)
end
return "%.1f", s
end
end
function TimerBar.Update(self, beforeEnd)
self.bar:SetValue(beforeEnd + (self._startTimeModified or self.startTime))
self.timeText:SetFormattedText(self:FormatTime(beforeEnd))
end
function TimerBar.Resize1(self, width, height)
self:SetWidth(width)
self:SetHeight(height)
self.mark:SetHeight(height*0.9)
self.mark.spark:SetHeight(height*2.6)
self.bar:SetWidth(width - self._height - 1)
self.bar:SetHeight(height)
self.bar.spark:SetHeight(height)
self.bar.spark:SetWidth(height*2)
self.spellText:SetWidth(self.bar:GetWidth()*0.8)
self.spellText:SetHeight(height/2+1)
end
function TimerBar.UpdateFonts(f)
local nameFont, nameSize, nameAlpha, nameOutline = getFont("nameFont")
f.spellText:SetFont(nameFont, nameSize, nameOutline and "OUTLINE")
f.spellText:SetAlpha(nameAlpha or 1)
local stackFont, stackSize, _stackAlpha = getFont("stackFont")
f.stacktext:SetFont(stackFont, stackSize, "OUTLINE")
local timeFont, timeSize, timeAlpha, timeOutline = getFont("timeFont")
f.timeText:SetFont(timeFont, timeSize, timeOutline and "OUTLINE")
f.timeText:SetJustifyH("RIGHT")
f.timeText:SetAlpha(timeAlpha or 1)
end
function TimerBar.UpdateTexture(f)
local texture = getStatusbar()
f.bar:SetStatusBarTexture(texture)
f.bar.bg:SetTexture(texture)
end
function NugRunning.UpdateAllFonts()
for i,timer in ipairs(NugRunning.timers) do
timer:UpdateFonts()
end
end
function NugRunning.UpdateAllTextures()
for i,timer in ipairs(NugRunning.timers) do
timer:UpdateTexture()
end
end
function NugRunning.UpdateAllNameplateTextures()
for i,f in ipairs(NugRunning.nameplate_timers) do
local texture = LSM:Fetch("statusbar", NugRunning.db.nptextureName)
f:SetStatusBarTexture(texture)
f.bg:SetTexture(texture)
end
end
function TimerBar:UpdateFrameBorder(borderType)
if self.border then self.border:Hide() end
if self.backdrop then self.backdrop:Hide() end
if borderType == "2PX" then
self.backdrop = self.backdrop or self:CreateTexture(nil, "BACKGROUND", nil, -2)
local backdrop = self.backdrop
local offset = pixelperfect(2, self)
backdrop:SetTexture("Interface\\BUTTONS\\WHITE8X8")
backdrop:SetVertexColor(0,0,0, 0.5)
backdrop:SetPoint("TOPLEFT", -offset, offset)
backdrop:SetPoint("BOTTOMRIGHT", offset, -offset)
backdrop:Show()
elseif borderType == "1PX" then
self.backdrop = self.backdrop or self:CreateTexture(nil, "BACKGROUND", nil, -2)
local backdrop = self.backdrop
local offset = pixelperfect(1, self)
backdrop:SetTexture("Interface\\BUTTONS\\WHITE8X8")
backdrop:SetVertexColor(0,0,0, 1)
backdrop:SetPoint("TOPLEFT", -offset, offset)
backdrop:SetPoint("BOTTOMRIGHT", offset, -offset)
backdrop:Show()
-- elseif borderType == "3PX" then
-- self.border = self.border or CreateFrame("Frame", nil, self)
-- local border = self.border
-- local offset = pixelperfect(3)
-- border:SetPoint("TOPLEFT", -offset, offset)
-- border:SetPoint("BOTTOMRIGHT", offset, -offset)
-- border:SetBackdrop({
-- edgeFile = "Interface\\AddOns\\NugRunning\\border_3px", edgeSize = 8, tileEdge = false,
-- })
-- border:SetBackdropBorderColor(0.4,0.4,0.4)
-- border:Show()
end
end
function TimerBar.Remains(self)
return self.endTime - GetTime()
end
function TimerBar:GetVScale()
return self._scale
end
function TimerBar.VScale(self, scale)
if scale == self._scale then return end
if scale > 2 then scale = 2 end
-- if not self._scale and scale == 1 then return end -- already at full size
self._scale = scale
local height = self._height * scale
local width = self._width
self:Resize1(width, height)
if scale <= 1 then
local x = 0.8 * (1-scale) * 0.5 -- half of the texcoord height * scale difference
self.icon:SetTexCoord(.1, .9, .1+x, .9-x)
elseif scale <=2 then
local x = self._height/height * 0.4
self.icon:SetTexCoord(.5-x, .5+x, .1, .9)
end
self.icon:GetParent():SetHeight(height)
self.shine:GetParent():SetHeight(height*1.8)
self.shine:Stop()
self.shine.tex:SetAlpha(0)
self._isMinimized = scale <= 0.4
if scale < 0.7 then
self.spellText:Hide()
self.timeText:Hide()
else
self.spellText:Show()
self.timeText:Show()
end
-- if scale == 1 then self._scale = nil end
end
function TimerBar.Resize(self, width, height)
width = pixelperfect(width)
height = pixelperfect(height)
self._width = width
self._height = height
self:Resize1(width, height)
self.icon:GetParent():SetWidth(height)
self.icon:GetParent():SetHeight(height)
self.shine:GetParent():SetWidth(height*1.8)
self.shine:GetParent():SetHeight(height*1.8)
end
function TimerBar.SetPowerStatus(self, status, powerdiff)
if status == "HIGH" then
self.status:SetTextColor(.5,1,.5)
self.status:SetText("+"..powerdiff.."%")
self.status:Show()
self.status.bg:Show()
elseif status == "LOW" then
self.status:SetTextColor(1,.1,.1)
self.status:SetText(powerdiff.."%")
self.status:Show()
self.status.bg:Show()
else
self.status:Hide()
self.status.bg:Hide()
end
end
function TimerBar.ShowOverlayGlow(self)
local self = self.iconframe
if ( self.overlay ) then
if ( self.overlay.animOut:IsPlaying() ) then
self.overlay.animOut:Stop();
self.overlay.animIn:Play();
end
else
self.overlay = ActionButton_GetOverlayGlow();
local frameWidth, frameHeight = self:GetSize();
-- print(frameWidth,frameHeight)
-- self.overlay.animIn:Play();
-- self.overlay.animIn:Stop();
self.overlay:SetParent(self:GetParent());
self.overlay:ClearAllPoints();
--Make the height/width available before the next frame:
self.overlay:SetSize(frameWidth * 1.4, frameHeight * 1.4);
self.overlay:SetPoint("TOPLEFT", self, "TOPLEFT", -frameWidth * 0.2, frameHeight * 0.2);
self.overlay:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", frameWidth * 0.2, -frameHeight * 0.2);
self.overlay.animIn:Play();
end
end
local Redraw = function(self)
if not self.model_path then return end
self:SetModelScale(1)
-- self:ClearTransform()
self:SetPosition(0,0,0)
self:SetModel(self.model_path)
self:SetModelScale(self.model_scale)
self:SetPosition(self.ox, self.oy, self.oz)
-- if self.transform then
-- -- it's not working, probably because of the nextframe bullshit
-- self:SetTransform(unpack(self.transform))
-- end
end
local ResetTransformations = function(self)
-- print(self:GetName(), "hiding", self:GetCameraDistance(), self:GetCameraPosition())
self:SetModelScale(1)
-- self:ClearTransform()
self:SetPosition(0,0,0)
end
local SparkSetValue = function(self, v)
local min, max = self:GetMinMaxValues()
local total = max-min
local p
if total == 0 then
p = 0
else
p = (v-min)/(max-min)
if p > 1 then p = 1 end
end
local len = p*self:GetWidth()
self.spark:SetPoint("CENTER", self, "LEFT", len, 0)
return self:NormalSetValue(v)
end
function TimerBar.EnableSpark(self, isEnabled)
if isEnabled then
self.bar.spark:Show()
self.bar.SetValue = SparkSetValue
else
self.bar.spark:Hide()
self.bar.SetValue = self.bar.NormalSetValue
end
end
NugRunning.ConstructTimerBar = function(width, height)
local f = CreateFrame("Frame",nil,UIParent)
Mixin(f, TimerBar)
f:SetWidth(width)
f:SetHeight(height)
f:UpdateFrameBorder("2PX")
local ic = CreateFrame("Frame",nil,f)
ic:SetPoint("TOPLEFT",f,"TOPLEFT", 0, 0)
ic:SetWidth(height)
ic:SetHeight(height)
ic:SetFrameLevel(1)
local ict = ic:CreateTexture(nil,"ARTWORK", nil, 0)
ict:SetTexCoord(.1, .9, .1, .9)
ict:SetAllPoints(ic)
f.icon = ict
f.iconframe = ic
f.stacktext = ic:CreateFontString(nil, "OVERLAY", "GameFontNormal");
f.stacktext:SetTextColor(1,1,1)
local stackFont, stackSize, _stackAlpha = getFont("stackFont")
f.stacktext:SetFont(stackFont, stackSize, "OUTLINE")
f.stacktext:SetJustifyH("RIGHT")
f.stacktext:SetVertexColor(1,1,1)
f.stacktext:SetPoint("RIGHT", ic, "RIGHT",1,-5)
local bar = CreateFrame("StatusBar",nil,f)
bar:SetFrameStrata("MEDIUM")
local texture = getStatusbar()
bar:SetStatusBarTexture(texture)
bar:GetStatusBarTexture():SetDrawLayer("ARTWORK")
bar:SetHeight(height)
bar:SetWidth(width - height - 1)
bar:SetPoint("TOPRIGHT",f,"TOPRIGHT",0,0)
bar.bg = bar:CreateTexture(nil, "BORDER")
bar.bg:SetAllPoints(bar)
bar.bg:SetTexture(texture)
local spark = bar:CreateTexture(nil, "ARTWORK", nil, 4)
spark:SetBlendMode("ADD")
spark:SetTexture([[Interface\AddOns\NugRunning\spark.tga]])
spark:SetSize(bar:GetHeight()*2, bar:GetHeight())
spark:SetPoint("CENTER", bar, "TOP",0,0)
spark:Hide()
bar.spark = spark
f.bar = bar
bar.NormalSetValue = bar.SetValue
bar.SparkSetValue = SparkSetValue
f.timeText = f.bar:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall");
f.timeText:SetTextColor(1,1,1)
local timeFont, timeSize, timeAlpha, timeOutline = getFont("timeFont")
f.timeText:SetFont(timeFont, timeSize, timeOutline and "OUTLINE")
f.timeText:SetJustifyH("RIGHT")
f.timeText:SetAlpha(timeAlpha or 1)
f.timeText:SetVertexColor(1,1,1)
f.timeText:SetPoint("RIGHT", f.bar, "RIGHT",-6,0)
f.spellText = f.bar:CreateFontString(nil, "ARTWORK", "GameFontNormal");
f.spellText:SetTextColor(1,1,1)
local nameFont, nameSize, nameAlpha, nameOutline = getFont("nameFont")
f.spellText:SetFont(nameFont, nameSize, nameOutline and "OUTLINE")
f.spellText:SetWidth(f.bar:GetWidth()*0.8)
f.spellText:SetHeight(height/2+1)
f.spellText:SetJustifyH("CENTER")
f.spellText:SetAlpha(nameAlpha or 1)
f.spellText:SetPoint("LEFT", f.bar, "LEFT",6,0)
local overlay = f.bar:CreateTexture(nil, "ARTWORK", nil, 3)
overlay:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
overlay:SetVertexColor(0,0,0, 0.2)
overlay:Hide()
f.overlay2 = overlay
local arrow = f:CreateTexture(nil, "ARTWORK",nil,3)
arrow:SetTexture("Interface\\BUTTONS\\WHITE8X8")
arrow:SetHeight(height)
arrow:SetWidth(height/4)
arrow:SetPoint("TOPRIGHT", f, "TOPLEFT",-3, 0)
arrow:SetPoint("BOTTOMRIGHT", f, "BOTTOMLEFT",-3, 0)
-- arrow:SetPoint("RIGHT", f, "LEFT",0,-5)
arrow:SetVertexColor(1,0,0)
arrow:Hide()
local glow2 = arrow:CreateAnimationGroup()
local g2a1 = glow2:CreateAnimation("Rotation")
-- g2a1:SetChange(0.5)
g2a1:SetDegrees(360)
g2a1:SetSmoothing("IN_OUT")
g2a1:SetDuration(1)
g2a1:SetOrder(1)
glow2:SetLooping("BOUNCE")
f.arrowglow = glow2
f.arrow = arrow
-- local arrow = f.bar:CreateTexture(nil, "ARTWORK", nil, 5)
-- arrow:SetSize(11, 10)
-- arrow:SetTexture("Interface\\AddOns\\NugRunning\\arrows")
-- -- arrow:SetTexCoord(0, 26/32, 0, 23/64)
-- arrow:SetTexCoord(0, 26/32, 41/64, 1)
-- -- arrow:SetVertexColor(0.3,1,0.3)
-- arrow:SetVertexColor(1,0.3,0.3)
-- arrow:SetPoint("RIGHT", f.bar, "RIGHT",-30,1)
-- arrow:Hide()
-- local status = f.bar:CreateTexture(nil, "ARTWORK", nil, 5)
-- status:SetTexture("Interface\\BUTTONS\\WHITE8X8")
-- -- status:SetPoint("TOPRIGHT", f.icon, "TOPLEFT", -2,0)
-- -- status:SetPoint("BOTTOMLEFT", f.icon, "BOTTOMLEFT",-5,0)
-- status:SetSize(width/2,height)
-- status:SetPoint("TOPLEFT", f.bar, "TOPLEFT",0,0)
-- -- status:SetPoint("TOPRIGHT", f.icon, "BOTTOMLEFT", 5,5)
-- -- status:SetPoint("BOTTOMLEFT", f.icon, "BOTTOMLEFT",-1,-1)
-- -- status:SetVertexColor(0, 0.8, 0, 1)
-- status:Hide()
-- local status = CreateFrame("Frame", nil, f.bar)
local powertext = f.bar:CreateFontString()
powertext:SetFont(nameFont, nameSize)
powertext:SetPoint("BOTTOMLEFT", f.bar, "BOTTOMLEFT",13,0)
local sbg = f.bar:CreateTexture(nil, "ARTWORK", nil, 5)
sbg:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
sbg:SetVertexColor(0,0,0, 0.6)
sbg:SetAllPoints(powertext)
powertext.bg = sbg
f.status = powertext
local at = ic:CreateTexture(nil,"OVERLAY")
at:SetTexture([[Interface\SpellActivationOverlay\IconAlert]])
at:SetTexCoord(0.00781250,0.50781250,0.27734375,0.52734375)
--at:SetTexture([[Interface\AchievementFrame\UI-Achievement-IconFrame]])
--at:SetTexCoord(0,0.5625,0,0.5625)
at:SetWidth(height*1.8)
at:SetHeight(height*1.8)
at:SetPoint("CENTER",f.icon,"CENTER",0,0)
at:SetAlpha(0)
local sag = at:CreateAnimationGroup()
local sa1 = sag:CreateAnimation("Alpha")
sa1:SetFromAlpha(0)
sa1:SetToAlpha(1)
sa1:SetDuration(0.3)
sa1:SetOrder(1)
local sa2 = sag:CreateAnimation("Alpha")
sa2:SetFromAlpha(1)
sa2:SetToAlpha(0)
sa2:SetDuration(0.5)
sa2:SetOrder(2)
-- sag:SetScript("OnFinished",function(self)
-- self:GetParent():SetAlpha(0)
-- end)
f.shine = sag
f.shine.tex = at
local pmf = CreateFrame("PlayerModel", nil, f )
pmf:SetFrameLevel(0)
pmf:SetPoint("CENTER", ic, "LEFT", 0,0)
pmf:SetSize(height*4, height*4)
-- local ebg = pmf:CreateTexture(nil, "BACKGROUND")
-- ebg:SetTexture("Interface\\AddOns\\NugRunning\\effect_bg.tga")
-- ebg:SetPoint("RIGHT", f, "LEFT", -2, 0)
-- ebg:SetVertexColor(0,0,0, 0.7)
-- ebg:SetSize(height*1, height*1.5)
pmf.model_scale = 1
pmf.ox = 0
pmf.oy = 0
pmf.oz = 0
pmf.SetEffect = function(self, effect)
if effect == self._effect_name then return end
self._effect_name = effect
if type(effect) == "string" then
effect = NugRunningConfig.effects[effect]
end
if not effect then return self:Hide() end
self.model_path = effect.path
self.model_scale = effect.model_scale or 1
self.ox = effect.ox or 0
self.oy = effect.oy or 0
self.oz = effect.oz or 0
-- self.transform = effect.transform
local scale = effect.scale or 1
self:SetSize(height*scale, height*scale)
local x = effect.x or 0
local y = effect.y or 0
pmf:SetPoint("CENTER", ic, "LEFT", x, y)
self:Hide()
end
pmf:SetScript("OnHide", ResetTransformations)
pmf:SetScript("OnShow", Redraw)
pmf.Redraw = Redraw
pmf.ResetTransformations = ResetTransformations
pmf:Hide()
f.effect = pmf
-- local shineglow = at:CreateAnimationGroup()
-- local sg1 = sag:CreateAnimation("Alpha")
-- sg1:SetFromAlpha(0)
-- sg1:SetToAlpha(1)
-- sg1:SetDuration(0.3)
-- sg1:SetOrder(1)
-- local sg2 = sag:CreateAnimation("Alpha")
-- sg2:SetFromAlpha(1)
-- sg2:SetToAlpha(0)
-- sg2:SetDuration(0.3)
-- sg2:SetOrder(2)
-- shineglow:SetLooping("BOUNCE")
-- f.shineglow = shineglow
local aag = f:CreateAnimationGroup()
local aa1 = aag:CreateAnimation("Scale")
aa1:SetOrigin("BOTTOM",0,0)
aa1:SetScale(1,0.1)
aa1:SetDuration(0)
aa1:SetOrder(1)
local aa2 = aag:CreateAnimation("Scale")
aa2:SetOrigin("BOTTOM",0,0)
aa2:SetScale(1,10)
aa2:SetDuration(0.15)
aa2:SetOrder(2)
local glow = f:CreateAnimationGroup()
local ga1 = glow:CreateAnimation("Alpha")
ga1:SetFromAlpha(1)
ga1:SetToAlpha(0.5)
ga1:SetDuration(0.25)
ga1:SetOrder(1)
glow:SetLooping("BOUNCE")
f.glow = glow
f.animIn = aag
local m = CreateFrame("Frame",nil, f)
m:SetParent(f)
m:SetWidth(8)
m:SetHeight(f:GetHeight()*0.9)
m:SetFrameLevel(4)
m:SetAlpha(0.6)
m:SetPoint("CENTER",f.bar,"LEFT",10,0)
local texture = m:CreateTexture(nil, "OVERLAY")
texture:SetTexture("Interface\\AddOns\\NugRunning\\mark")
texture:SetVertexColor(1,1,1,0.5)
texture:SetAllPoints(m)
m.texture = texture
local spark = f.bar:CreateTexture(nil, "OVERLAY", nil, 2)
spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
spark:SetAlpha(0)
spark:SetWidth(20)
spark:SetHeight(16*4)
-- spark:SetPoint("CENTER",m)
spark:SetBlendMode('ADD')
spark.mark = m
spark.CatchUp = function(self)
local p1, f, p2, x, y = self.mark:GetPoint()
self:SetPoint(p1, f, p2, x, y)
end
spark:CatchUp()
m.spark = spark
local ag = spark:CreateAnimationGroup()
local a1 = ag:CreateAnimation("Alpha")
a1:SetFromAlpha(0)
a1:SetToAlpha(1)
a1:SetDuration(0.2)
a1:SetOrder(1)
local a2 = ag:CreateAnimation("Alpha")
a2:SetFromAlpha(1)
a2:SetToAlpha(0)
a2:SetDuration(0.4)
a2:SetOrder(2)
ag:SetScript("OnFinished", function(self)
self:GetParent():CatchUp()
end)
m.shine = ag
f.mark = m
return f
end