diff --git a/tools/editor/cli_arg_required.cpp b/tools/editor/cli_arg_required.cpp index cd8ad947..f91709ad 100644 --- a/tools/editor/cli_arg_required.cpp +++ b/tools/editor/cli_arg_required.cpp @@ -174,6 +174,7 @@ const char* const kArgRequired[] = { "--export-wsch-json", "--import-wsch-json", "--gen-lfg", "--gen-lfg-heroic", "--gen-lfg-raid", "--info-wlfg", "--validate-wlfg", + "--export-wlfg-json", "--import-wlfg-json", "--gen-weather-temperate", "--gen-weather-arctic", "--gen-weather-desert", "--gen-weather-stormy", "--gen-zone-atmosphere", diff --git a/tools/editor/cli_help.cpp b/tools/editor/cli_help.cpp index 83edc0e9..d1d27151 100644 --- a/tools/editor/cli_help.cpp +++ b/tools/editor/cli_help.cpp @@ -1539,6 +1539,10 @@ void printUsage(const char* argv0) { std::printf(" Print WLFG entries (id / map / level range / minIlvl / difficulty / groupSize / role mask / expansion / rewards / name)\n"); std::printf(" --validate-wlfg [--json]\n"); std::printf(" Static checks: id+name+mapId required, difficulty 0..3 / expansion 0..3, minLevel<=maxLevel, recommended within range, role mask>0\n"); + std::printf(" --export-wlfg-json [out.json]\n"); + std::printf(" Export binary .wlfg to a human-editable JSON sidecar (defaults to .wlfg.json)\n"); + std::printf(" --import-wlfg-json [out-base]\n"); + std::printf(" Import a .wlfg.json sidecar back into binary .wlfg (accepts difficulty/expansion int OR name string; groupSize defaults to 5, role mask to kRoleAll)\n"); std::printf(" --gen-weather-temperate [zoneName]\n"); std::printf(" Emit .wow weather schedule: clear-dominant + occasional rain + fog (forest / grassland)\n"); std::printf(" --gen-weather-arctic [zoneName]\n"); diff --git a/tools/editor/cli_lfg_catalog.cpp b/tools/editor/cli_lfg_catalog.cpp index d88da36a..1e7c2491 100644 --- a/tools/editor/cli_lfg_catalog.cpp +++ b/tools/editor/cli_lfg_catalog.cpp @@ -132,6 +132,166 @@ int handleInfo(int& i, int argc, char** argv) { return 0; } +int handleExportJson(int& i, int argc, char** argv) { + // Mirrors the JSON pairs added for every other novel + // open format. Each dungeon emits all 13 scalar fields + // plus dual int + name forms for difficulty (4 values) + // and expansionRequired (4 values) so hand-edits can + // use either representation. + std::string base = argv[++i]; + std::string outPath; + if (parseOptArg(i, argc, argv)) outPath = argv[++i]; + base = stripWlfgExt(base); + if (outPath.empty()) outPath = base + ".wlfg.json"; + if (!wowee::pipeline::WoweeLFGDungeonLoader::exists(base)) { + std::fprintf(stderr, + "export-wlfg-json: WLFG not found: %s.wlfg\n", base.c_str()); + return 1; + } + auto c = wowee::pipeline::WoweeLFGDungeonLoader::load(base); + nlohmann::json j; + j["name"] = c.name; + nlohmann::json arr = nlohmann::json::array(); + for (const auto& e : c.entries) { + arr.push_back({ + {"dungeonId", e.dungeonId}, + {"name", e.name}, + {"description", e.description}, + {"mapId", e.mapId}, + {"minLevel", e.minLevel}, + {"maxLevel", e.maxLevel}, + {"recommendedLevel", e.recommendedLevel}, + {"minGearLevel", e.minGearLevel}, + {"difficulty", e.difficulty}, + {"difficultyName", wowee::pipeline::WoweeLFGDungeon::difficultyName(e.difficulty)}, + {"groupSize", e.groupSize}, + {"requiredRolesMask", e.requiredRolesMask}, + {"expansionRequired", e.expansionRequired}, + {"expansionRequiredName", wowee::pipeline::WoweeLFGDungeon::expansionRequiredName(e.expansionRequired)}, + {"queueRewardItemId", e.queueRewardItemId}, + {"queueRewardEmblemCount", e.queueRewardEmblemCount}, + {"firstClearAchievement", e.firstClearAchievement}, + }); + } + j["entries"] = arr; + std::ofstream out(outPath); + if (!out) { + std::fprintf(stderr, + "export-wlfg-json: cannot write %s\n", outPath.c_str()); + return 1; + } + out << j.dump(2) << "\n"; + out.close(); + std::printf("Wrote %s\n", outPath.c_str()); + std::printf(" source : %s.wlfg\n", base.c_str()); + std::printf(" dungeons : %zu\n", c.entries.size()); + return 0; +} + +int handleImportJson(int& i, int argc, char** argv) { + std::string jsonPath = argv[++i]; + std::string outBase; + if (parseOptArg(i, argc, argv)) outBase = argv[++i]; + if (outBase.empty()) { + outBase = jsonPath; + std::string suffix = ".wlfg.json"; + if (outBase.size() > suffix.size() && + outBase.substr(outBase.size() - suffix.size()) == suffix) { + outBase = outBase.substr(0, outBase.size() - suffix.size()); + } else if (outBase.size() > 5 && + outBase.substr(outBase.size() - 5) == ".json") { + outBase = outBase.substr(0, outBase.size() - 5); + } + } + outBase = stripWlfgExt(outBase); + std::ifstream in(jsonPath); + if (!in) { + std::fprintf(stderr, + "import-wlfg-json: cannot read %s\n", jsonPath.c_str()); + return 1; + } + nlohmann::json j; + try { in >> j; } + catch (const std::exception& e) { + std::fprintf(stderr, + "import-wlfg-json: bad JSON in %s: %s\n", + jsonPath.c_str(), e.what()); + return 1; + } + auto difficultyFromName = [](const std::string& s) -> uint8_t { + if (s == "normal") return wowee::pipeline::WoweeLFGDungeon::Normal; + if (s == "heroic") return wowee::pipeline::WoweeLFGDungeon::Heroic; + if (s == "mythic") return wowee::pipeline::WoweeLFGDungeon::Mythic; + if (s == "hardmode") return wowee::pipeline::WoweeLFGDungeon::Hardmode; + return wowee::pipeline::WoweeLFGDungeon::Normal; + }; + auto expansionFromName = [](const std::string& s) -> uint8_t { + if (s == "classic") return wowee::pipeline::WoweeLFGDungeon::Classic; + if (s == "tbc") return wowee::pipeline::WoweeLFGDungeon::TBC; + if (s == "wotlk") return wowee::pipeline::WoweeLFGDungeon::WotLK; + if (s == "turtle") return wowee::pipeline::WoweeLFGDungeon::TurtleWoW; + return wowee::pipeline::WoweeLFGDungeon::Classic; + }; + wowee::pipeline::WoweeLFGDungeon c; + c.name = j.value("name", std::string{}); + if (j.contains("entries") && j["entries"].is_array()) { + for (const auto& je : j["entries"]) { + wowee::pipeline::WoweeLFGDungeon::Entry e; + e.dungeonId = je.value("dungeonId", 0u); + e.name = je.value("name", std::string{}); + e.description = je.value("description", std::string{}); + e.mapId = je.value("mapId", 0u); + e.minLevel = static_cast(je.value("minLevel", 1)); + e.maxLevel = static_cast(je.value("maxLevel", 80)); + e.recommendedLevel = static_cast( + je.value("recommendedLevel", 0)); + e.minGearLevel = static_cast( + je.value("minGearLevel", 0)); + if (je.contains("difficulty") && + je["difficulty"].is_number_integer()) { + e.difficulty = static_cast( + je["difficulty"].get()); + } else if (je.contains("difficultyName") && + je["difficultyName"].is_string()) { + e.difficulty = difficultyFromName( + je["difficultyName"].get()); + } + // groupSize defaults to 5 (dungeon) if omitted. + e.groupSize = static_cast( + je.value("groupSize", 5)); + // requiredRolesMask defaults to kRoleAll so queue + // forms balanced groups by default. + e.requiredRolesMask = static_cast( + je.value("requiredRolesMask", + wowee::pipeline::WoweeLFGDungeon::kRoleAll)); + if (je.contains("expansionRequired") && + je["expansionRequired"].is_number_integer()) { + e.expansionRequired = static_cast( + je["expansionRequired"].get()); + } else if (je.contains("expansionRequiredName") && + je["expansionRequiredName"].is_string()) { + e.expansionRequired = expansionFromName( + je["expansionRequiredName"].get()); + } + e.queueRewardItemId = je.value("queueRewardItemId", 0u); + e.queueRewardEmblemCount = static_cast( + je.value("queueRewardEmblemCount", 0)); + e.firstClearAchievement = + je.value("firstClearAchievement", 0u); + c.entries.push_back(e); + } + } + if (!wowee::pipeline::WoweeLFGDungeonLoader::save(c, outBase)) { + std::fprintf(stderr, + "import-wlfg-json: failed to save %s.wlfg\n", outBase.c_str()); + return 1; + } + std::printf("Wrote %s.wlfg\n", outBase.c_str()); + std::printf(" source : %s\n", jsonPath.c_str()); + std::printf(" dungeons : %zu\n", c.entries.size()); + return 0; +} + int handleValidate(int& i, int argc, char** argv) { std::string base = argv[++i]; bool jsonOut = consumeJsonFlag(i, argc, argv); @@ -251,6 +411,12 @@ bool handleLFGCatalog(int& i, int argc, char** argv, int& outRc) { if (std::strcmp(argv[i], "--validate-wlfg") == 0 && i + 1 < argc) { outRc = handleValidate(i, argc, argv); return true; } + if (std::strcmp(argv[i], "--export-wlfg-json") == 0 && i + 1 < argc) { + outRc = handleExportJson(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--import-wlfg-json") == 0 && i + 1 < argc) { + outRc = handleImportJson(i, argc, argv); return true; + } return false; }