From 47d3d48ad76d6a4e40da1d945cbc8940ae2922c7 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Fri, 31 Jan 2025 19:31:10 -0500 Subject: pke: first-pass font serialization --- src/project.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/project.cpp') diff --git a/src/project.cpp b/src/project.cpp index ee8a0b1..891e5ea 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -4,6 +4,7 @@ #include "plugins.hpp" #include "entities.hpp" #include "helpers.hpp" +#include "font.hpp" #include #include @@ -18,6 +19,7 @@ const char* const PKE_PROJ_FILE_OBJ_END = ""; const char* const PKE_PROJ_FILE_OBJ_PROJECT_SETTINGS = "ProjectSettings:"; const char* const PKE_PROJ_FILE_OBJ_ENTITY_TYPE = "EntityType:"; const char* const PKE_PROJ_FILE_OBJ_ASSET = "Asset:"; +const char* const PKE_PROJ_FILE_OBJ_FONT = "Font:"; const char* const PKE_PROJ_FILE_PROJ_SETTINGS_DEFAULT_SCENE_NAME = "PkeSet::DefaultSceneName: "; const char* const PKE_PROJ_FILE_PROJ_SETTINGS_SCENE_COUNT = "PkeSet::SceneCount: "; @@ -332,6 +334,10 @@ void PkeProject_Load(const char *filePath) { Proj_ParseEntityType(f); continue; } + if (strcmp(PKE_PROJ_FILE_OBJ_FONT, projReadLine) == 0) { + FontType_Deserialize(f); + continue; + } } f.close(); @@ -388,6 +394,16 @@ void PkeProject_Save(const char *filePath) { } } + FontTypeIndex font_count; + FontType *fonts = FontType_GetFonts(font_count); + for (FontTypeIndex b = FontTypeIndex{0}; b < font_count; ++b) { + FontType *ft = &fonts[(FontTypeIndex_T)b]; + if (ft->title.val == nullptr) continue; + f << PKE_PROJ_FILE_OBJ_FONT << std::endl; + FontType_Serialize(f, ft); + f << PKE_PROJ_FILE_OBJ_END << std::endl; + } + f << PKE_PROJ_FILE_END << std::endl; f.flush(); -- cgit v1.2.3