-save dialog confirmation

This commit is contained in:
2022-10-23 16:37:11 +02:00
parent ec0660a5c6
commit 8acc26329a

View File

@@ -21,6 +21,8 @@ function _init()
c=caco.new(10,24,16) c=caco.new(10,24,16)
table.insert(actors,c) table.insert(actors,c)
score.create() score.create()
_update=update_game
end end
function text(str,x,y,col) function text(str,x,y,col)
@@ -52,7 +54,24 @@ function draw_hab(hab,x,y,editing)
camera(0,0) camera(0,0)
end end
function _update() function _update() end
function update_dialog()
rectfill(16,16,112,50,12)
rect(15,15,113,51,16)
text("Save the map?",20,20,2)
text("This cannot be undone",20,27,2)
text("(Y)es (N)o",25,40,2)
if btnp(KEY_N) then
_update=update_game
elseif btnp(KEY_Y) then
mapa_save()
_update=update_game
end
end
function update_game()
cls(16) cls(16)
if mode==modes.editing then if mode==modes.editing then
@@ -78,8 +97,8 @@ function _update()
elseif btnp(KEY_RETURN) then elseif btnp(KEY_RETURN) then
mode=modes.playing mode=modes.playing
mapa_do_backup() mapa_do_backup()
elseif btnp(KEY_S) then elseif btnp(KEY_S) and (btn(KEY_LCTRL) or btn(KEY_LGUI)) then
mapa_save() _update=update_dialog
elseif btnp(KEY_C) then elseif btnp(KEY_C) then
mapa_cycle_colors(abad.hab) mapa_cycle_colors(abad.hab)
end end