mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-08 10:03:51 +00:00
feat(editor): add --list-items companion to --add-item
Pretty-prints every record in <zoneDir>/items.json as a table with idx / id / itemLevel / stackable / quality (named) / displayId / name columns. Also supports --json for machine-readable output (emits the items array verbatim). Verified on a 3-item zone: table output aligns columns, quality labels resolve correctly (common/uncommon/legendary), --json mode emits a clean array consumable by jq or downstream tools. Brings command count to 197.
This commit is contained in:
parent
dd36182cd3
commit
6eeac1c861
1 changed files with 62 additions and 0 deletions
|
|
@ -530,6 +530,8 @@ static void printUsage(const char* argv0) {
|
||||||
std::printf(" Synthesize a procedural WOM primitive with proper normals, UVs, and bounds\n");
|
std::printf(" Synthesize a procedural WOM primitive with proper normals, UVs, and bounds\n");
|
||||||
std::printf(" --add-item <zoneDir> <name> [id] [quality] [displayId] [itemLevel]\n");
|
std::printf(" --add-item <zoneDir> <name> [id] [quality] [displayId] [itemLevel]\n");
|
||||||
std::printf(" Append one item entry to <zoneDir>/items.json (auto-creates the file)\n");
|
std::printf(" Append one item entry to <zoneDir>/items.json (auto-creates the file)\n");
|
||||||
|
std::printf(" --list-items <zoneDir> [--json]\n");
|
||||||
|
std::printf(" Print every item in <zoneDir>/items.json with quality colors and key fields\n");
|
||||||
std::printf(" --convert-dbc-json <dbc-path> [out.json]\n");
|
std::printf(" --convert-dbc-json <dbc-path> [out.json]\n");
|
||||||
std::printf(" Convert one DBC file to wowee JSON sidecar format\n");
|
std::printf(" Convert one DBC file to wowee JSON sidecar format\n");
|
||||||
std::printf(" --convert-json-dbc <json-path> [out.dbc]\n");
|
std::printf(" --convert-json-dbc <json-path> [out.dbc]\n");
|
||||||
|
|
@ -933,6 +935,7 @@ int main(int argc, char* argv[]) {
|
||||||
"--check-project-content", "--check-project-refs",
|
"--check-project-content", "--check-project-refs",
|
||||||
"--export-zone-deps-md", "--export-zone-spawn-png",
|
"--export-zone-deps-md", "--export-zone-spawn-png",
|
||||||
"--add-creature", "--add-object", "--add-quest", "--add-item",
|
"--add-creature", "--add-object", "--add-quest", "--add-item",
|
||||||
|
"--list-items",
|
||||||
"--add-quest-objective", "--add-quest-reward-item", "--set-quest-reward",
|
"--add-quest-objective", "--add-quest-reward-item", "--set-quest-reward",
|
||||||
"--remove-quest-objective", "--clone-quest", "--clone-creature",
|
"--remove-quest-objective", "--clone-quest", "--clone-creature",
|
||||||
"--clone-object",
|
"--clone-object",
|
||||||
|
|
@ -12584,6 +12587,65 @@ int main(int argc, char* argv[]) {
|
||||||
qualityNames[quality], itemLevel,
|
qualityNames[quality], itemLevel,
|
||||||
path.c_str(), doc["items"].size());
|
path.c_str(), doc["items"].size());
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if (std::strcmp(argv[i], "--list-items") == 0 && i + 1 < argc) {
|
||||||
|
// Inspect <zoneDir>/items.json. Pretty-prints id / quality
|
||||||
|
// / item level / display id / name as a table; also
|
||||||
|
// supports --json for machine-readable output.
|
||||||
|
std::string zoneDir = argv[++i];
|
||||||
|
bool jsonOut = (i + 1 < argc &&
|
||||||
|
std::strcmp(argv[i + 1], "--json") == 0);
|
||||||
|
if (jsonOut) i++;
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
std::string path = zoneDir + "/items.json";
|
||||||
|
if (!fs::exists(path)) {
|
||||||
|
std::fprintf(stderr,
|
||||||
|
"list-items: %s has no items.json\n", zoneDir.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
nlohmann::json doc;
|
||||||
|
try {
|
||||||
|
std::ifstream in(path);
|
||||||
|
in >> doc;
|
||||||
|
} catch (...) {
|
||||||
|
std::fprintf(stderr,
|
||||||
|
"list-items: %s is not valid JSON\n", path.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!doc.contains("items") || !doc["items"].is_array()) {
|
||||||
|
std::fprintf(stderr,
|
||||||
|
"list-items: %s has no 'items' array\n", path.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const auto& items = doc["items"];
|
||||||
|
if (jsonOut) {
|
||||||
|
std::printf("%s\n", items.dump(2).c_str());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static const char* qualityNames[] = {
|
||||||
|
"poor", "common", "uncommon", "rare", "epic",
|
||||||
|
"legendary", "artifact"
|
||||||
|
};
|
||||||
|
std::printf("Zone items: %s\n", path.c_str());
|
||||||
|
std::printf(" count : %zu\n\n", items.size());
|
||||||
|
if (items.empty()) {
|
||||||
|
std::printf(" *no items*\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
std::printf(" idx id ilvl stack quality displayId name\n");
|
||||||
|
for (size_t k = 0; k < items.size(); ++k) {
|
||||||
|
const auto& it = items[k];
|
||||||
|
uint32_t id = it.value("id", 0u);
|
||||||
|
uint32_t quality = it.value("quality", 1u);
|
||||||
|
uint32_t ilvl = it.value("itemLevel", 1u);
|
||||||
|
uint32_t displayId = it.value("displayId", 0u);
|
||||||
|
uint32_t stack = it.value("stackable", 1u);
|
||||||
|
std::string name = it.value("name", std::string());
|
||||||
|
if (quality > 6) quality = 0;
|
||||||
|
std::printf(" %3zu %5u %4u %5u %-10s %9u %s\n",
|
||||||
|
k, id, ilvl, stack,
|
||||||
|
qualityNames[quality], displayId, name.c_str());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
} else if (std::strcmp(argv[i], "--scaffold-zone") == 0 && i + 1 < argc) {
|
} else if (std::strcmp(argv[i], "--scaffold-zone") == 0 && i + 1 < argc) {
|
||||||
// Generate a minimal valid empty zone — useful for kickstarting
|
// Generate a minimal valid empty zone — useful for kickstarting
|
||||||
// a new authoring session without needing to launch the GUI.
|
// a new authoring session without needing to launch the GUI.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue