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

Update to Bevy 0.13 #178

Merged
merged 6 commits into from
Feb 18, 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
1,539 changes: 603 additions & 936 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions crates/bevy_plugin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_yarnspinner"
version = "0.1.2"
version = "0.2.0"
edition = "2021"
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
homepage = "https://docs.yarnspinner.dev/"
Expand All @@ -19,23 +19,22 @@ audio_assets = ["bevy/bevy_audio", "bevy/vorbis"]
[dependencies]
anyhow = "1"
csv = "1"
seldom_fn_plugin = "0.5"
serde = { version = "1", features = ["derive"] }
yarnspinner = { path = "../yarnspinner", features = ["bevy", "serde"], version = "0.1" }
yarnspinner = { path = "../yarnspinner", features = ["bevy", "serde"], version = "0.2" }
sha2 = "0.10"
rand = { version = "0.8", features = ["small_rng"] }


[target.'cfg(any(target_arch = "wasm32", target_os = "android"))'.dependencies.bevy]
version = "0.12"
version = "0.13"
default-features = false
features = ["bevy_asset", "serialize"]

[dev-dependencies]
tempfile = "3"

[dev-dependencies.bevy]
version = "0.12"
version = "0.13.0"
default-features = false
features = [
"bevy_core_pipeline",
Expand All @@ -48,7 +47,7 @@ features = [
]

[target.'cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))'.dependencies.bevy]
version = "0.12"
version = "0.13"
default-features = false
features = ["bevy_asset", "serialize", "file_watcher",]

Expand Down
7 changes: 3 additions & 4 deletions crates/bevy_plugin/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ use bevy::prelude::*;
pub(crate) use command_registry::wait::update_wait;
pub use command_registry::YarnCommands;
pub use command_wrapping::{TaskFinishedIndicator, UntypedYarnCommand, YarnCommand};
use seldom_fn_plugin::FnPluginExt;

mod command_registry;
mod command_wrapping;
mod execution;

pub(crate) fn commands_plugin(app: &mut App) {
app.fn_plugin(command_wrapping::command_wrapping_plugin)
.fn_plugin(command_registry::command_registry_plugin)
.fn_plugin(execution::command_execution_plugin);
app.add_plugins(command_wrapping::command_wrapping_plugin)
.add_plugins(command_registry::command_registry_plugin)
.add_plugins(execution::command_execution_plugin);
}
2 changes: 1 addition & 1 deletion crates/bevy_plugin/src/commands/command_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::time::Duration;
pub(crate) mod wait;

pub(crate) fn command_registry_plugin(app: &mut App) {
app.fn_plugin(wait::wait_command_plugin);
app.add_plugins(wait::wait_command_plugin);
}

#[derive(Debug, PartialEq, Eq, Default)]
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_plugin/src/dialogue_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ mod localized_line;
mod runtime_interaction;

pub(crate) fn dialogue_plugin(app: &mut App) {
app.fn_plugin(runtime_interaction::runtime_interaction_plugin)
.fn_plugin(localized_line::localized_line_plugin)
.fn_plugin(events::dialogue_runner_events_plugin)
.fn_plugin(dialogue_option::dialogue_option_plugin)
.fn_plugin(builder::dialogue_runner_builder_plugin)
.fn_plugin(inner::inner_dialogue_runner_plugin);
app.add_plugins(runtime_interaction::runtime_interaction_plugin)
.add_plugins(localized_line::localized_line_plugin)
.add_plugins(events::dialogue_runner_events_plugin)
.add_plugins(dialogue_option::dialogue_option_plugin)
.add_plugins(builder::dialogue_runner_builder_plugin)
.add_plugins(inner::inner_dialogue_runner_plugin);
}

/// The main type to interact with the dialogue system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) fn runtime_interaction_plugin(app: &mut App) {
(
continue_runtime
.pipe(panic_on_err)
.run_if(resource_exists::<YarnProject>()),
.run_if(resource_exists::<YarnProject>),
accept_line_hints,
)
.chain()
Expand Down
7 changes: 3 additions & 4 deletions crates/bevy_plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//! The main workflow is as follows:
//! - Register the [`YarnSpinnerPlugin`]
//! - When the [`YarnProject`] [`Resource`](bevy::prelude::Resource) is added, spawn a [`DialogueRunner`] from it.
//! The latter can nicely be done with `my_system.run_if(resource_added::<YarnProject>())`.
//! The latter can nicely be done with `my_system.run_if(resource_added::<YarnProject>)`.
//!
//! The following example is adapted from the [hello world example](https://github.com/YarnSpinnerTool/YarnSpinner-Rust/blob/main/examples/bevy_yarnspinner/src/bin/hello_world.rs).
//!
Expand Down Expand Up @@ -73,7 +73,7 @@
//! // Spawn the dialog as soon as the Yarn project finished compiling
//! .add_systems(
//! Update,
//! spawn_dialogue_runner.run_if(resource_added::<YarnProject>()),
//! spawn_dialogue_runner.run_if(resource_added::<YarnProject>),
//! )
//! .run();
//! }
Expand Down Expand Up @@ -144,14 +144,13 @@ pub mod prelude {
};
pub(crate) use crate::{localization::StringsFile, utils::*};
pub(crate) use anyhow::{Context, Error, Result};
pub(crate) use serde::{Deserialize, Serialize};
pub(crate) use yarnspinner::prelude::*;
pub use yarnspinner::prelude::{
IntoYarnValueFromNonYarnValue, Language, LineId, MarkupAttribute, MarkupValue, OptionId,
VariableStorage, YarnFn, YarnLibrary, YarnValue,
};
pub(crate) type SystemResult = Result<()>;
pub(crate) use seldom_fn_plugin::FnPluginExt;
pub(crate) use serde::{Deserialize, Serialize};
}

pub use crate::commands::{TaskFinishedIndicator, UntypedYarnCommand};
Expand Down
5 changes: 2 additions & 3 deletions crates/bevy_plugin/src/line_provider.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::prelude::*;
#[cfg(feature = "audio_assets")]
pub use asset_provider::AudioAssetProvider;
pub use asset_provider::{file_extensions, AssetProvider, FileExtensionAssetProvider, LineAssets};
Expand All @@ -10,8 +9,8 @@ mod asset_provider;
mod text_provider;

pub(crate) fn line_provider_plugin(app: &mut App) {
app.fn_plugin(asset_provider::asset_provider_plugin)
.fn_plugin(text_provider::text_provider_plugin);
app.add_plugins(asset_provider::asset_provider_plugin)
.add_plugins(text_provider::text_provider_plugin);
}

#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq, SystemSet)]
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_plugin/src/line_provider/asset_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ mod audio_asset_provider_plugin;
mod file_extension_asset_provider_plugin;

pub(crate) fn asset_provider_plugin(app: &mut App) {
app.fn_plugin(file_extension_asset_provider_plugin::file_extension_asset_provider_plugin);
app.add_plugins(file_extension_asset_provider_plugin::file_extension_asset_provider_plugin);

#[cfg(feature = "audio_assets")]
app.fn_plugin(audio_asset_provider_plugin::audio_asset_provider_plugin);
app.add_plugins(audio_asset_provider_plugin::audio_asset_provider_plugin);
}

/// Trait for providing assets for lines, e.g. audio files or character portraits.
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_plugin/src/line_provider/text_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ mod shared_text_provider;
mod strings_file_text_provider;

pub(crate) fn text_provider_plugin(app: &mut App) {
app.fn_plugin(shared_text_provider::shared_text_provider_plugin)
.fn_plugin(strings_file_text_provider::strings_file_text_provider_plugin)
app.add_plugins(shared_text_provider::shared_text_provider_plugin)
.add_plugins(strings_file_text_provider::strings_file_text_provider_plugin)
.add_systems(
Update,
fetch_resources
Expand Down
7 changes: 3 additions & 4 deletions crates/bevy_plugin/src/localization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ pub(crate) use self::{
line_id_generation::LineIdUpdateSystemSet,
strings_file::UpdateAllStringsFilesForStringTableEvent, strings_file::*,
};
use crate::prelude::*;
use bevy::prelude::*;

mod line_id_generation;
mod localizations;
mod strings_file;

pub(crate) fn localization_plugin(app: &mut App) {
app.fn_plugin(localizations::localization_config_plugin)
.fn_plugin(line_id_generation::line_id_generation_plugin)
.fn_plugin(strings_file::strings_file_plugin);
app.add_plugins(localizations::localization_config_plugin)
.add_plugins(line_id_generation::line_id_generation_plugin)
.add_plugins(strings_file::strings_file_plugin);
}
2 changes: 1 addition & 1 deletion crates/bevy_plugin/src/localization/line_id_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) fn line_id_generation_plugin(app: &mut App) {
.pipe(panic_on_err)
.run_if(in_development.and_then(has_localizations)),
handle_yarn_file_events_outside_development.run_if(
resource_exists::<YarnProject>()
resource_exists::<YarnProject>
.and_then(not(in_development.and_then(has_localizations))),
),
)
Expand Down
5 changes: 2 additions & 3 deletions crates/bevy_plugin/src/localization/strings_file.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
pub(crate) use self::{asset::StringsFile, updating::UpdateAllStringsFilesForStringTableEvent};
use bevy::prelude::*;
use seldom_fn_plugin::FnPluginExt;

mod asset;
mod updating;

pub(crate) fn strings_file_plugin(app: &mut App) {
app.fn_plugin(asset::strings_file_asset_plugin)
.fn_plugin(updating::strings_file_updating_plugin);
app.add_plugins(asset::strings_file_asset_plugin)
.add_plugins(updating::strings_file_updating_plugin);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) fn strings_file_updating_plugin(app: &mut App) {
.run_if(
in_development
.and_then(has_localizations)
.and_then(resource_exists::<YarnProject>())
.and_then(resource_exists::<YarnProject>)
.and_then(events_in_queue::<UpdateAllStringsFilesForStringTableEvent>()),
),)
.chain(),
Expand Down
14 changes: 7 additions & 7 deletions crates/bevy_plugin/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ impl YarnApp for App {
}

fn register_sub_plugins(&mut self) -> &mut Self {
self.fn_plugin(crate::yarn_file_asset::yarnspinner_asset_loader_plugin)
.fn_plugin(crate::localization::localization_plugin)
.fn_plugin(crate::dialogue_runner::dialogue_plugin)
.fn_plugin(crate::line_provider::line_provider_plugin)
.fn_plugin(crate::project::project_plugin)
.fn_plugin(crate::commands::commands_plugin)
.fn_plugin(crate::development_file_generation::development_file_generation_plugin)
self.add_plugins(crate::yarn_file_asset::yarnspinner_asset_loader_plugin)
.add_plugins(crate::localization::localization_plugin)
.add_plugins(crate::dialogue_runner::dialogue_plugin)
.add_plugins(crate::line_provider::line_provider_plugin)
.add_plugins(crate::project::project_plugin)
.add_plugins(crate::commands::commands_plugin)
.add_plugins(crate::development_file_generation::development_file_generation_plugin)
}

fn register_watching_for_changes(&mut self) -> &mut Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_plugin/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::iter;
mod compilation;

pub(crate) fn project_plugin(app: &mut App) {
app.fn_plugin(compilation::project_compilation_plugin)
app.add_plugins(compilation::project_compilation_plugin)
.add_event::<LoadYarnProjectEvent>();
}

Expand All @@ -23,7 +23,7 @@ pub(crate) struct CompilationSystemSet;
/// # use bevy::prelude::*;
/// # use bevy_yarnspinner::prelude::*;
/// # let mut app = App::new();
/// app.add_systems(Update, setup_dialogue_runners.run_if(resource_added::<YarnProject>()));
/// app.add_systems(Update, setup_dialogue_runners.run_if(resource_added::<YarnProject>));
///
/// fn setup_dialogue_runners(mut commands: Commands, project: Res<YarnProject>) {
/// commands.spawn(project.create_dialogue_runner());
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_plugin/src/project/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ pub(crate) fn project_compilation_plugin(app: &mut App) {
load_project.pipe(panic_on_err),
add_yarn_files_to_load_queue
.pipe(panic_on_err)
.run_if(resource_exists_and_changed::<YarnFilesToLoad>()),
.run_if(resource_exists_and_changed::<YarnFilesToLoad>),
compile_loaded_yarn_files
.pipe(panic_on_err)
.run_if(resource_exists::<YarnFilesToLoad>()),
.run_if(resource_exists::<YarnFilesToLoad>),
recompile_loaded_yarn_files
.map(error)
.run_if(events_in_queue::<RecompileLoadedYarnFilesEvent>()),
clear_temp_yarn_project.run_if(resource_added::<YarnProject>()),
clear_temp_yarn_project.run_if(resource_added::<YarnProject>),
)
.chain()
.after(LineIdUpdateSystemSet)
Expand Down
6 changes: 3 additions & 3 deletions crates/compiler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yarnspinner_compiler"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
homepage = "https://docs.yarnspinner.dev/"
Expand All @@ -18,11 +18,11 @@ bevy = ["dep:bevy", "yarnspinner_core/bevy"]
antlr-rust = "=0.3.0-beta"
better_any = "=0.2.0"
regex = "1"
yarnspinner_core = { path = "../core", version = "0.1" }
yarnspinner_core = { path = "../core", version = "0.2" }
thiserror = "1"
strum = "0.26"
strum_macros = "0.26"
annotate-snippets = "0.10"
serde = { version = "1", features = ["derive"], optional = true }
bevy = { version = "0.12", default-features = false, optional = true }
bevy = { version = "0.13", default-features = false, optional = true }
rand = { version = "0.8", features = ["small_rng"] }
4 changes: 2 additions & 2 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yarnspinner_core"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
homepage = "https://docs.yarnspinner.dev/"
Expand All @@ -23,4 +23,4 @@ strum_macros = "0.26"
thiserror = "1"
prost = "0.12"
serde = { version = "1", features = ["derive"], optional = true }
bevy = { version = "0.12", default-features = false, optional = true }
bevy = { version = "0.13", default-features = false, optional = true }
7 changes: 3 additions & 4 deletions 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.1.0"
version = "0.2.0"
edition = "2021"
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
homepage = "https://docs.yarnspinner.dev/"
Expand All @@ -14,11 +14,10 @@ readme = "../../readme.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy_yarnspinner = { path = "../bevy_plugin", version = "0.1" }
bevy_yarnspinner = { path = "../bevy_plugin", version = "0.2" }
unicode-segmentation = "1"
seldom_fn_plugin = "0.5"

[dependencies.bevy]
version = "0.12"
version = "0.13"
default-features = false
features = ["bevy_ui", "bevy_text", "bevy_render", "png", "bevy_asset"]
2 changes: 2 additions & 0 deletions crates/example_dialogue_view/src/assets.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bevy::asset::load_internal_binary_asset;
use bevy::prelude::*;
use bevy::render::render_asset::RenderAssetUsages;
use bevy::render::texture::{CompressedImageFormats, ImageSampler, ImageType};

pub(crate) fn ui_assets_plugin(app: &mut App) {
Expand Down Expand Up @@ -34,6 +35,7 @@ fn load_image(bytes: &[u8], _path: String) -> Image {
CompressedImageFormats::NONE,
IS_SRGB,
ImageSampler::Default,
RenderAssetUsages::RENDER_WORLD,
)
.unwrap()
}
Expand Down
11 changes: 5 additions & 6 deletions crates/example_dialogue_view/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#![warn(missing_docs, missing_debug_implementations)]

use bevy::prelude::*;
use seldom_fn_plugin::FnPluginExt;
pub use updating::SpeakerChangeEvent;

pub mod prelude {
Expand Down Expand Up @@ -77,10 +76,10 @@ mod updating;

impl Plugin for ExampleYarnSpinnerDialogueViewPlugin {
fn build(&self, app: &mut App) {
app.fn_plugin(assets::ui_assets_plugin)
.fn_plugin(setup::ui_setup_plugin)
.fn_plugin(updating::ui_updating_plugin)
.fn_plugin(typewriter::typewriter_plugin)
.fn_plugin(option_selection::option_selection_plugin);
app.add_plugins(assets::ui_assets_plugin)
.add_plugins(setup::ui_setup_plugin)
.add_plugins(updating::ui_updating_plugin)
.add_plugins(typewriter::typewriter_plugin)
.add_plugins(option_selection::option_selection_plugin);
}
}
Loading
Loading