mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-25 11:44:25 +03:00
fixing up a few lingering places in the game that were constructing text prompts
This commit is contained in:
parent
5304aa6ecf
commit
5358931a5e
@ -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
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user