mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 15:33:44 +03:00
Add a location button to the road / multi road editor. #718
This commit is contained in:
parent
07cce162c1
commit
9366116c9b
@ -14,6 +14,7 @@ use widgetry::{
|
||||
|
||||
use crate::app::App;
|
||||
use crate::app::Transition;
|
||||
use crate::common::Warping;
|
||||
use crate::edit::apply_map_edits;
|
||||
|
||||
pub struct SelectSegments {
|
||||
@ -31,12 +32,14 @@ pub struct SelectSegments {
|
||||
impl SelectSegments {
|
||||
pub fn new_state(
|
||||
ctx: &mut EventCtx,
|
||||
app: &App,
|
||||
app: &mut App,
|
||||
base_road: RoadID,
|
||||
orig_state: EditRoad,
|
||||
new_state: EditRoad,
|
||||
base_edits: MapEdits,
|
||||
) -> Box<dyn State<App>> {
|
||||
app.primary.current_selection = None;
|
||||
|
||||
// Find all road segments matching the original state and name. base_road has already
|
||||
// changed to new_state, so no need to exclude it.
|
||||
let map = &app.primary.map;
|
||||
@ -101,13 +104,23 @@ impl SelectSegments {
|
||||
Line("Apply changes to similar roads")
|
||||
.small_heading()
|
||||
.into_widget(ctx),
|
||||
Widget::row(vec![
|
||||
format!(
|
||||
"{} / {} roads similar to #{} are selected",
|
||||
"{} / {} roads similar to",
|
||||
self.current.len(),
|
||||
self.candidates.len(),
|
||||
self.base_road.0
|
||||
)
|
||||
.text_widget(ctx),
|
||||
.text_widget(ctx)
|
||||
.centered_vert(),
|
||||
ctx.style()
|
||||
.btn_plain
|
||||
.icon_text(
|
||||
"system/assets/tools/location.svg",
|
||||
format!("#{}", self.base_road.0),
|
||||
)
|
||||
.build_widget(ctx, "jump to changed road"),
|
||||
"are selected".text_widget(ctx).centered_vert(),
|
||||
]),
|
||||
// TODO Explain that this is only for lane configuration, NOT speed limit
|
||||
Widget::row(vec![
|
||||
"Click to select/unselect".text_widget(ctx).centered_vert(),
|
||||
@ -178,6 +191,17 @@ impl State<App> for SelectSegments {
|
||||
"Cancel" => {
|
||||
return Transition::Pop;
|
||||
}
|
||||
"jump to changed road" => {
|
||||
return Transition::Push(Warping::new_state(
|
||||
ctx,
|
||||
app.primary
|
||||
.canonical_point(ID::Road(self.base_road))
|
||||
.unwrap(),
|
||||
Some(10.0),
|
||||
Some(ID::Road(self.base_road)),
|
||||
&mut app.primary,
|
||||
));
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use widgetry::{
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
use crate::common::Warping;
|
||||
use crate::edit::zones::ZoneEditor;
|
||||
use crate::edit::{apply_map_edits, can_edit_lane, speed_limit_choices};
|
||||
|
||||
@ -189,6 +190,15 @@ impl State<App> for RoadEditor {
|
||||
self.current_lane = None;
|
||||
self.recalc_all_panels(ctx, app);
|
||||
}
|
||||
"jump to road" => {
|
||||
return Transition::Push(Warping::new_state(
|
||||
ctx,
|
||||
app.primary.canonical_point(ID::Road(self.r)).unwrap(),
|
||||
Some(10.0),
|
||||
Some(ID::Road(self.r)),
|
||||
&mut app.primary,
|
||||
));
|
||||
}
|
||||
"Apply to multiple road segments" => {
|
||||
return Transition::Push(
|
||||
crate::edit::multiple_roads::SelectSegments::new_state(
|
||||
@ -375,7 +385,11 @@ fn make_top_panel(
|
||||
|
||||
Panel::new_builder(Widget::col(vec![
|
||||
Widget::row(vec![
|
||||
Line("Editing road").small_heading().into_widget(ctx),
|
||||
Line(format!("Edit {}", r)).small_heading().into_widget(ctx),
|
||||
ctx.style()
|
||||
.btn_plain
|
||||
.icon("system/assets/tools/location.svg")
|
||||
.build_widget(ctx, "jump to road"),
|
||||
ctx.style()
|
||||
.btn_plain
|
||||
.text("+ Apply to multiple")
|
||||
|
Loading…
Reference in New Issue
Block a user