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