mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-26 16:02:23 +03:00
delete ModalMenu::hacky_new
This commit is contained in:
parent
cce1b6ff88
commit
17b31582cb
@ -41,16 +41,16 @@ enum State {
|
||||
}
|
||||
|
||||
impl SandboxMode {
|
||||
pub fn new(ctx: &EventCtx) -> SandboxMode {
|
||||
pub fn new(ctx: &mut EventCtx) -> SandboxMode {
|
||||
SandboxMode {
|
||||
desired_speed: 1.0,
|
||||
state: State::Paused,
|
||||
following: None,
|
||||
route_viewer: route_viewer::RouteViewer::Inactive,
|
||||
show_activity: show_activity::ShowActivity::Inactive,
|
||||
time_travel: time_travel::TimeTravel::new(ctx.canvas),
|
||||
time_travel: time_travel::TimeTravel::new(ctx),
|
||||
common: CommonState::new(),
|
||||
menu: ModalMenu::hacky_new(
|
||||
menu: ModalMenu::new(
|
||||
"Sandbox Mode",
|
||||
vec![
|
||||
vec![
|
||||
@ -76,7 +76,7 @@ impl SandboxMode {
|
||||
CommonState::modal_menu_entries(),
|
||||
]
|
||||
.concat(),
|
||||
ctx.canvas,
|
||||
ctx,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::ui::UI;
|
||||
use abstutil::MultiMap;
|
||||
use ezgui::{Canvas, EventCtx, GfxCtx, Key, ModalMenu, Text};
|
||||
use ezgui::{EventCtx, GfxCtx, Key, ModalMenu, Text};
|
||||
use geom::Duration;
|
||||
use map_model::{Map, Traversable};
|
||||
use sim::{CarID, DrawCarInput, DrawPedestrianInput, GetDrawAgents, PedestrianID};
|
||||
@ -22,19 +22,19 @@ struct StateAtTime {
|
||||
}
|
||||
|
||||
impl TimeTravel {
|
||||
pub fn new(canvas: &Canvas) -> TimeTravel {
|
||||
pub fn new(ctx: &mut EventCtx) -> TimeTravel {
|
||||
TimeTravel {
|
||||
state_per_time: Vec::new(),
|
||||
current_idx: None,
|
||||
should_record: false,
|
||||
menu: ModalMenu::hacky_new(
|
||||
menu: ModalMenu::new(
|
||||
"Time Traveler",
|
||||
vec![
|
||||
(Some(Key::Escape), "quit"),
|
||||
(Some(Key::Comma), "rewind"),
|
||||
(Some(Key::Dot), "forwards"),
|
||||
],
|
||||
canvas,
|
||||
ctx,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::widgets::{Menu, Position};
|
||||
use crate::{Canvas, EventCtx, GfxCtx, InputResult, Key, Text};
|
||||
use crate::{EventCtx, GfxCtx, InputResult, Key, Text};
|
||||
|
||||
pub struct ModalMenu {
|
||||
menu: Menu<()>,
|
||||
@ -8,15 +8,6 @@ pub struct ModalMenu {
|
||||
|
||||
impl ModalMenu {
|
||||
pub fn new(prompt_line: &str, choices: Vec<(Option<Key>, &str)>, ctx: &EventCtx) -> ModalMenu {
|
||||
ModalMenu::hacky_new(prompt_line, choices, ctx.canvas)
|
||||
}
|
||||
|
||||
// TODO Pass EventCtx when constructing the GUI?
|
||||
pub fn hacky_new(
|
||||
prompt_line: &str,
|
||||
choices: Vec<(Option<Key>, &str)>,
|
||||
canvas: &Canvas,
|
||||
) -> ModalMenu {
|
||||
let mut menu = Menu::new(
|
||||
Text::prompt(prompt_line),
|
||||
choices
|
||||
@ -26,11 +17,11 @@ impl ModalMenu {
|
||||
false,
|
||||
true,
|
||||
Position::TopRightOfScreen,
|
||||
canvas,
|
||||
ctx.canvas,
|
||||
);
|
||||
menu.mark_all_inactive();
|
||||
if canvas.hide_modal_menus {
|
||||
menu.make_hidden(canvas);
|
||||
if ctx.canvas.hide_modal_menus {
|
||||
menu.make_hidden(ctx.canvas);
|
||||
}
|
||||
ModalMenu {
|
||||
menu,
|
||||
|
Loading…
Reference in New Issue
Block a user