mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
First try to add undo
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ resolver = "2"
|
||||
members = ["./studio"]
|
||||
|
||||
[workspace.dependencies.bevy]
|
||||
version = "0.12.0"
|
||||
version = "0.12.1"
|
||||
features = ["tonemapping_luts"]
|
||||
|
||||
[profile.dev-custom]
|
||||
|
||||
@@ -32,6 +32,7 @@ web-sys = { version = "0.3.65", optional = true, features = [
|
||||
"HtmlElement",
|
||||
"Window",
|
||||
] }
|
||||
space_editor = {git = "https://github.com/rewin123/space_editor", rev = "f039601b6d286a5f9e3b09521623000d5bf3eb84"}
|
||||
|
||||
[features]
|
||||
wasm = [
|
||||
|
||||
@@ -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