diff --git a/ezgui/src/text.rs b/ezgui/src/text.rs index 1533eef1f5..16950c5b30 100644 --- a/ezgui/src/text.rs +++ b/ezgui/src/text.rs @@ -74,7 +74,7 @@ impl Text { } // TODO nope - pub fn prompt(line: &str) -> Text { + pub(crate) fn prompt(line: &str) -> Text { let mut txt = Text::new(); txt.add_highlighted(Line(line), PROMPT_COLOR); txt diff --git a/game/src/common/colors.rs b/game/src/common/colors.rs index ab8df56143..d6950418ce 100644 --- a/game/src/common/colors.rs +++ b/game/src/common/colors.rs @@ -164,7 +164,8 @@ impl ColorLegend { // - v2: be able to say something like "row: rectangle with width=30, height=80% of row. // then 10px spacing. then this text" // TODO Need to recalculate all this if the panel moves - let mut txt = Text::prompt(&self.title); + let mut txt = Text::new(); + txt.add_highlighted(Line(&self.title), Color::BLUE); for (label, _) in &self.rows { txt.add(Line(label)); } diff --git a/game/src/mission/dataviz.rs b/game/src/mission/dataviz.rs index 40dc714c12..7dc99642c4 100644 --- a/game/src/mission/dataviz.rs +++ b/game/src/mission/dataviz.rs @@ -34,9 +34,12 @@ struct Tract { impl DataVisualizer { pub fn new(ctx: &mut EventCtx, ui: &UI) -> DataVisualizer { - let mut timer = Timer::new("initialize popdat"); - let popdat: PopDat = abstutil::read_binary("../data/shapes/popdat.bin", &mut timer) - .expect("Couldn't load popdat.bin"); + let (popdat, tracts) = ctx.loading_screen("initialize popdat", |_, mut timer| { + let popdat: PopDat = abstutil::read_binary("../data/shapes/popdat.bin", &mut timer) + .expect("Couldn't load popdat.bin"); + let tracts = clip_tracts(&popdat, ui, &mut timer); + (popdat, tracts) + }); DataVisualizer { menu: ModalMenu::new( @@ -54,7 +57,7 @@ impl DataVisualizer { ], ctx, ), - tracts: clip_tracts(&popdat, ui, &mut timer), + tracts, popdat, show_bars: false, current_dataset: 0, @@ -64,25 +67,28 @@ impl DataVisualizer { } impl State for DataVisualizer { fn event(&mut self, ctx: &mut EventCtx, ui: &mut UI) -> Transition { - let mut txt = Text::prompt("Data Visualizer"); - if let Some(ref name) = self.current_tract { - txt.add_appended(vec![ - Line("Census "), - Line(name).fg(ui.cs.get("OSD name color")), - ]); - let tract = &self.tracts[name]; - txt.add(Line(format!( - "{} buildings", - prettyprint_usize(tract.num_bldgs) - ))); - txt.add(Line(format!( - "{} parking spots ", - prettyprint_usize(tract.num_parking_spots) - ))); - txt.add(Line(format!( - "{} total owned cars", - prettyprint_usize(tract.total_owned_cars) - ))); + { + let mut txt = Text::new(); + if let Some(ref name) = self.current_tract { + txt.add_appended(vec![ + Line("Census "), + Line(name).fg(ui.cs.get("OSD name color")), + ]); + let tract = &self.tracts[name]; + txt.add(Line(format!( + "{} buildings", + prettyprint_usize(tract.num_bldgs) + ))); + txt.add(Line(format!( + "{} parking spots ", + prettyprint_usize(tract.num_parking_spots) + ))); + txt.add(Line(format!( + "{} total owned cars", + prettyprint_usize(tract.total_owned_cars) + ))); + } + self.menu.set_info(ctx, txt); } self.menu.event(ctx); ctx.canvas.handle_event(ctx.input); diff --git a/game/src/sandbox/trip_stats.rs b/game/src/sandbox/trip_stats.rs index 9595e562e2..254a5ae457 100644 --- a/game/src/sandbox/trip_stats.rs +++ b/game/src/sandbox/trip_stats.rs @@ -191,11 +191,6 @@ impl ShowTripStats { ); } - let mut txt = Text::prompt("Trip Stats"); - txt.add(Line(format!( - "{} samples", - abstutil::prettyprint_usize(stats.samples.len()) - ))); Some(ShowTripStats { draw: ctx.prerender.upload(batch), labels,