diff --git a/src/editor/system/SystemEditor.cpp b/src/editor/system/SystemEditor.cpp index e1239b88cb9..7145f92b653 100644 --- a/src/editor/system/SystemEditor.cpp +++ b/src/editor/system/SystemEditor.cpp @@ -222,7 +222,7 @@ bool SystemEditor::LoadSystemFromFile(const FileSystem::FileInfo &file) ok = LoadCustomSystem(csys); if (ok) - m_systemInfo.comment = data["comment"]; + m_systemInfo.comment = data.value("comment", ""); } else if (ends_with_ci(file.GetPath(), ".lua")) { const CustomSystem *csys = m_systemLoader->LoadSystem(file.GetPath()); if (csys) diff --git a/src/pigui/PerfInfo.cpp b/src/pigui/PerfInfo.cpp index 629c06242d6..6b01267c1d3 100644 --- a/src/pigui/PerfInfo.cpp +++ b/src/pigui/PerfInfo.cpp @@ -17,6 +17,8 @@ #include "lua/Lua.h" #include "lua/LuaManager.h" #include "scenegraph/Model.h" +#include "JsonUtils.h" +#include "FileSystem.h" #include #include @@ -405,6 +407,27 @@ void PerfInfo::DrawWorldViewStats() if (system) system->Dump(Log::GetLog()->GetLogFileHandle()); } + + if (ImGui::Button("Dump System-Editor JSON")) { + SystemPath path = Pi::game->GetSectorView()->GetSelected(); + RefCountedPtr system = Pi::game->GetGalaxy()->GetStarSystem(path); + + if (system) { + const std::string fname = FileSystem::JoinPathBelow(FileSystem::userFiles.GetRoot(), fmt::format("{}.json", system->GetName())); + FILE *f = fopen(fname.c_str(), "w"); + + if (f) { + Json systemdef = Json::object(); + + system->DumpToJson(systemdef); + + std::string jsonData = systemdef.dump(1, '\t'); + + fwrite(jsonData.data(), 1, jsonData.size(), f); + fclose(f); + } + } + } } }