also draw OSD in some modes that dont use CommonState

This commit is contained in:
Dustin Carlino 2019-05-03 14:22:39 -07:00
parent 3db78d1ddd
commit 6f4252fcae
4 changed files with 27 additions and 0 deletions

View File

@ -74,6 +74,10 @@ impl CommonState {
}
self.turn_cycler.draw(g, ui);
CommonState::draw_osd(g, ui);
}
pub fn draw_osd(g: &mut GfxCtx, ui: &UI) {
let id_color = ui.cs.get_def("OSD ID color", Color::RED);
let name_color = ui.cs.get_def("OSD name color", Color::CYAN);
let mut osd = Text::new();
@ -91,6 +95,22 @@ impl CommonState {
osd.append(" is ".to_string(), None);
osd.append(ui.primary.map.get_b(b).get_name(), Some(name_color));
}
Some(ID::Turn(t)) => {
osd.append(
format!("TurnID({})", ui.primary.map.get_t(t).lookup_idx),
Some(id_color),
);
osd.append(" between ".to_string(), None);
osd.append(
ui.primary.map.get_parent(t.src).get_name(),
Some(name_color),
);
osd.append(" and ".to_string(), None);
osd.append(
ui.primary.map.get_parent(t.dst).get_name(),
Some(name_color),
);
}
// TODO Intersections, cars, pedestrians...
Some(id) => {
osd.append(format!("{:?}", id), Some(id_color));

View File

@ -310,6 +310,7 @@ impl EditMode {
}
menu.draw(g);
CommonState::draw_osd(g, &state.ui);
}
Mode::Edit(EditMode::EditingTrafficSignal(ref editor)) => {
editor.draw(g, state);

View File

@ -1,3 +1,4 @@
use crate::common::CommonState;
use crate::edit::apply_map_edits;
use crate::game::GameState;
use crate::helpers::ID;
@ -291,6 +292,8 @@ impl TrafficSignalEditor {
} else if let Some(ref wizard) = self.preset_wizard {
wizard.draw(g);
}
CommonState::draw_osd(g, &state.ui);
}
}

View File

@ -1,3 +1,4 @@
use crate::common::CommonState;
use crate::helpers::ID;
use crate::render::DrawOptions;
use crate::ui::{ShowEverything, UI};
@ -253,6 +254,8 @@ impl AgentSpawner {
if let Some((_, Some(ref trace))) = self.maybe_goal {
g.draw_polygon(ui.cs.get("route"), &trace.make_polygons(LANE_THICKNESS));
}
CommonState::draw_osd(g, ui);
}
}