-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuttonlist.lua
More file actions
56 lines (45 loc) · 1.07 KB
/
buttonlist.lua
File metadata and controls
56 lines (45 loc) · 1.07 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
-- a column of buttons acting as a single object
lg = love.graphics
lm = love.mouse
local list = {}
local screen = {w=lg.getWidth(),h=lg.getHeight()}
local size = {}
size.buttonHSpace = screen.h/24
size.buttonHeight = screen.h/6
size.buttonWidth = screen.w/2
function list.new(xin,yin,bquant,state)
local o = {}
o.buttons = {}
o.x = xin or 0
o.y = yin or 0
o.spacing = size.buttonHSpace
o.height = size.buttonHeight
o.width = size.buttonWidth
o.state = state
o.addButton = list.addButton
o.draw = list.draw
o.checkClick = list.checkClick
for i=1,bquant do
o:addButton()
end
return o
end
function list:addButton()
local newbut = button.new(self.x,self.y+(#self.buttons*(self.height+self.spacing)),self.width,self.height)
table.insert(self.buttons,newbut)
end
function list:draw()
lg.setColor(255,255,255)
for i,v in ipairs(self.buttons) do
v:draw()
end
end
function list:checkClick(xin,yin)
for i,v in ipairs(self.buttons) do
if v:check() then
return v
end
end
return nil
end
return list