Export levels with width, height, and number of tiles
parent
de5868305d
commit
62a762515d
|
@ -65,7 +65,7 @@ pub fn run_command() -> Result<(), Box<dyn Error>> {
|
|||
|
||||
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<dyn Error>> {
|
|||
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" );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -168,9 +168,11 @@ pub fn get_collision_map( tilemap: &TiledTilemap ) -> Result<Vec<u8>, Box<dyn Er
|
|||
/**
|
||||
* Get a helper .asm or .c file that ties all the level components together
|
||||
*/
|
||||
pub fn get_code( level_name: &str, path_prefix: &str ) -> Result<String, Box<dyn Error>> {
|
||||
pub fn get_code( tilemap: &TiledTilemap, level_name: &str, path_prefix: &str ) -> Result<String, Box<dyn Error>> {
|
||||
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<String, Box<dyn
|
|||
{level_label}Palettes:
|
||||
incbin '{path_prefix}{level_name}/palettes.pal'
|
||||
|
||||
"# );
|
||||
{level_label}:
|
||||
dc.w {width}, {height}, {num_tiles}
|
||||
dc.l {level_label}Tiles
|
||||
dc.l {level_label}Palettes"# );
|
||||
|
||||
Ok( file )
|
||||
}
|
Loading…
Reference in New Issue