mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
stop listing edits in main edit mode too
This commit is contained in:
parent
23b3b1e0a4
commit
30664d9791
@ -148,17 +148,6 @@ impl ModalMenu {
|
||||
panic!("Menu doesn't have {}", old_label);
|
||||
}
|
||||
|
||||
pub fn change_action_by_key(&mut self, mk: MultiKey, new_label: String, ctx: &EventCtx) {
|
||||
for c in self.choices.iter_mut() {
|
||||
if c.hotkey == Some(mk) {
|
||||
c.label = new_label;
|
||||
self.recalculate_dims(ctx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
panic!("Menu doesn't have a choice with hotkey {:?}", mk);
|
||||
}
|
||||
|
||||
pub fn maybe_change_action(&mut self, old_label: &str, new_label: &str, ctx: &EventCtx) {
|
||||
for c in self.choices.iter_mut() {
|
||||
if c.label == old_label {
|
||||
|
@ -45,12 +45,9 @@ impl EditMode {
|
||||
vec![
|
||||
(hotkey(Key::S), "save edits"),
|
||||
(hotkey(Key::L), "load different edits"),
|
||||
// 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::Num1), "1) ..."),
|
||||
(hotkey(Key::Num2), "2) ..."),
|
||||
(hotkey(Key::Num3), "3) ..."),
|
||||
(hotkey(Key::Num4), "4) ..."),
|
||||
(hotkey(Key::Num5), "5) ..."),
|
||||
],
|
||||
ctx,
|
||||
),
|
||||
@ -85,54 +82,8 @@ impl State for EditMode {
|
||||
self.menu.set_info(ctx, txt);
|
||||
}
|
||||
|
||||
// TODO Recalculate less frequently
|
||||
{
|
||||
let cmds = &ui.primary.map.get_edits().commands;
|
||||
for (idx, key) in vec![Key::Num1, Key::Num2, Key::Num3, Key::Num4, Key::Num5]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
let label = if idx < cmds.len() {
|
||||
format!("{}) {}", idx + 1, cmds[cmds.len() - 1 - idx].describe())
|
||||
} else {
|
||||
format!("{}) ...", idx + 1)
|
||||
};
|
||||
self.menu
|
||||
.change_action_by_key(hotkey(key).unwrap(), label, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
self.menu.event(ctx);
|
||||
|
||||
{
|
||||
let cmds = &ui.primary.map.get_edits().commands;
|
||||
for idx in 1..=5 {
|
||||
if idx <= cmds.len() {
|
||||
let label = format!("{}) {}", idx, cmds[cmds.len() - idx].describe());
|
||||
if self.menu.action(&label) {
|
||||
let id = match &cmds[cmds.len() - idx] {
|
||||
EditCmd::ChangeLaneType { id, .. } => ID::Lane(*id),
|
||||
EditCmd::ReverseLane { l, .. } => ID::Lane(*l),
|
||||
EditCmd::ChangeStopSign(ss) => ID::Intersection(ss.id),
|
||||
EditCmd::ChangeTrafficSignal(ss) => ID::Intersection(ss.id),
|
||||
EditCmd::CloseIntersection { id, .. } => ID::Intersection(*id),
|
||||
EditCmd::UncloseIntersection(id, _) => ID::Intersection(*id),
|
||||
};
|
||||
return Transition::PushWithMode(
|
||||
Warping::new(
|
||||
ctx,
|
||||
id.canonical_point(&ui.primary).unwrap(),
|
||||
None,
|
||||
Some(id),
|
||||
&mut ui.primary,
|
||||
),
|
||||
EventLoopMode::Animation,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if self.mode.can_edit_lanes() {
|
||||
if let Some(t) = self.lane_editor.event(ui, ctx) {
|
||||
return t;
|
||||
@ -238,8 +189,25 @@ impl State for EditMode {
|
||||
|
||||
if !ui.primary.map.get_edits().commands.is_empty() && self.menu.action("undo") {
|
||||
let mut edits = ui.primary.map.get_edits().clone();
|
||||
edits.commands.pop();
|
||||
let id = match edits.commands.pop().unwrap() {
|
||||
EditCmd::ChangeLaneType { id, .. } => ID::Lane(id),
|
||||
EditCmd::ReverseLane { l, .. } => ID::Lane(l),
|
||||
EditCmd::ChangeStopSign(ss) => ID::Intersection(ss.id),
|
||||
EditCmd::ChangeTrafficSignal(ss) => ID::Intersection(ss.id),
|
||||
EditCmd::CloseIntersection { id, .. } => ID::Intersection(id),
|
||||
EditCmd::UncloseIntersection(id, _) => ID::Intersection(id),
|
||||
};
|
||||
apply_map_edits(&mut ui.primary, &ui.cs, ctx, edits);
|
||||
return Transition::PushWithMode(
|
||||
Warping::new(
|
||||
ctx,
|
||||
id.canonical_point(&ui.primary).unwrap(),
|
||||
None,
|
||||
Some(id),
|
||||
&mut ui.primary,
|
||||
),
|
||||
EventLoopMode::Animation,
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(t) = self.common.event(ctx, ui) {
|
||||
|
Loading…
Reference in New Issue
Block a user