diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2024-01-06 14:59:48 +0100 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2024-01-06 15:01:44 +0100 |
| commit | aced0bef691dbc41bdd39b6e62662d2436877a4b (patch) | |
| tree | e90f9fd8e4c4c3471c2fb246bb1372974294b469 /tools/src/asset_processor/assets/subtileset.cpp | |
| parent | c3b771a20923b335bbea2ab97a68ac29d04fcc43 (diff) | |
Rename metaTiles
Now the 16x16 tiles are just called tiles and the 8x8 tiles are called subTiles.
Diffstat (limited to 'tools/src/asset_processor/assets/subtileset.cpp')
| -rw-r--r-- | tools/src/asset_processor/assets/subtileset.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tools/src/asset_processor/assets/subtileset.cpp b/tools/src/asset_processor/assets/subtileset.cpp new file mode 100644 index 00000000..02b52b2a --- /dev/null +++ b/tools/src/asset_processor/assets/subtileset.cpp @@ -0,0 +1,66 @@ +#include "subtileset.h" +#include "util.h" + +std::filesystem::path SubTileSetAsset::generateAssetPath() { + std::filesystem::path pngPath = path; + if (pngPath.extension() == ".lz") { + pngPath.replace_extension(""); + } + pngPath.replace_extension(".png"); + return pngPath; +} + +void SubTileSetAsset::convertToHumanReadable(const std::vector<char>& baserom) { + (void)baserom; + + std::filesystem::path toolsPath = "tools"; + std::vector<std::string> cmd; + + std::filesystem::path decompressedPath = path; + + if (isCompressed()) { + // First decompress. + decompressedPath.replace_extension(""); + cmd.push_back(toolsPath / "bin" / "gbagfx"); + cmd.push_back(path); + cmd.push_back(decompressedPath); + check_call(cmd); + cmd.clear(); + } + + cmd.push_back(toolsPath / "bin" / "gbagfx"); + cmd.push_back(decompressedPath); + cmd.push_back(assetPath); + // This creates a better looking tilemap but in some cases not all tiles are used, so it adds additional data when converting back to binary. + //cmd.push_back("-mwidth"); + //cmd.push_back("32"); + check_call(cmd); +} + +void SubTileSetAsset::buildToBinary() { + std::filesystem::path toolsPath = "tools"; + std::vector<std::string> cmd; + + std::filesystem::path decompressedPath = path; + if (isCompressed()) { + decompressedPath.replace_extension(""); + } + + cmd.push_back(toolsPath / "bin" / "gbagfx"); + cmd.push_back(assetPath); + cmd.push_back(decompressedPath); + check_call(cmd); + + if (isCompressed()) { + // Compress. + cmd.clear(); + cmd.push_back(toolsPath / "bin" / "gbagfx"); + cmd.push_back(decompressedPath); + cmd.push_back(path); + check_call(cmd); + } +} + +bool SubTileSetAsset::isCompressed() { + return path.extension() == ".lz"; +}
\ No newline at end of file |
