mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-29 12:43:38 +03:00
base RoadWithStopSign enabledness on turn priorities
This commit is contained in:
parent
6b218fb5ab
commit
ca23950097
@ -106,7 +106,7 @@ impl StopSignEditor {
|
||||
.input
|
||||
.contextual_action(Key::Space, &format!("toggle to {:?}", next_priority))
|
||||
{
|
||||
sign.turns.insert(t, next_priority);
|
||||
sign.change(t, next_priority, &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);
|
||||
|
@ -75,6 +75,7 @@ impl ControlStopSign {
|
||||
);
|
||||
}
|
||||
}
|
||||
ss.recalculate_stop_signs(map);
|
||||
|
||||
ss
|
||||
}
|
||||
@ -99,10 +100,6 @@ impl ControlStopSign {
|
||||
}
|
||||
}
|
||||
false
|
||||
/*self.turns
|
||||
.iter()
|
||||
.find(|(turn, pri)| turn.src == lane && **pri <= TurnPriority::Stop)
|
||||
.is_none()*/
|
||||
}
|
||||
|
||||
// Returns both errors and warnings.
|
||||
@ -151,6 +148,27 @@ impl ControlStopSign {
|
||||
|
||||
Ok(Warn::empty_warnings(warnings))
|
||||
}
|
||||
|
||||
pub fn change(&mut self, t: TurnID, pri: TurnPriority, map: &Map) {
|
||||
self.turns.insert(t, pri);
|
||||
self.recalculate_stop_signs(map);
|
||||
}
|
||||
|
||||
fn recalculate_stop_signs(&mut self, map: &Map) {
|
||||
for ss in self.roads.values_mut() {
|
||||
ss.enabled = false;
|
||||
for l in &ss.travel_lanes {
|
||||
for (turn, _) in map.get_next_turns_and_lanes(*l, self.id) {
|
||||
match self.turns[&turn.id] {
|
||||
TurnPriority::Stop | TurnPriority::Banned => {
|
||||
ss.enabled = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn smart_assignment(map: &Map, id: IntersectionID) -> Warn<ControlStopSign> {
|
||||
|
Loading…
Reference in New Issue
Block a user