mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 01:13:53 +03:00
flatten some DebugMode stuff that actually doesnt need to be permap, since it's exclusive blocking
This commit is contained in:
parent
a626f5c542
commit
46b3e85bd3
@ -573,6 +573,8 @@ Plugin styles are blocking or ambient. And some can conflict...
|
||||
- sim controls is a little weird; for now, it's always nonblocking and ambient and ever-present.
|
||||
- display logs is easy, just an exclusive blocking plugin.
|
||||
- debug mode stuff...
|
||||
- a bunch of exclusive blocking stuff... meaning it doesn't actually need to be per map!
|
||||
- make Layers and Hider mutate the current_selection state stuff themselves, and switch to ambient_event
|
||||
|
||||
|
||||
|
||||
|
@ -1,17 +1,14 @@
|
||||
mod chokepoints;
|
||||
mod classification;
|
||||
mod floodfill;
|
||||
mod geom_validation;
|
||||
mod hider;
|
||||
mod layers;
|
||||
pub mod chokepoints;
|
||||
pub mod classification;
|
||||
pub mod floodfill;
|
||||
pub mod geom_validation;
|
||||
pub mod hider;
|
||||
pub mod layers;
|
||||
|
||||
use crate::objects::{Ctx, ID};
|
||||
use crate::objects::ID;
|
||||
use crate::plugins::{Plugin, PluginCtx};
|
||||
use ezgui::{Color, GfxCtx};
|
||||
|
||||
pub struct DebugMode {
|
||||
active_plugin: Option<Box<Plugin>>,
|
||||
|
||||
// Ambient; they don't conflict with any of the main plugins.
|
||||
hider: hider::Hider,
|
||||
pub layers: layers::ToggleableLayers,
|
||||
@ -20,7 +17,6 @@ pub struct DebugMode {
|
||||
impl DebugMode {
|
||||
pub fn new() -> DebugMode {
|
||||
DebugMode {
|
||||
active_plugin: None,
|
||||
hider: hider::Hider::new(),
|
||||
layers: layers::ToggleableLayers::new(),
|
||||
}
|
||||
@ -39,39 +35,6 @@ impl Plugin for DebugMode {
|
||||
*ctx.recalculate_current_selection = true;
|
||||
ctx.primary.current_selection = None;
|
||||
}
|
||||
|
||||
if self.active_plugin.is_some() {
|
||||
if self.active_plugin.as_mut().unwrap().blocking_event(ctx) {
|
||||
return true;
|
||||
} else {
|
||||
self.active_plugin = None;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(p) = chokepoints::ChokepointsFinder::new(ctx) {
|
||||
self.active_plugin = Some(Box::new(p));
|
||||
} else if let Some(p) = classification::OsmClassifier::new(ctx) {
|
||||
self.active_plugin = Some(Box::new(p));
|
||||
} else if let Some(p) = floodfill::Floodfiller::new(ctx) {
|
||||
self.active_plugin = Some(Box::new(p));
|
||||
} else if let Some(p) = geom_validation::Validator::new(ctx) {
|
||||
self.active_plugin = Some(Box::new(p));
|
||||
}
|
||||
|
||||
self.active_plugin.is_some()
|
||||
}
|
||||
|
||||
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
|
||||
if let Some(ref plugin) = self.active_plugin {
|
||||
plugin.draw(g, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
|
||||
if let Some(ref plugin) = self.active_plugin {
|
||||
return plugin.color_for(obj, ctx);
|
||||
}
|
||||
None
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::colors::ColorScheme;
|
||||
use crate::objects::{Ctx, RenderingHints, ID};
|
||||
use crate::plugins;
|
||||
use crate::plugins::debug;
|
||||
use crate::plugins::debug::DebugMode;
|
||||
use crate::plugins::edit;
|
||||
use crate::plugins::logs::DisplayLogs;
|
||||
@ -168,8 +169,15 @@ impl UIState for DefaultUIState {
|
||||
|
||||
if let Some(p) = DisplayLogs::new(&mut ctx) {
|
||||
self.exclusive_blocking_plugin = Some(Box::new(p));
|
||||
}
|
||||
if ctx.secondary.is_none() {
|
||||
} else if let Some(p) = debug::chokepoints::ChokepointsFinder::new(&mut ctx) {
|
||||
self.exclusive_blocking_plugin = Some(Box::new(p));
|
||||
} else if let Some(p) = debug::classification::OsmClassifier::new(&mut ctx) {
|
||||
self.exclusive_blocking_plugin = Some(Box::new(p));
|
||||
} else if let Some(p) = debug::floodfill::Floodfiller::new(&mut ctx) {
|
||||
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 ctx.secondary.is_none() {
|
||||
if let Some(p) = edit::a_b_tests::ABTestManager::new(&mut ctx) {
|
||||
self.exclusive_blocking_plugin = Some(Box::new(p));
|
||||
} else if let Some(p) = edit::color_picker::ColorPicker::new(&mut ctx) {
|
||||
|
Loading…
Reference in New Issue
Block a user