mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
make UI handle loading new maps with no buildings to focus on
This commit is contained in:
parent
546213e82b
commit
7a10378b00
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "ban left turn",
|
||||
"name": "ban_left_turn",
|
||||
"intersections": [
|
||||
[
|
||||
0,
|
||||
@ -18,7 +18,7 @@
|
||||
"x": 426.5473937988281,
|
||||
"y": 394.67230224609377
|
||||
},
|
||||
"has_traffic_signal": false
|
||||
"has_traffic_signal": true
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -86,7 +86,9 @@
|
||||
"back": [
|
||||
"Driving"
|
||||
]
|
||||
}
|
||||
},
|
||||
"fwd_label": null,
|
||||
"back_label": null
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -104,7 +106,9 @@
|
||||
"back": [
|
||||
"Driving"
|
||||
]
|
||||
}
|
||||
},
|
||||
"fwd_label": null,
|
||||
"back_label": null
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -120,7 +124,9 @@
|
||||
"Driving"
|
||||
],
|
||||
"back": []
|
||||
}
|
||||
},
|
||||
"fwd_label": null,
|
||||
"back_label": null
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -136,7 +142,9 @@
|
||||
"Driving"
|
||||
],
|
||||
"back": []
|
||||
}
|
||||
},
|
||||
"fwd_label": null,
|
||||
"back_label": null
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -152,7 +160,9 @@
|
||||
"Driving"
|
||||
],
|
||||
"back": []
|
||||
}
|
||||
},
|
||||
"fwd_label": null,
|
||||
"back_label": null
|
||||
}
|
||||
],
|
||||
[
|
||||
@ -168,7 +178,9 @@
|
||||
"Driving"
|
||||
],
|
||||
"back": []
|
||||
}
|
||||
},
|
||||
"fwd_label": null,
|
||||
"back_label": null
|
||||
}
|
||||
]
|
||||
],
|
@ -37,3 +37,8 @@ Seattlites with opinions and ideas:
|
||||
* https://www.reddit.com/r/SeattleWA/comments/86g3p9/id_get_back_an_hour_and_a_half_a_week/
|
||||
* https://www.reddit.com/r/Seattle/comments/4z3ewl/what_are_seattles_worst_intersections/
|
||||
* https://www.reddit.com/r/SeattleWA/comments/83h4ri/the_intersection_at_john_and_broadway_desperately/
|
||||
|
||||
## Other projects
|
||||
|
||||
* https://github.com/uwescience/TrafficCruising-DSSG2017
|
||||
* http://sharedstreets.io/
|
||||
|
@ -7,7 +7,7 @@ use colors::ColorScheme;
|
||||
//use cpuprofiler;
|
||||
use ezgui::{Canvas, Color, EventLoopMode, GfxCtx, Text, UserInput, BOTTOM_LEFT, GUI};
|
||||
use kml;
|
||||
use map_model::{BuildingID, IntersectionID, Map};
|
||||
use map_model::{BuildingID, IntersectionID, LaneID, Map};
|
||||
use objects::{Ctx, RenderingHints, ID, ROOT_MENU};
|
||||
use piston::input::Key;
|
||||
use plugins;
|
||||
@ -324,11 +324,16 @@ impl UI {
|
||||
_ => {
|
||||
warn!("Couldn't load editor_state or it's for a different map, so just focusing on an arbitrary building");
|
||||
// TODO window_size isn't set yet, so this actually kinda breaks
|
||||
ui.canvas.center_on_map_pt(
|
||||
ID::Building(BuildingID(0))
|
||||
.canonical_point(&ui.primary.map, &ui.primary.sim, &ui.primary.draw_map)
|
||||
.expect("Can't get canonical_point of BuildingID(0)"),
|
||||
);
|
||||
let focus_pt = ID::Building(BuildingID(0))
|
||||
.canonical_point(&ui.primary.map, &ui.primary.sim, &ui.primary.draw_map)
|
||||
.or_else(|| {
|
||||
ID::Lane(LaneID(0)).canonical_point(
|
||||
&ui.primary.map,
|
||||
&ui.primary.sim,
|
||||
&ui.primary.draw_map,
|
||||
)
|
||||
}).expect("Can't get canonical_point of BuildingID(0) or Road(0)");
|
||||
ui.canvas.center_on_map_pt(focus_pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user