/
animation.lua
executable file
·66 lines (50 loc) · 1.25 KB
/
animation.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
--[[
An animation sytem based timer thingy
--]]
local AniUpdater = OmniCC:New('AniUpdater')
AniUpdater.updaters = {}
--[[ Constructor ]]--
function AniUpdater:Get(frame)
return self:GetActive(frame) or self:New(frame)
end
function AniUpdater:GetActive(frame)
return self.updaters[frame]
end
function AniUpdater:New(frame)
local updater = self:Bind(CreateFrame('Frame'))
self.updaters[frame] = updater
local group = updater:CreateAnimationGroup()
group:SetLooping('NONE')
group:SetScript('OnFinished', function(self)
self:GetParent():OnFinished()
end)
local animation = group:CreateAnimation('Animation')
animation:SetOrder(1)
updater.frame, updater.group = frame, group
updater.animation = animation
return updater
end
--[[ Controls ]]--
function AniUpdater:CancelUpdate()
self:StopAnimation()
self:Hide()
end
function AniUpdater:StopAnimation()
if self.group:IsPlaying() then
self.group:Stop()
end
end
function AniUpdater:ScheduleUpdate(delay)
self:StopAnimation()
if delay > 0 then
self:Show()
self.animation:SetDuration(delay + 0.0002)
self.group:Play()
else
self:OnFinished()
end
end
function AniUpdater:OnFinished()
self:Hide()
self.frame:UpdateText()
end