From 18c4f772fd7b32b1d6378afa0535cd1c19b69409 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Mon, 26 Feb 2024 19:18:58 +0100 Subject: [PATCH] Expose root ui node and fix some comments and asserts --- Cargo.lock | 111 +++++++++++++++++- crates/bevy_plugin/src/plugin.rs | 6 +- crates/bevy_plugin/src/project/compilation.rs | 4 +- crates/example_dialogue_view/Cargo.toml | 2 +- crates/example_dialogue_view/src/lib.rs | 6 + crates/example_dialogue_view/src/setup.rs | 3 +- examples/bevy_yarnspinner/Cargo.toml | 2 +- 7 files changed, 123 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bcb0c766..2adc493e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -413,6 +413,7 @@ dependencies = [ "futures-io", "futures-lite", "js-sys", + "notify-debouncer-full", "parking_lot 0.12.1", "ron", "serde", @@ -1124,7 +1125,7 @@ dependencies = [ [[package]] name = "bevy_yarnspinner_example_dialogue_view" -version = "0.2.0" +version = "0.2.1" dependencies = [ "bevy", "bevy_yarnspinner", @@ -1838,6 +1839,27 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "file-id" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6584280525fb2059cba3db2c04abf947a1a29a45ddae89f3870f8281704fafc9" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "filetime" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", +] + [[package]] name = "fixed_decimal" version = "0.5.5" @@ -1899,6 +1921,15 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" +[[package]] +name = "fsevent-sys" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" +dependencies = [ + "libc", +] + [[package]] name = "futures-core" version = "0.3.30" @@ -1977,7 +2008,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0af1827b7dd2f36d740ae804c1b3ea0d64c12533fb61ff91883005143a0e8c5a" dependencies = [ "core-foundation", - "inotify", + "inotify 0.10.2", "io-kit-sys", "js-sys", "libc", @@ -2334,6 +2365,17 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" +[[package]] +name = "inotify" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +dependencies = [ + "bitflags 1.3.2", + "inotify-sys", + "libc", +] + [[package]] name = "inotify" version = "0.10.2" @@ -2485,6 +2527,26 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" +[[package]] +name = "kqueue" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" +dependencies = [ + "bitflags 1.3.2", + "libc", +] + [[package]] name = "ktx2" version = "0.3.0" @@ -2656,6 +2718,18 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.48.0", +] + [[package]] name = "multimap" version = "0.8.3" @@ -2803,6 +2877,39 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" +[[package]] +name = "notify" +version = "6.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" +dependencies = [ + "bitflags 2.4.2", + "crossbeam-channel", + "filetime", + "fsevent-sys", + "inotify 0.9.6", + "kqueue", + "libc", + "log", + "mio", + "walkdir", + "windows-sys 0.48.0", +] + +[[package]] +name = "notify-debouncer-full" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f5dab59c348b9b50cf7f261960a20e389feb2713636399cd9082cd4b536154" +dependencies = [ + "crossbeam-channel", + "file-id", + "log", + "notify", + "parking_lot 0.12.1", + "walkdir", +] + [[package]] name = "ntapi" version = "0.4.1" diff --git a/crates/bevy_plugin/src/plugin.rs b/crates/bevy_plugin/src/plugin.rs index 98096a3d..f41c6b11 100644 --- a/crates/bevy_plugin/src/plugin.rs +++ b/crates/bevy_plugin/src/plugin.rs @@ -44,7 +44,7 @@ impl YarnSpinnerPlugin { /// Use [`YarnSpinnerPlugin::with_yarn_source`] or [`YarnSpinnerPlugin::with_yarn_sources`] there instead. /// /// All Yarn files will be shared across [`DialogueRunner`]s. - /// If [hot reloading](https://bevy-cheatbook.github.io/assets/hot-reload.html) is turned on, + /// If hot reloading is turned on via the \"file_watcher\" feature of Bevy, /// these Yarn files will be recompiled if they change during runtime. /// /// Calling this is equivalent to calling [`YarnSpinnerPlugin::with_yarn_source`] with a [`YarnFileSource::folder`] of `"dialogue"`. @@ -65,7 +65,7 @@ impl YarnSpinnerPlugin { /// Creates a new plugin that loads Yarn files from the given sources. /// All Yarn files will be shared across [`DialogueRunner`]s. - /// If [hot reloading](https://bevy-cheatbook.github.io/assets/hot-reload.html) is turned on, + /// If hot reloading is turned on via the \"file_watcher\" feature of Bevy, /// these Yarn files will be recompiled if they change during runtime. /// /// See [`YarnFileSource`] for more information on where Yarn files can be loaded from. @@ -92,7 +92,7 @@ impl YarnSpinnerPlugin { /// Creates a new plugin that loads Yarn files from the given source. /// All Yarn files will be shared across [`DialogueRunner`]s. - /// If [hot reloading](https://bevy-cheatbook.github.io/assets/hot-reload.html) is turned on, + /// If hot reloading is turned on via the \"file_watcher\" feature of Bevy, /// these Yarn files will be recompiled if they change during runtime. /// /// See [`YarnFileSource`] for more information on where Yarn files can be loaded from. diff --git a/crates/bevy_plugin/src/project/compilation.rs b/crates/bevy_plugin/src/project/compilation.rs index dfaab9c5..c963e3db 100644 --- a/crates/bevy_plugin/src/project/compilation.rs +++ b/crates/bevy_plugin/src/project/compilation.rs @@ -67,9 +67,7 @@ fn load_project( && !is_watching_for_changes.0 { warn!("Development file generation mode is set to `Full`, but hot reloading is not turned on. \ - For an optimal development experience, we recommend turning on hot reloading by setting the `watch_for_changes` field of the `AssetPlugin` to `Some`, \ - e.g. via `watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200))`. \ - You can see an example of how to do this in at "); + For an optimal development experience, we recommend turning on hot reloading by activating the \"file_watcher\" feature of Bevy"); } commands.insert_resource(YarnProjectConfigToLoad { diff --git a/crates/example_dialogue_view/Cargo.toml b/crates/example_dialogue_view/Cargo.toml index 3bffccdb..9865d71c 100644 --- a/crates/example_dialogue_view/Cargo.toml +++ b/crates/example_dialogue_view/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_yarnspinner_example_dialogue_view" -version = "0.2.0" +version = "0.2.1" edition = "2021" repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" homepage = "https://docs.yarnspinner.dev/" diff --git a/crates/example_dialogue_view/src/lib.rs b/crates/example_dialogue_view/src/lib.rs index 5fed0c05..5ef104e8 100644 --- a/crates/example_dialogue_view/src/lib.rs +++ b/crates/example_dialogue_view/src/lib.rs @@ -41,6 +41,8 @@ #![warn(missing_docs, missing_debug_implementations)] use bevy::prelude::*; +use bevy_yarnspinner::prelude::YarnSpinnerPlugin; +pub use setup::UiRootNode; pub use updating::SpeakerChangeEvent; pub mod prelude { @@ -76,6 +78,10 @@ mod updating; impl Plugin for ExampleYarnSpinnerDialogueViewPlugin { fn build(&self, app: &mut App) { + assert!( + app.is_plugin_added::(), + "YarnSpinnerPlugin must be added before ExampleYarnSpinnerDialogueViewPlugin" + ); app.add_plugins(assets::ui_assets_plugin) .add_plugins(setup::ui_setup_plugin) .add_plugins(updating::ui_updating_plugin) diff --git a/crates/example_dialogue_view/src/setup.rs b/crates/example_dialogue_view/src/setup.rs index 4e8a24c0..a112aafe 100644 --- a/crates/example_dialogue_view/src/setup.rs +++ b/crates/example_dialogue_view/src/setup.rs @@ -7,8 +7,9 @@ pub(crate) fn ui_setup_plugin(app: &mut App) { app.add_systems(Startup, setup); } +/// Marker for the [`Node`] that is the root of the UI #[derive(Debug, Default, Component)] -pub(crate) struct UiRootNode; +pub struct UiRootNode; #[derive(Debug, Default, Component)] pub(crate) struct DialogueNode; diff --git a/examples/bevy_yarnspinner/Cargo.toml b/examples/bevy_yarnspinner/Cargo.toml index a07ef310..e7cf9a52 100644 --- a/examples/bevy_yarnspinner/Cargo.toml +++ b/examples/bevy_yarnspinner/Cargo.toml @@ -10,6 +10,6 @@ authors = ["Jan Hohenheim "] publish = false [dependencies] -bevy = "0.13" +bevy = { version = "0.13", features = ["file_watcher"] } bevy_yarnspinner = { path = "../../crates/bevy_plugin", version = "0.2" } bevy_yarnspinner_example_dialogue_view = { path = "../../crates/example_dialogue_view", version = "0.2" }