diff options
| author | AltoXorg <atrl101@yahoo.com> | 2024-04-19 12:02:37 +0800 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2024-04-20 10:25:02 -0600 |
| commit | fb9a018feb83cd0b9e7e4a1145c6e9e9252ae381 (patch) | |
| tree | 3bb0d899d7c4e23c263a1ec9a07ba95b33fe865c /src/factories/TextureFactory.cpp | |
| parent | 8abeb379e42af05adb1fef7a9625f37037b767d8 (diff) | |
individual data incs option
The option creates a similar way that is found in splat's gfx & vtx segment where it parses and outputs the data in their individual ".inc.c" files
Diffstat (limited to 'src/factories/TextureFactory.cpp')
| -rw-r--r-- | src/factories/TextureFactory.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/factories/TextureFactory.cpp b/src/factories/TextureFactory.cpp index 6dfb3e7..d3bc923 100644 --- a/src/factories/TextureFactory.cpp +++ b/src/factories/TextureFactory.cpp @@ -137,7 +137,7 @@ ExportResult TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IP create_directories(fs::path(dpath).parent_path()); } - std::ofstream file(dpath + ".inc.c", std::ios::binary); + std::ostringstream imgstream; size_t byteSize = std::max(1, (int) (texture->mFormat.depth / 8)); @@ -145,20 +145,24 @@ ExportResult TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IP for (int i = 0; i < data.size(); i+=byteSize) { if (i % 16 == 0 && i != 0) { - file << std::endl; + imgstream << std::endl; } - file << "0x"; + imgstream << "0x"; for (int j = 0; j < byteSize; j++) { - file << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(data[i + j]); + imgstream << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(data[i + j]); } - file << ", "; + imgstream << ", "; } - file << std::endl; + imgstream << std::endl; - file.close(); + if (Companion::Instance->IsSingleCodeFile()){ + std::ofstream file(dpath + ".inc.c", std::ios::binary); + file << imgstream.str(); + file.close(); + } const auto searchTable = Companion::Instance->SearchTable(offset); @@ -174,7 +178,11 @@ ExportResult TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IP } write << tab << "{\n"; - write << tab << tab << "#include \"" << Companion::Instance->GetOutputPath() + "/" << *replacement << ".inc.c\"\n"; + if (Companion::Instance->IsSingleCodeFile()){ + write << tab << tab << "#include \"" << Companion::Instance->GetOutputPath() + "/" << *replacement << ".inc.c\"\n"; + } else { + write << imgstream.str(); + } write << tab << "},\n"; if(end == offset){ @@ -186,7 +194,11 @@ ExportResult TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IP } else { write << GetSafeNode<std::string>(node, "ctype", "u8") << " " << symbol << "[] = {\n"; - write << tab << "#include \"" << Companion::Instance->GetOutputPath() + "/" << *replacement << ".inc.c\"\n"; + if (Companion::Instance->IsSingleCodeFile()){ + write << tab << "#include \"" << Companion::Instance->GetOutputPath() + "/" << *replacement << ".inc.c\"\n"; + } else { + write << imgstream.str(); + } write << "};\n"; const auto sz = data.size(); |
