get rid of the output param primary_plugins hack

This commit is contained in:
Dustin Carlino 2018-11-22 15:53:00 -08:00
parent 541a7bc22f
commit 1fd6c17ff5
4 changed files with 8 additions and 13 deletions

View File

@ -24,6 +24,6 @@ Some initial steps:
- objects_onscreen is the main place!
- need to get draw car/ped on lane/turn, so index them that way, maybe implement a trait?
- deactivate lots of other plugins while in this mode
- make sim ctrl a proper plugin
= make sim ctrl a proper plugin
- anything that accesses sim and looks up agents becomes weird!
- interpolate instead of storing everything

View File

@ -47,7 +47,9 @@ impl Plugin for ABTestManager {
let ((new_primary, new_primary_plugins), new_secondary) =
launch_test(test, ctx.kml, &ctx.primary.current_flags);
*ctx.primary = new_primary;
*ctx.new_primary_plugins = Some(new_primary_plugins);
ctx.primary_plugins.map(|p_plugins| {
*p_plugins = new_primary_plugins;
});
*ctx.secondary = Some(new_secondary);
new_state = Some(ABTestManager::Inactive);
}

View File

@ -48,7 +48,9 @@ impl Plugin for EditsManager {
}
if let Some((p, plugins)) = new_primary {
*ctx.primary = p;
*ctx.new_primary_plugins = Some(plugins);
ctx.primary_plugins.map(|p_plugins| {
*p_plugins = plugins;
});
}
}
}

View File

@ -257,7 +257,6 @@ impl PerMapUI {
Box::new(plugins::geom_validation::Validator::new()),
Box::new(plugins::draw_neighborhoods::DrawNeighborhoodState::new()),
Box::new(plugins::scenarios::ScenarioManager::new()),
Box::new(plugins::map_edits::EditsManager::new()),
Box::new(plugins::chokepoints::ChokepointsFinder::new()),
Box::new(neighborhood_summary),
],
@ -304,6 +303,7 @@ impl UI {
Box::new(plugins::diff_all::DiffAllState::new()),
Box::new(plugins::diff_worlds::DiffWorldsState::new()),
Box::new(plugins::road_editor::RoadEditor::new()),
Box::new(plugins::map_edits::EditsManager::new()),
Box::new(plugins::sim_controls::SimController::new()),
],
},
@ -447,7 +447,6 @@ impl UI {
}
fn run_plugin(&mut self, idx: usize, input: &mut UserInput, osd: &mut Text) -> bool {
let mut new_primary_plugins: Option<PluginsPerMap> = None;
let active = {
let mut ctx = PluginCtx {
primary: &mut self.primary,
@ -458,7 +457,6 @@ impl UI {
input,
osd,
kml: &self.kml,
new_primary_plugins: &mut new_primary_plugins,
};
let len = self.plugins.list.len();
if idx < len {
@ -468,9 +466,6 @@ impl UI {
self.primary_plugins.list[idx - len].event(ctx)
}
};
if let Some(new_plugins) = new_primary_plugins {
self.primary_plugins = new_plugins;
}
active
}
@ -530,8 +525,4 @@ pub struct PluginCtx<'a> {
pub input: &'a mut UserInput,
pub osd: &'a mut Text,
pub kml: &'a Option<String>,
// Unfortunately we have to use an output parameter here, but it's pretty isolated to
// run_plugin
pub new_primary_plugins: &'a mut Option<PluginsPerMap>,
}