First try to add undo

This commit is contained in:
rewin
2024-01-09 23:24:51 +03:00
parent e0cf0efc7a
commit a7d1f80554
4 changed files with 19 additions and 2 deletions
+14
View File
@@ -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");
}
}