From f781d3e74f764408870cf4e81b12f3a812f48ebe Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Wed, 21 Apr 2021 14:58:08 -0700 Subject: [PATCH] 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 --- game/src/edit/debug_roads.rs | 84 ------------------------------------ game/src/edit/lanes.rs | 31 +++---------- game/src/edit/mod.rs | 1 - 3 files changed, 7 insertions(+), 109 deletions(-) delete mode 100644 game/src/edit/debug_roads.rs diff --git a/game/src/edit/debug_roads.rs b/game/src/edit/debug_roads.rs deleted file mode 100644 index aafe90eb98..0000000000 --- a/game/src/edit/debug_roads.rs +++ /dev/null @@ -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> { - 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 { - 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'), - ] -} diff --git a/game/src/edit/lanes.rs b/game/src/edit/lanes.rs index 4b4a094f9b..4db0bad697 100644 --- a/game/src/edit/lanes.rs +++ b/game/src/edit/lanes.rs @@ -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 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 => { diff --git a/game/src/edit/mod.rs b/game/src/edit/mod.rs index 126f8047c2..1d98fd0a72 100644 --- a/game/src/edit/mod.rs +++ b/game/src/edit/mod.rs @@ -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;