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

V0.6 bevy 0.14 #312

Merged
merged 19 commits into from
Sep 14, 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
2,536 changes: 1,342 additions & 1,194 deletions Cargo.lock

Large diffs are not rendered by default.

37 changes: 17 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repository = "https://github.com/rewin123/space_editor"
homepage = "https://github.com/rewin123/space_editor"

[workspace.dependencies]
bevy = "0.13.2"
bevy = "0.14"

# Editor Crates
space_prefab = { version = "0.6.0", path = "crates/prefab" }
Expand All @@ -57,24 +57,25 @@ space_editor_tabs = { version = "0.6.0", path = "crates/editor_tabs" }

# Crates inner libraries
anyhow = "1.0"
bevy_asset_loader = "0.20"
bevy_debug_grid = "0.5"
bevy_egui = "0.25"
bevy-inspector-egui = { version = "0.23", features = [
bevy_asset_loader = "0.21"
bevy_debug_grid = "0.6"
bevy_egui = "0.28"
bevy-inspector-egui = { version = "0.25", features = [
"bevy_pbr",
"highlight_changes",
] }
bevy_mod_billboard = { git = "https://github.com/kulkalkul/bevy_mod_billboard", branch = "main" }
bevy_mod_picking = { version = "0.18.2", default-features = false, features = ["backend_raycast", "selection",] }
bevy_panorbit_camera = { version = "0.16", default-features = false }
bevy-scene-hook = "10"
bevy_mod_billboard = { git = "https://github.com/rewin123/bevy_mod_billboard.git", branch = "bevy-0.14" }
bevy_mod_picking = { version = "0.20.1", default-features = false, features = ["backend_raycast", "selection",] }
bevy_panorbit_camera = { version = "0.19", default-features = false }
bevy-scene-hook = {git = "https://github.com/stargazing-dino/bevy-scene-hook.git", branch= "update-14.0"}
convert_case = "0.6"
egui_dock = "0.11"
egui_extras = { version = "0.26", features = ["all_loaders"] }
egui_file = "0.15"
egui-gizmo = "0.16.1"
egui-toast = "0.12.1"
image = {version = "0.24.8", feature = ["png"] }
egui_dock = "0.13"
egui_extras = { version = "0.28.1", features = ["all_loaders"] }
egui_file = "0.18"
transform-gizmo-egui = "0.3.0"
transform-gizmo-bevy = "0.3.0"
egui-toast = "0.14.0"
image = {version = "0.25.1", feature = ["png"] }
pretty-type-name = "1"
rand = "*"
ron = "0.8"
Expand All @@ -83,7 +84,7 @@ serde = "1"
# Community Modules
space_bevy_xpbd_plugin = { version = "0.6.0", path = "modules/bevy_xpbd_plugin"}
game_app = { version = "0.1.0", path = "game" }
bevy_xpbd_3d = { version = "0.4.2", default-features = false }
avian3d = { version = "0.1.0", default-features = false }

[dependencies]
bevy.workspace = true
Expand Down Expand Up @@ -159,10 +160,6 @@ default = [
"space_prefab/editor",
]

[[example]]
name = "platformer"
required-features = ["bevy_xpbd_3d"]


[[example]]
name = "spawn_prefab_with_physics"
Expand Down
2 changes: 1 addition & 1 deletion crates/editor_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bevy_egui.workspace = true
egui_dock.workspace = true
egui-toast.workspace = true

bevy_mod_outline = {version = "0.7.0", optional = true}
bevy_mod_outline = {git = "https://github.com/komadori/bevy_mod_outline.git", optional = true}
workspace-hakari = { version = "0.1", path = "../../workspace-hakari" }

[features]
Expand Down
2 changes: 1 addition & 1 deletion crates/editor_core/src/gltf_unpack.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{
asset::{AssetPath, LoadState},
ecs::system::CommandQueue,
ecs::world::CommandQueue,
gltf::{Gltf, GltfMesh, GltfNode},
prelude::*,
utils::HashMap,
Expand Down
16 changes: 8 additions & 8 deletions crates/editor_core/src/hotkeys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ pub trait HotkeyAppExt {

impl HotkeyAppExt for App {
fn editor_hotkey<T: Hotkey>(&mut self, key: T, binding: Vec<KeyCode>) -> &mut Self {
if !self.world.contains_resource::<AllHotkeys>() {
if !self.world().contains_resource::<AllHotkeys>() {
self.insert_resource(AllHotkeys::default());
}

if !self.world.contains_resource::<HotkeySet<T>>() {
if !self.world().contains_resource::<HotkeySet<T>>() {
self.insert_resource(HotkeySet::<T>::default());
self.init_resource::<ButtonInput<T>>();
#[cfg(feature = "persistence_editor")]
{
if self.world.contains_resource::<PersistenceRegistry>() {
if self.world().contains_resource::<PersistenceRegistry>() {
self.persistence_resource_with_fn::<HotkeySet<T>>(Box::new(
|dst: &mut HotkeySet<T>, src: HotkeySet<T>| {
dst.bindings.extend(src.bindings);
Expand All @@ -129,7 +129,7 @@ impl HotkeyAppExt for App {
self.register_type::<HotkeySet<T>>();
self.register_type::<HashMap<T, Vec<KeyCode>>>();
self.register_type::<T>();
self.world
self.world_mut()
// Safe, was injected in this function
.resource_mut::<AllHotkeys>()
.mappers
Expand All @@ -141,7 +141,7 @@ impl HotkeyAppExt for App {
});
}));

self.world
self.world_mut()
// Safe, was injected in this function
.resource_mut::<AllHotkeys>()
.global_mapper
Expand All @@ -152,7 +152,7 @@ impl HotkeyAppExt for App {
}))
}

let Some(mut set) = self.world.get_resource_mut::<HotkeySet<T>>() else {
let Some(mut set) = self.world_mut().get_resource_mut::<HotkeySet<T>>() else {
return self;
};
set.bindings.insert(key, binding);
Expand Down Expand Up @@ -213,14 +213,14 @@ mod tests {

app.update();
{
let mut input = app.world.resource_mut::<ButtonInput<KeyCode>>();
let mut input = app.world_mut().resource_mut::<ButtonInput<KeyCode>>();
input.press(KeyCode::KeyA);
assert!(input.pressed(KeyCode::KeyA));
}
app.update();

{
let input = app.world.resource::<ButtonInput<TestKey>>();
let input = app.world().resource::<ButtonInput<TestKey>>();
assert_eq!(input.pressed(TestKey::A), true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/editor_core/src/selected.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn selected_entity_wireframe_update(
cmds.entity(e).insert(OutlineBundle {
outline: OutlineVolume {
visible: true,
colour: Color::YELLOW,
colour: Color::srgb(1.0, 1.0, 0.0),
width: 2.0,
},
mode: bevy_mod_outline::OutlineMode::RealVertex,
Expand Down
12 changes: 9 additions & 3 deletions crates/editor_core/src/task_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn update_storage(mut storage: ResMut<BackgroundTaskStorage>, assets: Res<AssetS
let load_state = assets.get_load_state(handle.id());
if load_state == Some(LoadState::Loaded)
|| load_state.is_none()
|| load_state == Some(LoadState::Failed)
|| matches!(load_state, Some(LoadState::Failed(_)))
{
need_remove_task = true;
}
Expand Down Expand Up @@ -64,9 +64,15 @@ mod tests {
))
.add_systems(Update, update_storage);

assert_eq!(app.world.resource::<BackgroundTaskStorage>().tasks.len(), 1);
assert_eq!(
app.world().resource::<BackgroundTaskStorage>().tasks.len(),
1
);
app.update();

assert_eq!(app.world.resource::<BackgroundTaskStorage>().tasks.len(), 0);
assert_eq!(
app.world().resource::<BackgroundTaskStorage>().tasks.len(),
0
);
}
}
74 changes: 34 additions & 40 deletions crates/editor_core/src/toast.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::{prelude::*, window::PrimaryWindow};
use bevy_egui::EguiContext;
use bevy_egui::{EguiContext, EguiContexts};
use egui_dock::egui::{self, Align2};
use space_shared::toast::ToastMessage;

Expand All @@ -9,7 +9,7 @@ pub struct ToastUiPlugin;
impl Plugin for ToastUiPlugin {
fn build(&self, app: &mut App) {
app.add_plugins(ToastBasePlugin)
.add_systems(PostUpdate, show_toast);
.add_systems(Update, show_toast);
}
}

Expand Down Expand Up @@ -127,14 +127,8 @@ fn clear_toasts(mut events: EventReader<ClearToastMessage>, mut storage: ResMut<
events.clear();
}

fn show_toast(
mut storage: ResMut<ToastStorage>,
mut ctxs: Query<&mut EguiContext, With<PrimaryWindow>>,
) {
let Ok(mut ctx) = ctxs.get_single_mut() else {
return;
};
storage.toasts.show(ctx.get_mut());
fn show_toast(mut storage: ResMut<ToastStorage>, mut ctxs: EguiContexts) {
storage.toasts.show(ctxs.ctx_mut());
}

#[cfg(test)]
Expand All @@ -148,26 +142,26 @@ mod tests {

app.update();
assert!(!app
.world
.world()
.get_resource::<ToastStorage>()
.unwrap()
.has_toasts());
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Error));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Error));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Error));
app.update();
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Warning));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Warning));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Warning));
app.update();

let storage: &ToastStorage = app.world.get_resource::<ToastStorage>().unwrap();
let storage: &ToastStorage = app.world().get_resource::<ToastStorage>().unwrap();
assert_eq!(storage.toasts_per_kind.error.len(), 3);
assert_eq!(storage.toasts_per_kind.warning.len(), 3);
assert!(storage.has_toasts());
Expand All @@ -180,30 +174,30 @@ mod tests {

app.update();
assert!(!app
.world
.world()
.get_resource::<ToastStorage>()
.unwrap()
.has_toasts());
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Error));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Error));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Error));
app.update();
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Warning));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Warning));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Warning));
app.update();

app.world.send_event(ClearToastMessage::error(1));
app.world.send_event(ClearToastMessage::warn(1));
app.world_mut().send_event(ClearToastMessage::error(1));
app.world_mut().send_event(ClearToastMessage::warn(1));
app.update();

let storage: &ToastStorage = app.world.get_resource::<ToastStorage>().unwrap();
let storage: &ToastStorage = app.world().get_resource::<ToastStorage>().unwrap();
assert_eq!(storage.toasts_per_kind.error.len(), 2);
assert_eq!(storage.toasts_per_kind.warning.len(), 2);
}
Expand All @@ -215,29 +209,29 @@ mod tests {

app.update();
assert!(!app
.world
.world()
.get_resource::<ToastStorage>()
.unwrap()
.has_toasts());
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Error));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Error));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Error));
app.update();
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Warning));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Warning));
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Warning));
app.update();

app.world.send_event(ClearToastMessage::all());
app.world_mut().send_event(ClearToastMessage::all());
app.update();

let storage: &ToastStorage = app.world.get_resource::<ToastStorage>().unwrap();
let storage: &ToastStorage = app.world().get_resource::<ToastStorage>().unwrap();
assert!(!storage.has_toasts());
}

Expand All @@ -248,15 +242,15 @@ mod tests {

app.update();
assert!(!app
.world
.world()
.get_resource::<ToastStorage>()
.unwrap()
.has_toasts());
app.world
app.world_mut()
.send_event(ToastMessage::new("Test message", ToastKind::Info));
app.update();

let storage: &ToastStorage = app.world.get_resource::<ToastStorage>().unwrap();
let storage: &ToastStorage = app.world().get_resource::<ToastStorage>().unwrap();
assert!(!storage.has_toasts());
}
}
8 changes: 4 additions & 4 deletions crates/editor_tabs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod tab_viewer;

use std::fmt::Display;

use bevy::{ecs::system::CommandQueue, prelude::*, utils::HashMap, window::PrimaryWindow};
use bevy::{ecs::world::CommandQueue, prelude::*, utils::HashMap, window::PrimaryWindow};

use bevy_egui::{egui, EguiContext};

Expand Down Expand Up @@ -231,7 +231,7 @@ impl EditorUiAppExt for App {
}),
};

if let Some(mut editor) = self.world.get_resource_mut::<EditorUi>() {
if let Some(mut editor) = self.world_mut().get_resource_mut::<EditorUi>() {
editor.registry.insert(tab_name, reg);
};
self
Expand All @@ -252,11 +252,11 @@ impl EditorUiAppExt for App {
tab.schedule.add_systems(tab_systems);

// Not much we can do here
self.world
self.world_mut()
.resource_mut::<ScheduleEditorTabStorage>()
.0
.insert(tab_name_holder.clone(), tab);
if let Some(mut editor) = self.world.get_resource_mut::<EditorUi>() {
if let Some(mut editor) = self.world_mut().get_resource_mut::<EditorUi>() {
editor
.registry
.insert(tab_name_holder, EditorUiReg::Schedule);
Expand Down
2 changes: 1 addition & 1 deletion crates/editor_tabs/src/schedule_editor_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct ScheduleEditorTab {

impl EditorTab for ScheduleEditorTab {
fn ui(&mut self, ui: &mut egui::Ui, _: &mut Commands, world: &mut World) {
let inner_ui = ui.child_ui(ui.max_rect(), *ui.layout());
let inner_ui = ui.child_ui(ui.max_rect(), *ui.layout(), None);
world.insert_non_send_resource(EditorUiRef(inner_ui));

self.schedule.run(world);
Expand Down
Loading
Loading