From d06f80e9180d06094eb5d3599f961c49ea43a1d9 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Mon, 24 Dec 2018 17:27:58 -0800 Subject: [PATCH] lift warp plugin out of simmode. and categorize display logs as view, just to organize the directory more. --- docs/design/notes/gui.md | 2 ++ editor/src/plugins/mod.rs | 1 - editor/src/plugins/{ => view}/logs.rs | 0 editor/src/plugins/view/mod.rs | 38 +++++++-------------------- editor/src/state.rs | 8 +++--- 5 files changed, 17 insertions(+), 32 deletions(-) rename editor/src/plugins/{ => view}/logs.rs (100%) diff --git a/docs/design/notes/gui.md b/docs/design/notes/gui.md index 05d1d0a7e2..a13dd403c1 100644 --- a/docs/design/notes/gui.md +++ b/docs/design/notes/gui.md @@ -576,6 +576,8 @@ Plugin styles are blocking or ambient. And some can conflict... - a bunch of exclusive blocking stuff... meaning it doesn't actually need to be per map! - hider... per-map state, shouldnt exist till it does, stackable modal, should modify ctx itself. - layers... shouldnt be per-map state. should modify stuff itself. +- view mode... whew, one thing at a time. + - warp... exclusive blocking. apparently we used to still let ambient plugins draw and color stuff while it's active, but meh, doesnt seem important. diff --git a/editor/src/plugins/mod.rs b/editor/src/plugins/mod.rs index 4ad143eebc..a2d20432b1 100644 --- a/editor/src/plugins/mod.rs +++ b/editor/src/plugins/mod.rs @@ -1,6 +1,5 @@ pub mod debug; pub mod edit; -pub mod logs; pub mod sim; pub mod time_travel; pub mod view; diff --git a/editor/src/plugins/logs.rs b/editor/src/plugins/view/logs.rs similarity index 100% rename from editor/src/plugins/logs.rs rename to editor/src/plugins/view/logs.rs diff --git a/editor/src/plugins/view/mod.rs b/editor/src/plugins/view/mod.rs index 7e6eb2834b..49ef3bcec2 100644 --- a/editor/src/plugins/view/mod.rs +++ b/editor/src/plugins/view/mod.rs @@ -1,12 +1,13 @@ -mod debug_objects; -mod follow; -mod neighborhood_summary; -mod search; -mod show_activity; -mod show_associated; -mod show_route; -mod turn_cycler; -mod warp; +pub mod debug_objects; +pub mod follow; +pub mod logs; +pub mod neighborhood_summary; +pub mod search; +pub mod show_activity; +pub mod show_associated; +pub mod show_route; +pub mod turn_cycler; +pub mod warp; use crate::objects::{Ctx, ID}; use crate::plugins::{Plugin, PluginCtx}; @@ -16,7 +17,6 @@ use ezgui::{Color, GfxCtx}; use map_model::Map; pub struct ViewMode { - warp: Option>, search: Option, ambient_plugins: Vec>, } @@ -24,7 +24,6 @@ pub struct ViewMode { impl ViewMode { pub fn new(map: &Map, draw_map: &DrawMap, timer: &mut Timer) -> ViewMode { ViewMode { - warp: None, search: None, ambient_plugins: vec![ Box::new(debug_objects::DebugObjectsState::new()), @@ -45,18 +44,6 @@ impl ViewMode { impl Plugin for ViewMode { fn blocking_event(&mut self, ctx: &mut PluginCtx) -> bool { - if self.warp.is_some() { - if self.warp.as_mut().unwrap().blocking_event(ctx) { - return true; - } else { - self.warp = None; - return false; - } - } else if let Some(p) = warp::WarpState::new(ctx) { - self.warp = Some(Box::new(p)); - return true; - } - if self.search.is_some() { if self.search.as_mut().unwrap().blocking_event(ctx) { if self.search.as_ref().unwrap().is_blocking() { @@ -83,17 +70,12 @@ impl Plugin for ViewMode { p.draw(g, ctx); } - if let Some(ref p) = self.warp { - p.draw(g, ctx); - } if let Some(ref p) = self.search { p.draw(g, ctx); } } fn color_for(&self, obj: ID, ctx: &Ctx) -> Option { - // warp doesn't implement color_for. - if let Some(ref p) = self.search { if let Some(c) = p.color_for(obj, ctx) { return Some(c); diff --git a/editor/src/state.rs b/editor/src/state.rs index c28b792cf6..ae88d42ac5 100644 --- a/editor/src/state.rs +++ b/editor/src/state.rs @@ -3,8 +3,8 @@ use crate::objects::{Ctx, RenderingHints, ID}; use crate::plugins; use crate::plugins::debug; use crate::plugins::edit; -use crate::plugins::logs::DisplayLogs; use crate::plugins::time_travel::TimeTravel; +use crate::plugins::view; use crate::plugins::view::ViewMode; use crate::plugins::{Plugin, PluginCtx}; use crate::render::{DrawMap, Renderable}; @@ -62,7 +62,7 @@ impl DefaultUIState { pub fn new(flags: SimFlags, kml: Option, canvas: &Canvas) -> DefaultUIState { // Do this first to trigger the log console initialization, so anything logged by sim::load // isn't lost. - DisplayLogs::initialize(); + view::logs::DisplayLogs::initialize(); let (primary, primary_plugins) = PerMapUI::new(flags, kml); let mut state = DefaultUIState { primary, @@ -165,7 +165,7 @@ impl UIState for DefaultUIState { return; } - if let Some(p) = DisplayLogs::new(&mut ctx) { + if let Some(p) = view::logs::DisplayLogs::new(&mut ctx) { self.exclusive_blocking_plugin = Some(Box::new(p)); } else if let Some(p) = debug::chokepoints::ChokepointsFinder::new(&mut ctx) { self.exclusive_blocking_plugin = Some(Box::new(p)); @@ -175,6 +175,8 @@ impl UIState for DefaultUIState { self.exclusive_blocking_plugin = Some(Box::new(p)); } else if let Some(p) = debug::geom_validation::Validator::new(&mut ctx) { self.exclusive_blocking_plugin = Some(Box::new(p)); + } else if let Some(p) = view::warp::WarpState::new(&mut ctx) { + self.exclusive_blocking_plugin = Some(Box::new(p)); } else if ctx.secondary.is_none() { if let Some(p) = edit::a_b_tests::ABTestManager::new(&mut ctx) { self.exclusive_blocking_plugin = Some(Box::new(p));