-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmenue.lua
More file actions
80 lines (57 loc) · 1.81 KB
/
menue.lua
File metadata and controls
80 lines (57 loc) · 1.81 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
73
74
75
76
77
78
79
80
local menues ={}
local function wrap_text(str,num)
local ret = {}
for i = 1, string.len(str), num do
table.insert(ret, string.sub(str,i,i+num-1))
end
return ret
end
function menues.menue(header,options,x,y,width,height,marker_id,border)
if border == nil then
border = true
end
local x_off = 5
gr.setColor(0,0,0,255)
if #options>26 then return end
gr.rectangle("fill",x,y,width,height)
local wrapped =wrap_text(header,width)
local yoff =20
local line_size = 15
gr.setColor(255,255,255)
if border == true then
gr.rectangle("line",x,y,width,height)
end
for i,txt in pairs(wrapped) do
gr.print(txt,x+10 +x_off,y+yoff+i*line_size)
yoff = yoff+line_size
end
yoff = yoff + 10
for i,option in pairs(options) do
gr.print(option,x+10+x_off,y+yoff+i*line_size)
end
if marker_id ~= nil then
gr.rectangle("fill",x+x_off,y+yoff+marker_id*line_size + 4,5,5)
end
gr.setColor(0,0,0)
end
function menues.main_menue()
menues.menue("NotTheRogue",{"Start new","Load old","Options","Exit"},0,0,400,400,gvar.main_menue_item,false)
end
function menues.invi_menue(header,inventory,x,y,width,height)
local options ={}
debuger.on()
if inventory.num_stacks == 0 then
options={"No item in the inventory"}
else
for _,stack in pairs(inventory.item_stacks)do
table.insert(options,stack.stack_size.." x "..stack.item_type.name)
end
end
menues.menue(header,options,x,y,width,height,inventory.active_item+1)
debuger.off()
end
function menues.level_up_menue(header,x,y,width,height)
local options =glib.Level.getSelectableStates()
menues.menue(header,options,x,y,width,height,gvar.selected_state_idx)
end
return menues