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) <noreply@anthropic.com>
This commit is contained in:
Calic
2026-06-01 22:56:04 +02:00
parent f06ef5e2cb
commit e745be8d07
2 changed files with 32 additions and 5 deletions

View File

@@ -133,13 +133,23 @@ local state = (function()
function M.is_picker_open() return state.picker_open end function M.is_picker_open() return state.picker_open end
-- 0.2.0a: binary mode switch (Auto-Tile vs Direct). -- 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.get_mode() return state.mode end
function M.set_mode(m) 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 end
function M.toggle_mode() function M.cycle_mode()
state.mode = (state.mode == "auto-tile") and "direct" or "auto-tile" 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
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) function M.is_modal_open(id)
if id == nil then return state.modal_open ~= nil end if id == nil then return state.modal_open ~= nil end
@@ -548,6 +558,9 @@ local ui = (function()
{ type = "toggle", label = "Auto-Tile", { type = "toggle", label = "Auto-Tile",
is_on = function() return mode_is("auto-tile") end, is_on = function() return mode_is("auto-tile") end,
fire = function() actions.set_mode("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", { type = "toggle", label = "Direct", hotkey = "Tab",
is_on = function() return mode_is("direct") end, is_on = function() return mode_is("direct") end,
fire = function() actions.set_mode("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_debug_overlay", { "d" }) -- 0.2.0c.3
input.bind("toggle_world_overlay", { "g" }) -- 0.2.0c.4 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. -- 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, engine.test.equals(state.is_layer_visible(lname), not vis_before,
"t7: layer visibility flipped via state.toggle_layer_visible") "t7: layer visibility flipped via state.toggle_layer_visible")
state.toggle_layer_visible(lname) 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 end
-- ===================================================================== -- =====================================================================

View File

@@ -9,7 +9,7 @@
"blob_rect_stone": "lib-asset.prototype-blob-geom" "blob_rect_stone": "lib-asset.prototype-blob-geom"
}, },
"deps": [ "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.render","version":"0.1.0"},
{"id":"lib-core.camera","version":"0.3.0"}, {"id":"lib-core.camera","version":"0.3.0"},
{"id":"lib-core.input","version":"0.4.0"}, {"id":"lib-core.input","version":"0.4.0"},