// Monologue Trees Editor // // Editor for creating Monologue Trees levels use bevy::{ input::{keyboard::KeyboardInput, ButtonState}, prelude::*, }; use monologue_trees::{debug::*, ui::*}; fn main() { App::new() .add_plugins(( DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "Monologue Trees Editor".into(), resolution: (640., 480.).into(), ..default() }), ..default() }), DebugInfoPlugin, GameUiPlugin, )) .add_systems(Startup, (initialize_ui,)) .add_systems( Update, ( load_gltf, unload_gltf, load_audio, unload_audio, spawn_scene, play_audio, export_level, import_level, load_bogus, ), ) .run(); } /// UI: /// * GLTFs /// * Scenes /// * Cameras /// * Animations /// * Audios fn initialize_ui(mut commands: Commands) { commands.spawn(( Camera2dBundle { ..default() }, UiCameraConfig { show_ui: true }, )); commands .spawn(NodeBundle { style: Style { width: Val::Percent(100.0), height: Val::Percent(100.0), ..default() }, ..default() }) .with_children(|parent| { parent.spawn((GameUiList("GLTFs"), NodeBundle { ..default() }, GltfsUi)); parent.spawn((GameUiList("Scenes"), NodeBundle { ..default() }, ScenesUi)); parent.spawn((GameUiList("Cameras"), NodeBundle { ..default() }, CamerasUi)); parent.spawn(( GameUiList("Animations"), NodeBundle { ..default() }, AnimationsUi, )); parent.spawn(( GameUiSet("Audio Clips"), NodeBundle { ..default() }, AudioClipsUi, )); }); } fn load_bogus( mut events: EventReader, root: Query>, mut commands: Commands, ) { events .iter() .filter( |&KeyboardInput { key_code, state, .. }| *key_code == Some(KeyCode::Space) && *state == ButtonState::Pressed, ) .for_each(|_| { commands .spawn((GameUiButton("bogus"), NodeBundle { ..default() })) .set_parent(root.single()); }) } /// Component marking UI for loaded Gltf assets #[derive(Component)] struct GltfsUi; /// Component marking UI for Scene assets #[derive(Component)] struct ScenesUi; /// Component marking UI for Camera assets #[derive(Component)] struct CamerasUi; /// Component marking UI for Animation assets #[derive(Component)] struct AnimationsUi; /// Drag+Drop import GLTF to editor fn load_gltf() {} /// Remove gltf from editor fn unload_gltf() {} /// Component marking UI for Audio Clip assets #[derive(Component)] struct AudioClipsUi; /// Drag+Drop import Audio to editor fn load_audio() {} /// Remove audio from editor fn unload_audio() {} /// Spawn Scene fn spawn_scene() {} /// Play/Loop Audio fn play_audio() {} /// Export level fn export_level() {} /// Import Level fn import_level() {}