|
|
|
@ -36,6 +36,7 @@ use bevy::{
|
|
|
|
asset::{AssetLoader, LoadContext, LoadedAsset},
|
|
|
|
asset::{AssetLoader, LoadContext, LoadedAsset},
|
|
|
|
audio::PlaybackMode,
|
|
|
|
audio::PlaybackMode,
|
|
|
|
gltf::Gltf,
|
|
|
|
gltf::Gltf,
|
|
|
|
|
|
|
|
input::{keyboard::KeyboardInput, ButtonState},
|
|
|
|
prelude::*,
|
|
|
|
prelude::*,
|
|
|
|
utils::BoxedFuture,
|
|
|
|
utils::BoxedFuture,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
@ -60,7 +61,7 @@ fn main() {
|
|
|
|
.init_asset_loader::<MonologueLoader>()
|
|
|
|
.init_asset_loader::<MonologueLoader>()
|
|
|
|
.add_event::<CustomAssetEvent<Scene>>()
|
|
|
|
.add_event::<CustomAssetEvent<Scene>>()
|
|
|
|
.add_event::<CustomAssetEvent<AnimationClip>>()
|
|
|
|
.add_event::<CustomAssetEvent<AnimationClip>>()
|
|
|
|
.add_systems(Startup, initialize_ui)
|
|
|
|
.add_systems(Startup, (initialize_ui, welcome_message))
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
(
|
|
|
|
(
|
|
|
|
@ -116,7 +117,7 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
|
|
|
|
|
|
|
|
let base_style = Style {
|
|
|
|
let base_style = Style {
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
padding: UiRect::all(Val::Px(1.0)),
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
@ -125,9 +126,12 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
.spawn(NodeBundle {
|
|
|
|
.spawn(NodeBundle {
|
|
|
|
style: Style {
|
|
|
|
style: Style {
|
|
|
|
|
|
|
|
top: Val::Px(0.0),
|
|
|
|
|
|
|
|
left: Val::Px(0.0),
|
|
|
|
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
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(1.0)),
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
padding: UiRect::all(Val::Px(1.0)),
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
@ -141,8 +145,8 @@ fn initialize_ui(mut 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(1.0)),
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
padding: UiRect::all(Val::Px(1.0)),
|
|
|
|
flex_direction: FlexDirection::Row,
|
|
|
|
flex_direction: FlexDirection::Row,
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
@ -161,8 +165,8 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
NodeBundle {
|
|
|
|
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(1.0)),
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
padding: UiRect::all(Val::Px(1.0)),
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
justify_content: JustifyContent::FlexStart,
|
|
|
|
justify_content: JustifyContent::FlexStart,
|
|
|
|
@ -178,37 +182,31 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
content_containers.push(spawn_tab_container::<FontWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<FontWidget>(
|
|
|
|
"Font",
|
|
|
|
"Font",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Single,
|
|
|
|
ui::Select::Single,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<AudioWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<AudioWidget>(
|
|
|
|
"Audio",
|
|
|
|
"Audio",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Multi,
|
|
|
|
ui::Select::Multi,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<GltfWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<GltfWidget>(
|
|
|
|
"Gltf",
|
|
|
|
"Gltf",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Single,
|
|
|
|
ui::Select::Single,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<SceneWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<SceneWidget>(
|
|
|
|
"Scene",
|
|
|
|
"Scene",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Single,
|
|
|
|
ui::Select::Single,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<AnimationWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<AnimationWidget>(
|
|
|
|
"Animation",
|
|
|
|
"Animation",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Multi,
|
|
|
|
ui::Select::Multi,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
content_containers.push(spawn_tab_container::<CameraWidget>(
|
|
|
|
content_containers.push(spawn_tab_container::<CameraWidget>(
|
|
|
|
"Camera",
|
|
|
|
"Camera",
|
|
|
|
parent,
|
|
|
|
parent,
|
|
|
|
&base_style,
|
|
|
|
|
|
|
|
ui::Select::Single,
|
|
|
|
ui::Select::Single,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -219,8 +217,8 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
NodeBundle {
|
|
|
|
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(1.0)),
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
padding: UiRect::all(Val::Px(1.0)),
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
@ -246,7 +244,6 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
b.clone(),
|
|
|
|
b.clone(),
|
|
|
|
ui::Title { text: name.clone() },
|
|
|
|
ui::Title { text: name.clone() },
|
|
|
|
ui::Collapse { target: *target },
|
|
|
|
ui::Collapse { target: *target },
|
|
|
|
ui::Active,
|
|
|
|
|
|
|
|
));
|
|
|
|
));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -256,10 +253,13 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
NodeBundle {
|
|
|
|
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(1.0)),
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
padding: UiRect::all(Val::Px(1.0)),
|
|
|
|
flex_direction: FlexDirection::Row,
|
|
|
|
flex_direction: FlexDirection::Row,
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
overflow: Overflow::clip(),
|
|
|
|
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
|
|
|
|
align_content: AlignContent::Center,
|
|
|
|
|
|
|
|
justify_content: JustifyContent::SpaceBetween,
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
background_color: Color::ALICE_BLUE.into(),
|
|
|
|
background_color: Color::ALICE_BLUE.into(),
|
|
|
|
@ -275,28 +275,47 @@ fn initialize_ui(mut commands: Commands) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn welcome_message(mut writer: EventWriter<ui::Alert>) {
|
|
|
|
|
|
|
|
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(),
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn spawn_tab_container<T: Default + Component>(
|
|
|
|
fn spawn_tab_container<T: Default + Component>(
|
|
|
|
title: &'static str,
|
|
|
|
title: &'static str,
|
|
|
|
parent: &mut ChildBuilder,
|
|
|
|
parent: &mut ChildBuilder,
|
|
|
|
base_style: &Style,
|
|
|
|
|
|
|
|
select: ui::Select,
|
|
|
|
select: ui::Select,
|
|
|
|
) -> (String, Entity) {
|
|
|
|
) -> (String, Entity) {
|
|
|
|
(
|
|
|
|
(
|
|
|
|
title.into(),
|
|
|
|
title.into(),
|
|
|
|
|
|
|
|
// Content node
|
|
|
|
parent
|
|
|
|
parent
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
NodeBundle {
|
|
|
|
NodeBundle {
|
|
|
|
style: Style {
|
|
|
|
style: Style {
|
|
|
|
display: Display::None,
|
|
|
|
display: Display::None,
|
|
|
|
top: Val::Px(0.0),
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
..base_style.clone()
|
|
|
|
margin: UiRect::all(Val::Px(1.0)),
|
|
|
|
|
|
|
|
padding: UiRect::all(Val::Px(1.0)),
|
|
|
|
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
background_color: Color::WHITE.into(),
|
|
|
|
background_color: Color::WHITE.into(),
|
|
|
|
border_color: Color::BLACK.into(),
|
|
|
|
border_color: Color::BLACK.into(),
|
|
|
|
z_index: ZIndex::Local(100),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ui::Title { text: title.into() },
|
|
|
|
|
|
|
|
T::default(),
|
|
|
|
T::default(),
|
|
|
|
ui::Scroll,
|
|
|
|
ui::Scroll,
|
|
|
|
Interaction::default(),
|
|
|
|
Interaction::default(),
|
|
|
|
@ -461,8 +480,8 @@ mod assets {
|
|
|
|
ButtonBundle {
|
|
|
|
ButtonBundle {
|
|
|
|
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(1.0)),
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
padding: UiRect::all(Val::Px(1.0)),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
border_color: Color::BLACK.into(),
|
|
|
|
border_color: Color::BLACK.into(),
|
|
|
|
@ -486,8 +505,8 @@ mod assets {
|
|
|
|
ButtonBundle {
|
|
|
|
ButtonBundle {
|
|
|
|
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(1.0)),
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
padding: UiRect::all(Val::Px(1.0)),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
border_color: Color::BLACK.into(),
|
|
|
|
border_color: Color::BLACK.into(),
|
|
|
|
|