Skip to content
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,675 changes: 874 additions & 801 deletions Cargo.lock

Large diffs are not rendered by default.

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.18"
version = "0.19"
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.18"
version = "0.19"
default-features = false
features = [ "bevy_core_pipeline", "bevy_audio" ]

Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_plugin/src/dialogue_runner/runtime_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ fn continue_runtime(
Commands,
)> = SystemState::new(world);

let (mut dialogue_runners, loaded_untyped_assets, mut commands) = system_state.get_mut(world);
let (mut dialogue_runners, loaded_untyped_assets, mut commands) =
system_state.get_mut(world)?;

let mut dialogues: HashMap<_, _, FixedHasher> = HashMap::default();

Expand Down Expand Up @@ -125,7 +126,7 @@ fn continue_runtime(
Commands,
)> = SystemState::new(world);

let (mut dialogue_runners, project, mut commands) = system_state.get_mut(world);
let (mut dialogue_runners, project, mut commands) = system_state.get_mut(world)?;

for (source, mut dialogue_runner) in dialogue_runners.iter_mut() {
if let Some((dialogue, is_sending_missed_events, _, Some(events))) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl FileExtensionAssetProvider {
);
let path = dir.join(file_name);
let asset_path = path.to_string_lossy().replace('\\', "/");
let handle = asset_server.load_untyped(asset_path);
let handle = asset_server.load_builder().load_untyped(asset_path);
self.loading_handles.insert(path, handle);
}
}
Expand Down
7 changes: 4 additions & 3 deletions crates/bevy_plugin/src/localization/line_id_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ pub(crate) fn line_id_generation_plugin(app: &mut App) {
(
handle_yarn_file_events
.pipe(panic_on_err)
.run_if(in_development.and(has_localizations)),
.run_if(in_development.and_then(has_localizations)),
handle_yarn_file_events_outside_development.run_if(
resource_exists::<YarnProject>.and(not(in_development.and(has_localizations))),
resource_exists::<YarnProject>
.and_then(not(in_development.and_then(has_localizations))),
),
)
.chain()
Expand Down Expand Up @@ -135,7 +136,7 @@ fn handle_yarn_file_events(
if is_watching {
added_tags.insert(*id);
} else {
let yarn_file = assets.get_mut(*id).unwrap();
let mut yarn_file = assets.get_mut(*id).unwrap();
yarn_file.file.source = source_with_added_ids;

let string_table = YarnCompiler::new()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_plugin/src/localization/strings_file/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl StringsFile {
&& !record.text.starts_with(UPDATE_PREFIX)
&& !text_is_copied_from_base_language
{
format!("{UPDATE_PREFIX}{}", &record.text)
format!("{UPDATE_PREFIX}{}", record.text)
} else if !text_is_copied_from_base_language {
// not `other_record` because that one might not contain (NEEDS UPDATE)
record.text.clone()
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_plugin/src/localization/strings_file/updating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub(crate) fn strings_file_updating_plugin(app: &mut App) {
.in_set(YarnSpinnerSystemSet)
.run_if(
in_development
.and(has_localizations)
.and(resource_exists::<YarnProject>)
.and(events_in_queue::<UpdateAllStringsFilesForStringTableEvent>()),
.and_then(has_localizations)
.and_then(resource_exists::<YarnProject>)
.and_then(events_in_queue::<UpdateAllStringsFilesForStringTableEvent>()),
),)
.chain(),
);
Expand Down Expand Up @@ -77,9 +77,9 @@ fn update_all_strings_files_for_string_table(
.collect();
let file_names = file_names.into_iter().collect::<Vec<_>>().join(", ");
for (language, strings_file_handle) in languages_to_handles.clone() {
let strings_file = strings_files.get_mut(&strings_file_handle).unwrap();
let mut strings_file = strings_files.get_mut(&strings_file_handle).unwrap();
lint_strings_file(
strings_file,
&strings_file,
&expected_file_names,
&asset_server,
&strings_file_handle,
Expand Down
11 changes: 6 additions & 5 deletions crates/bevy_plugin/tests/test_strings_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ fn appends_to_pre_existing_strings_file() -> anyhow::Result<()> {
let handle = app
.world()
.resource::<AssetServer>()
.load_builder()
.load_untyped("dialogue/de-CH.strings.csv");
while app
.world()
Expand Down Expand Up @@ -241,16 +242,16 @@ fn replaces_entries_in_strings_file() -> anyhow::Result<()> {
.world_mut()
.get_resource_mut::<Assets<YarnFile>>()
.unwrap();
let yarn_file = yarn_file_assets.get_mut(&handle).unwrap();
let mut yarn_file = yarn_file_assets.get_mut(&handle).unwrap();

let strings_file_source =
fs::read_to_string(&strings_file_path)?.replace("*third*", "*dritter*");
fs::write(&strings_file_path, strings_file_source)?;

let mut lines: Vec<_> = yarn_file.content().lines().collect();
*lines.get_mut(2).unwrap() = "Changed line without translation #line:1";
*lines.get_mut(3).unwrap() = "Changed line with prior translation#line:2";
lines.insert(4, "Inserted line #line:13");
let mut lines: Vec<_> = yarn_file.content().lines().map(str::to_owned).collect();
*lines.get_mut(2).unwrap() = "Changed line without translation #line:1".to_owned();
*lines.get_mut(3).unwrap() = "Changed line with prior translation#line:2".to_owned();
lines.insert(4, "Inserted line #line:13".to_owned());
lines.remove(6);
yarn_file.set_content(lines.join("\n"))?;
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_plugin/tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl AppExt for App {
}
let mut system_state: SystemState<(Commands, Res<YarnProject>)> =
SystemState::new(self.world_mut());
let (mut commands, yarn_project) = system_state.get_mut(self.world_mut());
let (mut commands, yarn_project) = system_state.get_mut(self.world_mut()).unwrap();
yarn_project.build_dialogue_runner(&mut commands)
}

Expand Down Expand Up @@ -126,7 +126,7 @@ impl AppExt for App {
self.load_project();
let mut system_state: SystemState<(Commands, Res<YarnProject>)> =
SystemState::new(self.world_mut());
let (mut commands, yarn_project) = system_state.get_mut(self.world_mut());
let (mut commands, yarn_project) = system_state.get_mut(self.world_mut()).unwrap();
let dialogue_runner = yarn_project.create_dialogue_runner(&mut commands);
system_state.apply(self.world_mut());
self.world_mut().spawn(dialogue_runner).id()
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.8.0" }
annotate-snippets = "0.12"
serde = { version = "1", features = [ "derive" ], optional = true }
serde_json = { version = "1", optional = true }
bevy = { version = "0.18", default-features = false, optional = true }
bevy = { version = "0.19", 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/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.18", default-features = false, optional = true, features = [ "std" ] }
bevy = { version = "0.19", 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
2 changes: 1 addition & 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.8.0" }
unicode-segmentation = "1"

[dependencies.bevy]
version = "0.18"
version = "0.19"
default-features = false
features = [
"bevy_ui",
Expand Down
2 changes: 1 addition & 1 deletion crates/example_dialogue_view/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) fn ui_assets_plugin(app: &mut App) {
}

fn load_font(bytes: &[u8], _path: String) -> Font {
Font::try_from_bytes(bytes.to_vec()).unwrap()
Font::from_bytes(bytes.to_vec())
}

fn load_image(bytes: &[u8], _path: String) -> Image {
Expand Down
17 changes: 16 additions & 1 deletion crates/example_dialogue_view/src/option_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::typewriter::{Typewriter, TypewriterFinishedEvent};
use bevy::color::palettes::css;
use bevy::platform::collections::HashMap;
use bevy::prelude::*;
use bevy::text::TextLayoutInfo;
use bevy::window::{CursorIcon, PrimaryWindow, SystemCursorIcon};
use bevy_yarnspinner::{events::*, prelude::*};

Expand All @@ -12,9 +13,10 @@ pub(crate) fn option_selection_plugin(app: &mut App) {
Update,
(
create_options.run_if(resource_added::<OptionSelection>),
hack_sync_option_text_min_height.run_if(resource_exists::<OptionSelection>),
show_options,
select_option.run_if(
resource_exists::<OptionSelection>.and(any_with_component::<PrimaryWindow>),
resource_exists::<OptionSelection>.and_then(any_with_component::<PrimaryWindow>),
),
)
.chain()
Expand Down Expand Up @@ -65,6 +67,19 @@ fn create_options(
}
}

/// Looks like something is layouting the box for just one line instead of multiple ones
/// when text is wrapped. So let's force sync stuff.
fn hack_sync_option_text_min_height(
mut option_texts: Query<(&TextLayoutInfo, &mut Node), With<OptionButton>>,
) {
for (layout_info, mut node) in &mut option_texts {
let min_height = Val::Px(layout_info.size.y);
if node.min_height != min_height {
node.min_height = min_height;
}
}
}

fn show_options(
mut typewriter_finished_event: MessageReader<TypewriterFinishedEvent>,
mut options_node: Single<&mut Visibility, With<OptionsNode>>,
Expand Down
12 changes: 6 additions & 6 deletions crates/example_dialogue_view/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ mod text_style {
pub(crate) fn standard() -> (TextFont, TextColor) {
(
TextFont {
font: font_handle::MEDIUM,
font_size: 20.0,
font: FontSource::Handle(font_handle::MEDIUM),
font_size: FontSize::Px(20.0),
..default()
},
TextColor(Color::WHITE),
Expand All @@ -236,8 +236,8 @@ mod text_style {
pub(crate) fn name() -> (TextFont, TextColor) {
(
TextFont {
font: font_handle::MEDIUM,
font_size: 18.0,
font: FontSource::Handle(font_handle::MEDIUM),
font_size: FontSize::Px(18.0),
..standard().0
},
standard().1,
Expand All @@ -247,7 +247,7 @@ mod text_style {
pub(crate) fn option_id() -> (TextFont, TextColor) {
(
TextFont {
font: font_handle::MEDIUM,
font: FontSource::Handle(font_handle::MEDIUM),
..option_text().0
},
TextColor(css::ALICE_BLUE.into()),
Expand All @@ -257,7 +257,7 @@ mod text_style {
pub(crate) fn option_text() -> (TextFont, TextColor) {
(
TextFont {
font_size: 18.0,
font_size: FontSize::Px(18.0),
..standard().0
},
TextColor(css::TOMATO.into()),
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ fixed_decimal = { version = "0.7", default-features = false, features = [
once_cell = "1"
regex = "1"
serde = { version = "1", features = ["derive"], optional = true }
bevy = { version = "0.18.0", default-features = false, features = ["bevy_log"], optional = true }
bevy_platform = { version = "0.18.0", features = ["alloc"] }
bevy = { version = "0.19.0", default-features = false, features = ["bevy_log"], optional = true }
bevy_platform = { version = "0.19.0", features = ["alloc"] }

[lints.clippy]
std_instead_of_core = "warn"
Expand Down
4 changes: 2 additions & 2 deletions crates/yarnspinner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ yarnspinner_core = { path = "../core", version = "0.8.0" }
yarnspinner_compiler = { path = "../compiler", version = "0.8.0" }
yarnspinner_runtime = { path = "../runtime", version = "0.8.0" }
log = { version = "0.4", features = ["std"] }
bevy = { version = "0.18", default-features = false, optional = true }
bevy = { version = "0.19", default-features = false, optional = true }

[dev-dependencies]
regex = "1"
anyhow = "1"
bevy_platform = "0.18"
bevy_platform = "0.19"
5 changes: 1 addition & 4 deletions crates/yarnspinner/tests/test_base/step/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ impl<'a> Reader<'a> {
/// Parse the next T from this string, ignoring leading whitespace
fn read_next_raw(&mut self) -> String {
let mut string = String::new();
loop {
let Some(character) = self.read_char() else {
break;
};
while let Some(character) = self.read_char() {
if character.is_whitespace() {
// eat leading whitespace
continue;
Expand Down
5 changes: 1 addition & 4 deletions crates/yarnspinner/tests/type_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ fn test_variable_declarations_parsed() {
];

let actual_declarations = result.declarations;
for (expected, actual) in expected_declarations
.iter()
.zip(actual_declarations.into_iter())
{
for (expected, actual) in expected_declarations.iter().zip(actual_declarations) {
assert_eq!(expected.name, actual.name);
assert_eq!(expected.r#type, actual.r#type);
assert_eq!(expected.default_value, actual.default_value);
Expand Down
4 changes: 2 additions & 2 deletions demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
bevy = { version = "0.18.0" }
bevy = { version = "0.19.0" }
bevy_yarnspinner = { path = "../crates/bevy_plugin", version = "0.8.0" }
bevy_yarnspinner_example_dialogue_view = { path = "../crates/example_dialogue_view", version = "0.8.0" }
bevy_sprite3d = "8.0.0"
bevy_sprite3d = "9.0.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.4", features = ["wasm_js"] }
4 changes: 2 additions & 2 deletions demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use self::{setup::*, visual_effects::*, yarnspinner_integration::*};
use bevy::asset::AssetMetaCheck;
use bevy::color::palettes::css;
use bevy::prelude::*;
use bevy::scene::SceneInstance;
use bevy::window::PresentMode;
use bevy::world_serialization::WorldInstance;
use bevy_sprite3d::Sprite3dPlugin;
use bevy_yarnspinner::prelude::*;
use bevy_yarnspinner_example_dialogue_view::prelude::*;
Expand Down Expand Up @@ -45,7 +45,7 @@ fn main() {
Update,
(
spawn_dialogue_runner.run_if(resource_added::<YarnProject>),
adapt_materials.run_if(any_with_component::<SceneInstance>),
adapt_materials.run_if(any_with_component::<WorldInstance>),
spawn_sprites.run_if(sprites_have_loaded),
),
)
Expand Down
Loading