Skip to content

Commit

Permalink
fix: use bones::ExitGame to quit (#1035)
Browse files Browse the repository at this point in the history
Replace `std::process::exit(0)` with proper use of the
`bones::ExitBones` resource.
  • Loading branch information
nelson137 authored Oct 18, 2024
1 parent fee14ce commit 21eeba6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/ui/main_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ fn home_menu(
mut ui: In<&mut egui::Ui>,
meta: Root<GameMeta>,
localization: Localization<GameMeta>,
#[cfg(not(target_arch = "wasm32"))] exit_game: Option<ResMut<ExitBones>>,
) {
let ui = &mut *ui;
ui.vertical_centered(|ui| {
Expand Down Expand Up @@ -240,11 +241,9 @@ fn home_menu(
.show(ui)
.clicked()
{
// TODO: Gracefully exit game on quit.
// Right now we don't have a way for bones to trigger a Bevy graceful shutdown.
// We need to have a way for bones games to communicate that they want to exit,
// and then the Bones Bevy Renderer can gracefully shutdown.
std::process::exit(0);
if let Some(mut exit) = exit_game {
**exit = true;
}
}
});
});
Expand Down

0 comments on commit 21eeba6

Please sign in to comment.