mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 17:37:22 +03:00
er, stripping .json vs not...
This commit is contained in:
parent
307318a62e
commit
fcf0366e90
@ -124,14 +124,20 @@ pub fn list_all_objects(dir: &str, map_name: &str) -> Vec<(String, String)> {
|
||||
results.into_iter().collect()
|
||||
}
|
||||
|
||||
// Load all serialized things from a directory, return sorted by name.
|
||||
// Load all serialized things from a directory, return sorted by name, with file extension removed.
|
||||
pub fn load_all_objects<T: DeserializeOwned>(dir: &str, map_name: &str) -> Vec<(String, T)> {
|
||||
let mut tree: BTreeMap<String, T> = BTreeMap::new();
|
||||
match std::fs::read_dir(format!("../data/{}/{}/", dir, map_name)) {
|
||||
Ok(iter) => {
|
||||
for entry in iter {
|
||||
let name = entry.unwrap().file_name().into_string().unwrap();
|
||||
let load: T = read_json(&format!("../data/{}/{}/{}", dir, map_name, name)).unwrap();
|
||||
let name = Path::new(&entry.unwrap().file_name())
|
||||
.file_stem()
|
||||
.unwrap()
|
||||
.to_os_string()
|
||||
.into_string()
|
||||
.unwrap();
|
||||
let load: T =
|
||||
read_json(&format!("../data/{}/{}/{}.json", dir, map_name, name)).unwrap();
|
||||
tree.insert(name, load);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ impl ABTestManager {
|
||||
ABTestManager::ManageABTest(test, ref mut scroller) => {
|
||||
if input.key_pressed(Key::R, "run this A/B test") {
|
||||
new_ui = Some(launch_test(test, kml));
|
||||
new_state = Some(ABTestManager::Inactive);
|
||||
}
|
||||
if scroller.event(input) {
|
||||
new_state = Some(ABTestManager::Inactive);
|
||||
|
Loading…
Reference in New Issue
Block a user