diff --git a/bin/editor.rs b/bin/editor.rs index 156ed59..9c54a50 100644 --- a/bin/editor.rs +++ b/bin/editor.rs @@ -3,12 +3,15 @@ // Editor for creating Monologue Trees levels // // BUGS: +// * Multi-GLTF UX is bad. +// * Consider GLTF hierarchy (GLTF1 > Scene1a/Scene1b, GlTF2 > Scene2a/Scene2b, etc) +// * Easy despawn when de-selecting gltf // // TODO: -// * (medium) Load default scene when gltf selected -// * Use default camera. // * (easy) Play all animations -// * (medium) Visual errors for GLTFs problems (no cameras) +// * (easy) Clear button to wipe spawned scene +// * (brutal) export level +// * (hard) import level // // Asset types: // * Audios (done) @@ -66,23 +69,35 @@ fn main() { .add_systems( Update, ( - import_files, - audio_ui, - gltf_ui, - fonts_ui, - texts_ui, - cameras_ui, - manage_active_gltf, - manage_gltf_scene_ui, manage_gltf_animation_ui, - scenes_ui, + init_animations_ui, animations_ui, - control_active_scenes, + play_all_animations, + play_animation, + ), + ) + .add_systems( + Update, + (manage_gltf_scene_ui, scenes_ui, control_active_scenes), + ) + .add_systems( + Update, + ( + cameras_ui, manage_active_camera, control_active_camera, fallback_camera, - play_animation, - play_audio, + ), + ) + .add_systems(Update, (audio_ui, play_audio)) + .add_systems( + Update, + ( + import_files, + gltf_ui, + fonts_ui, + texts_ui, + manage_active_gltf, show_preview_text, sync_monologue_font, ), @@ -832,6 +847,36 @@ mod animations { #[derive(Debug, Component, Default)] pub struct AnimationWidget; + #[derive(Debug, Component)] + pub struct AnimationPlayAll; + + pub fn init_animations_ui( + events: Query>, + mut commands: Commands, + ) { + events.iter().for_each(|entity| { + commands.entity(entity).with_children(|parent| { + parent.spawn(( + AnimationPlayAll, + ButtonBundle { + style: Style { + border: UiRect::all(Val::Px(1.0)), + margin: UiRect::all(Val::Px(1.0)), + padding: UiRect::all(Val::Px(1.0)), + ..default() + }, + border_color: Color::BLACK.into(), + ..default() + }, + ui::Title { + text: "Play All".into(), + ..default() + }, + )); + }); + }) + } + pub fn animations_ui( mut events: EventReader>, mut commands: Commands, @@ -869,26 +914,59 @@ mod animations { }); } + pub fn play_all_animations( + start: Query, Added)>, + mut stop: RemovedComponents, + play_all_btn: Query>, + clip_btns: Query>>, + mut commands: Commands, + ) { + stop.iter() + .filter(|&entity| play_all_btn.contains(entity)) + .for_each(|_| { + clip_btns.iter().for_each(|entity| { + commands.entity(entity).remove::(); + }) + }); + start + .iter() + .filter(|&entity| play_all_btn.contains(entity)) + .for_each(|_| { + clip_btns.iter().for_each(|entity| { + commands.entity(entity).insert(ui::Active); + }) + }); + } + pub fn play_animation( - events: Query< - (&Interaction, &ui::TargetAsset), - (With