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
pub fn path_all_maps() -> String {
format!("../data/maps")
}
// System data (Players can't edit, needed at runtime)
pub fn path_map(map_name: &str) -> String {
format!("../data/maps/{}.bin", map_name)
}
pub fn path_polygon(polygon_name: &str) -> String {
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_all_maps() -> String {
format!("../data/maps")
}
pub fn path_prebaked_results(map_name: &str) -> String {
format!("../data/prebaked_results/{}.bin", map_name)
}
pub fn path_all_shortcuts() -> String {
format!("../data/shortcuts")
pub fn path_scenario(map_name: &str, scenario_name: &str) -> String {
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 {
format!("../data/scenarios/{}", map_name)
}
pub fn path_scenario(map_name: &str, scenario_name: &str) -> String {
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)
}
// Player data (Players edit this)
pub fn path_ab_test(map_name: &str, test_name: &str) -> String {
format!("../data/ab_tests/{}/{}.json", map_name, test_name)
}
pub fn path_all_ab_test_saves(map_name: &str, test_name: &str) -> String {
format!("../data/ab_test_saves/{}/{}", map_name, test_name)
pub fn path_all_ab_tests(map_name: &str) -> String {
format!("../data/ab_tests/{}", map_name)
}
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
)
}
pub fn path_popdat() -> String {
format!("../data/shapes/popdat.bin")
pub fn path_all_ab_test_saves(map_name: &str, test_name: &str) -> String {
format!("../data/ab_test_saves/{}/{}", map_name, test_name)
}
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_camera_state(map_name: &str) -> String {
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 {
@ -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
)
}
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();
if choices.is_empty() {
self.wizard.log_scroller = Some(LogScroller::new(
"Wizard".to_string(),
vec![format!("No choices for \"{}\", canceling wizard", query)],
query.to_string(),
vec!["No choices, never mind".to_string()],
));
return None;
}

View File

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