diff --git a/apps/cli/scene_tool/Cargo.toml b/apps/cli/scene_tool/Cargo.toml index 3fb9f44..34b546d 100644 --- a/apps/cli/scene_tool/Cargo.toml +++ b/apps/cli/scene_tool/Cargo.toml @@ -7,6 +7,7 @@ edition.workspace = true [dependencies] clap = { workspace = true } grim = { workspace = true, features = [ "midi" ] } +simplelog = { workspace = true } thiserror = { workspace = true } [lints] diff --git a/apps/cli/scene_tool/src/apps/dir2milo.rs b/apps/cli/scene_tool/src/apps/dir2milo.rs index b08c604..5d37e5f 100644 --- a/apps/cli/scene_tool/src/apps/dir2milo.rs +++ b/apps/cli/scene_tool/src/apps/dir2milo.rs @@ -1,9 +1,9 @@ -use crate::apps::{SubApp}; +use crate::apps::SubApp; use clap::Parser; use std::error::Error; -use std::path::{Path}; +use std::path::Path; use grim::{Platform, SystemInfo}; diff --git a/apps/cli/scene_tool/src/apps/milo2dir.rs b/apps/cli/scene_tool/src/apps/milo2dir.rs index ba49530..9af21ae 100644 --- a/apps/cli/scene_tool/src/apps/milo2dir.rs +++ b/apps/cli/scene_tool/src/apps/milo2dir.rs @@ -9,7 +9,7 @@ use thiserror::Error; use grim::{Platform, SystemInfo}; use grim::io::*; use grim::scene::{Object, ObjectDir, PackedObject, Tex}; -use grim::texture::{write_rgba_to_file}; +use grim::texture::write_rgba_to_file; // TODO: Use this error somewhere or refactor #[derive(Debug, Error)] diff --git a/apps/cli/scene_tool/src/main.rs b/apps/cli/scene_tool/src/main.rs index e54efca..820c2fe 100644 --- a/apps/cli/scene_tool/src/main.rs +++ b/apps/cli/scene_tool/src/main.rs @@ -1,7 +1,26 @@ mod apps; use apps::SceneTool; +use simplelog::*; + +#[cfg(debug_assertions)] +const LOG_LEVEL: LevelFilter = LevelFilter::Debug; + +#[cfg(not(debug_assertions))] +const LOG_LEVEL: LevelFilter = LevelFilter::Info; fn main() -> Result<(), Box> { + let log_config = ConfigBuilder::new() + .add_filter_allow_str("grim") + .add_filter_allow_str("scene_tool") + .build(); + + // Setup logging + CombinedLogger::init( + vec![ + TermLogger::new(LOG_LEVEL, log_config, TerminalMode::Mixed, ColorChoice::Auto), + ] + )?; + let mut scene = SceneTool::new(); scene.run() } \ No newline at end of file diff --git a/core/grim/src/io/archive.rs b/core/grim/src/io/archive.rs index 1ac2259..7319df8 100644 --- a/core/grim/src/io/archive.rs +++ b/core/grim/src/io/archive.rs @@ -1,4 +1,4 @@ -use crate::{SystemInfo}; +use crate::SystemInfo; use crate::io::compression::*; use crate::io::stream::{BinaryStream, IOEndian, MemoryStream, SeekFrom, Stream}; use crate::scene::{Object, ObjectDir, ObjectDirBase, PackedObject}; @@ -156,6 +156,8 @@ impl MiloArchive { pub fn unpack_directory(&self, info: &SystemInfo) -> Result> { let mut stream = self.get_stream(); + let stream_size = stream.len().unwrap() as u64; + let stream = stream.as_mut(); let mut reader = BinaryStream::from_stream_with_endian(stream, info.endian); @@ -258,6 +260,10 @@ impl MiloArchive { } } + if stream.pos() < stream_size { + log::warn!("Read less data than length of milo file. Likely not parsed correctly."); + } + Ok(ObjectDir::ObjectDir(ObjectDirBase { entries: packed_entries .into_iter()