mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
force GUI logic to handle selecting ped crowds by making a new ID
This commit is contained in:
parent
0379ceae11
commit
cd8a2eb65c
@ -111,6 +111,12 @@ fn dump_debug(id: ID, map: &Map, sim: &Sim, draw_map: &DrawMap) {
|
||||
ID::Pedestrian(id) => {
|
||||
sim.debug_ped(id);
|
||||
}
|
||||
ID::PedCrowd(members) => {
|
||||
println!("Crowd with {} members", members.len());
|
||||
for p in members {
|
||||
sim.debug_ped(p);
|
||||
}
|
||||
}
|
||||
ID::ExtraShape(id) => {
|
||||
let es = draw_map.get_es(id);
|
||||
for (k, v) in &es.attributes {
|
||||
@ -211,6 +217,9 @@ fn tooltip_lines(id: ID, g: &mut GfxCtx, ctx: &PerMapUI) -> Text {
|
||||
txt.add_wrapped_line(&g.canvas, line);
|
||||
}
|
||||
}
|
||||
ID::PedCrowd(members) => {
|
||||
txt.add_line(format!("Crowd of {}", members.len()));
|
||||
}
|
||||
ID::ExtraShape(id) => {
|
||||
styled_kv(&mut txt, &draw_map.get_es(id).attributes);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ pub enum ID {
|
||||
Building(BuildingID),
|
||||
Car(CarID),
|
||||
Pedestrian(PedestrianID),
|
||||
PedCrowd(Vec<PedestrianID>),
|
||||
ExtraShape(ExtraShapeID),
|
||||
BusStop(BusStopID),
|
||||
Area(AreaID),
|
||||
@ -36,6 +37,7 @@ impl ID {
|
||||
match *self {
|
||||
ID::Car(id) => Some(AgentID::Car(id)),
|
||||
ID::Pedestrian(id) => Some(AgentID::Pedestrian(id)),
|
||||
// PedCrowd doesn't map to a single agent.
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -55,6 +57,10 @@ impl ID {
|
||||
.get_draw_car(id, &primary.map)
|
||||
.map(|c| c.body.last_pt()),
|
||||
ID::Pedestrian(id) => primary.sim.get_draw_ped(id, &primary.map).map(|p| p.pos),
|
||||
ID::PedCrowd(ref members) => primary
|
||||
.sim
|
||||
.get_draw_ped(members[0], &primary.map)
|
||||
.map(|p| p.pos),
|
||||
// TODO maybe_get_es
|
||||
ID::ExtraShape(id) => Some(primary.draw_map.get_es(id).center()),
|
||||
ID::BusStop(id) => primary
|
||||
|
@ -46,6 +46,8 @@ pub const OUTLINE_THICKNESS: Distance = Distance::const_meters(0.5);
|
||||
// Does something belong here or as a method on ID? If it ONLY applies to renderable things, then
|
||||
// here. For example, trips aren't drawn, so it's meaningless to ask what their bounding box is.
|
||||
pub trait Renderable {
|
||||
// TODO This is expensive for the PedCrowd case. :( Returning a borrow is awkward, because most
|
||||
// Renderables are better off storing the inner ID directly.
|
||||
fn get_id(&self) -> ID;
|
||||
fn draw(&self, g: &mut GfxCtx, opts: &DrawOptions, ctx: &DrawCtx);
|
||||
// Higher z-ordered objects are drawn later. Default to low so roads at -1 don't vanish.
|
||||
|
@ -230,9 +230,9 @@ impl DrawPedCrowd {
|
||||
}
|
||||
|
||||
impl Renderable for DrawPedCrowd {
|
||||
// TODO this
|
||||
fn get_id(&self) -> ID {
|
||||
ID::Pedestrian(self.members[0])
|
||||
// Expensive! :(
|
||||
ID::PedCrowd(self.members.clone())
|
||||
}
|
||||
|
||||
fn draw(&self, g: &mut GfxCtx, opts: &DrawOptions, _: &DrawCtx) {
|
||||
|
@ -302,9 +302,12 @@ impl UI {
|
||||
ID::Building(id) => buildings.push(draw_map.get_b(id)),
|
||||
ID::ExtraShape(id) => extra_shapes.push(draw_map.get_es(id)),
|
||||
|
||||
ID::BusStop(_) | ID::Turn(_) | ID::Car(_) | ID::Pedestrian(_) | ID::Trip(_) => {
|
||||
panic!("{:?} shouldn't be in the quadtree", id)
|
||||
}
|
||||
ID::BusStop(_)
|
||||
| ID::Turn(_)
|
||||
| ID::Car(_)
|
||||
| ID::Pedestrian(_)
|
||||
| ID::PedCrowd(_)
|
||||
| ID::Trip(_) => panic!("{:?} shouldn't be in the quadtree", id),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user