-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.lua
More file actions
62 lines (50 loc) · 1.33 KB
/
menu.lua
File metadata and controls
62 lines (50 loc) · 1.33 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
menu = {}
Im = require("ImageLib/ImageLib")
XP = require("XP/XPLib2")
Windows = require("WindowLib/WindowLib2")
MainMenu = {}
function MainMenu.onCreate(self)
local files = love.filesystem.getDirectoryItems("")
y = 16
for i=1,#files do
if string.sub(files[i],-4) == ".cre" then
self.Windows:createObject(self,XPButton,{x=16,y=y,text=files[i],callback=function() self:selectPlayback(files[i]) end})
y = y + 32
end
end
end
function MainMenu.drawFunction(self)
local width, height = self:size()
XP:FillRect(0,0,width,height)
end
function MainMenu.size(self)
return 400,400
end
function MainMenu.selectPlayback(self,file)
local playback = require("playback")
playback.filename = string.sub(file,1,-5)
self.Windows:closeWindow(self.window)
ChangeState(playback)
end
function menu.init(menu)
XP:Init()
local mainmenu = Windows:createWindow(XPWindow,MainMenu)
mainmenu.x = 200
mainmenu.y = 100
end
function menu.update(menu)
Windows:update()
end
function menu.mouseDown(menu,x,y)
Windows:mouseDown(x,y)
end
function menu.mouseMove(menu,x,y)
Windows:mouseMove(x,y)
end
function menu.mouseUp(meny,x,y)
Windows:mouseUp(x,y)
end
function menu.draw(menu)
Windows:draw()
end
return menu