From ea309c3e0d1ce228a4a82e4c00dd959c19f8f376 Mon Sep 17 00:00:00 2001 From: Ross Andrews Date: Sat, 20 Jun 2026 18:36:28 -0500 Subject: [PATCH] more editor menus --- kiln-tui/src/editor.rs | 5 +++++ kiln-tui/src/editor_menu.rs | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/kiln-tui/src/editor.rs b/kiln-tui/src/editor.rs index 83a9847..913ff74 100644 --- a/kiln-tui/src/editor.rs +++ b/kiln-tui/src/editor.rs @@ -226,6 +226,11 @@ impl EditorState { )); } + pub(crate) fn set_current(&mut self, archetype: Archetype) { + self.current_archetype = archetype; + self.current_glyph = self.current_archetype.default_glyph(); + } + /// Stamps the current drawing thing (archetype + glyph) into the cell under the /// cursor, applying the placement rules (see [`Board::place_archetype`]). pub(crate) fn place_current(&mut self) { diff --git a/kiln-tui/src/editor_menu.rs b/kiln-tui/src/editor_menu.rs index 4b33347..3efd312 100644 --- a/kiln-tui/src/editor_menu.rs +++ b/kiln-tui/src/editor_menu.rs @@ -1,3 +1,4 @@ +use kiln_core::{Archetype, Direction}; use crate::editor::EditorState; use crate::menu::{MenuItem, MenuKey}; use crate::mode::PendingMode; @@ -15,7 +16,13 @@ pub(crate) enum MenuLevel { /// Menu of world-related concerns: set name / entry board World, /// Menu of floor options - Floor + Floor, + /// Normal things that go on a board: terrain + Terrain, + /// Things that do defined actions: machines + Machines, + /// Various directions of pushers + Pushers, } impl MenuLevel { @@ -24,7 +31,10 @@ impl MenuLevel { match self { MenuLevel::Main => "Main", MenuLevel::World => "World", - MenuLevel::Floor => "Floor" + MenuLevel::Floor => "Floor", + MenuLevel::Terrain => "Terrain", + MenuLevel::Machines => "Machines", + MenuLevel::Pushers => "Pushers", } } @@ -37,6 +47,8 @@ impl MenuLevel { MenuEntry::item('b', "Boards...", |ed| ed.open_boards_dialog()), MenuEntry::Separator, MenuEntry::item('f', "Floor", |ed| ed.menu.push(MenuLevel::Floor)), + MenuEntry::item('t', "Terrain", |ed| ed.menu.push(MenuLevel::Terrain)), + MenuEntry::item('m', "Machines", |ed| ed.menu.push(MenuLevel::Machines)), ], MenuLevel::World => vec![ MenuEntry::item('n', "Name", |ed| ed.open_name_dialog()), @@ -50,6 +62,22 @@ impl MenuLevel { MenuEntry::item('s', "Stone", |_| {}), MenuEntry::item('c', "Custom glyph [TODO]", |_| {}), ], + MenuLevel::Terrain => vec![ + MenuEntry::item('w', "Wall", |ed| ed.set_current(Archetype::Wall)), + MenuEntry::item('c', "■ Crate", |ed| ed.set_current(Archetype::Crate)), + MenuEntry::item('v', "↕ Crate", |ed| ed.set_current(Archetype::VCrate)), + MenuEntry::item('h', "↔ Crate", |ed| ed.set_current(Archetype::HCrate)), + + ], + MenuLevel::Machines => vec![ + MenuEntry::item('p', "Pushers...", |ed| ed.menu.push(MenuLevel::Pushers)), + ], + MenuLevel::Pushers => vec![ + MenuEntry::item('n', "▲ Pusher", |ed| ed.set_current(Archetype::Pusher(Direction::North))), + MenuEntry::item('s', "▼ Pusher", |ed| ed.set_current(Archetype::Pusher(Direction::South))), + MenuEntry::item('e', "► Pusher", |ed| ed.set_current(Archetype::Pusher(Direction::East))), + MenuEntry::item('w', "◄ Pusher", |ed| ed.set_current(Archetype::Pusher(Direction::West))), + ], } }