diff --git a/src/bin/trees/main.rs b/src/bin/trees/main.rs index 5b2fe78..0dd23a1 100644 --- a/src/bin/trees/main.rs +++ b/src/bin/trees/main.rs @@ -723,6 +723,7 @@ struct AssignMonologue(Handle); fn assign_monologue_to_tree( mut events: EventReader, query: Query, Without)>, + mut notice: ResMut, mut commands: Commands, ) { // Kinda a weird hack because query does not update @@ -739,8 +740,10 @@ fn assign_monologue_to_tree( commands.entity(tree).insert(monologue); } else if let Some(path) = event.0.path() { error!("No trees avaliable for {path:?}"); + notice.0 = format!("No trees avaliable for {path:?}"); } else { error!("Monologue is not yet loaded!"); + notice.0 = "Monologue is not yet loaded!".into(); } }); } diff --git a/src/debug.rs b/src/debug.rs index d60e05c..9a03c9f 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -11,6 +11,7 @@ impl Plugin for DebuggingPlugin { .init_resource::() .init_resource::() .init_resource::() + .init_resource::() .add_plugins(RapierDebugRenderPlugin::default().disabled()) // Added by Rapier // .add_plugins(AabbGizmoPlugin) @@ -32,6 +33,7 @@ impl Plugin for DebuggingPlugin { sync_resource_to_ui::.run_if(resource_changed::), track_entity_count, sync_resource_to_ui::.run_if(resource_changed::), + sync_resource_to_ui::.run_if(resource_changed::), ) .run_if(in_state(DebuggingState::On)), ), @@ -74,13 +76,29 @@ fn init_debug_ui(mut commands: Commands) { children![Text::new(VERSION),], GlobalZIndex(i32::MAX - 1), Node { - width: Val::Auto, + max_width: Val::Percent(50.0), align_self: AlignSelf::End, justify_self: JustifySelf::End, ..default() }, )); + commands.spawn(( + DebuggingState::On, + Name::new("Notice"), + children![( + Text::new(""), + SyncResource::::default(), + )], + GlobalZIndex(i32::MAX - 1), + Node { + max_width: Val::Percent(50.0), + align_self: AlignSelf::End, + justify_self: JustifySelf::Start, + ..default() + }, + )); + // "Turn on Debugging" button commands .spawn(( @@ -186,6 +204,15 @@ fn toggle_rapier_debug_render( context.enabled = *state.get() == DebuggingState::On; } +#[derive(Default, Resource)] +pub struct Notice(pub String); + +impl Display for Notice { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + writeln!(f, "{}", self.0) + } +} + /// Add a generic Tooltip that follows the mouse in debug mode #[derive(Default, Resource)] pub struct ToolTip(HashMap);