mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-06 22:47:48 +03:00
Rip out the old signal offset UI first.
This commit is contained in:
parent
57e5183c2c
commit
08805f6a32
@ -15,10 +15,10 @@ use map_model::{
|
|||||||
ControlTrafficSignal, EditCmd, EditIntersection, IntersectionID, MovementID, PhaseType, Stage,
|
ControlTrafficSignal, EditCmd, EditIntersection, IntersectionID, MovementID, PhaseType, Stage,
|
||||||
TurnPriority,
|
TurnPriority,
|
||||||
};
|
};
|
||||||
use std::collections::{BTreeSet, HashMap, VecDeque};
|
use std::collections::{BTreeSet, VecDeque};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
lctrl, Btn, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
lctrl, Btn, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
||||||
Outcome, Panel, RewriteColor, Spinner, Text, TextExt, VerticalAlignment, Widget,
|
Outcome, Panel, RewriteColor, Text, TextExt, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Welcome to one of the most overwhelmingly complicated parts of the UI...
|
// Welcome to one of the most overwhelmingly complicated parts of the UI...
|
||||||
@ -229,32 +229,6 @@ impl State for TrafficSignalEditor {
|
|||||||
});
|
});
|
||||||
return Transition::Keep;
|
return Transition::Keep;
|
||||||
}
|
}
|
||||||
if x == "Apply offset" {
|
|
||||||
let offset = Duration::seconds(self.side_panel.spinner("offset") as f64);
|
|
||||||
self.add_new_edit(ctx, app, self.current_stage, |ts| {
|
|
||||||
ts.offset = offset;
|
|
||||||
});
|
|
||||||
return Transition::Keep;
|
|
||||||
}
|
|
||||||
if x == "Apply offsets" {
|
|
||||||
let offsets: HashMap<IntersectionID, Duration> = self
|
|
||||||
.members
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(idx, i)| {
|
|
||||||
(
|
|
||||||
*i,
|
|
||||||
Duration::seconds(
|
|
||||||
self.side_panel.spinner(&format!("offset {}", idx)) as f64,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
self.add_new_edit(ctx, app, self.current_stage, |ts| {
|
|
||||||
ts.offset = offsets[&ts.id];
|
|
||||||
});
|
|
||||||
return Transition::Keep;
|
|
||||||
}
|
|
||||||
if let Some(x) = x.strip_prefix("change duration of stage ") {
|
if let Some(x) = x.strip_prefix("change duration of stage ") {
|
||||||
let idx = x.parse::<usize>().unwrap() - 1;
|
let idx = x.parse::<usize>().unwrap() - 1;
|
||||||
return Transition::Push(edits::ChangeDuration::new(
|
return Transition::Push(edits::ChangeDuration::new(
|
||||||
@ -631,16 +605,6 @@ fn make_side_panel(
|
|||||||
|
|
||||||
if members.len() == 1 {
|
if members.len() == 1 {
|
||||||
col.push(Btn::text_bg2("Edit entire signal").build_def(ctx, Key::E));
|
col.push(Btn::text_bg2("Edit entire signal").build_def(ctx, Key::E));
|
||||||
col.push(Widget::row(vec![
|
|
||||||
"Offset (s):".draw_text(ctx),
|
|
||||||
Spinner::new(
|
|
||||||
ctx,
|
|
||||||
(0, 90),
|
|
||||||
canonical_signal.offset.inner_seconds() as isize,
|
|
||||||
)
|
|
||||||
.named("offset"),
|
|
||||||
Btn::text_bg2("Apply").build(ctx, "Apply offset", None),
|
|
||||||
]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let translations = squish_polygons_together(
|
let translations = squish_polygons_together(
|
||||||
@ -713,35 +677,6 @@ fn make_side_panel(
|
|||||||
.centered_horiz(),
|
.centered_horiz(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO This doesn't even have a way of knowing which spinner corresponds to which
|
|
||||||
// intersection!
|
|
||||||
if members.len() > 1 {
|
|
||||||
col.push("Tune offset (s)".draw_text(ctx));
|
|
||||||
col.push(
|
|
||||||
Widget::row(
|
|
||||||
members
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(idx, i)| {
|
|
||||||
let spinner = Spinner::new(
|
|
||||||
ctx,
|
|
||||||
(0, 90),
|
|
||||||
map.get_traffic_signal(*i).offset.inner_seconds() as isize,
|
|
||||||
)
|
|
||||||
.named(format!("offset {}", idx));
|
|
||||||
if hovering == Some(*i) {
|
|
||||||
spinner.padding(2).outline(2.0, Color::YELLOW)
|
|
||||||
} else {
|
|
||||||
spinner
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
.evenly_spaced(),
|
|
||||||
);
|
|
||||||
col.push(Btn::text_bg2("Apply").build(ctx, "Apply offsets", None));
|
|
||||||
}
|
|
||||||
|
|
||||||
Panel::new(Widget::col(col))
|
Panel::new(Widget::col(col))
|
||||||
.aligned(HorizontalAlignment::Left, VerticalAlignment::Top)
|
.aligned(HorizontalAlignment::Left, VerticalAlignment::Top)
|
||||||
.exact_size_percent(30, 85)
|
.exact_size_percent(30, 85)
|
||||||
|
Loading…
Reference in New Issue
Block a user