mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
Pick default scenarios better, and describe some of the UK scenarios in the picker.
And the tiny Widget::evenly_spaced_row refactor from the previous PR
This commit is contained in:
parent
4a18c64701
commit
8c5f603c39
@ -2,6 +2,7 @@ use instant::Instant;
|
||||
use rand::Rng;
|
||||
use rand_xorshift::XorShiftRng;
|
||||
|
||||
use abstio::{CityName, MapName};
|
||||
use abstutil::Timer;
|
||||
use geom::{Duration, Line, Pt2D, Speed};
|
||||
use map_gui::tools::open_browser;
|
||||
@ -193,19 +194,11 @@ impl State<App> for MainMenu {
|
||||
return Tutorial::start(ctx, app);
|
||||
}
|
||||
"Sandbox mode" => {
|
||||
let scenario = if abstio::file_exists(abstio::path_scenario(
|
||||
app.primary.map.get_name(),
|
||||
"weekday",
|
||||
)) {
|
||||
"weekday"
|
||||
} else {
|
||||
"home_to_work"
|
||||
};
|
||||
return Transition::Push(SandboxMode::simple_new(
|
||||
app,
|
||||
GameplayMode::PlayScenario(
|
||||
app.primary.map.get_name().clone(),
|
||||
scenario.to_string(),
|
||||
default_scenario_for_map(app.primary.map.get_name()),
|
||||
Vec::new(),
|
||||
),
|
||||
));
|
||||
@ -377,6 +370,22 @@ impl Screensaver {
|
||||
}
|
||||
}
|
||||
|
||||
fn default_scenario_for_map(name: &MapName) -> String {
|
||||
if name.city == CityName::seattle()
|
||||
&& abstio::file_exists(abstio::path_scenario(name, "weekday"))
|
||||
{
|
||||
return "weekday".to_string();
|
||||
}
|
||||
if name.city.country == "gb" {
|
||||
for x in vec!["background", "base_with_bg"] {
|
||||
if abstio::file_exists(abstio::path_scenario(name, x)) {
|
||||
return x.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
"home_to_work".to_string()
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[allow(unused)]
|
||||
mod built_info {
|
||||
|
@ -193,20 +193,14 @@ fn launch(ctx: &mut EventCtx, app: &App, edits: PermanentMapEdits) -> Transition
|
||||
))
|
||||
} else {
|
||||
app.primary.layer = Some(Box::new(crate::layer::map::Static::edits(ctx, app)));
|
||||
|
||||
let mode = if abstio::file_exists(abstio::path_scenario(
|
||||
app.primary.map.get_name(),
|
||||
"weekday",
|
||||
)) {
|
||||
Transition::Replace(SandboxMode::simple_new(
|
||||
app,
|
||||
GameplayMode::PlayScenario(
|
||||
app.primary.map.get_name().clone(),
|
||||
"weekday".to_string(),
|
||||
crate::pregame::default_scenario_for_map(app.primary.map.get_name()),
|
||||
Vec::new(),
|
||||
)
|
||||
} else {
|
||||
GameplayMode::Freeform(app.primary.map.get_name().clone())
|
||||
};
|
||||
Transition::Replace(SandboxMode::simple_new(app, mode))
|
||||
),
|
||||
))
|
||||
}
|
||||
}),
|
||||
))
|
||||
|
@ -187,11 +187,18 @@ impl ChangeScenario {
|
||||
if name == "weekday" {
|
||||
choices.push((
|
||||
name,
|
||||
"realistic weekday traffic".to_string(),
|
||||
"typical weekday traffic".to_string(),
|
||||
"Trips will begin throughout the entire day. Midnight is usually quiet, so \
|
||||
you may need to fast-forward to morning rush hour. Data comes from Puget \
|
||||
Sound Regional Council's Soundcast model from 2014.",
|
||||
));
|
||||
} else if name == "background" || name == "base_with_bg" {
|
||||
choices.push((
|
||||
name,
|
||||
"typical weekday traffic".to_string(),
|
||||
"Home-to-work trips from 2011 UK census data are simulated. Traffic usually \
|
||||
starts around 7am.",
|
||||
));
|
||||
} else {
|
||||
choices.push((
|
||||
name.clone(),
|
||||
|
@ -414,17 +414,7 @@ impl Widget {
|
||||
|
||||
/// Creates a row with the specified widgets. Every member gets a default horizontal margin.
|
||||
pub fn row(widgets: Vec<Widget>) -> Widget {
|
||||
let mut new = Vec::new();
|
||||
let len = widgets.len();
|
||||
// TODO Time for that is_last iterator?
|
||||
for (idx, w) in widgets.into_iter().enumerate() {
|
||||
if idx == len - 1 {
|
||||
new.push(w);
|
||||
} else {
|
||||
new.push(w.margin_right(10));
|
||||
}
|
||||
}
|
||||
Widget::new(Box::new(Container::new(true, new)))
|
||||
Widget::evenly_spaced_row(widgets, 10)
|
||||
}
|
||||
|
||||
/// Creates a row with the specified widgets, with a `spacing` sized margin between members
|
||||
|
Loading…
Reference in New Issue
Block a user