- [NEW] 'app' module
- [NEW] 'editor' module - [NEW] 'msgbox' module - [NEW] 'score' module - [NEW] 'ui' module - [NEW] 'util' module
This commit is contained in:
@@ -4,7 +4,7 @@ popup={
|
||||
current = nil,
|
||||
|
||||
create = function(label,x,y)
|
||||
popup.list[label] = {x=x, y=y, width=0, options={}}
|
||||
popup.list[label] = {x=x, y=y, width=50, options={}}
|
||||
end,
|
||||
|
||||
addOption = function(parent, label, action)
|
||||
@@ -16,23 +16,36 @@ popup={
|
||||
end,
|
||||
|
||||
show = function(label)
|
||||
popup.old_update = mini.update
|
||||
popup.current = label
|
||||
mini.update = popup.update
|
||||
app.push(popup.update)
|
||||
end,
|
||||
|
||||
update = function()
|
||||
view.origin(0,0)
|
||||
local mx, my = mouse.pos()
|
||||
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)
|
||||
draw.outset(p.x, p.y, p.width, #p.options*7+2)
|
||||
local y = p.y+2
|
||||
for k,v in ipairs(p.options) do
|
||||
local inside = util.inside(mx, my, {p.x, y-2, p.width, 7})
|
||||
if inside then
|
||||
draw.rectf(p.x+1, y-1, p.width-2, 7, 21)
|
||||
if mouse.press(mouse.LEFT) then
|
||||
app.pop()
|
||||
v.action()
|
||||
end
|
||||
end
|
||||
draw.text(v.label, p.x+2, y, 28)
|
||||
y = y + 7
|
||||
end
|
||||
|
||||
local inside = util.inside(mx, my, {p.x, p.y, p.width, #p.options*7+2})
|
||||
if not inside and mouse.down(mouse.LEFT) then
|
||||
mouse.discard()
|
||||
app.pop()
|
||||
end
|
||||
if key.press(key.ESCAPE) then
|
||||
mini.update = popup.old_update
|
||||
app.pop()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user