woops, fix a tutorial crash from the refactor. and tweak a few info

panels [rebuild]
This commit is contained in:
Dustin Carlino 2020-03-28 23:05:24 -07:00
parent da67fb0da1
commit 403232e48e
5 changed files with 41 additions and 42 deletions

View File

@ -57,7 +57,8 @@ impl<T: 'static + Ord + PartialEq + Copy + core::fmt::Debug + Yvalue<T>> Plot<T>
Circle::new(Pt2D::new(radius, radius), Distance::meters(radius))
.to_polygon(),
)]),
),
)
.margin(5),
s.label.clone().draw_text(ctx),
])
})

View File

@ -79,7 +79,9 @@ pub fn people(ctx: &mut EventCtx, app: &App, details: &mut Details, id: Building
let mut rows = header(ctx, app, details, id, Tab::BldgPeople(id));
// TODO Sort/group better
// Show minimal info: ID, next departure time, type of that trip
let mut any = false;
for p in app.primary.sim.bldg_to_people(id) {
any = true;
let person = app.primary.sim.get_person(p);
let mut next_trip: Option<(Time, TripMode)> = None;
@ -112,6 +114,9 @@ pub fn people(ctx: &mut EventCtx, app: &App, details: &mut Details, id: Building
},
]));
}
if !any {
rows.push("Nobody's inside right now".draw_text(ctx));
}
rows
}

View File

@ -2,7 +2,7 @@ use crate::app::App;
use crate::helpers::rotating_color_map;
use crate::info::{header_btns, make_tabs, throughput, Details, Tab};
use abstutil::prettyprint_usize;
use ezgui::{EventCtx, Line, Plot, PlotOptions, Series, Text, Widget};
use ezgui::{EventCtx, Line, Plot, PlotOptions, Series, Text, TextExt, Widget};
use geom::{Duration, Statistic, Time};
use map_model::{IntersectionID, IntersectionType};
use sim::Analytics;
@ -36,22 +36,18 @@ pub fn traffic(
let mut txt = Text::new();
txt.add(Line("Throughput"));
txt.add(
Line(format!(
"Since midnight: {} agents crossed",
prettyprint_usize(
app.primary
.sim
.get_analytics()
.thruput_stats
.count_per_intersection
.get(id)
)
))
.secondary(),
);
txt.add(Line(format!("In 20 minute buckets:")).secondary());
txt.add(Line(format!(
"Since midnight: {} agents crossed",
prettyprint_usize(
app.primary
.sim
.get_analytics()
.thruput_stats
.count_per_intersection
.get(id)
)
)));
txt.add(Line(format!("In 20 minute buckets:")));
rows.push(txt.draw(ctx));
rows.push(
@ -69,9 +65,7 @@ pub fn delay(ctx: &EventCtx, app: &App, details: &mut Details, id: IntersectionI
let i = app.primary.map.get_i(id);
assert!(i.is_traffic_signal());
let mut txt = Text::from(Line("Delay"));
txt.add(Line(format!("In 20 minute buckets:")).secondary());
rows.push(txt.draw(ctx));
rows.push("In 20 minute buckets".draw_text(ctx));
rows.push(delay_plot(ctx, app, id, Duration::minutes(20)).margin(10));

View File

@ -100,23 +100,19 @@ pub fn traffic(ctx: &EventCtx, app: &App, details: &mut Details, id: LaneID) ->
let r = map.get_r(l.parent);
// Since this applies to the entire road, ignore lane type.
let mut txt = Text::from(Line(""));
txt.add(Line("Throughput (entire road)"));
txt.add(
Line(format!(
"Since midnight: {} agents crossed",
prettyprint_usize(
app.primary
.sim
.get_analytics()
.thruput_stats
.count_per_road
.get(r.id)
)
))
.secondary(),
);
txt.add(Line(format!("In 20 minute buckets:")).secondary());
let mut txt = Text::from(Line("Traffic over entire road, not just this lane"));
txt.add(Line(format!(
"Since midnight: {} agents crossed",
prettyprint_usize(
app.primary
.sim
.get_analytics()
.thruput_stats
.count_per_road
.get(r.id)
)
)));
txt.add(Line(format!("In 20 minute buckets:")));
rows.push(txt.draw(ctx));
let r = map.get_l(id).parent;

View File

@ -80,8 +80,11 @@ impl GameplayState for Tutorial {
) -> (Option<Transition>, bool) {
// TODO Hack. We have to do this before grabbing the tutorial session.
let target = CarID(30, VehicleType::Car);
let following_car =
controls.common.as_ref().unwrap().info_panel_open(app) == Some(ID::Car(target));
let following_car = controls
.common
.as_ref()
.map(|c| c.info_panel_open(app) == Some(ID::Car(target)))
.unwrap_or(false);
let mut tut = app.session.tutorial.as_mut().unwrap();
@ -439,7 +442,7 @@ impl Task {
}
Task::TimeControls => "Simulate until after 5pm",
Task::PauseResume => {
let mut txt = Text::from(Line(" Pause/resume "));
let mut txt = Text::from(Line("[ ] Pause/resume "));
txt.append(Line(format!("{} times", 3 - state.num_pauses)).fg(Color::GREEN));
return txt;
}
@ -472,7 +475,7 @@ impl Task {
};
let mut txt = Text::new();
txt.add_wrapped(format!(" {}", simple), 0.6 * ctx.canvas.window_width);
txt.add_wrapped(format!("[ ] {}", simple), 0.6 * ctx.canvas.window_width);
txt
}