dont allow 0s phases

This commit is contained in:
Dustin Carlino 2020-01-09 17:38:02 -06:00
parent 4115d26b6b
commit 7b4c7306e7

View File

@ -361,9 +361,14 @@ fn change_traffic_signal(signal: ControlTrafficSignal, ui: &mut UI, ctx: &mut Ev
fn change_phase_duration(current_duration: Duration) -> Box<dyn State> {
WizardState::new(Box::new(move |wiz, ctx, _| {
let new_duration = wiz.wrap(ctx).input_usize_prefilled(
let new_duration = wiz.wrap(ctx).input_something(
"How long should this phase be (seconds)?",
format!("{}", current_duration.inner_seconds() as usize),
Some(format!("{}", current_duration.inner_seconds() as usize)),
Box::new(|line| {
line.parse::<usize>()
.ok()
.and_then(|n| if n != 0 { Some(n) } else { None })
}),
)?;
Some(Transition::PopWithData(Box::new(move |state, ui, ctx| {
let mut editor = state.downcast_mut::<TrafficSignalEditor>().unwrap();