DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

ref: 65f015815047c636164087a5169ef351dbbb54e6 deck-builder/sdbclient/src/plugins/menu/play/mod.rs -rw-r--r-- 1.8 KiB
65f01581Jonni Liljamo fix(sdbclient): change play menu setup visibilities 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * 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))
}