- [CHG] Mòdul "level" renomenat a "rooms"
- [NEW] Mòdul "menu" - [NEW] Mòdul "popup"
This commit is contained in:
46
data/menu.lua
Normal file
46
data/menu.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
require "popup"
|
||||
|
||||
menu = {
|
||||
visible = false,
|
||||
current_x = 0,
|
||||
|
||||
init = function()
|
||||
end,
|
||||
|
||||
show = function()
|
||||
menu.visible = true
|
||||
end,
|
||||
|
||||
hide = function()
|
||||
menu.visible = false
|
||||
end,
|
||||
|
||||
draw = function()
|
||||
view.origin(0,0)
|
||||
view.clip()
|
||||
draw.rectf(0,0,160,7,23)
|
||||
draw.hline(0,7,160,16)
|
||||
menu.current_x = 1
|
||||
menu.option("FILE")
|
||||
popup.create("FILE", 1, 8)
|
||||
popup.addOption("FILE", "New", function() sys.quit() end)
|
||||
popup.addOption("FILE", "Load", function() sys.quit() end)
|
||||
popup.addOption("FILE", "Save", function() sys.quit() end)
|
||||
popup.addOption("FILE", "Save As...", function() sys.quit() end)
|
||||
menu.option("EDIT")
|
||||
menu.option("TOOLS")
|
||||
end,
|
||||
|
||||
option = function(label)
|
||||
local next_x = menu.current_x + (#label + 2)*4
|
||||
local mx, my = mouse.pos()
|
||||
if my < 8 and mx >= menu.current_x and mx < next_x then
|
||||
draw.rectf(menu.current_x, 0, next_x-menu.current_x, 8, 21)
|
||||
if mouse.down(mouse.LEFT) then
|
||||
popup.show(label)
|
||||
end
|
||||
end
|
||||
draw.text(label,menu.current_x+4,1,28)
|
||||
menu.current_x = next_x
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user