Skip to content

Commit

Permalink
Merge pull request #169 from rewin123/detach-undo
Browse files Browse the repository at this point in the history
Detach undo
  • Loading branch information
rewin123 authored Jan 9, 2024
2 parents ac3863d + 1d99cdc commit f039601
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion crates/editor_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ use space_shared::{
ext::bevy_inspector_egui::{quick::WorldInspectorPlugin, DefaultInspectorConfigPlugin},
EditorCameraMarker, EditorSet, EditorState, PrefabMarker, PrefabMemoryCache,
};
use space_undo::UndoPlugin;
use space_undo::{UndoPlugin, UndoSet};
use ui_registration::BundleReg;

use self::{
Expand Down Expand Up @@ -127,6 +127,7 @@ impl Plugin for EditorPlugin {
app.add_plugins(bevy_egui::EguiPlugin);
}
app.add_plugins(UndoPlugin); //Undo must be included before prefab plugin for undo registration
app.configure_sets(PostUpdate, UndoSet::Global.in_set(EditorSet::Editor));
if !app.is_plugin_added::<PrefabPlugin>() {
app.add_plugins(PrefabPlugin);
}
Expand Down
12 changes: 7 additions & 5 deletions crates/undo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::Arc;

use bevy::{prelude::*, utils::HashMap};

use space_shared::{EditorSet, PrefabMarker};
use space_shared::PrefabMarker;

const MAX_REFLECT_RECURSION: i32 = 10;
const AUTO_UNDO_LATENCY: i32 = 2;
Expand All @@ -14,8 +14,10 @@ pub struct UndoPlugin;
#[derive(SystemSet, Hash, PartialEq, Eq, Debug, Clone)]
pub enum UndoSet {
PerType,
Global,
UpdateAll,
Remaping,
///Contains all undo sets
Global,
}

impl Plugin for UndoPlugin {
Expand All @@ -31,9 +33,9 @@ impl Plugin for UndoPlugin {

app.configure_sets(
PostUpdate,
(UndoSet::PerType, UndoSet::Global, UndoSet::Remaping)
(UndoSet::PerType, UndoSet::UpdateAll, UndoSet::Remaping)
.chain()
.in_set(EditorSet::Editor),
.in_set(UndoSet::Global),
);

app.add_systems(
Expand All @@ -45,7 +47,7 @@ impl Plugin for UndoPlugin {
undo_ignore_tick,
)
.chain()
.in_set(UndoSet::Global),
.in_set(UndoSet::UpdateAll),
);
}
}
Expand Down

0 comments on commit f039601

Please sign in to comment.