From f64d61bc72defaf168cab101a625f1c8e93a7fa5 Mon Sep 17 00:00:00 2001 From: Liam Routt Date: Mon, 11 Mar 2024 16:43:04 +1100 Subject: [PATCH 1/3] Updates to Bevy 0.13 Updates to reach Bevy 0.13. All compiles, but examples all panic in a tweenable tick, for me. --- Cargo.toml | 8 +++----- examples/custom_skip.rs | 10 +++++----- examples/layouts.rs | 14 +++++++------- examples/screens.rs | 8 ++++---- examples/simple.rs | 4 ++-- src/lens.rs | 14 ++++++-------- src/lib.rs | 18 ++++++++++++++++++ src/splash.rs | 2 +- 8 files changed, 46 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 751f07a..133f257 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ opt-level = 1 opt-level = 3 [dev-dependencies] -bevy = { version = "0.12", default-features = false, features = [ +bevy = { version = "0.13", default-features = false, features = [ "multi-threaded", "bevy_asset", "bevy_winit", @@ -66,8 +66,6 @@ required-features = ["dev"] path = "./examples/simple.rs" [dependencies] -bevy = { version = "0.12", default-features = false } -bevy_tweening = "0.9" +bevy = { version = "0.13", default-features = false } +bevy_tweening = "0.10" -[patch.crates-io] -bevy_tweening = { git = "https://github.com/SergioRibera/bevy_tweening", branch = "infinite_mirrored" } diff --git a/examples/custom_skip.rs b/examples/custom_skip.rs index 8847785..fa9ff17 100644 --- a/examples/custom_skip.rs +++ b/examples/custom_skip.rs @@ -17,7 +17,7 @@ enum ScreenStates { fn main() { App::new() .add_plugins(DefaultPlugins) - .add_state::() + .init_state::() .add_plugins( SplashPlugin::new(ScreenStates::Splash, ScreenStates::Menu) .ignore_default_events() @@ -41,7 +41,7 @@ fn main() { }, ), ]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::WHITE, @@ -64,7 +64,7 @@ fn main() { ..default() }, ) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::WHITE, @@ -124,7 +124,7 @@ fn create_scene(mut cmd: Commands, assets: ResMut) { ..default() }, ) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), ..default() }, Animator::new( @@ -147,7 +147,7 @@ fn button_system( ) { for interaction in &mut interaction_query { match *interaction { - Interaction::Pressed => send_skip.send(SplashScreenSkipEvent), + Interaction::Pressed => {send_skip.send(SplashScreenSkipEvent); }, _ => {} } } diff --git a/examples/layouts.rs b/examples/layouts.rs index 791513d..775f4cf 100644 --- a/examples/layouts.rs +++ b/examples/layouts.rs @@ -14,7 +14,7 @@ enum ScreenStates { fn main() { App::new() .add_plugins(DefaultPlugins) - .add_state::() + .init_state::() .add_plugins( SplashPlugin::new(ScreenStates::Splash, ScreenStates::Menu) .skipable() @@ -48,7 +48,7 @@ fn main() { }, ), ]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::SEA_GREEN, @@ -68,7 +68,7 @@ fn main() { ..default() }, )]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::WHITE, @@ -95,7 +95,7 @@ fn main() { ..default() }, )]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::YELLOW, @@ -115,7 +115,7 @@ fn main() { ..default() }, )]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::BLUE, @@ -135,7 +135,7 @@ fn main() { ..default() }, )]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::WHITE, @@ -155,7 +155,7 @@ fn main() { ..default() }, )]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::PURPLE, diff --git a/examples/screens.rs b/examples/screens.rs index 60e56c1..75a715f 100644 --- a/examples/screens.rs +++ b/examples/screens.rs @@ -14,7 +14,7 @@ enum ScreenStates { fn main() { App::new() .add_plugins(DefaultPlugins) - .add_state::() + .init_state::() .add_plugins( SplashPlugin::new(ScreenStates::Splash, ScreenStates::Menu) .add_screen(SplashScreen { @@ -46,7 +46,7 @@ fn main() { }, ), ]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::SEA_GREEN, @@ -70,7 +70,7 @@ fn main() { ..default() }, )]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::WHITE, @@ -95,7 +95,7 @@ fn main() { ..default() }, )]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::RED, diff --git a/examples/simple.rs b/examples/simple.rs index fbbd5ab..810460b 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -14,7 +14,7 @@ enum ScreenStates { fn main() { App::new() .add_plugins(DefaultPlugins) - .add_state::() + .init_state::() .add_plugins( SplashPlugin::new(ScreenStates::Splash, ScreenStates::Menu) .skipable() @@ -48,7 +48,7 @@ fn main() { }, ), ]) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), "FiraSans-Bold.ttf".to_string(), ), tint: Color::SEA_GREEN, diff --git a/src/lens.rs b/src/lens.rs index 32bde73..eaaea64 100644 --- a/src/lens.rs +++ b/src/lens.rs @@ -33,10 +33,9 @@ impl Lens for SplashTextColorLens { .iter_mut() .enumerate() .for_each(|(i, section)| { - let start: Vec4 = self.0[i].with_a(0.).into(); - let end: Vec4 = self.0[i].into(); - let value = start.lerp(end, ratio); - section.style.color = value.into(); + use crate::ColorLerper as _; + let value = self.0[i].with_a(0.).lerp(&self.0[i], ratio); + section.style.color = value; }); } } @@ -49,9 +48,8 @@ impl InstanceLens for SplashImageColorLens { impl Lens for SplashImageColorLens { fn lerp(&mut self, target: &mut BackgroundColor, ratio: f32) { - let start: Vec4 = self.start.into(); - let end: Vec4 = self.end.into(); - let value = start.lerp(end, ratio); - target.0 = value.into(); + use crate::ColorLerper as _; + let value = self.start.lerp(&self.end, ratio); + target.0 = value; } } diff --git a/src/lib.rs b/src/lib.rs index ac89e90..ac30184 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -132,3 +132,21 @@ where ); } } + +/// Trait to interpolate between two values. +/// Needed for color. +#[allow(dead_code)] +trait ColorLerper { + fn lerp(&self, target: &Self, ratio: f32) -> Self; +} + +#[allow(dead_code)] +impl ColorLerper for Color { + fn lerp(&self, target: &Color, ratio: f32) -> Color { + let r = self.r().lerp(target.r(), ratio); + let g = self.g().lerp(target.g(), ratio); + let b = self.b().lerp(target.b(), ratio); + let a = self.a().lerp(target.a(), ratio); + Color::rgba(r, g, b, a) + } +} diff --git a/src/splash.rs b/src/splash.rs index 9a9a9a5..c85636f 100644 --- a/src/splash.rs +++ b/src/splash.rs @@ -98,7 +98,7 @@ pub(crate) fn create_splash( ..s.style }, })) - .with_alignment(text.alignment); + .with_justify(text.justify); cmd.spawn(( TextBundle { text: text.clone(), From 55d703f03013f9bbeb5561f0b5c5b264e92d04b3 Mon Sep 17 00:00:00 2001 From: Liam Routt Date: Fri, 15 Mar 2024 12:15:29 +1100 Subject: [PATCH 2/3] Return patch Inadvertently removed the patch crate reference; returning it --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 133f257..eb29b73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,3 +69,5 @@ path = "./examples/simple.rs" bevy = { version = "0.13", default-features = false } bevy_tweening = "0.10" +[patch.crates-io] +bevy_tweening = { git = "https://github.com/SergioRibera/bevy_tweening", branch = "infinite_mirrored" } From 51648533f7bb1c7f0fbf0d0c69027abdfa02a1ce Mon Sep 17 00:00:00 2001 From: Liam Routt Date: Fri, 15 Mar 2024 18:10:00 +1100 Subject: [PATCH 3/3] Fixing format Fix to pacify cargo fmt --- examples/custom_skip.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/custom_skip.rs b/examples/custom_skip.rs index fa9ff17..ae1a46f 100644 --- a/examples/custom_skip.rs +++ b/examples/custom_skip.rs @@ -147,7 +147,7 @@ fn button_system( ) { for interaction in &mut interaction_query { match *interaction { - Interaction::Pressed => {send_skip.send(SplashScreenSkipEvent); }, + Interaction::Pressed => send_skip.send(SplashScreenSkipEvent), _ => {} } }