more editor menus

This commit is contained in:
2026-06-20 18:36:28 -05:00
parent 0dc69c7ebb
commit ea309c3e0d
2 changed files with 35 additions and 2 deletions
+5
View File
@@ -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) {
+30 -2
View File
@@ -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))),
],
}
}