From 69569194145fb1e31fa7ad4de47ad3cca1e210e5 Mon Sep 17 00:00:00 2001 From: Calic Date: Mon, 1 Jun 2026 19:41:51 +0200 Subject: [PATCH] feat(map-editor): Esc cascades modal -> menu -> quit Esc no longer immediately exits the editor; it first dismisses any open modal, then any open dropdown menu, and only falls through to engine.exit() when no overlay is up. Co-Authored-By: Claude Opus 4.7 (1M context) --- init.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index bcae7d3..f6264b8 100644 --- a/init.lua +++ b/init.lua @@ -330,6 +330,7 @@ local actions = (function() function M.set_mode(m) state.set_mode(m) end function M.open_cheatsheet() state.open_modal("cheatsheet") end function M.close_modal() state.close_modal() end + function M.close_menu() state.close_menu() end -- 0.2.0c actions function M.toggle_flip() state.toggle_flip() end @@ -1004,10 +1005,16 @@ function update(ctx, dt) end end - -- Quit + -- Esc precedence: modal → dropdown → quit if input.was_action_pressed("quit") then - engine.exit() - return + if state.is_modal_open() then + actions.close_modal() + elseif state.get_menu_open() then + actions.close_menu() + else + engine.exit() + return + end end -- Update mouse-cell tracking for status chip