mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 17:37:22 +03:00
Start in the daytime when starting on an empty map. (#486)
This commit is contained in:
parent
ba5ea18101
commit
71bd7a37fc
@ -5,7 +5,7 @@ extern crate log;
|
||||
|
||||
use abstio::MapName;
|
||||
use abstutil::{CmdArgs, Timer};
|
||||
use geom::{LonLat, Pt2D};
|
||||
use geom::{Duration, LonLat, Pt2D};
|
||||
use map_gui::options::Options;
|
||||
use map_model::Map;
|
||||
use sim::{Sim, SimFlags};
|
||||
@ -119,10 +119,11 @@ fn setup_app(
|
||||
&& !flags.sim_flags.load.contains("player/save")
|
||||
&& !flags.sim_flags.load.contains("/scenarios/")
|
||||
&& maybe_mode.is_none();
|
||||
// If we're starting directly in sandbox mode, usually time is midnight, so save some effort
|
||||
// and start with the correct color scheme. If we're loading a savestate and it's actually
|
||||
// daytime, we'll pay a small penalty to switch colors.
|
||||
if !title {
|
||||
// If we're starting directly in a challenge mode, the tutorial, or by playing a scenario,
|
||||
// usually time is midnight, so save some effort and start with the correct color scheme. If
|
||||
// we're loading a savestate and it's actually daytime, we'll pay a small penalty to switch
|
||||
// colors.
|
||||
if maybe_mode.is_some() {
|
||||
opts.color_scheme = map_gui::colors::ColorSchemeChoice::NightMode;
|
||||
}
|
||||
let cs = map_gui::colors::ColorScheme::new(ctx, opts.color_scheme);
|
||||
@ -254,10 +255,27 @@ fn finish_app_setup(
|
||||
|
||||
let states: Vec<Box<dyn State<App>>> = if title {
|
||||
vec![Box::new(TitleScreen::new(ctx, app))]
|
||||
} else {
|
||||
let mode = maybe_mode
|
||||
.unwrap_or_else(|| GameplayMode::Freeform(app.primary.map.get_name().clone()));
|
||||
} else if let Some(mode) = maybe_mode {
|
||||
vec![SandboxMode::simple_new(ctx, app, mode)]
|
||||
} else {
|
||||
// We got here by just passing --dev and a map as flags; we're just looking at an empty
|
||||
// map. Start in the daytime.
|
||||
vec![SandboxMode::async_new(
|
||||
ctx,
|
||||
app,
|
||||
GameplayMode::Freeform(app.primary.map.get_name().clone()),
|
||||
Box::new(|ctx, app| {
|
||||
ctx.loading_screen("start in the daytime", |_, mut timer| {
|
||||
app.primary.sim.timed_step(
|
||||
&app.primary.map,
|
||||
Duration::hours(6),
|
||||
&mut None,
|
||||
&mut timer,
|
||||
);
|
||||
});
|
||||
vec![Transition::Keep]
|
||||
}),
|
||||
)]
|
||||
};
|
||||
if let Some(ss) = savestate {
|
||||
// TODO This is weird, we're left in Freeform mode with the wrong UI. Can't instantiate
|
||||
|
Loading…
Reference in New Issue
Block a user