feat(editor): complete importOpen, keyboard shortcuts, DBC exporter

- importOpen now loads WHM alpha maps + full WOT metadata (textures,
  layers, holes, water) — was height-only stub
- DBC exporter migrated to nlohmann/json (last naive JSON file)
- Add Z-axis gizmo constraint (Z key) alongside X/Y
- Add Ctrl+Y as alternate redo binding
- Add F1 keyboard shortcut for help panel toggle
- Update help panel: document Z-axis, Ctrl+Y, all shortcuts
This commit is contained in:
Kelsi 2026-05-05 13:15:00 -07:00
parent 5b180c5579
commit 97e7a4c71a
5 changed files with 117 additions and 35 deletions

View file

@ -1,6 +1,7 @@
#include "dbc_exporter.hpp"
#include "pipeline/asset_manager.hpp"
#include "core/logger.hpp"
#include <nlohmann/json.hpp>
#include <fstream>
#include <filesystem>
@ -16,49 +17,37 @@ bool DBCExporter::exportAsJson(pipeline::AssetManager* am,
namespace fs = std::filesystem;
fs::create_directories(fs::path(outputPath).parent_path());
std::ofstream f(outputPath);
if (!f) return false;
f << "{\n";
f << " \"format\": \"wowee-dbc-json-1.0\",\n";
f << " \"source\": \"" << dbcName << "\",\n";
f << " \"recordCount\": " << dbc->getRecordCount() << ",\n";
f << " \"fieldCount\": " << dbc->getFieldCount() << ",\n";
f << " \"records\": [\n";
nlohmann::json j;
j["format"] = "wowee-dbc-json-1.0";
j["source"] = dbcName;
j["recordCount"] = dbc->getRecordCount();
j["fieldCount"] = dbc->getFieldCount();
nlohmann::json records = nlohmann::json::array();
for (uint32_t i = 0; i < dbc->getRecordCount(); i++) {
f << " [";
for (uint32_t j = 0; j < dbc->getFieldCount(); j++) {
// Try to detect string fields vs numeric
uint32_t val = dbc->getUInt32(i, j);
// Check if it looks like a string offset (points into string block)
std::string strVal = dbc->getString(i, j);
nlohmann::json row = nlohmann::json::array();
for (uint32_t field = 0; field < dbc->getFieldCount(); field++) {
uint32_t val = dbc->getUInt32(i, field);
std::string strVal = dbc->getString(i, field);
if (!strVal.empty() && strVal[0] != '\0' && strVal.size() < 200) {
// Escape quotes in string
std::string escaped;
for (char c : strVal) {
if (c == '"') escaped += "\\\"";
else if (c == '\\') escaped += "\\\\";
else if (c == '\n') escaped += "\\n";
else escaped += c;
}
f << "\"" << escaped << "\"";
row.push_back(strVal);
} else {
// Check if it's a float
float fval = dbc->getFloat(i, j);
float fval = dbc->getFloat(i, field);
if (val != 0 && fval != 0.0f && fval > -1e10f && fval < 1e10f &&
static_cast<uint32_t>(fval) != val) {
f << fval;
row.push_back(fval);
} else {
f << val;
row.push_back(val);
}
}
if (j + 1 < dbc->getFieldCount()) f << ", ";
}
f << "]" << (i + 1 < dbc->getRecordCount() ? "," : "") << "\n";
records.push_back(row);
}
j["records"] = records;
f << " ]\n}\n";
std::ofstream f(outputPath);
if (!f) return false;
f << j.dump(2) << "\n";
LOG_INFO("DBC exported as JSON: ", dbcName, "", outputPath,
" (", dbc->getRecordCount(), " records)");
@ -67,7 +56,6 @@ bool DBCExporter::exportAsJson(pipeline::AssetManager* am,
int DBCExporter::exportZoneDBCs(pipeline::AssetManager* am,
const std::string& outputDir) {
// Zone-relevant DBCs for custom content
const char* zoneDBCs[] = {
"AreaTable.dbc",
"Map.dbc",