mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-04 12:36:46 +03:00
make OSD work for intersection editors
This commit is contained in:
parent
3501c0ab4f
commit
b7daea7fb4
@ -84,14 +84,14 @@ impl CommonState {
|
||||
}
|
||||
self.turn_cycler.draw(g, ui);
|
||||
|
||||
CommonState::draw_osd(g, ui);
|
||||
CommonState::draw_osd(g, ui, ui.primary.current_selection);
|
||||
}
|
||||
|
||||
pub fn draw_osd(g: &mut GfxCtx, ui: &UI) {
|
||||
pub fn draw_osd(g: &mut GfxCtx, ui: &UI, id: Option<ID>) {
|
||||
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();
|
||||
match ui.primary.current_selection {
|
||||
match id {
|
||||
None => {
|
||||
osd.append("...".to_string(), None);
|
||||
}
|
||||
@ -126,7 +126,10 @@ impl CommonState {
|
||||
osd.append(format!("{:?}", id), Some(id_color));
|
||||
}
|
||||
}
|
||||
CommonState::draw_custom_osd(g, osd);
|
||||
}
|
||||
|
||||
pub fn draw_custom_osd(g: &mut GfxCtx, mut osd: Text) {
|
||||
let keys = g.get_active_context_menu_keys();
|
||||
if !keys.is_empty() {
|
||||
osd.append(" Hotkeys: ".to_string(), None);
|
||||
|
@ -4,7 +4,7 @@ use crate::game::GameState;
|
||||
use crate::helpers::ID;
|
||||
use crate::render::{DrawCtx, DrawOptions, DrawTurn, Renderable};
|
||||
use crate::ui::{ShowEverything, UI};
|
||||
use ezgui::{Color, EventCtx, GfxCtx, Key, ModalMenu};
|
||||
use ezgui::{Color, EventCtx, GfxCtx, Key, ModalMenu, Text};
|
||||
use geom::{Angle, Distance, Polygon, Pt2D};
|
||||
use map_model::{IntersectionID, LaneID, Map, Road, TurnID, TurnPriority, TurnType};
|
||||
|
||||
@ -180,8 +180,23 @@ impl StopSignEditor {
|
||||
}
|
||||
|
||||
self.menu.draw(g);
|
||||
// TODO This doesn't know about selecting the stop signs!
|
||||
CommonState::draw_osd(g, &state.ui);
|
||||
if let Some(idx) = self.selected_sign {
|
||||
let mut osd = Text::from_line("Stop sign for ".to_string());
|
||||
osd.append(
|
||||
state
|
||||
.ui
|
||||
.primary
|
||||
.map
|
||||
.get_parent(self.signs[idx].travel_lanes[0])
|
||||
.get_name(),
|
||||
Some(state.ui.cs.get("OSD name color")),
|
||||
);
|
||||
CommonState::draw_custom_osd(g, osd);
|
||||
} else if let Some(t) = self.selected_turn {
|
||||
CommonState::draw_osd(g, &state.ui, Some(ID::Turn(t)));
|
||||
} else {
|
||||
CommonState::draw_osd(g, &state.ui, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,11 @@ impl TrafficSignalEditor {
|
||||
}
|
||||
|
||||
self.menu.draw(g);
|
||||
CommonState::draw_osd(g, &state.ui);
|
||||
if let Some(t) = self.icon_selected {
|
||||
CommonState::draw_osd(g, &state.ui, Some(ID::Turn(t)));
|
||||
} else {
|
||||
CommonState::draw_osd(g, &state.ui, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ impl AgentSpawner {
|
||||
}
|
||||
|
||||
self.menu.draw(g);
|
||||
CommonState::draw_osd(g, ui);
|
||||
CommonState::draw_osd(g, ui, ui.primary.current_selection);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user