merge status and trips pages. and go back to latest lyon after fix in

https://github.com/nical/lyon/issues/558
This commit is contained in:
Dustin Carlino 2020-03-31 14:45:07 -07:00
parent 8ed2d596ff
commit 509eb87bf5
4 changed files with 52 additions and 62 deletions

View File

@ -23,9 +23,7 @@ glutin = { git = "https://github.com/dabreegster/glutin", optional = true }
htmlescape = "0.3.1"
instant = "0.1.2"
lru = "0.4.3"
# TODO Something broke here
#lyon = "0.15.6"
lyon = { git = "https://github.com/nical/lyon/", rev = "0235217bfa9826f29e8d5fc5dbdfa8a6e35ebdff" }
lyon = "0.15.6"
serde = "1.0.98"
serde_derive = "1.0.98"
simsearch = "0.2.0"

View File

@ -41,7 +41,6 @@ pub struct InfoPanel {
#[derive(Clone, PartialEq)]
pub enum Tab {
PersonStatus(PersonID),
PersonTrips(PersonID, BTreeSet<TripID>),
PersonBio(PersonID),
@ -79,18 +78,31 @@ impl Tab {
ID::Building(b) => Tab::BldgInfo(b),
ID::Car(c) => {
if let Some(p) = app.primary.sim.agent_to_person(AgentID::Car(c)) {
Tab::PersonStatus(p)
// 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)
} else if c.1 == VehicleType::Bus {
Tab::BusStatus(c)
} else {
Tab::ParkedCar(c)
}
}
ID::Pedestrian(p) => Tab::PersonStatus(
ID::Pedestrian(p) => Tab::PersonTrips(
app.primary
.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
},
),
ID::PedCrowd(members) => Tab::Crowd(members),
ID::ExtraShape(es) => Tab::ExtraShape(es),
@ -102,7 +114,7 @@ impl Tab {
// TODO Temporary hack until object actions go away.
fn to_id(self, app: &App) -> Option<ID> {
match self {
Tab::PersonStatus(p) | Tab::PersonTrips(p, _) | Tab::PersonBio(p) => {
Tab::PersonTrips(p, _) | Tab::PersonBio(p) => {
match app.primary.sim.get_person(p).state {
PersonState::Inside(b) => Some(ID::Building(b)),
PersonState::Trip(t) => app
@ -178,7 +190,6 @@ impl InfoPanel {
};
let (mut col, main_tab) = match tab {
Tab::PersonStatus(p) => (person::status(ctx, app, &mut details, p), true),
Tab::PersonTrips(p, ref open) => {
(person::trips(ctx, app, &mut details, p, open), false)
}

View File

@ -8,53 +8,6 @@ use sim::{
};
use std::collections::BTreeSet;
pub fn status(ctx: &mut EventCtx, app: &App, details: &mut Details, id: PersonID) -> Vec<Widget> {
let mut rows = header(ctx, app, details, id, Tab::PersonStatus(id));
let map = &app.primary.map;
let sim = &app.primary.sim;
match sim.get_person(id).state {
PersonState::Inside(b) => {
// TODO hyperlink
rows.push(
format!("Currently inside {}", map.get_b(b).just_address(map)).draw_text(ctx),
);
}
PersonState::OffMap => {
rows.push("Currently outside the map boundaries".draw_text(ctx));
}
PersonState::Limbo => {
rows.push(
"Currently in limbo -- they broke out of the Matrix! Woops. (A bug occurred)"
.draw_text(ctx),
);
}
PersonState::Trip(t) => {
if let Some(a) = sim.trip_to_agent(t).ok() {
let (kv, extra) = match a {
AgentID::Car(c) => sim.car_properties(c, map),
AgentID::Pedestrian(p) => sim.ped_properties(p, map),
};
rows.extend(make_table(ctx, kv));
if !extra.is_empty() {
let mut txt = Text::from(Line(""));
for line in extra {
txt.add(Line(line));
}
rows.push(txt.draw(ctx));
}
}
let mut open_trips = BTreeSet::new();
open_trips.insert(t);
rows.push(trip::details(ctx, app, t, details, id, open_trips));
}
}
rows
}
pub fn trips(
ctx: &mut EventCtx,
app: &App,
@ -171,9 +124,17 @@ pub fn crowd(
format!("{})", idx + 1).draw_text(ctx),
Btn::text_fg(format!("Person #{}", person.0)).build_def(ctx, None),
]));
details
.hyperlinks
.insert(format!("Person #{}", person.0), Tab::PersonStatus(person));
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),
);
}
rows
@ -256,7 +217,6 @@ fn header(ctx: &EventCtx, app: &App, details: &mut Details, id: PersonID, tab: T
&mut details.hyperlinks,
tab,
vec![
("Status", Tab::PersonStatus(id)),
("Trips", Tab::PersonTrips(id, open_trips)),
("Bio", Tab::PersonBio(id)),
],

View File

@ -8,7 +8,7 @@ use ezgui::{
};
use geom::{Angle, Distance, Duration, Polygon, Pt2D, Time};
use map_model::{Map, Path, PathStep};
use sim::{PersonID, TripEndpoint, TripID, TripPhaseType, TripResult};
use sim::{AgentID, PersonID, TripEndpoint, TripID, TripPhaseType, TripResult};
use std::collections::BTreeSet;
pub fn details(
@ -261,13 +261,34 @@ pub fn details(
timeline.insert(0, start_btn.margin(5));
timeline.push(goal_btn.margin(5));
col.push(Widget::row(timeline).evenly_spaced().margin_above(25));
kv.push(("Duration", total_duration_so_far.to_string()));
if let Some(t) = end_time {
kv.push(("Trip end", t.ampm_tostring()));
}
col.push(Widget::row(timeline).evenly_spaced().margin_above(25));
col.extend(make_table(ctx, kv));
if let Some(a) = sim.trip_to_agent(trip).ok() {
let (more_kv, extra) = match a {
AgentID::Car(c) => sim.car_properties(c, map),
AgentID::Pedestrian(p) => sim.ped_properties(p, map),
};
for (k, v) in &more_kv {
kv.push((k, v.to_string()));
}
col.extend(make_table(ctx, kv));
if !extra.is_empty() {
let mut txt = Text::from(Line(""));
for line in extra {
txt.add(Line(line));
}
col.push(txt.draw(ctx));
}
} else {
col.extend(make_table(ctx, kv));
}
col.extend(elevation);
Widget::col(col)