summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2024-01-01 16:21:43 -0500
committerJonathan Bradley <jcb@pikum.xyz>2024-01-01 16:21:43 -0500
commitb380281d1235ed6a4c6e271bd0c53d393f14b394 (patch)
tree99129a1fe9f2c175438b2827b0e1d0b8ed977727 /editor
parent95d8b7bf77b7f86e5c7a7be2fe76f1276d16e8ef (diff)
editor - create asset modal
Diffstat (limited to 'editor')
-rw-r--r--editor/editor.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index 8c6261e..ada13bf 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -496,6 +496,80 @@ void RecordImGui_AssetPicker(AssetPickerSearchStruct &apss) {
}
}
+void RecordImGuiModalCreateAsset() {
+ if (ImGui::BeginPopupModal("CreateAsset", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
+ static char assetPath[256];
+ static char assetKey[AssetKeyLength + 1];
+ static AssetType type;
+ assetPath[255] = '\0';
+ assetKey[AssetKeyLength] = '\0';
+
+ ImGui::InputText("Asset Key", assetKey, AssetKeyLength);
+
+ static bool bShader = false, bModel = false, bTexture = false, bAudio = false;
+ if (ImGui::Checkbox("Shader", &bShader)) {
+ bModel = false;
+ bTexture = false;
+ bAudio = false;
+ type = PKE_ASSET_TYPE_SHADER;
+ }
+ if (ImGui::Checkbox("Model", &bModel)) {
+ bShader = false;
+ bTexture = false;
+ bAudio = false;
+ type = PKE_ASSET_TYPE_MODEL;
+ }
+ if (ImGui::Checkbox("Texture", &bTexture)) {
+ bShader = false;
+ bModel = false;
+ bAudio = false;
+ type = PKE_ASSET_TYPE_TEXTURE;
+ }
+ if (ImGui::Checkbox("Audio", &bAudio)) {
+ bShader = false;
+ bModel = false;
+ bTexture = false;
+ type = PKE_ASSET_TYPE_AUDIO;
+ }
+
+ if (ImGui::Button("Select File")) {
+ const char * patterns[1] = {"*.*"};
+ char *selectedPath = tinyfd_openFileDialog(nullptr, "cafebabe.pstf", 1, patterns, "Pke Scene Text File", 0);
+ if (selectedPath != nullptr) {
+ strncpy(assetPath, selectedPath, 255);
+ }
+ }
+ ImGui::SameLine();
+ ImGui::Text("%s", assetPath);
+
+ ImGui::Separator();
+
+ bool shouldClose = false;
+
+ if (ImGui::Button("Create")) {
+ AM_Register(assetKey, type, assetPath);
+ shouldClose = true;
+ }
+ ImGui::SameLine();
+ if (ImGui::Button("Cancel")) {
+ shouldClose = true;
+ }
+
+ if (shouldClose) {
+ type = PKE_ASSET_TYPE_UNSET;
+ bModel = false;
+ bTexture = false;
+ bModel = false;
+ bAudio = false;
+ assetKey[0] = '\0';
+ assetPath[0] = '\0';
+ ImGui::CloseCurrentPopup();
+ }
+
+ ImGui::EndPopup();
+ }
+}
+
void RecordImGuiEditorWrapper() {
ImGui::DockSpaceOverViewport(nullptr, ImGuiDockNodeFlags_PassthruCentralNode);
ImGui::BeginMainMenuBar();
@@ -1140,6 +1214,9 @@ void RecordImGuiSceneEditor() {
ImGui::End();
return;
}
+ if (ImGui::Button("Create Asset")) {
+ ImGui::OpenPopup("CreateAsset");
+ }
if (ImGui::Button("Create Entity Type")) {
ImGui::OpenPopup("CreateEntityType");
}
@@ -1154,6 +1231,7 @@ void RecordImGuiSceneEditor() {
RecordImGui_CompInstPos(false, ECS_GetInstance(selectedEntity));
}
+ RecordImGuiModalCreateAsset();
RecordImGuiModalCreateEntityType();
ImGui::End();