Skip to content

Commit

Permalink
Expose root ui node and fix some comments and asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Feb 26, 2024
1 parent d96962e commit 18c4f77
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 11 deletions.
111 changes: 109 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/bevy_plugin/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"`.
Expand All @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions crates/bevy_plugin/src/project/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/bevyengine/bevy/blob/v0.11.0/examples/asset/hot_asset_reloading.rs>");
For an optimal development experience, we recommend turning on hot reloading by activating the \"file_watcher\" feature of Bevy");
}

commands.insert_resource(YarnProjectConfigToLoad {
Expand Down
2 changes: 1 addition & 1 deletion crates/example_dialogue_view/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down
6 changes: 6 additions & 0 deletions crates/example_dialogue_view/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -76,6 +78,10 @@ mod updating;

impl Plugin for ExampleYarnSpinnerDialogueViewPlugin {
fn build(&self, app: &mut App) {
assert!(
app.is_plugin_added::<YarnSpinnerPlugin>(),
"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)
Expand Down
3 changes: 2 additions & 1 deletion crates/example_dialogue_view/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/bevy_yarnspinner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ authors = ["Jan Hohenheim <[email protected]>"]
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" }

0 comments on commit 18c4f77

Please sign in to comment.