mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-25 11:44:25 +03:00
simplify UI state a bit... dont plumb around extra KML shapes to display. if we load an A/B test or different map edits, no need to preserve the KML; its for one-off debugging.
This commit is contained in:
parent
4b7a424b1f
commit
8e715de098
@ -501,3 +501,7 @@ First simplify UI in smaller ways.
|
||||
- and between drawing and mousing over, dont recalculate all of the DrawCar/Ped stuff!
|
||||
|
||||
- stop doing the generic plugin stuff in UI. be direct, since we have very few "plugins".
|
||||
|
||||
|
||||
|
||||
Tutorial mode needs to wrap the other stuff (and omit DebugMode!) to reach into SimMode and install a callback. Forces us back to this problem again. Radical idea: What state and code in UI is even important to preserve? Should TutorialMode literally be a new UI impl?
|
||||
|
@ -39,7 +39,7 @@ impl Plugin for ABTestManager {
|
||||
ABTestManager::ManageABTest(test, ref mut scroller) => {
|
||||
if ctx.input.key_pressed(Key::R, "run this A/B test") {
|
||||
let ((new_primary, new_primary_plugins), new_secondary) =
|
||||
launch_test(test, ctx.kml, &ctx.primary.current_flags, &ctx.canvas);
|
||||
launch_test(test, &ctx.primary.current_flags, &ctx.canvas);
|
||||
*ctx.primary = new_primary;
|
||||
if let Some(p_plugins) = ctx.primary_plugins.as_mut() {
|
||||
**p_plugins = new_primary_plugins;
|
||||
@ -90,7 +90,6 @@ fn pick_ab_test(map: &Map, mut wizard: WrappedWizard) -> Option<ABTest> {
|
||||
|
||||
fn launch_test(
|
||||
test: &ABTest,
|
||||
kml: &Option<String>,
|
||||
current_flags: &SimFlags,
|
||||
canvas: &Canvas,
|
||||
) -> ((PerMapUI, PluginsPerMap), (PerMapUI, PluginsPerMap)) {
|
||||
@ -112,7 +111,7 @@ fn launch_test(
|
||||
run_name: format!("{} with {}", test.test_name, test.edits1_name),
|
||||
edits_name: test.edits1_name.clone(),
|
||||
},
|
||||
kml,
|
||||
None,
|
||||
canvas,
|
||||
);
|
||||
let secondary = PerMapUI::new(
|
||||
@ -122,7 +121,7 @@ fn launch_test(
|
||||
run_name: format!("{} with {}", test.test_name, test.edits2_name),
|
||||
edits_name: test.edits2_name.clone(),
|
||||
},
|
||||
kml,
|
||||
None,
|
||||
canvas,
|
||||
);
|
||||
// That's all! The scenario will be instantiated.
|
||||
|
@ -32,7 +32,6 @@ impl Plugin for EditsManager {
|
||||
if manage_edits(
|
||||
&mut ctx.primary.current_flags,
|
||||
&ctx.primary.map,
|
||||
ctx.kml,
|
||||
&mut new_primary,
|
||||
&ctx.canvas,
|
||||
self.wizard.wrap(ctx.input),
|
||||
@ -59,7 +58,6 @@ impl Plugin for EditsManager {
|
||||
fn manage_edits(
|
||||
current_flags: &mut SimFlags,
|
||||
map: &Map,
|
||||
kml: &Option<String>,
|
||||
new_primary: &mut Option<(PerMapUI, PluginsPerMap)>,
|
||||
canvas: &Canvas,
|
||||
mut wizard: WrappedWizard,
|
||||
@ -101,7 +99,7 @@ fn manage_edits(
|
||||
flags.edits_name = load_name;
|
||||
|
||||
info!("Reloading everything...");
|
||||
*new_primary = Some(PerMapUI::new(flags, kml, canvas));
|
||||
*new_primary = Some(PerMapUI::new(flags, None, canvas));
|
||||
Some(())
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
@ -47,7 +47,6 @@ pub struct PluginCtx<'a> {
|
||||
pub cs: &'a mut ColorScheme,
|
||||
pub input: &'a mut UserInput,
|
||||
pub hints: &'a mut RenderingHints,
|
||||
pub kml: &'a Option<String>,
|
||||
}
|
||||
|
||||
// TODO Further refactoring should be done, but at least group these here to start.
|
||||
|
@ -29,9 +29,6 @@ pub struct UI {
|
||||
|
||||
canvas: Canvas,
|
||||
cs: ColorScheme,
|
||||
|
||||
// Remember this to support loading a new PerMapUI
|
||||
kml: Option<String>,
|
||||
}
|
||||
|
||||
impl GUI<RenderingHints> for UI {
|
||||
@ -173,7 +170,7 @@ pub struct PerMapUI {
|
||||
impl PerMapUI {
|
||||
pub fn new(
|
||||
flags: SimFlags,
|
||||
kml: &Option<String>,
|
||||
kml: Option<String>,
|
||||
canvas: &Canvas,
|
||||
) -> (PerMapUI, PluginsPerMap) {
|
||||
let mut timer = abstutil::Timer::new("setup PerMapUI");
|
||||
@ -219,7 +216,7 @@ impl UI {
|
||||
let plugins = PluginsPerUI::new(&flags);
|
||||
|
||||
let canvas = Canvas::new();
|
||||
let (primary, primary_plugins) = PerMapUI::new(flags, &kml, &canvas);
|
||||
let (primary, primary_plugins) = PerMapUI::new(flags, kml, &canvas);
|
||||
let mut ui = UI {
|
||||
primary,
|
||||
primary_plugins,
|
||||
@ -231,8 +228,6 @@ impl UI {
|
||||
|
||||
canvas,
|
||||
cs: ColorScheme::load().unwrap(),
|
||||
|
||||
kml,
|
||||
};
|
||||
|
||||
match abstutil::read_json::<EditorState>("editor_state") {
|
||||
@ -323,7 +318,6 @@ impl UI {
|
||||
cs: &mut self.cs,
|
||||
input,
|
||||
hints,
|
||||
kml: &self.kml,
|
||||
};
|
||||
let len = self.plugins.list.len();
|
||||
if idx < len {
|
||||
|
Loading…
Reference in New Issue
Block a user