From aba9415ad697ee7abfdbc8ef465dabc4743a31f6 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Mon, 28 Aug 2023 14:36:08 -0700 Subject: [PATCH] fixed camera issue, moved welcome messages to const --- bin/editor.rs | 167 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 123 insertions(+), 44 deletions(-) diff --git a/bin/editor.rs b/bin/editor.rs index 14958b1..83b7c18 100644 --- a/bin/editor.rs +++ b/bin/editor.rs @@ -3,18 +3,12 @@ // Editor for creating Monologue Trees levels // // BUGS: -// * Cannot view scene when selected, WTF -// * Scene and Animation tabs are whacked // // TODO: -// * (medium) Spawn gltf scene // * (medium) Load default scene when gltf selected -// * (medium) Set gltf to active/inactive -// * (medium) Play individual animation(s) -// * (hard) Better Colorscheme -// * (medium) Visual errors for bad GLTFs -// * (medium) Play clicked animation +// * Use default camera. // * (easy) Play all animations +// * (medium) Visual errors for GLTFs problems (no cameras) // // Asset types: // * Audios (done) @@ -36,6 +30,19 @@ use bevy::{ }; use monologue_trees::{debug::*, ui}; +const WELCOME_MESSAGES: &'static [&'static str] = &[ + "Welcome to the Monologue Trees editor!", + concat!( + "Import assets by dragging and dropping files into the editor\n", + "\n", + "Supported file types (for now):\n", + "* 3D: .gltf, .glb\n", + "* Audio: .ogg\n", + "* Font: .ttf, .otf\n", + "* Monologues: .monologue.txt\n", + ), +]; + fn main() { App::new() .add_plugins(( @@ -70,8 +77,10 @@ fn main() { manage_gltf_animation_ui, scenes_ui, animations_ui, - spawn_scenes, - manage_camera, + control_active_scenes, + manage_active_camera, + control_active_camera, + fallback_camera, play_animation, play_audio, show_preview_text, @@ -105,10 +114,11 @@ fn initialize_ui(mut commands: Commands) { commands.spawn((SpatialBundle { ..default() }, LevelRoot)); commands.spawn(( - Camera3dBundle { ..default() }, + Camera2dBundle { ..default() }, UiCameraConfig { show_ui: true }, Name::new("Editor Camera"), EditorCamera, + ui::Active, )); let base_style = Style { @@ -198,7 +208,7 @@ fn initialize_ui(mut commands: Commands) { content_containers.push(spawn_tab_container::( "Scene", parent, - ui::Select::Single, + ui::Select::Multi, )); content_containers.push(spawn_tab_container::( "Animation", @@ -266,21 +276,9 @@ fn initialize_ui(mut commands: Commands) { } fn welcome_message(mut writer: EventWriter) { - writer.send(ui::Alert::Info( - "Welcome to the Monologue Trees editor!".into(), - )); - writer.send(ui::Alert::Info( - [ - "Import assets by dragging and dropping files into the editor", - "", - "Supported file types (for now):", - "* 3D: .gltf, .glb", - "* Audio: .ogg", - "* Font: .ttf, .otf", - ] - .join("\n") - .into(), - )); + WELCOME_MESSAGES + .iter() + .for_each(|&msg| writer.send(ui::Alert::Info(msg.into()))) } fn spawn_tab_container( @@ -524,6 +522,22 @@ mod assets { } } + pub fn destroy_entity_button( + current: &Query<(Entity, &ui::TargetEntity)>, + commands: &mut Commands, + target: &ui::TargetEntity, + ) { + if let Some(entity) = current.iter().find_map(|(entity, this)| { + if this.entity == target.entity { + Some(entity) + } else { + None + } + }) { + commands.entity(entity).despawn_recursive(); + } + } + pub fn has_extensions( server: &AssetServer, handle: Handle, @@ -764,18 +778,31 @@ mod scenes { }); } - pub fn spawn_scenes( - events: Query< - (&Interaction, &ui::TargetAsset), - (With