generated from tipragot/rust
WIP - Beggining of the menu ui, setup nodes
Some checks failed
Rust Checks / checks (push) Failing after 18s
Some checks failed
Rust Checks / checks (push) Failing after 18s
This commit is contained in:
parent
ba14642981
commit
6abd0f0c87
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -442,6 +442,7 @@ version = "0.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e4bc7e09282a82a48d70ade0c4c1154b0fd7882a735a39c66766a5d0f4718ea9"
|
checksum = "e4bc7e09282a82a48d70ade0c4c1154b0fd7882a735a39c66766a5d0f4718ea9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bevy_dylib",
|
||||||
"bevy_internal",
|
"bevy_internal",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -617,6 +618,15 @@ dependencies = [
|
||||||
"sysinfo",
|
"sysinfo",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bevy_dylib"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "45b99001eb4837c78d9c63cc8b32fda61ea96b194a2cda54b569aeee69a9853c"
|
||||||
|
dependencies = [
|
||||||
|
"bevy_internal",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_ecs"
|
name = "bevy_ecs"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
|
|
|
@ -10,3 +10,11 @@ missing_docs_in_private_items = "warn"
|
||||||
unwrap_in_result = "warn"
|
unwrap_in_result = "warn"
|
||||||
unwrap_used = "warn"
|
unwrap_used = "warn"
|
||||||
nursery = "warn"
|
nursery = "warn"
|
||||||
|
|
||||||
|
# Enable a small amount of optimization in debug mode
|
||||||
|
[profile.dev]
|
||||||
|
opt-level = 1
|
||||||
|
|
||||||
|
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
opt-level = 3
|
||||||
|
|
|
@ -11,5 +11,5 @@ authors = ["CoCoSol"]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.12.1"
|
bevy = { version = "0.12.1", features = ["dynamic_linking"] }
|
||||||
bevy_egui = "0.24.0"
|
bevy_egui = "0.24.0"
|
|
@ -1,7 +1,6 @@
|
||||||
//! The main menu of the game.
|
//! The main menu of the game.
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_egui::{egui, EguiContexts};
|
|
||||||
|
|
||||||
use crate::CurrentScene;
|
use crate::CurrentScene;
|
||||||
|
|
||||||
|
@ -10,36 +9,103 @@ 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(Update, menu_ui.run_if(in_state(CurrentScene::Menu)));
|
app.add_systems(Startup, menu_ui.run_if(in_state(CurrentScene::Menu)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Display the UI of the menu to host a game or join one.
|
/// Display the UI of the menu to host a game or join one.
|
||||||
fn menu_ui(
|
fn menu_ui(mut commands: Commands) {
|
||||||
mut ctx: EguiContexts,
|
commands.spawn(Camera2dBundle::default());
|
||||||
mut connection_string: Local<String>,
|
// Green
|
||||||
mut next_scene: ResMut<NextState<CurrentScene>>,
|
commands
|
||||||
) {
|
.spawn(NodeBundle {
|
||||||
egui::CentralPanel::default().show(ctx.ctx_mut(), |ui| {
|
style: Style {
|
||||||
ui.heading("Border Wars");
|
margin: UiRect {
|
||||||
|
left: (Val::Auto),
|
||||||
|
right: (Val::Auto),
|
||||||
|
top: (Val::Px(0.)),
|
||||||
|
bottom: (Val::Px(0.)),
|
||||||
|
},
|
||||||
|
width: Val::Percent(55.),
|
||||||
|
height: Val::Percent(100.),
|
||||||
|
flex_direction: FlexDirection::Column,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
})
|
||||||
|
// Text
|
||||||
|
.with_children(|parent| {
|
||||||
|
parent.spawn(
|
||||||
|
NodeBundle{
|
||||||
|
style: Style {
|
||||||
|
margin: UiRect {
|
||||||
|
left: (Val::Auto),
|
||||||
|
right: (Val::Auto),
|
||||||
|
top: (Val::Percent(5.)),
|
||||||
|
bottom: (Val::Percent(15.)),
|
||||||
|
},
|
||||||
|
width: Val::Percent(90.),
|
||||||
|
height: Val::Percent(25.),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
background_color: BackgroundColor(Color::RED),
|
||||||
|
..default()
|
||||||
|
}
|
||||||
|
|
||||||
ui.separator();
|
);
|
||||||
|
})
|
||||||
ui.label("Connect to an existing game:");
|
// BLUE
|
||||||
ui.horizontal(|ui| {
|
.with_children(|parent| {
|
||||||
ui.label("Game ID: ");
|
parent
|
||||||
ui.text_edit_singleline(&mut *connection_string);
|
.spawn(NodeBundle {
|
||||||
|
style: Style {
|
||||||
if ui.button("Join").clicked() {
|
flex_direction: FlexDirection::Column,
|
||||||
next_scene.set(CurrentScene::Game);
|
margin: UiRect {
|
||||||
// TODO: connect to the game
|
left: (Val::Auto),
|
||||||
}
|
right: (Val::Auto),
|
||||||
|
top: (Val::Auto),
|
||||||
|
bottom: (Val::Percent(5.)),
|
||||||
|
},
|
||||||
|
width: Val::Percent(85.),
|
||||||
|
height: Val::Percent(70.),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
})
|
||||||
|
// YELLOW_GREEN 1
|
||||||
|
.with_children(|parent| {
|
||||||
|
parent.spawn(NodeBundle {
|
||||||
|
style: Style {
|
||||||
|
width: Val::Percent(100.),
|
||||||
|
height: Val::Percent(45.),
|
||||||
|
margin: UiRect {
|
||||||
|
left: (Val::Auto),
|
||||||
|
right: (Val::Auto),
|
||||||
|
top: (Val::Auto),
|
||||||
|
bottom: (Val::Auto),
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
background_color: BackgroundColor(Color::YELLOW_GREEN),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
})
|
||||||
|
// YELLOW_GREEN 2
|
||||||
|
.with_children(|parent| {
|
||||||
|
parent.spawn(NodeBundle {
|
||||||
|
style: Style {
|
||||||
|
width: Val::Percent(100.),
|
||||||
|
height: Val::Percent(45.),
|
||||||
|
margin: UiRect {
|
||||||
|
left: (Val::Auto),
|
||||||
|
right: (Val::Auto),
|
||||||
|
top: (Val::Auto),
|
||||||
|
bottom: (Val::Auto),
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
background_color: BackgroundColor(Color::YELLOW_GREEN),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.separator();
|
|
||||||
|
|
||||||
if ui.button("Create new game").clicked() {
|
|
||||||
next_scene.set(CurrentScene::Lobby);
|
|
||||||
// TODO: create a new game
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue