- [CHG] Mòdul "level" renomenat a "rooms"

- [NEW] Mòdul "menu"
- [NEW] Mòdul "popup"
This commit is contained in:
2025-06-19 22:11:05 +02:00
parent 9f884751cc
commit bbbf9d0c50
8 changed files with 191 additions and 101 deletions

39
data/popup.lua Normal file
View 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
}