diff --git a/src/lib.rs b/src/lib.rs index 211eedb..3ef2f56 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,7 @@ mod scene; pub use colour::Colour; pub use config::Config; +pub use crate::image::Image; pub use music::Music; pub use palette::Palette; pub use scene::Scene; @@ -104,6 +105,9 @@ pub struct Position { pub struct Game { config: Config, palettes: Vec, + images: Vec, + // todo tiles + // todo things // variables: Vec, // triggers: HashMap, music: Vec, @@ -116,6 +120,7 @@ impl Game { pub fn from(path: String) -> Result { let path = PathBuf::from(path); + let mut images = Vec::new(); let mut music = Vec::new(); let mut palettes = Vec::new(); @@ -144,6 +149,18 @@ impl Game { println!("palette found: {:?}", file.file_name()); } + let mut images_dir = path.clone(); + images_dir.push("palettes"); + + let image_files = images_dir.read_dir() + .expect("couldn't read images dir"); + + for file in image_files { + let file = file.unwrap(); + images.push(Image::from_file(file.path())); + println!("image found: {:?}", file.file_name()); + } + let mut game_config = path.clone(); game_config.push("game.toml"); let config = fs::read_to_string(game_config) @@ -151,6 +168,6 @@ impl Game { let config: Config = toml::from_str(&config) .expect("Couldn't parse game config"); - Ok(Game { config, palettes, music }) + Ok(Game { config, images, palettes, music }) } }