Make menus more consistent for about/help screens

main
Elijah Voigt 1 year ago
parent 6c8a289ad6
commit 0e9b3e7db7

@ -1,7 +1,4 @@
use bevy::{ use bevy::{prelude::*, utils::HashMap};
prelude::*,
utils::{HashMap, RandomState},
};
/// Deck and Cards /// Deck and Cards
pub struct DeckPlugin; pub struct DeckPlugin;

@ -283,33 +283,58 @@ fn set_set_count(
query.single_mut().0 = format!("{}", set_number.get(trigger.entity()).unwrap().0); query.single_mut().0 = format!("{}", set_number.get(trigger.entity()).unwrap().0);
} }
fn setup_about(mut commands: Commands) { fn setup_about(mut commands: Commands, server: Res<AssetServer>) {
commands commands
.spawn(( .spawn((
ViewState::About, ViewState::About,
Node { Node {
position_type: PositionType::Absolute,
width: Val::Percent(100.0), width: Val::Percent(100.0),
height: Val::Percent(100.0), justify_content: JustifyContent::SpaceBetween,
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
flex_direction: FlexDirection::Column,
..default() ..default()
}, },
)) ))
.with_children(|parent| { .with_children(|parent| {
parent.spawn(Node::default()).with_children(|parent| {
parent parent
.spawn(button_builder(Node { .spawn((
position_type: PositionType::Absolute, Button,
top: Val::Px(0.0), BackgroundColor(BLACK.with_alpha(0.9).into()),
left: Val::Px(0.0), Node {
margin: UiRect::all(Val::Px(5.0)),
padding: UiRect::all(Val::Px(5.0)),
border: UiRect::all(Val::Px(1.0)),
height: Val::Px(40.0),
..default() ..default()
})) },
BorderColor(WHITE.into()),
GlobalZIndex(1),
))
.with_children(|parent| { .with_children(|parent| {
parent.spawn(Text("Menu".to_string())); parent.spawn(ImageNode {
image: server.load("kenney_game-icons/PNG/White/1x/home.png"),
..default()
});
}) })
.observe(button_hover_on)
.observe(button_hover_off)
.observe(button_set_state(ViewState::Menu)); .observe(button_set_state(ViewState::Menu));
});
});
commands
.spawn((
ViewState::About,
Node {
position_type: PositionType::Absolute,
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
flex_direction: FlexDirection::Column,
..default()
},
))
.with_children(|parent| {
parent parent
.spawn(( .spawn((
Node { Node {
@ -346,33 +371,57 @@ fn setup_about(mut commands: Commands) {
}); });
} }
fn setup_how_to_play(mut commands: Commands, deck: Res<Deck>) { fn setup_how_to_play(mut commands: Commands, deck: Res<Deck>, server: Res<AssetServer>) {
commands commands
.spawn(( .spawn((
ViewState::HowToPlay, ViewState::HowToPlay,
Node { Node {
position_type: PositionType::Absolute,
width: Val::Percent(100.0), width: Val::Percent(100.0),
height: Val::Percent(100.0), justify_content: JustifyContent::SpaceBetween,
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
flex_direction: FlexDirection::Column,
..default() ..default()
}, },
)) ))
.with_children(|parent| { .with_children(|parent| {
parent.spawn(Node::default()).with_children(|parent| {
parent parent
.spawn(button_builder(Node { .spawn((
position_type: PositionType::Absolute, Button,
top: Val::Px(0.0), BackgroundColor(BLACK.with_alpha(0.9).into()),
left: Val::Px(0.0), Node {
margin: UiRect::all(Val::Px(5.0)),
padding: UiRect::all(Val::Px(5.0)),
border: UiRect::all(Val::Px(1.0)),
height: Val::Px(40.0),
..default() ..default()
})) },
BorderColor(WHITE.into()),
GlobalZIndex(1),
))
.with_children(|parent| { .with_children(|parent| {
parent.spawn(Text("Menu".to_string())); parent.spawn(ImageNode {
image: server.load("kenney_game-icons/PNG/White/1x/home.png"),
..default()
});
}) })
.observe(button_hover_on)
.observe(button_hover_off)
.observe(button_set_state(ViewState::Menu)); .observe(button_set_state(ViewState::Menu));
});
});
commands
.spawn((
ViewState::HowToPlay,
Node {
position_type: PositionType::Absolute,
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
flex_direction: FlexDirection::Column,
..default()
},
))
.with_children(|parent| {
parent.spawn((Node { parent.spawn((Node {
width: Val::Px(500.0), width: Val::Px(500.0),
align_items: AlignItems::Center, align_items: AlignItems::Center,

@ -1,6 +1,5 @@
TODO: TODO:
* Make "set" button visually interesting when 3 cards selected * Make "set" button visually interesting when 3 cards selected
* Make menus consistent
Later: Later:
* Make button(s) look pretty * Make button(s) look pretty

Loading…
Cancel
Save