Skip to content

Commit

Permalink
First undo/redo logic and background task indicator (#72)
Browse files Browse the repository at this point in the history
* Fix compilation with bevy 0.12

Only compilation, many bugs exists

* FIxed omponents name and visible defaults

* Fix picking, fix platformer scene

* Fix platformer example

* Fix physics spawn and simple spawn examples

* cargo fmt

* cargo clippy

* Update Cargo.toml

* cargo fmt again

* Del shortcut

* Added commands to tools and tabs traits

* Sorted names in inspector and fix xpbd debug render

* cargo fmt

* Cargo clippy

* Fix compiling without features

* Persistance logic

* Hide persistance under feature

* Cache open states

* Loading indicator

* Undo redo base

* added undo plugin

* First worked undo redo for transforms

* Merge branches

---------

Co-authored-by: a.yamaev <[email protected]>
  • Loading branch information
rewin123 and ayamaev-se authored Nov 23, 2023
1 parent 74f1f27 commit 65266fd
Show file tree
Hide file tree
Showing 14 changed files with 862 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Cargo.lock

docs/.obsidian/*
.vscode/launch.json
editor.ron
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bevy_egui = "0.23"
egui-gizmo = "0.12"
bevy-scene-hook = "9"
ron = "0.8"
serde = "1"
bevy_panorbit_camera = "0.9"
bevy-inspector-egui = { version = "0.21", features = ["bevy_pbr", "highlight_changes"]}
pretty-type-name = "1.0"
Expand Down Expand Up @@ -48,6 +49,7 @@ opt-level = 3
[features]
bevy_xpbd_3d = ["dep:bevy_xpbd_3d", "bevy_xpbd_3d/debug-plugin", "bevy_xpbd_3d/3d", "bevy_xpbd_3d/collider-from-mesh", "bevy_xpbd_3d/f32"]
default = ["bevy_xpbd_3d"]
persistance_editor = []

[[example]]
name = "platformer"
Expand Down
10 changes: 9 additions & 1 deletion src/editor/core/gltf_unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use crate::{
PrefabMarker,
};

use super::{BackgroundTask, BackgroundTaskStorage};

#[derive(Event)]
pub struct EditorUnpackGltf {
pub path: String,
Expand Down Expand Up @@ -47,9 +49,15 @@ fn unpack_gltf_event(
mut events: EventReader<EditorUnpackGltf>,
assets: Res<AssetServer>,
mut queue: ResMut<GltfSceneQueue>,
mut background_tasks: ResMut<BackgroundTaskStorage>,
) {
for event in events.read() {
queue.0.push(assets.load(event.path.clone()));
let handle = assets.load(event.path.clone());
background_tasks.tasks.push(BackgroundTask::AssetLoading(
event.path.clone(),
handle.clone().untyped(),
));
queue.0.push(handle);
}
events.clear();
}
Expand Down
26 changes: 24 additions & 2 deletions src/editor/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ use load::*;
pub mod tool;
pub use tool::*;

pub mod task_storage;
pub use task_storage::*;

pub mod undo;
pub use undo::*;

#[cfg(feature = "persistance_editor")]
pub mod persistance;
#[cfg(feature = "persistance_editor")]
pub use persistance::*;

pub mod gltf_unpack;
pub mod settings;

use bevy::prelude::*;

Expand All @@ -24,6 +34,12 @@ impl Plugin for EditorCore {
fn build(&self, app: &mut App) {
app.add_plugins(gltf_unpack::UnpackGltfPlugin);

#[cfg(feature = "persistance_editor")]
app.add_plugins(PersistancePlugin);

app.add_plugins(BackgroundTaskStoragePlugin);
app.add_plugins(UndoPlugin);

app.add_event::<EditorEvent>();

app.init_resource::<PrefabMemoryCache>();
Expand Down Expand Up @@ -67,12 +83,18 @@ fn editor_event_listener(
mut start_game_state: ResMut<NextState<EditorState>>,
cache: ResMut<PrefabMemoryCache>,
mut gltf_events: EventWriter<gltf_unpack::EditorUnpackGltf>,
mut background_tasks: ResMut<BackgroundTaskStorage>,
) {
for event in events.read() {
match event {
EditorEvent::Load(path) => match path {
EditorPrefabPath::File(path) => {
load_server.scene = Some(assets.load(path.to_string()))
let handle = assets.load(path.to_string());
background_tasks.tasks.push(BackgroundTask::AssetLoading(
path.to_string(),
handle.clone().untyped(),
));
load_server.scene = Some(handle);
}
EditorPrefabPath::MemoryCahce => {
load_server.scene = cache.scene.clone();
Expand Down
Loading

0 comments on commit 65266fd

Please sign in to comment.