Skip to content

Commit 93f162e

Browse files
committed
chore: update to bevy 0.17
1 parent d703972 commit 93f162e

8 files changed

Lines changed: 71 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe
1010

1111
## Unreleased
1212

13+
## 0.8.0
14+
15+
### Added
16+
17+
- Egui support with the `bevy_egui_0_38` feature. This will make inputs ignored during egui focus.
18+
19+
### Changed
20+
21+
- Updated to bevy 0.17
22+
1323
## 0.7.0
1424

1525
### Added

Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ members = ["examples/run_wasm", "examples/demo"]
44

55
[workspace.package]
66
edition = "2021"
7-
version = "0.7.0"
7+
version = "0.8.0"
88
license = "MIT OR Apache-2.0"
99
repository = "https://github.com/loopystudios/bevy_ogle"
1010

@@ -24,7 +24,7 @@ readme = "README.md"
2424

2525

2626
[workspace.dependencies]
27-
bevy = { version = "0.16.0", default-features = false }
27+
bevy = { version = "0.17.3", default-features = false }
2828

2929
[dependencies]
3030
bevy = { workspace = true, default-features = false, features = [
@@ -33,9 +33,12 @@ bevy = { workspace = true, default-features = false, features = [
3333
] }
3434
dolly = "0.6.0"
3535
mint = "0.5.9"
36+
bevy_egui_0_38 = { package = "bevy_egui", version = "0.38.1", optional = true, default-features = false }
3637

3738
[dev-dependencies]
38-
wasm-bindgen-test = "0.3.50"
39+
wasm-bindgen-test = "0.3.56"
3940

4041
[features]
41-
default = []
42+
default = ["bevy_egui_0_38"]
43+
bevy_egui_0_38 = ["dep:bevy_egui_0_38", "internal_bevy_egui"]
44+
internal_bevy_egui = []

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ cargo run -p demo
2424

2525
|bevy|bevy_ogle|
2626
|---|---|
27-
|0.16|0.5-0.7, main|
27+
|0.17|0.8,main|
28+
|0.16|0.5-0.7|
2829
|0.15|0.3-0.4|
2930
|0.14|0.1-0.2|
3031
|< 0.13| unsupported |

examples/demo/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ publish = false
1010
[dependencies]
1111
bevy = { workspace = true, default-features = true }
1212
bevy_ogle = { path = "../.." }
13-
bevy_egui = "0.36.0"
13+
bevy_egui = "0.38.1"
1414
rand = "0.9.1"

src/egui_support.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use bevy::prelude::*;
2+
3+
use crate::OgleSystems;
4+
5+
#[derive(Resource, Deref, DerefMut, PartialEq, Eq, Default)]
6+
struct EguiWantsFocus(bool);
7+
8+
pub(crate) struct EguiPanCamPlugin;
9+
10+
impl Plugin for EguiPanCamPlugin {
11+
fn build(&self, app: &mut App) {
12+
app.init_resource::<EguiWantsFocus>()
13+
.add_systems(PostUpdate, check_egui_wants_focus)
14+
.configure_sets(
15+
Update,
16+
OgleSystems.run_if(resource_equals(EguiWantsFocus(false))),
17+
);
18+
}
19+
}
20+
21+
// todo: make run condition when Bevy supports mutable resources in them
22+
fn check_egui_wants_focus(
23+
#[cfg(feature = "bevy_egui_0_38")] mut contexts_0_38: Query<&mut bevy_egui_0_38::EguiContext>,
24+
mut wants_focus: ResMut<EguiWantsFocus>,
25+
) {
26+
let mut new_wants_focus = false;
27+
28+
#[cfg(feature = "bevy_egui_0_38")]
29+
{
30+
let ctx = contexts_0_38.iter_mut().next();
31+
if let Some(ctx) = ctx {
32+
let ctx = ctx.into_inner().get_mut();
33+
if ctx.wants_keyboard_input() || ctx.is_using_pointer() {
34+
new_wants_focus = true;
35+
}
36+
}
37+
}
38+
39+
wants_focus.set_if_neq(EguiWantsFocus(new_wants_focus));
40+
}

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ mod systems;
66
mod plugin;
77
pub use plugin::OglePlugin;
88

9-
/// System set to allow ordering of `OglePlugin`
9+
#[cfg(feature = "internal_bevy_egui")]
10+
mod egui_support;
11+
12+
/// System sets of the camera
1013
#[derive(Debug, Clone, Copy, SystemSet, PartialEq, Eq, Hash)]
11-
pub struct OgleSystemSet;
14+
pub struct OgleSystems;
1215

1316
#[derive(Component, Debug)]
1417
#[require(Camera2d)]

src/plugin.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{systems, OgleSystemSet};
1+
use crate::{systems, OgleSystems};
22
use bevy::prelude::*;
33

44
#[derive(Default)]
@@ -16,7 +16,10 @@ impl Plugin for OglePlugin {
1616
systems::commit_camera_changes,
1717
)
1818
.chain()
19-
.in_set(OgleSystemSet),
19+
.in_set(OgleSystems),
2020
);
21+
22+
#[cfg(feature = "internal_bevy_egui")]
23+
app.add_plugins(crate::egui_support::EguiPanCamPlugin);
2124
}
2225
}

src/systems.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn do_follow_target(query_transform: Query<&Transform>, mut query_cam: Query
4949

5050
pub fn do_camera_zooming(
5151
mut query_cam: Query<&mut OgleCam>,
52-
mut scroll_events: EventReader<MouseWheel>,
52+
mut scroll_events: MessageReader<MouseWheel>,
5353
) {
5454
for mut cam in query_cam.iter_mut() {
5555
match cam.mode {

0 commit comments

Comments
 (0)