tiny anti-refactor: explicitly copy the 3 CommonState keys into the 4 places they're used

This commit is contained in:
Dustin Carlino 2019-06-24 15:26:42 -07:00
parent b996b3773e
commit 02c50453ad
5 changed files with 75 additions and 89 deletions

View File

@ -30,25 +30,24 @@ impl ABTestMode {
menu: ModalMenu::new(
"A/B Test Mode",
vec![
vec![
(hotkey(Key::Escape), "quit"),
(hotkey(Key::LeftBracket), "slow down"),
(hotkey(Key::RightBracket), "speed up"),
(hotkey(Key::Space), "pause/resume"),
(hotkey(Key::M), "step forwards 0.1s"),
(hotkey(Key::N), "step forwards 10 mins"),
(hotkey(Key::B), "jump to specific time"),
(hotkey(Key::S), "swap"),
(hotkey(Key::D), "diff all trips"),
(hotkey(Key::A), "stop diffing trips"),
(hotkey(Key::F), "stop following agent"),
(hotkey(Key::R), "stop showing agent's route"),
(hotkey(Key::Q), "scoreboard"),
(hotkey(Key::O), "save state"),
],
CommonState::modal_menu_entries(),
]
.concat(),
(hotkey(Key::Escape), "quit"),
(hotkey(Key::LeftBracket), "slow down"),
(hotkey(Key::RightBracket), "speed up"),
(hotkey(Key::Space), "pause/resume"),
(hotkey(Key::M), "step forwards 0.1s"),
(hotkey(Key::N), "step forwards 10 mins"),
(hotkey(Key::B), "jump to specific time"),
(hotkey(Key::S), "swap"),
(hotkey(Key::D), "diff all trips"),
(hotkey(Key::A), "stop diffing trips"),
(hotkey(Key::F), "stop following agent"),
(hotkey(Key::R), "stop showing agent's route"),
(hotkey(Key::Q), "scoreboard"),
(hotkey(Key::O), "save state"),
(hotkey(Key::J), "warp"),
(hotkey(Key::K), "navigate"),
(hotkey(Key::F1), "take a screenshot"),
],
ctx,
),
speed: SpeedControls::new(ctx, None),

View File

@ -17,8 +17,7 @@ use crate::helpers::ID;
use crate::render::DrawOptions;
use crate::ui::UI;
use ezgui::{
hotkey, Color, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, Key, ModalMenu, MultiKey,
Text, VerticalAlignment,
Color, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, ModalMenu, Text, VerticalAlignment,
};
use std::collections::BTreeSet;
@ -35,15 +34,6 @@ impl CommonState {
}
}
pub fn modal_menu_entries() -> Vec<(Option<MultiKey>, &'static str)> {
vec![
(hotkey(Key::J), "warp"),
// TODO This definitely conflicts with some modes.
(hotkey(Key::K), "navigate"),
(hotkey(Key::F1), "take a screenshot"),
]
}
pub fn event(
&mut self,
ctx: &mut EventCtx,

View File

@ -45,30 +45,29 @@ impl DebugMode {
menu: ModalMenu::new(
"Debug Mode",
vec![
vec![
(hotkey(Key::Escape), "quit"),
(hotkey(Key::C), "show/hide chokepoints"),
(hotkey(Key::O), "clear original roads shown"),
(hotkey(Key::G), "clear intersection geometry"),
(hotkey(Key::H), "unhide everything"),
(hotkey(Key::Num1), "show/hide buildings"),
(hotkey(Key::Num2), "show/hide intersections"),
(hotkey(Key::Num3), "show/hide lanes"),
(hotkey(Key::Num4), "show/hide areas"),
(hotkey(Key::Num5), "show/hide extra shapes"),
(hotkey(Key::Num6), "show/hide geometry debug mode"),
(None, "screenshot everything"),
(hotkey(Key::Slash), "search OSM metadata"),
(hotkey(Key::M), "clear OSM search results"),
(hotkey(Key::S), "configure colors"),
(hotkey(Key::N), "show/hide neighborhood summaries"),
(hotkey(Key::R), "show/hide route for all agents"),
(lctrl(Key::S), "sandbox mode"),
(lctrl(Key::E), "edit mode"),
],
CommonState::modal_menu_entries(),
]
.concat(),
(hotkey(Key::Escape), "quit"),
(hotkey(Key::C), "show/hide chokepoints"),
(hotkey(Key::O), "clear original roads shown"),
(hotkey(Key::G), "clear intersection geometry"),
(hotkey(Key::H), "unhide everything"),
(hotkey(Key::Num1), "show/hide buildings"),
(hotkey(Key::Num2), "show/hide intersections"),
(hotkey(Key::Num3), "show/hide lanes"),
(hotkey(Key::Num4), "show/hide areas"),
(hotkey(Key::Num5), "show/hide extra shapes"),
(hotkey(Key::Num6), "show/hide geometry debug mode"),
(None, "screenshot everything"),
(hotkey(Key::Slash), "search OSM metadata"),
(hotkey(Key::M), "clear OSM search results"),
(hotkey(Key::S), "configure colors"),
(hotkey(Key::N), "show/hide neighborhood summaries"),
(hotkey(Key::R), "show/hide route for all agents"),
(lctrl(Key::S), "sandbox mode"),
(lctrl(Key::E), "edit mode"),
(hotkey(Key::J), "warp"),
(hotkey(Key::K), "navigate"),
(hotkey(Key::F1), "take a screenshot"),
],
ctx,
),
common: CommonState::new(),

View File

@ -33,16 +33,15 @@ impl EditMode {
menu: ModalMenu::new(
"Map Edit Mode",
vec![
vec![
(hotkey(Key::Escape), "quit"),
(hotkey(Key::S), "save edits"),
(hotkey(Key::L), "load different edits"),
(lctrl(Key::S), "sandbox mode"),
(lctrl(Key::D), "debug mode"),
],
CommonState::modal_menu_entries(),
]
.concat(),
(hotkey(Key::Escape), "quit"),
(hotkey(Key::S), "save edits"),
(hotkey(Key::L), "load different edits"),
(lctrl(Key::S), "sandbox mode"),
(lctrl(Key::D), "debug mode"),
(hotkey(Key::J), "warp"),
(hotkey(Key::K), "navigate"),
(hotkey(Key::F1), "take a screenshot"),
],
ctx,
),
}

View File

@ -32,31 +32,30 @@ impl SandboxMode {
menu: ModalMenu::new(
"Sandbox Mode",
vec![
vec![
(hotkey(Key::Escape), "quit"),
(hotkey(Key::RightBracket), "speed up"),
(hotkey(Key::LeftBracket), "slow down"),
(hotkey(Key::Space), "pause/resume"),
(hotkey(Key::O), "save sim state"),
(hotkey(Key::Y), "load previous sim state"),
(hotkey(Key::U), "load next sim state"),
(hotkey(Key::M), "step forwards 0.1s"),
(hotkey(Key::N), "step forwards 10 mins"),
(hotkey(Key::B), "jump to specific time"),
(hotkey(Key::X), "reset sim"),
(hotkey(Key::S), "seed the sim with agents"),
// TODO Strange to always have this. Really it's a case of stacked modal?
(hotkey(Key::F), "stop following agent"),
(hotkey(Key::R), "stop showing agent's route"),
(hotkey(Key::A), "show/hide active traffic"),
(hotkey(Key::T), "start time traveling"),
(hotkey(Key::Q), "scoreboard"),
(lctrl(Key::D), "debug mode"),
(lctrl(Key::E), "edit mode"),
],
CommonState::modal_menu_entries(),
]
.concat(),
(hotkey(Key::Escape), "quit"),
(hotkey(Key::RightBracket), "speed up"),
(hotkey(Key::LeftBracket), "slow down"),
(hotkey(Key::Space), "pause/resume"),
(hotkey(Key::O), "save sim state"),
(hotkey(Key::Y), "load previous sim state"),
(hotkey(Key::U), "load next sim state"),
(hotkey(Key::M), "step forwards 0.1s"),
(hotkey(Key::N), "step forwards 10 mins"),
(hotkey(Key::B), "jump to specific time"),
(hotkey(Key::X), "reset sim"),
(hotkey(Key::S), "seed the sim with agents"),
// TODO Strange to always have this. Really it's a case of stacked modal?
(hotkey(Key::F), "stop following agent"),
(hotkey(Key::R), "stop showing agent's route"),
(hotkey(Key::A), "show/hide active traffic"),
(hotkey(Key::T), "start time traveling"),
(hotkey(Key::Q), "scoreboard"),
(lctrl(Key::D), "debug mode"),
(lctrl(Key::E), "edit mode"),
(hotkey(Key::J), "warp"),
(hotkey(Key::K), "navigate"),
(hotkey(Key::F1), "take a screenshot"),
],
ctx,
),
}