gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 95ec5fd532dea6b90a02a98caa64b514d20ee169 parent d7bdbf9e39bff942e2fd380920a402f0197735b4 Author: Toxa <untoxa@mail.ru> Date: Thu, 18 Apr 2024 19:27:15 +0300 -rel_paths command line argument Diffstat:
5 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/gbdk-support/png2asset/main.cpp b/gbdk-support/png2asset/main.cpp @@ -27,6 +27,12 @@ using namespace std; +string extract_path(bool extract, string const & path, string const & name) +{ + int p = path.find_last_of("/\\"); + return ((extract) && (p > 0)) ? path.substr(0, p + 1) + name: name; +} + int main(int argc, char* argv[]) { int errorCode = 0; @@ -50,10 +56,9 @@ int main(int argc, char* argv[]) // Iterate through each source tileset and execute while (sourceTilesetFileNameIter < arguments.source_tilesets.end()) { - // Run with current source tileset filename arguments.processing_mode = MODE_SOURCE_TILESET; - errorCode = png2AssetInstance.Execute(&arguments, *sourceTilesetFileNameIter); + errorCode = png2AssetInstance.Execute(&arguments, extract_path(arguments.relative_paths, arguments.input_filename, *sourceTilesetFileNameIter)); // Return the error code if the function returns non-zero if(errorCode != 0) { @@ -77,10 +82,9 @@ int main(int argc, char* argv[]) // If there is an entity tileset if (!arguments.entity_tileset_filename.empty()) { - // Run with entity tileset filename arguments.processing_mode = MODE_ENTITY_TILESET; - errorCode = png2AssetInstance.Execute(&arguments, arguments.entity_tileset_filename); + errorCode = png2AssetInstance.Execute(&arguments, extract_path(arguments.relative_paths, arguments.input_filename, arguments.entity_tileset_filename)); // Return the error code if the function returns non-zero if(errorCode != 0) { diff --git a/gbdk-support/png2asset/maps.cpp b/gbdk-support/png2asset/maps.cpp @@ -82,8 +82,7 @@ void GetMap(PNG2AssetData* assetData) if (!FindTile(tile, idx, props, assetData->tiles, assetData)) { if (assetData->args->has_source_tilesets) { - printf("found a tile not in the source tileset at %d,%d. The target tileset has %d extra tiles.\n", x, y, (unsigned int)assetData->args->extra_tile_count + 1); - assetData->args->extra_tile_count++; + printf("found a tile not in the source tileset at %d,%d\n", x, y); assetData->args->includeTileData = true; } assetData->tiles.push_back(tile); diff --git a/gbdk-support/png2asset/metasprites.cpp b/gbdk-support/png2asset/metasprites.cpp @@ -51,8 +51,7 @@ void GetMetaSprite(int _x, int _y, int _w, int _h, int pivot_x, int pivot_y, PNG if(!FindTile(tile, idx, props, assetData->tiles, assetData)) { if (assetData->args->has_source_tilesets) { - printf("found a tile not in the source tileset at %d,%d. The target tileset has %d extra tiles.\n", x, y, (unsigned int)assetData->args->extra_tile_count + 1); - assetData->args->extra_tile_count++; + printf("found a tile not in the source tileset at %d,%d\n", x, y); assetData->args->includeTileData = true; } assetData->tiles.push_back(tile); diff --git a/gbdk-support/png2asset/process_arguments.cpp b/gbdk-support/png2asset/process_arguments.cpp @@ -69,7 +69,6 @@ int processPNG2AssetArguments(int argc, char* argv[], PNG2AssetArguments* args) args->props_default = 0; args->tile_origin = 0; // Default to no tile index offset - // args->extra_tile_count; args->source_total_color_count = 0; args->source_tileset_size = 0; args->has_source_tilesets = false; @@ -81,6 +80,7 @@ int processPNG2AssetArguments(int argc, char* argv[], PNG2AssetArguments* args) args->pack_mode = Tile::GB; args->map_entry_size_bytes = 1; + args->relative_paths = false; if(argc < 2) { @@ -124,6 +124,7 @@ int processPNG2AssetArguments(int argc, char* argv[], PNG2AssetArguments* args) printf("-bin export to binary format\n"); printf("-transposed export transposed (column-by-column instead of row-by-row)\n"); + printf("-rel_paths paths to tilesets are relative to the input file path\n"); return 0; } @@ -294,6 +295,7 @@ int processPNG2AssetArguments(int argc, char* argv[], PNG2AssetArguments* args) else if(!strcmp(argv[i], "-entity_tileset")) { args->entity_tileset_filename = argv[++i]; + args->has_entity_tileset = true; } else if(!strcmp(argv[i], "-bin")) { @@ -303,6 +305,9 @@ int processPNG2AssetArguments(int argc, char* argv[], PNG2AssetArguments* args) { args->output_transposed = true; } + else if(!strcmp(argv[i], "-rel_paths")) { + args->relative_paths = true; + } else { printf("Warning: Argument \"%s\" not recognized\n", argv[i]); } diff --git a/gbdk-support/png2asset/process_arguments.h b/gbdk-support/png2asset/process_arguments.h @@ -50,6 +50,7 @@ struct PNG2AssetArguments { bool include_palettes; bool use_structs; bool flip_tiles; + bool relative_paths; int errorCode; int bank; @@ -58,7 +59,6 @@ struct PNG2AssetArguments { int props_default; // Default Sprite props has no attributes enabled unsigned int tile_origin; // Default to no tile index offset - size_t extra_tile_count; size_t source_total_color_count; // Total number of colors (palette_count x colors_per_palette) unsigned int source_tileset_size; bool has_source_tilesets;
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.