mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-04 12:36:46 +03:00
controls to naively flip stop signs on/off
This commit is contained in:
parent
ca23950097
commit
5c9086a829
@ -111,6 +111,14 @@ impl StopSignEditor {
|
||||
new_edits.stop_sign_overrides.insert(self.id, sign);
|
||||
apply_map_edits(ui, ctx, new_edits);
|
||||
}
|
||||
} else if let Some(r) = self.selected_sign {
|
||||
if ctx.input.contextual_action(Key::Space, "toggle stop sign") {
|
||||
let mut sign = ui.primary.map.get_stop_sign(self.id).clone();
|
||||
sign.flip_sign(r, &ui.primary.map);
|
||||
let mut new_edits = ui.primary.map.get_edits().clone();
|
||||
new_edits.stop_sign_overrides.insert(self.id, sign);
|
||||
apply_map_edits(ui, ctx, new_edits);
|
||||
}
|
||||
} else if self.menu.action("quit") {
|
||||
return true;
|
||||
} else if self.menu.action("reset to default") {
|
||||
|
@ -154,6 +154,23 @@ impl ControlStopSign {
|
||||
self.recalculate_stop_signs(map);
|
||||
}
|
||||
|
||||
pub fn flip_sign(&mut self, r: RoadID, map: &Map) {
|
||||
// Very naive approach
|
||||
let ss = self.roads.get_mut(&r).unwrap();
|
||||
ss.enabled = !ss.enabled;
|
||||
// TODO Upgrade some to Priority
|
||||
let new_pri = if ss.enabled {
|
||||
TurnPriority::Stop
|
||||
} else {
|
||||
TurnPriority::Yield
|
||||
};
|
||||
for l in &ss.travel_lanes {
|
||||
for (turn, _) in map.get_next_turns_and_lanes(*l, self.id) {
|
||||
self.turns.insert(turn.id, new_pri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn recalculate_stop_signs(&mut self, map: &Map) {
|
||||
for ss in self.roads.values_mut() {
|
||||
ss.enabled = false;
|
||||
|
Loading…
Reference in New Issue
Block a user