|
|
|
@ -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};
|
|
|
|
use crate::view::{button_set_state, ViewState};
|
|
|
|
|
|
|
|
|
|
|
|
@ -7,7 +10,7 @@ pub struct MenuPlugin;
|
|
|
|
|
|
|
|
|
|
|
|
impl Plugin for MenuPlugin {
|
|
|
|
impl Plugin for MenuPlugin {
|
|
|
|
fn build(&self, app: &mut App) {
|
|
|
|
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()));
|
|
|
|
parent.spawn(Text("Play".to_string()));
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.observe(button_set_state(ViewState::Play));
|
|
|
|
.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<Pointer<Click>>, mut exit_event: EventWriter<AppExit>) {
|
|
|
|
|
|
|
|
exit_event.send(AppExit::Success);
|
|
|
|
|
|
|
|
}
|
|
|
|
|