mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-27 19:20:44 +01:00
feat: add settings window
This commit is contained in:
@@ -2,7 +2,7 @@ use checkers::ui::{
|
|||||||
macroquad::{
|
macroquad::{
|
||||||
difficulty_selection::draw_dificulty_selection, game::game::GameClient,
|
difficulty_selection::draw_dificulty_selection, game::game::GameClient,
|
||||||
main_menu::draw_main_menu, mode_selection::draw_mode_selection,
|
main_menu::draw_main_menu, mode_selection::draw_mode_selection,
|
||||||
server_selection::draw_server_selection,
|
server_selection::draw_server_selection, settings::draw_settings,
|
||||||
},
|
},
|
||||||
state::{GameContext, GuiState},
|
state::{GameContext, GuiState},
|
||||||
};
|
};
|
||||||
@@ -121,7 +121,7 @@ pub async fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GuiState::Settings => {
|
GuiState::Settings => {
|
||||||
todo!();
|
draw_settings(&mut state).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiState::Game(client) => {
|
GuiState::Game(client) => {
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ pub mod main_menu;
|
|||||||
mod menu_builder;
|
mod menu_builder;
|
||||||
pub mod mode_selection;
|
pub mod mode_selection;
|
||||||
pub mod server_selection;
|
pub mod server_selection;
|
||||||
|
pub mod settings;
|
||||||
|
|||||||
32
src/ui/macroquad/settings.rs
Normal file
32
src/ui/macroquad/settings.rs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
use macroquad::{
|
||||||
|
color::GRAY,
|
||||||
|
math::vec2,
|
||||||
|
shapes::draw_rectangle,
|
||||||
|
ui::{hash, root_ui, widgets::Group},
|
||||||
|
window::{screen_height, screen_width},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::ui::{macroquad::menu_builder::MenuBuilder, state::GuiState};
|
||||||
|
|
||||||
|
pub async fn draw_settings(state: &mut GuiState) {
|
||||||
|
let menu_size = vec2(screen_width() * 0.5, screen_height() * 0.5);
|
||||||
|
let menu_pos = vec2(
|
||||||
|
screen_width() / 2.0 - menu_size.x / 2.0,
|
||||||
|
screen_height() / 2.0 - menu_size.y / 2.0,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut menu_builder = MenuBuilder::new(menu_size.x, menu_size.y * 0.1);
|
||||||
|
draw_rectangle(menu_pos.x, menu_pos.y, menu_size.x, menu_size.y, GRAY);
|
||||||
|
|
||||||
|
Group::new(hash!(), menu_size)
|
||||||
|
.position(menu_pos)
|
||||||
|
.ui(&mut root_ui(), |ui| {
|
||||||
|
menu_builder.label(ui, "Game settings");
|
||||||
|
|
||||||
|
menu_builder.label(ui, "Server settings");
|
||||||
|
|
||||||
|
if menu_builder.button(ui, "Go back") {
|
||||||
|
*state = GuiState::MainMenu;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user