diff --git a/game/src/info/building.rs b/game/src/info/building.rs index 60a92519ec..c3159fcefb 100644 --- a/game/src/info/building.rs +++ b/game/src/info/building.rs @@ -108,7 +108,12 @@ pub fn people(ctx: &mut EventCtx, app: &App, details: &mut Details, id: Building rows.push(Widget::col(vec![ Btn::text_bg1(p.to_string()).build_def(ctx, None), if let Some((t, mode)) = next_trip { - format!("Leaving in {} to {}", t - app.primary.sim.time(), mode).draw_text(ctx) + format!( + "Leaving in {} to {}", + t - app.primary.sim.time(), + mode.verb() + ) + .draw_text(ctx) } else { "Staying inside".draw_text(ctx) }, diff --git a/game/src/info/mod.rs b/game/src/info/mod.rs index 975830c186..c0e96555d7 100644 --- a/game/src/info/mod.rs +++ b/game/src/info/mod.rs @@ -460,7 +460,7 @@ fn throughput BTreeMap>> let mut series = get_data(app.primary.sim.get_analytics(), app.primary.sim.time()) .into_iter() .map(|(m, pts)| Series { - label: m.to_string(), + label: m.ongoing_verb().to_string(), color: color_for_mode(m, app), pts, }) @@ -469,7 +469,7 @@ fn throughput BTreeMap>> // TODO Ahh these colors don't show up differently at all. for (m, pts) in get_data(app.prebaked(), Time::END_OF_DAY) { series.push(Series { - label: format!("{} (baseline)", m), + label: format!("{} (baseline)", m.ongoing_verb()), color: color_for_mode(m, app).alpha(0.3), pts, }); diff --git a/game/src/info/person.rs b/game/src/info/person.rs index 72a312d764..a8af430e60 100644 --- a/game/src/info/person.rs +++ b/game/src/info/person.rs @@ -55,11 +55,13 @@ pub fn trips( } TripResult::TripDoesntExist => unreachable!(), }; + let (_, _, _, trip_mode) = sim.trip_info(*t); // TODO Style wrong. Button should be the entire row. rows.push( Widget::row(vec![ t.to_string().draw_text(ctx), + Line(trip_mode.ongoing_verb()).secondary().draw(ctx), if trip_status == "ongoing" { // TODO Padding doesn't work without wrapping in a row Widget::row(vec![Line(trip_status) diff --git a/game/src/info/trip.rs b/game/src/info/trip.rs index 5c89d677d9..91abf96212 100644 --- a/game/src/info/trip.rs +++ b/game/src/info/trip.rs @@ -9,13 +9,13 @@ use ezgui::{ }; use geom::{Angle, Distance, Duration, Polygon, Pt2D, Time}; use map_model::{Map, Path, PathStep}; -use sim::{TripEndpoint, TripID, TripPhase, TripPhaseType}; +use sim::{AgentID, TripEndpoint, TripID, TripPhase, TripPhaseType, VehicleType}; pub fn details(ctx: &mut EventCtx, app: &App, trip: TripID, details: &mut Details) -> Widget { let map = &app.primary.map; let sim = &app.primary.sim; let phases = sim.get_analytics().get_trip_phases(trip, map); - let (start_time, trip_start, trip_end, trip_mode) = sim.trip_info(trip); + let (start_time, trip_start, trip_end, _) = sim.trip_info(trip); let end_time = phases.last().as_ref().and_then(|p| p.end_time); if phases.is_empty() { @@ -27,7 +27,6 @@ pub fn details(ctx: &mut EventCtx, app: &App, trip: TripID, details: &mut Detail return Widget::col(make_table( ctx, vec![ - ("Type", trip_mode.to_string()), ("Departure", start_time.ampm_tostring()), ("From", name1), ("To", name2), @@ -39,14 +38,22 @@ pub fn details(ctx: &mut EventCtx, app: &App, trip: TripID, details: &mut Detail // Describe properties of the trip let total_trip_time = end_time.unwrap_or_else(|| sim.time()) - phases[0].start_time; - // TODO Depict differently - col.extend(make_table(ctx, vec![("Type", trip_mode.to_string())])); // Describe this leg of the trip let progress_along_path = if let Some(a) = sim.trip_to_agent(trip).ok() { let props = sim.agent_properties(a); - // TODO we want the current TripPhaseType.describe here - let activity = "here"; + // This is different than the entire TripMode, and also not the current TripPhaseType. + // Sigh. + let activity = match a { + AgentID::Pedestrian(_) => "walking", + AgentID::Car(c) => match c.1 { + VehicleType::Car => "driving", + VehicleType::Bike => "biking", + // TODO And probably riding a bus is broken, I don't know how that gets mapped right + // now + VehicleType::Bus => "riding the bus", + }, + }; // TODO Style needs work. Like, always. @@ -99,7 +106,10 @@ pub fn details(ctx: &mut EventCtx, app: &App, trip: TripID, details: &mut Detail Some(props.dist_crossed / props.total_dist) } else { // The trip is finished - // TODO total time + col.push(Widget::row(vec![ + Line("Trip time").secondary().draw(ctx).margin_right(20), + total_trip_time.to_string().draw_text(ctx), + ])); None }; diff --git a/game/src/sandbox/dashboards.rs b/game/src/sandbox/dashboards.rs index e2ff1e319b..ff7852812a 100644 --- a/game/src/sandbox/dashboards.rs +++ b/game/src/sandbox/dashboards.rs @@ -130,7 +130,11 @@ fn trips_summary_prebaked(ctx: &EventCtx, app: &App) -> Widget { let a = &now_per_mode[&mode]; let b = &baseline_per_mode[&mode]; txt.add_appended(vec![ - Line(format!("{} {} trips (", prettyprint_usize(a.count()), mode)), + Line(format!( + "{} trips {} (", + prettyprint_usize(a.count()), + mode.ongoing_verb() + )), cmp_count_more(a.count(), b.count()), Line(")"), ]); @@ -209,9 +213,9 @@ fn trips_summary_not_prebaked(ctx: &EventCtx, app: &App) -> Widget { for mode in TripMode::all() { let a = &per_mode[&mode]; txt.add(Line(format!( - "{} {} trips", + "{} trips {}", prettyprint_usize(a.count()), - mode + mode.ongoing_verb() ))); if a.count() > 0 { for stat in Statistic::all() { @@ -243,7 +247,13 @@ fn trips_summary_not_prebaked(ctx: &EventCtx, app: &App) -> Widget { fn finished_trips_plot(ctx: &EventCtx, app: &App) -> Widget { let mut lines: Vec<(String, Color, Option)> = TripMode::all() .into_iter() - .map(|m| (m.to_string(), color_for_mode(m, app), Some(m))) + .map(|m| { + ( + m.ongoing_verb().to_string(), + color_for_mode(m, app), + Some(m), + ) + }) .collect(); lines.push(("aborted".to_string(), Color::PURPLE.alpha(0.5), None)); diff --git a/game/src/sandbox/gameplay/create_gridlock.rs b/game/src/sandbox/gameplay/create_gridlock.rs index 2dba0dc1ee..49a46daf85 100644 --- a/game/src/sandbox/gameplay/create_gridlock.rs +++ b/game/src/sandbox/gameplay/create_gridlock.rs @@ -67,7 +67,11 @@ fn gridlock_panel(app: &App) -> Text { let a = now_per_mode[&mode].count(); let b = baseline_per_mode[&mode].count(); txt.add_appended(vec![ - Line(format!(" {}: {} (", mode, prettyprint_usize(a))), + Line(format!( + " {}: {} (", + mode.ongoing_verb(), + prettyprint_usize(a) + )), cmp_count_fewer(a, b), Line(")"), ]); diff --git a/game/src/sandbox/gameplay/faster_trips.rs b/game/src/sandbox/gameplay/faster_trips.rs index 56a8dcbbbd..a6da0d79f2 100644 --- a/game/src/sandbox/gameplay/faster_trips.rs +++ b/game/src/sandbox/gameplay/faster_trips.rs @@ -23,7 +23,7 @@ impl FasterTrips { top_center: challenge_controller( ctx, mode, - &format!("Faster {} Trips Challenge", trip_mode), + &format!("Faster Trips {} Challenge", trip_mode.ongoing_verb()), Vec::new(), ), }) @@ -87,9 +87,9 @@ fn faster_trips_panel(mode: TripMode, app: &App) -> Text { let mut txt = Text::new(); txt.add_appended(vec![ Line(format!( - "{} {} trips (", + "{} trips {} (", prettyprint_usize(now.count()), - mode + mode.ongoing_verb() )), cmp_count_more(now.count(), baseline.count()), Line(")"), diff --git a/sim/src/trips.rs b/sim/src/trips.rs index bf6e2d407c..0fa32ad8c2 100644 --- a/sim/src/trips.rs +++ b/sim/src/trips.rs @@ -794,15 +794,23 @@ impl TripMode { }, } } -} -impl std::fmt::Display for TripMode { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + pub fn verb(self) -> &'static str { match self { - TripMode::Walk => write!(f, "walk"), - TripMode::Bike => write!(f, "bike"), - TripMode::Transit => write!(f, "transit"), - TripMode::Drive => write!(f, "drive"), + TripMode::Walk => "walk", + TripMode::Bike => "bike", + TripMode::Transit => "use transit", + TripMode::Drive => "drive", + } + } + + // If I used "present participle" in a method name, I'd never live it down. + pub fn ongoing_verb(self) -> &'static str { + match self { + TripMode::Walk => "walking", + TripMode::Bike => "biking", + TripMode::Transit => "using transit", + TripMode::Drive => "driving", } } }