wobin@1
|
1 local AddonName, AfterDark = ...
|
wobin@1
|
2
|
wobin@1
|
3 local TOASTERUP = "Interface\\AddOns\\AfterDark\\Images\\WingUp"
|
wobin@1
|
4 local TOASTERCOASTER = "Interface\\AddOns\\AfterDark\\Images\\WingNeutral"
|
wobin@1
|
5 local TOASTERDOWN = "Interface\\AddOns\\AfterDark\\Images\\WingDown"
|
wobin@1
|
6
|
wobin@1
|
7 function AfterDark:ConstructToaster(frame)
|
wobin@1
|
8 frame.toasterup = frame:CreateTexture(nil, "BACKGROUND")
|
wobin@1
|
9 frame.toasterup:SetAllPoints(frame)
|
wobin@1
|
10 frame.toasterup:SetTexture(TOASTERUP)
|
wobin@1
|
11
|
wobin@1
|
12 frame.toasterdown = frame:CreateTexture(nil, "BACKGROUND")
|
wobin@1
|
13 frame.toasterdown:SetAllPoints(frame)
|
wobin@1
|
14 frame.toasterdown:SetTexture(TOASTERDOWN)
|
wobin@1
|
15 frame.toasterdown:SetAlpha(0)
|
wobin@1
|
16
|
wobin@1
|
17 frame.toasterglide = frame:CreateTexture(nil, "BACKGROUND")
|
wobin@1
|
18 frame.toasterglide:SetAllPoints(frame)
|
wobin@1
|
19 frame.toasterglide:SetTexture(TOASTERCOASTER)
|
wobin@1
|
20 frame.toasterglide:SetAlpha(0)
|
wobin@1
|
21
|
wobin@1
|
22 frame.fader = frame.toasterup:CreateAnimationGroup()
|
wobin@1
|
23 frame.fader.parent = frame.toasterup
|
wobin@1
|
24 frame.fader:SetLooping("BOUNCE")
|
wobin@1
|
25
|
wobin@1
|
26 frame.toasterup.fade = frame.fader:CreateAnimation("Alpha")
|
wobin@1
|
27 frame.toasterup.fade:SetDuration(1)
|
wobin@1
|
28 frame.toasterup.fade:SetChange(-1)
|
wobin@1
|
29 frame.toasterup.fade:SetOrder(1)
|
wobin@1
|
30
|
wobin@1
|
31 frame.crossfader = frame.toasterdown:CreateAnimationGroup()
|
wobin@1
|
32 frame.crossfader.parent = frame.toasterdown
|
wobin@1
|
33 frame.crossfader:SetLooping("BOUNCE")
|
wobin@1
|
34
|
wobin@1
|
35 frame.toasterdown.fade = frame.crossfader:CreateAnimation("Alpha")
|
wobin@1
|
36 frame.toasterdown.fade:SetDuration(1)
|
wobin@1
|
37 frame.toasterdown.fade:SetChange(1)
|
wobin@1
|
38 frame.toasterdown.fade:SetOrder(1)
|
wobin@1
|
39
|
wobin@1
|
40 frame.hashfader = frame.toasterglide:CreateAnimationGroup()
|
wobin@1
|
41 frame.hashfader.parent = frame.toasterglide
|
wobin@1
|
42 frame.hashfader:SetLooping("BOUNCE")
|
wobin@1
|
43
|
wobin@1
|
44 frame.toasterglide.fade = frame.hashfader:CreateAnimation("Alpha")
|
wobin@1
|
45 frame.toasterglide.fade:SetDuration(0.5)
|
wobin@1
|
46 frame.toasterglide.fade:SetChange(1)
|
wobin@1
|
47 frame.toasterglide.fade:SetOrder(1)
|
wobin@1
|
48
|
wobin@1
|
49 if math.random(0,5) > 4 then
|
wobin@1
|
50 local delay = math.random(30,AfterDark.db.profile.Speed * 10)
|
wobin@1
|
51
|
wobin@1
|
52 frame.tumbler = frame:CreateAnimationGroup()
|
wobin@1
|
53 frame.tumbler.parent = frame
|
wobin@1
|
54 frame.tumbler:SetLooping("NONE")
|
wobin@1
|
55
|
wobin@1
|
56 frame.spin = frame.tumbler:CreateAnimation("Rotation")
|
wobin@1
|
57 frame.spin:SetDegrees(360)
|
wobin@1
|
58 frame.spin:SetOrigin("CENTER", -20,-20)
|
wobin@1
|
59 frame.spin:SetStartDelay(delay/10)
|
wobin@1
|
60 frame.spin:SetDuration(1)
|
wobin@1
|
61 frame.spin:SetOrder(1)
|
wobin@1
|
62 end
|
wobin@1
|
63
|
wobin@1
|
64 frame.IsToaster = true
|
wobin@1
|
65
|
wobin@1
|
66 frame.Respeed = function(self)
|
wobin@1
|
67 if frame.spin then
|
wobin@1
|
68 frame.spin:SetStartDelay(math.random(30, AfterDark.db.profile.Speed * 10)/10)
|
wobin@1
|
69 end
|
wobin@1
|
70 end
|
wobin@1
|
71
|
wobin@1
|
72 frame.Start = function(self)
|
wobin@1
|
73 self.mover:Play()
|
wobin@1
|
74 self.fader:Play()
|
wobin@1
|
75 self.crossfader:Play()
|
wobin@1
|
76 self.hashfader:Play()
|
wobin@1
|
77 if self.tumbler then
|
wobin@1
|
78 self.tumbler:Play()
|
wobin@1
|
79 end
|
wobin@1
|
80 self:Show()
|
wobin@1
|
81 end
|
wobin@1
|
82
|
wobin@1
|
83 frame.Finish = function(self)
|
wobin@1
|
84 self:StopAnimating()
|
wobin@1
|
85 self:Hide()
|
wobin@1
|
86 end
|
wobin@1
|
87
|
wobin@1
|
88 end
|