Create an early scripting engine #2
|
@ -237,6 +237,7 @@ impl ResourceManager {
|
||||||
let path = resource.path();
|
let path = resource.path();
|
||||||
if let Some(loader) = self.loaders.iter()
|
if let Some(loader) = self.loaders.iter()
|
||||||
.find(|l| l.does_support_file(&path)) {
|
.find(|l| l.does_support_file(&path)) {
|
||||||
|
println!("got loader");
|
||||||
let loader = Arc::clone(loader); // stop borrowing from self
|
let loader = Arc::clone(loader); // stop borrowing from self
|
||||||
let loaded = loader.load(self, &path)?;
|
let loaded = loader.load(self, &path)?;
|
||||||
let loaded = loaded.as_arc_any();
|
let loaded = loaded.as_arc_any();
|
||||||
|
@ -325,6 +326,7 @@ mod tests {
|
||||||
let img = res.try_data_ref();
|
let img = res.try_data_ref();
|
||||||
img.unwrap();
|
img.unwrap();
|
||||||
|
|
||||||
|
println!("Path = {}", res.path());
|
||||||
man.reload(res.clone()).unwrap();
|
man.reload(res.clone()).unwrap();
|
||||||
assert_eq!(res.version(), 1);
|
assert_eq!(res.version(), 1);
|
||||||
|
|
||||||
|
@ -334,8 +336,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn watch_image() {
|
fn watch_image() {
|
||||||
let image_path = get_image("squiggles.png");
|
let orig_path = get_image("squiggles.png");
|
||||||
let image_bytes = std::fs::read(&image_path).unwrap();
|
let image_path = get_image("squiggles_test.png");
|
||||||
|
std::fs::copy(orig_path, &image_path).unwrap();
|
||||||
|
|
||||||
let mut man = ResourceManager::new();
|
let mut man = ResourceManager::new();
|
||||||
let res = man.request::<Texture>(&image_path).unwrap();
|
let res = man.request::<Texture>(&image_path).unwrap();
|
||||||
|
@ -350,8 +353,6 @@ mod tests {
|
||||||
let event = recv.recv().unwrap();
|
let event = recv.recv().unwrap();
|
||||||
let event = event.unwrap();
|
let event = event.unwrap();
|
||||||
|
|
||||||
std::fs::write(image_path, image_bytes).unwrap();
|
|
||||||
|
|
||||||
assert!(event.iter().any(|ev| ev.kind.is_remove() || ev.kind.is_modify()));
|
assert!(event.iter().any(|ev| ev.kind.is_remove() || ev.kind.is_modify()));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue