|
|
|
@ -35,7 +35,6 @@ use bevy::{
|
|
|
|
asset::{Asset, Assets},
|
|
|
|
asset::{Asset, Assets},
|
|
|
|
asset::{AssetLoader, LoadContext, LoadedAsset},
|
|
|
|
asset::{AssetLoader, LoadContext, LoadedAsset},
|
|
|
|
audio::PlaybackMode,
|
|
|
|
audio::PlaybackMode,
|
|
|
|
ecs::system::EntityCommands,
|
|
|
|
|
|
|
|
gltf::Gltf,
|
|
|
|
gltf::Gltf,
|
|
|
|
prelude::*,
|
|
|
|
prelude::*,
|
|
|
|
utils::BoxedFuture,
|
|
|
|
utils::BoxedFuture,
|
|
|
|
@ -101,18 +100,12 @@ pub struct TabRoot;
|
|
|
|
#[derive(Debug, Component)]
|
|
|
|
#[derive(Debug, Component)]
|
|
|
|
pub struct LevelRoot;
|
|
|
|
pub struct LevelRoot;
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Component)]
|
|
|
|
|
|
|
|
pub enum Minimize {
|
|
|
|
|
|
|
|
Open,
|
|
|
|
|
|
|
|
Closed,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Component)]
|
|
|
|
#[derive(Debug, Component)]
|
|
|
|
pub struct EditorCamera;
|
|
|
|
pub struct EditorCamera;
|
|
|
|
|
|
|
|
|
|
|
|
fn initialize_ui(mut commands: Commands) {
|
|
|
|
fn initialize_ui(mut commands: Commands) {
|
|
|
|
// Empty entity for populating the level being edited
|
|
|
|
// Empty entity for populating the level being edited
|
|
|
|
commands.spawn(LevelRoot);
|
|
|
|
commands.spawn((TransformBundle { ..default() }, LevelRoot));
|
|
|
|
|
|
|
|
|
|
|
|
commands.spawn((
|
|
|
|
commands.spawn((
|
|
|
|
Camera3dBundle { ..default() },
|
|
|
|
Camera3dBundle { ..default() },
|
|
|
|
@ -130,7 +123,7 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
.spawn(NodeBundle {
|
|
|
|
.spawn((NodeBundle {
|
|
|
|
style: Style {
|
|
|
|
style: Style {
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
margin: UiRect::all(Val::Px(5.0)),
|
|
|
|
margin: UiRect::all(Val::Px(5.0)),
|
|
|
|
@ -142,7 +135,7 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
background_color: Color::WHITE.into(),
|
|
|
|
background_color: Color::WHITE.into(),
|
|
|
|
border_color: Color::BLACK.into(),
|
|
|
|
border_color: Color::BLACK.into(),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
})
|
|
|
|
},))
|
|
|
|
.with_children(|parent| {
|
|
|
|
.with_children(|parent| {
|
|
|
|
// HACK: This is super janky but I think we need it like this for UI layout rules
|
|
|
|
// HACK: This is super janky but I think we need it like this for UI layout rules
|
|
|
|
let mut content_containers: Vec<(String, Entity)> = Vec::new();
|
|
|
|
let mut content_containers: Vec<(String, Entity)> = Vec::new();
|
|
|
|
@ -171,31 +164,37 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
"Font",
|
|
|
|
"Font",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Single,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<AudioWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<AudioWidget>(
|
|
|
|
"Audio",
|
|
|
|
"Audio",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Multi,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<GltfWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<GltfWidget>(
|
|
|
|
"Gltf",
|
|
|
|
"Gltf",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Single,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<SceneWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<SceneWidget>(
|
|
|
|
"Scene",
|
|
|
|
"Scene",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Single,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<AnimationWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<AnimationWidget>(
|
|
|
|
"Animation",
|
|
|
|
"Animation",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Multi,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<CameraWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<CameraWidget>(
|
|
|
|
"Camera",
|
|
|
|
"Camera",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Single,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -216,6 +215,7 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ui::Sorting(1),
|
|
|
|
ui::Sorting(1),
|
|
|
|
|
|
|
|
ui::Select::Single,
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.with_children(|parent| {
|
|
|
|
.with_children(|parent| {
|
|
|
|
let b = ButtonBundle {
|
|
|
|
let b = ButtonBundle {
|
|
|
|
@ -244,6 +244,7 @@ fn spawn_tab_container<T: Default + Component>(
|
|
|
|
title: &'static str,
|
|
|
|
title: &'static str,
|
|
|
|
parent: &mut ChildBuilder,
|
|
|
|
parent: &mut ChildBuilder,
|
|
|
|
base_style: &Style,
|
|
|
|
base_style: &Style,
|
|
|
|
|
|
|
|
select: ui::Select,
|
|
|
|
) -> (String, Entity) {
|
|
|
|
) -> (String, Entity) {
|
|
|
|
(
|
|
|
|
(
|
|
|
|
title.into(),
|
|
|
|
title.into(),
|
|
|
|
@ -267,6 +268,7 @@ fn spawn_tab_container<T: Default + Component>(
|
|
|
|
T::default(),
|
|
|
|
T::default(),
|
|
|
|
ui::Scroll,
|
|
|
|
ui::Scroll,
|
|
|
|
Interaction::default(),
|
|
|
|
Interaction::default(),
|
|
|
|
|
|
|
|
select,
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.id(),
|
|
|
|
.id(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@ -567,28 +569,19 @@ mod gltf {
|
|
|
|
|
|
|
|
|
|
|
|
pub fn manage_active_gltf(
|
|
|
|
pub fn manage_active_gltf(
|
|
|
|
events: Query<
|
|
|
|
events: Query<
|
|
|
|
(Entity, &Parent, &Interaction, Option<&ui::Active>),
|
|
|
|
(Entity, &Interaction, Option<&ui::Active>),
|
|
|
|
(With<Button>, Changed<Interaction>),
|
|
|
|
(With<Button>, Changed<Interaction>),
|
|
|
|
>,
|
|
|
|
>,
|
|
|
|
children: Query<&Children, With<ui::Active>>,
|
|
|
|
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
events
|
|
|
|
events
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.filter(|(_, _, &interaction, _)| interaction == Interaction::Pressed)
|
|
|
|
.filter(|(_, &interaction, _)| interaction == Interaction::Pressed)
|
|
|
|
.for_each(|(entity, parent, _, active_ish)| match active_ish {
|
|
|
|
.for_each(|(entity, _, active_ish)| match active_ish {
|
|
|
|
Some(_) => {
|
|
|
|
Some(_) => {
|
|
|
|
commands.entity(entity).remove::<ui::Active>();
|
|
|
|
commands.entity(entity).remove::<ui::Active>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None => {
|
|
|
|
None => {
|
|
|
|
if let Ok(childs) = children.get(parent.get()) {
|
|
|
|
|
|
|
|
childs
|
|
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
|
|
.filter(|&child| *child != entity)
|
|
|
|
|
|
|
|
.for_each(|&child| {
|
|
|
|
|
|
|
|
commands.entity(child).remove::<ui::Active>();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
commands.entity(entity).insert(ui::Active);
|
|
|
|
commands.entity(entity).insert(ui::Active);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -934,12 +927,12 @@ mod monologues {
|
|
|
|
// TODO: Load .txt files for monologues
|
|
|
|
// TODO: Load .txt files for monologues
|
|
|
|
pub fn texts_ui(
|
|
|
|
pub fn texts_ui(
|
|
|
|
mut events: EventReader<AssetEvent<Monologue>>,
|
|
|
|
mut events: EventReader<AssetEvent<Monologue>>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut _commands: Commands,
|
|
|
|
widget: Query<Entity, With<MonologueWidget>>,
|
|
|
|
_widget: Query<Entity, With<MonologueWidget>>,
|
|
|
|
current: Query<(Entity, &ui::TargetAsset<Monologue>)>,
|
|
|
|
_current: Query<(Entity, &ui::TargetAsset<Monologue>)>,
|
|
|
|
server: Res<AssetServer>,
|
|
|
|
_server: Res<AssetServer>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
events.iter().for_each(|event| {
|
|
|
|
events.iter().for_each(|_event| {
|
|
|
|
info!("Loading monologue");
|
|
|
|
info!("Loading monologue");
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|