mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-27 19:20:44 +01:00
feat: first draft at window
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
|
use checkers::ui::{macroquad::main_menu::draw_main_menu, state::GuiState};
|
||||||
use macroquad::{
|
use macroquad::{
|
||||||
color::BLACK,
|
color::{BLUE, RED},
|
||||||
miniquad::{self, conf::LinuxBackend::WaylandWithX11Fallback},
|
miniquad::{self, conf::LinuxBackend::WaylandWithX11Fallback},
|
||||||
window::{Conf, clear_background, next_frame},
|
window::{Conf, clear_background, next_frame},
|
||||||
};
|
};
|
||||||
@@ -18,8 +19,28 @@ fn window_conf() -> Conf {
|
|||||||
|
|
||||||
#[macroquad::main(window_conf)]
|
#[macroquad::main(window_conf)]
|
||||||
pub async fn main() {
|
pub async fn main() {
|
||||||
|
env_logger::init();
|
||||||
|
|
||||||
|
let mut state = Default::default();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
clear_background(BLACK);
|
match state {
|
||||||
next_frame().await;
|
GuiState::MainMenu => {
|
||||||
|
draw_main_menu(&mut state).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiState::Settings => {
|
||||||
|
clear_background(RED);
|
||||||
|
next_frame().await;
|
||||||
|
}
|
||||||
|
GuiState::Game => {
|
||||||
|
clear_background(BLUE);
|
||||||
|
next_frame().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiState::Exit => {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,39 @@
|
|||||||
fn draw_main_menu() {}
|
use log::info;
|
||||||
|
use macroquad::{
|
||||||
|
color::{BLACK, WHITE},
|
||||||
|
input::is_mouse_button_pressed,
|
||||||
|
math::vec2,
|
||||||
|
ui::{StyleBuilder, hash, root_ui},
|
||||||
|
window::{clear_background, next_frame, screen_height, screen_width},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::ui::state::GuiState;
|
||||||
|
|
||||||
|
pub async fn draw_main_menu(state: &mut GuiState) {
|
||||||
|
let style = root_ui().style_builder().text_color(WHITE).font_size(64);
|
||||||
|
let text_style = root_ui().style_builder().text_color(WHITE).font_size(32);
|
||||||
|
|
||||||
|
let window_size = vec2(370.0, 320.0);
|
||||||
|
|
||||||
|
root_ui().window(
|
||||||
|
hash!(),
|
||||||
|
vec2(screen_width() / 2.0, screen_height() / 2.0),
|
||||||
|
window_size,
|
||||||
|
|ui| {
|
||||||
|
ui.label(vec2(80.0, -34.0), "Main Menu");
|
||||||
|
if ui.button(vec2(65.0, 25.0), "Play") {
|
||||||
|
*state = GuiState::Game;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ui.button(vec2(65.0, 25.0), "Settings") {
|
||||||
|
*state = GuiState::Settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ui.button(vec2(65.0, 125.0), "Quit") {
|
||||||
|
*state = GuiState::Exit;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
next_frame().await;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
#[derive(Default)]
|
||||||
pub enum GuiState {
|
pub enum GuiState {
|
||||||
|
#[default]
|
||||||
MainMenu,
|
MainMenu,
|
||||||
Settings,
|
Settings,
|
||||||
Game,
|
Game,
|
||||||
|
Exit,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user