organize abstutil paths internally a bit, inching towards organizing data/ dir

This commit is contained in:
Dustin Carlino 2019-12-03 11:15:17 -08:00
parent 71854bc959
commit 6695f72847
3 changed files with 61 additions and 64 deletions

View File

@ -39,82 +39,33 @@ macro_rules! skip_fail {
}; };
} }
// TODO Organize these // System data (Players can't edit, needed at runtime)
pub fn path_all_maps() -> String {
format!("../data/maps")
}
pub fn path_map(map_name: &str) -> String { pub fn path_map(map_name: &str) -> String {
format!("../data/maps/{}.bin", map_name) format!("../data/maps/{}.bin", map_name)
} }
pub fn path_all_maps() -> String {
pub fn path_polygon(polygon_name: &str) -> String { format!("../data/maps")
format!("../data/polygons/{}.poly", polygon_name)
}
pub fn path_raw_map(map_name: &str) -> String {
format!("../data/raw_maps/{}.bin", map_name)
}
pub fn path_fixes(name: &str) -> String {
format!("../data/fixes/{}.json", name)
}
pub fn path_camera_state(map_name: &str) -> String {
format!("../data/camera_state/{}.json", map_name)
}
pub fn path_pending_screenshots(map_name: &str) -> String {
format!("../data/screenshots/pending_{}", map_name)
} }
pub fn path_prebaked_results(map_name: &str) -> String { pub fn path_prebaked_results(map_name: &str) -> String {
format!("../data/prebaked_results/{}.bin", map_name) format!("../data/prebaked_results/{}.bin", map_name)
} }
pub fn path_all_shortcuts() -> String { pub fn path_scenario(map_name: &str, scenario_name: &str) -> String {
format!("../data/shortcuts") format!("../data/scenarios/{}/{}.bin", map_name, scenario_name)
} }
pub fn path_shortcut(name: &str) -> String {
format!("../data/shortcuts/{}.json", name)
}
pub fn path_all_scenarios(map_name: &str) -> String { pub fn path_all_scenarios(map_name: &str) -> String {
format!("../data/scenarios/{}", map_name) format!("../data/scenarios/{}", map_name)
} }
pub fn path_scenario(map_name: &str, scenario_name: &str) -> String { // Player data (Players edit this)
format!("../data/scenarios/{}/{}.bin", map_name, scenario_name)
}
pub fn path_all_edits(map_name: &str) -> String {
format!("../data/edits/{}", map_name)
}
pub fn path_edits(map_name: &str, edits_name: &str) -> String {
format!("../data/edits/{}/{}.json", map_name, edits_name)
}
pub fn path_all_neighborhoods(map_name: &str) -> String {
format!("../data/neighborhoods/{}", map_name)
}
pub fn path_neighborhood(map_name: &str, neighborhood: &str) -> String {
format!("../data/neighborhoods/{}/{}.json", map_name, neighborhood)
}
pub fn path_all_ab_tests(map_name: &str) -> String {
format!("../data/ab_tests/{}", map_name)
}
pub fn path_ab_test(map_name: &str, test_name: &str) -> String { pub fn path_ab_test(map_name: &str, test_name: &str) -> String {
format!("../data/ab_tests/{}/{}.json", map_name, test_name) format!("../data/ab_tests/{}/{}.json", map_name, test_name)
} }
pub fn path_all_ab_tests(map_name: &str) -> String {
pub fn path_all_ab_test_saves(map_name: &str, test_name: &str) -> String { format!("../data/ab_tests/{}", map_name)
format!("../data/ab_test_saves/{}/{}", map_name, test_name)
} }
pub fn path_ab_test_save(map_name: &str, test_name: &str, time: String) -> String { pub fn path_ab_test_save(map_name: &str, test_name: &str, time: String) -> String {
@ -123,13 +74,19 @@ pub fn path_ab_test_save(map_name: &str, test_name: &str, time: String) -> Strin
map_name, test_name, time map_name, test_name, time
) )
} }
pub fn path_all_ab_test_saves(map_name: &str, test_name: &str) -> String {
pub fn path_popdat() -> String { format!("../data/ab_test_saves/{}/{}", map_name, test_name)
format!("../data/shapes/popdat.bin")
} }
pub fn path_all_saves(map_name: &str, edits_name: &str, run_name: &str) -> String { pub fn path_camera_state(map_name: &str) -> String {
format!("../data/saves/{}/{}_{}", map_name, edits_name, run_name) format!("../data/camera_state/{}.json", map_name)
}
pub fn path_edits(map_name: &str, edits_name: &str) -> String {
format!("../data/edits/{}/{}.json", map_name, edits_name)
}
pub fn path_all_edits(map_name: &str) -> String {
format!("../data/edits/{}", map_name)
} }
pub fn path_save(map_name: &str, edits_name: &str, run_name: &str, time: String) -> String { pub fn path_save(map_name: &str, edits_name: &str, run_name: &str, time: String) -> String {
@ -138,3 +95,42 @@ pub fn path_save(map_name: &str, edits_name: &str, run_name: &str, time: String)
map_name, edits_name, run_name, time map_name, edits_name, run_name, time
) )
} }
pub fn path_all_saves(map_name: &str, edits_name: &str, run_name: &str) -> String {
format!("../data/saves/{}/{}_{}", map_name, edits_name, run_name)
}
pub fn path_shortcut(name: &str) -> String {
format!("../data/shortcuts/{}.json", name)
}
pub fn path_all_shortcuts() -> String {
format!("../data/shortcuts")
}
// Input data (For developers to build maps, not needed at runtime)
pub fn path_fixes(name: &str) -> String {
format!("../data/fixes/{}.json", name)
}
pub fn path_neighborhood(map_name: &str, neighborhood: &str) -> String {
format!("../data/neighborhoods/{}/{}.json", map_name, neighborhood)
}
pub fn path_all_neighborhoods(map_name: &str) -> String {
format!("../data/neighborhoods/{}", map_name)
}
pub fn path_pending_screenshots(map_name: &str) -> String {
format!("../data/screenshots/pending_{}", map_name)
}
pub fn path_polygon(polygon_name: &str) -> String {
format!("../data/polygons/{}.poly", polygon_name)
}
pub fn path_popdat() -> String {
format!("../data/shapes/popdat.bin")
}
pub fn path_raw_map(map_name: &str) -> String {
format!("../data/raw_maps/{}.bin", map_name)
}

View File

@ -261,8 +261,8 @@ impl<'a, 'b> WrappedWizard<'a, 'b> {
let choices: Vec<Choice<R>> = choices_generator(); let choices: Vec<Choice<R>> = choices_generator();
if choices.is_empty() { if choices.is_empty() {
self.wizard.log_scroller = Some(LogScroller::new( self.wizard.log_scroller = Some(LogScroller::new(
"Wizard".to_string(), query.to_string(),
vec![format!("No choices for \"{}\", canceling wizard", query)], vec!["No choices, never mind".to_string()],
)); ));
return None; return None;
} }

View File

@ -2,6 +2,7 @@ use crate::game::{State, Transition, WizardState};
use ezgui::Choice; use ezgui::Choice;
// TODO SimOptions stuff too // TODO SimOptions stuff too
// TODO Move dev mode here
#[derive(Clone)] #[derive(Clone)]
pub struct Options { pub struct Options {
pub traffic_signal_style: TrafficSignalStyle, pub traffic_signal_style: TrafficSignalStyle,