From 8f890ef1f3bb23c35a2161e64096c00df2decd7a Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 23:19:38 -0700 Subject: [PATCH] =?UTF-8?q?feat(editor):=20add=20--convert-blp-batch=20for?= =?UTF-8?q?=20bulk=20BLP=E2=86=92PNG=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Walks recursively for every .blp file (case-insensitive) and re-invokes --convert-blp-png per file. The single-file converter writes the .png as a sidecar next to the source by default, so a batched run mirrors the standard "PNG sidecar everywhere" layout that the editor's open-format runtime expects. Verified discovery: 3 placeholder .blp files (lowercase, uppercase, sub-dir) found correctly; .png file in same tree skipped; all fail conversion as expected for empty bytes; exit 1 on failures. Brings command count to 185. --- tools/editor/main.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/tools/editor/main.cpp b/tools/editor/main.cpp index 253fb43a..9fbfe56d 100644 --- a/tools/editor/main.cpp +++ b/tools/editor/main.cpp @@ -514,6 +514,8 @@ static void printUsage(const char* argv0) { std::printf(" Convert a wowee JSON DBC back to binary DBC for private-server compat\n"); std::printf(" --convert-blp-png [out.png]\n"); std::printf(" Convert one BLP texture to PNG sidecar\n"); + std::printf(" --convert-blp-batch \n"); + std::printf(" Bulk BLP→PNG conversion across every .blp in (sidecars next to source)\n"); std::printf(" --migrate-wom [out-base]\n"); std::printf(" Upgrade an older WOM (v1/v2) to WOM3 with a default single-batch entry\n"); std::printf(" --migrate-zone \n"); @@ -925,7 +927,8 @@ int main(int argc, char* argv[]) { "--bake-project-obj", "--bake-project-stl", "--bake-project-glb", "--convert-m2", "--convert-m2-batch", "--convert-wmo", "--convert-wmo-batch", - "--convert-dbc-json", "--convert-json-dbc", "--convert-blp-png", + "--convert-dbc-json", "--convert-json-dbc", + "--convert-blp-png", "--convert-blp-batch", "--migrate-wom", "--migrate-zone", "--migrate-project", "--migrate-jsondbc", }; @@ -13403,6 +13406,52 @@ int main(int argc, char* argv[]) { std::printf("\n summary : %d ok, %d failed (out of %zu)\n", ok, failed, wmoFiles.size()); return failed == 0 ? 0 : 1; + } else if (std::strcmp(argv[i], "--convert-blp-batch") == 0 && i + 1 < argc) { + // Bulk BLP→PNG conversion. Walks recursively for + // every .blp file and re-invokes --convert-blp-png per + // file via a child process. The single-file converter + // writes the .png as a sidecar next to the source by + // default, so a batched run mirrors the standard "PNG + // sidecar everywhere" layout. + std::string srcDir = argv[++i]; + namespace fs = std::filesystem; + if (!fs::exists(srcDir) || !fs::is_directory(srcDir)) { + std::fprintf(stderr, + "convert-blp-batch: %s is not a directory\n", + srcDir.c_str()); + return 1; + } + std::vector blpFiles; + std::error_code ec; + for (const auto& e : fs::recursive_directory_iterator(srcDir, ec)) { + if (!e.is_regular_file()) continue; + std::string ext = e.path().extension().string(); + std::transform(ext.begin(), ext.end(), ext.begin(), + [](unsigned char c) { return std::tolower(c); }); + if (ext != ".blp") continue; + blpFiles.push_back(e.path().string()); + } + std::sort(blpFiles.begin(), blpFiles.end()); + std::printf("convert-blp-batch: %s\n", srcDir.c_str()); + std::printf(" candidates : %zu .blp file(s)\n", blpFiles.size()); + std::string self = argv[0]; + int ok = 0, failed = 0; + for (const auto& blp : blpFiles) { + std::fflush(stdout); + std::string cmd = "\"" + self + "\" --convert-blp-png \"" + blp + "\""; + cmd += " >/dev/null 2>&1"; + int rc = std::system(cmd.c_str()); + if (rc == 0) { + ok++; + std::printf(" [ok] %s\n", blp.c_str()); + } else { + failed++; + std::printf(" [FAIL] %s (rc=%d)\n", blp.c_str(), rc); + } + } + std::printf("\n summary : %d ok, %d failed (out of %zu)\n", + ok, failed, blpFiles.size()); + return failed == 0 ? 0 : 1; } else if (std::strcmp(argv[i], "--repair-zone") == 0 && i + 1 < argc) { // Auto-fix the common manifest-vs-disk drift issues that // accumulate when a zone is hand-edited or partially copied: