Skip to content

Commit

Permalink
fix-添加了等待页面中的关闭功能
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhgithub committed Sep 5, 2023
1 parent b4b4292 commit 7c10fa5
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/client/state_manager/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::time::Duration;
use bevy::{
app::AppExit,
prelude::{
in_state, Entity, EventWriter, IntoSystemConfigs, NextState, OnEnter, Plugin, Query, Res,
ResMut, Resource, States, Update, With,
in_state, not, Entity, EventReader, EventWriter, IntoSystemConfigs, NextState, OnEnter,
Plugin, Query, Res, ResMut, Resource, States, Update, With,
},
window::{PrimaryWindow, Window},
window::{PrimaryWindow, Window, WindowCloseRequested},
};
use bevy_egui::{egui, EguiContext, EguiContexts, EguiUserTextures};

Expand Down Expand Up @@ -47,6 +47,11 @@ impl Plugin for MenuPlugin {
Update,
menu_multiplayer.run_if(in_state(MenuState::Multiplayer)),
);

app.add_systems(
Update,
disconnect_on_close_without_connected.run_if(not(in_state(GameState::Game))),
);
}
}

Expand Down Expand Up @@ -192,3 +197,12 @@ fn test(
}
}
}

fn disconnect_on_close_without_connected(
mut exit: EventWriter<AppExit>,
mut closed: EventReader<WindowCloseRequested>,
) {
for _ in closed.iter() {
exit.send(AppExit);
}
}

0 comments on commit 7c10fa5

Please sign in to comment.