DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

e32bf353e291ee93e5ce3438cbaf7d6140906bf6 — Jonni Liljamo 1 year, 8 months ago 5ff7ff1
feat(client): swap cur_game to be in global, and set it
M client/src/main.rs => client/src/main.rs +4 -0
@@ 57,6 57,8 @@ pub struct Global {
    pub users_cache_queue: Vec<String>,
    pub games_cache: HashMap<String, GamePub>,
    pub games_cache_queue: Vec<String>,

    pub cur_game: Option<GamePub>,
}

#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]


@@ 113,6 115,8 @@ fn main() {
        users_cache_queue: vec![],
        games_cache: HashMap::new(),
        games_cache_queue: vec![],

        cur_game: None,
    })
    .insert_resource(cfg::CfgDirs(
        directories::ProjectDirs::from("com", "liljamo", "deckbuilder")

M client/src/plugins/menu/ui/play/mod.rs => client/src/plugins/menu/ui/play/mod.rs +0 -2
@@ 26,8 26,6 @@ pub struct PlayScreenData {
    pub waiting_for_my_games: bool,

    #[reflect(ignore)]
    pub cur_game: Option<GamePub>,
    #[reflect(ignore)]
    pub all_forming: Vec<GamePub>,
    #[reflect(ignore)]
    pub my_games: Vec<GamePub>,

M client/src/plugins/menu/ui/play/ui.rs => client/src/plugins/menu/ui/play/ui.rs +8 -8
@@ 30,7 30,7 @@ pub fn ui(
    mut egui_contexts: EguiContexts,
    mut data: ResMut<PlayScreenData>,
    cfg_user: Res<CfgUser>,
    global: Res<Global>,
    mut global: ResMut<Global>,
    mut creategame_ev_w: EventWriter<GameCreateEvent>,
    mut allforming_ev_w: EventWriter<GameAllFormingEvent>,
    mut mygames_ev_w: EventWriter<GameMyGamesEvent>,


@@ 107,10 107,10 @@ pub fn ui(
                ui.vertical_centered(|ui| {
                    egui::ScrollArea::vertical().show(ui, |ui| match data.browse_state {
                        PlayScreenBrowseState::Forming => {
                            browse_forming(ui, &mut data, &cfg_user, &global);
                            browse_forming(ui, &mut data, &cfg_user, &mut global);
                        }
                        PlayScreenBrowseState::InProgress => {
                            browse_inprogress(ui, &mut data, &global, &cfg_user);
                            browse_inprogress(ui, &mut data, &mut global, &cfg_user);
                        }
                        PlayScreenBrowseState::Finished => {
                            browse_finished(ui, &mut data, &global, &cfg_user);


@@ 159,7 159,7 @@ fn browse_forming(
    ui: &mut egui::Ui,
    data: &mut PlayScreenData,
    cfg_user: &CfgUser,
    global: &Global,
    global: &mut Global,
) {
    if data.waiting_for_all_forming {
        ui.horizontal(|ui| {


@@ 206,13 206,13 @@ fn browse_forming(
                            if game.guest_id.clone().unwrap_or_default() == cfg_user.id {
                                ui.add_enabled(false, egui::Button::new("Joined"));
                                if ui.button("Inspect").clicked() {
                                    data.cur_game = Some(game.clone());
                                    global.cur_game = Some(game.clone());
                                    data.state = PlayScreenState::InLobbyGuest;
                                }
                            } else if game.host_id == cfg_user.id {
                                ui.add_enabled(false, egui::Button::new("Host"));
                                if ui.button("Inspect").clicked() {
                                    data.cur_game = Some(game.clone());
                                    global.cur_game = Some(game.clone());
                                    data.state = PlayScreenState::InLobbyHost;
                                }
                            } else if ui.button("Join").clicked() {


@@ 229,7 229,7 @@ fn browse_forming(
fn browse_inprogress(
    ui: &mut egui::Ui,
    data: &mut PlayScreenData,
    global: &Global,
    global: &mut Global,
    cfg_user: &CfgUser,
) {
    if data.waiting_for_my_games {


@@ 279,7 279,7 @@ fn browse_inprogress(
                        ));
                        ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
                            if ui.button("Resume").clicked() {
                                data.cur_game = Some(game.clone());
                                global.cur_game = Some(game.clone());
                                //resumegame_ev_w.send(ResumeGameEvent);
                            }
                        });

M client/src/plugins/networking/systems/events/receive/mod.rs => client/src/plugins/networking/systems/events/receive/mod.rs +1 -1
@@ 97,7 97,7 @@ pub fn message_events(
                    //       and if the response data is an error)
                    let game =
                        serde_json::from_str(response.data.unwrap().get(0).unwrap()).unwrap();
                    play_data.cur_game = Some(game);
                    global.cur_game = Some(game);
                    play_data.state = PlayScreenState::InLobbyHost;
                }
                DataRequestType::GameAllForming => {