mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
Small steps towards matching more GMNS signals: #626
- toss a loading screen around it - allow jump to ID in edit mode - break down failure types more
This commit is contained in:
parent
59597708ec
commit
96aa09edd0
@ -41,11 +41,8 @@ impl CommonState {
|
||||
app: &mut App,
|
||||
ctx_actions: &mut dyn ContextualActions,
|
||||
) -> Option<Transition> {
|
||||
if ctx.input.pressed(lctrl(Key::S)) {
|
||||
app.opts.dev = !app.opts.dev;
|
||||
}
|
||||
if ctx.input.pressed(lctrl(Key::J)) {
|
||||
return Some(Transition::Push(warp::DebugWarp::new_state(ctx)));
|
||||
if let Some(t) = CommonState::debug_actions(ctx, app) {
|
||||
return Some(t);
|
||||
}
|
||||
|
||||
// Layers can be launched from many places, many of which don't have a way of getting at
|
||||
@ -304,6 +301,17 @@ impl CommonState {
|
||||
pub fn info_panel_open(&self, app: &App) -> Option<ID> {
|
||||
self.info_panel.as_ref().and_then(|i| i.active_id(app))
|
||||
}
|
||||
|
||||
/// Allow toggling of dev mode and warping to an object by ID.
|
||||
pub fn debug_actions(ctx: &mut EventCtx, app: &mut App) -> Option<Transition> {
|
||||
if ctx.input.pressed(lctrl(Key::S)) {
|
||||
app.opts.dev = !app.opts.dev;
|
||||
}
|
||||
if ctx.input.pressed(lctrl(Key::J)) {
|
||||
return Some(Transition::Push(warp::DebugWarp::new_state(ctx)));
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Kinda misnomer
|
||||
|
@ -154,6 +154,10 @@ impl State<App> for EditMode {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(t) = CommonState::debug_actions(ctx, app) {
|
||||
return t;
|
||||
}
|
||||
|
||||
ctx.canvas_movement();
|
||||
// Restrict what can be selected.
|
||||
if ctx.redo_mouseover() {
|
||||
|
@ -115,27 +115,37 @@ pub fn import_all(ctx: &mut EventCtx, app: &mut App, path: &str) -> Box<dyn Stat
|
||||
})
|
||||
.collect();
|
||||
let mut successes = 0;
|
||||
let mut failures = 0;
|
||||
let mut failures_no_match = 0;
|
||||
let mut failures_other = 0;
|
||||
let mut edits = app.primary.map.get_edits().clone();
|
||||
|
||||
for i in all_signals {
|
||||
match import(&app.primary.map, i, path).and_then(|signal| signal.validate().map(|_| signal))
|
||||
{
|
||||
Ok(signal) => {
|
||||
info!("Success at {}", i);
|
||||
successes += 1;
|
||||
edits.commands.push(EditCmd::ChangeIntersection {
|
||||
i,
|
||||
old: app.primary.map.get_i_edit(i),
|
||||
new: EditIntersection::TrafficSignal(signal.export(&app.primary.map)),
|
||||
});
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Failure at {}: {}", i, err);
|
||||
failures += 1;
|
||||
ctx.loading_screen("import signal timing", |_, timer| {
|
||||
timer.start_iter("import", all_signals.len());
|
||||
for i in all_signals {
|
||||
timer.next();
|
||||
match import(&app.primary.map, i, path)
|
||||
.and_then(|signal| signal.validate().map(|_| signal))
|
||||
{
|
||||
Ok(signal) => {
|
||||
info!("Success at {}", i);
|
||||
successes += 1;
|
||||
edits.commands.push(EditCmd::ChangeIntersection {
|
||||
i,
|
||||
old: app.primary.map.get_i_edit(i),
|
||||
new: EditIntersection::TrafficSignal(signal.export(&app.primary.map)),
|
||||
});
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Failure at {}: {}", i, err);
|
||||
if err.to_string().contains("no matches for") {
|
||||
failures_no_match += 1;
|
||||
} else {
|
||||
failures_other += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
apply_map_edits(ctx, app, edits);
|
||||
|
||||
@ -144,7 +154,8 @@ pub fn import_all(ctx: &mut EventCtx, app: &mut App, path: &str) -> Box<dyn Stat
|
||||
&format!("Import from {}", path),
|
||||
vec![
|
||||
format!("{} traffic signals successfully imported", successes),
|
||||
format!("{} failures, no changes made", failures),
|
||||
format!("{} intersections without any data", failures_no_match),
|
||||
format!("{} other failures", failures_other),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user