diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2022-12-06 17:00:46 +0100 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2022-12-06 17:00:46 +0100 |
| commit | 80b66166f57ddca9dec06fbec6e621b1771e3cca (patch) | |
| tree | 5b75135ff8034f0e08a37275f9bba368882798d4 /tools/src/asset_processor/assets/map.cpp | |
| parent | 03408debcd86ef85aa02a85680b4ebc26e53efb9 (diff) | |
Decompress map assets
Diffstat (limited to 'tools/src/asset_processor/assets/map.cpp')
| -rw-r--r-- | tools/src/asset_processor/assets/map.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/src/asset_processor/assets/map.cpp b/tools/src/asset_processor/assets/map.cpp new file mode 100644 index 00000000..2d5a0bca --- /dev/null +++ b/tools/src/asset_processor/assets/map.cpp @@ -0,0 +1,44 @@ +#include "map.h" +#include "util.h" +#include <nlohmann/json.hpp> + +std::filesystem::path MapAsset::generateAssetPath() { + std::filesystem::path decompressedPath = path; + if (isCompressed()) { + if (decompressedPath.extension() == ".lz") { + decompressedPath.replace_extension(""); + } + } + return decompressedPath; +} + + +void MapAsset::convertToHumanReadable(const std::vector<char>& baserom) { + (void)baserom; + if (isCompressed()) { + std::filesystem::path toolsPath = "tools"; + std::vector<std::string> cmd; + // Decompress. + cmd.push_back(toolsPath / "bin" / "gbagfx"); + cmd.push_back(path); + cmd.push_back(assetPath); + check_call(cmd); + } +} + +void MapAsset::buildToBinary() { + if (isCompressed()) { + std::filesystem::path toolsPath = "tools"; + std::vector<std::string> cmd; + // Compress. + cmd.push_back(toolsPath / "bin" / "gbagfx"); + cmd.push_back(assetPath); + cmd.push_back(path); + check_call(cmd); + } + +} + +bool MapAsset::isCompressed() { + return path.extension() == ".lz"; +}
\ No newline at end of file |
