Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detach undo #169

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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