mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-03 03:47:23 +03:00
more obvious way to leave edit mode [rebuild]
This commit is contained in:
parent
2daf5c51ca
commit
719e720bf7
@ -48,6 +48,7 @@ impl EditMode {
|
||||
// TODO Support redo. Bit harder here to reset the redo_stack when the edits
|
||||
// change, because nested other places modify it too.
|
||||
(lctrl(Key::Z), "undo"),
|
||||
(hotkey(Key::Escape), "finish editing"),
|
||||
],
|
||||
ctx,
|
||||
),
|
||||
@ -57,6 +58,22 @@ impl EditMode {
|
||||
once: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn quit(&self, ctx: &mut EventCtx, ui: &mut UI) -> Transition {
|
||||
ctx.loading_screen("apply edits", |ctx, mut timer| {
|
||||
ui.overlay = Overlays::Inactive;
|
||||
ui.primary
|
||||
.map
|
||||
.recalculate_pathfinding_after_edits(&mut timer);
|
||||
// Parking state might've changed
|
||||
ui.primary.clear_sim();
|
||||
if let GameplayMode::Tutorial(current, latest) = self.mode {
|
||||
Transition::PopThenReplace(TutorialMode::resume(ctx, ui, current, latest))
|
||||
} else {
|
||||
Transition::PopThenReplace(Box::new(SandboxMode::new(ctx, ui, self.mode.clone())))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl State for EditMode {
|
||||
@ -112,6 +129,8 @@ impl State for EditMode {
|
||||
})));
|
||||
} else if self.menu.action("load different edits") {
|
||||
return Transition::Push(make_load_edits(self.mode.clone()));
|
||||
} else if self.menu.action("finish editing") {
|
||||
return self.quit(ctx, ui);
|
||||
}
|
||||
|
||||
if let Some(ID::Intersection(id)) = ui.primary.current_selection {
|
||||
@ -205,23 +224,7 @@ impl State for EditMode {
|
||||
match self.tool_panel.event(ctx, ui) {
|
||||
Some(WrappedOutcome::Transition(t)) => t,
|
||||
Some(WrappedOutcome::Clicked(x)) => match x.as_ref() {
|
||||
"back" => ctx.loading_screen("apply edits", |ctx, mut timer| {
|
||||
ui.overlay = Overlays::Inactive;
|
||||
ui.primary
|
||||
.map
|
||||
.recalculate_pathfinding_after_edits(&mut timer);
|
||||
// Parking state might've changed
|
||||
ui.primary.clear_sim();
|
||||
if let GameplayMode::Tutorial(current, latest) = self.mode {
|
||||
Transition::PopThenReplace(TutorialMode::resume(ctx, ui, current, latest))
|
||||
} else {
|
||||
Transition::PopThenReplace(Box::new(SandboxMode::new(
|
||||
ctx,
|
||||
ui,
|
||||
self.mode.clone(),
|
||||
)))
|
||||
}
|
||||
}),
|
||||
"back" => self.quit(ctx, ui),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
None => Transition::Keep,
|
||||
|
Loading…
Reference in New Issue
Block a user