diff --git a/src/menu.rs b/src/menu.rs index 188d2cc..2fa7739 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -1,4 +1,7 @@ -use bevy::{color::palettes::css::TEAL, prelude::*}; +use bevy::{ + color::palettes::css::{BLACK, ORANGE, PURPLE, RED, TEAL}, + prelude::*, +}; use crate::view::{button_set_state, ViewState}; @@ -7,7 +10,7 @@ pub struct MenuPlugin; impl Plugin for MenuPlugin { fn build(&self, app: &mut App) { - app.add_systems(Startup, setup); + app.add_systems(Startup, (setup, setup_about, setup_how_to_play)); } } @@ -21,5 +24,72 @@ fn setup(mut commands: Commands) { parent.spawn(Text("Play".to_string())); }) .observe(button_set_state(ViewState::Play)); + parent + .spawn((Button, BackgroundColor(ORANGE.into()))) + .with_children(|parent| { + parent.spawn(Text("About".to_string())); + }) + .observe(button_set_state(ViewState::About)); + parent + .spawn((Button, BackgroundColor(PURPLE.into()))) + .with_children(|parent| { + parent.spawn(Text("How to Play".to_string())); + }) + .observe(button_set_state(ViewState::HowToPlay)); + parent + .spawn((Button, BackgroundColor(RED.into()))) + .with_children(|parent| { + parent.spawn(Text("Quit".to_string())); + }) + .observe(quit_button); + }); + + commands + .spawn((ViewState::Play, Node::default())) + .with_children(|parent| { + parent + .spawn((Button, BackgroundColor(TEAL.into()), GlobalZIndex(1))) + .with_children(|parent| { + parent.spawn(Text("Menu".to_string())); + }) + .observe(button_set_state(ViewState::Menu)); + }); +} + +fn setup_about(mut commands: Commands) { + commands + .spawn((ViewState::About, Node::default())) + .with_children(|parent| { + parent + .spawn((Button, BackgroundColor(TEAL.into()))) + .with_children(|parent| { + parent.spawn(Text("Menu".to_string())); + }) + .observe(button_set_state(ViewState::Menu)); + parent.spawn(( + Text("This is the about page".to_string()), + BackgroundColor(BLACK.into()), + )); + }); +} + +fn setup_how_to_play(mut commands: Commands) { + commands + .spawn((ViewState::HowToPlay, Node::default())) + .with_children(|parent| { + parent + .spawn((Button, BackgroundColor(TEAL.into()))) + .with_children(|parent| { + parent.spawn(Text("Menu".to_string())); + }) + .observe(button_set_state(ViewState::Menu)); + parent.spawn(( + Text("This is the how to play page".to_string()), + BackgroundColor(BLACK.into()), + )); }); } + +fn quit_button(_trigger: Trigger>, mut exit_event: EventWriter) { + exit_event.send(AppExit::Success); +} diff --git a/src/setup.rs b/src/setup.rs index 2ba4e81..45f1d81 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -86,7 +86,7 @@ pub(crate) fn setup_set_check_button(mut commands: Commands) { }, Visibility::default(), ViewState::Play, - BackgroundColor(Color::BLACK.with_alpha(0.8).into()), + BackgroundColor(Color::BLACK.into()), )) .with_children(|parent| { parent