aboutsummaryrefslogtreecommitdiff
path: root/source/30-game/EditorUtils.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/30-game/EditorUtils.hpp')
-rw-r--r--source/30-game/EditorUtils.hpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/source/30-game/EditorUtils.hpp b/source/30-game/EditorUtils.hpp
index 99c522b..8a9ab95 100644
--- a/source/30-game/EditorUtils.hpp
+++ b/source/30-game/EditorUtils.hpp
@@ -1,7 +1,11 @@
#pragma once
-#include "Color.hpp"
+#include "EditorCore.hpp"
#include "EditorGuizmo.hpp"
+#include "Ires.hpp"
+
+#include <Color.hpp>
+#include <Metadata.hpp>
#include <imgui.h>
#include <string>
@@ -60,4 +64,21 @@ float CalcImageHeight(glm::vec2 original, int targetWidth);
float CalcImageWidth(glm::vec2 original, float targetHeight);
ImVec2 FitImage(glm::vec2 original);
+// TODO get kind from T
+template <class T>
+T* SimpleIresReceptor(T* existing, IEditor& editor, IresObject::Kind kind) {
+ if (existing) {
+ existing->ShowReference(editor);
+ } else {
+ IresObject::ShowReferenceNull(editor);
+ }
+ if (ImGui::BeginDragDropTarget()) {
+ if (auto payload = ImGui::AcceptDragDropPayload(Metadata::EnumToString(kind).data())) {
+ return *static_cast<T* const*>(payload->Data);
+ }
+ ImGui::EndDragDropTarget();
+ }
+ return nullptr;
+}
+
} // namespace Utils