mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-18 00:23:14 +00:00
First try to add undo
This commit is contained in:
@@ -3,6 +3,7 @@ use bevy::{
|
||||
prelude::*,
|
||||
utils::HashSet,
|
||||
};
|
||||
use space_editor::prelude::space_undo::UndoRedo;
|
||||
|
||||
#[derive(SystemSet, Hash, Debug, PartialEq, Eq, Clone)]
|
||||
pub struct StudioInputSystem;
|
||||
@@ -18,6 +19,7 @@ impl Plugin for StudioInputPlugin {
|
||||
translate_debug_toggle,
|
||||
translate_dcc_camera_events,
|
||||
translate_fps_camera_events,
|
||||
send_undo_event
|
||||
)
|
||||
.in_set(StudioInputSystem)
|
||||
.after(bevy::input::InputSystem),
|
||||
@@ -291,3 +293,15 @@ fn read_mouse_delta(mut mouse_motion: EventReader<MouseMotion>) -> Vec2 {
|
||||
.read()
|
||||
.fold(Vec2::ZERO, |accum, current| accum + current.delta)
|
||||
}
|
||||
|
||||
|
||||
// TODO: Make it configurable
|
||||
fn send_undo_event(
|
||||
mut events : EventWriter<UndoRedo>,
|
||||
keyboard: Res<Input<KeyCode>>,
|
||||
) {
|
||||
if keyboard.pressed(KeyCode::ControlLeft) && keyboard.just_pressed(KeyCode::Z) {
|
||||
events.send(UndoRedo::Undo);
|
||||
info!("Undo event sent");
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -13,6 +13,7 @@ use bevy::{
|
||||
scene::InstanceId,
|
||||
};
|
||||
|
||||
use space_editor::prelude::PrefabMarker;
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
@@ -207,6 +208,7 @@ fn spawn_next_scene(
|
||||
SceneRoot,
|
||||
SceneElement,
|
||||
SpatialBundle::default(),
|
||||
PrefabMarker
|
||||
))
|
||||
.id();
|
||||
|
||||
@@ -254,7 +256,7 @@ fn tag_scene_elements(
|
||||
};
|
||||
|
||||
if gltf.named_nodes.contains_key(&**name) {
|
||||
cmd.entity(ent).insert(SceneElement);
|
||||
cmd.entity(ent).insert(SceneElement).insert(PrefabMarker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user