From 09d48951bcf4f9a750e5596d00cce203efec2f99 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Wed, 5 Jul 2023 08:14:15 -0700 Subject: [PATCH] making progress on modular text animation systems --- bin/debug-info.rs | 2 +- bin/text-inspect.rs | 98 +++-------------------- src/debug.rs | 6 +- src/lib.rs | 2 + src/text.rs | 191 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 208 insertions(+), 91 deletions(-) create mode 100644 src/text.rs diff --git a/bin/debug-info.rs b/bin/debug-info.rs index 82362d7..965736c 100644 --- a/bin/debug-info.rs +++ b/bin/debug-info.rs @@ -12,6 +12,6 @@ fn main() { }), ..default() })) - .add_plugin(debug::DebugInfo) + .add_plugin(debug::DebugInfoPlugin) .run() } diff --git a/bin/text-inspect.rs b/bin/text-inspect.rs index 60ca952..1c7f3bf 100644 --- a/bin/text-inspect.rs +++ b/bin/text-inspect.rs @@ -2,7 +2,7 @@ use std::time::Duration; use bevy::prelude::*; -use monologue_trees::*; +use monologue_trees::{debug::*, text::*}; const LOREM: [&str; 5] = [ "Ullam nostrum aut amet adipisci consequuntur quisquam nemo consequatur. Vel eum et ullam ullam aperiam earum voluptas consequuntur. Blanditiis earum voluptatem voluptas animi dolorum fuga aliquam ea.\n", @@ -22,13 +22,14 @@ fn main() { }), ..default() })) - .add_plugin(debug::DebugInfo) + .add_plugin(DebugInfoPlugin) + .add_plugin(AnimatedTextPlugin) .add_startup_system(load_fonts) .add_startup_system(init_ui) .add_system(manage_buttons) - .add_system(update_font) + .add_system(manage_fonts) .add_system(mouse_cursor) - .add_system(play) + .add_system(manage_animation) .run(); } @@ -93,20 +94,10 @@ fn init_ui(mut commands: Commands) { )); parent.spawn(( - TextBundle::from_sections(LOREM.iter().map(|§ion| TextSection { - value: section.into(), - style: TextStyle { - font_size: 20.0, - ..default() - }, - })) - .with_style(Style { - max_size: Size { - width: Val::Px(450.), - height: Val::Undefined, - }, - ..default() - }), + AnimatedTextBundle { + text_bundle: TextBundle { ..default() }, + animated_text: AnimatedText::new(TextAnimationType::Typing(12.0)), + }, Marker, PreviewText, )); @@ -169,7 +160,7 @@ fn manage_buttons( } } -fn update_font( +fn manage_fonts( mut texts: Query<&mut Text, (With, With)>, interaction: Query<(&Interaction, &FontButton), Changed>, ) { @@ -199,7 +190,7 @@ fn mouse_cursor( } } -fn play( +fn manage_animation( mut texts: Query<&mut Text, (With, With)>, interactions: Query<&Interaction, (Changed, With)>, time: Res