From e745be8d0799d7c73ba504afc46fc91e300ef71e Mon Sep 17 00:00:00 2001 From: Calic Date: Mon, 1 Jun 2026 22:56:04 +0200 Subject: [PATCH] feat(map-editor): cell-tile as third state.mode + Tools menu entry state.set_mode now accepts "cell-tile"; toggle_mode is renamed cycle_mode (with a backwards-compat alias) and now advances auto-tile -> cell-tile -> direct -> auto-tile. Tools > Mode submenu gains a third entry between Auto-Tile and Direct. Self-test gains t8 (set/get round-trip) and t12 (cycle order). Startup banner updated to "Tab=cycle mode". Manifest dep pin bumped to lib-core.maps 0.5.7 to match installed version. Co-Authored-By: Claude Opus 4.7 (1M context) --- init.lua | 35 +++++++++++++++++++++++++++++++---- manifest.module | 2 +- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 4b99aea..8e5cbe2 100644 --- a/init.lua +++ b/init.lua @@ -133,13 +133,23 @@ local state = (function() function M.is_picker_open() return state.picker_open end -- 0.2.0a: binary mode switch (Auto-Tile vs Direct). + -- CT6: extended to three-way cycle (auto-tile / cell-tile / direct). function M.get_mode() return state.mode end function M.set_mode(m) - if m == "auto-tile" or m == "direct" then state.mode = m end + if m == "auto-tile" or m == "cell-tile" or m == "direct" then state.mode = m end end - function M.toggle_mode() - state.mode = (state.mode == "auto-tile") and "direct" or "auto-tile" + function M.cycle_mode() + if state.mode == "auto-tile" then + state.mode = "cell-tile" + elseif state.mode == "cell-tile" then + state.mode = "direct" + else + state.mode = "auto-tile" + end end + -- Backwards-compat alias (still called by the input binding and the + -- toolbar mode toggle in older code paths; both now cycle 3 modes). + M.toggle_mode = M.cycle_mode function M.is_modal_open(id) if id == nil then return state.modal_open ~= nil end @@ -548,6 +558,9 @@ local ui = (function() { type = "toggle", label = "Auto-Tile", is_on = function() return mode_is("auto-tile") end, fire = function() actions.set_mode("auto-tile") end }, + { type = "toggle", label = "Cell-Tile", + is_on = function() return mode_is("cell-tile") end, + fire = function() actions.set_mode("cell-tile") end }, { type = "toggle", label = "Direct", hotkey = "Tab", is_on = function() return mode_is("direct") end, fire = function() actions.set_mode("direct") end }, @@ -1464,7 +1477,7 @@ input.bind("reset_transform", { "0" }) -- 0.2.0c input.bind("toggle_debug_overlay", { "d" }) -- 0.2.0c.3 input.bind("toggle_world_overlay", { "g" }) -- 0.2.0c.4 -engine.print("map-editor v0.3.0: ready. Tab=mode, I=help, G=grid, D=debug, S=save, E=erase, R=rotate, H=flip, 0=reset, ESC=quit / close") +engine.print("map-editor v0.3.0: ready. Tab=cycle mode, I=help, G=grid, D=debug, S=save, E=erase, R=rotate, H=flip, 0=reset, ESC=quit / close") -- ===================================================================== -- 0.3.0: self-tests (Spec ยง7.1). Run once on the first CI frame. @@ -1541,6 +1554,20 @@ local function self_test() engine.test.equals(state.is_layer_visible(lname), not vis_before, "t7: layer visibility flipped via state.toggle_layer_visible") state.toggle_layer_visible(lname) + + -- t8: state.set_mode accepts "cell-tile" + state.set_mode("cell-tile") + engine.test.equals(state.get_mode(), "cell-tile", + "t8: set_mode('cell-tile') sets mode") + + -- t12: cycle_mode cycles auto -> cell -> direct -> auto + state.set_mode("auto-tile") + state.cycle_mode() + engine.test.equals(state.get_mode(), "cell-tile", "t12: cycle auto -> cell") + state.cycle_mode() + engine.test.equals(state.get_mode(), "direct", "t12: cycle cell -> direct") + state.cycle_mode() + engine.test.equals(state.get_mode(), "auto-tile", "t12: cycle direct -> auto") end -- ===================================================================== diff --git a/manifest.module b/manifest.module index 1b80c6c..a723fc6 100644 --- a/manifest.module +++ b/manifest.module @@ -9,7 +9,7 @@ "blob_rect_stone": "lib-asset.prototype-blob-geom" }, "deps": [ - {"id":"lib-core.maps","version":"0.5.6"}, + {"id":"lib-core.maps","version":"0.5.7"}, {"id":"lib-core.render","version":"0.1.0"}, {"id":"lib-core.camera","version":"0.3.0"}, {"id":"lib-core.input","version":"0.4.0"},