diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-05-06 13:12:24 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-05-06 13:12:24 -0400 |
| commit | 32968050f0b34fdabfcc2a4fb5601d4be361bbd2 (patch) | |
| tree | acef384a2156a16d4d506c37f13f79d454a4a6e9 /editor | |
| parent | ef37d054dfe5812efa9eefb4b9b18621fdabac25 (diff) | |
pke: major serialization refactor, first-pass
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor-io.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/editor/editor-io.cpp b/editor/editor-io.cpp index 7b93b51..fdf21c4 100644 --- a/editor/editor-io.cpp +++ b/editor/editor-io.cpp @@ -10,9 +10,10 @@ void pke_editor_scene_save(const char *file_path) { srlztn_serialize_helper *helper = pke_serialize_init(pkeSettings.mem.bkt); bool failed = false; + std::ostringstream o; try { - pke_serialize_file_scene(helper); + pke_serialize_scene_to_stream(o, helper); } catch (std::exception &e) { fprintf(stderr, "[%s][Game_SaveSceneFile] Failed to serialize scene file: %s\n", __FILE__, e.what()); failed = false; @@ -26,7 +27,7 @@ void pke_editor_scene_save(const char *file_path) { if (!f.is_open()) { failed = true; } else { - f << helper->o.str(); + f << o.str(); } f.flush(); f.close(); @@ -38,7 +39,7 @@ void pke_editor_scene_save(const char *file_path) { strncpy(errFileName + strlen(file_path), ".err", 256 - strlen(file_path)); std::ofstream errF(file_path); if (errF.is_open()) { - errF << helper->o.str(); + errF << o.str(); errF.flush(); errF.close(); fprintf(stderr, "Failed to save scene file '%s', partial output saved to '%s'\n", file_path, errFileName); @@ -56,14 +57,13 @@ void pke_editor_scene_load(const char *file_path) { return; } srlztn_deserialize_helper *helper = pke_deserialize_init(pkeSettings.mem.bkt); - helper->i = &f; // TODO scene name is in the file? helper->scene = pke_scene_get_by_name(file_path); if (helper->scene == nullptr) { helper->scene = pke_scene_create(file_path); } - pke_deserialize_file_scene(helper); + pke_deserialize_scene_from_stream(f, helper); pke_deserialize_teardown(helper); @@ -71,7 +71,9 @@ void pke_editor_scene_load(const char *file_path) { } void pke_editor_project_save(const char *file_path) { + (void)file_path; } void pke_editor_project_load(const char *file_path) { + (void)file_path; } |
