diff --git a/CHANGELOG.md b/CHANGELOG.md index 651c1b8..b6e086f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,7 @@ Game store page: https://crispypin.itch.io/marble-machinations ### added - create "missing levels" section allowing access to solutions to levels that are no longer available - click to collapse chapters in level list -- input bindings for eraser (X), selection (B), blueprint list (Ctrl B), no tool (no default binding) ### fixed -- when start and stop are bound to the same thing (as by default), only start works - When two input bindings had the same trigger but one has a strict subset of the others modifiers, both would activate when the one with more modifiers was pressed. For example (Ctrl+S -> Save) would also trigger (S -> Wire Tool). Now, Shift+S will still trigger Wire Tool, unless Shift+S (or eg. Shift+Ctrl+S) is bound to something else. ## v0.3.1 - 2025-04-05 @@ -18,7 +16,7 @@ Game store page: https://crispypin.itch.io/marble-machinations ### added - score number: bounding area - configurable key bindings for many editor actions -- QWERTY+ASDFGH key bindings for the tile tools by default +- QWERTY+ASDFGH keybindings for the tile tools by default - OS clipboard copy/paste, with fallback to old behavior when copying - cut selection - in-grid text comments (not yet editable in-game) diff --git a/src/editor.rs b/src/editor.rs index f8fa6a1..4db5372 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -478,25 +478,22 @@ impl Editor { if globals.is_pressed(ActionId::StepSim) { self.step_pressed() } - match self.sim_state { - SimState::Editing => { - if globals.is_pressed(ActionId::StartSim) { + if globals.is_pressed(ActionId::StartSim) { + match self.sim_state { + SimState::Editing => { self.init_sim(); self.sim_state = SimState::Running; } + SimState::Stepping => self.sim_state = SimState::Running, + SimState::Running => (), } - SimState::Stepping => { - if globals.is_pressed(ActionId::StartSim) { - self.sim_state = SimState::Running - } else if globals.is_pressed(ActionId::StopSim) { + } else if globals.is_pressed(ActionId::StopSim) { + match self.sim_state { + SimState::Running | SimState::Stepping => { self.sim_state = SimState::Editing; self.popup = Popup::None; } - } - SimState::Running => { - if globals.is_pressed(ActionId::StopSim) { - self.sim_state = SimState::Editing; - } + SimState::Editing => (), } } @@ -1063,7 +1060,7 @@ impl Editor { self.tooltip.add(276, y, 40, 40, "Delete"); if simple_button((d, &self.mouse), 276, y, 40, 40) - || globals.is_pressed(ActionId::EraseSelection) + || globals.is_pressed(ActionId::Erase) { erase_selection = true; } @@ -1094,7 +1091,7 @@ impl Editor { texture: &str, tooltip: &'static str, tool_option: Tool, - action: ActionId| { + action: Option| { let border = 4.; let gap = 2.; let button_size = 32. + border * 2.; @@ -1114,26 +1111,20 @@ impl Editor { tool_option, &mut self.active_tool, border, - globals.is_pressed(action), + action.map(|a| globals.is_pressed(a)).unwrap_or(false), ) }; - tool_button((0, -2), "eraser", "Eraser", Tool::Erase, ActionId::Eraser); + tool_button((0, -2), "eraser", "Eraser", Tool::Erase, None); tool_button( (1, -2), "selection", "Select", Tool::SelectArea(Selection::default()), - ActionId::Selection, + None, ); - tool_button( - (0, -1), - "blueprint", - "Blueprints", - Tool::Blueprint, - ActionId::Blueprints, - ); - tool_button((1, -1), "transparent", "None", Tool::None, ActionId::NoTool); + tool_button((0, -1), "blueprint", "Blueprints", Tool::Blueprint, None); + tool_button((1, -1), "transparent", "None", Tool::None, None); if !hide_tile_tools { tool_button( @@ -1141,42 +1132,42 @@ impl Editor { "block", "Block", Tool::SetTile(Tile::from_char('#')), - ActionId::TileBlock, + Some(ActionId::TileBlock), ); tool_button( (0, 1), "silo_off", "Silo", Tool::SetTile(Tile::from_char('B')), - ActionId::TileSilo, + Some(ActionId::TileSilo), ); tool_button( (0, 2), "button_off", "Button", Tool::SetTile(Tile::from_char('*')), - ActionId::TileButton, + Some(ActionId::TileButton), ); tool_button( (0, 3), "io_tile_off", "Input/Output silo", Tool::SetTile(Tile::from_char('I')), - ActionId::TileIOSilo, + Some(ActionId::TileIOSilo), ); tool_button( (0, 4), "flipper_off", "Flipper", Tool::SetTile(Tile::from_char('F')), - ActionId::TileFlipper, + Some(ActionId::TileFlipper), ); tool_button( (0, 5), "digit_tool", "Digit", Tool::Digits(None), - ActionId::TileDigit, + Some(ActionId::TileDigit), ); tool_button( @@ -1184,14 +1175,14 @@ impl Editor { "marble", "Marble", Tool::SetTile(Tile::from_char('o')), - ActionId::TileMarble, + Some(ActionId::TileMarble), ); match tool_button( (1, 1), self.tool_wire.texture_name_off(), self.tool_wire.human_name(), Tool::Wire, - ActionId::TileGroupWire, + Some(ActionId::TileGroupWire), ) { Some(Scroll::Down) => self.tool_wire.next(), Some(Scroll::Up) => self.tool_wire.prev(), @@ -1203,7 +1194,7 @@ impl Editor { self.tool_arrow.arrow_tile_texture_name(), self.tool_arrow.arrow_tile_human_name(), Tool::Arrow, - ActionId::TileGroupArrow, + Some(ActionId::TileGroupArrow), ) { Some(Scroll::Down) => self.tool_arrow = self.tool_arrow.right(), Some(Scroll::Up) => self.tool_arrow = self.tool_arrow.left(), @@ -1214,7 +1205,7 @@ impl Editor { self.tool_mirror.texture_name(), self.tool_mirror.human_name(), Tool::Mirror, - ActionId::TileGroupMirror, + Some(ActionId::TileGroupMirror), ) .is_some() { @@ -1225,7 +1216,7 @@ impl Editor { self.tool_math.texture_name_off(), self.tool_math.human_name(), Tool::Math, - ActionId::TileGroupMath, + Some(ActionId::TileGroupMath), ) { Some(Scroll::Down) => self.tool_math.next(), Some(Scroll::Up) => self.tool_math.prev(), @@ -1236,7 +1227,7 @@ impl Editor { self.tool_comparator.texture_name_off(), self.tool_comparator.human_name(), Tool::Comparator, - ActionId::TileGroupCompare, + Some(ActionId::TileGroupCompare), ) { Some(Scroll::Down) => self.tool_comparator.next(), Some(Scroll::Up) => self.tool_comparator.prev(), diff --git a/src/input.rs b/src/input.rs index 6ad84c6..bc4241b 100644 --- a/src/input.rs +++ b/src/input.rs @@ -23,7 +23,7 @@ pub enum ActionId { Copy, Cut, Paste, - EraseSelection, + Erase, ToggleMenu, Save, StartSim, @@ -32,10 +32,6 @@ pub enum ActionId { CycleGroup, CycleGroupRevMod, - Eraser, - Selection, - Blueprints, - NoTool, TileBlock, TileSilo, TileButton, @@ -69,7 +65,7 @@ impl Default for Input { bind_key(ActionId::Copy, vec![LCtrl], C); bind_key(ActionId::Cut, vec![LCtrl], X); bind_key(ActionId::Paste, vec![LCtrl], V); - bind_key(ActionId::EraseSelection, vec![], Backspace); + bind_key(ActionId::Erase, vec![], Backspace); bind_key(ActionId::ToggleMenu, vec![], Escape); bind_key(ActionId::Save, vec![LCtrl], S); bind_key(ActionId::StartSim, vec![], Enter); @@ -77,9 +73,6 @@ impl Default for Input { bind_key(ActionId::StepSim, vec![], Space); bind_key(ActionId::CycleGroup, vec![], Tab); bind_key(ActionId::CycleGroupRevMod, vec![], LShift); - bind_key(ActionId::Eraser, vec![], X); - bind_key(ActionId::Blueprints, vec![LCtrl], B); - bind_key(ActionId::Selection, vec![], B); bind_key(ActionId::TileBlock, vec![], Q); bind_key(ActionId::TileSilo, vec![], W); bind_key(ActionId::TileButton, vec![], E);