diff --git a/studio/Cargo.toml b/studio/Cargo.toml index 3044bb6..7991ccc 100644 --- a/studio/Cargo.toml +++ b/studio/Cargo.toml @@ -32,7 +32,7 @@ web-sys = { version = "0.3.65", optional = true, features = [ "HtmlElement", "Window", ] } -space_editor = {git = "https://github.com/rewin123/space_editor", rev = "a6804e63428e29d858d8b5c0eabeb4fe7b2aa7f4"} +space_editor = {git = "https://github.com/rewin123/space_editor", rev = "f3e2e0de52540125b79dad98656382ff473dedc2"} [features] wasm = [ diff --git a/studio/src/input.rs b/studio/src/input.rs index 65f4370..e88fcfd 100644 --- a/studio/src/input.rs +++ b/studio/src/input.rs @@ -318,8 +318,13 @@ fn read_mouse_delta( // TODO: Make it configurable fn send_undo_event(mut events: EventWriter, keyboard: Res>) { - if keyboard.pressed(KeyCode::ControlLeft) && keyboard.just_pressed(KeyCode::Z) { + if keyboard.pressed(KeyCode::ControlLeft) && keyboard.just_pressed(KeyCode::Z) && !keyboard.pressed(KeyCode::ShiftLeft) { events.send(UndoRedo::Undo); info!("Undo event sent"); } + + if keyboard.pressed(KeyCode::ControlLeft) && keyboard.just_pressed(KeyCode::Z) && keyboard.pressed(KeyCode::ShiftLeft) { + events.send(UndoRedo::Redo); + info!("Redo event sent"); + } } diff --git a/studio/src/interaction/selection.rs b/studio/src/interaction/selection.rs index fa600fe..eccdd5c 100644 --- a/studio/src/interaction/selection.rs +++ b/studio/src/interaction/selection.rs @@ -32,6 +32,11 @@ impl Plugin for SelectionPlugin { .map(bevy::utils::error) .run_if(resource_changed_or_removed::()), ); + + app.add_systems( + Update, + sync_editor_selected + ); } } @@ -44,6 +49,30 @@ pub struct Selected; #[derive(Resource, Deref, DerefMut, Debug)] pub struct Selection(Entity); +fn sync_editor_selected( + mut cmd: Commands, + q_new_selected: Query, Without)>, + q_editor_selected: Query>, + q_selected: Query>, + q_added_editor_selected: Query, Added)>, +) { + for ent in q_new_selected.iter() { + for ed_ent in q_editor_selected.iter() { + cmd.entity(ed_ent).remove::(); + } + cmd.entity(ent).insert(space_editor::prelude::Selected); + } + + for ent in q_added_editor_selected.iter() { + cmd.entity(ent).insert(Selected); + cmd.insert_resource(Selection(ent)); + + for ent in q_selected.iter() { + cmd.entity(ent).remove::(); + } + } +} + fn tag_scene_elements( mut cmd: Commands, q_scene_elements: Query<(Entity, &Children), (With, Without)>,