- [CHG] Mòdul "level" renomenat a "rooms"
- [NEW] Mòdul "menu" - [NEW] Mòdul "popup"
This commit is contained in:
39
data/popup.lua
Normal file
39
data/popup.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
popup={
|
||||
list = {},
|
||||
old_update = nil,
|
||||
current = nil,
|
||||
|
||||
create = function(label,x,y)
|
||||
popup.list[label] = {x=x, y=y, width=0, options={}}
|
||||
end,
|
||||
|
||||
addOption = function(parent, label, action)
|
||||
popup.list[parent].options[#popup.list[parent].options+1] = { label=label, action=action }
|
||||
local option_width = #label*4+4
|
||||
if option_width > popup.list[parent].width then
|
||||
popup.list[parent].width = option_width
|
||||
end
|
||||
end,
|
||||
|
||||
show = function(label)
|
||||
popup.old_update = mini.update
|
||||
popup.current = label
|
||||
mini.update = popup.update
|
||||
end,
|
||||
|
||||
update = function()
|
||||
local p = popup.list[popup.current]
|
||||
draw.rectf(p.x, p.y, p.width, #p.options*7+2, 23)
|
||||
draw.rect(p.x, p.y, p.width, #p.options*7+2, 16)
|
||||
local y = p.y+2
|
||||
for k,v in ipairs(p.options) do
|
||||
draw.text(v.label, p.x+2, y, 28)
|
||||
y = y + 7
|
||||
end
|
||||
|
||||
if key.press(key.ESCAPE) then
|
||||
mini.update = popup.old_update
|
||||
end
|
||||
end
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user