/*
* This file is part of sdbclient
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* Licensed under GPL-3.0-only.
* See LICENSE for licensing information.
*/
use bevy::prelude::*;
use iyes_loopless::prelude::*;
use crate::remove_ui;
use super::MenuState;
mod browsegames;
mod creategame;
mod inlobbyguest;
mod inlobbyhost;
mod main;
pub(super) struct PlayMenuPlugin;
impl Plugin for PlayMenuPlugin {
fn build(&self, app: &mut App) {
app.add_loopless_state(PlayMenuState::None)
.add_enter_system(MenuState::Play, play_menu_setup)
// Systems for main play menu
.add_enter_system(PlayMenuState::Main, main::setup)
.add_exit_system(PlayMenuState::Main, remove_ui)
// Systems for create game menu
.add_enter_system(PlayMenuState::CreateGame, creategame::setup)
.add_exit_system(PlayMenuState::CreateGame, remove_ui)
// Systems for browse games menu
.add_enter_system(PlayMenuState::BrowseGames, browsegames::setup)
.add_exit_system(PlayMenuState::BrowseGames, remove_ui)
// Systems for in lobby host menu
.add_enter_system(PlayMenuState::InLobbyHost, inlobbyhost::setup)
.add_exit_system(PlayMenuState::InLobbyHost, remove_ui)
// Systems for in lobby guest menu
.add_enter_system(PlayMenuState::InLobbyGuest, inlobbyguest::setup)
.add_exit_system(PlayMenuState::InLobbyGuest, remove_ui);
}
}
/// Play Menu State
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub(super) enum PlayMenuState {
None,
Main,
CreateGame,
BrowseGames,
InLobbyHost,
InLobbyGuest,
}
fn play_menu_setup(mut commands: Commands) {
commands.insert_resource(NextState(PlayMenuState::Main))
}