Retain tab when changing maps

This commit is contained in:
Dustin Carlino 2021-08-26 10:17:08 -07:00
parent 5b7523b2c4
commit deb4a202d9
3 changed files with 12 additions and 10 deletions

View File

@ -416,7 +416,8 @@ fn finish_app_setup(
vec![SandboxMode::simple_new(app, mode)]
}
} else if setup.ungap {
vec![ungap::ExploreMap::launch(ctx, app)]
let layers = ungap::Layers::new(ctx, app);
vec![ungap::ExploreMap::new_state(ctx, app, layers)]
} else {
// Not attempting to keep the primary and secondary simulations synchronized at the same
// time yet. Just handle this one startup case, so we can switch maps without constantly

View File

@ -26,11 +26,6 @@ impl TakeLayers for ExploreMap {
}
impl ExploreMap {
pub fn launch(ctx: &mut EventCtx, app: &mut App) -> Box<dyn State<App>> {
let layers = Layers::new(ctx, app);
ExploreMap::new_state(ctx, app, layers)
}
pub fn new_state(ctx: &mut EventCtx, app: &mut App, layers: Layers) -> Box<dyn State<App>> {
app.opts.show_building_driveways = false;

View File

@ -84,12 +84,18 @@ impl Tab {
Transition::Push(CityPicker::new_state(
ctx,
app,
Box::new(|ctx, app| {
Box::new(move |ctx, app| {
// Since we're totally changing maps, don't reuse the Layers
let layers = Layers::new(ctx, app);
Transition::Multi(vec![
Transition::Pop,
// Since we're totally changing maps, don't reuse the Layers
// TODO Keep current tab...
Transition::Replace(ExploreMap::launch(ctx, app)),
Transition::Replace(match self {
Tab::Explore => ExploreMap::new_state(ctx, app, layers),
Tab::Create => {
quick_sketch::QuickSketch::new_state(ctx, app, layers)
}
Tab::Route => route::RoutePlanner::new_state(ctx, app, layers),
}),
])
}),
))