/*
* This file is part of laurelin_client
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* Licensed under GPL-3.0-only.
* See LICENSE for licensing information.
*/
use bevy::prelude::*;
use crate::AppState;
mod ui;
pub struct MenuPlugin;
impl Plugin for MenuPlugin {
fn build(&self, app: &mut App) {
app.add_state::<MenuState>()
.insert_resource(MenuData::default())
.add_system(menu_setup.in_schedule(OnEnter(AppState::Menu)))
.add_system(ui::ui.run_if(not(in_state(MenuState::None))));
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, States)]
enum MenuState {
#[default]
None,
Visible,
}
#[derive(Resource)]
pub struct MenuData {
pub ui_state: MenuUIState,
error: String,
login_email: String,
login_password: String,
register_username: String,
register_email: String,
register_password: String,
register_password_confirm: String,
}
impl Default for MenuData {
fn default() -> Self {
Self {
ui_state: MenuUIState::Login,
error: String::from(""),
login_email: String::from(""),
login_password: String::from(""),
register_username: String::from(""),
register_email: String::from(""),
register_password: String::from(""),
register_password_confirm: String::from(""),
}
}
}
#[derive(Debug)]
pub enum MenuUIState {
Loading, // for waiting for requests to finish
Login,
Register,
Main,
Browse,
}
fn menu_setup(mut commands: Commands) {
commands.insert_resource(NextState(Some(MenuState::Visible)));
}