mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
very basic version of labeling roads
This commit is contained in:
parent
3cebc3cc44
commit
8b14f9c69c
@ -53,6 +53,7 @@ impl DebugMode {
|
||||
(hotkey(Key::Num4), "show/hide areas"),
|
||||
(hotkey(Key::Num5), "show/hide extra shapes"),
|
||||
(hotkey(Key::Num6), "show/hide geometry debug mode"),
|
||||
(hotkey(Key::Num7), "show/hide labels"),
|
||||
(hotkey(Key::N), "show/hide neighborhood summaries"),
|
||||
(hotkey(Key::R), "show/hide route for all agents"),
|
||||
],
|
||||
@ -239,6 +240,8 @@ impl State for DebugMode {
|
||||
self.layers.show_extra_shapes = !self.layers.show_extra_shapes;
|
||||
} else if self.menu.action("show/hide geometry debug mode") {
|
||||
self.layers.geom_debug_mode = !self.layers.geom_debug_mode;
|
||||
} else if self.menu.action("show/hide labels") {
|
||||
self.layers.show_labels = !self.layers.show_labels;
|
||||
} else {
|
||||
changed = false;
|
||||
}
|
||||
@ -290,7 +293,8 @@ impl State for DebugMode {
|
||||
|
||||
fn draw(&self, g: &mut GfxCtx, ui: &UI) {
|
||||
let mut opts = self.common.draw_options(ui);
|
||||
opts.label_buildings = true;
|
||||
opts.label_buildings = self.layers.show_labels;
|
||||
opts.label_roads = self.layers.show_labels;
|
||||
opts.geom_debug_mode = self.layers.geom_debug_mode;
|
||||
if let Some(ref chokepoints) = self.chokepoints {
|
||||
let color = ui.cs.get_def("chokepoint", Color::RED);
|
||||
|
@ -88,6 +88,7 @@ pub struct DrawOptions {
|
||||
pub geom_debug_mode: bool,
|
||||
pub suppress_unzoomed_agents: bool,
|
||||
pub label_buildings: bool,
|
||||
pub label_roads: bool,
|
||||
}
|
||||
|
||||
impl DrawOptions {
|
||||
@ -98,6 +99,7 @@ impl DrawOptions {
|
||||
geom_debug_mode: false,
|
||||
suppress_unzoomed_agents: false,
|
||||
label_buildings: false,
|
||||
label_roads: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,6 +143,8 @@ impl UI {
|
||||
let mut drawn_all_areas = false;
|
||||
|
||||
for obj in objects {
|
||||
obj.draw(g, &opts, &ctx);
|
||||
|
||||
match obj.get_id() {
|
||||
ID::Building(b) => {
|
||||
if !drawn_all_buildings {
|
||||
@ -164,6 +166,19 @@ impl UI {
|
||||
}
|
||||
}
|
||||
}
|
||||
ID::Road(r) => {
|
||||
if opts.label_roads {
|
||||
let road = ctx.map.get_r(r);
|
||||
let mut txt = Text::new();
|
||||
txt.add_styled_line(
|
||||
road.get_name(),
|
||||
None, //Some(Color::BLACK),
|
||||
None,
|
||||
Some(50),
|
||||
);
|
||||
g.draw_text_at_mapspace(&txt, road.center_pts.middle());
|
||||
}
|
||||
}
|
||||
ID::Area(_) => {
|
||||
if !drawn_all_areas {
|
||||
g.redraw(&self.primary.draw_map.draw_all_areas);
|
||||
@ -172,7 +187,6 @@ impl UI {
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
obj.draw(g, &opts, &ctx);
|
||||
|
||||
if self.primary.current_selection == Some(obj.get_id()) {
|
||||
g.draw_polygon(
|
||||
@ -387,6 +401,7 @@ pub struct ShowLayers {
|
||||
pub show_areas: bool,
|
||||
pub show_extra_shapes: bool,
|
||||
pub geom_debug_mode: bool,
|
||||
pub show_labels: bool,
|
||||
}
|
||||
|
||||
impl ShowLayers {
|
||||
@ -398,6 +413,7 @@ impl ShowLayers {
|
||||
show_areas: true,
|
||||
show_extra_shapes: true,
|
||||
geom_debug_mode: false,
|
||||
show_labels: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user