mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +03:00
easily swap lanes on a road
This commit is contained in:
parent
504b818800
commit
77a2d72d34
@ -105,23 +105,7 @@ impl GUI for UI {
|
||||
}
|
||||
}
|
||||
State::Viewing => {
|
||||
if input.unimportant_key_pressed(Key::Escape, KEY_CATEGORY, "quit") {
|
||||
process::exit(0);
|
||||
}
|
||||
|
||||
if input.key_pressed(Key::S, "save") {
|
||||
if self.model.name.is_some() {
|
||||
self.model.save();
|
||||
} else {
|
||||
self.state = State::SavingModel(Wizard::new());
|
||||
}
|
||||
} else if self.model.name.is_some() && input.key_pressed(Key::X, "export map") {
|
||||
self.model.export();
|
||||
} else if input.key_pressed(Key::I, "create intersection") {
|
||||
self.model.create_i(cursor);
|
||||
} else if input.key_pressed(Key::B, "create building") {
|
||||
self.model.create_b(cursor);
|
||||
} else if let Some(i) = self.model.mouseover_intersection(cursor) {
|
||||
if let Some(i) = self.model.mouseover_intersection(cursor) {
|
||||
if input.key_pressed(Key::LCtrl, "move intersection") {
|
||||
self.state = State::MovingIntersection(i);
|
||||
} else if input.key_pressed(Key::R, "create road") {
|
||||
@ -142,6 +126,24 @@ impl GUI for UI {
|
||||
self.model.remove_road(r);
|
||||
} else if input.key_pressed(Key::E, "edit lanes") {
|
||||
self.state = State::EditingRoad(r, Wizard::new());
|
||||
} else if input.key_pressed(Key::S, "swap lanes") {
|
||||
self.model.swap_lanes(r);
|
||||
}
|
||||
} else {
|
||||
if input.unimportant_key_pressed(Key::Escape, KEY_CATEGORY, "quit") {
|
||||
process::exit(0);
|
||||
} else if input.key_pressed(Key::S, "save") {
|
||||
if self.model.name.is_some() {
|
||||
self.model.save();
|
||||
} else {
|
||||
self.state = State::SavingModel(Wizard::new());
|
||||
}
|
||||
} else if self.model.name.is_some() && input.key_pressed(Key::X, "export map") {
|
||||
self.model.export();
|
||||
} else if input.key_pressed(Key::I, "create intersection") {
|
||||
self.model.create_i(cursor);
|
||||
} else if input.key_pressed(Key::B, "create building") {
|
||||
self.model.create_b(cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ use ezgui::{Color, GfxCtx};
|
||||
use geom::{Circle, LonLat, PolyLine, Polygon, Pt2D};
|
||||
use map_model::{raw_data, LaneType, RoadSpec, LANE_THICKNESS};
|
||||
use std::collections::BTreeMap;
|
||||
use std::mem;
|
||||
|
||||
const INTERSECTION_RADIUS: f64 = 10.0;
|
||||
const BUILDING_LENGTH: f64 = 30.0;
|
||||
@ -277,6 +278,11 @@ impl Model {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn swap_lanes(&mut self, id: RoadID) {
|
||||
let lanes = &mut self.roads.get_mut(&id).unwrap().lanes;
|
||||
mem::swap(&mut lanes.fwd, &mut lanes.back);
|
||||
}
|
||||
|
||||
pub fn remove_road(&mut self, id: RoadID) {
|
||||
self.roads.remove(&id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user