Create an early scripting engine #2

Merged
SeanOMik merged 42 commits from feature/early-scripting into main 2024-03-03 03:28:57 +00:00
1 changed files with 5 additions and 4 deletions
Showing only changes of commit 639ec0ee42 - Show all commits

View File

@ -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()));
} }
} }