Saving my place, reworking menus

main
Elijah C. Voigt 2 years ago
parent 82b817a614
commit ca092ddbc0

@ -104,10 +104,12 @@ impl Plugin for Display3dPlugin {
.run_if(in_state(GameState::Play))
.run_if(in_state(DisplayState::Display3d)),
)
// Manage visible/hidden states
.add_systems(
Update,
manage_state_entities::<DisplayState>().run_if(state_changed::<DisplayState>()),
OnEnter(GameState::Intro),
(
// Toggle hidden/visible 3d entities
manage_state_entities::<DisplayState>(),
),
)
.add_systems(
OnEnter(GameState::Play),
@ -166,20 +168,32 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
..default()
},
Display3d,
DisplayState::Display3d,
))
.with_children(|parent| {
info!("Intializing 3D Board!");
parent
.spawn((Display3d, game::BoardComponent, SceneBundle { ..default() }))
.spawn((
Display3d,
DisplayState::Display3d,
game::BoardComponent,
SceneBundle { ..default() },
))
.with_children(|parent| {
// TEMP: Tiles
parent.spawn((Display3d, TilesComponent, SceneBundle { ..default() }));
parent.spawn((
Display3d,
DisplayState::Display3d,
TilesComponent,
SceneBundle { ..default() },
));
// Hitboxes
game::tiles().for_each(|(index, tile)| {
let side = Board::side(index).expect("Spawn valid side");
parent.spawn((
DisplayState::Display3d,
Display3d,
index,
tile,
@ -199,6 +213,7 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
let side = Board::side(index).expect("Spawn valid side");
parent.spawn((
DisplayState::Display3d,
Display3d,
index,
SceneBundle {
@ -217,6 +232,7 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
parent.spawn((
side,
DisplayState::Display3d,
Display3d,
piece.clone(),
index.clone(),
@ -251,8 +267,8 @@ fn hydrate_camera(
info!("Hydrating camera {:?}", entity);
// Populate the components for the camera
commands.entity(entity).insert((
Display3d,
DisplayState::Display3d,
Display3d,
Camera3dBundle {
camera: Camera {
is_active: true,

@ -18,11 +18,13 @@ struct Loading;
fn initialize(mut commands: Commands, server: Res<AssetServer>) {
commands.spawn((
Loading,
GameState::Loading,
Camera2dBundle { ..default() },
UiCameraConfig { show_ui: true },
));
commands.spawn((
Loading,
GameState::Loading,
ImageBundle {
image: UiImage {
texture: server.load("images/Liquid Mirror.jpg"),

@ -1,3 +1,5 @@
use bevy::ecs::system::EntityCommands;
use crate::prelude::*;
pub(crate) struct MenuPlugin;
@ -27,34 +29,43 @@ enum MenuState {
Endgame,
}
fn init_menu_ui(mut commands: Commands) {
fn init_play_menu(mut commands: Commands) {
info!("Initializing Play menu");
commands
.spawn((NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
flex_direction: FlexDirection::Column,
position_type: PositionType::Absolute,
.spawn((
MenuState::Play,
NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
flex_direction: FlexDirection::Column,
position_type: PositionType::Absolute,
..default()
},
background_color: Color::NONE.into(),
visibility: Visibility::Hidden,
..default()
},
background_color: Color::NONE.into(),
visibility: Visibility::Hidden,
..default()
},))
))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"M A R T I A N C H E S S",
TextStyle {
font_size: 48.0,
color: Color::ORANGE_RED,
..default()
},
parent.spawn((
MenuState::Play,
TextBundle::from_section(
"M A R T I A N C H E S S",
TextStyle {
font_size: 48.0,
color: Color::ORANGE_RED,
..default()
},
),
));
parent
.spawn((
GameState::Intro,
GameState::Play,
MenuState::None,
ButtonBundle {
style: Style {
padding: UiRect::all(Val::Px(5.0)),
@ -67,9 +78,10 @@ fn init_menu_ui(mut commands: Commands) {
))
.with_children(|parent| {
parent.spawn((
GameState::Intro,
GameState::Play,
MenuState::None,
TextBundle::from_section(
"Start",
"Continue",
TextStyle {
color: Color::BLACK,
font_size: 32.0,
@ -82,6 +94,7 @@ fn init_menu_ui(mut commands: Commands) {
parent
.spawn((
GameState::Credits,
MenuState::None,
ButtonBundle {
style: Style {
padding: UiRect::all(Val::Px(5.0)),
@ -95,6 +108,7 @@ fn init_menu_ui(mut commands: Commands) {
.with_children(|parent| {
parent.spawn((
GameState::Credits,
MenuState::None,
TextBundle::from_section(
"Credits",
TextStyle {
@ -126,17 +140,43 @@ fn init_menu_ui(mut commands: Commands) {
},
),));
});
});
}
fn init_play_menu(mut commands: Commands) {
todo!("Play Menu");
parent
.spawn((
tutorial::TutorialState::Intro, // Marks the button to start the tutorial
GameState::Play, // Marks the button to be ignored during tutorial step cleanup
MenuState::None,
ButtonBundle {
style: Style {
padding: UiRect::all(Val::Px(5.0)),
margin: UiRect::all(Val::Px(5.0)),
position_type: PositionType::Absolute,
top: Val::Px(0.0),
right: Val::Px(0.0),
..default()
},
background_color: Color::ORANGE.with_a(0.5).into(),
visibility: Visibility::Hidden,
..default()
},
))
.with_children(|parent| {
parent.spawn((TextBundle::from_section(
"Tutorial",
TextStyle {
color: Color::BLACK,
font_size: 16.0,
..default()
},
),));
});
});
}
fn init_tutorial_menu(mut commands: Commands) {
todo!("Tutorial Menu");
error!("Tutorial Menu");
}
fn init_endgame_menu(mut commands: Commands) {
todo!("Endgame Menu");
error!("Endgame Menu");
}

@ -82,38 +82,6 @@ fn initialize_tutorial(
info!("Initializing tutorial entities");
// Tutorial button used for toggling on/off during gameplay
{
commands
.spawn((
TutorialState::Intro, // Marks the button to start the tutorial
GameState::Play, // Marks the button to be ignored during tutorial step cleanup
ButtonBundle {
style: Style {
padding: UiRect::all(Val::Px(5.0)),
margin: UiRect::all(Val::Px(5.0)),
position_type: PositionType::Absolute,
top: Val::Px(0.0),
right: Val::Px(0.0),
..default()
},
background_color: Color::ORANGE.with_a(0.5).into(),
visibility: Visibility::Hidden,
..default()
},
))
.with_children(|parent| {
parent.spawn((TextBundle::from_section(
"Tutorial",
TextStyle {
color: Color::BLACK,
font_size: 16.0,
..default()
},
),));
});
}
let background_hex = tweak.get::<String>("tutorial_rgba_background").unwrap();
let text_visible_hex = tweak.get::<String>("tutorial_rgba_visible").unwrap();

Loading…
Cancel
Save