|
|
|
|
@ -253,42 +253,33 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
OpRes State::SaveToFile(std::string filename)
|
|
|
|
|
{
|
|
|
|
|
// pugi::xml_document doc;
|
|
|
|
|
// doc.append_child("State");
|
|
|
|
|
|
|
|
|
|
// doc.child("State").append_child("DataDirectory");
|
|
|
|
|
// doc.child("State").child("DataDirectory").text().set(DataDirectory.c_str());
|
|
|
|
|
|
|
|
|
|
// const char* types[] = { "game", "editor", "test"};
|
|
|
|
|
// doc.child("State").append_child("Mode").append_attribute("Type").set_value(types[Mode]);
|
|
|
|
|
|
|
|
|
|
// // Display
|
|
|
|
|
// pugi::xml_node display = doc.child("State").append_child("Display");
|
|
|
|
|
// display.append_attribute("IsFullScreen").set_value(Display.IsFullScreen);
|
|
|
|
|
// display.append_attribute("VSyncEnabled").set_value(Display.VSyncEnabled);
|
|
|
|
|
|
|
|
|
|
// const char* names[] = { "opengl", "vulkan", "unknown" };
|
|
|
|
|
// display.append_attribute("Renderer").set_value(names[Display.Renderer]);
|
|
|
|
|
|
|
|
|
|
// pugi::xml_node fsr = display.append_child("FullScreenResolution");
|
|
|
|
|
// fsr.append_attribute("Width").set_value(Display.FullScreenResolution.Width);
|
|
|
|
|
// fsr.append_attribute("Height").set_value(Display.FullScreenResolution.Height);
|
|
|
|
|
|
|
|
|
|
// pugi::xml_node ws = display.append_child("WindowedSize");
|
|
|
|
|
// ws.append_attribute("Width").set_value(Display.WindowedSize.Width);
|
|
|
|
|
// ws.append_attribute("Height").set_value(Display.WindowedSize.Height);
|
|
|
|
|
|
|
|
|
|
// pugi::xml_node wsp = display.append_child("WindowStartPosition");
|
|
|
|
|
// wsp.append_attribute("X").set_value(Display.WindowStartPosition.X);
|
|
|
|
|
// wsp.append_attribute("Y").set_value(Display.WindowStartPosition.Y);
|
|
|
|
|
|
|
|
|
|
// // Interface
|
|
|
|
|
// pugi::xml_node interface = doc.child("State").append_child("Interface");
|
|
|
|
|
// interface.append_attribute("MainFont").set_value(Interface.MainFont.c_str());
|
|
|
|
|
|
|
|
|
|
// return doc.save_file(filename.c_str())
|
|
|
|
|
// ? OpRes::OK()
|
|
|
|
|
// : OpRes::Fail((std::string("Could not save xml file: ") + filename).c_str());
|
|
|
|
|
nlohmann::json j;
|
|
|
|
|
auto& s = j["State"];
|
|
|
|
|
s["DataDirectory"] = DataDirectory;
|
|
|
|
|
|
|
|
|
|
auto& d = s["Display"];
|
|
|
|
|
const char* names[] = { "opengl", "vulkan", "unknown" };
|
|
|
|
|
d["FullScreenResolution"]["Width"] = Display.FullScreenResolution.Width;
|
|
|
|
|
d["FullScreenResolution"]["Height"] = Display.FullScreenResolution.Height;
|
|
|
|
|
d["WindowedSize"]["Width"] = Display.WindowedSize.Width;
|
|
|
|
|
d["WindowedSize"]["Height"] = Display.WindowedSize.Height;
|
|
|
|
|
d["WindowStartPosition"]["X"] = Display.WindowStartPosition.X;
|
|
|
|
|
d["WindowStartPosition"]["Y"] = Display.WindowStartPosition.Y;
|
|
|
|
|
d["Renderer"] = names[Display.Renderer];
|
|
|
|
|
d["IsFullScreen"] = Display.IsFullScreen;
|
|
|
|
|
d["VSyncEnabled"] = Display.VSyncEnabled;
|
|
|
|
|
|
|
|
|
|
auto& i = s["Interface"];
|
|
|
|
|
i["MainFont"] = Interface.MainFont;
|
|
|
|
|
|
|
|
|
|
std::ofstream ofs = std::ofstream(filename.c_str());
|
|
|
|
|
if (!ofs.is_open())
|
|
|
|
|
{
|
|
|
|
|
return OpRes::Fail("Could not save state file: %s - failed to open/create file", filename.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ofs << std::setw(4) << j;
|
|
|
|
|
ofs.close();
|
|
|
|
|
|
|
|
|
|
return OpRes::OK();
|
|
|
|
|
}
|
|
|
|
|
|