mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 10:44:56 +03:00
show better names for maps and scenarios
This commit is contained in:
parent
041b28ad2a
commit
09b0c47f3c
@ -26,7 +26,7 @@ impl abstutil::Cloneable for Challenge {}
|
||||
pub fn all_challenges() -> BTreeMap<String, Vec<Challenge>> {
|
||||
let mut tree = BTreeMap::new();
|
||||
tree.insert(
|
||||
"Fix all of the traffic signals".to_string(),
|
||||
"Fix traffic signals".to_string(),
|
||||
vec![
|
||||
Challenge {
|
||||
title: "Tutorial 1".to_string(),
|
||||
@ -62,33 +62,33 @@ pub fn all_challenges() -> BTreeMap<String, Vec<Challenge>> {
|
||||
],
|
||||
);
|
||||
tree.insert(
|
||||
"Speed up bus route 43".to_string(),
|
||||
"Speed up a bus route (WIP)".to_string(),
|
||||
vec![
|
||||
Challenge {
|
||||
title: "Just Montlake area".to_string(),
|
||||
title: "Route 43 in the small Montlake area".to_string(),
|
||||
description: vec![
|
||||
"Decrease the average waiting time between all of route 43's stops by at \
|
||||
least 30s"
|
||||
.to_string(),
|
||||
],
|
||||
map_path: abstutil::path_map("montlake"),
|
||||
alias: "bus43/montlake".to_string(),
|
||||
alias: "bus/43_montlake".to_string(),
|
||||
gameplay: GameplayMode::OptimizeBus("43".to_string()),
|
||||
},
|
||||
Challenge {
|
||||
title: "Larger area of the 43".to_string(),
|
||||
title: "Route 43 in a larger area".to_string(),
|
||||
description: vec![
|
||||
"Decrease the average waiting time between all of 43's stops by at least 30s"
|
||||
.to_string(),
|
||||
],
|
||||
map_path: abstutil::path_map("23rd"),
|
||||
alias: "bus43/23rd".to_string(),
|
||||
alias: "bus/43_23rd".to_string(),
|
||||
gameplay: GameplayMode::OptimizeBus("43".to_string()),
|
||||
},
|
||||
],
|
||||
);
|
||||
tree.insert(
|
||||
"Gridlock all of the everything".to_string(),
|
||||
"Cause gridlock (WIP)".to_string(),
|
||||
vec![Challenge {
|
||||
title: "Gridlock all of the everything".to_string(),
|
||||
description: vec!["Make traffic as BAD as possible!".to_string()],
|
||||
@ -98,7 +98,7 @@ pub fn all_challenges() -> BTreeMap<String, Vec<Challenge>> {
|
||||
}],
|
||||
);
|
||||
tree.insert(
|
||||
"Playing favorites".to_string(),
|
||||
"Playing favorites (WIP)".to_string(),
|
||||
vec![
|
||||
Challenge {
|
||||
title: "Speed up all bike trips".to_string(),
|
||||
|
@ -224,3 +224,16 @@ pub fn plain_list_names(names: BTreeSet<String>) -> String {
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
// TODO Associate this with maps, but somehow avoid reading the entire file when listing them.
|
||||
pub fn nice_map_name(name: &str) -> &str {
|
||||
match name {
|
||||
"23rd" => "23rd Ave E corridor",
|
||||
"ballard" => "Ballard",
|
||||
"caphill" => "Capitol Hill",
|
||||
"downtown" => "Downtown Seattle",
|
||||
"huge_seattle" => "Seattle (entire area)",
|
||||
"montlake" => "Montlake and Eastlake",
|
||||
_ => name,
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
use crate::edit::EditMode;
|
||||
use crate::game::{State, Transition, WizardState};
|
||||
use crate::helpers::ID;
|
||||
use crate::helpers::{nice_map_name, ID};
|
||||
use crate::managed::WrappedComposite;
|
||||
use crate::sandbox::gameplay::{change_scenario, spawner, GameplayMode, GameplayState};
|
||||
use crate::sandbox::SandboxMode;
|
||||
use crate::ui::UI;
|
||||
use ezgui::{
|
||||
hotkey, lctrl, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
||||
ManagedWidget, Text, VerticalAlignment,
|
||||
hotkey, lctrl, Choice, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key,
|
||||
Line, ManagedWidget, Text, VerticalAlignment,
|
||||
};
|
||||
use geom::Polygon;
|
||||
use map_model::IntersectionID;
|
||||
@ -80,7 +80,7 @@ pub fn freeform_controller(
|
||||
WrappedComposite::nice_text_button(
|
||||
ctx,
|
||||
Text::from(
|
||||
Line(format!("{} ▼", ui.primary.map.get_name()))
|
||||
Line(format!("{} ▼", nice_map_name(ui.primary.map.get_name())))
|
||||
.size(18)
|
||||
.roboto(),
|
||||
),
|
||||
@ -137,11 +137,12 @@ pub fn freeform_controller(
|
||||
|
||||
fn make_load_map(gameplay: GameplayMode) -> Box<dyn State> {
|
||||
WizardState::new(Box::new(move |wiz, ctx, ui| {
|
||||
if let Some(name) = wiz.wrap(ctx).choose_string("Load which map?", || {
|
||||
if let Some((_, name)) = wiz.wrap(ctx).choose("Load which map?", || {
|
||||
let current_map = ui.primary.map.get_name();
|
||||
abstutil::list_all_objects(abstutil::path_all_maps())
|
||||
.into_iter()
|
||||
.filter(|n| n != current_map)
|
||||
.map(|n| Choice::new(nice_map_name(&n), n.clone()))
|
||||
.collect()
|
||||
}) {
|
||||
ui.switch_map(ctx, abstutil::path_map(&name));
|
||||
|
@ -16,7 +16,7 @@ use crate::sandbox::SandboxMode;
|
||||
use crate::ui::UI;
|
||||
use abstutil::{prettyprint_usize, Timer};
|
||||
use ezgui::{
|
||||
lctrl, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
||||
lctrl, Choice, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
||||
ManagedWidget, ModalMenu, Text, TextSpan, VerticalAlignment, Wizard,
|
||||
};
|
||||
use geom::{Duration, Polygon};
|
||||
@ -207,16 +207,29 @@ impl GameplayRunner {
|
||||
}
|
||||
|
||||
fn change_scenario(wiz: &mut Wizard, ctx: &mut EventCtx, ui: &mut UI) -> Option<Transition> {
|
||||
let scenario_name = wiz
|
||||
.wrap(ctx)
|
||||
.choose_string("Instantiate which scenario?", || {
|
||||
let mut list =
|
||||
abstutil::list_all_objects(abstutil::path_all_scenarios(ui.primary.map.get_name()));
|
||||
list.push("random".to_string());
|
||||
list.push("just buses".to_string());
|
||||
list.push("empty".to_string());
|
||||
list
|
||||
})?;
|
||||
let (_, scenario_name) = wiz.wrap(ctx).choose("Run what type of traffic?", || {
|
||||
let mut list = Vec::new();
|
||||
for name in
|
||||
abstutil::list_all_objects(abstutil::path_all_scenarios(ui.primary.map.get_name()))
|
||||
{
|
||||
let nice_name = if name == "weekday" {
|
||||
"realistic weekday traffic".to_string()
|
||||
} else {
|
||||
name.clone()
|
||||
};
|
||||
list.push(Choice::new(nice_name, name));
|
||||
}
|
||||
list.push(Choice::new(
|
||||
"random unrealistic trips",
|
||||
"random".to_string(),
|
||||
));
|
||||
list.push(Choice::new("just buses", "just buses".to_string()));
|
||||
list.push(Choice::new(
|
||||
"none (you manually spawn traffic)",
|
||||
"empty".to_string(),
|
||||
));
|
||||
list
|
||||
})?;
|
||||
ui.primary.clear_sim();
|
||||
Some(Transition::PopThenReplace(Box::new(SandboxMode::new(
|
||||
ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user