summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-01-16 18:41:36 -0500
committerJonathan Bradley <jcb@pikum.xyz>2025-01-16 18:41:36 -0500
commit846a6e1185417ee3e187edc06ef327d180bf0d9b (patch)
treec372f0dbe0d12361acd5ef60c082679a1651d863
parent15524958f409b1f13a1deffc4dd8c1fbddefaf28 (diff)
pke: add font asset type
-rw-r--r--editor/editor.cpp8
-rw-r--r--src/asset-manager.hpp1
2 files changed, 8 insertions, 1 deletions
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<AssetType_T>(PKE_ASSET_TYPE_AUDIO));
type = PKE_ASSET_TYPE_AUDIO;
}
+ if (ImGui::CheckboxFlags("Font", &assetTypeMask, 1U << static_cast<AssetType_T>(PKE_ASSET_TYPE_FONT))) {
+ assetTypeMask = assetTypeMask & (1U << static_cast<AssetType_T>(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;