From 62a762515d78759e64098b304fca8f74b0dde2f7 Mon Sep 17 00:00:00 2001 From: ashley Date: Sun, 17 Sep 2023 22:48:50 -0400 Subject: [PATCH] Export levels with width, height, and number of tiles --- src/reskit/cli/evaluator.rs | 4 ++-- src/reskit/cli/settings.rs | 6 +----- src/reskit/level/system.rs | 9 +++++++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/reskit/cli/evaluator.rs b/src/reskit/cli/evaluator.rs index f11943a..7fbcf31 100644 --- a/src/reskit/cli/evaluator.rs +++ b/src/reskit/cli/evaluator.rs @@ -65,7 +65,7 @@ pub fn run_command() -> Result<(), Box> { print_good( "all files converted successfully" ); } - Tools::Level { input_file, output_directory, console, tile_size } => { + Tools::Level { input_file, output_directory, console: _ } => { let tiled_file = get_tiled_tilemap( &input_file )?; // Get tile and palette files @@ -80,7 +80,7 @@ pub fn run_command() -> Result<(), Box> { print_good( "exported palettes.pal" ); let mut code_asm = File::create( format!( "{}level.asm", output_directory ) )?; - code_asm.write_all( &get_code( "testlevel", "levels/" )?.as_bytes() )?; + code_asm.write_all( &get_code( &tiled_file, "testlevel", "levels/" )?.as_bytes() )?; print_good( "exported level.asm" ); } }; diff --git a/src/reskit/cli/settings.rs b/src/reskit/cli/settings.rs index 9b6d0e9..c23281e 100644 --- a/src/reskit/cli/settings.rs +++ b/src/reskit/cli/settings.rs @@ -111,10 +111,6 @@ pub enum Tools { /// Console system type #[arg(short, long, value_enum, default_value_t=SystemType::Md)] - console: SystemType, - - /// Tile Size ("WxH" format) - #[arg(long, default_value_t=String::from( "2x2" ))] - tile_size: String + console: SystemType } } \ No newline at end of file diff --git a/src/reskit/level/system.rs b/src/reskit/level/system.rs index 0ef7981..9c02a76 100644 --- a/src/reskit/level/system.rs +++ b/src/reskit/level/system.rs @@ -168,9 +168,11 @@ pub fn get_collision_map( tilemap: &TiledTilemap ) -> Result, Box Result> { +pub fn get_code( tilemap: &TiledTilemap, level_name: &str, path_prefix: &str ) -> Result> { let version = env!( "CARGO_PKG_VERSION" ); let level_label = symbol_to_pascal( level_name ); + let ( width, height ) = ( tilemap.width, tilemap.height ); + let num_tiles = ( tilemap.tileset.image.width() / 8 ) * ( tilemap.tileset.image.height() / 8 ); // --system md let file = format!( r#"; Level definition file ; Generated by reskit v{version} @@ -180,7 +182,10 @@ pub fn get_code( level_name: &str, path_prefix: &str ) -> Result