mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-25 11:44:25 +03:00
use a loading screen when exiting a/b test mode, since it's so laggy
This commit is contained in:
parent
36b3558db5
commit
66b21c81ec
@ -189,12 +189,15 @@ impl State for ABTestMode {
|
||||
self.speed.pause();
|
||||
}
|
||||
|
||||
fn on_destroy(&mut self, ui: &mut UI) {
|
||||
// TODO Should we clear edits too?
|
||||
ui.primary.reset_sim();
|
||||
fn on_destroy(&mut self, ctx: &mut EventCtx, ui: &mut UI) {
|
||||
ctx.loading_screen("exit A/B test mode", |_, timer| {
|
||||
timer.start("destroy secondary sim");
|
||||
// TODO Should we clear edits too?
|
||||
ui.primary.reset_sim();
|
||||
|
||||
// Note destroying this has some noticeable delay.
|
||||
ui.secondary = None;
|
||||
ui.secondary = None;
|
||||
timer.stop("destroy secondary sim");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ impl State for EditMode {
|
||||
self.menu.draw(g);
|
||||
}
|
||||
|
||||
fn on_destroy(&mut self, ui: &mut UI) {
|
||||
fn on_destroy(&mut self, _: &mut EventCtx, ui: &mut UI) {
|
||||
// TODO Warn about unsaved edits
|
||||
// TODO Maybe put a loading screen around these.
|
||||
ui.primary
|
||||
|
@ -70,7 +70,7 @@ impl GUI for Game {
|
||||
match transition {
|
||||
Transition::KeepWithMode(evmode) => evmode,
|
||||
Transition::PopWithMode(evmode) => {
|
||||
self.states.pop().unwrap().on_destroy(&mut self.ui);
|
||||
self.states.pop().unwrap().on_destroy(ctx, &mut self.ui);
|
||||
if self.states.is_empty() {
|
||||
self.before_quit(ctx.canvas);
|
||||
std::process::exit(0);
|
||||
@ -81,7 +81,7 @@ impl GUI for Game {
|
||||
evmode
|
||||
}
|
||||
Transition::PopWithData(cb) => {
|
||||
self.states.pop().unwrap().on_destroy(&mut self.ui);
|
||||
self.states.pop().unwrap().on_destroy(ctx, &mut self.ui);
|
||||
cb(self.states.last_mut().unwrap());
|
||||
if self.idx_draw_base == Some(self.states.len()) {
|
||||
self.idx_draw_base = None;
|
||||
@ -101,7 +101,7 @@ impl GUI for Game {
|
||||
evmode
|
||||
}
|
||||
Transition::ReplaceWithMode(state, evmode) => {
|
||||
self.states.pop().unwrap().on_destroy(&mut self.ui);
|
||||
self.states.pop().unwrap().on_destroy(ctx, &mut self.ui);
|
||||
if self.idx_draw_base == Some(self.states.len()) {
|
||||
self.idx_draw_base = None;
|
||||
}
|
||||
@ -182,7 +182,7 @@ pub trait State: downcast_rs::Downcast {
|
||||
// Before we push a new state on top of this one, call this.
|
||||
fn on_suspend(&mut self, _: &mut UI) {}
|
||||
// Before this state is popped or replaced, call this.
|
||||
fn on_destroy(&mut self, _: &mut UI) {}
|
||||
fn on_destroy(&mut self, _: &mut EventCtx, _: &mut UI) {}
|
||||
// We don't need an on_enter -- the constructor for the state can just do it.
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ impl State for TutorialMode {
|
||||
self.menu.draw(g);
|
||||
}
|
||||
|
||||
fn on_destroy(&mut self, ui: &mut UI) {
|
||||
fn on_destroy(&mut self, _: &mut EventCtx, ui: &mut UI) {
|
||||
ui.primary.reset_sim();
|
||||
}
|
||||
}
|
||||
@ -86,7 +86,7 @@ impl State for Part2 {
|
||||
self.menu.draw(g);
|
||||
}
|
||||
|
||||
fn on_destroy(&mut self, ui: &mut UI) {
|
||||
fn on_destroy(&mut self, _: &mut EventCtx, ui: &mut UI) {
|
||||
ui.primary.reset_sim();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user