From 5d2289d1c0eeab5610d10a7af35dbbb6fbb0474a Mon Sep 17 00:00:00 2001 From: tuxmain Date: Fri, 26 Aug 2022 10:16:40 +0200 Subject: [PATCH] editor: move camera --- README.md | 6 ++++++ src/editor.rs | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 70716d5..c29d372 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,12 @@ Skip to level `N: u32` with the command `bevyjam `. Edit the level `N: u32` with the command `bevyjam e`. +### Editor controls + +* **Select handles**: left click to select, click in void to deselect, CTRL+click to select many, CTRL+A to select all +* **Move handles**: arrows to move one step, Shift+arrows to move continuously +* **Move camera**: CTRL+arrows + ## License GNU AGPL v3, CopyLeft 2022 Pascal Engélibert, Nixon Cheng diff --git a/src/editor.rs b/src/editor.rs index 08ebb43..5404140 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -184,9 +184,23 @@ fn setup( fn keyboard_input_system( keyboard_input: Res>, + mut camera_query: Query<&mut Transform, (With, Without)>, mut drag_query: Query<(&mut Transform, &Selection, Option<&End>), With>, mut drag_end_event: EventWriter, ) { + if keyboard_input.pressed(KeyCode::LControl) || keyboard_input.pressed(KeyCode::RControl) { + let mut transform = camera_query.single_mut(); + let drag = Vec3 { + x: (keyboard_input.pressed(KeyCode::Right) as i8 + - keyboard_input.pressed(KeyCode::Left) as i8) as _, + y: (keyboard_input.pressed(KeyCode::Up) as i8 + - keyboard_input.pressed(KeyCode::Down) as i8) as _, + z: 0., + } * 8.; + transform.translation += drag; + return; + } + let drag = if keyboard_input.pressed(KeyCode::LShift) || keyboard_input.pressed(KeyCode::RShift) { Vec3 {