mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 12:12:00 +03:00
lift warp plugin out of simmode. and categorize display logs as view,
just to organize the directory more.
This commit is contained in:
parent
597828ce28
commit
d06f80e918
@ -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.
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
pub mod debug;
|
||||
pub mod edit;
|
||||
pub mod logs;
|
||||
pub mod sim;
|
||||
pub mod time_travel;
|
||||
pub mod view;
|
||||
|
@ -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<Box<Plugin>>,
|
||||
search: Option<search::SearchState>,
|
||||
ambient_plugins: Vec<Box<Plugin>>,
|
||||
}
|
||||
@ -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<Color> {
|
||||
// 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);
|
||||
|
@ -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<String>, 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));
|
||||
|
Loading…
Reference in New Issue
Block a user