1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
use bevy::prelude::*;
use game_library::font_resource::FontResource;
use crate::{
main_menu::{
button_actions::{ButtonAction, MainMenuButton},
plugin::OnMainMenuScreen,
},
resources::style_prefab,
};
/// System to setup the main menu screen
///
/// When the main menu screen is entered, we spawn the main menu entities. This includes the
/// background, the title, and the buttons.
pub fn main_menu_setup(mut commands: Commands, fonts: Res<FontResource>) {
// Common style for all buttons on the screen
commands
.spawn((style_prefab::main_menu_full_node_bundle(), OnMainMenuScreen))
.with_children(|parent| {
// Game Title
parent.spawn(style_prefab::main_menu_title_bundle(
"Elementalist",
fonts.display_font.clone(),
));
// #### MENU BUTTONS #####
parent
.spawn(style_prefab::main_menu_column_node_bundle())
.with_children(|menu_buttons| {
// Start Game Button
menu_buttons
.spawn((
style_prefab::menu_button_bundle(),
ButtonAction::StartGame,
MainMenuButton,
))
.with_children(|button| {
button.spawn(style_prefab::menu_button_text(
"Start",
fonts.interface_font.clone(),
));
});
// Settings Button
menu_buttons
.spawn((
style_prefab::menu_button_bundle(),
ButtonAction::Settings,
MainMenuButton,
))
.with_children(|button| {
button.spawn(style_prefab::menu_button_text(
"Settings",
fonts.interface_font.clone(),
));
});
// Quit Button
menu_buttons
.spawn((
style_prefab::menu_button_bundle(),
ButtonAction::Quit,
MainMenuButton,
))
.with_children(|button| {
button.spawn(style_prefab::menu_button_text(
"Quit",
fonts.interface_font.clone(),
));
});
});
});
}