Skip to content
Open
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,269 changes: 896 additions & 373 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ inherits = "release"
opt-level = "z"
lto = "fat"
codegen-units = 1

4 changes: 2 additions & 2 deletions crates/bevy_plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sha2 = "0.10"
variadics_please = "1"

[dependencies.bevy]
version = "0.19"
version = "0.20"
default-features = false
features = [ "bevy_asset", "multi_threaded", "bevy_log" ]

Expand All @@ -35,7 +35,7 @@ tempfile = "3"
static_assertions = "1.1.0"

[dev-dependencies.bevy]
version = "0.19"
version = "0.20"
default-features = false
features = [ "bevy_core_pipeline", "bevy_audio" ]

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub mod prelude {
yarn_file_asset::YarnFile,
};
pub(crate) use crate::{localization::StringsFile, utils::*};
pub(crate) use anyhow::{Context, Error};
pub(crate) use anyhow::Error;
pub(crate) use serde::{Deserialize, Serialize};
pub(crate) use yarnspinner::prelude::*;
pub use yarnspinner::prelude::{
Expand Down
21 changes: 13 additions & 8 deletions crates/bevy_plugin/src/localization/line_id_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,22 @@ fn handle_yarn_file_events(
if added_tags.contains(id) {
continue;
}
let asset_path = asset_server
.get_path(*id)
.with_context(|| format!("Failed to overwrite Yarn file \"{}\" with new IDs because it was not found on disk",
yarn_file.file_name()))?;
let asset_path = anyhow::Context::with_context(asset_server.get_path(*id), || {
format!(
"Failed to overwrite Yarn file \"{}\" with new IDs because it was not found on disk",
yarn_file.file_name()
)
})?;
let path = asset_root.0.join(asset_path.path());

std::fs::write(&path, &source_with_added_ids)
.context(
format!("Failed to overwrite Yarn file at {} with new line IDs. \
anyhow::Context::context(
std::fs::write(&path, &source_with_added_ids),
format!(
"Failed to overwrite Yarn file at {} with new line IDs. \
Aborting because localization requires all lines to have IDs, but this file is missing some.",
path.display()))?;
path.display()
),
)?;

info!(
"Automatically generated line IDs for Yarn file at {}",
Expand Down
26 changes: 15 additions & 11 deletions crates/bevy_plugin/src/plugin/yarn_file_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ impl YarnFileSource {
match self {
Self::Handle(handle) => Ok(vec![handle.clone()]),
Self::InMemory(yarn_file) => Ok(vec![assets.add(yarn_file.clone())]),
Self::File(path) => Ok(vec![asset_server.load(path.clone())]),
// A PathBuf becomes a default-source AssetPath in Bevy. Parse its
// string form instead so named sources such as game:// survive.
Self::File(path) => Ok(vec![asset_server.load(path.to_string_lossy().into_owned())]),
#[cfg(not(any(target_arch = "wasm32", target_os = "android")))]
Self::Folder(path) => Self::load_folder(asset_server, path.as_path(), asset_root),
}
Expand All @@ -77,20 +79,22 @@ impl YarnFileSource {
"Failed to load Yarn file folder {path}.\nHelp: Does the folder exist?",
path = path.display()
);
let handles: Result<Vec<_>> =
glob(path.join("**/*.yarn").to_str().with_context(|| {
let handles: Result<Vec<_>> = glob(anyhow::Context::with_context(
path.join("**/*.yarn").to_str(),
|| {
format!(
"Failed to create string from path: {path}",
path = path.display(),
)
})?)?
.map(|entry| {
let full_path = entry?;
let path = full_path.strip_prefix(&asset_root.0)?;
let asset_path = path.to_string_lossy().replace('\\', "/");
Ok(asset_server.load(asset_path))
})
.collect();
},
)?)?
.map(|entry| {
let full_path = entry?;
let path = full_path.strip_prefix(&asset_root.0)?;
let asset_path = path.to_string_lossy().replace('\\', "/");
Ok(asset_server.load(asset_path))
})
.collect();
let handles = handles?;

if handles.is_empty() {
Expand Down
15 changes: 7 additions & 8 deletions crates/bevy_plugin/src/yarn_file_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ impl AssetLoader for YarnFileAssetLoader {

fn read_yarn_file(bytes: Vec<u8>, load_context: &LoadContext) -> Result<YarnFile, Error> {
let source = String::from_utf8(bytes)?;
let file_name = load_context
.path()
.path()
.file_name()
.context("Yarn file has no filename")?
.to_str()
.context("Yarn file name is not valid UTF-8")?
.to_owned();
let file_name = anyhow::Context::context(
load_context.path().path().file_name(),
"Yarn file has no filename",
)?;
let file_name =
anyhow::Context::context(file_name.to_str(), "Yarn file name is not valid UTF-8")?
.to_owned();
let file = InnerYarnFile { file_name, source };
let string_table = YarnCompiler::new()
.with_compilation_type(CompilationType::StringsOnly)
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ yarnspinner_core = { path = "../core", version = "0.9.0" }
annotate-snippets = "0.12"
serde = { version = "1", features = [ "derive" ], optional = true }
serde_json = { version = "1", optional = true }
bevy = { version = "0.19", default-features = false, optional = true }
bevy = { version = "0.20", default-features = false, optional = true }
rand = { version = "0.10", default-features = false }
crc32fast = "1.5"
globset = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/src/listeners/error_listener/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Diagnostic {
T: ParserRuleContextExt<'input>,
<<<<T as CustomRuleContext<'input>>::TF as TokenFactory<'input>>::Inner as Token>::Data as ToOwned>::Owned:
Into<String>
{
{
let lines_above_and_below_offending_line = 2;
let lines_around = ctx.get_lines_around(token_stream, lines_above_and_below_offending_line);
let range = ctx.range();
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bevy = [ "dep:bevy" ]
rand = { version = "0.10", default-features = false, features = [ "sys_rng" ] }
prost = { version = "0.14", default-features = false, features = [ "derive" ] }
serde = { version = "1", features = [ "derive" ], optional = true }
bevy = { version = "0.19", default-features = false, optional = true, features = [ "std" ] }
bevy = { version = "0.20", default-features = false, optional = true, features = [ "std" ] }
variadics_please = "1.1.0"
hashbrown = "0.16.1"
yarnspinner_internal_shared = { path = "../internal_shared", version = "0.1.0" }
Expand Down
4 changes: 3 additions & 1 deletion crates/example_dialogue_view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bevy_yarnspinner = { path = "../bevy_plugin", version = "0.9.0" }
unicode-segmentation = "1"

[dependencies.bevy]
version = "0.19"
version = "0.20"
default-features = false
features = [
"bevy_ui",
Expand All @@ -28,4 +28,6 @@ features = [
"png",
"bevy_asset",
"bevy_window",
"bevy_ui_widgets",
"ui_picking",
]
Loading