From c40109788c93b91e2d49f28e74008ee5ee302dde Mon Sep 17 00:00:00 2001 From: Sergei Surovtsev <97428129+stillonearth@users.noreply.github.com> Date: Wed, 3 Jan 2024 20:34:01 +0300 Subject: [PATCH] main menu; --- src/loading.rs | 2 ++ src/menu.rs | 44 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/loading.rs b/src/loading.rs index c3227d2..10f2c39 100644 --- a/src/loading.rs +++ b/src/loading.rs @@ -57,6 +57,8 @@ pub struct AvatarAssets { pub struct CutsceneAssets { #[asset(path = "cutscenes/phone-call-1.png")] pub phone_call_1: Handle, + #[asset(path = "cutscenes/main-menu.png")] + pub main_menu: Handle, } #[derive(Resource)] diff --git a/src/menu.rs b/src/menu.rs index 8fbbce7..cecc6d2 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -1,7 +1,7 @@ use crate::loading::TextureAssets; +use crate::CutsceneAssets; use crate::GameState; use bevy::prelude::*; -// use rand::Rng; pub struct MenuPlugin; @@ -39,11 +39,50 @@ impl Default for ButtonColors { #[derive(Component)] struct Menu; -fn setup_menu(mut commands: Commands, textures: Res) { +fn setup_menu( + mut commands: Commands, + textures: Res, + cutscene_assets: Res, +) { info!("menu"); commands.spawn(Camera2dBundle::default()); + commands + .spawn(( + NodeBundle { + style: Style { + width: Val::Percent(100.0), + height: Val::Percent(100.0), + position_type: PositionType::Absolute, + justify_content: JustifyContent::Center, + align_items: AlignItems::Center, + ..default() + }, + // background_color: Color::BLACK.into(), + ..default() + }, + Menu, + Name::new("cutscene image container"), + )) + .with_children(|parent| { + // bevy logo (image) + // A `NodeBundle` is used to display the logo the image as an `ImageBundle` can't automatically + // size itself with a child node present. + parent.spawn(( + NodeBundle { + style: Style { + width: Val::Px(512.0), + height: Val::Px(512.0), + ..default() + }, + background_color: Color::WHITE.into(), + ..default() + }, + UiImage::new(cutscene_assets.main_menu.clone()), + )); + }); + commands .spawn(( NodeBundle { @@ -88,6 +127,7 @@ fn setup_menu(mut commands: Commands, textures: Res) { )); }); }); + commands .spawn(( NodeBundle {