mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-09-11 10:55:27 +03:00
Transition::Pop and title screens considered harmful
Get rid of all of the places in app startup that push on the project-wide titlescreen onto the state stack. Instead make sure there's a way to get to that title screen without jsut popping off all states. Reasoning about the stack-of-states is very hard past a few special cases.
This commit is contained in:
parent
1f24af176c
commit
cff5bc5978
@ -30,15 +30,7 @@ fn run(mut settings: Settings) {
|
||||
.canvas_settings(options.canvas_settings.clone());
|
||||
widgetry::run(settings, |ctx| {
|
||||
map_gui::SimpleApp::new(ctx, options, args.map_name(), args.cam, (), |ctx, app| {
|
||||
vec![
|
||||
map_gui::tools::TitleScreen::new_state(
|
||||
ctx,
|
||||
app,
|
||||
map_gui::tools::Executable::FifteenMin,
|
||||
Box::new(|ctx, app, _| viewer::Viewer::random_start(ctx, app)),
|
||||
),
|
||||
viewer::Viewer::random_start(ctx, app),
|
||||
]
|
||||
vec![viewer::Viewer::random_start(ctx, app)]
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -130,7 +130,12 @@ impl State<App> for Viewer {
|
||||
return Transition::Push(crate::bus::BusExperiment::new_state(ctx, app));
|
||||
}
|
||||
"Home" => {
|
||||
return Transition::Pop;
|
||||
return Transition::Clear(vec![map_gui::tools::TitleScreen::new_state(
|
||||
ctx,
|
||||
app,
|
||||
map_gui::tools::Executable::FifteenMin,
|
||||
Box::new(|ctx, app, _| Self::random_start(ctx, app)),
|
||||
)]);
|
||||
}
|
||||
"change map" => {
|
||||
return Transition::Push(CityPicker::new_state(
|
||||
|
@ -186,12 +186,6 @@ fn setup_initial_states(
|
||||
app.per_map.consultation.unwrap(),
|
||||
));
|
||||
} else {
|
||||
states.push(map_gui::tools::TitleScreen::new_state(
|
||||
ctx,
|
||||
app,
|
||||
map_gui::tools::Executable::LTN,
|
||||
Box::new(|ctx, app, _| PickArea::new_state(ctx, app)),
|
||||
));
|
||||
states.push(PickArea::new_state(ctx, app));
|
||||
}
|
||||
if let Some(state) = popup_state {
|
||||
|
@ -20,15 +20,7 @@ pub fn run(mut settings: Settings) {
|
||||
.canvas_settings(opts.canvas_settings.clone());
|
||||
widgetry::run(settings, |ctx| {
|
||||
map_gui::SimpleApp::new(ctx, opts, args.map_name(), args.cam, (), |ctx, app| {
|
||||
vec![
|
||||
map_gui::tools::TitleScreen::new_state(
|
||||
ctx,
|
||||
app,
|
||||
map_gui::tools::Executable::OSMViewer,
|
||||
Box::new(|ctx, app, _| viewer::Viewer::new_state(ctx, app)),
|
||||
),
|
||||
viewer::Viewer::new_state(ctx, app),
|
||||
]
|
||||
vec![viewer::Viewer::new_state(ctx, app)]
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -262,7 +262,12 @@ impl State<App> for Viewer {
|
||||
match self.top_panel.event(ctx) {
|
||||
Outcome::Clicked(x) => match x.as_ref() {
|
||||
"Home" => {
|
||||
return Transition::Pop;
|
||||
return Transition::Clear(vec![map_gui::tools::TitleScreen::new_state(
|
||||
ctx,
|
||||
app,
|
||||
map_gui::tools::Executable::OSMViewer,
|
||||
Box::new(|ctx, app, _| Self::new_state(ctx, app)),
|
||||
)]);
|
||||
}
|
||||
"change map" => {
|
||||
return Transition::Push(CityPicker::new_state(
|
||||
|
@ -16,15 +16,7 @@ fn main() {
|
||||
.canvas_settings(options.canvas_settings.clone());
|
||||
widgetry::run(settings, |ctx| {
|
||||
map_gui::SimpleApp::new(ctx, options, args.map_name(), args.cam, (), |ctx, app| {
|
||||
vec![
|
||||
map_gui::tools::TitleScreen::new_state(
|
||||
ctx,
|
||||
app,
|
||||
map_gui::tools::Executable::ParkingMapper,
|
||||
Box::new(|ctx, app, _| mapper::ParkingMapper::new_state(ctx, app)),
|
||||
),
|
||||
mapper::ParkingMapper::new_state(ctx, app),
|
||||
]
|
||||
vec![mapper::ParkingMapper::new_state(ctx, app)]
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -329,7 +329,12 @@ impl State<App> for ParkingMapper {
|
||||
};
|
||||
}
|
||||
"Home" => {
|
||||
return Transition::Pop;
|
||||
return Transition::Clear(vec![map_gui::tools::TitleScreen::new_state(
|
||||
ctx,
|
||||
app,
|
||||
map_gui::tools::Executable::ParkingMapper,
|
||||
Box::new(|ctx, app, _| Self::new_state(ctx, app)),
|
||||
)]);
|
||||
}
|
||||
"change map" => {
|
||||
return Transition::Push(CityPicker::new_state(
|
||||
|
@ -54,15 +54,7 @@ fn run(mut settings: Settings) {
|
||||
music::Music::start(ctx, app.session.play_music, "jingle_bells");
|
||||
app.session.music.specify_volume(music::OUT_OF_GAME);
|
||||
|
||||
vec![
|
||||
map_gui::tools::TitleScreen::new_state(
|
||||
ctx,
|
||||
app,
|
||||
map_gui::tools::Executable::Santa,
|
||||
Box::new(|ctx, app, _| title::TitleScreen::new_state(ctx, app)),
|
||||
),
|
||||
title::TitleScreen::new_state(ctx, app),
|
||||
]
|
||||
vec![title::TitleScreen::new_state(ctx, app)]
|
||||
},
|
||||
)
|
||||
});
|
||||
|
@ -77,7 +77,12 @@ impl SimpleState<App> for TitleScreen {
|
||||
_: &mut Panel,
|
||||
) -> Transition {
|
||||
match x {
|
||||
"Home" => Transition::Pop,
|
||||
"Home" => Transition::Clear(vec![map_gui::tools::TitleScreen::new_state(
|
||||
ctx,
|
||||
app,
|
||||
map_gui::tools::Executable::Santa,
|
||||
Box::new(|ctx, app, _| Self::new_state(ctx, app)),
|
||||
)]),
|
||||
"Credits" => Transition::Push(Credits::new_state(ctx)),
|
||||
x => {
|
||||
for level in &app.session.levels {
|
||||
|
Loading…
Reference in New Issue
Block a user