mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
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:
parent
3d6c508491
commit
e0d14de5d2
6 changed files with 117 additions and 1 deletions
77
tools/editor/zone_manifest.cpp
Normal file
77
tools/editor/zone_manifest.cpp
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue