mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-27 11:10:48 +01:00
feat: add mode selection screen
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
use checkers::ui::{
|
||||
macroquad::main_menu::{draw_main_menu, get_main_menu_style},
|
||||
macroquad::{
|
||||
main_menu::{draw_main_menu, get_main_menu_style},
|
||||
mode_selection::draw_mode_selection,
|
||||
},
|
||||
state::GuiState,
|
||||
};
|
||||
use macroquad::{
|
||||
color::{BLUE, RED, WHITE},
|
||||
color::{BLACK, BLUE, RED, WHITE},
|
||||
math::vec2,
|
||||
miniquad::{self, conf::LinuxBackend::WaylandWithX11Fallback},
|
||||
texture::{DrawTextureParams, draw_texture_ex, load_texture},
|
||||
ui::root_ui,
|
||||
ui::{Skin, root_ui},
|
||||
window::{Conf, clear_background, next_frame, screen_height, screen_width},
|
||||
};
|
||||
|
||||
@@ -23,6 +26,26 @@ fn window_conf() -> Conf {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_general_style() -> Skin {
|
||||
let label_style = root_ui()
|
||||
.style_builder()
|
||||
.text_color(WHITE)
|
||||
.font_size(64)
|
||||
.build();
|
||||
|
||||
let button_style = root_ui()
|
||||
.style_builder()
|
||||
.text_color(BLACK)
|
||||
.font_size(32)
|
||||
.build();
|
||||
|
||||
Skin {
|
||||
label_style,
|
||||
button_style,
|
||||
..root_ui().default_skin()
|
||||
}
|
||||
}
|
||||
|
||||
#[macroquad::main(window_conf)]
|
||||
pub async fn main() {
|
||||
env_logger::init();
|
||||
@@ -30,7 +53,7 @@ pub async fn main() {
|
||||
let mut state = Default::default();
|
||||
let background = load_texture("assets/background.png").await.unwrap();
|
||||
|
||||
let main_menu_style = get_main_menu_style().await;
|
||||
let main_menu_style = get_general_style().await;
|
||||
root_ui().push_skin(&main_menu_style);
|
||||
|
||||
loop {
|
||||
@@ -50,13 +73,23 @@ pub async fn main() {
|
||||
draw_main_menu(&mut state).await;
|
||||
}
|
||||
|
||||
GuiState::ModeSelection => {
|
||||
draw_mode_selection(&mut state).await;
|
||||
}
|
||||
|
||||
GuiState::DificultySelection => {
|
||||
todo!();
|
||||
}
|
||||
|
||||
GuiState::ServerSelection => {
|
||||
todo!();
|
||||
}
|
||||
|
||||
GuiState::Settings => {
|
||||
clear_background(RED);
|
||||
next_frame().await;
|
||||
todo!();
|
||||
}
|
||||
GuiState::Game => {
|
||||
clear_background(BLUE);
|
||||
next_frame().await;
|
||||
todo!();
|
||||
}
|
||||
|
||||
GuiState::Exit => {
|
||||
|
||||
@@ -45,7 +45,7 @@ pub async fn draw_main_menu(state: &mut GuiState) {
|
||||
menu_builder.label(ui, "Main menu");
|
||||
|
||||
if menu_builder.button(ui, "Play") {
|
||||
*state = GuiState::Game;
|
||||
*state = GuiState::ModeSelection;
|
||||
}
|
||||
|
||||
if menu_builder.button(ui, "Settings") {
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
pub mod main_menu;
|
||||
pub mod mode_selection;
|
||||
mod menu_builder;
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
pub enum GuiState {
|
||||
#[default]
|
||||
MainMenu,
|
||||
|
||||
ModeSelection,
|
||||
DificultySelection,
|
||||
ServerSelection,
|
||||
|
||||
Settings,
|
||||
Game,
|
||||
Exit,
|
||||
|
||||
Reference in New Issue
Block a user