summaryrefslogtreecommitdiff
path: root/tools/src/asset_processor/assets/map.cpp
blob: 2d5a0bca6958f985bdb4b8a94e7eef77fe2f26ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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";
}