From 846a6e1185417ee3e187edc06ef327d180bf0d9b Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Thu, 16 Jan 2025 18:41:36 -0500 Subject: pke: add font asset type --- editor/editor.cpp | 8 +++++++- src/asset-manager.hpp | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/editor/editor.cpp b/editor/editor.cpp index e67ee12..a15c838 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -483,7 +483,8 @@ void RecordImGui_AssetPicker(AssetPickerSearchStruct &apss) { for (pk_handle_item_index_T i = 0; i < iCount; ++i) { const Asset &a = assets[i]; assetLabel &al = assetEntries.Push(); - memcpy(al.key, a.key, AssetKeyLength); + strncpy(al.key, a.key, AssetKeyLength); + al.key[AssetKeyLength-1] = '\0'; al.handle = a.handle; al.type = a.type; } @@ -538,6 +539,10 @@ void RecordImGuiModalCreateAsset() { assetTypeMask = assetTypeMask & (1U << static_cast(PKE_ASSET_TYPE_AUDIO)); type = PKE_ASSET_TYPE_AUDIO; } + if (ImGui::CheckboxFlags("Font", &assetTypeMask, 1U << static_cast(PKE_ASSET_TYPE_FONT))) { + assetTypeMask = assetTypeMask & (1U << static_cast(PKE_ASSET_TYPE_FONT)); + type = PKE_ASSET_TYPE_FONT; + } if (ImGui::Button("Select File")) { const char * patterns[1] = {"*.*"}; @@ -556,6 +561,7 @@ void RecordImGuiModalCreateAsset() { if (ImGui::Button("Create")) { AM_Register(assetKey, type, assetPath); shouldRebuildAssetList = true; + assetEntries.Resize(0); shouldClose = true; } ImGui::SameLine(); diff --git a/src/asset-manager.hpp b/src/asset-manager.hpp index 9129ceb..0a7cd5c 100644 --- a/src/asset-manager.hpp +++ b/src/asset-manager.hpp @@ -26,6 +26,7 @@ const AssetType PKE_ASSET_TYPE_SHADER = AssetType {0x01}; const AssetType PKE_ASSET_TYPE_MODEL = AssetType {0x02}; const AssetType PKE_ASSET_TYPE_TEXTURE = AssetType {0x04}; const AssetType PKE_ASSET_TYPE_AUDIO = AssetType {0x08}; +const AssetType PKE_ASSET_TYPE_FONT = AssetType {0x10}; const AssetType PKE_ASSET_TYPE_ALL = AssetType {0xFF}; constexpr int64_t EngineDefinedAssetCount = 4; -- cgit v1.2.3