generated from tipragot/rust
This commit is contained in:
parent
7ce491aee1
commit
118065339c
4179
Cargo.lock
generated
4179
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,3 +8,7 @@ authors = ["CoCoSol"]
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bevy = "0.12.1"
|
||||||
|
bevy_egui = "0.24.0"
|
||||||
|
|
BIN
crates/border-wars/assets/fonts/font.ttf
Normal file
BIN
crates/border-wars/assets/fonts/font.ttf
Normal file
Binary file not shown.
|
@ -1,5 +1,12 @@
|
||||||
//! A simple program that prints "Hello, world!" to the terminal.
|
//! The main entry point of the game.
|
||||||
|
|
||||||
|
use bevy::prelude::*;
|
||||||
|
mod menu;
|
||||||
|
use menu::MenuPlugin;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
App::new()
|
||||||
|
.add_plugins(DefaultPlugins)
|
||||||
|
.add_plugins(MenuPlugin)
|
||||||
|
.run();
|
||||||
}
|
}
|
||||||
|
|
53
crates/border-wars/src/menu.rs
Normal file
53
crates/border-wars/src/menu.rs
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
//! The main menu of the game.
|
||||||
|
|
||||||
|
use bevy::prelude::*;
|
||||||
|
use bevy_egui::{egui, EguiContexts, EguiPlugin};
|
||||||
|
|
||||||
|
#[derive(Default, Resource)]
|
||||||
|
struct Address {
|
||||||
|
host: bool,
|
||||||
|
ip: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MenuPlugin;
|
||||||
|
|
||||||
|
impl Plugin for MenuPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.add_plugins(EguiPlugin)
|
||||||
|
.init_resource::<Address>()
|
||||||
|
.add_systems(Update, ui_connect_button)
|
||||||
|
.add_systems(Update, ui_host_button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ui_connect_button(mut address: ResMut<Address>, mut egui_ctx: EguiContexts) {
|
||||||
|
// text edit
|
||||||
|
egui::Window::new("Connect")
|
||||||
|
.default_width(400.0)
|
||||||
|
.show(egui_ctx.ctx_mut(), |ui| {
|
||||||
|
ui.heading("Please enter the password of the game: ");
|
||||||
|
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.label("Address: ");
|
||||||
|
ui.text_edit_singleline(&mut address.ip);
|
||||||
|
let button = ui.button("Join");
|
||||||
|
if button.clicked() {
|
||||||
|
println!("clicked: {}", address.ip);
|
||||||
|
address.host = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ui_host_button(mut egui_ctx: EguiContexts, mut address: ResMut<Address>) {
|
||||||
|
// text edit
|
||||||
|
egui::Window::new("Host")
|
||||||
|
.default_width(400.0)
|
||||||
|
.show(egui_ctx.ctx_mut(), |ui| {
|
||||||
|
let button = ui.button("Create new game");
|
||||||
|
if button.clicked() {
|
||||||
|
println!("clicked");
|
||||||
|
address.host = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue