add key bindings for eraser, selection, blueprint list and 'none' tool

This commit is contained in:
Crispy 2025-04-13 22:25:53 +02:00
parent 454c836b38
commit 44494f4d01
3 changed files with 36 additions and 22 deletions

View file

@ -5,6 +5,7 @@ Game store page: https://crispypin.itch.io/marble-machinations
### added ### added
- create "missing levels" section allowing access to solutions to levels that are no longer available - create "missing levels" section allowing access to solutions to levels that are no longer available
- click to collapse chapters in level list - click to collapse chapters in level list
- input bindings for eraser (X), selection (B), blueprint list (Ctrl B), no tool (no default binding)
### fixed ### fixed
- 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. - 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.
@ -16,7 +17,7 @@ Game store page: https://crispypin.itch.io/marble-machinations
### added ### added
- score number: bounding area - score number: bounding area
- configurable key bindings for many editor actions - configurable key bindings for many editor actions
- QWERTY+ASDFGH keybindings for the tile tools by default - QWERTY+ASDFGH key bindings for the tile tools by default
- OS clipboard copy/paste, with fallback to old behavior when copying - OS clipboard copy/paste, with fallback to old behavior when copying
- cut selection - cut selection
- in-grid text comments (not yet editable in-game) - in-grid text comments (not yet editable in-game)

View file

@ -1060,7 +1060,7 @@ impl Editor {
self.tooltip.add(276, y, 40, 40, "Delete"); self.tooltip.add(276, y, 40, 40, "Delete");
if simple_button((d, &self.mouse), 276, y, 40, 40) if simple_button((d, &self.mouse), 276, y, 40, 40)
|| globals.is_pressed(ActionId::Erase) || globals.is_pressed(ActionId::EraseSelection)
{ {
erase_selection = true; erase_selection = true;
} }
@ -1091,7 +1091,7 @@ impl Editor {
texture: &str, texture: &str,
tooltip: &'static str, tooltip: &'static str,
tool_option: Tool, tool_option: Tool,
action: Option<ActionId>| { action: ActionId| {
let border = 4.; let border = 4.;
let gap = 2.; let gap = 2.;
let button_size = 32. + border * 2.; let button_size = 32. + border * 2.;
@ -1111,20 +1111,26 @@ impl Editor {
tool_option, tool_option,
&mut self.active_tool, &mut self.active_tool,
border, border,
action.map(|a| globals.is_pressed(a)).unwrap_or(false), globals.is_pressed(action),
) )
}; };
tool_button((0, -2), "eraser", "Eraser", Tool::Erase, None); tool_button((0, -2), "eraser", "Eraser", Tool::Erase, ActionId::Eraser);
tool_button( tool_button(
(1, -2), (1, -2),
"selection", "selection",
"Select", "Select",
Tool::SelectArea(Selection::default()), Tool::SelectArea(Selection::default()),
None, ActionId::Selection,
); );
tool_button((0, -1), "blueprint", "Blueprints", Tool::Blueprint, None); tool_button(
tool_button((1, -1), "transparent", "None", Tool::None, None); (0, -1),
"blueprint",
"Blueprints",
Tool::Blueprint,
ActionId::Blueprints,
);
tool_button((1, -1), "transparent", "None", Tool::None, ActionId::NoTool);
if !hide_tile_tools { if !hide_tile_tools {
tool_button( tool_button(
@ -1132,42 +1138,42 @@ impl Editor {
"block", "block",
"Block", "Block",
Tool::SetTile(Tile::from_char('#')), Tool::SetTile(Tile::from_char('#')),
Some(ActionId::TileBlock), ActionId::TileBlock,
); );
tool_button( tool_button(
(0, 1), (0, 1),
"silo_off", "silo_off",
"Silo", "Silo",
Tool::SetTile(Tile::from_char('B')), Tool::SetTile(Tile::from_char('B')),
Some(ActionId::TileSilo), ActionId::TileSilo,
); );
tool_button( tool_button(
(0, 2), (0, 2),
"button_off", "button_off",
"Button", "Button",
Tool::SetTile(Tile::from_char('*')), Tool::SetTile(Tile::from_char('*')),
Some(ActionId::TileButton), ActionId::TileButton,
); );
tool_button( tool_button(
(0, 3), (0, 3),
"io_tile_off", "io_tile_off",
"Input/Output silo", "Input/Output silo",
Tool::SetTile(Tile::from_char('I')), Tool::SetTile(Tile::from_char('I')),
Some(ActionId::TileIOSilo), ActionId::TileIOSilo,
); );
tool_button( tool_button(
(0, 4), (0, 4),
"flipper_off", "flipper_off",
"Flipper", "Flipper",
Tool::SetTile(Tile::from_char('F')), Tool::SetTile(Tile::from_char('F')),
Some(ActionId::TileFlipper), ActionId::TileFlipper,
); );
tool_button( tool_button(
(0, 5), (0, 5),
"digit_tool", "digit_tool",
"Digit", "Digit",
Tool::Digits(None), Tool::Digits(None),
Some(ActionId::TileDigit), ActionId::TileDigit,
); );
tool_button( tool_button(
@ -1175,14 +1181,14 @@ impl Editor {
"marble", "marble",
"Marble", "Marble",
Tool::SetTile(Tile::from_char('o')), Tool::SetTile(Tile::from_char('o')),
Some(ActionId::TileMarble), ActionId::TileMarble,
); );
match tool_button( match tool_button(
(1, 1), (1, 1),
self.tool_wire.texture_name_off(), self.tool_wire.texture_name_off(),
self.tool_wire.human_name(), self.tool_wire.human_name(),
Tool::Wire, Tool::Wire,
Some(ActionId::TileGroupWire), ActionId::TileGroupWire,
) { ) {
Some(Scroll::Down) => self.tool_wire.next(), Some(Scroll::Down) => self.tool_wire.next(),
Some(Scroll::Up) => self.tool_wire.prev(), Some(Scroll::Up) => self.tool_wire.prev(),
@ -1194,7 +1200,7 @@ impl Editor {
self.tool_arrow.arrow_tile_texture_name(), self.tool_arrow.arrow_tile_texture_name(),
self.tool_arrow.arrow_tile_human_name(), self.tool_arrow.arrow_tile_human_name(),
Tool::Arrow, Tool::Arrow,
Some(ActionId::TileGroupArrow), ActionId::TileGroupArrow,
) { ) {
Some(Scroll::Down) => self.tool_arrow = self.tool_arrow.right(), Some(Scroll::Down) => self.tool_arrow = self.tool_arrow.right(),
Some(Scroll::Up) => self.tool_arrow = self.tool_arrow.left(), Some(Scroll::Up) => self.tool_arrow = self.tool_arrow.left(),
@ -1205,7 +1211,7 @@ impl Editor {
self.tool_mirror.texture_name(), self.tool_mirror.texture_name(),
self.tool_mirror.human_name(), self.tool_mirror.human_name(),
Tool::Mirror, Tool::Mirror,
Some(ActionId::TileGroupMirror), ActionId::TileGroupMirror,
) )
.is_some() .is_some()
{ {
@ -1216,7 +1222,7 @@ impl Editor {
self.tool_math.texture_name_off(), self.tool_math.texture_name_off(),
self.tool_math.human_name(), self.tool_math.human_name(),
Tool::Math, Tool::Math,
Some(ActionId::TileGroupMath), ActionId::TileGroupMath,
) { ) {
Some(Scroll::Down) => self.tool_math.next(), Some(Scroll::Down) => self.tool_math.next(),
Some(Scroll::Up) => self.tool_math.prev(), Some(Scroll::Up) => self.tool_math.prev(),
@ -1227,7 +1233,7 @@ impl Editor {
self.tool_comparator.texture_name_off(), self.tool_comparator.texture_name_off(),
self.tool_comparator.human_name(), self.tool_comparator.human_name(),
Tool::Comparator, Tool::Comparator,
Some(ActionId::TileGroupCompare), ActionId::TileGroupCompare,
) { ) {
Some(Scroll::Down) => self.tool_comparator.next(), Some(Scroll::Down) => self.tool_comparator.next(),
Some(Scroll::Up) => self.tool_comparator.prev(), Some(Scroll::Up) => self.tool_comparator.prev(),

View file

@ -23,7 +23,7 @@ pub enum ActionId {
Copy, Copy,
Cut, Cut,
Paste, Paste,
Erase, EraseSelection,
ToggleMenu, ToggleMenu,
Save, Save,
StartSim, StartSim,
@ -32,6 +32,10 @@ pub enum ActionId {
CycleGroup, CycleGroup,
CycleGroupRevMod, CycleGroupRevMod,
Eraser,
Selection,
Blueprints,
NoTool,
TileBlock, TileBlock,
TileSilo, TileSilo,
TileButton, TileButton,
@ -65,7 +69,7 @@ impl Default for Input {
bind_key(ActionId::Copy, vec![LCtrl], C); bind_key(ActionId::Copy, vec![LCtrl], C);
bind_key(ActionId::Cut, vec![LCtrl], X); bind_key(ActionId::Cut, vec![LCtrl], X);
bind_key(ActionId::Paste, vec![LCtrl], V); bind_key(ActionId::Paste, vec![LCtrl], V);
bind_key(ActionId::Erase, vec![], Backspace); bind_key(ActionId::EraseSelection, vec![], Backspace);
bind_key(ActionId::ToggleMenu, vec![], Escape); bind_key(ActionId::ToggleMenu, vec![], Escape);
bind_key(ActionId::Save, vec![LCtrl], S); bind_key(ActionId::Save, vec![LCtrl], S);
bind_key(ActionId::StartSim, vec![], Enter); bind_key(ActionId::StartSim, vec![], Enter);
@ -73,6 +77,9 @@ impl Default for Input {
bind_key(ActionId::StepSim, vec![], Space); bind_key(ActionId::StepSim, vec![], Space);
bind_key(ActionId::CycleGroup, vec![], Tab); bind_key(ActionId::CycleGroup, vec![], Tab);
bind_key(ActionId::CycleGroupRevMod, vec![], LShift); 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::TileBlock, vec![], Q);
bind_key(ActionId::TileSilo, vec![], W); bind_key(ActionId::TileSilo, vec![], W);
bind_key(ActionId::TileButton, vec![], E); bind_key(ActionId::TileButton, vec![], E);