|
|
|
|
@ -4,9 +4,6 @@
|
|
|
|
|
//
|
|
|
|
|
// BUGS:
|
|
|
|
|
// * Camera order ambiguity
|
|
|
|
|
// * Multi-GLTF UX is bad.
|
|
|
|
|
// * Consider GLTF hierarchy (GLTF1 > Scene1a/Scene1b, GlTF2 > Scene2a/Scene2b, etc)
|
|
|
|
|
// * Easy despawn when de-selecting gltf
|
|
|
|
|
// * Load new GLTF -> Despawn all level entities
|
|
|
|
|
//
|
|
|
|
|
// TODO:
|
|
|
|
|
@ -32,12 +29,11 @@
|
|
|
|
|
// * Monologues (done)
|
|
|
|
|
|
|
|
|
|
use bevy::{
|
|
|
|
|
asset::{Asset, Assets},
|
|
|
|
|
asset::{AssetLoader, LoadContext, LoadedAsset},
|
|
|
|
|
asset::{Asset, AssetLoader, Assets, ChangeWatcher, LoadContext, LoadedAsset},
|
|
|
|
|
audio::PlaybackMode,
|
|
|
|
|
gltf::Gltf,
|
|
|
|
|
prelude::*,
|
|
|
|
|
utils::BoxedFuture,
|
|
|
|
|
utils::{BoxedFuture, Duration},
|
|
|
|
|
};
|
|
|
|
|
use monologue_trees::{debug::*, ui};
|
|
|
|
|
|
|
|
|
|
@ -57,13 +53,18 @@ const WELCOME_MESSAGES: &'static [&'static str] = &[
|
|
|
|
|
fn main() {
|
|
|
|
|
App::new()
|
|
|
|
|
.add_plugins((
|
|
|
|
|
DefaultPlugins.set(WindowPlugin {
|
|
|
|
|
DefaultPlugins
|
|
|
|
|
.set(WindowPlugin {
|
|
|
|
|
primary_window: Some(Window {
|
|
|
|
|
title: "Monologue Trees Editor".into(),
|
|
|
|
|
resolution: (640., 480.).into(),
|
|
|
|
|
..default()
|
|
|
|
|
}),
|
|
|
|
|
..default()
|
|
|
|
|
})
|
|
|
|
|
.set(AssetPlugin {
|
|
|
|
|
watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)),
|
|
|
|
|
..default()
|
|
|
|
|
}),
|
|
|
|
|
DebugInfoPlugin,
|
|
|
|
|
ui::GameUiPlugin,
|
|
|
|
|
@ -110,6 +111,14 @@ fn main() {
|
|
|
|
|
sync_monologue_font,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.add_systems(
|
|
|
|
|
Update,
|
|
|
|
|
(
|
|
|
|
|
point_light_force_shadows,
|
|
|
|
|
spot_light_force_shadows,
|
|
|
|
|
directional_light_force_shadows,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -233,16 +242,16 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
|
parent,
|
|
|
|
|
ui::Select::Single,
|
|
|
|
|
));
|
|
|
|
|
content_containers.push(spawn_tab_container::<AnimationWidget>(
|
|
|
|
|
"Animation",
|
|
|
|
|
parent,
|
|
|
|
|
ui::Select::Multi,
|
|
|
|
|
));
|
|
|
|
|
content_containers.push(spawn_tab_container::<CameraWidget>(
|
|
|
|
|
"Camera",
|
|
|
|
|
parent,
|
|
|
|
|
ui::Select::Single,
|
|
|
|
|
));
|
|
|
|
|
content_containers.push(spawn_tab_container::<AnimationWidget>(
|
|
|
|
|
"Animation",
|
|
|
|
|
parent,
|
|
|
|
|
ui::Select::Multi,
|
|
|
|
|
));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Container for tabs that open/close containers
|
|
|
|
|
@ -812,24 +821,28 @@ mod animations {
|
|
|
|
|
|
|
|
|
|
// When a scene is de-selected, remove any outdated animation options
|
|
|
|
|
pub fn remove_animations_ui(
|
|
|
|
|
mut events: RemovedComponents<Handle<Scene>>,
|
|
|
|
|
mut removed_players: RemovedComponents<Handle<Scene>>,
|
|
|
|
|
names: Query<&Name>,
|
|
|
|
|
current: Query<(Entity, &ui::TargetAsset<AnimationClip>)>,
|
|
|
|
|
clips: Res<Assets<AnimationClip>>,
|
|
|
|
|
targets: Query<(&AnimationPlayer, &Name)>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
) {
|
|
|
|
|
// For each removed scene
|
|
|
|
|
events.iter().for_each(|_| {
|
|
|
|
|
info!("Scene despawn!");
|
|
|
|
|
removed_players.iter().for_each(|_| {
|
|
|
|
|
// Iterate over the current animation buttons
|
|
|
|
|
current.iter().for_each(|(_, ui::TargetAsset { handle })| {
|
|
|
|
|
info!("Checking button for {:?}", handle);
|
|
|
|
|
// If the button points to a valid clip
|
|
|
|
|
if let Some(clip) = clips.get(handle) {
|
|
|
|
|
// Check if any active animation players are compatible with this clip
|
|
|
|
|
let compatible = targets.iter().any(|(_, name)| clip.compatible_with(name));
|
|
|
|
|
// If not, despawn the button
|
|
|
|
|
if !compatible {
|
|
|
|
|
current
|
|
|
|
|
.iter()
|
|
|
|
|
.filter(|(_, ui::TargetAsset { handle })| {
|
|
|
|
|
// Check if this clip is compatible with any remaining entities
|
|
|
|
|
// NOTE: We are checking this is *not* compatible with any entities
|
|
|
|
|
clips
|
|
|
|
|
.get(handle)
|
|
|
|
|
.map(|clip| !(targets.iter().any(|(_, name)| clip.compatible_with(name))))
|
|
|
|
|
.unwrap_or(true)
|
|
|
|
|
})
|
|
|
|
|
.for_each(|(_, ui::TargetAsset { handle })| {
|
|
|
|
|
// Destroy the buton if it is so
|
|
|
|
|
destroy_asset_button(
|
|
|
|
|
¤t,
|
|
|
|
|
&mut commands,
|
|
|
|
|
@ -837,8 +850,6 @@ mod animations {
|
|
|
|
|
handle: handle.clone(),
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@ -1238,3 +1249,28 @@ mod cameras {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
use lighting::*;
|
|
|
|
|
mod lighting {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
pub fn spot_light_force_shadows(mut spot_lights: Query<&mut SpotLight, Added<SpotLight>>) {
|
|
|
|
|
spot_lights.iter_mut().for_each(|mut light| {
|
|
|
|
|
light.shadows_enabled = true;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn directional_light_force_shadows(
|
|
|
|
|
mut directional_lights: Query<&mut DirectionalLight, Added<DirectionalLight>>,
|
|
|
|
|
) {
|
|
|
|
|
directional_lights.iter_mut().for_each(|mut light| {
|
|
|
|
|
light.shadows_enabled = true;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn point_light_force_shadows(mut point_lights: Query<&mut PointLight, Added<PointLight>>) {
|
|
|
|
|
point_lights.iter_mut().for_each(|mut light| {
|
|
|
|
|
light.shadows_enabled = true;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|