feat(map-editor): fill all seven menu categories with initial items

Items in File / Edit / View / Map / Tools / Window / Help. New Map
and Open Map appear as disabled placeholders pending a v3-aware
maps.create and engine.asset.list_dir. Undo/Redo are disabled
pending an edit-stack. Cycle Rotation / Toggle Flip / Reset
Transform disable themselves in Auto-Tile mode via a mode_is()
callback. Submenus for View > Layers and Tools > Mode are
declared but their items array stays nil until the submenu render
slice.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Calic
2026-06-01 19:55:06 +02:00
parent b5afe35df8
commit 211056ac8c

View File

@@ -445,14 +445,86 @@ local ui = (function()
"topsurface", "surface", "subsurface", "foundation", "topsurface", "surface", "subsurface", "foundation",
} }
-- Item-array stubs for the dropdown system. Filled in T9. -- Item-arrays for the dropdown system (T9).
local FILE_ITEMS = {} -- mode_is must be declared before the arrays so the disabled-callbacks
local EDIT_ITEMS = {} -- capture it as a proper upvalue (Lua resolves upvalues at closure
local VIEW_ITEMS = {} -- creation time).
local MAP_ITEMS = {} local function mode_is(m) return state.get_mode() == m end
local TOOLS_ITEMS = {}
local WINDOW_ITEMS = {} local FILE_ITEMS = {
local HELP_ITEMS = {} { type = "modal", label = "New Map", modal_id = "new_map", disabled = true },
{ type = "modal", label = "Open Map", modal_id = "open_map", disabled = true },
{ type = "action", label = "Save", hotkey = "S", fire = function() actions.save() end },
{ type = "modal", label = "Save As", modal_id = "save_as" },
{ type = "separator" },
{ type = "action", label = "Quit", hotkey = "Esc", fire = function() engine.exit() end },
}
local EDIT_ITEMS = {
{ type = "action", label = "Undo", hotkey = "Ctrl+Z", disabled = true, fire = function() end },
{ type = "action", label = "Redo", hotkey = "Ctrl+Y", disabled = true, fire = function() end },
{ type = "separator" },
{ type = "action", label = "Cycle Rotation", hotkey = "R",
disabled = function() return not mode_is("direct") end,
fire = function() actions.cycle_rotation() end },
{ type = "action", label = "Toggle Flip", hotkey = "H",
disabled = function() return not mode_is("direct") end,
fire = function() actions.toggle_flip() end },
{ type = "action", label = "Reset Transform", hotkey = "0",
disabled = function() return not mode_is("direct") end,
fire = function() actions.reset_transform() end },
{ type = "separator" },
{ type = "action", label = "Erase Cell", hotkey = "E",
fire = function()
local c = state.get_mouse_cell()
if c then actions.erase_cell_at(c.x, c.y) end
end },
}
local VIEW_ITEMS = {
{ type = "toggle", label = "World Overlay", hotkey = "G",
is_on = function() return state.is_world_overlay() end,
fire = function() actions.toggle_world_overlay() end },
{ type = "toggle", label = "Debug Overlay", hotkey = "D",
is_on = function() return state.is_debug_overlay() end,
fire = function() actions.toggle_debug_overlay() end },
{ type = "separator" },
{ type = "toggle", label = "Roof Mode",
is_on = function() return state.is_roof_mode() end,
fire = function() actions.toggle_roof_mode() end },
{ type = "separator" },
{ type = "submenu", label = "Layers", items = nil }, -- populated in T10
}
local MAP_ITEMS = {
{ type = "modal", label = "Map Properties", modal_id = "map_properties" },
{ type = "separator" },
{ type = "action", label = "Reload from Disk",
fire = function()
local id = maps.load(state.get_map_path())
maps.set_current(id)
state.mark_clean()
end },
}
local TOOLS_ITEMS = {
{ type = "submenu", label = "Mode", items = nil }, -- populated in T10
}
local WINDOW_ITEMS = {
{ type = "toggle", label = "Layers Panel",
is_on = function() return state.is_layers_panel_shown() end,
fire = function() state.toggle_layers_panel() end },
{ type = "toggle", label = "Palette",
is_on = function() return state.is_palette_shown() end,
fire = function() state.toggle_palette() end },
}
local HELP_ITEMS = {
{ type = "modal", label = "Cheatsheet", hotkey = "I", modal_id = "cheatsheet" },
{ type = "separator" },
{ type = "modal", label = "About", modal_id = "about" },
}
local MENU_CATEGORIES = { local MENU_CATEGORIES = {
{ name = "File", items = FILE_ITEMS }, { name = "File", items = FILE_ITEMS },