mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-03 03:47:23 +03:00
Delete the temporary old road editor. I didn't expect the new editor to become usable so quickly.
And enable the new editor for everyone, with the experimental warning
This commit is contained in:
parent
9aa5d97271
commit
f781d3e74f
@ -1,84 +0,0 @@
|
||||
use map_gui::tools::PromptInput;
|
||||
use map_model::{Direction, LaneSpec, LaneType, Road};
|
||||
use widgetry::{EventCtx, State};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
use crate::edit::apply_map_edits;
|
||||
|
||||
/// Specify the lane types for a road using a text box. This is a temporary UI to start
|
||||
/// experimenting with widening roads. It'll be replaced by a real UI once the design is ready.
|
||||
pub fn prompt_for_lanes(ctx: &mut EventCtx, road: &Road) -> Box<dyn State<App>> {
|
||||
let r = road.id;
|
||||
PromptInput::new(
|
||||
ctx,
|
||||
"Define lanes_ltr",
|
||||
lanes_to_string(road),
|
||||
Box::new(move |string, ctx, app| {
|
||||
// We're selecting a lane before this, but the ID is probably about to be invalidated.
|
||||
app.primary.current_selection = None;
|
||||
|
||||
let mut edits = app.primary.map.get_edits().clone();
|
||||
edits.commands.push(app.primary.map.edit_road_cmd(r, |new| {
|
||||
new.lanes_ltr = string_to_lanes(string.clone());
|
||||
}));
|
||||
apply_map_edits(ctx, app, edits);
|
||||
Transition::Multi(vec![Transition::Pop, Transition::Pop])
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
fn lanes_to_string(road: &Road) -> String {
|
||||
// TODO Assuming driving on the right.
|
||||
let mut dir_change = false;
|
||||
let mut string = String::new();
|
||||
for (_, dir, lt) in road.lanes_ltr() {
|
||||
if !dir_change && dir == Direction::Fwd {
|
||||
string.push('/');
|
||||
dir_change = true;
|
||||
}
|
||||
string.push(
|
||||
lane_type_codes()
|
||||
.into_iter()
|
||||
.find(|(x, _)| *x == lt)
|
||||
.unwrap()
|
||||
.1,
|
||||
);
|
||||
}
|
||||
string
|
||||
}
|
||||
|
||||
fn string_to_lanes(string: String) -> Vec<LaneSpec> {
|
||||
let mut lanes = Vec::new();
|
||||
let mut dir = Direction::Back;
|
||||
for x in string.chars() {
|
||||
if x == '/' {
|
||||
dir = Direction::Fwd;
|
||||
continue;
|
||||
}
|
||||
let lt = lane_type_codes()
|
||||
.into_iter()
|
||||
.find(|(_, code)| *code == x)
|
||||
.unwrap()
|
||||
.0;
|
||||
lanes.push(LaneSpec {
|
||||
lt,
|
||||
dir,
|
||||
width: map_model::NORMAL_LANE_THICKNESS,
|
||||
});
|
||||
}
|
||||
lanes
|
||||
}
|
||||
|
||||
fn lane_type_codes() -> Vec<(LaneType, char)> {
|
||||
vec![
|
||||
(LaneType::Driving, 'd'),
|
||||
(LaneType::Parking, 'p'),
|
||||
(LaneType::Sidewalk, 's'),
|
||||
(LaneType::Shoulder, 'S'),
|
||||
(LaneType::Biking, 'b'),
|
||||
(LaneType::Bus, 't'), // transit
|
||||
(LaneType::SharedLeftTurn, 'l'),
|
||||
(LaneType::Construction, 'c'),
|
||||
(LaneType::LightRail, 'r'),
|
||||
]
|
||||
}
|
@ -100,23 +100,11 @@ impl LaneEditor {
|
||||
.text("Change access restrictions")
|
||||
.hotkey(Key::A)
|
||||
.build_def(ctx),
|
||||
if app.opts.dev {
|
||||
ctx.style()
|
||||
.btn_plain_destructive
|
||||
.text("Modify entire road")
|
||||
.hotkey(Key::R)
|
||||
.build_def(ctx)
|
||||
} else {
|
||||
Widget::nothing()
|
||||
},
|
||||
if app.opts.dev {
|
||||
ctx.style()
|
||||
.btn_plain_destructive
|
||||
.text("Modify entire road (debug)")
|
||||
.build_def(ctx)
|
||||
} else {
|
||||
Widget::nothing()
|
||||
},
|
||||
ctx.style()
|
||||
.btn_plain_destructive
|
||||
.text("Modify entire road (experimental!)")
|
||||
.hotkey(Key::R)
|
||||
.build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_solid_primary
|
||||
.text("Finish")
|
||||
@ -144,13 +132,8 @@ impl SimpleState<App> for LaneEditor {
|
||||
app,
|
||||
app.primary.map.get_l(self.l).parent,
|
||||
)),
|
||||
"Modify entire road" => Transition::Replace(crate::edit::roads::RoadEditor::new(
|
||||
ctx,
|
||||
app,
|
||||
app.primary.map.get_l(self.l).parent,
|
||||
)),
|
||||
"Modify entire road (debug)" => Transition::Push(
|
||||
crate::edit::debug_roads::prompt_for_lanes(ctx, app.primary.map.get_parent(self.l)),
|
||||
"Modify entire road (experimental!)" => Transition::Replace(
|
||||
crate::edit::roads::RoadEditor::new(ctx, app, app.primary.map.get_l(self.l).parent),
|
||||
),
|
||||
"Finish" => Transition::Pop,
|
||||
x => {
|
||||
|
@ -23,7 +23,6 @@ use crate::debug::DebugMode;
|
||||
use crate::sandbox::{GameplayMode, SandboxMode, TimeWarpScreen};
|
||||
|
||||
mod bulk;
|
||||
mod debug_roads;
|
||||
mod lanes;
|
||||
mod roads;
|
||||
mod routes;
|
||||
|
Loading…
Reference in New Issue
Block a user