diff --git a/editor/src/sandbox/mod.rs b/editor/src/sandbox/mod.rs index aa4b6fc4e0..7490c817b7 100644 --- a/editor/src/sandbox/mod.rs +++ b/editor/src/sandbox/mod.rs @@ -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, ), } } diff --git a/editor/src/sandbox/time_travel.rs b/editor/src/sandbox/time_travel.rs index 5cb7d85789..c51a29afb5 100644 --- a/editor/src/sandbox/time_travel.rs +++ b/editor/src/sandbox/time_travel.rs @@ -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, ), } } diff --git a/ezgui/src/widgets/modal_menu.rs b/ezgui/src/widgets/modal_menu.rs index 4cf4c78258..16eb5584a2 100644 --- a/ezgui/src/widgets/modal_menu.rs +++ b/ezgui/src/widgets/modal_menu.rs @@ -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, &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, &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,