mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
Overhaul lane editor UI. #331
This commit is contained in:
parent
da287ae68f
commit
6e10f40801
@ -1,3 +0,0 @@
|
||||
<svg width="37" height="50" viewBox="0 0 37 50" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M18.5 11.3636V18.1818L27.75 9.09091L18.5 0V6.81818C8.27875 6.81818 0 14.9545 0 25C0 28.5682 1.06375 31.8864 2.8675 34.6818L6.24375 31.3636C5.20312 29.4773 4.625 27.2955 4.625 25C4.625 17.4773 10.8456 11.3636 18.5 11.3636ZM34.1325 15.3182L30.7562 18.6364C31.7737 20.5455 32.375 22.7045 32.375 25C32.375 32.5227 26.1544 38.6364 18.5 38.6364V31.8182L9.25 40.9091L18.5 50V43.1818C28.7213 43.1818 37 35.0455 37 25C37 21.4318 35.9363 18.1136 34.1325 15.3182V15.3182Z" fill="white"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 589 B |
@ -4,7 +4,7 @@ use crate::edit::{apply_map_edits, change_speed_limit, try_change_lt};
|
||||
use crate::game::{PopupMsg, State, Transition};
|
||||
use geom::Speed;
|
||||
use map_model::{LaneType, RoadID};
|
||||
use std::collections::BTreeSet;
|
||||
use maplit::btreeset;
|
||||
use widgetry::{
|
||||
hotkey, hotkeys, Btn, Choice, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Key, Line,
|
||||
Outcome, Panel, TextExt, VerticalAlignment, Widget,
|
||||
@ -16,8 +16,8 @@ pub struct BulkSelect {
|
||||
}
|
||||
|
||||
impl BulkSelect {
|
||||
pub fn new(ctx: &mut EventCtx, app: &mut App) -> Box<dyn State> {
|
||||
let selector = RoadSelector::new(app, BTreeSet::new());
|
||||
pub fn new(ctx: &mut EventCtx, app: &mut App, start: RoadID) -> Box<dyn State> {
|
||||
let selector = RoadSelector::new(ctx, app, btreeset! {start});
|
||||
let panel = make_select_panel(ctx, app, &selector);
|
||||
Box::new(BulkSelect { panel, selector })
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ use crate::render::Renderable;
|
||||
use crate::sandbox::GameplayMode;
|
||||
use map_model::{EditCmd, LaneID, LaneType, Map};
|
||||
use widgetry::{
|
||||
hotkey, Btn, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Outcome, Panel, RewriteColor,
|
||||
hotkey, Btn, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, Text,
|
||||
TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
@ -55,7 +55,6 @@ impl LaneEditor {
|
||||
Key::C,
|
||||
lt != LaneType::Construction,
|
||||
),
|
||||
("contraflow", "reverse lane direction", Key::F, true),
|
||||
] {
|
||||
row.push(if active {
|
||||
Btn::svg_def(format!("system/assets/edit/{}.svg", icon)).build(
|
||||
@ -64,23 +63,26 @@ impl LaneEditor {
|
||||
hotkey(key),
|
||||
)
|
||||
} else {
|
||||
Widget::draw_svg_transform(
|
||||
ctx,
|
||||
&format!("system/assets/edit/{}.svg", icon),
|
||||
RewriteColor::ChangeAll(Color::WHITE.alpha(0.5)),
|
||||
)
|
||||
Widget::draw_svg(ctx, &format!("system/assets/edit/{}.svg", icon))
|
||||
.container()
|
||||
.padding(5)
|
||||
.outline(2.0, Color::WHITE)
|
||||
});
|
||||
}
|
||||
|
||||
let parent = app.primary.map.get_parent(l);
|
||||
let col = vec![
|
||||
format!(
|
||||
"Convert this lane of {} to what type?",
|
||||
parent.get_name(app.opts.language.as_ref())
|
||||
)
|
||||
.draw_text(ctx)
|
||||
.centered_horiz(),
|
||||
Widget::row(vec![
|
||||
Line(format!("Editing {}", l)).small_heading().draw(ctx),
|
||||
Btn::plaintext_custom(
|
||||
"Edit multiple lanes",
|
||||
Text::from(Line("+ Edit multiple").fg(Color::hex("#4CA7E9"))),
|
||||
)
|
||||
.build_def(ctx, hotkey(Key::M)),
|
||||
]),
|
||||
"Type of lane".draw_text(ctx),
|
||||
Widget::custom_row(row).centered(),
|
||||
Btn::text_fg("reverse direction").build_def(ctx, hotkey(Key::F)),
|
||||
change_speed_limit(ctx, parent.speed_limit),
|
||||
Btn::text_fg("Change access restrictions").build_def(ctx, hotkey(Key::A)),
|
||||
Btn::text_bg2("Finish").build_def(ctx, hotkey(Key::Escape)),
|
||||
@ -127,6 +129,13 @@ impl State for LaneEditor {
|
||||
|
||||
match self.panel.event(ctx) {
|
||||
Outcome::Clicked(x) => match x.as_ref() {
|
||||
"Edit multiple lanes" => {
|
||||
return Transition::Replace(crate::edit::bulk::BulkSelect::new(
|
||||
ctx,
|
||||
app,
|
||||
app.primary.map.get_l(self.l).parent,
|
||||
));
|
||||
}
|
||||
"Change access restrictions" => {
|
||||
return Transition::Push(ZoneEditor::new(
|
||||
ctx,
|
||||
@ -140,7 +149,7 @@ impl State for LaneEditor {
|
||||
x => {
|
||||
let map = &mut app.primary.map;
|
||||
let result = match x {
|
||||
"reverse lane direction" => Ok(reverse_lane(map, self.l)),
|
||||
"reverse direction" => Ok(reverse_lane(map, self.l)),
|
||||
"convert to a driving lane" => {
|
||||
try_change_lt(ctx, map, self.l, LaneType::Driving)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ impl EditMode {
|
||||
let layer = crate::layer::map::Static::edits(ctx, app);
|
||||
Box::new(EditMode {
|
||||
tool_panel: tool_panel(ctx),
|
||||
top_center: make_topcenter(ctx, app, &mode),
|
||||
top_center: make_topcenter(ctx, app),
|
||||
changelist: make_changelist(ctx, app),
|
||||
orig_edits: edits.clone(),
|
||||
orig_dirty,
|
||||
@ -157,9 +157,6 @@ impl State for EditMode {
|
||||
|
||||
match self.top_center.event(ctx) {
|
||||
Outcome::Clicked(x) => match x.as_ref() {
|
||||
"bulk edit" => {
|
||||
return Transition::Push(bulk::BulkSelect::new(ctx, app));
|
||||
}
|
||||
"finish editing" => {
|
||||
return self.quit(ctx, app);
|
||||
}
|
||||
@ -586,24 +583,17 @@ impl State for LoadEdits {
|
||||
}
|
||||
}
|
||||
|
||||
fn make_topcenter(ctx: &mut EventCtx, app: &App, mode: &GameplayMode) -> Panel {
|
||||
fn make_topcenter(ctx: &mut EventCtx, app: &App) -> Panel {
|
||||
Panel::new(Widget::col(vec![
|
||||
Line("Editing map")
|
||||
.small_heading()
|
||||
.draw(ctx)
|
||||
.centered_horiz(),
|
||||
Widget::row(vec![
|
||||
if mode.can_edit_lanes() {
|
||||
Btn::text_fg("bulk edit").build_def(ctx, hotkey(Key::B))
|
||||
} else {
|
||||
Btn::text_fg("bulk edit").inactive(ctx)
|
||||
},
|
||||
Btn::text_bg2(format!(
|
||||
"Finish & resume from {}",
|
||||
app.suspended_sim.as_ref().unwrap().time().ampm_tostring()
|
||||
))
|
||||
.build(ctx, "finish editing", hotkey(Key::Escape)),
|
||||
]),
|
||||
Btn::text_bg2(format!(
|
||||
"Finish & resume from {}",
|
||||
app.suspended_sim.as_ref().unwrap().time().ampm_tostring()
|
||||
))
|
||||
.build(ctx, "finish editing", hotkey(Key::Escape)),
|
||||
]))
|
||||
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
|
||||
.build(ctx)
|
||||
|
@ -28,14 +28,16 @@ pub enum Mode {
|
||||
}
|
||||
|
||||
impl RoadSelector {
|
||||
pub fn new(app: &mut App, roads: BTreeSet<RoadID>) -> RoadSelector {
|
||||
pub fn new(ctx: &mut EventCtx, app: &mut App, roads: BTreeSet<RoadID>) -> RoadSelector {
|
||||
app.primary.current_selection = None;
|
||||
RoadSelector {
|
||||
let mut rs = RoadSelector {
|
||||
roads,
|
||||
preview: None,
|
||||
mode: Mode::Paint,
|
||||
dragging: false,
|
||||
}
|
||||
};
|
||||
rs.roads_changed(ctx, app);
|
||||
rs
|
||||
}
|
||||
|
||||
pub fn make_controls(&self, ctx: &mut EventCtx) -> Widget {
|
||||
|
@ -44,7 +44,7 @@ impl ZoneEditor {
|
||||
|
||||
let (unzoomed, zoomed, legend) = draw_zone(ctx, app, &members);
|
||||
let orig_members = members.clone();
|
||||
let selector = RoadSelector::new(app, members);
|
||||
let selector = RoadSelector::new(ctx, app, members);
|
||||
|
||||
Box::new(ZoneEditor {
|
||||
panel: Panel::new(Widget::col(vec![
|
||||
|
Loading…
Reference in New Issue
Block a user