summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-12-28 12:00:47 -0500
committerJonathan Bradley <jcb@pikum.xyz>2023-12-28 12:00:47 -0500
commitcf0fac0eab12421f407d3acc1f1c84faead248bc (patch)
treec5b174085ebcd1bccaa29d20334e4123ade73f6b /editor
parent41b5dafb1a3bf80db48abeb235ce00ec8e1c566f (diff)
add asset type for filtering
Diffstat (limited to 'editor')
-rw-r--r--editor/editor.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index 3a8e068..542769a 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -442,6 +442,7 @@ void RecordImGui_GLM(const char *label, glm::mat4 &mat) {
struct assetLabel {
AssetKey key = {'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'};
AssetHandle handle{};
+ AssetType type{};
};
DynArray<assetLabel> assetEntries{0, nullptr};
int assetLabelCmp(const void *a, const void *b) {
@@ -456,6 +457,7 @@ struct AssetPickerSearchStruct {
int64_t selectedItem = -1;
char source[8];
char safeKey[AssetKeyLength + 1];
+ AssetType type{PKE_ASSET_TYPE_ALL};
};
void RecordImGui_AssetPicker(AssetPickerSearchStruct &apss) {
if (shouldRebuildAssetList == true) {
@@ -469,6 +471,7 @@ void RecordImGui_AssetPicker(AssetPickerSearchStruct &apss) {
assetLabel &al = assetEntries.Push();
memcpy(al.key, a.key, AssetKeyLength);
al.handle = a.handle;
+ al.type = a.type;
}
}
}
@@ -479,6 +482,9 @@ void RecordImGui_AssetPicker(AssetPickerSearchStruct &apss) {
const int64_t iCount = assetEntries.Count();
for (int64_t i = 0; i < iCount; ++i) {
const assetLabel &al = assetEntries[i];
+ if ((al.type & apss.type) == AssetType{0}) {
+ continue;
+ }
char buf[AssetKeyLength + 1];
snprintf(buf, AssetKeyLength + 1, "%s", al.key);
if (ImGui::Selectable(buf, apss.selectedItem == i)) {
@@ -778,10 +784,12 @@ void RecordImGuiModalCreateEntityType() {
static AssetPickerSearchStruct apssModel{
.source = {"cet_mdl"},
.safeKey = {""},
+ .type = PKE_ASSET_TYPE_MODEL,
};
static AssetPickerSearchStruct apssTexture{
.source = {"cet_txr"},
.safeKey = {""},
+ .type = PKE_ASSET_TYPE_TEXTURE,
};
if (ImGui::Button("Model Key")) {