diff options
| -rw-r--r-- | ZAPD/Globals.cpp | 20 | ||||
| -rw-r--r-- | ZAPD/Globals.h | 2 | ||||
| -rw-r--r-- | ZAPD/ImageBackend.cpp | 2 | ||||
| -rw-r--r-- | ZAPD/Main.cpp | 21 | ||||
| -rw-r--r-- | ZAPD/ZTexture.cpp | 2 |
5 files changed, 30 insertions, 17 deletions
diff --git a/ZAPD/Globals.cpp b/ZAPD/Globals.cpp index 455205b..5fbc420 100644 --- a/ZAPD/Globals.cpp +++ b/ZAPD/Globals.cpp @@ -119,6 +119,26 @@ void Globals::AddExternalFile(ZFile* file, int workerID) workerData[workerID]->externalFiles.push_back(file); } +void Globals::BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath) +{ + std::string name = outPath.stem().string(); + + ZTexture tex(nullptr); + + if (name.find("u32") != std::string::npos) + tex.dWordAligned = false; + + tex.FromPNG(pngFilePath.string(), texType); + std::string cfgPath = StringHelper::Split(pngFilePath.string(), ".")[0] + ".cfg"; + + if (File::Exists(cfgPath)) + name = File::ReadAllText(cfgPath); + + std::string src = tex.GetBodySourceCode(); + + File::WriteAllText(outPath.string(), src); +} + std::map<std::string, ExporterSet*>& Globals::GetExporterMap() { static std::map<std::string, ExporterSet*> exporters; diff --git a/ZAPD/Globals.h b/ZAPD/Globals.h index 683fd6f..e0cf1d1 100644 --- a/ZAPD/Globals.h +++ b/ZAPD/Globals.h @@ -64,6 +64,7 @@ public: bool forceStatic = false; bool forceUnaccountedStatic = false; bool otrMode = true; + bool buildRawTexture = false; ZRom* rom; std::vector<ZFile*> files; @@ -85,6 +86,7 @@ public: std::map<int32_t, std::vector<ZFile*>> GetSegmentRefFiles(int workerID); void AddFile(ZFile* file, int workerID); void AddExternalFile(ZFile* file, int workerID); + void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath); ZResourceExporter* GetExporter(ZResourceType resType); ExporterSet* GetExporterSet(); diff --git a/ZAPD/ImageBackend.cpp b/ZAPD/ImageBackend.cpp index 8accb6b..2e6beca 100644 --- a/ZAPD/ImageBackend.cpp +++ b/ZAPD/ImageBackend.cpp @@ -147,7 +147,7 @@ void ImageBackend::ReadPng(const char* filename) void ImageBackend::ReadPng(const fs::path& filename) { - ReadPng(filename.c_str()); + ReadPng(filename.string().c_str()); } void ImageBackend::WritePng(const char* filename) diff --git a/ZAPD/Main.cpp b/ZAPD/Main.cpp index a9f70ee..2f1d5be 100644 --- a/ZAPD/Main.cpp +++ b/ZAPD/Main.cpp @@ -256,6 +256,10 @@ int main(int argc, char* argv[]) { Globals::Instance->forceUnaccountedStatic = true; } + else if (arg == "-brt" || arg == "--build-raw-texture") + { + Globals::Instance->buildRawTexture = true; + } } // Parse File Mode @@ -590,22 +594,7 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath) { - std::string name = outPath.stem().string(); - - ZTexture tex(nullptr); - - if (name.find("u32") != std::string::npos) - tex.dWordAligned = false; - - tex.FromPNG(pngFilePath.string(), texType); - std::string cfgPath = StringHelper::Split(pngFilePath.string(), ".")[0] + ".cfg"; - - if (File::Exists(cfgPath)) - name = File::ReadAllText(cfgPath); - - std::string src = tex.GetBodySourceCode(); - - File::WriteAllText(outPath.string(), src); + return Globals::Instance->BuildAssetTexture(pngFilePath, texType, outPath); } void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath) diff --git a/ZAPD/ZTexture.cpp b/ZAPD/ZTexture.cpp index 24f1270..4b58b71 100644 --- a/ZAPD/ZTexture.cpp +++ b/ZAPD/ZTexture.cpp @@ -830,6 +830,8 @@ std::string ZTexture::GetBodySourceCode() const // Please don't remove this line, unless you somehow made a way to prevent // that warning when building the OoT repo. sourceOutput += "\n"; + } else if (Globals::Instance->buildRawTexture) { + sourceOutput += std::string(textureDataRaw.begin(), textureDataRaw.end()); } return sourceOutput; |
