241{
243 const json root_json = json::parse(root_json_string);
244
245 const auto &gui_json = root_json.find("gui");
246 const auto &render_json = root_json.find("render");
247 const auto &scene_data_json = root_json.find("scene_data");
248 const auto &objects_json = root_json.find("objects");
249
250 if (gui_json != root_json.end())
251 {
252 const auto &is_gui_enabled = gui_json->find("is_gui_enabled");
253 const auto &is_dockspace = gui_json->find("is_dockspace");
254
255 if (is_gui_enabled != gui_json->end()) application::Get().GuiEnabled = is_gui_enabled->get<bool>();
256 if (is_dockspace != gui_json->end())
gui::IsDockspace = is_dockspace->get<
bool>();
257 }
258 if (render_json != root_json.end())
259 {
260 const auto &clear_color = render_json->find("clear_color");
261 const auto &is_wireframe = render_json->find("is_wireframe");
262 const auto &is_vsync = render_json->find("is_vsync");
263
267 }
268 if (scene_data_json != root_json.end())
269 {
270 const auto &viewport_id = scene_data_json->find("viewport_id");
271 const auto &enviroment_ambient = scene_data_json->find("enviroment_ambient");
272
273 if (viewport_id != scene_data_json->end()) Scene->SetViewportId(viewport_id->get<int>());
274 if (enviroment_ambient != scene_data_json->end()) Scene->SetEnviromentAmbient(enviroment_ambient->get<
vec3>());
275 }
276 if (objects_json != root_json.end())
277 {
278 for (const auto &object_json : *objects_json)
279 {
280 scene_object object;
281 const auto &name_json = object_json.find(typeid(name_component).name());
282 if (name_json == object_json.end())
283 {
284 object = Scene->CreateObject();
285 }
286 else
287 {
288 name_component object_name_component { "" };
289 from_json(*name_json, object_name_component);
290 object = Scene->CreaetOrGetObject(object_name_component.Name);
291 }
292
293 DeserializeObject(object_json, object);
294 }
295 }
296
297}
static void SetVSync(bool VSync)
static void SetClearColor(const vec4 &ClearColor)
static void SetWireframeMode(bool IsWireframe)
std::string LoadFile(const std::filesystem::path &FilePath)
bool from_json(const json &Json, name_component &NameComponent)