mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-11 03:23:51 +00:00
feat(editor): add WIQR JSON round-trip (--export/--import-wiqr-json)
Closes the editing loop on the item-quality catalog: dump a .wiqr to JSON, hand-edit color hex / vendor multiplier / level gates / disenchant flag / border texture path (e.g. retune Epic purple from #a335ee to #c33fff for a brighter look, raise Heirloom unlock from lvl 80 to 85, mark Legendary as disenchantable, swap a server-custom tier's border texture), re-import to a byte-identical binary. The colors export as raw RGBA uint32 — direct pasting of 0xAARRGGBB hex values without conversion. canBeDisenchanted round-trips as a JSON bool but accepts int as well so machine- generated sidecars work too. Verified byte-identical round-trip on all three presets (std / srv / raid). CLI flag count 1008 -> 1010.
This commit is contained in:
parent
efb88be366
commit
a7057393eb
3 changed files with 127 additions and 0 deletions
|
|
@ -259,6 +259,7 @@ const char* const kArgRequired[] = {
|
|||
"--export-waur-json", "--import-waur-json",
|
||||
"--gen-iqr", "--gen-iqr-server", "--gen-iqr-raid",
|
||||
"--info-wiqr", "--validate-wiqr",
|
||||
"--export-wiqr-json", "--import-wiqr-json",
|
||||
"--gen-weather-temperate", "--gen-weather-arctic",
|
||||
"--gen-weather-desert", "--gen-weather-stormy",
|
||||
"--gen-zone-atmosphere",
|
||||
|
|
|
|||
|
|
@ -1933,6 +1933,10 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Print WIQR entries (id / name / nameColor RGBA / vendor multiplier / minLevel / maxLevel / disenchant flag / border texture)\n");
|
||||
std::printf(" --validate-wiqr <wiqr-base> [--json]\n");
|
||||
std::printf(" Static checks: name required, no duplicate ids, vendor>=0, min<=max; warns on lvl>80 (unreachable), vendor>100x (sanity), alpha=0 nameColor (invisible)\n");
|
||||
std::printf(" --export-wiqr-json <wiqr-base> [out.json]\n");
|
||||
std::printf(" Export binary .wiqr to a human-editable JSON sidecar (defaults to <base>.wiqr.json). Colors as RGBA uint32, easy to paste hex values\n");
|
||||
std::printf(" --import-wiqr-json <json-path> [out-base]\n");
|
||||
std::printf(" Import a .wiqr.json sidecar back into binary .wiqr (canBeDisenchanted accepts bool OR int)\n");
|
||||
std::printf(" --gen-weather-temperate <wow-base> [zoneName]\n");
|
||||
std::printf(" Emit .wow weather schedule: clear-dominant + occasional rain + fog (forest / grassland)\n");
|
||||
std::printf(" --gen-weather-arctic <wow-base> [zoneName]\n");
|
||||
|
|
|
|||
|
|
@ -123,6 +123,122 @@ int handleInfo(int& i, int argc, char** argv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handleExportJson(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string outPath;
|
||||
if (parseOptArg(i, argc, argv)) outPath = argv[++i];
|
||||
base = stripWiqrExt(base);
|
||||
if (!wowee::pipeline::WoweeItemQualityLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"export-wiqr-json: WIQR not found: %s.wiqr\n",
|
||||
base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeItemQualityLoader::load(base);
|
||||
if (outPath.empty()) outPath = base + ".wiqr.json";
|
||||
nlohmann::json j;
|
||||
j["catalog"] = c.name;
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
nlohmann::json je;
|
||||
je["qualityId"] = e.qualityId;
|
||||
je["name"] = e.name;
|
||||
je["description"] = e.description;
|
||||
je["nameColorRGBA"] = e.nameColorRGBA;
|
||||
je["borderColorRGBA"] = e.borderColorRGBA;
|
||||
je["vendorPriceMultiplier"] = e.vendorPriceMultiplier;
|
||||
je["minLevelToDrop"] = e.minLevelToDrop;
|
||||
je["maxLevelToDrop"] = e.maxLevelToDrop;
|
||||
je["canBeDisenchanted"] = e.canBeDisenchanted != 0;
|
||||
je["inventoryBorderTexture"] = e.inventoryBorderTexture;
|
||||
arr.push_back(je);
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::ofstream os(outPath);
|
||||
if (!os) {
|
||||
std::fprintf(stderr,
|
||||
"export-wiqr-json: failed to open %s for write\n",
|
||||
outPath.c_str());
|
||||
return 1;
|
||||
}
|
||||
os << j.dump(2) << "\n";
|
||||
std::printf("Wrote %s\n", outPath.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" tiers : %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];
|
||||
std::ifstream is(jsonPath);
|
||||
if (!is) {
|
||||
std::fprintf(stderr,
|
||||
"import-wiqr-json: failed to open %s\n", jsonPath.c_str());
|
||||
return 1;
|
||||
}
|
||||
nlohmann::json j;
|
||||
try {
|
||||
is >> j;
|
||||
} catch (const std::exception& ex) {
|
||||
std::fprintf(stderr,
|
||||
"import-wiqr-json: parse error in %s: %s\n",
|
||||
jsonPath.c_str(), ex.what());
|
||||
return 1;
|
||||
}
|
||||
wowee::pipeline::WoweeItemQuality c;
|
||||
if (j.contains("catalog") && j["catalog"].is_string())
|
||||
c.name = j["catalog"].get<std::string>();
|
||||
if (j.contains("entries") && j["entries"].is_array()) {
|
||||
for (const auto& je : j["entries"]) {
|
||||
wowee::pipeline::WoweeItemQuality::Entry e;
|
||||
if (je.contains("qualityId")) e.qualityId = je["qualityId"].get<uint32_t>();
|
||||
if (je.contains("name")) e.name = je["name"].get<std::string>();
|
||||
if (je.contains("description")) e.description = je["description"].get<std::string>();
|
||||
if (je.contains("nameColorRGBA")) e.nameColorRGBA = je["nameColorRGBA"].get<uint32_t>();
|
||||
if (je.contains("borderColorRGBA")) e.borderColorRGBA = je["borderColorRGBA"].get<uint32_t>();
|
||||
if (je.contains("vendorPriceMultiplier")) e.vendorPriceMultiplier = je["vendorPriceMultiplier"].get<float>();
|
||||
if (je.contains("minLevelToDrop")) e.minLevelToDrop = je["minLevelToDrop"].get<uint8_t>();
|
||||
if (je.contains("maxLevelToDrop")) e.maxLevelToDrop = je["maxLevelToDrop"].get<uint8_t>();
|
||||
if (je.contains("canBeDisenchanted")) {
|
||||
if (je["canBeDisenchanted"].is_boolean())
|
||||
e.canBeDisenchanted = je["canBeDisenchanted"].get<bool>() ? 1 : 0;
|
||||
else
|
||||
e.canBeDisenchanted = je["canBeDisenchanted"].get<uint8_t>() ? 1 : 0;
|
||||
}
|
||||
if (je.contains("inventoryBorderTexture"))
|
||||
e.inventoryBorderTexture = je["inventoryBorderTexture"].get<std::string>();
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
}
|
||||
if (outBase.empty()) {
|
||||
outBase = jsonPath;
|
||||
const std::string suffix1 = ".wiqr.json";
|
||||
const std::string suffix2 = ".json";
|
||||
if (outBase.size() >= suffix1.size() &&
|
||||
outBase.compare(outBase.size() - suffix1.size(),
|
||||
suffix1.size(), suffix1) == 0) {
|
||||
outBase.resize(outBase.size() - suffix1.size());
|
||||
} else if (outBase.size() >= suffix2.size() &&
|
||||
outBase.compare(outBase.size() - suffix2.size(),
|
||||
suffix2.size(), suffix2) == 0) {
|
||||
outBase.resize(outBase.size() - suffix2.size());
|
||||
}
|
||||
}
|
||||
outBase = stripWiqrExt(outBase);
|
||||
if (!wowee::pipeline::WoweeItemQualityLoader::save(c, outBase)) {
|
||||
std::fprintf(stderr,
|
||||
"import-wiqr-json: failed to save %s.wiqr\n",
|
||||
outBase.c_str());
|
||||
return 1;
|
||||
}
|
||||
std::printf("Wrote %s.wiqr\n", outBase.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" tiers : %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);
|
||||
|
|
@ -234,6 +350,12 @@ bool handleItemQualitiesCatalog(int& i, int argc, char** argv,
|
|||
if (std::strcmp(argv[i], "--validate-wiqr") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--export-wiqr-json") == 0 && i + 1 < argc) {
|
||||
outRc = handleExportJson(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--import-wiqr-json") == 0 && i + 1 < argc) {
|
||||
outRc = handleImportJson(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue