From 13976ea0c59baf205faa992a84bb4fb514f60eb2 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Sat, 5 Oct 2019 14:23:52 -0700 Subject: [PATCH] start undoing the separate DynamicMenu experiment. move agent colorscheme back into main modalmenu --- game/src/abtest/mod.rs | 4 ++-- game/src/common/agent.rs | 16 +++++++++------- game/src/sandbox/mod.rs | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/game/src/abtest/mod.rs b/game/src/abtest/mod.rs index d5238bd7e4..1f99b99a67 100644 --- a/game/src/abtest/mod.rs +++ b/game/src/abtest/mod.rs @@ -146,9 +146,9 @@ impl State for ABTestMode { return Transition::Push(Box::new(explorer)); } - /*if let Some(t) = self.primary_agent_tools.event(ctx, ui, &mut self.menu) { + if let Some(t) = self.primary_agent_tools.event(ctx, ui, &mut self.menu) { return t; - }*/ + } if self.menu.action("save state") { ctx.loading_screen("savestate", |_, timer| { diff --git a/game/src/common/agent.rs b/game/src/common/agent.rs index f129dc7de7..196cd8dcf7 100644 --- a/game/src/common/agent.rs +++ b/game/src/common/agent.rs @@ -3,7 +3,7 @@ use crate::common::ColorLegend; use crate::game::{Transition, WizardState}; use crate::render::{AgentColorScheme, MIN_ZOOM_FOR_DETAIL}; use crate::ui::UI; -use ezgui::{hotkey, Choice, DynamicMenu, EventCtx, GfxCtx, Key}; +use ezgui::{hotkey, Choice, DynamicMenu, EventCtx, GfxCtx, Key, ModalMenu}; use geom::{Duration, Pt2D}; use sim::{TripID, TripResult}; use std::cell::RefCell; @@ -19,18 +19,20 @@ pub struct AgentTools { impl AgentTools { pub fn new(ctx: &mut EventCtx) -> AgentTools { - let mut menu = DynamicMenu::new("Agent Tools", ctx); - menu.add_action(hotkey(Key::Semicolon), "change agent colorscheme", ctx); - AgentTools { following: None, route_viewer: RouteViewer::Inactive, agent_cs_legend: RefCell::new(None), - menu, + menu: DynamicMenu::new("Agent Tools", ctx), } } - pub fn event(&mut self, ctx: &mut EventCtx, ui: &UI) -> Option { + pub fn event( + &mut self, + ctx: &mut EventCtx, + ui: &UI, + menu: &mut ModalMenu, + ) -> Option { self.menu.handle_event(ctx); if self.following.is_none() { @@ -91,7 +93,7 @@ impl AgentTools { } self.route_viewer.event(ctx, ui, &mut self.menu); - if self.menu.action("change agent colorscheme") { + if menu.action("change agent colorscheme") { return Some(Transition::Push(WizardState::new(Box::new( |wiz, ctx, ui| { let (_, acs) = wiz.wrap(ctx).choose("Which colorscheme for agents?", || { diff --git a/game/src/sandbox/mod.rs b/game/src/sandbox/mod.rs index adcb4b4ffd..fb6d63228a 100644 --- a/game/src/sandbox/mod.rs +++ b/game/src/sandbox/mod.rs @@ -61,10 +61,10 @@ impl SandboxMode { (hotkey(Key::S), "start a scenario"), ], vec![ - // TODO Strange to always have this. Really it's a case of stacked modal? (hotkey(Key::T), "start time traveling"), (hotkey(Key::Q), "scoreboard"), (hotkey(Key::L), "change analytics overlay"), + (hotkey(Key::Semicolon), "change agent colorscheme"), ], vec![ (hotkey(Key::Escape), "quit"), @@ -121,7 +121,7 @@ impl State for SandboxMode { return Transition::Push(Box::new(explorer)); } - if let Some(t) = self.agent_tools.event(ctx, ui) { + if let Some(t) = self.agent_tools.event(ctx, ui, &mut self.menu) { return t; } if ui.primary.current_selection.is_none() && self.menu.action("start time traveling") {