|
|
|
@ -3,12 +3,15 @@
|
|
|
|
// Editor for creating Monologue Trees levels
|
|
|
|
// Editor for creating Monologue Trees levels
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// BUGS:
|
|
|
|
// BUGS:
|
|
|
|
|
|
|
|
// * Multi-GLTF UX is bad.
|
|
|
|
|
|
|
|
// * Consider GLTF hierarchy (GLTF1 > Scene1a/Scene1b, GlTF2 > Scene2a/Scene2b, etc)
|
|
|
|
|
|
|
|
// * Easy despawn when de-selecting gltf
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// TODO:
|
|
|
|
// TODO:
|
|
|
|
// * (medium) Load default scene when gltf selected
|
|
|
|
|
|
|
|
// * Use default camera.
|
|
|
|
|
|
|
|
// * (easy) Play all animations
|
|
|
|
// * (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:
|
|
|
|
// Asset types:
|
|
|
|
// * Audios (done)
|
|
|
|
// * Audios (done)
|
|
|
|
@ -66,23 +69,35 @@ fn main() {
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
(
|
|
|
|
(
|
|
|
|
import_files,
|
|
|
|
|
|
|
|
audio_ui,
|
|
|
|
|
|
|
|
gltf_ui,
|
|
|
|
|
|
|
|
fonts_ui,
|
|
|
|
|
|
|
|
texts_ui,
|
|
|
|
|
|
|
|
cameras_ui,
|
|
|
|
|
|
|
|
manage_active_gltf,
|
|
|
|
|
|
|
|
manage_gltf_scene_ui,
|
|
|
|
|
|
|
|
manage_gltf_animation_ui,
|
|
|
|
manage_gltf_animation_ui,
|
|
|
|
scenes_ui,
|
|
|
|
init_animations_ui,
|
|
|
|
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,
|
|
|
|
manage_active_camera,
|
|
|
|
control_active_camera,
|
|
|
|
control_active_camera,
|
|
|
|
fallback_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,
|
|
|
|
show_preview_text,
|
|
|
|
sync_monologue_font,
|
|
|
|
sync_monologue_font,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -832,6 +847,36 @@ mod animations {
|
|
|
|
#[derive(Debug, Component, Default)]
|
|
|
|
#[derive(Debug, Component, Default)]
|
|
|
|
pub struct AnimationWidget;
|
|
|
|
pub struct AnimationWidget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Component)]
|
|
|
|
|
|
|
|
pub struct AnimationPlayAll;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn init_animations_ui(
|
|
|
|
|
|
|
|
events: Query<Entity, Added<AnimationWidget>>,
|
|
|
|
|
|
|
|
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(
|
|
|
|
pub fn animations_ui(
|
|
|
|
mut events: EventReader<CustomAssetEvent<AnimationClip>>,
|
|
|
|
mut events: EventReader<CustomAssetEvent<AnimationClip>>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
@ -869,25 +914,58 @@ mod animations {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn play_all_animations(
|
|
|
|
|
|
|
|
start: Query<Entity, (With<Button>, Added<ui::Active>)>,
|
|
|
|
|
|
|
|
mut stop: RemovedComponents<ui::Active>,
|
|
|
|
|
|
|
|
play_all_btn: Query<Entity, With<AnimationPlayAll>>,
|
|
|
|
|
|
|
|
clip_btns: Query<Entity, With<ui::TargetAsset<AnimationClip>>>,
|
|
|
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
stop.iter()
|
|
|
|
|
|
|
|
.filter(|&entity| play_all_btn.contains(entity))
|
|
|
|
|
|
|
|
.for_each(|_| {
|
|
|
|
|
|
|
|
clip_btns.iter().for_each(|entity| {
|
|
|
|
|
|
|
|
commands.entity(entity).remove::<ui::Active>();
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
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(
|
|
|
|
pub fn play_animation(
|
|
|
|
events: Query<
|
|
|
|
start: Query<Entity, (With<Button>, Added<ui::Active>)>,
|
|
|
|
(&Interaction, &ui::TargetAsset<AnimationClip>),
|
|
|
|
mut stop: RemovedComponents<ui::Active>,
|
|
|
|
(With<Button>, Changed<Interaction>),
|
|
|
|
clip_refs: Query<&ui::TargetAsset<AnimationClip>>,
|
|
|
|
>,
|
|
|
|
|
|
|
|
mut targets: Query<(&mut AnimationPlayer, &Name), With<Transform>>,
|
|
|
|
mut targets: Query<(&mut AnimationPlayer, &Name), With<Transform>>,
|
|
|
|
clips: Res<Assets<AnimationClip>>,
|
|
|
|
clips: Res<Assets<AnimationClip>>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
events
|
|
|
|
stop.iter().for_each(|entity| {
|
|
|
|
.iter()
|
|
|
|
if let Ok(ui::TargetAsset { handle }) = clip_refs.get(entity) {
|
|
|
|
.filter(|(&interaction, _)| interaction == Interaction::Pressed)
|
|
|
|
let clip = clips.get(&handle).expect("Load animation clip");
|
|
|
|
.for_each(|(_, ui::TargetAsset { handle })| {
|
|
|
|
targets
|
|
|
|
let clip = clips.get(handle).expect("Load animation clip");
|
|
|
|
.iter_mut()
|
|
|
|
|
|
|
|
.filter(|(_, name)| clip.compatible_with(name))
|
|
|
|
|
|
|
|
.for_each(|(mut player, _)| {
|
|
|
|
|
|
|
|
player.pause();
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
start.iter().for_each(|entity| {
|
|
|
|
|
|
|
|
if let Ok(ui::TargetAsset { handle }) = clip_refs.get(entity) {
|
|
|
|
|
|
|
|
let clip = clips.get(&handle).expect("Load animation clip");
|
|
|
|
targets
|
|
|
|
targets
|
|
|
|
.iter_mut()
|
|
|
|
.iter_mut()
|
|
|
|
.filter(|(_, name)| clip.compatible_with(name))
|
|
|
|
.filter(|(_, name)| clip.compatible_with(name))
|
|
|
|
.for_each(|(mut player, _)| {
|
|
|
|
.for_each(|(mut player, _)| {
|
|
|
|
player.play(handle.clone()).repeat();
|
|
|
|
player.play(handle.clone()).repeat();
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -899,7 +977,6 @@ mod fonts {
|
|
|
|
#[derive(Debug, Component, Default)]
|
|
|
|
#[derive(Debug, Component, Default)]
|
|
|
|
pub struct FontWidget;
|
|
|
|
pub struct FontWidget;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Make each button have the font
|
|
|
|
|
|
|
|
pub fn fonts_ui(
|
|
|
|
pub fn fonts_ui(
|
|
|
|
mut events: EventReader<AssetEvent<Font>>,
|
|
|
|
mut events: EventReader<AssetEvent<Font>>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
|