mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 19:27:11 +03:00
dont reload prebaked data unnecessarily [rebuild]
This commit is contained in:
parent
935e42aee6
commit
1cd7629dfa
@ -257,7 +257,7 @@ impl Overlays {
|
||||
ctx,
|
||||
)),
|
||||
];
|
||||
if !ui.has_prebaked() {
|
||||
if ui.has_prebaked().is_none() {
|
||||
choices.retain(|w| !w.has_name("finished trips histogram"));
|
||||
}
|
||||
// TODO Grey out the inactive SVGs, and add the green checkmark
|
||||
@ -568,7 +568,7 @@ impl Overlays {
|
||||
}
|
||||
|
||||
pub fn finished_trips_histogram(ctx: &mut EventCtx, ui: &UI) -> Overlays {
|
||||
if !ui.has_prebaked() {
|
||||
if ui.has_prebaked().is_none() {
|
||||
return Overlays::Inactive;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ pub fn make(ctx: &mut EventCtx, ui: &UI, tab: Tab) -> Box<dyn State> {
|
||||
}
|
||||
|
||||
fn finished_trips_summary_prebaked(ctx: &EventCtx, ui: &UI) -> ManagedWidget {
|
||||
if !ui.has_prebaked() {
|
||||
if ui.has_prebaked().is_none() {
|
||||
return finished_trips_summary_not_prebaked(ctx, ui);
|
||||
}
|
||||
|
||||
|
@ -161,17 +161,31 @@ impl GameplayMode {
|
||||
);
|
||||
ui.primary.sim.step(&ui.primary.map, Duration::seconds(0.1));
|
||||
|
||||
// If there's no prebaked data, so be it; some functionality disappears
|
||||
if let Ok(prebaked) = abstutil::maybe_read_binary::<Analytics>(
|
||||
abstutil::path_prebaked_results(&scenario.map_name, &scenario.scenario_name),
|
||||
timer,
|
||||
) {
|
||||
ui.set_prebaked(Some(prebaked));
|
||||
} else {
|
||||
println!(
|
||||
"WARNING: No prebaked results for {} on {}, some stuff might break",
|
||||
scenario.scenario_name, scenario.map_name
|
||||
);
|
||||
// Maybe we've already got prebaked data for this map+scenario.
|
||||
if !ui
|
||||
.has_prebaked()
|
||||
.map(|(m, s)| m == &scenario.map_name && s == &scenario.scenario_name)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
// If there's no prebaked data, so be it; some functionality disappears
|
||||
if let Ok(prebaked) = abstutil::maybe_read_binary::<Analytics>(
|
||||
abstutil::path_prebaked_results(
|
||||
&scenario.map_name,
|
||||
&scenario.scenario_name,
|
||||
),
|
||||
timer,
|
||||
) {
|
||||
ui.set_prebaked(Some((
|
||||
scenario.map_name.clone(),
|
||||
scenario.scenario_name.clone(),
|
||||
prebaked,
|
||||
)));
|
||||
} else {
|
||||
println!(
|
||||
"WARNING: No prebaked results for {} on {}, some stuff might break",
|
||||
scenario.scenario_name, scenario.map_name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -17,8 +17,9 @@ pub struct UI {
|
||||
pub primary: PerMapUI,
|
||||
// Invariant: This is Some(...) iff we're in A/B test mode or a sub-state.
|
||||
pub secondary: Option<PerMapUI>,
|
||||
// Only exists in some gameplay modes. Must be carefully reset otherwise.
|
||||
prebaked: Option<Analytics>,
|
||||
// Only exists in some gameplay modes. Must be carefully reset otherwise. Has the map and
|
||||
// scenario name too. TODO Embed that in Analytics directly instead.
|
||||
prebaked: Option<(String, String, Analytics)>,
|
||||
pub cs: ColorScheme,
|
||||
// TODO This is a bit weird to keep here; it's controlled almost entirely by the minimap panel.
|
||||
// It has no meaning in edit mode.
|
||||
@ -86,13 +87,13 @@ impl UI {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_prebaked(&self) -> bool {
|
||||
self.prebaked.is_some()
|
||||
pub fn has_prebaked(&self) -> Option<(&String, &String)> {
|
||||
self.prebaked.as_ref().map(|(m, s, _)| (m, s))
|
||||
}
|
||||
pub fn prebaked(&self) -> &Analytics {
|
||||
self.prebaked.as_ref().unwrap()
|
||||
&self.prebaked.as_ref().unwrap().2
|
||||
}
|
||||
pub fn set_prebaked(&mut self, prebaked: Option<Analytics>) {
|
||||
pub fn set_prebaked(&mut self, prebaked: Option<(String, String, Analytics)>) {
|
||||
self.prebaked = prebaked;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user