-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayback.lua
More file actions
72 lines (63 loc) · 1.8 KB
/
playback.lua
File metadata and controls
72 lines (63 loc) · 1.8 KB
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
playback = {}
CrazyLib = require("CrazyLib/CrazyLib")
function playback.init(self)
self.timer = 0
love.audio.play(love.audio.newSource(self.filename..".mp3","stream"))
CrazyLib:load(self.filename..".cre")
end
function playback.executeCommand(self,err)
local cmd = err.command
if string.startswith(cmd,"clear") then
local splitted = string.split(cmd,",")
if #splitted == 2 then
local i = 1
while i < #Windows.objects do
if Windows.objects[i].id == splitted[2] then
table.remove(Windows.objects,i)
else
i = i + 1
end
end
else
Windows.objects = {}
end
end
end
function playback.update(self)
if #CrazyLib.events == 0 then
Windows.objects = {}
ChangeState(require("menu"))
love.audio.stop()
return
end
local errors = CrazyLib:tick(self.timer)
for i=1,#errors do
if errors[i].command ~= nil then
self:executeCommand(errors[i])
else
local err = errors[i].error
local msg = Windows:createWindow(XPWindow,XP:CreateMessageBox(err[2],err[3],Im:Image(err[4]),err[5]),{
x = errors[i].pos[1],
y = errors[i].pos[2],
originx = errors[i].pos[3] or 0,
originy = errors[i].pos[4] or 0
})
msg.id = errors[i].id
end
end
self.timer = self.timer + love.timer.getDelta()
Windows:update()
end
function playback.mouseDown(self,x,y)
Windows:mouseDown(x,y)
end
function playback.mouseMove(self,x,y)
Windows:mouseMove(x,y)
end
function playback.mouseUp(self,x,y)
Windows:mouseUp(x,y)
end
function playback.draw(self)
Windows:draw()
end
return playback