Skip to content

Commit

Permalink
update to bevy main
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Jun 18, 2023
1 parent 8768a9c commit ceac00d
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ default_fonts = ["egui/default_fonts"]
serde = ["egui/serde"]

[dependencies]
bevy = { version = "0.10", default-features = false, features = [
bevy = { git = "https://github.com/bevyengine/bevy.git", branch = "main", default-features = false, features = [
"bevy_render",
"bevy_asset",
] }
Expand All @@ -36,7 +36,7 @@ thread_local = { version = "1.1.0", optional = true }
[dev-dependencies]
once_cell = "1.16.0"
version-sync = "0.9.4"
bevy = { version = "0.10", default-features = false, features = [
bevy = { git = "https://github.com/bevyengine/bevy.git", branch = "main", default-features = false, features = [
"x11",
"png",
"bevy_pbr",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn main() {
.add_plugin(EguiPlugin)
// Systems that create Egui widgets should be run during the `CoreSet::Update` set,
// or after the `EguiSet::BeginFrame` system (which belongs to the `CoreSet::PreUpdate` set).
.add_system(ui_example_system)
.add_systems(Update, ui_example_system)
.run();
}

Expand Down
6 changes: 3 additions & 3 deletions examples/render_to_image_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(EguiPlugin)
.add_startup_system(setup)
.add_system(rotator_system)
.add_system(render_to_image_example_system)
.add_systems(Startup, setup)
.add_systems(Update, rotator_system)
.add_systems(Update, render_to_image_example_system)
.run();
}

Expand Down
6 changes: 3 additions & 3 deletions examples/side_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(EguiPlugin)
.init_resource::<OccupiedScreenSpace>()
.add_startup_system(setup_system)
.add_system(ui_example_system)
.add_system(update_camera_transform_system)
.add_systems(Startup, setup_system)
.add_systems(Update, ui_example_system)
.add_systems(Update, update_camera_transform_system)
.run();
}

Expand Down
2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
.add_plugin(EguiPlugin)
// Systems that create Egui widgets should be run during the `CoreSet::Update` set,
// or after the `EguiSet::BeginFrame` system (which belongs to the `CoreSet::PreUpdate` set).
.add_system(ui_example_system)
.add_systems(Update, ui_example_system)
.run();
}

Expand Down
8 changes: 4 additions & 4 deletions examples/two_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ fn main() {
app.add_plugins(DefaultPlugins)
.add_plugin(EguiPlugin)
.init_resource::<SharedUiState>()
.add_startup_system(load_assets_system)
.add_startup_system(create_new_window_system)
.add_system(ui_first_window_system)
.add_system(ui_second_window_system);
.add_systems(Startup, load_assets_system)
.add_systems(Startup, create_new_window_system)
.add_systems(Update, ui_first_window_system)
.add_systems(Update, ui_second_window_system);

app.run();
}
Expand Down
8 changes: 4 additions & 4 deletions examples/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ fn main() {
..default()
}))
.add_plugin(EguiPlugin)
.add_startup_system(configure_visuals_system)
.add_startup_system(configure_ui_state_system)
.add_system(update_ui_scale_factor_system)
.add_system(ui_example_system)
.add_systems(Startup, configure_visuals_system)
.add_systems(Startup, configure_ui_state_system)
.add_systems(Update, update_ui_scale_factor_system)
.add_systems(Update, ui_example_system)
.run();
}
#[derive(Default, Resource)]
Expand Down
8 changes: 4 additions & 4 deletions src/egui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ impl Node for EguiNode {
return Ok(()); // No window
};

let swap_chain_texture =
if let Some(swap_chain_texture) = extracted_window.swap_chain_texture.as_ref() {
swap_chain_texture
let swap_chain_texture_view =
if let Some(swap_chain_texture_view) = extracted_window.swap_chain_texture_view.as_ref() {
swap_chain_texture_view
} else {
return Ok(()); // No swapchain texture
};
Expand All @@ -343,7 +343,7 @@ impl Node for EguiNode {
.begin_render_pass(&RenderPassDescriptor {
label: Some("egui render pass"),
color_attachments: &[Some(RenderPassColorAttachment {
view: swap_chain_texture,
view: swap_chain_texture_view,
resolve_target: None,
ops: Operations {
load: LoadOp::Load,
Expand Down
64 changes: 32 additions & 32 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,24 @@ use crate::{
#[cfg(all(feature = "manage_clipboard", not(target_arch = "wasm32")))]
use arboard::Clipboard;
use bevy::{
app::{App, Plugin},
app::{App, Plugin, Update, Last, PostUpdate, PreUpdate, PreStartup},
asset::{AssetEvent, Assets, Handle},
ecs::{
event::EventReader,
query::{QueryEntityError, WorldQuery},
schedule::apply_system_buffers,
schedule::apply_deferred,
system::{ResMut, SystemParam},
},
input::InputSystem,
log,
prelude::{
Added, Commands, Component, CoreSet, Deref, DerefMut, Entity, IntoSystemAppConfigs,
IntoSystemConfig, IntoSystemConfigs, Query, Resource, Shader, StartupSet, SystemSet, With,
Added, Commands, Component, Deref, DerefMut, Entity,
IntoSystemConfigs, Query, Resource, Shader, SystemSet, With,
Without,
},
render::{
render_resource::SpecializedRenderPipelines, texture::Image, ExtractSchedule, RenderApp,
RenderSet,
RenderSet, Render
},
utils::HashMap,
window::{PrimaryWindow, Window},
Expand Down Expand Up @@ -555,77 +555,77 @@ impl Plugin for EguiPlugin {
world.init_resource::<EguiMousePosition>();

#[cfg(all(feature = "manage_clipboard", target_arch = "wasm32"))]
app.add_startup_system(web_clipboard::startup_setup_web_events);
app.add_startup_systems(
app.add_systems(Startup, web_clipboard::startup_setup_web_events);
app.add_systems(PreStartup,
(
setup_new_windows_system,
apply_system_buffers,
apply_deferred,
update_window_contexts_system,
)
.chain()
.in_set(EguiStartupSet::InitContexts)
.in_base_set(StartupSet::PreStartup),
.in_set(EguiStartupSet::InitContexts),
);
app.add_systems(
app.add_systems(PreUpdate,
(
setup_new_windows_system,
apply_system_buffers,
apply_deferred,
update_window_contexts_system,
)
.chain()
.in_set(EguiSet::InitContexts)
.in_base_set(CoreSet::PreUpdate),
.in_set(EguiSet::InitContexts),
);
app.add_system(
app.add_systems(PreUpdate,
process_input_system
.in_set(EguiSet::ProcessInput)
.after(InputSystem)
.after(EguiSet::InitContexts)
.in_base_set(CoreSet::PreUpdate),
.after(EguiSet::InitContexts),
);
app.add_system(
app.add_systems(PreUpdate,
begin_frame_system
.in_set(EguiSet::BeginFrame)
.after(EguiSet::ProcessInput)
.in_base_set(CoreSet::PreUpdate),
.after(EguiSet::ProcessInput),
);
app.add_system(
app.add_systems(PostUpdate,
process_output_system
.in_set(EguiSet::ProcessOutput)
.in_base_set(CoreSet::PostUpdate),
.in_set(EguiSet::ProcessOutput),
);
app.add_system(
app.add_systems(PostUpdate,
update_egui_textures_system
.after(EguiSet::ProcessOutput)
.in_base_set(CoreSet::PostUpdate),
.after(EguiSet::ProcessOutput),
);
app.add_system(free_egui_textures_system.in_base_set(CoreSet::Last));
app.add_systems(Last, free_egui_textures_system)
.add_systems(Render,
render_systems::prepare_egui_transforms_system.in_set(RenderSet::Prepare),
)
.add_systems(Render, render_systems::queue_bind_groups_system.in_set(RenderSet::Queue))
.add_systems(Render, render_systems::queue_pipelines_system.in_set(RenderSet::Queue));

let mut shaders = app.world.resource_mut::<Assets<Shader>>();
shaders.set_untracked(
EGUI_SHADER_HANDLE,
Shader::from_wgsl(include_str!("egui.wgsl")),
);
}

fn finish(&self, app: &mut App) {
if let Ok(render_app) = app.get_sub_app_mut(RenderApp) {
render_app
.init_resource::<egui_node::EguiPipeline>()
.init_resource::<SpecializedRenderPipelines<EguiPipeline>>()
.init_resource::<EguiTransforms>()
.add_systems(
.add_systems(ExtractSchedule,
(
render_systems::extract_egui_render_data_system,
render_systems::extract_egui_textures_system,
render_systems::setup_new_windows_render_system,
)
.into_configs()
.in_schedule(ExtractSchedule),
)
.add_system(
.add_systems(Render,
render_systems::prepare_egui_transforms_system.in_set(RenderSet::Prepare),
)
.add_system(render_systems::queue_bind_groups_system.in_set(RenderSet::Queue))
.add_system(render_systems::queue_pipelines_system.in_set(RenderSet::Queue));
.add_systems(Render, render_systems::queue_bind_groups_system.in_set(RenderSet::Queue))
.add_systems(Render, render_systems::queue_pipelines_system.in_set(RenderSet::Queue));
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ pub fn process_input_system(
};
}

let shift = input_resources.keyboard_input.pressed(KeyCode::LShift)
|| input_resources.keyboard_input.pressed(KeyCode::RShift);
let ctrl = input_resources.keyboard_input.pressed(KeyCode::LControl)
|| input_resources.keyboard_input.pressed(KeyCode::RControl);
let alt = input_resources.keyboard_input.pressed(KeyCode::LAlt)
|| input_resources.keyboard_input.pressed(KeyCode::RAlt);
let win = input_resources.keyboard_input.pressed(KeyCode::LWin)
|| input_resources.keyboard_input.pressed(KeyCode::RWin);
let shift = input_resources.keyboard_input.pressed(KeyCode::ShiftLeft)
|| input_resources.keyboard_input.pressed(KeyCode::ShiftRight);
let ctrl = input_resources.keyboard_input.pressed(KeyCode::ControlLeft)
|| input_resources.keyboard_input.pressed(KeyCode::ControlRight);
let alt = input_resources.keyboard_input.pressed(KeyCode::AltLeft)
|| input_resources.keyboard_input.pressed(KeyCode::AltRight);
let win = input_resources.keyboard_input.pressed(KeyCode::SuperLeft)
|| input_resources.keyboard_input.pressed(KeyCode::SuperRight);

let mac_cmd = if *is_mac { win } else { false };
let command = if *is_mac { win } else { ctrl };
Expand Down Expand Up @@ -164,7 +164,6 @@ pub fn process_input_system(
.contexts
.get_mut(cursor_moved.window)
.unwrap();
mouse_position.1 = context.window_size.height() / scale_factor - mouse_position.1;
egui_mouse_position.0 = Some((cursor_moved.window, mouse_position.into()));
context
.egui_input
Expand Down

0 comments on commit ceac00d

Please sign in to comment.