feat(editor): zone manifest for client loading, export workflow complete

- Zone manifest (zone.json): generated on export with map name, map ID,
  tile list, biome, creature flag, and file paths. This is what the
  wowee client will read to discover and load custom zones.
- Export workflow now produces a complete loadable zone package:
  zone.json + MapName.wdt + MapName_X_Y.adt + creatures.json
- ZoneManifest class with save/load (JSON format)
- Custom map IDs start at 9000+ to avoid conflicting with retail maps
- New Terrain dialog shows helper text for map name format
This commit is contained in:
Kelsi 2026-05-05 05:06:41 -07:00
parent 3d6c508491
commit e0d14de5d2
6 changed files with 117 additions and 1 deletions

View file

@ -1292,6 +1292,7 @@ add_executable(wowee_editor
tools/editor/npc_spawner.cpp
tools/editor/npc_presets.cpp
tools/editor/transform_gizmo.cpp
tools/editor/zone_manifest.cpp
tools/editor/asset_browser.cpp
tools/editor/editor_water.cpp
tools/editor/editor_markers.cpp

View file

@ -1,5 +1,6 @@
#include "editor_app.hpp"
#include "adt_writer.hpp"
#include "zone_manifest.hpp"
#include "rendering/vk_context.hpp"
#include "pipeline/adt_loader.hpp"
#include "pipeline/terrain_mesh.hpp"
@ -596,6 +597,15 @@ void EditorApp::exportZone(const std::string& outputDir) {
npcSpawner_.saveToFile(npcPath);
}
// Write zone manifest (for client loading)
ZoneManifest manifest;
manifest.mapName = loadedMap_;
manifest.displayName = loadedMap_;
manifest.tiles.push_back({loadedTileX_, loadedTileY_});
manifest.hasCreatures = (npcSpawner_.spawnCount() > 0);
manifest.baseHeight = terrain_.chunks[0].position[2];
manifest.save(base + "/zone.json");
lastSavePath_ = outputDir;
showToast("Zone exported to " + base);
LOG_INFO("Zone exported to: ", base);

View file

@ -8,6 +8,7 @@
#include "object_placer.hpp"
#include "npc_spawner.hpp"
#include "npc_presets.hpp"
#include "zone_manifest.hpp"
#include "asset_browser.hpp"
#include "core/window.hpp"
#include "pipeline/asset_manager.hpp"

View file

@ -235,9 +235,11 @@ void EditorUI::renderToolbar(EditorApp& app) {
}
void EditorUI::renderNewTerrainDialog(EditorApp& /*app*/) {
ImGui::SetNextWindowSize(ImVec2(400, 300), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(400, 320), ImGuiCond_FirstUseEver);
if (ImGui::Begin("New Terrain", &showNewDialog_)) {
ImGui::InputText("Map Name", newMapNameBuf_, sizeof(newMapNameBuf_));
ImGui::TextColored(ImVec4(0.6f, 0.6f, 0.6f, 1),
"Internal name (no spaces). Used for file paths.");
ImGui::InputInt("Tile X", &newTileX_);
ImGui::InputInt("Tile Y", &newTileY_);
ImGui::SliderFloat("Base Height", &newBaseHeight_, 0.0f, 500.0f);

View file

@ -0,0 +1,77 @@
#include "zone_manifest.hpp"
#include "core/logger.hpp"
#include <fstream>
#include <filesystem>
namespace wowee {
namespace editor {
bool ZoneManifest::save(const std::string& path) const {
auto dir = std::filesystem::path(path).parent_path();
if (!dir.empty()) std::filesystem::create_directories(dir);
std::ofstream f(path);
if (!f) { LOG_ERROR("Failed to write zone manifest: ", path); return false; }
f << "{\n";
f << " \"mapName\": \"" << mapName << "\",\n";
f << " \"displayName\": \"" << displayName << "\",\n";
f << " \"mapId\": " << mapId << ",\n";
f << " \"biome\": \"" << biome << "\",\n";
f << " \"baseHeight\": " << baseHeight << ",\n";
f << " \"hasCreatures\": " << (hasCreatures ? "true" : "false") << ",\n";
f << " \"description\": \"" << description << "\",\n";
f << " \"tiles\": [";
for (size_t i = 0; i < tiles.size(); i++) {
f << "[" << tiles[i].first << "," << tiles[i].second << "]";
if (i + 1 < tiles.size()) f << ",";
}
f << "],\n";
f << " \"files\": {\n";
f << " \"wdt\": \"" << mapName << ".wdt\",\n";
for (size_t i = 0; i < tiles.size(); i++) {
f << " \"adt_" << tiles[i].first << "_" << tiles[i].second << "\": \""
<< mapName << "_" << tiles[i].first << "_" << tiles[i].second << ".adt\"";
if (i + 1 < tiles.size() || hasCreatures) f << ",";
f << "\n";
}
if (hasCreatures)
f << " \"creatures\": \"creatures.json\"\n";
f << " }\n";
f << "}\n";
LOG_INFO("Zone manifest saved: ", path);
return true;
}
bool ZoneManifest::load(const std::string& path) {
std::ifstream f(path);
if (!f) return false;
std::string content((std::istreambuf_iterator<char>(f)),
std::istreambuf_iterator<char>());
auto findStr = [&](const std::string& key) -> std::string {
auto pos = content.find("\"" + key + "\"");
if (pos == std::string::npos) return "";
pos = content.find('"', content.find(':', pos) + 1);
if (pos == std::string::npos) return "";
auto end = content.find('"', pos + 1);
return content.substr(pos + 1, end - pos - 1);
};
mapName = findStr("mapName");
displayName = findStr("displayName");
biome = findStr("biome");
description = findStr("description");
auto numPos = content.find("\"mapId\"");
if (numPos != std::string::npos) {
numPos = content.find(':', numPos);
mapId = static_cast<uint32_t>(std::stoi(content.substr(numPos + 1)));
}
return !mapName.empty();
}
} // namespace editor
} // namespace wowee

View file

@ -0,0 +1,25 @@
#pragma once
#include <string>
#include <vector>
#include <cstdint>
namespace wowee {
namespace editor {
struct ZoneManifest {
std::string mapName;
std::string displayName;
uint32_t mapId = 9000; // Custom map IDs start high to avoid conflicts
std::vector<std::pair<int, int>> tiles; // (tileX, tileY) pairs
std::string biome;
float baseHeight = 100.0f;
bool hasCreatures = false;
std::string description;
bool save(const std::string& path) const;
bool load(const std::string& path);
};
} // namespace editor
} // namespace wowee