Hook up the action selectors to the buttons
All checks were successful
Basic checks / Basic build-and-test supertask (push) Successful in 7m8s
All checks were successful
Basic checks / Basic build-and-test supertask (push) Successful in 7m8s
This commit is contained in:
@@ -141,6 +141,7 @@ fn spawn_gameover_ui(mut commands: Commands) {
|
|||||||
children![
|
children![
|
||||||
(
|
(
|
||||||
Button,
|
Button,
|
||||||
|
GameOverMenuAction::ToMainMenu,
|
||||||
Node {
|
Node {
|
||||||
width: Val::Px(150.0),
|
width: Val::Px(150.0),
|
||||||
height: Val::Px(65.0),
|
height: Val::Px(65.0),
|
||||||
@@ -161,6 +162,7 @@ fn spawn_gameover_ui(mut commands: Commands) {
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
Button,
|
Button,
|
||||||
|
GameOverMenuAction::Quit,
|
||||||
Node {
|
Node {
|
||||||
width: Val::Px(150.0),
|
width: Val::Px(150.0),
|
||||||
height: Val::Px(65.0),
|
height: Val::Px(65.0),
|
||||||
@@ -216,17 +218,31 @@ fn animate_get_ready_widget(
|
|||||||
/// place to keep all system logic for this plugin.
|
/// place to keep all system logic for this plugin.
|
||||||
fn operate_gameover_ui(
|
fn operate_gameover_ui(
|
||||||
mut interactions: Query<
|
mut interactions: Query<
|
||||||
(&Interaction, &mut BackgroundColor, &mut BorderColor),
|
(
|
||||||
|
&Interaction,
|
||||||
|
&mut BackgroundColor,
|
||||||
|
&mut BorderColor,
|
||||||
|
&GameOverMenuAction,
|
||||||
|
),
|
||||||
(Changed<Interaction>, With<Button>),
|
(Changed<Interaction>, With<Button>),
|
||||||
>,
|
>,
|
||||||
|
mut game_state: ResMut<NextState<GameState>>,
|
||||||
|
mut app_exit_events: EventWriter<AppExit>,
|
||||||
) {
|
) {
|
||||||
// TODO: Better colors. These are taken from the example and they're ugly.
|
// TODO: Better colors. These are taken from the example and they're ugly.
|
||||||
// TODO: Read the menu action enum component and take that action.
|
for (interaction, mut color, mut border_color, menu_action) in &mut interactions {
|
||||||
for (interaction, mut color, mut border_color) in &mut interactions {
|
|
||||||
match *interaction {
|
match *interaction {
|
||||||
Interaction::Pressed => {
|
Interaction::Pressed => {
|
||||||
*color = UI_BUTTON_PRESSED.into();
|
*color = UI_BUTTON_PRESSED.into();
|
||||||
border_color.0 = RED.into();
|
border_color.0 = RED.into();
|
||||||
|
match menu_action {
|
||||||
|
GameOverMenuAction::ToMainMenu => {
|
||||||
|
game_state.set(GameState::TitleScreen);
|
||||||
|
}
|
||||||
|
GameOverMenuAction::Quit => {
|
||||||
|
app_exit_events.write(AppExit::Success);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Interaction::Hovered => {
|
Interaction::Hovered => {
|
||||||
*color = UI_BUTTON_HOVERED.into();
|
*color = UI_BUTTON_HOVERED.into();
|
||||||
|
|||||||
Reference in New Issue
Block a user