mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 15:33:44 +03:00
parent
f733763f73
commit
2181d8a56d
@ -20,6 +20,7 @@ ezgui = { path = "../ezgui", default-features=false }
|
||||
geom = { path = "../geom" }
|
||||
instant = "0.1.2"
|
||||
kml = { path = "../kml" }
|
||||
maplit = "1.0.2"
|
||||
map_model = { path = "../map_model" }
|
||||
popdat = { path = "../popdat" }
|
||||
rand = "0.7.0"
|
||||
|
@ -102,12 +102,11 @@ pub fn people(ctx: &mut EventCtx, app: &App, details: &mut Details, id: Building
|
||||
}
|
||||
}
|
||||
|
||||
let label = format!("Person #{}", p.0);
|
||||
details
|
||||
.hyperlinks
|
||||
.insert(label.clone(), Tab::PersonTrips(p, BTreeSet::new()));
|
||||
.insert(p.to_string(), Tab::PersonTrips(p, BTreeSet::new()));
|
||||
rows.push(Widget::col(vec![
|
||||
Btn::text_bg1(label).build_def(ctx, None),
|
||||
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)
|
||||
} else {
|
||||
@ -132,9 +131,7 @@ fn header(
|
||||
let mut rows = vec![];
|
||||
|
||||
rows.push(Widget::row(vec![
|
||||
Line(format!("Building #{}", id.0))
|
||||
.small_heading()
|
||||
.draw(ctx),
|
||||
Line(id.to_string()).small_heading().draw(ctx),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
|
||||
|
@ -92,8 +92,8 @@ fn bus_header(
|
||||
let mut rows = vec![];
|
||||
rows.push(Widget::row(vec![
|
||||
Line(format!(
|
||||
"Bus #{} (route {})",
|
||||
id.0,
|
||||
"{} (route {})",
|
||||
id,
|
||||
app.primary.map.get_br(route).name
|
||||
))
|
||||
.small_heading()
|
||||
|
@ -8,7 +8,7 @@ pub fn area(ctx: &EventCtx, app: &App, _: &mut Details, id: AreaID) -> Vec<Widge
|
||||
let mut rows = vec![];
|
||||
|
||||
rows.push(Widget::row(vec![
|
||||
Line(format!("Area #{}", id.0)).small_heading().draw(ctx),
|
||||
Line(id.to_string()).small_heading().draw(ctx),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
|
||||
@ -26,9 +26,7 @@ pub fn extra_shape(ctx: &EventCtx, app: &App, _: &mut Details, id: ExtraShapeID)
|
||||
let mut rows = vec![];
|
||||
|
||||
rows.push(Widget::row(vec![
|
||||
Line(format!("Extra GIS shape #{}", id.0))
|
||||
.small_heading()
|
||||
.draw(ctx),
|
||||
Line(id.to_string()).small_heading().draw(ctx),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
|
||||
|
@ -152,10 +152,10 @@ fn header(
|
||||
let i = app.primary.map.get_i(id);
|
||||
|
||||
let label = match i.intersection_type {
|
||||
IntersectionType::StopSign => format!("Intersection #{} (Stop signs)", id.0),
|
||||
IntersectionType::TrafficSignal => format!("Intersection #{} (Traffic signals)", id.0),
|
||||
IntersectionType::StopSign => format!("{} (Stop signs)", id),
|
||||
IntersectionType::TrafficSignal => format!("{} (Traffic signals)", id),
|
||||
IntersectionType::Border => format!("Border #{}", id.0),
|
||||
IntersectionType::Construction => format!("Intersection #{} (under construction)", id.0),
|
||||
IntersectionType::Construction => format!("{} (under construction)", id),
|
||||
};
|
||||
rows.push(Widget::row(vec![
|
||||
Line(label).small_heading().draw(ctx),
|
||||
|
@ -19,6 +19,7 @@ use ezgui::{
|
||||
};
|
||||
use geom::{Circle, Distance, Duration, Time};
|
||||
use map_model::{AreaID, BuildingID, BusStopID, IntersectionID, LaneID};
|
||||
use maplit::btreeset;
|
||||
use sim::{
|
||||
AgentID, Analytics, CarID, PedestrianID, PersonID, PersonState, TripID, TripMode, VehicleType,
|
||||
};
|
||||
@ -78,10 +79,10 @@ impl Tab {
|
||||
ID::Building(b) => Tab::BldgInfo(b),
|
||||
ID::Car(c) => {
|
||||
if let Some(p) = app.primary.sim.agent_to_person(AgentID::Car(c)) {
|
||||
// TODO Can we get the macro please?
|
||||
let mut open_trips = BTreeSet::new();
|
||||
open_trips.insert(app.primary.sim.agent_to_trip(AgentID::Car(c)).unwrap());
|
||||
Tab::PersonTrips(p, open_trips)
|
||||
Tab::PersonTrips(
|
||||
p,
|
||||
btreeset! {app.primary.sim.agent_to_trip(AgentID::Car(c)).unwrap()},
|
||||
)
|
||||
} else if c.1 == VehicleType::Bus {
|
||||
Tab::BusStatus(c)
|
||||
} else {
|
||||
@ -93,16 +94,7 @@ impl Tab {
|
||||
.sim
|
||||
.agent_to_person(AgentID::Pedestrian(p))
|
||||
.unwrap(),
|
||||
{
|
||||
let mut open_trips = BTreeSet::new();
|
||||
open_trips.insert(
|
||||
app.primary
|
||||
.sim
|
||||
.agent_to_trip(AgentID::Pedestrian(p))
|
||||
.unwrap(),
|
||||
);
|
||||
open_trips
|
||||
},
|
||||
btreeset! {app.primary.sim.agent_to_trip(AgentID::Pedestrian(p)).unwrap()},
|
||||
),
|
||||
ID::PedCrowd(members) => Tab::Crowd(members),
|
||||
ID::ExtraShape(es) => Tab::ExtraShape(es),
|
||||
|
@ -3,6 +3,7 @@ use crate::info::{building, header_btns, make_table, make_tabs, trip, Details, T
|
||||
use crate::render::Renderable;
|
||||
use ezgui::{Btn, Color, EventCtx, Line, TextExt, Widget};
|
||||
use map_model::Map;
|
||||
use maplit::btreeset;
|
||||
use sim::{
|
||||
AgentID, CarID, PedestrianID, Person, PersonID, PersonState, TripID, TripResult, VehicleType,
|
||||
};
|
||||
@ -54,18 +55,18 @@ pub fn trips(
|
||||
// TODO Style wrong. Button should be the entire row.
|
||||
rows.push(
|
||||
Widget::row(vec![
|
||||
format!("Trip #{} ({})", t.0, trip_status).draw_text(ctx),
|
||||
format!("{} ({})", t, trip_status).draw_text(ctx),
|
||||
Btn::text_fg(if open_trips.contains(t) { "▲" } else { "▼" })
|
||||
.build(
|
||||
ctx,
|
||||
format!(
|
||||
"{} Trip #{}",
|
||||
"{} {}",
|
||||
if open_trips.contains(t) {
|
||||
"hide"
|
||||
} else {
|
||||
"show"
|
||||
},
|
||||
t.0
|
||||
t
|
||||
),
|
||||
None,
|
||||
)
|
||||
@ -79,17 +80,15 @@ pub fn trips(
|
||||
|
||||
let mut new_trips = open_trips.clone();
|
||||
new_trips.remove(t);
|
||||
details.hyperlinks.insert(
|
||||
format!("hide Trip #{}", t.0),
|
||||
Tab::PersonTrips(id, new_trips),
|
||||
);
|
||||
details
|
||||
.hyperlinks
|
||||
.insert(format!("hide {}", t), Tab::PersonTrips(id, new_trips));
|
||||
} else {
|
||||
let mut new_trips = open_trips.clone();
|
||||
new_trips.insert(*t);
|
||||
details.hyperlinks.insert(
|
||||
format!("show Trip #{}", t.0),
|
||||
Tab::PersonTrips(id, new_trips),
|
||||
);
|
||||
details
|
||||
.hyperlinks
|
||||
.insert(format!("show {}", t), Tab::PersonTrips(id, new_trips));
|
||||
}
|
||||
}
|
||||
if wheres_waldo {
|
||||
@ -144,18 +143,14 @@ pub fn crowd(
|
||||
// TODO What other info is useful to summarize?
|
||||
rows.push(Widget::row(vec![
|
||||
format!("{})", idx + 1).draw_text(ctx),
|
||||
Btn::text_fg(format!("Person #{}", person.0)).build_def(ctx, None),
|
||||
Btn::text_fg(person.to_string()).build_def(ctx, None),
|
||||
]));
|
||||
let mut open_trips = BTreeSet::new();
|
||||
open_trips.insert(
|
||||
app.primary
|
||||
.sim
|
||||
.agent_to_trip(AgentID::Pedestrian(*id))
|
||||
.unwrap(),
|
||||
);
|
||||
details.hyperlinks.insert(
|
||||
format!("Person #{}", person.0),
|
||||
Tab::PersonTrips(person, open_trips),
|
||||
person.to_string(),
|
||||
Tab::PersonTrips(
|
||||
person,
|
||||
btreeset! {app.primary.sim.agent_to_trip(AgentID::Pedestrian(*id)).unwrap()},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -217,16 +212,17 @@ fn header(ctx: &EventCtx, app: &App, details: &mut Details, id: PersonID, tab: T
|
||||
};
|
||||
|
||||
rows.push(Widget::row(vec![
|
||||
Line(format!("Person #{} ({})", id.0, descr))
|
||||
Line(format!("{} ({})", id, descr))
|
||||
.small_heading()
|
||||
.draw(ctx),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
|
||||
let mut open_trips = BTreeSet::new();
|
||||
if let Some(t) = current_trip {
|
||||
open_trips.insert(t);
|
||||
}
|
||||
let open_trips = if let Some(t) = current_trip {
|
||||
btreeset! {t}
|
||||
} else {
|
||||
BTreeSet::new()
|
||||
};
|
||||
rows.push(make_tabs(
|
||||
ctx,
|
||||
&mut details.hyperlinks,
|
||||
|
@ -76,7 +76,7 @@ pub fn details(ctx: &mut EventCtx, app: &App, trip: TripID, details: &mut Detail
|
||||
progress_along_path,
|
||||
));
|
||||
|
||||
Widget::col(col).padding(5).margin(10)
|
||||
Widget::col(col)
|
||||
}
|
||||
|
||||
fn make_timeline(
|
||||
@ -97,7 +97,7 @@ fn make_timeline(
|
||||
let (id, center, name) = endpoint(&trip_start, map);
|
||||
details
|
||||
.warpers
|
||||
.insert(format!("jump to start of Trip #{}", trip.0), id);
|
||||
.insert(format!("jump to start of {}", trip), id);
|
||||
details.unzoomed.add_svg(
|
||||
ctx.prerender,
|
||||
"../data/system/assets/timeline/start_pos.svg",
|
||||
@ -119,14 +119,14 @@ fn make_timeline(
|
||||
RewriteColor::Change(Color::WHITE, colors::HOVERING),
|
||||
)
|
||||
.tooltip(txt)
|
||||
.build(ctx, format!("jump to start of Trip #{}", trip.0), None)
|
||||
.build(ctx, format!("jump to start of {}", trip), None)
|
||||
};
|
||||
|
||||
let goal_btn = {
|
||||
let (id, center, name) = endpoint(&trip_end, map);
|
||||
details
|
||||
.warpers
|
||||
.insert(format!("jump to goal of Trip #{}", trip.0), id);
|
||||
.insert(format!("jump to goal of {}", trip), id);
|
||||
details.unzoomed.add_svg(
|
||||
ctx.prerender,
|
||||
"../data/system/assets/timeline/goal_pos.svg",
|
||||
@ -150,7 +150,7 @@ fn make_timeline(
|
||||
RewriteColor::Change(Color::WHITE, colors::HOVERING),
|
||||
)
|
||||
.tooltip(txt)
|
||||
.build(ctx, format!("jump to goal of Trip #{}", trip.0), None)
|
||||
.build(ctx, format!("jump to goal of {}", trip), None)
|
||||
};
|
||||
|
||||
let total_duration_so_far = end_time.unwrap_or_else(|| sim.time()) - phases[0].start_time;
|
||||
@ -239,7 +239,7 @@ fn make_timeline(
|
||||
.tooltip(txt)
|
||||
.build(
|
||||
ctx,
|
||||
format!("examine trip phase {} of Trip #{}", idx + 1, trip.0),
|
||||
format!("examine trip phase {} of {}", idx + 1, trip),
|
||||
None,
|
||||
)
|
||||
.centered_vert(),
|
||||
|
@ -13,7 +13,7 @@ pub struct ExtraShapeID(pub usize);
|
||||
|
||||
impl fmt::Display for ExtraShapeID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "ExtraShapeID({0})", self.0)
|
||||
write!(f, "Extra GIS shape #{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ pub fn make_signal_diagram(
|
||||
|
||||
let signal = app.primary.map.get_traffic_signal(i);
|
||||
let txt_widget = {
|
||||
let mut txt = Text::from(Line(format!("Intersection #{}", i.0)).big_heading_plain());
|
||||
let mut txt = Text::from(Line(i.to_string()).big_heading_plain());
|
||||
|
||||
let mut road_names = BTreeSet::new();
|
||||
for r in &app.primary.map.get_i(i).roads {
|
||||
|
@ -17,10 +17,10 @@ use ezgui::{
|
||||
};
|
||||
use geom::{Distance, Duration, PolyLine, Polygon, Pt2D, Statistic, Time};
|
||||
use map_model::{BuildingID, IntersectionID, IntersectionType, LaneType, Map, RoadID};
|
||||
use maplit::btreeset;
|
||||
use sim::{
|
||||
AgentID, Analytics, BorderSpawnOverTime, CarID, OriginDestination, Scenario, VehicleType,
|
||||
};
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
pub struct Tutorial {
|
||||
top_center: Composite,
|
||||
@ -620,10 +620,7 @@ fn make_bike_lane_scenario(map: &Map) -> Scenario {
|
||||
|
||||
fn make_bus_lane_scenario(map: &Map) -> Scenario {
|
||||
let mut s = Scenario::empty(map, "car vs bus contention");
|
||||
let mut routes = BTreeSet::new();
|
||||
routes.insert("43".to_string());
|
||||
routes.insert("48".to_string());
|
||||
s.only_seed_buses = Some(routes);
|
||||
s.only_seed_buses = Some(btreeset! {"43".to_string(), "48".to_string()});
|
||||
for src in vec![
|
||||
RoadID(61).backwards(),
|
||||
RoadID(240).forwards(),
|
||||
|
@ -9,7 +9,7 @@ pub struct AreaID(pub usize);
|
||||
|
||||
impl fmt::Display for AreaID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "AreaID({0})", self.0)
|
||||
write!(f, "Area #{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ pub struct BuildingID(pub usize);
|
||||
|
||||
impl fmt::Display for BuildingID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "BuildingID({0})", self.0)
|
||||
write!(f, "Building #{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ pub struct BusRouteID(pub usize);
|
||||
|
||||
impl fmt::Display for BusRouteID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "BusRouteID({0})", self.0)
|
||||
write!(f, "BusRoute #{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ pub struct IntersectionID(pub usize);
|
||||
|
||||
impl fmt::Display for IntersectionID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "IntersectionID({0})", self.0)
|
||||
write!(f, "Intersection #{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ pub struct LaneID(pub usize);
|
||||
|
||||
impl fmt::Display for LaneID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "LaneID({0})", self.0)
|
||||
write!(f, "Lane #{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ pub struct RoadID(pub usize);
|
||||
|
||||
impl fmt::Display for RoadID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "RoadID({0})", self.0)
|
||||
write!(f, "Road #{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,11 @@ pub struct CarID(pub usize, pub VehicleType);
|
||||
|
||||
impl fmt::Display for CarID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "CarID({} -- {})", self.0, self.1)
|
||||
match self.1 {
|
||||
VehicleType::Car => write!(f, "Car #{}", self.0),
|
||||
VehicleType::Bus => write!(f, "Bus #{}", self.0),
|
||||
VehicleType::Bike => write!(f, "Bike #{}", self.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +74,7 @@ pub struct PedestrianID(pub usize);
|
||||
|
||||
impl fmt::Display for PedestrianID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "PedestrianID({0})", self.0)
|
||||
write!(f, "Pedestrian #{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +107,7 @@ pub struct TripID(pub usize);
|
||||
|
||||
impl fmt::Display for TripID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "TripID({0})", self.0)
|
||||
write!(f, "Trip #{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +116,7 @@ pub struct PersonID(pub usize);
|
||||
|
||||
impl fmt::Display for PersonID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "PersonID({0})", self.0)
|
||||
write!(f, "Person {}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user