|
|
|
@ -46,7 +46,17 @@ impl Tweaks {
|
|
|
|
.filter_map(|(k, v)| match v {
|
|
|
|
.filter_map(|(k, v)| match v {
|
|
|
|
toml::Value::String(s) => std::path::Path::new(format!("assets/{}", s).as_str())
|
|
|
|
toml::Value::String(s) => std::path::Path::new(format!("assets/{}", s).as_str())
|
|
|
|
.exists()
|
|
|
|
.exists()
|
|
|
|
.then(|| (k.clone(), load_context.load_untyped(s).untyped())),
|
|
|
|
.then(|| {
|
|
|
|
|
|
|
|
if s.ends_with(".gltf") || s.ends_with(".glb") {
|
|
|
|
|
|
|
|
Some(load_context.load::<Gltf>(s).untyped())
|
|
|
|
|
|
|
|
} else if s.ends_with(".png") {
|
|
|
|
|
|
|
|
Some(load_context.load::<Image>(s).untyped())
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).flatten().map(|h| {
|
|
|
|
|
|
|
|
(k.clone(), h)
|
|
|
|
|
|
|
|
}),
|
|
|
|
_ => None,
|
|
|
|
_ => None,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.collect();
|
|
|
|
.collect();
|
|
|
|
@ -69,8 +79,10 @@ impl Tweaks {
|
|
|
|
|
|
|
|
|
|
|
|
pub fn get<'de, T: Deserialize<'de>>(&self, key: &str) -> Option<T> {
|
|
|
|
pub fn get<'de, T: Deserialize<'de>>(&self, key: &str) -> Option<T> {
|
|
|
|
Tweaks::locate(&self.table, key)
|
|
|
|
Tweaks::locate(&self.table, key)
|
|
|
|
.map(|val| val.try_into().ok())
|
|
|
|
.map(|val| match val.try_into() {
|
|
|
|
.flatten()
|
|
|
|
Ok(val) => val,
|
|
|
|
|
|
|
|
Err(e) => panic!("{}", e.message())
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn iter_all(t: &toml::Table, key: &str) -> Vec<(String, toml::Value)> {
|
|
|
|
fn iter_all(t: &toml::Table, key: &str) -> Vec<(String, toml::Value)> {
|
|
|
|
|