diff --git a/README.md b/README.md index 2f92f82..625a5eb 100644 --- a/README.md +++ b/README.md @@ -11,20 +11,20 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble - comments - editing - add to all intro levels +- UI layout engine + - global scale setting - highlight regions with background colours - accessibility - - ui scaling - background colour setting - hotkeys for everything (no mouse needed to play) - - font selection (probably a lot of work) - more levels - footprint and bounding box stats (instead of area) - scroll output bytes -- cut selections, copy to system clipboard - timestamps in solutions and blueprints - lock tile types for early levels to make it less overwhelming - display tool variant more clearly (it's not obvious there are more states) - better text rendering + - font selection (probably a lot of work) ### online stuff - store scores in server - validate solutions in server (with limits) diff --git a/assets/cut.png b/assets/cut.png new file mode 100644 index 0000000..20daa77 Binary files /dev/null and b/assets/cut.png differ diff --git a/src/editor.rs b/src/editor.rs index 7820d57..ed07b31 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -1036,8 +1036,31 @@ impl Editor { draw_scaled_texture(d, globals.get_tex("save"), 148, y + 4, 2.); self.tooltip.add(188, y, 40, 40, "Copy"); + let mut copy_selection = false; if simple_button((d, &self.mouse), 188, y, 40, 40) || globals.is_pressed(ActionId::Copy) { + copy_selection = true; + } + draw_scaled_texture(d, globals.get_tex("copy"), 192, y + 4, 2.); + + self.tooltip.add(232, y, 40, 40, "Cut"); + let mut erase_selection = false; + if simple_button((d, &self.mouse), 232, y, 40, 40) || globals.is_pressed(ActionId::Cut) + { + copy_selection = true; + erase_selection = true; + } + draw_scaled_texture(d, globals.get_tex("cut"), 236, y + 4, 2.); + + self.tooltip.add(276, y, 40, 40, "Delete"); + if simple_button((d, &self.mouse), 276, y, 40, 40) + || globals.is_pressed(ActionId::Erase) + { + erase_selection = true; + } + draw_scaled_texture(d, globals.get_tex("eraser"), 280, y + 4, 2.); + + if copy_selection { let board = self.get_selected_as_board(selection); if let Some(clipboard) = &mut globals.clipboard { clipboard @@ -1047,10 +1070,7 @@ impl Editor { self.pasting_board = Some(board); } } - draw_scaled_texture(d, globals.get_tex("copy"), 192, y + 4, 2.); - - self.tooltip.add(232, y, 40, 40, "Delete"); - if simple_button((d, &self.mouse), 232, y, 40, 40) { + if erase_selection { let min = selection.0.min(selection.1); let max = selection.0.max(selection.1); let board = Board::new(Grid::new_empty( @@ -1059,7 +1079,6 @@ impl Editor { )); self.set_area(min, board); } - draw_scaled_texture(d, globals.get_tex("eraser"), 236, y + 4, 2.); } let mut tool_button = |(row, col): (i32, i32), diff --git a/src/input.rs b/src/input.rs index d15dd18..b705f2b 100644 --- a/src/input.rs +++ b/src/input.rs @@ -21,7 +21,9 @@ pub enum ActionId { Undo, Redo, Copy, + Cut, Paste, + Erase, ToggleMenu, StartSim, StopSim, @@ -59,7 +61,9 @@ impl Default for Input { bind_key(ActionId::Redo, vec![LCtrl], Y); bind_key(ActionId::Redo, vec![LCtrl, LShift], Z); bind_key(ActionId::Copy, vec![LCtrl], C); + bind_key(ActionId::Cut, vec![LCtrl], X); bind_key(ActionId::Paste, vec![LCtrl], V); + bind_key(ActionId::Erase, vec![], Backspace); bind_key(ActionId::ToggleMenu, vec![], Escape); bind_key(ActionId::StartSim, vec![], Enter); bind_key(ActionId::StopSim, vec![], Enter);