diff --git a/.clang-format b/.clang-format index 9212806..4116e5c 100644 --- a/.clang-format +++ b/.clang-format @@ -17,3 +17,4 @@ AllowShortIfStatementsOnASingleLine: false BreakBeforeBraces: Attach NamespaceIndentation: All PointerAlignment: Left +ColumnLimit: 0 diff --git a/DeerStudio/src/DeerStudio/DockPanel/DockPanelContext.cpp b/DeerStudio/src/DeerStudio/DockPanel/DockPanelContext.cpp new file mode 100644 index 0000000..2679701 --- /dev/null +++ b/DeerStudio/src/DeerStudio/DockPanel/DockPanelContext.cpp @@ -0,0 +1,90 @@ +#include "DeerStudio/DockPanel/DockPanelContext.h" +#include "Deer/Log.h" +#include "DeerStudio/EditorEngine.h" + +#include "angelscript.h" +#include + +namespace Deer { + namespace EditorEngine { + DockPanelContext::DockPanelContext(asIScriptModule* _module, + DockPanelInfo* _info) + : module(_module), info(_info) { + + size_t nScripts = module->GetObjectTypeCount(); + asITypeInfo* dockPanelType = + scriptEngine->GetTypeInfoByName("DockPanel"); + + if (!dockPanelType) { + DEER_EDITOR_ENGINE_ERROR( + "Could not load DockPanel interface type"); + return; + } + + context = scriptEngine->CreateContext(); + context->AddRef(); + for (size_t i = 0; i < nScripts; i++) { + asITypeInfo* info = module->GetObjectTypeByIndex(i); + + // If it does not implement dock panel we are not interested int + // it + if (!info->Implements(dockPanelType)) + continue; + + dockPanels.push_back({info, context}); + } + } + + DockPanelContext::DockPanelContext(DockPanelContext&& dp) + : dockPanels(std::move(dp.dockPanels)) { + module = dp.module; + context = dp.context; + info = dp.info; + + dp.context = nullptr; + dp.module = nullptr; + dp.info = nullptr; + } + + DockPanelContext& DockPanelContext::operator=(DockPanelContext&& dp) { + if (&dp != this) { + dockPanels = std::move(dp.dockPanels); + module = dp.module; + context = dp.context; + info = dp.info; + + dp.context = nullptr; + dp.module = nullptr; + dp.info = nullptr; + } + return *this; + } + + void DockPanelContext::init() { + for (DockPanelObject& panel : dockPanels) { + currentDockPanelExecution = &panel; + panel.init(); + } + + currentDockPanelExecution = nullptr; + } + + void DockPanelContext::render() { + for (DockPanelObject& panel : dockPanels) { + currentDockPanelExecution = &panel; + panel.render(); + } + + currentDockPanelExecution = nullptr; + } + + DockPanelContext::~DockPanelContext() { + dockPanels.clear(); + + if (context) + context->Release(); + + delete info; + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelContext.h b/DeerStudio/src/DeerStudio/DockPanel/DockPanelContext.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelContext.h rename to DeerStudio/src/DeerStudio/DockPanel/DockPanelContext.h diff --git a/DeerStudio/src/DeerStudio/DockPanel/DockPanelInfo.h b/DeerStudio/src/DeerStudio/DockPanel/DockPanelInfo.h new file mode 100644 index 0000000..216263d --- /dev/null +++ b/DeerStudio/src/DeerStudio/DockPanel/DockPanelInfo.h @@ -0,0 +1,19 @@ +#pragma once +#include "DeerStudio/ServiceScript/ServiceScriptInfo.h" + +#include "Deer/Path.h" +#include +#include + +namespace Deer { + namespace EditorEngine { + struct DockPanelInfo { + std::string name = "null"; + std::string author = ""; + std::string version = "0.0.0"; + std::vector services; + }; + + DockPanelInfo* loadDockPanelInfo(Path panelInfo); + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/DockPanel/DockPanelInfoSerialization.cpp b/DeerStudio/src/DeerStudio/DockPanel/DockPanelInfoSerialization.cpp new file mode 100644 index 0000000..8a271f4 --- /dev/null +++ b/DeerStudio/src/DeerStudio/DockPanel/DockPanelInfoSerialization.cpp @@ -0,0 +1,49 @@ +#include "Deer/Log.h" +#include "DeerStudio/DockPanel/DockPanelInfo.h" + +#include "cereal/archives/json.hpp" +#include "cereal/cereal.hpp" +#include "cereal/types/string.hpp" +#include "cereal/types/vector.hpp" + +#include +#include +#include + +namespace Deer { + namespace EditorEngine { + template + void serialize(Archive& ar, DockPanelInfo& data) { + ar(cereal::make_nvp("name", data.name)); + ar(cereal::make_nvp("author", data.author)); + ar(cereal::make_nvp("version", data.version)); + ar(cereal::make_nvp("services", data.services)); + } + + template + void serialize(Archive& ar, ServiceScriptRef& data) { + ar(cereal::make_nvp("name", data.name)); + ar(cereal::make_nvp("version", data.version)); + } + + DockPanelInfo* loadDockPanelInfo(Path dockPanelInfoPath) { + try { + std::ifstream is(dockPanelInfoPath); + + if (!is) + return new DockPanelInfo(); + + DockPanelInfo* info = new DockPanelInfo(); + { + cereal::JSONInputArchive archive(is); + archive(cereal::make_nvp("dockPanelModule", *info)); + } + + return info; + } catch (const std::exception& e) { + DEER_EDITOR_ENGINE_TRACE(e.what()); + return new DockPanelInfo(); + } + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/DockPanel/DockPanelObject.cpp b/DeerStudio/src/DeerStudio/DockPanel/DockPanelObject.cpp new file mode 100644 index 0000000..02bacb6 --- /dev/null +++ b/DeerStudio/src/DeerStudio/DockPanel/DockPanelObject.cpp @@ -0,0 +1,213 @@ +#include "DeerStudio/DockPanel/DockPanelObject.h" +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" + +#include "Deer/Log.h" + +#include "angelscript.h" +#include + +#include "imgui.h" + +namespace Deer { + EditorEngine::DockPanelObject::DockPanelObject( + asITypeInfo* _type, asIScriptContext* _scriptContext) + : type(_type), isValid(false), scriptContext(_scriptContext) { + + // Constructor + // "type@ type()" + std::string callString; + const std::string ns(type->GetNamespace()); + if (ns != "") { + callString += ns; + callString += "::"; + } + callString += type->GetName(); + callString += "@ "; + if (ns != "") { + callString += ns; + callString += "::"; + } + callString += type->GetName(); + callString += "()"; + + flags = DockPannelFlag_ShowPannel; + + asIScriptFunction* factory = type->GetFactoryByDecl(callString.c_str()); + + AS_CHECK(scriptContext->Prepare(factory)); + AS_CHECK(scriptContext->Execute()); + + // Return value contains the ref to a asIScriptObject in the location + // provided + object = *(asIScriptObject**)scriptContext->GetAddressOfReturnValue(); + if (!object) { + DEER_EDITOR_ENGINE_ERROR("Could not create object", + type->GetName()); + return; + } + object->AddRef(); + + renderFunction = type->GetMethodByDecl("void onRender()"); + if (!renderFunction) { + DEER_EDITOR_ENGINE_ERROR("Could not load void onRender() from {0}", + type->GetName()); + return; + } + + menuBarFunction = type->GetMethodByDecl("void onMenuBar()"); + initFunction = type->GetMethodByDecl("void onInit()"); + + isValid = true; + + scriptContext->Unprepare(); + } + + int EditorEngine::DockPanelObject::getRefCount() { + int refCount = object->AddRef(); // increments refcount by 1 + refCount = object->Release(); + + return refCount; + } + + const char* EditorEngine::DockPanelObject::getName() { + return type->GetName(); + } + + EditorEngine::DockPanelObject::~DockPanelObject() { + if (object) + object->Release(); + } + + void EditorEngine::DockPanelObject::invalidate() { + DEER_EDITOR_ENGINE_ERROR("Last error was caused executing {0}", + type->GetName()); + isValid = false; + } + + void EditorEngine::DockPanelObject::init() { + + if (!initFunction) + return; + + executingScriptContext = scriptContext; + AS_CHECK(scriptContext->Prepare(initFunction)); + AS_CHECK(scriptContext->SetObject(object)); + AS_CHECK(scriptContext->Execute()); + AS_CHECK(scriptContext->Unprepare()); + executingScriptContext = nullptr; + } + + void EditorEngine::DockPanelObject::render() { + bool show = flags & DockPannelFlag_ShowPannel; + if (!show) + return; + + // We cache the result because the user can remove the flag while + // executing + bool hasPadding = flags & DockPannelFlag_PannelPadding; + if (hasPadding) + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); + + if (menuBarFunction) { + ImGui::Begin(type->GetName(), (bool*)0, ImGuiWindowFlags_MenuBar); + + if (ImGui::BeginMenuBar()) { + executingScriptContext = scriptContext; + AS_CHECK(scriptContext->Prepare(menuBarFunction)); + AS_CHECK(scriptContext->SetObject(object)); + AS_CHECK(scriptContext->Execute()); + AS_CHECK(scriptContext->Unprepare()); + executingScriptContext = nullptr; + + ImGui::EndMenuBar(); + } + } else { + ImGui::Begin(type->GetName()); + } + + // This is to make sure that right click activates the window + if (ImGui::IsWindowHovered( + ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) && + (ImGui::IsMouseClicked(ImGuiMouseButton_Right) || + ImGui::IsMouseClicked(ImGuiMouseButton_Middle))) { + ImGui::SetWindowFocus(); + } + + if (!isValid) { + ImGui::TextColored(ImVec4(1, 0.3f, 0.3f, 1), + "There was a runtime error"); + ImGui::TextColored(ImVec4(1, 0.4f, 0.4f, 1), + "Please check the log"); + ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1), + "Plese restart the interface"); + ImGui::End(); + return; + } + + executingScriptContext = scriptContext; + AS_CHECK(scriptContext->Prepare(renderFunction)); + AS_CHECK(scriptContext->SetObject(object)); + AS_CHECK(scriptContext->Execute()); + AS_CHECK(scriptContext->Unprepare()); + executingScriptContext = nullptr; + + ImGui::End(); + + if (hasPadding) + ImGui::PopStyleVar(); + } + + EditorEngine::DockPanelObject::DockPanelObject( + DockPanelObject&& other) noexcept + : isValid(other.isValid), renderFunction(other.renderFunction), + type(other.type), object(other.object), + menuBarFunction(other.menuBarFunction), + initFunction(other.initFunction), flags(other.flags), + scriptContext(other.scriptContext) { + + other.isValid = false; + other.renderFunction = nullptr; + other.type = nullptr; + other.object = nullptr; + other.menuBarFunction = nullptr; + other.initFunction = nullptr; + other.scriptContext = nullptr; + } + + EditorEngine::DockPanelObject& EditorEngine::DockPanelObject::operator=( + EditorEngine::DockPanelObject&& other) noexcept { + if (this != &other) { + if (object) + object->Release(); + + isValid = other.isValid; + renderFunction = other.renderFunction; + type = other.type; + object = other.object; + menuBarFunction = other.menuBarFunction; + initFunction = other.initFunction; + flags = other.flags; + scriptContext = other.scriptContext; + + other.isValid = false; + other.renderFunction = nullptr; + other.type = nullptr; + other.object = nullptr; + other.menuBarFunction = nullptr; + other.initFunction = nullptr; + other.scriptContext = nullptr; + } + + return *this; + } + + void EditorEngine::DockPanelObject::setFlag(uint32_t flag, bool value) { + if ((flag & flags) != value) + flags ^= flag; + } + + bool EditorEngine::DockPanelObject::getFlag(uint32_t flag) { + return flag & flags; + } +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelObject.h b/DeerStudio/src/DeerStudio/DockPanel/DockPanelObject.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelObject.h rename to DeerStudio/src/DeerStudio/DockPanel/DockPanelObject.h diff --git a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/LoadDockPanels.cpp b/DeerStudio/src/DeerStudio/DockPanel/LoadDockPanels.cpp similarity index 79% rename from DeerStudio/src/DeerStudio/EditorEngine/DockPanel/LoadDockPanels.cpp rename to DeerStudio/src/DeerStudio/DockPanel/LoadDockPanels.cpp index b9a722d..a70f284 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/LoadDockPanels.cpp +++ b/DeerStudio/src/DeerStudio/DockPanel/LoadDockPanels.cpp @@ -1,11 +1,11 @@ #include "Deer/Log.h" +#include "DeerStudio/DockPanel/DockPanelContext.h" +#include "DeerStudio/DockPanel/DockPanelInfo.h" #include "DeerStudio/EditorEngine.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelInfo.h" #include "DeerStudio/EditorEngine/ErrorHandle.h" #include "DeerStudio/EditorEngine/AngelscriptPredefined.h" -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.h" +#include "DeerStudio/ServiceScript/ServiceScriptContext.h" #include "Deer/DataStore.h" #include "Deer/Path.h" @@ -24,10 +24,10 @@ namespace Deer { namespace EditorEngine { CScriptBuilder scriptBuilder; - ServiceScriptContext * - getServiceScriptContext(const ServiceScriptRef &ref) { - for (ServiceScriptContext &ctx : serviceScriptModules) { - const ServiceScriptInfo &info = ctx.getInfo(); + ServiceScriptContext* + getServiceScriptContext(const ServiceScriptRef& ref) { + for (ServiceScriptContext& ctx : serviceScriptModules) { + const ServiceScriptInfo& info = ctx.getInfo(); if (info.name == ref.name && info.version == ref.version) { return &ctx; @@ -48,7 +48,7 @@ namespace Deer { } DEER_CORE_TRACE("Extracting UI Engine Scripts "); - for (const auto &_dir : fs::directory_iterator(path)) { + for (const auto& _dir : fs::directory_iterator(path)) { Path panelInfo_path = _dir.path() / "dockPanelModule.json"; // A panel info is neded to load a panel @@ -60,7 +60,7 @@ namespace Deer { continue; } - DockPanelInfo *dockPanelInfo = loadDockPanelInfo(panelInfo_path); + DockPanelInfo* dockPanelInfo = loadDockPanelInfo(panelInfo_path); if (dockPanelInfo->name == "null") { DEER_EDITOR_ENGINE_ERROR( "Failed to load dock panel module from {0},\n incorrect " @@ -83,11 +83,11 @@ namespace Deer { continue; } - asIScriptModule *module = scriptBuilder.GetModule(); + asIScriptModule* module = scriptBuilder.GetModule(); // Extract apis - for (const ServiceScriptRef &serviceRef : dockPanelInfo->services) { - ServiceScriptContext *ctx = getServiceScriptContext(serviceRef); + for (const ServiceScriptRef& serviceRef : dockPanelInfo->services) { + ServiceScriptContext* ctx = getServiceScriptContext(serviceRef); if (ctx == nullptr) { DEER_EDITOR_ENGINE_ERROR( @@ -101,7 +101,7 @@ namespace Deer { serviceRef.name.c_str()); } - for (const auto &entry : fs::recursive_directory_iterator(_dir)) { + for (const auto& entry : fs::recursive_directory_iterator(_dir)) { if (entry.is_regular_file() && entry.path().extension() == ".as") { r = scriptBuilder.AddSectionFromFile( diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API.h b/DeerStudio/src/DeerStudio/EditorEngine/API.h index 479fcd1..75dbb63 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API.h +++ b/DeerStudio/src/DeerStudio/EditorEngine/API.h @@ -1,11 +1,12 @@ #pragma once -#include "DeerStudio/EditorEngine/API/Asset.h" -#include "DeerStudio/EditorEngine/API/Debug.h" -#include "DeerStudio/EditorEngine/API/Entity.h" -#include "DeerStudio/EditorEngine/API/Environment.h" -#include "DeerStudio/EditorEngine/API/FrameBuffer.h" -#include "DeerStudio/EditorEngine/API/Layout.h" -#include "DeerStudio/EditorEngine/API/Math.h" -#include "DeerStudio/EditorEngine/API/Menu.h" -#include "DeerStudio/EditorEngine/API/UI.h" +#include "DeerStudio/StudioAPI/Asset.h" +#include "DeerStudio/StudioAPI/Debug.h" +#include "DeerStudio/StudioAPI/Engine.h" +#include "DeerStudio/StudioAPI/Entity.h" +#include "DeerStudio/StudioAPI/Environment.h" +#include "DeerStudio/StudioAPI/FrameBuffer.h" +#include "DeerStudio/StudioAPI/Layout.h" +#include "DeerStudio/StudioAPI/Math.h" +#include "DeerStudio/StudioAPI/Menu.h" +#include "DeerStudio/StudioAPI/UI.h" diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h b/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h deleted file mode 100644 index d346887..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h +++ /dev/null @@ -1,129 +0,0 @@ -#pragma once -#include "DeerStudio/EditorEngine/API/GenericRefStructs.h" - -#include -#include -#include "glm/glm.hpp" - -namespace Deer { - namespace EditorEngine { - struct EntityStruct; - extern EntityStruct activeEntity; - - // IN ANGEL SCRIPT IT LOOKS LIKE THIS - //class Entity { - // int id; - // string name; - // - // int childCount; - // bool isRoot; - // - // Entity parent; - // Entiy getChild(int); - // Entity createChild(int); - // - // void destroy(); - // bool isDescendantOf - // - // bool == - //} - struct EntityStruct : EntityHandleStruct { - EntityStruct(uint16_t entId = 0) { entityId = entId; } - - std::string getName(); - void setName(std::string&); - - int getId(); - bool exists(); - - bool isRoot(); - void destroy(); - - EntityHandleStruct createChild(std::string&); - - void setParent(EntityHandleStruct parent); - EntityHandleStruct getParent(); - - bool isDescendantOf(EntityHandleStruct parent); - bool opEquals(const EntityHandleStruct& other); - - //COMPONENTS - EntityHandleStruct getMeshComponent(); - EntityHandleStruct createMeshComponent(); - bool hasMeshComponent(); - void removeMeshComponent(); - - EntityHandleStruct getShaderComponent(); - EntityHandleStruct createShaderComponent(); - bool hasShaderComponent(); - void removeShaderComponent(); - - EntityHandleStruct getCameraComponent(); - EntityHandleStruct createCameraComponent(); - bool hasCameraComponent(); - void removeCameraComponent(); - - // This function can be adapted to get a specific transform since the data is the same - EntityHandleStruct getSelf(); - }; - - struct EntityChildArrayStruct : EntityHandleStruct { - int getChildCount(); - EntityHandleStruct getChild(int); - }; - - struct TransformComponentStruct : EntityHandleStruct { - glm::vec3 getPosition(); - glm::vec3 getScale(); - glm::vec3 getRotation(); - - void setPosition(glm::vec3); - void setScale(glm::vec3); - void setRotation(glm::vec3); - }; - - struct MeshComponentStruct : EntityHandleStruct { - bool isActive(); - void setActive(bool); - - bool hasMesh(); - void clear(); - - std::string getMesh(); - void setMesh(std::string&); - - bool assertMeshComponent(const char* funcName); - }; - - struct ShaderComponentStruct : EntityHandleStruct { - bool hasShader(); - void clear(); - - std::string getShader(); - void setShader(std::string&); - - bool assertShaderComponent(const char* funcName); - }; - - struct CameraComponentStruct : EntityHandleStruct { - float getFov(); - float getAspectRation(); - float getNearZ(); - float getFarZ(); - - void setFov(float); - void setAspectRation(float); - void setNearZ(float); - void setFarZ(float); - - bool assertCameraComponent(const char* funcName); - }; - - EntityHandleStruct getRoot(); - void constructEntityStruct(int id, void* memory); - void copyEntityStruct(int id, void* memory); - - void registerEntityStructs(); - void registerEntityFunctions(); - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h b/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h deleted file mode 100644 index e5e3066..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "DeerStudio/EditorEngine/API/GenericRefStructs.h" -#include -#include - -namespace Deer { - namespace EditorEngine { - struct FrameBufferStruct : FrameBufferHandleStruct{ - FrameBufferStruct(uint16_t _id) { frameBufferId = _id; } - - int getWidth(); - int getHeight(); - - void clearRGBA(int, int, int, int); - bool isValid(); - - void resize(int, int); - std::string getName(); - }; - - FrameBufferStruct createRGBA8FrameBuffer(std::string& name, int, int); - FrameBufferStruct getFrameBuffer(std::string& name); - - void frameBuffer_constructor(FrameBufferHandleStruct* mem); - - void registerFrameBufferStructs(); - void registerFrameBufferFunctions(); - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/UI.h b/DeerStudio/src/DeerStudio/EditorEngine/API/UI.h deleted file mode 100644 index 77327d3..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/UI.h +++ /dev/null @@ -1,106 +0,0 @@ -#pragma once -#include -#include "glm/glm.hpp" -#include "DeerStudio/EditorEngine/API/GenericRefStructs.h" - -class asIScriptFunction; -class CScriptAny; - -namespace Deer { - namespace EditorEngine { - namespace DragDropPayload { - extern CScriptAny* payload; - } - - // Renders the ui elements in the same line - void sameline(); - // Renders a line separator - void separator(); - - // Renders a button - bool button(std::string&); - // Renders a button at the end - bool buttonCenter(std::string&); - // Renders a button at the end - bool buttonEnd(std::string&); - - // Renders a text - void text(std::string&); - // Renders a text - void textCenter(std::string&); - // Renders a text - void textEnd(std::string&); - - // Renders a text with the defined rgb values from range [0.0, 1.0] - void textColor(float r, float g, float b, std::string& msg); - // Renders a big text - void title(std::string&); - // Renders a big text - void titleCenter(std::string&); - // Renders a big text - void titleEnd(std::string&); - - // Renders a big text in the center of a specified height - void titleCenterY(std::string&, int); - - // Renders a icon in the specified size in pixels - void drawIcon(std::string& iconId, int size); - // Renders a icon in the specified size in pixels at the center - void drawIconCentered(std::string& iconId, int size); - - // Renders a icon in the specified size in pixels - void drawFrameBuffer(FrameBufferHandleStruct frameBuffer, int sizeX, int sizeY); - // Renders a icon in the specified size in pixels - void drawFrameBufferCentered(FrameBufferHandleStruct frameBuffer, int sizeX, int sizeY); - - // Returns if the specified mouse button is clicked on the last element - bool isItemClicked(int mouse); - // Returns if the specified mouse button is double clicked - bool isMouseDoubleClicked(int mouse); - - bool isKeyDown(int); - bool isKeyPressed(int); - - bool isMouseDraggin(int); - float getMouseDragDeltaX(); - float getMouseDragDeltaY(); - float getMouseDeltaX(); - float getMouseDeltaY(); - - void disablePannelPadding(bool); - - int getAvailableSizeX(); - int getAvailableSizeY(); - - float slider(std::string&, float, float, float); - int sliderInt(std::string&, int, int, int); - - // Draws a button for a popup menu - bool menuItem(std::string&); - // Draws a button disabled - void menuItemDisabled(std::string&); - // Draws a space where you can put buttons inside - void menuSpace(std::string&, CScriptAny*, asIScriptFunction*); - - // Initializes the drag drop source with the id and the data you want to pass - void dragDropSource(std::string&, CScriptAny*, std::string&); - // Prepares the function to accept payload with the id and calls the function with the data - void dragDropTarget(std::string&, CScriptAny*, asIScriptFunction*); - - // Draws a simple input with a label, input and output string - bool inputText(std::string& label, std::string&, std::string&); - // Draws a simple checkbox - bool checkbox(std::string& label, bool); - // Draws a simple checkbox - bool checkboxDisabled(std::string& label, bool); - // Draws a complex slider that with double click you can set a specific value - float magicSlider(std::string&, float, float); - // Draws a complex slider that with double click you can set a specific value in vec3 - glm::vec3 magicSlider3(std::string&, glm::vec3, float); - // Returns if the current executing pannel is active - bool isPannelActive(); - - void registerUIFunctions(); - void registerUIStructs(); - } -} diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Debug.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Debug.cpp deleted file mode 100644 index 7a1aeed..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Debug.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "DeerStudio/EditorEngine/API/Debug.h" -#include "Deer/Log.h" - -#include "angelscript.h" -#include "imgui.h" - -namespace Deer { - namespace EditorEngine { - - void errorCallback(const asSMessageInfo *msg, void *param) { - if (msg->type == asMSGTYPE_WARNING) { - DEER_EDITOR_ENGINE_WARN("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message); - } else if( msg->type == asMSGTYPE_INFORMATION ) { - DEER_EDITOR_ENGINE_ERROR("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message); - } else if (msg->type == asMSGTYPE_INFORMATION){ - DEER_EDITOR_ENGINE_TRACE("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message); - } - } - - void print(std::string& msg) { - DEER_EDITOR_ENGINE_INFO("{0}", msg.c_str()); - } - - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp deleted file mode 100644 index f46df16..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp +++ /dev/null @@ -1,509 +0,0 @@ -#include "DeerStudio/EditorEngine/API/Entity.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h" -#include "DeerStudio/EditorEngine.h" - -#include "DeerRender/Components.h" - -#include "Deer/Enviroment.h" -#include "Deer/Scene.h" - -#include - -#define GET_ENV(env) (*Deer::EditorEngine::environments[env]) - -#define GET_ENTITY(env, id) GET_ENV(env).getEntity(id) -#define GET_MESH_COMPONENT(env, id) GET_ENV(env).getEntity(id).getComponent() -#define GET_SHADER_COMPONENT(env, id) GET_ENV(env).getEntity(id).getComponent() -#define GET_CAMERA_COMPONENT(env, id) GET_ENV(env).getEntity(id).getComponent() - -#define ASSERT_ENTITY(func, ret) if (!assertEntity(func)) ret; -#define ASSERT_MESH_COMPONENT(func, ret) if (!assertMeshComponent(func)) ret; -#define ASSERT_SHADER_COMPONENT(func, ret) if (!assertShaderComponent(func)) ret; -#define ASSERT_CAMERA_COMPONENT(func, ret) if (!assertCameraComponent(func)) ret; - - -namespace Deer { - namespace EditorEngine { - extern std::vector > environments; - - EntityHandleStruct getRoot() { - return EntityStruct(0); - } - - void constructEntityStruct(int id, void* memory) { - new (memory)EntityStruct(id); - } - - int EntityStruct::getId() { - return entityId; - } - - bool EntityHandleStruct::assertEntity(const char* funcName) { - if (!Scene::environment.entityExists(entityId)) { - DEER_EDITOR_ENGINE_ERROR("Error, invalid entity calling {0}, entityId : {1}", funcName, entityId); - if (currentDockPanelExecution) - currentDockPanelExecution->invalidate(); - return false; - } - return true; - } - - std::string EntityStruct::getName() { - ASSERT_ENTITY("getName()", return "NULL"); - - return GET_ENTITY(environmentId, entityId) - .getComponent() - .tag; - } - - - void EntityStruct::setName(std::string& name) { - ASSERT_ENTITY("setName()", return); - - GET_ENTITY(environmentId, entityId) - .getComponent() - .tag = name; - } - - void EntityStruct::destroy() { - ASSERT_ENTITY("destroy()", return); - - GET_ENTITY(environmentId, entityId) - .destroy(); - } - - bool EntityStruct::isRoot() { - ASSERT_ENTITY("isRoot()", return false); - - return entityId == 0; - } - - bool EntityStruct::exists() { - ASSERT_ENTITY("exists()", return false); - - return Scene::environment - .entityExists(entityId); - } - - void EntityStruct::setParent(EntityHandleStruct parent_struct) { - ASSERT_ENTITY("setParent()", return); - - Entity& parent = GET_ENTITY(parent_struct.environmentId, parent_struct.entityId); - - GET_ENTITY(environmentId, entityId) - .setParent(parent); - } - - EntityHandleStruct EntityStruct::getParent() { - ASSERT_ENTITY("getParent()", return *this); - - Entity& self = GET_ENTITY(environmentId, entityId); - if (self.isRoot()) - return *this; - - return EntityStruct(self.getParentId()); - } - - bool EntityStruct::isDescendantOf(EntityHandleStruct parent_struct) { - ASSERT_ENTITY("isDescendantOf()", return false); - - Entity& parent = GET_ENTITY(parent_struct.environmentId, parent_struct.entityId); - - return GET_ENTITY(environmentId, entityId) - .isDescendantOf(parent); - } - - bool EntityStruct::opEquals(const EntityHandleStruct& other) { - ASSERT_ENTITY("opEquals()", return false); - - return entityId == other.entityId; - } - - EntityHandleStruct EntityStruct::getSelf() { - ASSERT_ENTITY("getSelf()", return *this); - - return *this; - } - - glm::vec3 TransformComponentStruct::getPosition() { - ASSERT_ENTITY("getPosition()", return glm::vec3()); - - return GET_ENTITY(environmentId, entityId).getComponent().position; - } - - glm::vec3 TransformComponentStruct::getScale() { - ASSERT_ENTITY("getScale()", return glm::vec3()); - - return GET_ENTITY(environmentId, entityId).getComponent().scale; - } - - glm::vec3 TransformComponentStruct::getRotation() { - ASSERT_ENTITY("getRotation()", return glm::vec3()); - - return GET_ENTITY(environmentId, entityId).getComponent().getEulerAngles(); - } - - void TransformComponentStruct::setPosition(glm::vec3 value) { - ASSERT_ENTITY("setPosition()", return); - - GET_ENTITY(environmentId, entityId).getComponent().position = value; - } - - void TransformComponentStruct::setScale(glm::vec3 value) { - ASSERT_ENTITY("setScale()", return); - - GET_ENTITY(environmentId, entityId).getComponent().scale = value; - } - - void TransformComponentStruct::setRotation(glm::vec3 value) { - ASSERT_ENTITY("setRotation()", return); - - GET_ENTITY(environmentId, entityId).getComponent().setEulerAngles(value); - } - - int EntityChildArrayStruct::getChildCount() { - ASSERT_ENTITY("getChildCount()", return 0); - - return GET_ENTITY(environmentId, entityId) - .getComponent() - .childCount; - } - - bool MeshComponentStruct::assertMeshComponent(const char* funcName) { - if (!assertEntity(funcName)) return false; - Entity& ent = Scene::environment.getEntity(entityId); - - if (!ent.hasComponent()) { - DEER_EDITOR_ENGINE_ERROR("Error, calling MeshComponent.{0} entity {1} with id {2} has no MeshComponent", - funcName, - ent.getComponent().tag.c_str(), - entityId - ); - - if (currentDockPanelExecution) - currentDockPanelExecution->invalidate(); - return false; - } - - return true; - } - - EntityHandleStruct EntityChildArrayStruct::getChild(int i) { - ASSERT_ENTITY("getChild()", return *this); - - RelationshipComponent& rc = GET_ENTITY(environmentId, entityId) - .getComponent(); - - if (i < 0 || i >= rc.childCount) { - DEER_EDITOR_ENGINE_ERROR("Error while executing EntityChild.getChild(..), id {0} is invalid for child count of {1}", i, rc.childCount); - if (currentDockPanelExecution) - currentDockPanelExecution->invalidate(); - - return EntityStruct(0); - } - - return EntityStruct(rc.getChildrenId(i)); - } - - EntityHandleStruct EntityStruct::createChild(std::string& name) { - ASSERT_ENTITY("createChild()", return *this); - - Entity& newEnt = Scene::environment.createEntity(name); - Entity& me = GET_ENTITY(environmentId, entityId); - - newEnt.setParent(me); - - return EntityStruct(newEnt.getId()); - } - - EntityHandleStruct EntityStruct::getMeshComponent() { - ASSERT_ENTITY("getMeshComponent()", return *this); - - Entity& self = GET_ENTITY(environmentId, entityId); - - if (!self.hasComponent()) { - DEER_CORE_ERROR("Error, entity {0} with id {1} does not have MeshComponent", - GET_ENTITY(environmentId, entityId).getComponent().tag.c_str(), - entityId - ); - - if (currentDockPanelExecution) - currentDockPanelExecution->invalidate(); - } - - return *this; - } - - EntityHandleStruct EntityStruct::createMeshComponent() { - ASSERT_ENTITY("createMeshComponent()", return *this); - - Entity& self = GET_ENTITY(environmentId, entityId); - - if (!self.hasComponent()) { - self.addComponent(); - } - - return *this; - } - - bool EntityStruct::hasMeshComponent() { - ASSERT_ENTITY("hasMeshComponent()", return false); - - Entity& self = GET_ENTITY(environmentId, entityId); - - return self.hasComponent(); - } - - void EntityStruct::removeMeshComponent() { - ASSERT_ENTITY("removeMeshComponent()", return); - - Entity& self = GET_ENTITY(environmentId, entityId); - - if (self.hasComponent()) { - self.removeComponent(); - } - } - - EntityHandleStruct EntityStruct::getCameraComponent() { - ASSERT_ENTITY("getCameraComponent()", return *this); - - Entity& self = GET_ENTITY(environmentId, entityId); - - if (!self.hasComponent()) { - DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Camera Component", - GET_ENTITY(environmentId, entityId).getComponent().tag.c_str(), - entityId - ); - - if (currentDockPanelExecution) - currentDockPanelExecution->invalidate(); - } - - return *this; - } - - EntityHandleStruct EntityStruct::createCameraComponent() { - ASSERT_ENTITY("createCameraComponent()", return *this); - - Entity& self = GET_ENTITY(environmentId, entityId); - - if (!self.hasComponent()) { - self.addComponent(); - } - - return *this; - } - - bool EntityStruct::hasCameraComponent() { - ASSERT_ENTITY("hasCameraComponent()", return false); - - Entity& self = GET_ENTITY(environmentId, entityId); - - return self.hasComponent(); - } - - void EntityStruct::removeCameraComponent() { - ASSERT_ENTITY("removeMeshComponent()", return); - - Entity& self = GET_ENTITY(environmentId, entityId); - - if (self.hasComponent()) { - self.removeComponent(); - } - } - - EntityHandleStruct EntityStruct::getShaderComponent() { - ASSERT_ENTITY("getShaderComponent()", return *this); - - Entity& self = GET_ENTITY(environmentId, entityId); - - if (!self.hasComponent()) { - DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Shader Component", - GET_ENTITY(environmentId, entityId).getComponent().tag.c_str(), - entityId - ); - - if (currentDockPanelExecution) - currentDockPanelExecution->invalidate(); - } - - return *this; - } - - EntityHandleStruct EntityStruct::createShaderComponent() { - ASSERT_ENTITY("createShaderComponent()", return *this); - - Entity& self = GET_ENTITY(environmentId, entityId); - - if (!self.hasComponent()) { - self.addComponent(); - } - - return *this; - } - - bool EntityStruct::hasShaderComponent() { - ASSERT_ENTITY("hasShaderComponent()", return false); - - Entity& self = GET_ENTITY(environmentId, entityId); - return self.hasComponent(); - } - - void EntityStruct::removeShaderComponent() { - ASSERT_ENTITY("removeShaderComponent()", return); - - Entity& self = GET_ENTITY(environmentId, entityId); - - if (self.hasComponent()) { - self.removeComponent(); - } - } - - bool MeshComponentStruct::isActive() { - ASSERT_MESH_COMPONENT("isActive()", return false); - return GET_MESH_COMPONENT(environmentId, entityId).isActive(); - } - - void MeshComponentStruct::setActive(bool value) { - ASSERT_MESH_COMPONENT("setActive(bool)", return); - - GET_MESH_COMPONENT(environmentId, entityId).setActive(value); - } - - bool MeshComponentStruct::hasMesh() { - ASSERT_MESH_COMPONENT("hasMesh()", return false); - - return GET_MESH_COMPONENT(environmentId, entityId).hasMesh(); - } - - void MeshComponentStruct::clear() { - ASSERT_MESH_COMPONENT("clear()", return); - - GET_MESH_COMPONENT(environmentId, entityId).clear(); - } - - std::string MeshComponentStruct::getMesh() { - ASSERT_MESH_COMPONENT("getMesh()", return "NULL"); - - return GET_MESH_COMPONENT(environmentId, entityId).getMeshName(); - } - - void MeshComponentStruct::setMesh(std::string& name) { - ASSERT_MESH_COMPONENT("setMesh()", return); - - uint16_t meshId = MeshManager::loadModel(name); - GET_MESH_COMPONENT(environmentId, entityId).setMesh(meshId); - } - - bool ShaderComponentStruct::hasShader() { - ASSERT_ENTITY("hasShader()", return false); - - return GET_SHADER_COMPONENT(environmentId, entityId).hasShader(); - } - - bool ShaderComponentStruct::assertShaderComponent(const char* funcName) { - if (!assertEntity(funcName)) return false; - Entity& ent = Scene::environment.getEntity(entityId); - - if (!ent.hasComponent()) { - DEER_EDITOR_ENGINE_ERROR("Error, calling ShaderComponent.{0} entity {1} with id {2} has no ShaderComponent", - funcName, - ent.getComponent().tag.c_str(), - entityId - ); - - if (currentDockPanelExecution) - currentDockPanelExecution->invalidate(); - return false; - } - - return true; - } - - void ShaderComponentStruct::clear() { - ASSERT_SHADER_COMPONENT("clear()", return); - - GET_SHADER_COMPONENT(environmentId, entityId).clear(); - } - - std::string ShaderComponentStruct::getShader() { - ASSERT_SHADER_COMPONENT("getShader()", return "NULL"); - - return GET_SHADER_COMPONENT(environmentId, entityId).getName(); - } - - void ShaderComponentStruct::setShader(std::string& name) { - ASSERT_SHADER_COMPONENT("getShader()", return); - - uint16_t shaderId = ShaderManager::loadShader(name); - GET_SHADER_COMPONENT(environmentId, entityId).setShader(shaderId); - } - - - bool CameraComponentStruct::assertCameraComponent(const char* funcName) { - if (!assertEntity(funcName)) return false; - Entity& ent = Scene::environment.getEntity(entityId); - - if (!ent.hasComponent()) { - DEER_EDITOR_ENGINE_ERROR("Error, calling CameraComponent.{0} entity {1} with id {2} has no CameraComponent", - funcName, - ent.getComponent().tag.c_str(), - entityId - ); - - if (currentDockPanelExecution) - currentDockPanelExecution->invalidate(); - return false; - } - - return true; - } - - float CameraComponentStruct::getFov() { - ASSERT_CAMERA_COMPONENT("getFov()", return 0); - - return GET_CAMERA_COMPONENT(environmentId, entityId).fov / 3.141f * 180.0f; - } - - float CameraComponentStruct::getAspectRation() { - ASSERT_CAMERA_COMPONENT("getAspectRation()", return 0); - - return GET_CAMERA_COMPONENT(environmentId, entityId).aspect; - } - - float CameraComponentStruct::getNearZ() { - ASSERT_CAMERA_COMPONENT("getNearZ()", return 0); - - return GET_CAMERA_COMPONENT(environmentId, entityId).nearZ; - } - - float CameraComponentStruct::getFarZ() { - ASSERT_CAMERA_COMPONENT("getFarZ()", return 0); - - return GET_CAMERA_COMPONENT(environmentId, entityId).farZ; - } - - void CameraComponentStruct::setFov(float v) { - ASSERT_CAMERA_COMPONENT("getFarZ()", return); - - GET_CAMERA_COMPONENT(environmentId, entityId).fov = v * 3.141f / 180.0f; - } - void CameraComponentStruct::setAspectRation(float v) { - ASSERT_CAMERA_COMPONENT("setAspectRation()", return); - - GET_CAMERA_COMPONENT(environmentId, entityId).aspect = v; - } - void CameraComponentStruct::setNearZ(float v) { - ASSERT_CAMERA_COMPONENT("setNearZ()", return); - - GET_CAMERA_COMPONENT(environmentId, entityId).nearZ = v; - } - void CameraComponentStruct::setFarZ(float v) { - ASSERT_CAMERA_COMPONENT("setFarZ()", return); - - GET_CAMERA_COMPONENT(environmentId, entityId).farZ = v; - } - - - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Environment.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Environment.cpp deleted file mode 100644 index 2e489ed..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Environment.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "Deer/Enviroment.h" -#include "Deer/Scene.h" -#include "Deer/Memory.h" - -#include "DeerStudio/EditorEngine/API/Environment.h" - -#include "DeerRender/FrameBuffer.h" -#include "DeerRender/SceneCamera.h" - -#include - -namespace Deer { - namespace EditorEngine { - // The first element has to allways point to the main scene env - std::vector environments { &Scene::environment }; - - void EnvironmentStruct::render(FrameBufferHandleStruct frameBuffer_handle, SceneCamera& sc) { - FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer(frameBuffer_handle.frameBufferId); - Environment& env = *environments[environmentId]; - - frameBuffer.bind(); - - // TODO - env.render(sc); - - frameBuffer.unbind(); - } - - EntityHandleStruct EnvironmentStruct::getRootEntity() { - return EntityHandleStruct(0, environmentId); - } - - EntityHandleStruct EnvironmentStruct::getEntity(int id) { - return EntityHandleStruct(id, environmentId); - } - - EnvironmentHandleStruct getMainEnvironment() { - return EnvironmentHandleStruct(0); - } - - EnvironmentHandleStruct createEnvironment() { - uint16_t envId = environments.size(); - environments.push_back({}); - - return EnvironmentHandleStruct(envId); - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer.cpp deleted file mode 100644 index 25946db..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "DeerStudio/EditorEngine/API/FrameBuffer.h" -#include "DeerRender/FrameBuffer.h" - -namespace Deer { - namespace EditorEngine { - - int FrameBufferStruct::getWidth() { - return FrameBufferManager::getFrameBufferWidth(frameBufferId); - } - - int FrameBufferStruct::getHeight() { - return FrameBufferManager::getFrameBufferWidth(frameBufferId); - } - - void FrameBufferStruct::resize(int x, int y) { - FrameBufferManager::resizeFrameBuffer(frameBufferId, x, y); - } - - void FrameBufferStruct::clearRGBA(int r, int g, int b, int a) { - FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer(frameBufferId); - - frameBuffer.bind(); - frameBuffer.clear(); - uint8_t clearColor[4] {(uint8_t)r, (uint8_t)g, (uint8_t)b, (uint8_t)a}; - frameBuffer.clearBuffer(0, &clearColor); - frameBuffer.unbind(); - } - - std::string FrameBufferStruct::getName() { - return FrameBufferManager::getFrameBufferName(frameBufferId); - } - - FrameBufferStruct createRGBA8FrameBuffer(std::string& name, int x, int y) { - uint16_t id = FrameBufferManager::createRGBA8FrameBuffer(name, x, y); - return FrameBufferStruct(id); - } - - void frameBuffer_constructor(FrameBufferHandleStruct* mem) { - new (mem) FrameBufferHandleStruct(0); - } - - bool FrameBufferStruct::isValid() { - return frameBufferId > 0 && frameBufferId < 100; - } - - FrameBufferStruct getFrameBuffer(std::string& name) { - return FrameBufferManager::getFrameBufferId(name); - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Math.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Math.cpp deleted file mode 100644 index 693d8cb..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Math.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "glm/glm.hpp" -#include "DeerStudio/EditorEngine/API/Math.h" - -namespace Deer { - namespace EditorEngine { - void vec3_constructor(void* mem) { - new (mem) glm::vec3(0, 0, 0); - } - void vec3_constructor_params(float x, float y, float z, void* mem) { - new (mem) glm::vec3(x, y, z); - } - glm::vec3 vec3_add(glm::vec3& value, glm::vec3& self) { - return self + value; - } - glm::vec3 vec3_sub(const glm::vec3& value, glm::vec3& self) { - return self - value; - } - glm::vec3 vec3_neg(glm::vec3& self) { - return -self; - } - glm::vec3 vec3_mult(float value, glm::vec3& self) { - return self * value; - } - - void quat_construct(glm::quat* mem) { - new (mem) glm::quat(); - } - void quat_copyConstruct(glm::quat* data, glm::quat* mem) { - new (mem) glm::quat(*data); - } - void quat_destruct(glm::quat* mem) { - } - void quat_constructFromValue(float x, float y, float z, float w, glm::quat* mem) { - new (mem) glm::quat(x, y, z, w); - } - - glm::vec3 quat_getEuler(glm::quat* mem) { - return glm::degrees(glm::eulerAngles(*mem)); - } - void quat_setEuler(glm::vec3 euler, glm::quat* mem) { - new (mem) glm::quat(glm::radians(euler)); - } - glm::quat quat_multiply(glm::quat* data, glm::quat* mem) { - return *mem * *data; - } - - glm::vec3 transform_relative(glm::vec3 pos, TransformComponent* transform) { - return transform->getMatrix() * glm::vec4(pos, 1.0f); - } - - void transform_construct(TransformComponent* mem) { - new (mem) TransformComponent(); - } - void camera_construct(CameraComponent* mem) { - new (mem) CameraComponent(); - } - void sceneCamera_Construct(SceneCamera* mem) { - new (mem) SceneCamera(); - } - - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Menu.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Menu.cpp deleted file mode 100644 index 8452d9d..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Menu.cpp +++ /dev/null @@ -1,160 +0,0 @@ -#include "DeerStudio/EditorEngine/API/Menu.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h" -#include "DeerStudio/EditorEngine.h" -#include "angelscript.h" -#include "scriptany.h" -#include "imgui.h" - -namespace Deer { - namespace EditorEngine { - namespace MenuContext { - CScriptAny* payload = nullptr; - std::string menuId; - } - - void contextItemPopup(std::string& menu_id, CScriptAny* data, asIScriptFunction* func) { - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); - if (ImGui::BeginPopupContextItem(menu_id.c_str())) { - - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { - - AS_CHECK(executingScriptContext->Prepare(func)); - - AS_CHECK(executingScriptContext->SetArgObject(0, data)); - - AS_CHECK(executingScriptContext->Execute()); - - executingScriptContext->PopState(); - } else { - ImGui::Text("Something failed"); - } - - ImGui::EndPopup(); - } - ImGui::PopStyleVar(); - } - - void contextMenuPopup(std::string& menu_id, CScriptAny* data, asIScriptFunction* func) { - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); - if (ImGui::BeginPopupContextWindow(menu_id.c_str())) { - - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { - - AS_CHECK(executingScriptContext->Prepare(func)); - - AS_CHECK(executingScriptContext->SetArgObject(0, data)); - - AS_CHECK(executingScriptContext->Execute()); - - executingScriptContext->PopState(); - } else { - ImGui::Text("Something failed"); - } - - ImGui::EndPopup(); - } - ImGui::PopStyleVar(); - } - - void closePopup() { - if (MenuContext::payload) { - MenuContext::payload->Release(); - MenuContext::payload = nullptr; - } - - MenuContext::menuId = ""; - ImGui::CloseCurrentPopup(); - } - - void openPopup(std::string& menu_id, CScriptAny* data) { - if (MenuContext::payload) { - MenuContext::payload->Release(); - } - - data->AddRef(); - MenuContext::payload = data; - MenuContext::menuId = menu_id; - } - - void modalPopup(std::string& menu_id, asIScriptFunction* func) { - if (!ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup) && MenuContext::menuId == menu_id) { - ImGui::OpenPopup(menu_id.c_str()); - MenuContext::menuId = ""; - } - - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); - if (ImGui::BeginPopupModal(menu_id.c_str())) { - // This should not happen - if (!MenuContext::payload) { - ImGui::CloseCurrentPopup(); - ImGui::EndPopup(); - ImGui::PopStyleVar(); - - return; - } - - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { - AS_CHECK(executingScriptContext->Prepare(func)); - - AS_CHECK(executingScriptContext->SetArgObject(0, MenuContext::payload)); - - AS_CHECK(executingScriptContext->Execute()); - - executingScriptContext->PopState(); - } else { - ImGui::Text("Something failed"); - } - - ImGui::EndPopup(); - } - ImGui::PopStyleVar(); - } - - void simplePopup(std::string& menu_id, asIScriptFunction* func) { - if (!ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup)) { - if (MenuContext::menuId == menu_id) { - ImGui::OpenPopup(menu_id.c_str()); - MenuContext::menuId = ""; - - ImVec2 mouse_pos = ImGui::GetMousePos(); - ImVec2 popup_size = ImVec2(200, 0); - ImVec2 popup_pos = ImVec2(mouse_pos.x - popup_size.x * 0.5f, mouse_pos.y); - ImGui::SetNextWindowSize(popup_size); - ImGui::SetNextWindowPos(popup_pos, ImGuiCond_Appearing); - - // In the case a payload is loaded we unload it - } else if (MenuContext::payload && MenuContext::menuId == "") { - MenuContext::payload->Release(); - MenuContext::payload = nullptr; - } - } - - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); - if (ImGui::BeginPopup(menu_id.c_str())) { - // This should not happen - if (!MenuContext::payload) { - ImGui::CloseCurrentPopup(); - ImGui::EndPopup(); - ImGui::PopStyleVar(); - return; - } - - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { - AS_CHECK(executingScriptContext->Prepare(func)); - - AS_CHECK(executingScriptContext->SetArgObject(0, MenuContext::payload)); - - AS_CHECK(executingScriptContext->Execute()); - - executingScriptContext->PopState(); - } else { - ImGui::Text("Something failed"); - } - - ImGui::EndPopup(); - } - ImGui::PopStyleVar(); - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/UI.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/UI.cpp deleted file mode 100644 index c65d60d..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/UI.cpp +++ /dev/null @@ -1,494 +0,0 @@ -#include "DeerStudio/EditorEngine/API/UI.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h" -#include "DeerStudio/EditorEngine.h" -#include "DeerRender/FrameBuffer.h" -#include "Deer/Log.h" - -#include "imgui.h" -#include "angelscript.h" -#include "scriptany.h" -#include "DeerStudio/Fonts.h" - -#include - -namespace Deer { - namespace EditorEngine { - namespace DragDropPayload{ - CScriptAny* payload; - } - - void separator() { - ImGui::Separator(); - } - - void title(std::string& txt) { - ImGui::PushFont(titleText); - ImGui::Text("%s", txt.c_str()); - ImGui::PopFont(); - } - - void titleEnd(std::string& txt) { - ImGui::PushFont(titleText); - textEnd(txt); - ImGui::PopFont(); - } - - void titleCenter(std::string& txt) { - ImGui::PushFont(titleText); - textCenter(txt); - ImGui::PopFont(); - } - - void titleCenterY(std::string& txt, int height) { - ImGui::PushFont(titleText); - - float textHeight = ImGui::GetFontSize(); - float yOffset = (height - textHeight) * 0.5f; - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + yOffset); - - ImGui::Text("%s", txt.c_str()); - ImGui::PopFont(); - } - - void sameline() { - ImGui::SameLine(); - } - - bool button(std::string& txt) { - return ImGui::Button(txt.c_str()); - } - - bool buttonCenter(std::string& txt) { - float sizeX; - if (ImGui::GetColumnsCount() > 1) - sizeX = ImGui::GetColumnWidth(-1); - else - sizeX = ImGui::GetContentRegionAvail().x; - - float textWidth = ImGui::CalcTextSize(txt.c_str(), nullptr, false).x; - float padding = (sizeX - textWidth - ImGui::GetStyle().FramePadding.x * 2) * 0.5f; - - if (padding > 0.0f) - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); - - return ImGui::Button(txt.c_str()); - } - - bool buttonEnd(std::string& txt) { - float sizeX; - if (ImGui::GetColumnsCount() > 1) - sizeX = ImGui::GetColumnWidth(-1); - else - sizeX = ImGui::GetContentRegionAvail().x; - - float textWidth = ImGui::CalcTextSize(txt.c_str(), nullptr, false).x; - float padding = (sizeX - textWidth - ImGui::GetStyle().FramePadding.x * 2); - - if (padding > 0.0f) - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); - - return ImGui::Button(txt.c_str()); - } - - void textColor(float r, float g, float b, std::string& msg) { - ImGui::TextColored(ImVec4(r, g, b, 1.0f), "%s", msg.c_str()); - } - - void text(std::string& msg) { - ImGui::Text("%s", msg.c_str()); - } - - bool isPannelActive() { - return ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); - } - - void textEnd(std::string& msg) { - float sizeX; - if (ImGui::GetColumnsCount() > 1) - sizeX = ImGui::GetColumnWidth(-1); - else - sizeX = ImGui::GetContentRegionAvail().x; - - float textWidth = ImGui::CalcTextSize(msg.c_str(), nullptr, false).x; - float padding = (sizeX - textWidth); - - if (padding > 0.0f) - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); - - ImGui::Text("%s", msg.c_str()); - } - - void textCenter(std::string& msg) { - float sizeX; - if (ImGui::GetColumnsCount() > 1) - sizeX = ImGui::GetColumnWidth(-1); - else - sizeX = ImGui::GetContentRegionAvail().x; - - float textWidth = ImGui::CalcTextSize(msg.c_str(), nullptr, false).x; - float padding = (sizeX - textWidth) * 0.5f; - - if (padding > 0.0f) - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); - - ImGui::Text("%s", msg.c_str()); - } - - void drawIcon(std::string& name, int size) { - int iconId = DataStore::getIconId(name); - - if (iconId < 0) { - DEER_EDITOR_ENGINE_ERROR("Invalid icon name {0}", name.c_str()); - if (currentDockPanelExecution) { - currentDockPanelExecution->invalidate(); - } - return; - } - - ImGui::Image((void*)(uint64_t)iconId, - ImVec2(size, size), ImVec2(0, 1), - ImVec2(1, 0)); - } - - void drawFrameBuffer(FrameBufferHandleStruct frameBuffer_handle, int sizeX, int sizeY) { - FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer(frameBuffer_handle.frameBufferId); - frameBuffer.bind(); - int frameBufferId = frameBuffer.getTextureBufferID(0); - - ImGui::Image((void*)(uint64_t)frameBufferId, - ImVec2(sizeX, sizeY), ImVec2(0, 1), - ImVec2(1, 0)); - frameBuffer.unbind(); - } - - void drawFrameBufferCentered(FrameBufferHandleStruct frameBuffer_handle, int _x, int _y) { - FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer(frameBuffer_handle.frameBufferId); - int frameBufferId = frameBuffer.getTextureBufferID(); - - float sizeX; - if (ImGui::GetColumnsCount() > 1) - sizeX = ImGui::GetColumnWidth(-1); - else - sizeX = ImGui::GetContentRegionAvail().x; - - float iconWidth = _x; - float padding = (sizeX - iconWidth) * 0.5f; - - if (padding > 0.0f) - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); - - ImGui::Image((void*)(uint64_t)frameBufferId, - ImVec2(_x, _y), ImVec2(0, 1), - ImVec2(1, 0)); - } - - void drawIconCentered(std::string& name, int size) { - int iconId = DataStore::getIconId(name); - if (iconId < 0) { - DEER_EDITOR_ENGINE_ERROR("Invalid icon name {0}", name.c_str()); - if (currentDockPanelExecution) { - currentDockPanelExecution->invalidate(); - } - return; - } - - float sizeX; - if (ImGui::GetColumnsCount() > 1) - sizeX = ImGui::GetColumnWidth(-1); - else - sizeX = ImGui::GetContentRegionAvail().x; - - float iconWidth = size; - float padding = (sizeX - iconWidth) * 0.5f; - - if (padding > 0.0f) - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); - - drawIcon(name, size); - } - - bool isItemClicked(int mouse) { - return ImGui::IsItemClicked(mouse); - } - - bool isMouseDoubleClicked(int mouse) { - return ImGui::IsMouseDoubleClicked(mouse); - } - - bool menuItem(std::string& txt) { - return ImGui::MenuItem(txt.c_str()); - } - - void menuSpace(std::string& txt, CScriptAny* data ,asIScriptFunction* func) { - if (ImGui::BeginMenu(txt.c_str())) { - - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { - - AS_CHECK(executingScriptContext->Prepare(func)); - - AS_CHECK(executingScriptContext->SetArgObject(0, data)); - - AS_CHECK(executingScriptContext->Execute()); - - executingScriptContext->PopState(); - } - - ImGui::EndMenu(); - } - } - - void menuItemDisabled(std::string& txt) { - ImGui::BeginDisabled(); - ImGui::MenuItem(txt.c_str()); - ImGui::EndDisabled(); - } - - void dragDropSource(std::string& id, CScriptAny* data, std::string& debugText) { - if (DragDropPayload::payload && !ImGui::GetDragDropPayload()) { - DragDropPayload::payload->Release(); - DragDropPayload::payload = nullptr; - } - - data->AddRef(); - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); - if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAllowNullID)) { - if (DragDropPayload::payload) - DragDropPayload::payload->Release(); - - DragDropPayload::payload = data; - - ImGui::SetDragDropPayload(id.c_str(), nullptr, 0); - ImGui::Text("%s", debugText.c_str()); - - ImGui::EndDragDropSource(); - } - ImGui::PopStyleVar(); - } - - void dragDropTarget(std::string& id, CScriptAny* data, asIScriptFunction* func) { - if (ImGui::BeginDragDropTarget()) { - if (ImGui::AcceptDragDropPayload(id.c_str()) && DragDropPayload::payload) { - - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { - - AS_CHECK(executingScriptContext->Prepare(func)); - - AS_CHECK(executingScriptContext->SetArgObject(0, data)); - - AS_CHECK(executingScriptContext->SetArgObject(1, DragDropPayload::payload)); - - AS_CHECK(executingScriptContext->Execute()); - - executingScriptContext->PopState(); - } - - DragDropPayload::payload->Release(); - DragDropPayload::payload = nullptr; - } - ImGui::EndDragDropTarget(); - } - } - - bool inputText(std::string& id, std::string& in, std::string& text) { - static char buffer[256]; - strncpy(buffer, in.c_str(), sizeof(buffer)); - buffer[sizeof(buffer) - 1] = '\0'; - - bool edited = ImGui::InputText(id.c_str(), buffer, sizeof(buffer)); - if (edited) { - text = buffer; - } - - return edited; - } - - bool checkbox(std::string& label, bool value) { - ImGui::Checkbox(label.c_str(), &value); - - return value; - } - - bool checkboxDisabled(std::string& label, bool value) { - ImGui::BeginDisabled(); - ImGui::Checkbox(label.c_str(), &value); - ImGui::EndDisabled(); - - return value; - } - - float magicSlider(std::string& txt, float value, float speed) { - - ImGui::PushID(txt.c_str()); - - static ImGuiID id = 0; - - float tmp = value; - bool value_changed = false; - - ImGui::Columns(2, nullptr, false); - - ImGui::Text("%s", txt.c_str()); - ImGui::SameLine(); - - ImGui::NextColumn(); - - if (id == ImGui::GetID(txt.c_str())) - { - // — Input mode — - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::InputFloat("##input", &tmp, 0.0f, 0.0f, "%.2f", - ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll)) - { - value_changed = true; - id = 0; - } - // Cancel if click away or Esc - if (!ImGui::IsItemActive() && !ImGui::IsItemHovered()){ - value_changed = true; - id = 0; - } - } - else - { - // — Drag mode (unbounded) — - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - ImGui::DragFloat("##input", &tmp, speed, 0.0f, 0.0f, "%.2f"); - if (ImGui::IsItemActive()) - value_changed = true; - - // Click to enter edit mode - if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) - { - id = ImGui::GetID(txt.c_str()); - ImGui::SetKeyboardFocusHere(0); - } - } - - ImGui::Columns(); - - if (value_changed) - value = tmp; - - ImGui::PopID(); - return value; - } - - glm::vec3 magicSlider3(std::string& txt, glm::vec3 value, float speed) { - static ImGuiID id = 0; - - glm::vec3 tmp = value; - bool value_changed = false; - - ImGui::Columns(4, nullptr, false); - - ImGui::PushID(txt.c_str()); - ImGui::Text("%s", txt.c_str()); - ImGui::NextColumn(); - - for (int i = 0; i < 3; i++) { - ImGui::PushID(i); - if (id == ImGui::GetID("##input")) - { - // — Input mode — - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::InputFloat("##input", &tmp[i], 0.0f, 0.0f, "%.2f", - ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll)) - { - value_changed = true; - id = 0; - } - // Cancel if click away or Esc - if (!ImGui::IsItemActive() && !ImGui::IsItemHovered()){ - value_changed = true; - id = 0; - } - } - else - { - // — Drag mode (unbounded) — - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - ImGui::DragFloat("##input", &tmp[i], speed, 0.0f, 0.0f, "%.2f"); - if (ImGui::IsItemActive()) - value_changed = true; - - // Click to enter edit mode - if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) - { - id = ImGui::GetID("##input"); - ImGui::SetKeyboardFocusHere(-1); - } - } - ImGui::PopID(); - ImGui::NextColumn(); - } - ImGui::Columns(); - ImGui::PopID(); - - if (value_changed) - value = tmp; - - return value; - } - - bool isKeyDown(int key) { - return ImGui::IsKeyDown((ImGuiKey)key); - } - - bool isKeyPressed(int key) { - return ImGui::IsKeyPressed((ImGuiKey)key, false); - } - - bool isMouseDraggin(int key) { - if (key == ImGuiKey_MouseRight) - return ImGui::IsMouseDragging(ImGuiMouseButton_Right); - else if (key == ImGuiKey_MouseLeft) - return ImGui::IsMouseDragging(ImGuiMouseButton_Left); - else if (key == ImGuiKey_MouseMiddle) - return ImGui::IsMouseDragging(ImGuiMouseButton_Middle); - return false; - } - - float slider(std::string& label, float value, float min, float max) { - ImGui::SliderFloat(label.c_str(), &value, min, max); - return value; - } - - int sliderInt(std::string& label, int value, int min, int max) { - ImGui::SliderInt(label.c_str(), &value, min, max); - return value; - } - - float getMouseDeltaX() { - ImGuiIO& io = ImGui::GetIO(); - return io.MouseDelta.x; - } - - float getMouseDeltaY() { - ImGuiIO& io = ImGui::GetIO(); - return io.MouseDelta.y; - } - - float getMouseDragDeltaX() { - return ImGui::GetMouseDragDelta().x; - } - - float getMouseDragDeltaY() { - return ImGui::GetMouseDragDelta().y; - } - - int getAvailableSizeX() { - return ImGui::GetContentRegionAvail().x; - } - - int getAvailableSizeY() { - return ImGui::GetContentRegionAvail().y; - } - - void disablePannelPadding(bool value) { - if (currentDockPanelExecution) { - currentDockPanelExecution->setFlag(DockPannelFlag_PannelPadding, value); - } - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/Entity_Register.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/Entity_Register.cpp deleted file mode 100644 index f6c71dd..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/Entity_Register.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "DeerStudio/EditorEngine.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine/API.h" -#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h" - -#include "scripthandle.h" -#include "scriptany.h" -#include "angelscript.h" - -namespace Deer { - namespace EditorEngine { - void registerTransformComponentFunctions(); - void registerMeshComponentFunction(); - void registerShaderComponentFunctions(); - void registerComponentComponentFunctions(); - - void registerEntityStructs() { - AS_CHECK(scriptEngine->RegisterObjectType("Entity", sizeof(EntityHandleStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - - AS_CHECK(scriptEngine->RegisterObjectType("EntityChilds", sizeof(EntityHandleStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - - AS_CHECK(scriptEngine->RegisterObjectType("TransformComponent", sizeof(EntityHandleStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - - AS_CHECK(scriptEngine->RegisterObjectType("MeshComponent", sizeof(EntityHandleStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - - AS_CHECK(scriptEngine->RegisterObjectType("ShaderComponent", sizeof(EntityHandleStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - - AS_CHECK(scriptEngine->RegisterObjectType("CameraComponent", sizeof(EntityHandleStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - } - - void registerEntityFunctions() { - registerTransformComponentFunctions(); - registerMeshComponentFunction(); - registerShaderComponentFunctions(); - registerComponentComponentFunctions(); - - REGISTER_OBJECT_METHOD("Entity", "string get_name() const property", EntityStruct, getName); - REGISTER_OBJECT_METHOD("Entity", "void set_name(string& in) property", EntityStruct, setName); - REGISTER_OBJECT_METHOD("Entity", "int get_id() const property", EntityStruct, getId); - REGISTER_OBJECT_METHOD("Entity", "Entity createChild(const string& in)", EntityStruct, createChild); - REGISTER_OBJECT_METHOD("Entity", "bool get_isRoot() const property", EntityStruct, isRoot); - REGISTER_OBJECT_METHOD("Entity", "void destroy()", EntityStruct, destroy); - REGISTER_OBJECT_METHOD("Entity", "bool get_exists() const property", EntityStruct, exists); - REGISTER_OBJECT_METHOD("Entity", "Entity get_parent() property", EntityStruct, getParent); - REGISTER_OBJECT_METHOD("Entity", "void set_parent(Entity) property", EntityStruct, setParent); - REGISTER_OBJECT_METHOD("Entity", "bool isDescendantOf(Entity)", EntityStruct, isDescendantOf); - REGISTER_OBJECT_METHOD("Entity", "bool opEquals(const Entity &in) const", EntityStruct, opEquals); - REGISTER_OBJECT_METHOD("Entity", "EntityChilds get_childs() const property", EntityStruct, getSelf); - REGISTER_OBJECT_METHOD("Entity", "TransformComponent get_transform() const property", EntityStruct, getSelf); - REGISTER_OBJECT_METHOD("Entity", "MeshComponent getMeshComponent()", EntityStruct, getMeshComponent); - REGISTER_OBJECT_METHOD("Entity", "MeshComponent createMeshComponent()", EntityStruct, createMeshComponent); - REGISTER_OBJECT_METHOD("Entity", "bool hasMeshComponent()", EntityStruct, hasMeshComponent); - REGISTER_OBJECT_METHOD("Entity", "void removeMeshComponent()", EntityStruct, removeMeshComponent); - REGISTER_OBJECT_METHOD("Entity", "ShaderComponent getShaderComponent()", EntityStruct, getShaderComponent); - REGISTER_OBJECT_METHOD("Entity", "ShaderComponent createShaderComponent()", EntityStruct, createShaderComponent); - REGISTER_OBJECT_METHOD("Entity", "bool hasShaderComponent()", EntityStruct, hasShaderComponent); - REGISTER_OBJECT_METHOD("Entity", "void removeShaderComponent()", EntityStruct, removeShaderComponent); - REGISTER_OBJECT_METHOD("Entity", "CameraComponent getCameraComponent()", EntityStruct, getCameraComponent); - REGISTER_OBJECT_METHOD("Entity", "CameraComponent createCameraComponent()", EntityStruct, createCameraComponent); - REGISTER_OBJECT_METHOD("Entity", "bool hasCameraComponent()", EntityStruct, hasCameraComponent); - REGISTER_OBJECT_METHOD("Entity", "void removeCameraComponent()", EntityStruct, removeCameraComponent); - - scriptEngine->SetDefaultNamespace("Engine"); - REGISTER_GLOBAL_FUNC("Entity getRoot()", getRoot); - scriptEngine->SetDefaultNamespace(""); - - REGISTER_OBJECT_METHOD("EntityChilds", "int get_count() const property", EntityChildArrayStruct, getChildCount); - REGISTER_OBJECT_METHOD("EntityChilds", "Entity opIndex(int) const", EntityChildArrayStruct, getChild); - - } - - void registerMeshComponentFunction() { - REGISTER_OBJECT_METHOD("MeshComponent", "bool get_isActive() const property", MeshComponentStruct, isActive); - REGISTER_OBJECT_METHOD("MeshComponent", "bool get_hasMesh() const property", MeshComponentStruct, hasMesh); - REGISTER_OBJECT_METHOD("MeshComponent", "void clear()", MeshComponentStruct, clear); - REGISTER_OBJECT_METHOD("MeshComponent", "string getMesh()", MeshComponentStruct, getMesh); - REGISTER_OBJECT_METHOD("MeshComponent", "void setMesh(string&in)", MeshComponentStruct, setMesh); - REGISTER_OBJECT_METHOD("MeshComponent", "void set_isActive(const bool) property", MeshComponentStruct, setActive); - } - - void registerTransformComponentFunctions() { - REGISTER_OBJECT_METHOD("TransformComponent", "vec3 get_position() const property", TransformComponentStruct, getPosition); - REGISTER_OBJECT_METHOD("TransformComponent", "vec3 get_scale() const property", TransformComponentStruct, getScale); - REGISTER_OBJECT_METHOD("TransformComponent", "vec3 get_rotation() const property", TransformComponentStruct, getRotation); - - REGISTER_OBJECT_METHOD("TransformComponent", "void set_position(const vec3) property", TransformComponentStruct, setPosition); - REGISTER_OBJECT_METHOD("TransformComponent", "void set_scale(const vec3) property", TransformComponentStruct, setScale); - REGISTER_OBJECT_METHOD("TransformComponent", "void set_rotation(const vec3) property", TransformComponentStruct, setRotation); - } - - void registerShaderComponentFunctions() { - REGISTER_OBJECT_METHOD("ShaderComponent", "bool get_hasShader() const property", ShaderComponentStruct, hasShader); - REGISTER_OBJECT_METHOD("ShaderComponent", "void clear()", ShaderComponentStruct, clear); - REGISTER_OBJECT_METHOD("ShaderComponent", "string getShader()", ShaderComponentStruct, getShader); - REGISTER_OBJECT_METHOD("ShaderComponent", "void setShader(const string& in)", ShaderComponentStruct, setShader); - } - - void registerComponentComponentFunctions() { - REGISTER_OBJECT_METHOD("CameraComponent", "float get_fov() const property", CameraComponentStruct, getFov); - REGISTER_OBJECT_METHOD("CameraComponent", "float get_aspectRatio() const property", CameraComponentStruct, getAspectRation); - REGISTER_OBJECT_METHOD("CameraComponent", "float get_nearZ() const property", CameraComponentStruct, getNearZ); - REGISTER_OBJECT_METHOD("CameraComponent", "float get_farZ() const property", CameraComponentStruct, getFarZ); - - REGISTER_OBJECT_METHOD("CameraComponent", "void set_fov(float) property", CameraComponentStruct, setFov); - REGISTER_OBJECT_METHOD("CameraComponent", "void set_aspectRatio(float) property", CameraComponentStruct, setAspectRation); - REGISTER_OBJECT_METHOD("CameraComponent", "void set_nearZ(float) property", CameraComponentStruct, setNearZ); - REGISTER_OBJECT_METHOD("CameraComponent", "void set_farZ(float) property", CameraComponentStruct, setFarZ); - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/Environment_Register.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/Environment_Register.cpp deleted file mode 100644 index c8a7528..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/Environment_Register.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "DeerStudio/EditorEngine/API/Environment.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine.h" -#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h" - -#include "angelscript.h" - -namespace Deer { - namespace EditorEngine { - void registerEnvironmentStructs(); - void registerEnvironmentFunctions(); - - void registerEnvironmentStructs() { - AS_CHECK(scriptEngine->RegisterObjectType("Environment", sizeof(EnvironmentStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - } - - void registerEnvironmentFunctions() { - scriptEngine->SetDefaultNamespace("Engine"); - REGISTER_GLOBAL_FUNC("Environment getMainEnvironment()", getMainEnvironment); - REGISTER_GLOBAL_FUNC("Environment createEnvironment()", createEnvironment); - scriptEngine->SetDefaultNamespace(""); - - REGISTER_OBJECT_METHOD("Environment", "void render(FrameBuffer, SceneCamera&in)", EnvironmentStruct, render); - REGISTER_OBJECT_METHOD("Environment", "Entity getRootEntity()", EnvironmentStruct, getRootEntity); - REGISTER_OBJECT_METHOD("Environment", "Entity getEntity(int)", EnvironmentStruct, getEntity); - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/FrameBuffer_Register.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/FrameBuffer_Register.cpp deleted file mode 100644 index 43631d8..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/FrameBuffer_Register.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "DeerStudio/EditorEngine/API/FrameBuffer.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h" -#include "DeerStudio/EditorEngine.h" -#include "angelscript.h" - -namespace Deer { - namespace EditorEngine { - void registerFrameBufferStructs() { - AS_CHECK(scriptEngine->RegisterObjectType("FrameBuffer", sizeof(FrameBufferStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - - } - - void registerFrameBufferFunctions() { - REGISTER_OBJECT_METHOD("FrameBuffer", "void clearRGBA(int, int, int, int)", FrameBufferStruct, clearRGBA); - REGISTER_OBJECT_METHOD("FrameBuffer", "int get_height() const property", FrameBufferStruct, getHeight); - REGISTER_OBJECT_METHOD("FrameBuffer", "void resize(int, int)", FrameBufferStruct, resize); - REGISTER_OBJECT_METHOD("FrameBuffer", "string get_name() const property", FrameBufferStruct, getName); - REGISTER_OBJECT_METHOD("FrameBuffer", "bool isValid()", FrameBufferStruct, isValid); - REGISTER_EXT_OBJECT_CONSTRUCTOR("FrameBuffer", "void f()", frameBuffer_constructor); - - scriptEngine->SetDefaultNamespace("Engine"); - REGISTER_GLOBAL_FUNC("FrameBuffer createRGBA8FrameBuffer(const string&in, int, int)", createRGBA8FrameBuffer); - REGISTER_GLOBAL_FUNC("FrameBuffer getFrameBuffer(const string&in)", getFrameBuffer); - scriptEngine->SetDefaultNamespace(""); - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/Math_Register.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/Math_Register.cpp deleted file mode 100644 index 839bd85..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/Math_Register.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "DeerStudio/EditorEngine.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine/API.h" -#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h" - -#include "scripthandle.h" -#include "scriptany.h" -#include "angelscript.h" -#include "glm/glm.hpp" - -namespace Deer { - namespace EditorEngine { - void registerMathStructs() { - AS_CHECK(scriptEngine->RegisterObjectType( - "vec3", - sizeof(glm::vec3), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLFLOATS)); - - AS_CHECK(scriptEngine->RegisterObjectBehaviour("vec3", asBEHAVE_CONSTRUCT, - "void f()", asFUNCTION(vec3_constructor), asCALL_CDECL_OBJLAST)); - - AS_CHECK(scriptEngine->RegisterObjectBehaviour("vec3", asBEHAVE_CONSTRUCT, - "void f(float, float = 0, float = 0)", asFUNCTION(vec3_constructor_params), asCALL_CDECL_OBJLAST)); - - AS_CHECK(scriptEngine->RegisterObjectProperty("vec3", "float x", asOFFSET(glm::vec3, x))); - AS_CHECK(scriptEngine->RegisterObjectProperty("vec3", "float y", asOFFSET(glm::vec3, y))); - AS_CHECK(scriptEngine->RegisterObjectProperty("vec3", "float z", asOFFSET(glm::vec3, z))); - - AS_CHECK(scriptEngine->RegisterObjectType( - "quat", - sizeof(glm::quat), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLFLOATS)); - - AS_CHECK(scriptEngine->RegisterObjectProperty("quat", "float x", asOFFSET(glm::quat, x))); - AS_CHECK(scriptEngine->RegisterObjectProperty("quat", "float y", asOFFSET(glm::quat, y))); - AS_CHECK(scriptEngine->RegisterObjectProperty("quat", "float z", asOFFSET(glm::quat, z))); - AS_CHECK(scriptEngine->RegisterObjectProperty("quat", "float w", asOFFSET(glm::quat, w))); - - AS_CHECK(scriptEngine->RegisterObjectType( - "Transform", - sizeof(TransformComponent), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits())); - - AS_CHECK(scriptEngine->RegisterObjectProperty("Transform", "vec3 position", asOFFSET(TransformComponent, position))); - AS_CHECK(scriptEngine->RegisterObjectProperty("Transform", "vec3 scale", asOFFSET(TransformComponent, scale))); - AS_CHECK(scriptEngine->RegisterObjectProperty("Transform", "quat rotation", asOFFSET(TransformComponent, rotation))); - - AS_CHECK(scriptEngine->RegisterObjectType( - "Camera", - sizeof(CameraComponent), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits())); - - AS_CHECK(scriptEngine->RegisterObjectProperty("Camera", "float fov", asOFFSET(CameraComponent, fov))); - AS_CHECK(scriptEngine->RegisterObjectProperty("Camera", "float aspect", asOFFSET(CameraComponent, aspect))); - AS_CHECK(scriptEngine->RegisterObjectProperty("Camera", "float nearZ", asOFFSET(CameraComponent, nearZ))); - AS_CHECK(scriptEngine->RegisterObjectProperty("Camera", "float farZ", asOFFSET(CameraComponent, farZ))); - - AS_CHECK(scriptEngine->RegisterObjectType( - "SceneCamera", - sizeof(SceneCamera), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits())); - AS_CHECK(scriptEngine->RegisterObjectProperty("SceneCamera", "Camera camera", asOFFSET(SceneCamera, camera))); - AS_CHECK(scriptEngine->RegisterObjectProperty("SceneCamera", "Transform transform", asOFFSET(SceneCamera, transform))); - } - - void registerMathFunctions() { - REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opAdd(const vec3 &in)", vec3_add); - REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opSub(const vec3 &in) const", vec3_sub); - REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opNeg() const", vec3_neg); - REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opMul(float) const", vec3_mult); - REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opMul_r(float) const", vec3_mult); - - REGISTER_EXT_OBJECT_CONSTRUCTOR("quat", "void f()", quat_construct); - REGISTER_EXT_OBJECT_CONSTRUCTOR("quat", "void f(float, float, float, float)", quat_constructFromValue); - REGISTER_EXT_OBJECT_DESTRUCTOR("quat", "void f()", quat_destruct); - - REGISTER_EXT_OBJECT_METHOD("quat", "quat opMul(const quat &in) const", quat_multiply); - REGISTER_EXT_OBJECT_METHOD("quat", "vec3 getEuler() const", quat_getEuler); - REGISTER_EXT_OBJECT_METHOD("quat", "void setEuler(vec3)", quat_setEuler); - - REGISTER_EXT_OBJECT_CONSTRUCTOR("Transform", "void f()", transform_construct); - REGISTER_EXT_OBJECT_CONSTRUCTOR("Camera", "void f()", camera_construct); - REGISTER_EXT_OBJECT_CONSTRUCTOR("SceneCamera", "void f()", sceneCamera_Construct); - - REGISTER_EXT_OBJECT_METHOD("Transform", "vec3 relative(vec3)", transform_relative); - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/RegisterFunctions.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/RegisterFunctions.cpp deleted file mode 100644 index 4ba8e29..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/RegisterFunctions.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "DeerStudio/EditorEngine.h" -#include "DeerStudio/EditorEngine/API.h" -#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" - -#include "angelscript.h" - -namespace Deer { - void EditorEngine::registerEditorEngineFunctions() { - registerEntityFunctions(); - registerMathFunctions(); - registerUIFunctions(); - registerFrameBufferFunctions(); - registerEnvironmentFunctions(); - - scriptEngine->SetDefaultNamespace("UI"); - REGISTER_GLOBAL_FUNC("void setupAutomaticColumns(int)", - setupAutomaticColumns); - REGISTER_GLOBAL_FUNC("void setupColumns(int)", setupColumns); - REGISTER_GLOBAL_FUNC("void endColumns()", endColumns); - REGISTER_GLOBAL_FUNC("void nextColumn()", nextColumn); - scriptEngine->SetDefaultNamespace(""); - - scriptEngine->SetDefaultNamespace("Assets"); - REGISTER_GLOBAL_FUNC("int getAssetCount(AssetType, const string& in)", - getAssetCount); - REGISTER_GLOBAL_FUNC( - "string getAssetNameById(AssetType, const string& in, int)", - getAssetNameById); - REGISTER_GLOBAL_FUNC( - "string getAssetTypePathById(AssetType, const string& in, int)", - getAssetTypePathById); - REGISTER_GLOBAL_FUNC("int getDirCount(AssetType, const string& in)", - getDirCount); - REGISTER_GLOBAL_FUNC( - "string getDirPathById(AssetType, const string& in, int)", - getDirPathById); - REGISTER_GLOBAL_FUNC( - "string getDirNameById(AssetType, const string& in, int)", - getDirNameById); - scriptEngine->SetDefaultNamespace(""); - - scriptEngine->SetDefaultNamespace("Engine"); - REGISTER_GLOBAL_FUNC("void print(const string& in)", print); - REGISTER_GLOBAL_FUNC("string getParentPath(const string&in)", - getParentPath); - REGISTER_GLOBAL_FUNC("string getParentPathName(const string&in)", - getParentPathName); - scriptEngine->SetDefaultNamespace(""); - - scriptEngine->SetDefaultNamespace("UI"); - REGISTER_GLOBAL_FUNC("void treeNodeLeaf(const string& in, bool)", - treeNode); - REGISTER_GLOBAL_FUNC( - "bool treeNode(const string& in, bool, any@+, ReciverFunc@+)", - treeNodeRecursive); - REGISTER_GLOBAL_FUNC( - "bool componentNode(const string& in, any@+, ReciverFunc@+)", - componentNode); - REGISTER_GLOBAL_FUNC("bool componentNode_contextMenu(const string& in, " - "any@+, ReciverFunc@+, ReciverFunc@+)", - componentNode_contextMenu); - REGISTER_GLOBAL_FUNC( - "void contextItemPopup(const string& in, any@+, ReciverFunc@+)", - contextItemPopup); - REGISTER_GLOBAL_FUNC( - "void contextMenuPopup(const string& in, any@+, ReciverFunc@+)", - contextMenuPopup); - REGISTER_GLOBAL_FUNC("void modalPopup(const string& in, ReciverFunc@+)", - modalPopup); - REGISTER_GLOBAL_FUNC( - "void simplePopup(const string& in, ReciverFunc@+)", simplePopup); - REGISTER_GLOBAL_FUNC("void openPopup(const string& in, any@)", - openPopup); - REGISTER_GLOBAL_FUNC("void closePopup()", closePopup); - REGISTER_GLOBAL_FUNC( - "void dragDropSource(const string& in, any@, const string& in)", - dragDropSource); - REGISTER_GLOBAL_FUNC( - "void dragDropTarget(const string& in, any@+, TransferFunc@+)", - dragDropTarget); - scriptEngine->SetDefaultNamespace(""); - } -} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/UI_Register.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/UI_Register.cpp deleted file mode 100644 index 7c23875..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/UI_Register.cpp +++ /dev/null @@ -1,256 +0,0 @@ -#include "DeerStudio/EditorEngine.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine/API.h" -#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h" - -#include "scripthandle.h" -#include "scriptany.h" -#include "angelscript.h" -#include "imgui.h" - -namespace Deer { - void EditorEngine::registerUIFunctions() { - - scriptEngine->SetDefaultNamespace("UI"); - REGISTER_GLOBAL_FUNC("bool button(const string& in)", button); - REGISTER_GLOBAL_FUNC("bool buttonCenter(const string&in)", buttonCenter); - REGISTER_GLOBAL_FUNC("bool buttonEnd(const string&in)", buttonEnd); - REGISTER_GLOBAL_FUNC("bool checkbox(const string& in, bool)", checkbox); - REGISTER_GLOBAL_FUNC("bool checkboxDisabled(const string& in, bool)", checkboxDisabled); - REGISTER_GLOBAL_FUNC("void drawFrameBuffer(FrameBuffer, int, int)", drawFrameBuffer); - REGISTER_GLOBAL_FUNC("void drawFrameBufferCentered(FrameBuffer, int, int)", drawFrameBufferCentered); - REGISTER_GLOBAL_FUNC("void drawIcon(const string& in, int)", drawIcon); - REGISTER_GLOBAL_FUNC("void drawIconCentered(const string& in, int)", drawIconCentered); - REGISTER_GLOBAL_FUNC("bool inputText(const string& in, const string& in, string& out)", inputText); - REGISTER_GLOBAL_FUNC("bool isItemClicked(int)", isItemClicked); - REGISTER_GLOBAL_FUNC("bool isMouseDoubleClicked(int)", isMouseDoubleClicked); - REGISTER_GLOBAL_FUNC("float magicSlider(const string& in, float, float)", magicSlider); - REGISTER_GLOBAL_FUNC("vec3 magicSlider3(const string& in, vec3, float)", magicSlider3); - REGISTER_GLOBAL_FUNC("bool menuItem(const string& in)", menuItem); - REGISTER_GLOBAL_FUNC("void menuItemDisabled(const string& in)", menuItemDisabled); - REGISTER_GLOBAL_FUNC("void menuSpace(const string& in, any@+, ReciverFunc@+)", menuSpace); - REGISTER_GLOBAL_FUNC("void sameline()", sameline); - REGISTER_GLOBAL_FUNC("void separator()", separator); - REGISTER_GLOBAL_FUNC("void space()", space); - REGISTER_GLOBAL_FUNC("void space(int, int = 10)", space_params); - REGISTER_GLOBAL_FUNC("void text(const string& in)", text); - REGISTER_GLOBAL_FUNC("void textCenter(const string& in)", textCenter); - REGISTER_GLOBAL_FUNC("void textColor(float, float, float, const string& in)", textColor); - REGISTER_GLOBAL_FUNC("void textEnd(const string& in)", textEnd); - REGISTER_GLOBAL_FUNC("void title(const string&in)", title); - REGISTER_GLOBAL_FUNC("void titleCenter(const string&in)", titleCenter); - REGISTER_GLOBAL_FUNC("void titleCenterY(const string&in, int)", titleCenterY); - REGISTER_GLOBAL_FUNC("void titleEnd(const string&in)", titleEnd); - REGISTER_GLOBAL_FUNC("bool isKeyDown(key)", isKeyDown); - REGISTER_GLOBAL_FUNC("bool isKeyPressed(key)", isKeyPressed); - REGISTER_GLOBAL_FUNC("bool isMouseDraggin(key)", isMouseDraggin); - REGISTER_GLOBAL_FUNC("bool isPannelActive()", isPannelActive); - REGISTER_GLOBAL_FUNC("float getMouseDragDeltaX()", getMouseDragDeltaX); - REGISTER_GLOBAL_FUNC("float getMouseDragDeltaY()", getMouseDragDeltaY); - REGISTER_GLOBAL_FUNC("float getMouseDeltaX()", getMouseDeltaX); - REGISTER_GLOBAL_FUNC("float getMouseDeltaY()", getMouseDeltaY); - REGISTER_GLOBAL_FUNC("int getAvailableSizeX()", getAvailableSizeX); - REGISTER_GLOBAL_FUNC("int getAvailableSizeY()", getAvailableSizeY); - REGISTER_GLOBAL_FUNC("void disablePannelPadding(bool)", disablePannelPadding); - REGISTER_GLOBAL_FUNC("int sliderInt(string&in, int, int, int)", sliderInt); - REGISTER_GLOBAL_FUNC("float slider(string&in, float, float, float)", slider); - scriptEngine->SetDefaultNamespace(""); - } - - void EditorEngine::registerUIStructs() { - AS_CHECK(scriptEngine->RegisterEnum("key")); - - AS_CHECK(scriptEngine->RegisterEnumValue("key", "A", ImGuiKey_A)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "B", ImGuiKey_B)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "C", ImGuiKey_C)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "D", ImGuiKey_D)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "E", ImGuiKey_E)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "F", ImGuiKey_F)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "G", ImGuiKey_G)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "H", ImGuiKey_H)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "I", ImGuiKey_I)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "J", ImGuiKey_J)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K", ImGuiKey_K)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "L", ImGuiKey_L)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "M", ImGuiKey_M)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "N", ImGuiKey_N)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "O", ImGuiKey_O)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "P", ImGuiKey_P)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Q", ImGuiKey_Q)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "R", ImGuiKey_R)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "S", ImGuiKey_S)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "T", ImGuiKey_T)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "U", ImGuiKey_U)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "V", ImGuiKey_V)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "W", ImGuiKey_W)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "X", ImGuiKey_X)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Y", ImGuiKey_Y)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Z", ImGuiKey_Z)); - - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K0", ImGuiKey_0)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K1", ImGuiKey_1)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K2", ImGuiKey_2)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K3", ImGuiKey_3)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K4", ImGuiKey_4)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K5", ImGuiKey_5)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K6", ImGuiKey_6)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K7", ImGuiKey_7)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K8", ImGuiKey_8)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K9", ImGuiKey_9)); - - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Tab", ImGuiKey_Tab)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Enter", ImGuiKey_Enter)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Escape", ImGuiKey_Escape)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Backspace", ImGuiKey_Backspace)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Space", ImGuiKey_Space)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Delete", ImGuiKey_Delete)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Insert", ImGuiKey_Insert)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Home", ImGuiKey_Home)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "End", ImGuiKey_End)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "PageUp", ImGuiKey_PageUp)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "PageDown", ImGuiKey_PageDown)); - - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Right", ImGuiKey_RightArrow)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Up", ImGuiKey_UpArrow)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Down", ImGuiKey_DownArrow)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Left", ImGuiKey_LeftArrow)); - - AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightCtrl", ImGuiKey_RightCtrl)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftShift", ImGuiKey_LeftShift)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightShift", ImGuiKey_RightShift)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftAlt", ImGuiKey_LeftAlt)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightAlt", ImGuiKey_RightAlt)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftSuper", ImGuiKey_LeftSuper)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightSuper", ImGuiKey_RightSuper)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftCtrl", ImGuiKey_LeftCtrl)); - - AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseLeft", ImGuiKey_MouseLeft)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseRight", ImGuiKey_MouseRight)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseMiddle", ImGuiKey_MouseMiddle)); - } -} - -/* -enum ImGuiKey : int -{ - // Keyboard - ImGuiKey_None = 0, - ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN - ImGuiKey_LeftArrow, - ImGuiKey_RightArrow, - ImGuiKey_UpArrow, - ImGuiKey_DownArrow, - ImGuiKey_PageUp, - ImGuiKey_PageDown, - ImGuiKey_Home, - ImGuiKey_End, - ImGuiKey_Insert, - ImGuiKey_Delete, - ImGuiKey_Backspace, - ImGuiKey_Space, - ImGuiKey_Enter, - ImGuiKey_Escape, - ImGuiKey_LeftCtrl, ImGuiKey_LeftShift, ImGuiKey_LeftAlt, ImGuiKey_LeftSuper, - ImGuiKey_RightCtrl, ImGuiKey_RightShift, ImGuiKey_RightAlt, ImGuiKey_RightSuper, - ImGuiKey_Menu, - ImGuiKey_0, ImGuiKey_1, ImGuiKey_2, ImGuiKey_3, ImGuiKey_4, ImGuiKey_5, ImGuiKey_6, ImGuiKey_7, ImGuiKey_8, ImGuiKey_9, - ImGuiKey_A, ImGuiKey_B, ImGuiKey_C, ImGuiKey_D, ImGuiKey_E, ImGuiKey_F, ImGuiKey_G, ImGuiKey_H, ImGuiKey_I, ImGuiKey_J, - ImGuiKey_K, ImGuiKey_L, ImGuiKey_M, ImGuiKey_N, ImGuiKey_O, ImGuiKey_P, ImGuiKey_Q, ImGuiKey_R, ImGuiKey_S, ImGuiKey_T, - ImGuiKey_U, ImGuiKey_V, ImGuiKey_W, ImGuiKey_X, ImGuiKey_Y, ImGuiKey_Z, - ImGuiKey_F1, ImGuiKey_F2, ImGuiKey_F3, ImGuiKey_F4, ImGuiKey_F5, ImGuiKey_F6, - ImGuiKey_F7, ImGuiKey_F8, ImGuiKey_F9, ImGuiKey_F10, ImGuiKey_F11, ImGuiKey_F12, - ImGuiKey_Apostrophe, // ' - ImGuiKey_Comma, // , - ImGuiKey_Minus, // - - ImGuiKey_Period, // . - ImGuiKey_Slash, // / - ImGuiKey_Semicolon, // ; - ImGuiKey_Equal, // = - ImGuiKey_LeftBracket, // [ - ImGuiKey_Backslash, // \ (this text inhibit multiline comment caused by backslash) - ImGuiKey_RightBracket, // ] - ImGuiKey_GraveAccent, // ` - ImGuiKey_CapsLock, - ImGuiKey_ScrollLock, - ImGuiKey_NumLock, - ImGuiKey_PrintScreen, - ImGuiKey_Pause, - ImGuiKey_Keypad0, ImGuiKey_Keypad1, ImGuiKey_Keypad2, ImGuiKey_Keypad3, ImGuiKey_Keypad4, - ImGuiKey_Keypad5, ImGuiKey_Keypad6, ImGuiKey_Keypad7, ImGuiKey_Keypad8, ImGuiKey_Keypad9, - ImGuiKey_KeypadDecimal, - ImGuiKey_KeypadDivide, - ImGuiKey_KeypadMultiply, - ImGuiKey_KeypadSubtract, - ImGuiKey_KeypadAdd, - ImGuiKey_KeypadEnter, - ImGuiKey_KeypadEqual, - - // Gamepad (some of those are analog values, 0.0f to 1.0f) // NAVIGATION ACTION - // (download controller mapping PNG/PSD at http://dearimgui.org/controls_sheets) - ImGuiKey_GamepadStart, // Menu (Xbox) + (Switch) Start/Options (PS) - ImGuiKey_GamepadBack, // View (Xbox) - (Switch) Share (PS) - ImGuiKey_GamepadFaceLeft, // X (Xbox) Y (Switch) Square (PS) // Tap: Toggle Menu. Hold: Windowing mode (Focus/Move/Resize windows) - ImGuiKey_GamepadFaceRight, // B (Xbox) A (Switch) Circle (PS) // Cancel / Close / Exit - ImGuiKey_GamepadFaceUp, // Y (Xbox) X (Switch) Triangle (PS) // Text Input / On-screen Keyboard - ImGuiKey_GamepadFaceDown, // A (Xbox) B (Switch) Cross (PS) // Activate / Open / Toggle / Tweak - ImGuiKey_GamepadDpadLeft, // D-pad Left // Move / Tweak / Resize Window (in Windowing mode) - ImGuiKey_GamepadDpadRight, // D-pad Right // Move / Tweak / Resize Window (in Windowing mode) - ImGuiKey_GamepadDpadUp, // D-pad Up // Move / Tweak / Resize Window (in Windowing mode) - ImGuiKey_GamepadDpadDown, // D-pad Down // Move / Tweak / Resize Window (in Windowing mode) - ImGuiKey_GamepadL1, // L Bumper (Xbox) L (Switch) L1 (PS) // Tweak Slower / Focus Previous (in Windowing mode) - ImGuiKey_GamepadR1, // R Bumper (Xbox) R (Switch) R1 (PS) // Tweak Faster / Focus Next (in Windowing mode) - ImGuiKey_GamepadL2, // L Trig. (Xbox) ZL (Switch) L2 (PS) [Analog] - ImGuiKey_GamepadR2, // R Trig. (Xbox) ZR (Switch) R2 (PS) [Analog] - ImGuiKey_GamepadL3, // L Stick (Xbox) L3 (Switch) L3 (PS) - ImGuiKey_GamepadR3, // R Stick (Xbox) R3 (Switch) R3 (PS) - ImGuiKey_GamepadLStickLeft, // [Analog] // Move Window (in Windowing mode) - ImGuiKey_GamepadLStickRight, // [Analog] // Move Window (in Windowing mode) - ImGuiKey_GamepadLStickUp, // [Analog] // Move Window (in Windowing mode) - ImGuiKey_GamepadLStickDown, // [Analog] // Move Window (in Windowing mode) - ImGuiKey_GamepadRStickLeft, // [Analog] - ImGuiKey_GamepadRStickRight, // [Analog] - ImGuiKey_GamepadRStickUp, // [Analog] - ImGuiKey_GamepadRStickDown, // [Analog] - - // Aliases: Mouse Buttons (auto-submitted from AddMouseButtonEvent() calls) - // - This is mirroring the data also written to io.MouseDown[], io.MouseWheel, in a format allowing them to be accessed via standard key API. - ImGuiKey_MouseLeft, ImGuiKey_MouseRight, ImGuiKey_MouseMiddle, ImGuiKey_MouseX1, ImGuiKey_MouseX2, ImGuiKey_MouseWheelX, ImGuiKey_MouseWheelY, - - // [Internal] Reserved for mod storage - ImGuiKey_ReservedForModCtrl, ImGuiKey_ReservedForModShift, ImGuiKey_ReservedForModAlt, ImGuiKey_ReservedForModSuper, - ImGuiKey_COUNT, - - // Keyboard Modifiers (explicitly submitted by backend via AddKeyEvent() calls) - // - This is mirroring the data also written to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper, in a format allowing - // them to be accessed via standard key API, allowing calls such as IsKeyPressed(), IsKeyReleased(), querying duration etc. - // - Code polling every key (e.g. an interface to detect a key press for input mapping) might want to ignore those - // and prefer using the real keys (e.g. ImGuiKey_LeftCtrl, ImGuiKey_RightCtrl instead of ImGuiMod_Ctrl). - // - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys. - // In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and - // backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user... - ImGuiMod_None = 0, - ImGuiMod_Ctrl = 1 << 12, // Ctrl - ImGuiMod_Shift = 1 << 13, // Shift - ImGuiMod_Alt = 1 << 14, // Option/Menu - ImGuiMod_Super = 1 << 15, // Cmd/Super/Windows - ImGuiMod_Shortcut = 1 << 11, // Alias for Ctrl (non-macOS) _or_ Super (macOS). - ImGuiMod_Mask_ = 0xF800, // 5-bits - - // [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index + the io.KeyMap[] array. - // We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE) - ImGuiKey_NamedKey_BEGIN = 512, - ImGuiKey_NamedKey_END = ImGuiKey_COUNT, - ImGuiKey_NamedKey_COUNT = ImGuiKey_NamedKey_END - ImGuiKey_NamedKey_BEGIN, -#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO - ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys - ImGuiKey_KeysData_OFFSET = ImGuiKey_NamedKey_BEGIN, // First key stored in io.KeysData[0]. Accesses to io.KeysData[] must use (key - ImGuiKey_KeysData_OFFSET). -#else - ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys - ImGuiKey_KeysData_OFFSET = 0, // First key stored in io.KeysData[0]. Accesses to io.KeysData[] must use (key - ImGuiKey_KeysData_OFFSET). -#endif - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - ImGuiKey_ModCtrl = ImGuiMod_Ctrl, ImGuiKey_ModShift = ImGuiMod_Shift, ImGuiKey_ModAlt = ImGuiMod_Alt, ImGuiKey_ModSuper = ImGuiMod_Super, // Renamed in 1.89 - ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter, // Renamed in 1.87 -#endif -}*/ \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelContext.cpp b/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelContext.cpp deleted file mode 100644 index 7163a1d..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelContext.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h" -#include "DeerStudio/EditorEngine.h" -#include "Deer/Log.h" - -#include "angelscript.h" -#include - -namespace Deer { - namespace EditorEngine { - DockPanelContext::DockPanelContext(asIScriptModule* _module, DockPanelInfo* _info) - : module(_module), info(_info) { - - size_t nScripts = module->GetObjectTypeCount(); - asITypeInfo* dockPanelType = scriptEngine->GetTypeInfoByName("DockPanel"); - - if (!dockPanelType) { - DEER_EDITOR_ENGINE_ERROR("Could not load DockPanel interface type"); - return; - } - - context = scriptEngine->CreateContext(); - context->AddRef(); - for (size_t i = 0; i < nScripts; i++) { - asITypeInfo* info = module->GetObjectTypeByIndex(i); - - // If it does not implement dock panel we are not interested int it - if (!info->Implements(dockPanelType)) - continue; - - dockPanels.push_back({info, context}); - } - - } - - DockPanelContext::DockPanelContext(DockPanelContext&& dp) - : dockPanels(std::move(dp.dockPanels)) { - module = dp.module; - context = dp.context; - info = dp.info; - - dp.context = nullptr; - dp.module = nullptr; - dp.info = nullptr; - } - - DockPanelContext& DockPanelContext::operator=(DockPanelContext&& dp) { - if (&dp != this) { - dockPanels = std::move(dp.dockPanels); - module = dp.module; - context = dp.context; - info = dp.info; - - dp.context = nullptr; - dp.module = nullptr; - dp.info = nullptr; - } - return *this; - } - - void DockPanelContext::init() { - for (DockPanelObject& panel : dockPanels) { - currentDockPanelExecution = &panel; - panel.init(); - } - - currentDockPanelExecution = nullptr; - } - - void DockPanelContext::render() { - for (DockPanelObject& panel : dockPanels) { - currentDockPanelExecution = &panel; - panel.render(); - } - - currentDockPanelExecution = nullptr; - } - - DockPanelContext::~DockPanelContext() { - dockPanels.clear(); - - if (context) - context->Release(); - - delete info; - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelInfo.h b/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelInfo.h deleted file mode 100644 index 583d091..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelInfo.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptInfo.h" - -#include "Deer/Path.h" -#include -#include - -namespace Deer { - namespace EditorEngine { - struct DockPanelInfo { - std::string name = "null"; - std::string author = ""; - std::string version = "0.0.0"; - std::vector services; - }; - - DockPanelInfo* loadDockPanelInfo(Path panelInfo); - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelInfoSerialization.cpp b/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelInfoSerialization.cpp deleted file mode 100644 index a3bf2e6..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelInfoSerialization.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "DeerStudio/EditorEngine/DockPanel/DockPanelInfo.h" -#include "Deer/Log.h" - -#include "cereal/cereal.hpp" -#include "cereal/archives/json.hpp" -#include "cereal/types/string.hpp" -#include "cereal/types/vector.hpp" - -#include -#include -#include - -namespace Deer { - namespace EditorEngine { - template - void serialize(Archive& ar, DockPanelInfo& data) { - ar(cereal::make_nvp("name", data.name)); - ar(cereal::make_nvp("author", data.author)); - ar(cereal::make_nvp("version", data.version)); - ar(cereal::make_nvp("services", data.services)); - } - - template - void serialize(Archive& ar, ServiceScriptRef& data) { - ar(cereal::make_nvp("name", data.name)); - ar(cereal::make_nvp("version", data.version)); - } - - DockPanelInfo* loadDockPanelInfo(Path dockPanelInfoPath) { - try { - std::ifstream is(dockPanelInfoPath); - - if (!is) - return new DockPanelInfo(); - - DockPanelInfo* info = new DockPanelInfo(); - { - cereal::JSONInputArchive archive(is); - archive(cereal::make_nvp("dockPanelModule", *info)); - } - - return info; - } catch (const std::exception& e) { - DEER_EDITOR_ENGINE_TRACE(e.what()); - return new DockPanelInfo(); - } - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelObject.cpp b/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelObject.cpp deleted file mode 100644 index da87681..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/DockPanel/DockPanelObject.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine.h" - -#include "Deer/Log.h" - -#include "angelscript.h" -#include - -#include "imgui.h" - -namespace Deer { - EditorEngine::DockPanelObject::DockPanelObject(asITypeInfo* _type, asIScriptContext* _scriptContext) - : type (_type), isValid(false), scriptContext(_scriptContext){ - - // Constructor - // "type@ type()" - std::string callString; - const std::string ns(type->GetNamespace()); - if (ns != "") { - callString += ns; - callString += "::"; - } - callString += type->GetName(); - callString += "@ "; - if (ns != "") { - callString += ns; - callString += "::"; - } - callString += type->GetName(); - callString += "()"; - - flags = DockPannelFlag_ShowPannel; - - asIScriptFunction* factory = type->GetFactoryByDecl(callString.c_str()); - - AS_CHECK(scriptContext->Prepare(factory)); - AS_CHECK(scriptContext->Execute()); - - // Return value contains the ref to a asIScriptObject in the location provided - object = *(asIScriptObject**)scriptContext->GetAddressOfReturnValue(); - if (!object){ - DEER_EDITOR_ENGINE_ERROR("Could not create object", type->GetName()); - return; - } - object->AddRef(); - - renderFunction = type->GetMethodByDecl("void onRender()"); - if (!renderFunction) { - DEER_EDITOR_ENGINE_ERROR("Could not load void onRender() from {0}", type->GetName()); - return; - } - - menuBarFunction = type->GetMethodByDecl("void onMenuBar()"); - initFunction = type->GetMethodByDecl("void onInit()"); - - isValid = true; - - scriptContext->Unprepare(); - - } - - int EditorEngine::DockPanelObject::getRefCount() { - int refCount = object->AddRef(); // increments refcount by 1 - refCount = object->Release(); - - return refCount; - } - - const char* EditorEngine::DockPanelObject::getName() { - return type->GetName(); - } - - EditorEngine::DockPanelObject::~DockPanelObject() { - if (object) - object->Release(); - } - - void EditorEngine::DockPanelObject::invalidate() { - DEER_EDITOR_ENGINE_ERROR("Last error was caused executing {0}", type->GetName()); - isValid = false; - } - - void EditorEngine::DockPanelObject::init() { - - if (!initFunction) - return; - - executingScriptContext = scriptContext; - AS_CHECK(scriptContext->Prepare(initFunction)); - AS_CHECK(scriptContext->SetObject(object)); - AS_CHECK(scriptContext->Execute()); - AS_CHECK(scriptContext->Unprepare()); - executingScriptContext = nullptr; - } - - void EditorEngine::DockPanelObject::render() { - bool show = flags & DockPannelFlag_ShowPannel; - if (!show) - return; - - // We cache the result because the user can remove the flag while executing - bool hasPadding = flags & DockPannelFlag_PannelPadding; - if (hasPadding) - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); - - if (menuBarFunction) { - ImGui::Begin(type->GetName(), (bool*)0, ImGuiWindowFlags_MenuBar); - - if (ImGui::BeginMenuBar()) { - executingScriptContext = scriptContext; - AS_CHECK(scriptContext->Prepare(menuBarFunction)); - AS_CHECK(scriptContext->SetObject(object)); - AS_CHECK(scriptContext->Execute()); - AS_CHECK(scriptContext->Unprepare()); - executingScriptContext = nullptr; - - ImGui::EndMenuBar(); - } - } else { - ImGui::Begin(type->GetName()); - } - - // This is to make sure that right click activates the window - if (ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) && - (ImGui::IsMouseClicked(ImGuiMouseButton_Right) || ImGui::IsMouseClicked(ImGuiMouseButton_Middle))) { - ImGui::SetWindowFocus(); - } - - if (!isValid) { - ImGui::TextColored(ImVec4(1, 0.3f, 0.3f, 1), "There was a runtime error"); - ImGui::TextColored(ImVec4(1, 0.4f, 0.4f, 1), "Please check the log"); - ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1), "Plese restart the interface"); - ImGui::End(); - return; - } - - executingScriptContext = scriptContext; - AS_CHECK(scriptContext->Prepare(renderFunction)); - AS_CHECK(scriptContext->SetObject(object)); - AS_CHECK(scriptContext->Execute()); - AS_CHECK(scriptContext->Unprepare()); - executingScriptContext = nullptr; - - ImGui::End(); - - if (hasPadding) - ImGui::PopStyleVar(); - } - - EditorEngine::DockPanelObject::DockPanelObject(DockPanelObject&& other) noexcept - : isValid(other.isValid), - renderFunction(other.renderFunction), - type(other.type), - object(other.object), - menuBarFunction(other.menuBarFunction), - initFunction(other.initFunction), - flags(other.flags), - scriptContext(other.scriptContext) { - - other.isValid = false; - other.renderFunction = nullptr; - other.type = nullptr; - other.object = nullptr; - other.menuBarFunction = nullptr; - other.initFunction = nullptr; - other.scriptContext = nullptr; - } - - EditorEngine::DockPanelObject& EditorEngine::DockPanelObject::operator=(EditorEngine::DockPanelObject&& other) noexcept { - if (this != &other) { - if (object) - object->Release(); - - isValid = other.isValid; - renderFunction = other.renderFunction; - type = other.type; - object = other.object; - menuBarFunction = other.menuBarFunction; - initFunction = other.initFunction; - flags = other.flags; - scriptContext = other.scriptContext; - - other.isValid = false; - other.renderFunction = nullptr; - other.type = nullptr; - other.object = nullptr; - other.menuBarFunction = nullptr; - other.initFunction = nullptr; - other.scriptContext = nullptr; - } - - return *this; - } - - void EditorEngine::DockPanelObject::setFlag(uint32_t flag, bool value) { - if ((flag & flags) != value) - flags ^= flag; - } - - bool EditorEngine::DockPanelObject::getFlag(uint32_t flag) { - return flag & flags; - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/EditorEngine.cpp b/DeerStudio/src/DeerStudio/EditorEngine/EditorEngine.cpp index b6f167d..061aa68 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/EditorEngine.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/EditorEngine.cpp @@ -2,11 +2,11 @@ #include "DeerStudio/EditorEngine/API.h" #include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "DeerStudio/DockPanel/DockPanelContext.h" +#include "DeerStudio/DockPanel/DockPanelObject.h" #include "DeerStudio/EditorEngine.h" #include "DeerStudio/EditorEngine/AngelscriptPredefined.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h" -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.h" +#include "DeerStudio/ServiceScript/ServiceScriptContext.h" #include "Deer/Log.h" #include @@ -19,13 +19,13 @@ namespace Deer { namespace EditorEngine { - asIScriptEngine *scriptEngine = nullptr; + asIScriptEngine* scriptEngine = nullptr; std::vector dockPanelModules; std::vector serviceScriptModules; - DockPanelObject *currentDockPanelExecution = nullptr; + DockPanelObject* currentDockPanelExecution = nullptr; - asIScriptContext *executingScriptContext; + asIScriptContext* executingScriptContext; bool active = false; } // namespace EditorEngine @@ -56,11 +56,11 @@ namespace Deer { loadDockPanels(); active = true; - for (ServiceScriptContext &service : serviceScriptModules) { + for (ServiceScriptContext& service : serviceScriptModules) { service.init(); } - for (DockPanelContext &pannel : dockPanelModules) + for (DockPanelContext& pannel : dockPanelModules) pannel.init(); } @@ -79,7 +79,7 @@ namespace Deer { if (!active) return; - for (auto &panel : dockPanelModules) + for (auto& panel : dockPanelModules) panel.render(); } } // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/SeriveScriptInfoSerialization.cpp b/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/SeriveScriptInfoSerialization.cpp deleted file mode 100644 index 5245621..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/SeriveScriptInfoSerialization.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptInfo.h" -#include "Deer/Log.h" - -#include "cereal/cereal.hpp" -#include "cereal/archives/json.hpp" -#include "cereal/types/string.hpp" - -#include -#include -#include - -namespace Deer { - namespace EditorEngine { - template - void serialize(Archive& ar, ServiceScriptInfo& data) { - ar(cereal::make_nvp("name", data.name)); - ar(cereal::make_nvp("author", data.author)); - ar(cereal::make_nvp("version", data.version)); - } - - ServiceScriptInfo* loadServiceScriptInfo(Path seriveScriptInfoPath) { - try { - std::ifstream is(seriveScriptInfoPath); - - if (!is) - return new ServiceScriptInfo(); - - ServiceScriptInfo* info = new ServiceScriptInfo(); - { - cereal::JSONInputArchive archive(is); - archive(cereal::make_nvp("serviceScriptModule", *info)); - } - - return info; - } catch (const std::exception& e) { - DEER_EDITOR_ENGINE_TRACE(e.what()); - return new ServiceScriptInfo(); - } - } - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.h b/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.h deleted file mode 100644 index f91703b..0000000 --- a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptInfo.h" -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.h" -#include - -class asIScriptModule; -class asIScriptContext; - -namespace Deer { - namespace EditorEngine { - class ServiceScriptContext { - public: - ServiceScriptContext(asIScriptModule*, ServiceScriptInfo*); - ~ServiceScriptContext(); - - ServiceScriptContext(ServiceScriptContext&) = delete; - ServiceScriptContext& operator=(ServiceScriptContext&) = delete; - - ServiceScriptContext(ServiceScriptContext&&); - ServiceScriptContext& operator=(ServiceScriptContext&&); - - void update(); - void init(); - - void bindFunctions(); - - inline const char* getName() const { return info->name.c_str(); } - inline const ServiceScriptInfo& getInfo() const { return *info; } - - std::vector scriptServices; - private: - asIScriptContext* context; - asIScriptModule* module; - ServiceScriptInfo* info; - }; - } -} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/PannelMenuBarManagment.cpp b/DeerStudio/src/DeerStudio/PannelMenuBarManagment.cpp index 6f7ff24..473796b 100644 --- a/DeerStudio/src/DeerStudio/PannelMenuBarManagment.cpp +++ b/DeerStudio/src/DeerStudio/PannelMenuBarManagment.cpp @@ -1,7 +1,7 @@ #include "DeerStudio/DeerStudio.h" +#include "DeerStudio/DockPanel/DockPanelContext.h" +#include "DeerStudio/DockPanel/DockPanelObject.h" #include "DeerStudio/EditorEngine.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h" #include "imgui.h" diff --git a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/LoadServiceScripts.cpp b/DeerStudio/src/DeerStudio/ServiceScript/LoadServiceScripts.cpp similarity index 89% rename from DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/LoadServiceScripts.cpp rename to DeerStudio/src/DeerStudio/ServiceScript/LoadServiceScripts.cpp index 56bab03..be4e9ea 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/LoadServiceScripts.cpp +++ b/DeerStudio/src/DeerStudio/ServiceScript/LoadServiceScripts.cpp @@ -2,8 +2,8 @@ #include "DeerStudio/EditorEngine.h" #include "DeerStudio/EditorEngine/AngelscriptPredefined.h" #include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.h" -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptInfo.h" +#include "DeerStudio/ServiceScript/ServiceScriptContext.h" +#include "DeerStudio/ServiceScript/ServiceScriptInfo.h" #include "Deer/DataStore.h" #include "Deer/Path.h" @@ -28,7 +28,7 @@ namespace Deer { return; } - for (const auto &_dir : fs::directory_iterator(path)) { + for (const auto& _dir : fs::directory_iterator(path)) { Path panelInfo_path = _dir.path() / "ServiceScript.json"; // A panel info is neded to load a panel @@ -40,7 +40,7 @@ namespace Deer { continue; } - ServiceScriptInfo *serviceScriptInfo = + ServiceScriptInfo* serviceScriptInfo = loadServiceScriptInfo(panelInfo_path); if (serviceScriptInfo->name == "null") { DEER_EDITOR_ENGINE_ERROR( @@ -64,7 +64,7 @@ namespace Deer { continue; } - for (const auto &entry : fs::recursive_directory_iterator(_dir)) { + for (const auto& entry : fs::recursive_directory_iterator(_dir)) { if (entry.is_regular_file() && entry.path().extension() == ".as") { r = scriptBuilder.AddSectionFromFile( diff --git a/DeerStudio/src/DeerStudio/ServiceScript/SeriveScriptInfoSerialization.cpp b/DeerStudio/src/DeerStudio/ServiceScript/SeriveScriptInfoSerialization.cpp new file mode 100644 index 0000000..e1873d1 --- /dev/null +++ b/DeerStudio/src/DeerStudio/ServiceScript/SeriveScriptInfoSerialization.cpp @@ -0,0 +1,41 @@ +#include "Deer/Log.h" +#include "DeerStudio/ServiceScript/ServiceScriptInfo.h" + +#include "cereal/archives/json.hpp" +#include "cereal/cereal.hpp" +#include "cereal/types/string.hpp" + +#include +#include +#include + +namespace Deer { + namespace EditorEngine { + template + void serialize(Archive& ar, ServiceScriptInfo& data) { + ar(cereal::make_nvp("name", data.name)); + ar(cereal::make_nvp("author", data.author)); + ar(cereal::make_nvp("version", data.version)); + } + + ServiceScriptInfo* loadServiceScriptInfo(Path seriveScriptInfoPath) { + try { + std::ifstream is(seriveScriptInfoPath); + + if (!is) + return new ServiceScriptInfo(); + + ServiceScriptInfo* info = new ServiceScriptInfo(); + { + cereal::JSONInputArchive archive(is); + archive(cereal::make_nvp("serviceScriptModule", *info)); + } + + return info; + } catch (const std::exception& e) { + DEER_EDITOR_ENGINE_TRACE(e.what()); + return new ServiceScriptInfo(); + } + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.cpp b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptContext.cpp similarity index 96% rename from DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.cpp rename to DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptContext.cpp index 7a4fd84..620ac2a 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.cpp +++ b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptContext.cpp @@ -1,4 +1,4 @@ -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.h" +#include "DeerStudio/ServiceScript/ServiceScriptContext.h" #include "DeerStudio/EditorEngine.h" #include "DeerStudio/EditorEngine/ErrorHandle.h" diff --git a/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptContext.h b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptContext.h new file mode 100644 index 0000000..5d26a5f --- /dev/null +++ b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptContext.h @@ -0,0 +1,38 @@ +#pragma once +#include "DeerStudio/ServiceScript/ServiceScriptInfo.h" +#include "DeerStudio/ServiceScript/ServiceScriptObject.h" +#include + +class asIScriptModule; +class asIScriptContext; + +namespace Deer { + namespace EditorEngine { + class ServiceScriptContext { + public: + ServiceScriptContext(asIScriptModule*, ServiceScriptInfo*); + ~ServiceScriptContext(); + + ServiceScriptContext(ServiceScriptContext&) = delete; + ServiceScriptContext& operator=(ServiceScriptContext&) = delete; + + ServiceScriptContext(ServiceScriptContext&&); + ServiceScriptContext& operator=(ServiceScriptContext&&); + + void update(); + void init(); + + void bindFunctions(); + + inline const char* getName() const { return info->name.c_str(); } + inline const ServiceScriptInfo& getInfo() const { return *info; } + + std::vector scriptServices; + + private: + asIScriptContext* context; + asIScriptModule* module; + ServiceScriptInfo* info; + }; + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptGenericFunction.cpp b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptGenericFunction.cpp similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptGenericFunction.cpp rename to DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptGenericFunction.cpp diff --git a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptGenericFunction.h b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptGenericFunction.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptGenericFunction.h rename to DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptGenericFunction.h diff --git a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptInfo.h b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptInfo.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptInfo.h rename to DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptInfo.h diff --git a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.cpp b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptObject.cpp similarity index 97% rename from DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.cpp rename to DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptObject.cpp index c39cc4e..ec77ecc 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.cpp +++ b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptObject.cpp @@ -1,9 +1,9 @@ -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.h" +#include "DeerStudio/ServiceScript/ServiceScriptObject.h" #include "DeerStudio/EditorEngine.h" #include "DeerStudio/EditorEngine/ErrorHandle.h" -#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptGenericFunction.h" +#include "DeerStudio/ServiceScript/ServiceScriptGenericFunction.h" #include "angelscript.h" #include "scriptbuilder.h" diff --git a/DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.h b/DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptObject.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.h rename to DeerStudio/src/DeerStudio/ServiceScript/ServiceScriptObject.h diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Asset.h b/DeerStudio/src/DeerStudio/StudioAPI/Asset.h similarity index 92% rename from DeerStudio/src/DeerStudio/EditorEngine/API/Asset.h rename to DeerStudio/src/DeerStudio/StudioAPI/Asset.h index b10ac67..e180000 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/Asset.h +++ b/DeerStudio/src/DeerStudio/StudioAPI/Asset.h @@ -27,9 +27,6 @@ namespace Deer { // dir std::string getDirNameById(AssetType, std::string& dir, int i); - std::string getParentPath(std::string&); - std::string getParentPathName(std::string&); - // INTERNAL const char* getAssetTypePath(AssetType); const char* getAssetTypeExtension(AssetType); diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Component.h b/DeerStudio/src/DeerStudio/StudioAPI/Component.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/API/Component.h rename to DeerStudio/src/DeerStudio/StudioAPI/Component.h diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Debug.h b/DeerStudio/src/DeerStudio/StudioAPI/Debug.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/API/Debug.h rename to DeerStudio/src/DeerStudio/StudioAPI/Debug.h diff --git a/DeerStudio/src/DeerStudio/StudioAPI/Engine.h b/DeerStudio/src/DeerStudio/StudioAPI/Engine.h new file mode 100644 index 0000000..d21a65c --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI/Engine.h @@ -0,0 +1,14 @@ +#pragma once +#include "scriptarray.h" +#include + +namespace Deer { + namespace EditorEngine { + std::string getParentPath(std::string&); + std::string getParentPathName(std::string&); + + CScriptArray* dividePath(std::string&); + + void registerEngineFunctions(); + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI/Entity.h b/DeerStudio/src/DeerStudio/StudioAPI/Entity.h new file mode 100644 index 0000000..0ce3559 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI/Entity.h @@ -0,0 +1,130 @@ +#pragma once +#include "DeerStudio/StudioAPI/GenericRefStructs.h" + +#include "glm/glm.hpp" +#include +#include + +namespace Deer { + namespace EditorEngine { + struct EntityStruct; + extern EntityStruct activeEntity; + + // IN ANGEL SCRIPT IT LOOKS LIKE THIS + // class Entity { + // int id; + // string name; + // + // int childCount; + // bool isRoot; + // + // Entity parent; + // Entiy getChild(int); + // Entity createChild(int); + // + // void destroy(); + // bool isDescendantOf + // + // bool == + //} + struct EntityStruct : EntityHandleStruct { + EntityStruct(uint16_t entId = 0) { entityId = entId; } + + std::string getName(); + void setName(std::string&); + + int getId(); + bool exists(); + + bool isRoot(); + void destroy(); + + EntityHandleStruct createChild(std::string&); + + void setParent(EntityHandleStruct parent); + EntityHandleStruct getParent(); + + bool isDescendantOf(EntityHandleStruct parent); + bool opEquals(const EntityHandleStruct& other); + + // COMPONENTS + EntityHandleStruct getMeshComponent(); + EntityHandleStruct createMeshComponent(); + bool hasMeshComponent(); + void removeMeshComponent(); + + EntityHandleStruct getShaderComponent(); + EntityHandleStruct createShaderComponent(); + bool hasShaderComponent(); + void removeShaderComponent(); + + EntityHandleStruct getCameraComponent(); + EntityHandleStruct createCameraComponent(); + bool hasCameraComponent(); + void removeCameraComponent(); + + // This function can be adapted to get a specific transform since + // the data is the same + EntityHandleStruct getSelf(); + }; + + struct EntityChildArrayStruct : EntityHandleStruct { + int getChildCount(); + EntityHandleStruct getChild(int); + }; + + struct TransformComponentStruct : EntityHandleStruct { + glm::vec3 getPosition(); + glm::vec3 getScale(); + glm::vec3 getRotation(); + + void setPosition(glm::vec3); + void setScale(glm::vec3); + void setRotation(glm::vec3); + }; + + struct MeshComponentStruct : EntityHandleStruct { + bool isActive(); + void setActive(bool); + + bool hasMesh(); + void clear(); + + std::string getMesh(); + void setMesh(std::string&); + + bool assertMeshComponent(const char* funcName); + }; + + struct ShaderComponentStruct : EntityHandleStruct { + bool hasShader(); + void clear(); + + std::string getShader(); + void setShader(std::string&); + + bool assertShaderComponent(const char* funcName); + }; + + struct CameraComponentStruct : EntityHandleStruct { + float getFov(); + float getAspectRation(); + float getNearZ(); + float getFarZ(); + + void setFov(float); + void setAspectRation(float); + void setNearZ(float); + void setFarZ(float); + + bool assertCameraComponent(const char* funcName); + }; + + EntityHandleStruct getRoot(); + void constructEntityStruct(int id, void* memory); + void copyEntityStruct(int id, void* memory); + + void registerEntityStructs(); + void registerEntityFunctions(); + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h b/DeerStudio/src/DeerStudio/StudioAPI/Environment.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h rename to DeerStudio/src/DeerStudio/StudioAPI/Environment.h diff --git a/DeerStudio/src/DeerStudio/StudioAPI/FrameBuffer.h b/DeerStudio/src/DeerStudio/StudioAPI/FrameBuffer.h new file mode 100644 index 0000000..a0ce565 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI/FrameBuffer.h @@ -0,0 +1,29 @@ +#pragma once +#include "DeerStudio/StudioAPI/GenericRefStructs.h" +#include +#include + +namespace Deer { + namespace EditorEngine { + struct FrameBufferStruct : FrameBufferHandleStruct { + FrameBufferStruct(uint16_t _id) { frameBufferId = _id; } + + int getWidth(); + int getHeight(); + + void clearRGBA(int, int, int, int); + bool isValid(); + + void resize(int, int); + std::string getName(); + }; + + FrameBufferStruct createRGBA8FrameBuffer(std::string& name, int, int); + FrameBufferStruct getFrameBuffer(std::string& name); + + void frameBuffer_constructor(FrameBufferHandleStruct* mem); + + void registerFrameBufferStructs(); + void registerFrameBufferFunctions(); + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h b/DeerStudio/src/DeerStudio/StudioAPI/GenericRefStructs.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h rename to DeerStudio/src/DeerStudio/StudioAPI/GenericRefStructs.h diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h b/DeerStudio/src/DeerStudio/StudioAPI/Layout.h similarity index 97% rename from DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h rename to DeerStudio/src/DeerStudio/StudioAPI/Layout.h index 1db6454..b413767 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h +++ b/DeerStudio/src/DeerStudio/StudioAPI/Layout.h @@ -26,7 +26,7 @@ namespace Deer { bool treeNodeRecursive(std::string&, bool, CScriptAny*, asIScriptFunction&); - // Call, x, y, border + // Data, Call, x, y, border void childWindow(CScriptAny*, asIScriptFunction*, int, int, bool); void space(); diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Math.h b/DeerStudio/src/DeerStudio/StudioAPI/Math.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/API/Math.h rename to DeerStudio/src/DeerStudio/StudioAPI/Math.h diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Menu.h b/DeerStudio/src/DeerStudio/StudioAPI/Menu.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/API/Menu.h rename to DeerStudio/src/DeerStudio/StudioAPI/Menu.h diff --git a/DeerStudio/src/DeerStudio/StudioAPI/UI.h b/DeerStudio/src/DeerStudio/StudioAPI/UI.h new file mode 100644 index 0000000..e0dc727 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI/UI.h @@ -0,0 +1,112 @@ +#pragma once +#include "DeerStudio/StudioAPI/GenericRefStructs.h" +#include "glm/glm.hpp" +#include + +class asIScriptFunction; +class CScriptAny; + +namespace Deer { + namespace EditorEngine { + namespace DragDropPayload { + extern CScriptAny* payload; + } + + // Renders the ui elements in the same line + void sameline(); + // Renders a line separator + void separator(); + + // Renders a button + bool button(std::string&); + // Renders a button at the end + bool buttonCenter(std::string&); + // Renders a button at the end + bool buttonEnd(std::string&); + + // Renders a text + void text(std::string&); + // Renders a text + void textCenter(std::string&); + // Renders a text + void textEnd(std::string&); + + // Renders a text with the defined rgb values from range [0.0, 1.0] + void textColor(float r, float g, float b, std::string& msg); + // Renders a big text + void title(std::string&); + // Renders a big text + void titleCenter(std::string&); + // Renders a big text + void titleEnd(std::string&); + + // Renders a big text in the center of a specified height + void titleCenterY(std::string&, int); + + // Renders a icon in the specified size in pixels + void drawIcon(std::string& iconId, int size); + // Renders a icon in the specified size in pixels at the center + void drawIconCentered(std::string& iconId, int size); + + // Renders a icon in the specified size in pixels + void drawFrameBuffer(FrameBufferHandleStruct frameBuffer, int sizeX, + int sizeY); + // Renders a icon in the specified size in pixels + void drawFrameBufferCentered(FrameBufferHandleStruct frameBuffer, + int sizeX, int sizeY); + + // Returns if the specified mouse button is clicked on the last element + bool isItemClicked(int mouse); + // Returns if the specified mouse button is double clicked + bool isMouseDoubleClicked(int mouse); + + bool isKeyDown(int); + bool isKeyPressed(int); + + bool isMouseDraggin(int); + float getMouseDragDeltaX(); + float getMouseDragDeltaY(); + float getMouseDeltaX(); + float getMouseDeltaY(); + + void disablePannelPadding(bool); + + int getAvailableSizeX(); + int getAvailableSizeY(); + + float slider(std::string&, float, float, float); + int sliderInt(std::string&, int, int, int); + + // Draws a button for a popup menu + bool menuItem(std::string&); + // Draws a button disabled + void menuItemDisabled(std::string&); + // Draws a space where you can put buttons inside + void menuSpace(std::string&, CScriptAny*, asIScriptFunction*); + + // Initializes the drag drop source with the id and the data you want to + // pass + void dragDropSource(std::string&, CScriptAny*, std::string&); + // Prepares the function to accept payload with the id and calls the + // function with the data + void dragDropTarget(std::string&, CScriptAny*, asIScriptFunction*); + + // Draws a simple input with a label, input and output string + bool inputText(std::string& label, std::string&, std::string&); + // Draws a simple checkbox + bool checkbox(std::string& label, bool); + // Draws a simple checkbox + bool checkboxDisabled(std::string& label, bool); + // Draws a complex slider that with double click you can set a specific + // value + float magicSlider(std::string&, float, float); + // Draws a complex slider that with double click you can set a specific + // value in vec3 + glm::vec3 magicSlider3(std::string&, glm::vec3, float); + // Returns if the current executing pannel is active + bool isPannelActive(); + + void registerUIFunctions(); + void registerUIStructs(); + } // namespace EditorEngine +} // namespace Deer diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Resource.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Asset.cpp similarity index 94% rename from DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Resource.cpp rename to DeerStudio/src/DeerStudio/StudioAPI_Implementation/Asset.cpp index a598ac2..1701ee9 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Resource.cpp +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Asset.cpp @@ -1,8 +1,8 @@ +#include "DeerStudio/StudioAPI/Asset.h" #include "Deer/DataStore.h" #include "Deer/Log.h" +#include "DeerStudio/DockPanel/DockPanelObject.h" #include "DeerStudio/EditorEngine.h" -#include "DeerStudio/EditorEngine/API/Asset.h" -#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h" namespace Deer { namespace EditorEngine { @@ -100,14 +100,6 @@ namespace Deer { return dirData.elements[i].stem().string(); } - std::string getParentPath(std::string& path) { - return Path(path).parent_path().string(); - } - - std::string getParentPathName(std::string& path) { - return Path(path).parent_path().stem().string(); - } - std::string getAssetTypePathById(AssetType type, std::string& dir, int i) { const char* resourcePath = getAssetTypePath(type); diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Debug.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Debug.cpp new file mode 100644 index 0000000..69328af --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Debug.cpp @@ -0,0 +1,28 @@ +#include "DeerStudio/StudioAPI/Debug.h" +#include "Deer/Log.h" + +#include "angelscript.h" +#include "imgui.h" + +namespace Deer { + namespace EditorEngine { + + void errorCallback(const asSMessageInfo* msg, void* param) { + if (msg->type == asMSGTYPE_WARNING) { + DEER_EDITOR_ENGINE_WARN("{0}:{1}:{2}) : {3}", msg->section, + msg->row, msg->col, msg->message); + } else if (msg->type == asMSGTYPE_INFORMATION) { + DEER_EDITOR_ENGINE_ERROR("{0}:{1}:{2}) : {3}", msg->section, + msg->row, msg->col, msg->message); + } else if (msg->type == asMSGTYPE_INFORMATION) { + DEER_EDITOR_ENGINE_TRACE("{0}:{1}:{2}) : {3}", msg->section, + msg->row, msg->col, msg->message); + } + } + + void print(std::string& msg) { + DEER_EDITOR_ENGINE_INFO("{0}", msg.c_str()); + } + + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Engine.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Engine.cpp new file mode 100644 index 0000000..aac0ca5 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Engine.cpp @@ -0,0 +1,36 @@ +#include "DeerStudio/StudioAPI/Engine.h" +#include "DeerStudio/EditorEngine.h" +#include "angelscript.h" +#include "scriptstdstring.h" + +#include "Deer/Path.h" +#include + +namespace Deer { + namespace EditorEngine { + std::string getParentPath(std::string& path) { + return Path(path).parent_path().string(); + } + + std::string getParentPathName(std::string& path) { + return Path(path).parent_path().stem().string(); + } + + CScriptArray* dividePath(std::string& path_s) { + asITypeInfo* arrType = + EditorEngine::scriptEngine->GetTypeInfoByDecl("array"); + + CScriptArray* array = CScriptArray::Create(arrType); + + Path path_p(path_s); + for (const auto& part : path_p) { + std::string s = part.string(); + + array->Resize(array->GetSize() + 1); + array->SetValue(array->GetSize() - 1, &s); + } + + return array; + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Entity.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Entity.cpp new file mode 100644 index 0000000..e2c4be9 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Entity.cpp @@ -0,0 +1,541 @@ +#include "DeerStudio/StudioAPI/Entity.h" +#include "DeerStudio/DockPanel/DockPanelObject.h" +#include "DeerStudio/EditorEngine.h" + +#include "DeerRender/Components.h" + +#include "Deer/Enviroment.h" +#include "Deer/Scene.h" + +#include + +#define GET_ENV(env) (*Deer::EditorEngine::environments[env]) + +#define GET_ENTITY(env, id) GET_ENV(env).getEntity(id) +#define GET_MESH_COMPONENT(env, id) \ + GET_ENV(env).getEntity(id).getComponent() +#define GET_SHADER_COMPONENT(env, id) \ + GET_ENV(env).getEntity(id).getComponent() +#define GET_CAMERA_COMPONENT(env, id) \ + GET_ENV(env).getEntity(id).getComponent() + +#define ASSERT_ENTITY(func, ret) \ + if (!assertEntity(func)) \ + ret; +#define ASSERT_MESH_COMPONENT(func, ret) \ + if (!assertMeshComponent(func)) \ + ret; +#define ASSERT_SHADER_COMPONENT(func, ret) \ + if (!assertShaderComponent(func)) \ + ret; +#define ASSERT_CAMERA_COMPONENT(func, ret) \ + if (!assertCameraComponent(func)) \ + ret; + +namespace Deer { + namespace EditorEngine { + extern std::vector> environments; + + EntityHandleStruct getRoot() { return EntityStruct(0); } + + void constructEntityStruct(int id, void* memory) { + new (memory) EntityStruct(id); + } + + int EntityStruct::getId() { return entityId; } + + bool EntityHandleStruct::assertEntity(const char* funcName) { + if (!Scene::environment.entityExists(entityId)) { + DEER_EDITOR_ENGINE_ERROR( + "Error, invalid entity calling {0}, entityId : {1}", + funcName, entityId); + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + return false; + } + return true; + } + + std::string EntityStruct::getName() { + ASSERT_ENTITY("getName()", return "NULL"); + + return GET_ENTITY(environmentId, entityId) + .getComponent() + .tag; + } + + void EntityStruct::setName(std::string& name) { + ASSERT_ENTITY("setName()", return); + + GET_ENTITY(environmentId, entityId) + .getComponent() + .tag = name; + } + + void EntityStruct::destroy() { + ASSERT_ENTITY("destroy()", return); + + GET_ENTITY(environmentId, entityId).destroy(); + } + + bool EntityStruct::isRoot() { + ASSERT_ENTITY("isRoot()", return false); + + return entityId == 0; + } + + bool EntityStruct::exists() { + ASSERT_ENTITY("exists()", return false); + + return Scene::environment.entityExists(entityId); + } + + void EntityStruct::setParent(EntityHandleStruct parent_struct) { + ASSERT_ENTITY("setParent()", return); + + Entity& parent = + GET_ENTITY(parent_struct.environmentId, parent_struct.entityId); + + GET_ENTITY(environmentId, entityId).setParent(parent); + } + + EntityHandleStruct EntityStruct::getParent() { + ASSERT_ENTITY("getParent()", return *this); + + Entity& self = GET_ENTITY(environmentId, entityId); + if (self.isRoot()) + return *this; + + return EntityStruct(self.getParentId()); + } + + bool EntityStruct::isDescendantOf(EntityHandleStruct parent_struct) { + ASSERT_ENTITY("isDescendantOf()", return false); + + Entity& parent = + GET_ENTITY(parent_struct.environmentId, parent_struct.entityId); + + return GET_ENTITY(environmentId, entityId).isDescendantOf(parent); + } + + bool EntityStruct::opEquals(const EntityHandleStruct& other) { + ASSERT_ENTITY("opEquals()", return false); + + return entityId == other.entityId; + } + + EntityHandleStruct EntityStruct::getSelf() { + ASSERT_ENTITY("getSelf()", return *this); + + return *this; + } + + glm::vec3 TransformComponentStruct::getPosition() { + ASSERT_ENTITY("getPosition()", return glm::vec3()); + + return GET_ENTITY(environmentId, entityId) + .getComponent() + .position; + } + + glm::vec3 TransformComponentStruct::getScale() { + ASSERT_ENTITY("getScale()", return glm::vec3()); + + return GET_ENTITY(environmentId, entityId) + .getComponent() + .scale; + } + + glm::vec3 TransformComponentStruct::getRotation() { + ASSERT_ENTITY("getRotation()", return glm::vec3()); + + return GET_ENTITY(environmentId, entityId) + .getComponent() + .getEulerAngles(); + } + + void TransformComponentStruct::setPosition(glm::vec3 value) { + ASSERT_ENTITY("setPosition()", return); + + GET_ENTITY(environmentId, entityId) + .getComponent() + .position = value; + } + + void TransformComponentStruct::setScale(glm::vec3 value) { + ASSERT_ENTITY("setScale()", return); + + GET_ENTITY(environmentId, entityId) + .getComponent() + .scale = value; + } + + void TransformComponentStruct::setRotation(glm::vec3 value) { + ASSERT_ENTITY("setRotation()", return); + + GET_ENTITY(environmentId, entityId) + .getComponent() + .setEulerAngles(value); + } + + int EntityChildArrayStruct::getChildCount() { + ASSERT_ENTITY("getChildCount()", return 0); + + return GET_ENTITY(environmentId, entityId) + .getComponent() + .childCount; + } + + bool MeshComponentStruct::assertMeshComponent(const char* funcName) { + if (!assertEntity(funcName)) + return false; + Entity& ent = Scene::environment.getEntity(entityId); + + if (!ent.hasComponent()) { + DEER_EDITOR_ENGINE_ERROR( + "Error, calling MeshComponent.{0} entity {1} with id {2} " + "has no MeshComponent", + funcName, ent.getComponent().tag.c_str(), + entityId); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + return false; + } + + return true; + } + + EntityHandleStruct EntityChildArrayStruct::getChild(int i) { + ASSERT_ENTITY("getChild()", return *this); + + RelationshipComponent& rc = + GET_ENTITY(environmentId, entityId) + .getComponent(); + + if (i < 0 || i >= rc.childCount) { + DEER_EDITOR_ENGINE_ERROR( + "Error while executing EntityChild.getChild(..), id {0} is " + "invalid for child count of {1}", + i, rc.childCount); + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + + return EntityStruct(0); + } + + return EntityStruct(rc.getChildrenId(i)); + } + + EntityHandleStruct EntityStruct::createChild(std::string& name) { + ASSERT_ENTITY("createChild()", return *this); + + Entity& newEnt = Scene::environment.createEntity(name); + Entity& me = GET_ENTITY(environmentId, entityId); + + newEnt.setParent(me); + + return EntityStruct(newEnt.getId()); + } + + EntityHandleStruct EntityStruct::getMeshComponent() { + ASSERT_ENTITY("getMeshComponent()", return *this); + + Entity& self = GET_ENTITY(environmentId, entityId); + + if (!self.hasComponent()) { + DEER_CORE_ERROR( + "Error, entity {0} with id {1} does not have MeshComponent", + GET_ENTITY(environmentId, entityId) + .getComponent() + .tag.c_str(), + entityId); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + } + + return *this; + } + + EntityHandleStruct EntityStruct::createMeshComponent() { + ASSERT_ENTITY("createMeshComponent()", return *this); + + Entity& self = GET_ENTITY(environmentId, entityId); + + if (!self.hasComponent()) { + self.addComponent(); + } + + return *this; + } + + bool EntityStruct::hasMeshComponent() { + ASSERT_ENTITY("hasMeshComponent()", return false); + + Entity& self = GET_ENTITY(environmentId, entityId); + + return self.hasComponent(); + } + + void EntityStruct::removeMeshComponent() { + ASSERT_ENTITY("removeMeshComponent()", return); + + Entity& self = GET_ENTITY(environmentId, entityId); + + if (self.hasComponent()) { + self.removeComponent(); + } + } + + EntityHandleStruct EntityStruct::getCameraComponent() { + ASSERT_ENTITY("getCameraComponent()", return *this); + + Entity& self = GET_ENTITY(environmentId, entityId); + + if (!self.hasComponent()) { + DEER_CORE_ERROR("Error, entity {0} with id {1} does not have " + "Camera Component", + GET_ENTITY(environmentId, entityId) + .getComponent() + .tag.c_str(), + entityId); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + } + + return *this; + } + + EntityHandleStruct EntityStruct::createCameraComponent() { + ASSERT_ENTITY("createCameraComponent()", return *this); + + Entity& self = GET_ENTITY(environmentId, entityId); + + if (!self.hasComponent()) { + self.addComponent(); + } + + return *this; + } + + bool EntityStruct::hasCameraComponent() { + ASSERT_ENTITY("hasCameraComponent()", return false); + + Entity& self = GET_ENTITY(environmentId, entityId); + + return self.hasComponent(); + } + + void EntityStruct::removeCameraComponent() { + ASSERT_ENTITY("removeMeshComponent()", return); + + Entity& self = GET_ENTITY(environmentId, entityId); + + if (self.hasComponent()) { + self.removeComponent(); + } + } + + EntityHandleStruct EntityStruct::getShaderComponent() { + ASSERT_ENTITY("getShaderComponent()", return *this); + + Entity& self = GET_ENTITY(environmentId, entityId); + + if (!self.hasComponent()) { + DEER_CORE_ERROR("Error, entity {0} with id {1} does not have " + "Shader Component", + GET_ENTITY(environmentId, entityId) + .getComponent() + .tag.c_str(), + entityId); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + } + + return *this; + } + + EntityHandleStruct EntityStruct::createShaderComponent() { + ASSERT_ENTITY("createShaderComponent()", return *this); + + Entity& self = GET_ENTITY(environmentId, entityId); + + if (!self.hasComponent()) { + self.addComponent(); + } + + return *this; + } + + bool EntityStruct::hasShaderComponent() { + ASSERT_ENTITY("hasShaderComponent()", return false); + + Entity& self = GET_ENTITY(environmentId, entityId); + return self.hasComponent(); + } + + void EntityStruct::removeShaderComponent() { + ASSERT_ENTITY("removeShaderComponent()", return); + + Entity& self = GET_ENTITY(environmentId, entityId); + + if (self.hasComponent()) { + self.removeComponent(); + } + } + + bool MeshComponentStruct::isActive() { + ASSERT_MESH_COMPONENT("isActive()", return false); + return GET_MESH_COMPONENT(environmentId, entityId).isActive(); + } + + void MeshComponentStruct::setActive(bool value) { + ASSERT_MESH_COMPONENT("setActive(bool)", return); + + GET_MESH_COMPONENT(environmentId, entityId).setActive(value); + } + + bool MeshComponentStruct::hasMesh() { + ASSERT_MESH_COMPONENT("hasMesh()", return false); + + return GET_MESH_COMPONENT(environmentId, entityId).hasMesh(); + } + + void MeshComponentStruct::clear() { + ASSERT_MESH_COMPONENT("clear()", return); + + GET_MESH_COMPONENT(environmentId, entityId).clear(); + } + + std::string MeshComponentStruct::getMesh() { + ASSERT_MESH_COMPONENT("getMesh()", return "NULL"); + + return GET_MESH_COMPONENT(environmentId, entityId).getMeshName(); + } + + void MeshComponentStruct::setMesh(std::string& name) { + ASSERT_MESH_COMPONENT("setMesh()", return); + + uint16_t meshId = MeshManager::loadModel(name); + GET_MESH_COMPONENT(environmentId, entityId).setMesh(meshId); + } + + bool ShaderComponentStruct::hasShader() { + ASSERT_ENTITY("hasShader()", return false); + + return GET_SHADER_COMPONENT(environmentId, entityId).hasShader(); + } + + bool + ShaderComponentStruct::assertShaderComponent(const char* funcName) { + if (!assertEntity(funcName)) + return false; + Entity& ent = Scene::environment.getEntity(entityId); + + if (!ent.hasComponent()) { + DEER_EDITOR_ENGINE_ERROR( + "Error, calling ShaderComponent.{0} entity {1} with id {2} " + "has no ShaderComponent", + funcName, ent.getComponent().tag.c_str(), + entityId); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + return false; + } + + return true; + } + + void ShaderComponentStruct::clear() { + ASSERT_SHADER_COMPONENT("clear()", return); + + GET_SHADER_COMPONENT(environmentId, entityId).clear(); + } + + std::string ShaderComponentStruct::getShader() { + ASSERT_SHADER_COMPONENT("getShader()", return "NULL"); + + return GET_SHADER_COMPONENT(environmentId, entityId).getName(); + } + + void ShaderComponentStruct::setShader(std::string& name) { + ASSERT_SHADER_COMPONENT("getShader()", return); + + uint16_t shaderId = ShaderManager::loadShader(name); + GET_SHADER_COMPONENT(environmentId, entityId).setShader(shaderId); + } + + bool + CameraComponentStruct::assertCameraComponent(const char* funcName) { + if (!assertEntity(funcName)) + return false; + Entity& ent = Scene::environment.getEntity(entityId); + + if (!ent.hasComponent()) { + DEER_EDITOR_ENGINE_ERROR( + "Error, calling CameraComponent.{0} entity {1} with id {2} " + "has no CameraComponent", + funcName, ent.getComponent().tag.c_str(), + entityId); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + return false; + } + + return true; + } + + float CameraComponentStruct::getFov() { + ASSERT_CAMERA_COMPONENT("getFov()", return 0); + + return GET_CAMERA_COMPONENT(environmentId, entityId).fov / 3.141f * + 180.0f; + } + + float CameraComponentStruct::getAspectRation() { + ASSERT_CAMERA_COMPONENT("getAspectRation()", return 0); + + return GET_CAMERA_COMPONENT(environmentId, entityId).aspect; + } + + float CameraComponentStruct::getNearZ() { + ASSERT_CAMERA_COMPONENT("getNearZ()", return 0); + + return GET_CAMERA_COMPONENT(environmentId, entityId).nearZ; + } + + float CameraComponentStruct::getFarZ() { + ASSERT_CAMERA_COMPONENT("getFarZ()", return 0); + + return GET_CAMERA_COMPONENT(environmentId, entityId).farZ; + } + + void CameraComponentStruct::setFov(float v) { + ASSERT_CAMERA_COMPONENT("getFarZ()", return); + + GET_CAMERA_COMPONENT(environmentId, entityId).fov = + v * 3.141f / 180.0f; + } + void CameraComponentStruct::setAspectRation(float v) { + ASSERT_CAMERA_COMPONENT("setAspectRation()", return); + + GET_CAMERA_COMPONENT(environmentId, entityId).aspect = v; + } + void CameraComponentStruct::setNearZ(float v) { + ASSERT_CAMERA_COMPONENT("setNearZ()", return); + + GET_CAMERA_COMPONENT(environmentId, entityId).nearZ = v; + } + void CameraComponentStruct::setFarZ(float v) { + ASSERT_CAMERA_COMPONENT("setFarZ()", return); + + GET_CAMERA_COMPONENT(environmentId, entityId).farZ = v; + } + + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Environment.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Environment.cpp new file mode 100644 index 0000000..018fa82 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Environment.cpp @@ -0,0 +1,51 @@ +#include "Deer/Enviroment.h" +#include "Deer/Memory.h" +#include "Deer/Scene.h" + +#include "DeerStudio/StudioAPI/Environment.h" + +#include "DeerRender/FrameBuffer.h" +#include "DeerRender/SceneCamera.h" + +#include + +namespace Deer { + namespace EditorEngine { + // The first element has to allways point to the main scene env + std::vector environments{&Scene::environment}; + + void + EnvironmentStruct::render(FrameBufferHandleStruct frameBuffer_handle, + SceneCamera& sc) { + FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer( + frameBuffer_handle.frameBufferId); + Environment& env = *environments[environmentId]; + + frameBuffer.bind(); + + // TODO + env.render(sc); + + frameBuffer.unbind(); + } + + EntityHandleStruct EnvironmentStruct::getRootEntity() { + return EntityHandleStruct(0, environmentId); + } + + EntityHandleStruct EnvironmentStruct::getEntity(int id) { + return EntityHandleStruct(id, environmentId); + } + + EnvironmentHandleStruct getMainEnvironment() { + return EnvironmentHandleStruct(0); + } + + EnvironmentHandleStruct createEnvironment() { + uint16_t envId = environments.size(); + environments.push_back({}); + + return EnvironmentHandleStruct(envId); + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Implementation/FrameBuffer.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/FrameBuffer.cpp new file mode 100644 index 0000000..d3827ee --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/FrameBuffer.cpp @@ -0,0 +1,54 @@ +#include "DeerStudio/StudioAPI/FrameBuffer.h" +#include "DeerRender/FrameBuffer.h" + +namespace Deer { + namespace EditorEngine { + + int FrameBufferStruct::getWidth() { + return FrameBufferManager::getFrameBufferWidth(frameBufferId); + } + + int FrameBufferStruct::getHeight() { + return FrameBufferManager::getFrameBufferWidth(frameBufferId); + } + + void FrameBufferStruct::resize(int x, int y) { + FrameBufferManager::resizeFrameBuffer(frameBufferId, x, y); + } + + void FrameBufferStruct::clearRGBA(int r, int g, int b, int a) { + FrameBuffer& frameBuffer = + FrameBufferManager::getFrameBuffer(frameBufferId); + + frameBuffer.bind(); + frameBuffer.clear(); + uint8_t clearColor[4]{(uint8_t)r, (uint8_t)g, (uint8_t)b, + (uint8_t)a}; + frameBuffer.clearBuffer(0, &clearColor); + frameBuffer.unbind(); + } + + std::string FrameBufferStruct::getName() { + return FrameBufferManager::getFrameBufferName(frameBufferId); + } + + FrameBufferStruct createRGBA8FrameBuffer(std::string& name, int x, + int y) { + uint16_t id = + FrameBufferManager::createRGBA8FrameBuffer(name, x, y); + return FrameBufferStruct(id); + } + + void frameBuffer_constructor(FrameBufferHandleStruct* mem) { + new (mem) FrameBufferHandleStruct(0); + } + + bool FrameBufferStruct::isValid() { + return frameBufferId > 0 && frameBufferId < 100; + } + + FrameBufferStruct getFrameBuffer(std::string& name) { + return FrameBufferManager::getFrameBufferId(name); + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/IconManagment.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/IconManagment.cpp similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/IconManagment.cpp rename to DeerStudio/src/DeerStudio/StudioAPI_Implementation/IconManagment.cpp diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Layout.cpp similarity index 99% rename from DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp rename to DeerStudio/src/DeerStudio/StudioAPI_Implementation/Layout.cpp index bbb3957..8b54f6d 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Layout.cpp @@ -1,4 +1,4 @@ -#include "DeerStudio/EditorEngine/API/Layout.h" +#include "DeerStudio/StudioAPI/Layout.h" #include "DeerStudio/EditorEngine.h" #include "DeerStudio/EditorEngine/ErrorHandle.h" #include "angelscript.h" diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Math.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Math.cpp new file mode 100644 index 0000000..1f4a647 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Math.cpp @@ -0,0 +1,57 @@ +#include "DeerStudio/StudioAPI/Math.h" +#include "glm/glm.hpp" + +namespace Deer { + namespace EditorEngine { + void vec3_constructor(void* mem) { new (mem) glm::vec3(0, 0, 0); } + void vec3_constructor_params(float x, float y, float z, void* mem) { + new (mem) glm::vec3(x, y, z); + } + glm::vec3 vec3_add(glm::vec3& value, glm::vec3& self) { + return self + value; + } + glm::vec3 vec3_sub(const glm::vec3& value, glm::vec3& self) { + return self - value; + } + glm::vec3 vec3_neg(glm::vec3& self) { return -self; } + glm::vec3 vec3_mult(float value, glm::vec3& self) { + return self * value; + } + + void quat_construct(glm::quat* mem) { new (mem) glm::quat(); } + void quat_copyConstruct(glm::quat* data, glm::quat* mem) { + new (mem) glm::quat(*data); + } + void quat_destruct(glm::quat* mem) {} + void quat_constructFromValue(float x, float y, float z, float w, + glm::quat* mem) { + new (mem) glm::quat(x, y, z, w); + } + + glm::vec3 quat_getEuler(glm::quat* mem) { + return glm::degrees(glm::eulerAngles(*mem)); + } + void quat_setEuler(glm::vec3 euler, glm::quat* mem) { + new (mem) glm::quat(glm::radians(euler)); + } + glm::quat quat_multiply(glm::quat* data, glm::quat* mem) { + return *mem * *data; + } + + glm::vec3 transform_relative(glm::vec3 pos, + TransformComponent* transform) { + return transform->getMatrix() * glm::vec4(pos, 1.0f); + } + + void transform_construct(TransformComponent* mem) { + new (mem) TransformComponent(); + } + void camera_construct(CameraComponent* mem) { + new (mem) CameraComponent(); + } + void sceneCamera_Construct(SceneCamera* mem) { + new (mem) SceneCamera(); + } + + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Menu.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Menu.cpp new file mode 100644 index 0000000..b848960 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/Menu.cpp @@ -0,0 +1,170 @@ +#include "DeerStudio/StudioAPI/Menu.h" +#include "DeerStudio/DockPanel/DockPanelObject.h" +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "angelscript.h" +#include "imgui.h" +#include "scriptany.h" + +namespace Deer { + namespace EditorEngine { + namespace MenuContext { + CScriptAny* payload = nullptr; + std::string menuId; + } // namespace MenuContext + + void contextItemPopup(std::string& menu_id, CScriptAny* data, + asIScriptFunction* func) { + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); + if (ImGui::BeginPopupContextItem(menu_id.c_str())) { + + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { + + AS_CHECK(executingScriptContext->Prepare(func)); + + AS_CHECK(executingScriptContext->SetArgObject(0, data)); + + AS_CHECK(executingScriptContext->Execute()); + + executingScriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } + + ImGui::EndPopup(); + } + ImGui::PopStyleVar(); + } + + void contextMenuPopup(std::string& menu_id, CScriptAny* data, + asIScriptFunction* func) { + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); + if (ImGui::BeginPopupContextWindow(menu_id.c_str())) { + + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { + + AS_CHECK(executingScriptContext->Prepare(func)); + + AS_CHECK(executingScriptContext->SetArgObject(0, data)); + + AS_CHECK(executingScriptContext->Execute()); + + executingScriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } + + ImGui::EndPopup(); + } + ImGui::PopStyleVar(); + } + + void closePopup() { + if (MenuContext::payload) { + MenuContext::payload->Release(); + MenuContext::payload = nullptr; + } + + MenuContext::menuId = ""; + ImGui::CloseCurrentPopup(); + } + + void openPopup(std::string& menu_id, CScriptAny* data) { + if (MenuContext::payload) { + MenuContext::payload->Release(); + } + + data->AddRef(); + MenuContext::payload = data; + MenuContext::menuId = menu_id; + } + + void modalPopup(std::string& menu_id, asIScriptFunction* func) { + if (!ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup) && + MenuContext::menuId == menu_id) { + ImGui::OpenPopup(menu_id.c_str()); + MenuContext::menuId = ""; + } + + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); + if (ImGui::BeginPopupModal(menu_id.c_str())) { + // This should not happen + if (!MenuContext::payload) { + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + ImGui::PopStyleVar(); + + return; + } + + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { + AS_CHECK(executingScriptContext->Prepare(func)); + + AS_CHECK(executingScriptContext->SetArgObject( + 0, MenuContext::payload)); + + AS_CHECK(executingScriptContext->Execute()); + + executingScriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } + + ImGui::EndPopup(); + } + ImGui::PopStyleVar(); + } + + void simplePopup(std::string& menu_id, asIScriptFunction* func) { + if (!ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup)) { + if (MenuContext::menuId == menu_id) { + ImGui::OpenPopup(menu_id.c_str()); + MenuContext::menuId = ""; + + ImVec2 mouse_pos = ImGui::GetMousePos(); + ImVec2 popup_size = ImVec2(200, 0); + ImVec2 popup_pos = + ImVec2(mouse_pos.x - popup_size.x * 0.5f, mouse_pos.y); + ImGui::SetNextWindowSize(popup_size); + ImGui::SetNextWindowPos(popup_pos, ImGuiCond_Appearing); + + // In the case a payload is loaded we unload it + } else if (MenuContext::payload && MenuContext::menuId == "") { + MenuContext::payload->Release(); + MenuContext::payload = nullptr; + } + } + + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); + if (ImGui::BeginPopup(menu_id.c_str())) { + // This should not happen + if (!MenuContext::payload) { + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + ImGui::PopStyleVar(); + return; + } + + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { + AS_CHECK(executingScriptContext->Prepare(func)); + + AS_CHECK(executingScriptContext->SetArgObject( + 0, MenuContext::payload)); + + AS_CHECK(executingScriptContext->Execute()); + + executingScriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } + + ImGui::EndPopup(); + } + ImGui::PopStyleVar(); + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Implementation/UI.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/UI.cpp new file mode 100644 index 0000000..fad93d1 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Implementation/UI.cpp @@ -0,0 +1,486 @@ +#include "DeerStudio/StudioAPI/UI.h" +#include "Deer/Log.h" +#include "DeerRender/FrameBuffer.h" +#include "DeerStudio/DockPanel/DockPanelObject.h" +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" + +#include "DeerStudio/Fonts.h" +#include "angelscript.h" +#include "imgui.h" +#include "scriptany.h" + +#include + +namespace Deer { + namespace EditorEngine { + namespace DragDropPayload { + CScriptAny* payload; + } + + void separator() { ImGui::Separator(); } + + void title(std::string& txt) { + ImGui::PushFont(titleText); + ImGui::Text("%s", txt.c_str()); + ImGui::PopFont(); + } + + void titleEnd(std::string& txt) { + ImGui::PushFont(titleText); + textEnd(txt); + ImGui::PopFont(); + } + + void titleCenter(std::string& txt) { + ImGui::PushFont(titleText); + textCenter(txt); + ImGui::PopFont(); + } + + void titleCenterY(std::string& txt, int height) { + ImGui::PushFont(titleText); + + float textHeight = ImGui::GetFontSize(); + float yOffset = (height - textHeight) * 0.5f; + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + yOffset); + + ImGui::Text("%s", txt.c_str()); + ImGui::PopFont(); + } + + void sameline() { ImGui::SameLine(); } + + bool button(std::string& txt) { return ImGui::Button(txt.c_str()); } + + bool buttonCenter(std::string& txt) { + float sizeX; + if (ImGui::GetColumnsCount() > 1) + sizeX = ImGui::GetColumnWidth(-1); + else + sizeX = ImGui::GetContentRegionAvail().x; + + float textWidth = + ImGui::CalcTextSize(txt.c_str(), nullptr, false).x; + float padding = + (sizeX - textWidth - ImGui::GetStyle().FramePadding.x * 2) * + 0.5f; + + if (padding > 0.0f) + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); + + return ImGui::Button(txt.c_str()); + } + + bool buttonEnd(std::string& txt) { + float sizeX; + if (ImGui::GetColumnsCount() > 1) + sizeX = ImGui::GetColumnWidth(-1); + else + sizeX = ImGui::GetContentRegionAvail().x; + + float textWidth = + ImGui::CalcTextSize(txt.c_str(), nullptr, false).x; + float padding = + (sizeX - textWidth - ImGui::GetStyle().FramePadding.x * 2); + + if (padding > 0.0f) + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); + + return ImGui::Button(txt.c_str()); + } + + void textColor(float r, float g, float b, std::string& msg) { + ImGui::TextColored(ImVec4(r, g, b, 1.0f), "%s", msg.c_str()); + } + + void text(std::string& msg) { ImGui::Text("%s", msg.c_str()); } + + bool isPannelActive() { + return ImGui::IsWindowFocused( + ImGuiFocusedFlags_RootAndChildWindows); + } + + void textEnd(std::string& msg) { + float sizeX; + if (ImGui::GetColumnsCount() > 1) + sizeX = ImGui::GetColumnWidth(-1); + else + sizeX = ImGui::GetContentRegionAvail().x; + + float textWidth = + ImGui::CalcTextSize(msg.c_str(), nullptr, false).x; + float padding = (sizeX - textWidth); + + if (padding > 0.0f) + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); + + ImGui::Text("%s", msg.c_str()); + } + + void textCenter(std::string& msg) { + float sizeX; + if (ImGui::GetColumnsCount() > 1) + sizeX = ImGui::GetColumnWidth(-1); + else + sizeX = ImGui::GetContentRegionAvail().x; + + float textWidth = + ImGui::CalcTextSize(msg.c_str(), nullptr, false).x; + float padding = (sizeX - textWidth) * 0.5f; + + if (padding > 0.0f) + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); + + ImGui::Text("%s", msg.c_str()); + } + + void drawIcon(std::string& name, int size) { + int iconId = DataStore::getIconId(name); + + if (iconId < 0) { + DEER_EDITOR_ENGINE_ERROR("Invalid icon name {0}", name.c_str()); + if (currentDockPanelExecution) { + currentDockPanelExecution->invalidate(); + } + return; + } + + ImGui::Image((void*)(uint64_t)iconId, ImVec2(size, size), + ImVec2(0, 1), ImVec2(1, 0)); + } + + void drawFrameBuffer(FrameBufferHandleStruct frameBuffer_handle, + int sizeX, int sizeY) { + FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer( + frameBuffer_handle.frameBufferId); + frameBuffer.bind(); + int frameBufferId = frameBuffer.getTextureBufferID(0); + + ImGui::Image((void*)(uint64_t)frameBufferId, ImVec2(sizeX, sizeY), + ImVec2(0, 1), ImVec2(1, 0)); + frameBuffer.unbind(); + } + + void drawFrameBufferCentered(FrameBufferHandleStruct frameBuffer_handle, + int _x, int _y) { + FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer( + frameBuffer_handle.frameBufferId); + int frameBufferId = frameBuffer.getTextureBufferID(); + + float sizeX; + if (ImGui::GetColumnsCount() > 1) + sizeX = ImGui::GetColumnWidth(-1); + else + sizeX = ImGui::GetContentRegionAvail().x; + + float iconWidth = _x; + float padding = (sizeX - iconWidth) * 0.5f; + + if (padding > 0.0f) + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); + + ImGui::Image((void*)(uint64_t)frameBufferId, ImVec2(_x, _y), + ImVec2(0, 1), ImVec2(1, 0)); + } + + void drawIconCentered(std::string& name, int size) { + int iconId = DataStore::getIconId(name); + if (iconId < 0) { + DEER_EDITOR_ENGINE_ERROR("Invalid icon name {0}", name.c_str()); + if (currentDockPanelExecution) { + currentDockPanelExecution->invalidate(); + } + return; + } + + float sizeX; + if (ImGui::GetColumnsCount() > 1) + sizeX = ImGui::GetColumnWidth(-1); + else + sizeX = ImGui::GetContentRegionAvail().x; + + float iconWidth = size; + float padding = (sizeX - iconWidth) * 0.5f; + + if (padding > 0.0f) + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding); + + drawIcon(name, size); + } + + bool isItemClicked(int mouse) { return ImGui::IsItemClicked(mouse); } + + bool isMouseDoubleClicked(int mouse) { + return ImGui::IsMouseDoubleClicked(mouse); + } + + bool menuItem(std::string& txt) { return ImGui::MenuItem(txt.c_str()); } + + void menuSpace(std::string& txt, CScriptAny* data, + asIScriptFunction* func) { + if (ImGui::BeginMenu(txt.c_str())) { + + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { + + AS_CHECK(executingScriptContext->Prepare(func)); + + AS_CHECK(executingScriptContext->SetArgObject(0, data)); + + AS_CHECK(executingScriptContext->Execute()); + + executingScriptContext->PopState(); + } + + ImGui::EndMenu(); + } + } + + void menuItemDisabled(std::string& txt) { + ImGui::BeginDisabled(); + ImGui::MenuItem(txt.c_str()); + ImGui::EndDisabled(); + } + + void dragDropSource(std::string& id, CScriptAny* data, + std::string& debugText) { + if (DragDropPayload::payload && !ImGui::GetDragDropPayload()) { + DragDropPayload::payload->Release(); + DragDropPayload::payload = nullptr; + } + + data->AddRef(); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); + if (ImGui::BeginDragDropSource( + ImGuiDragDropFlags_SourceAllowNullID)) { + if (DragDropPayload::payload) + DragDropPayload::payload->Release(); + + DragDropPayload::payload = data; + + ImGui::SetDragDropPayload(id.c_str(), nullptr, 0); + ImGui::Text("%s", debugText.c_str()); + + ImGui::EndDragDropSource(); + } + ImGui::PopStyleVar(); + } + + void dragDropTarget(std::string& id, CScriptAny* data, + asIScriptFunction* func) { + if (ImGui::BeginDragDropTarget()) { + if (ImGui::AcceptDragDropPayload(id.c_str()) && + DragDropPayload::payload) { + + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { + + AS_CHECK(executingScriptContext->Prepare(func)); + + AS_CHECK(executingScriptContext->SetArgObject(0, data)); + + AS_CHECK(executingScriptContext->SetArgObject( + 1, DragDropPayload::payload)); + + AS_CHECK(executingScriptContext->Execute()); + + executingScriptContext->PopState(); + } + + DragDropPayload::payload->Release(); + DragDropPayload::payload = nullptr; + } + ImGui::EndDragDropTarget(); + } + } + + bool inputText(std::string& id, std::string& in, std::string& text) { + static char buffer[256]; + strncpy(buffer, in.c_str(), sizeof(buffer)); + buffer[sizeof(buffer) - 1] = '\0'; + + bool edited = ImGui::InputText(id.c_str(), buffer, sizeof(buffer)); + if (edited) { + text = buffer; + } + + return edited; + } + + bool checkbox(std::string& label, bool value) { + ImGui::Checkbox(label.c_str(), &value); + + return value; + } + + bool checkboxDisabled(std::string& label, bool value) { + ImGui::BeginDisabled(); + ImGui::Checkbox(label.c_str(), &value); + ImGui::EndDisabled(); + + return value; + } + + float magicSlider(std::string& txt, float value, float speed) { + + ImGui::PushID(txt.c_str()); + + static ImGuiID id = 0; + + float tmp = value; + bool value_changed = false; + + ImGui::Columns(2, nullptr, false); + + ImGui::Text("%s", txt.c_str()); + ImGui::SameLine(); + + ImGui::NextColumn(); + + if (id == ImGui::GetID(txt.c_str())) { + // — Input mode — + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputFloat("##input", &tmp, 0.0f, 0.0f, "%.2f", + ImGuiInputTextFlags_EnterReturnsTrue | + ImGuiInputTextFlags_AutoSelectAll)) { + value_changed = true; + id = 0; + } + // Cancel if click away or Esc + if (!ImGui::IsItemActive() && !ImGui::IsItemHovered()) { + value_changed = true; + id = 0; + } + } else { + // — Drag mode (unbounded) — + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + ImGui::DragFloat("##input", &tmp, speed, 0.0f, 0.0f, "%.2f"); + if (ImGui::IsItemActive()) + value_changed = true; + + // Click to enter edit mode + if (ImGui::IsItemHovered() && + ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { + id = ImGui::GetID(txt.c_str()); + ImGui::SetKeyboardFocusHere(0); + } + } + + ImGui::Columns(); + + if (value_changed) + value = tmp; + + ImGui::PopID(); + return value; + } + + glm::vec3 magicSlider3(std::string& txt, glm::vec3 value, float speed) { + static ImGuiID id = 0; + + glm::vec3 tmp = value; + bool value_changed = false; + + ImGui::Columns(4, nullptr, false); + + ImGui::PushID(txt.c_str()); + ImGui::Text("%s", txt.c_str()); + ImGui::NextColumn(); + + for (int i = 0; i < 3; i++) { + ImGui::PushID(i); + if (id == ImGui::GetID("##input")) { + // — Input mode — + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputFloat( + "##input", &tmp[i], 0.0f, 0.0f, "%.2f", + ImGuiInputTextFlags_EnterReturnsTrue | + ImGuiInputTextFlags_AutoSelectAll)) { + value_changed = true; + id = 0; + } + // Cancel if click away or Esc + if (!ImGui::IsItemActive() && !ImGui::IsItemHovered()) { + value_changed = true; + id = 0; + } + } else { + // — Drag mode (unbounded) — + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + ImGui::DragFloat("##input", &tmp[i], speed, 0.0f, 0.0f, + "%.2f"); + if (ImGui::IsItemActive()) + value_changed = true; + + // Click to enter edit mode + if (ImGui::IsItemHovered() && + ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { + id = ImGui::GetID("##input"); + ImGui::SetKeyboardFocusHere(-1); + } + } + ImGui::PopID(); + ImGui::NextColumn(); + } + ImGui::Columns(); + ImGui::PopID(); + + if (value_changed) + value = tmp; + + return value; + } + + bool isKeyDown(int key) { return ImGui::IsKeyDown((ImGuiKey)key); } + + bool isKeyPressed(int key) { + return ImGui::IsKeyPressed((ImGuiKey)key, false); + } + + bool isMouseDraggin(int key) { + if (key == ImGuiKey_MouseRight) + return ImGui::IsMouseDragging(ImGuiMouseButton_Right); + else if (key == ImGuiKey_MouseLeft) + return ImGui::IsMouseDragging(ImGuiMouseButton_Left); + else if (key == ImGuiKey_MouseMiddle) + return ImGui::IsMouseDragging(ImGuiMouseButton_Middle); + return false; + } + + float slider(std::string& label, float value, float min, float max) { + ImGui::SliderFloat(label.c_str(), &value, min, max); + return value; + } + + int sliderInt(std::string& label, int value, int min, int max) { + ImGui::SliderInt(label.c_str(), &value, min, max); + return value; + } + + float getMouseDeltaX() { + ImGuiIO& io = ImGui::GetIO(); + return io.MouseDelta.x; + } + + float getMouseDeltaY() { + ImGuiIO& io = ImGui::GetIO(); + return io.MouseDelta.y; + } + + float getMouseDragDeltaX() { return ImGui::GetMouseDragDelta().x; } + + float getMouseDragDeltaY() { return ImGui::GetMouseDragDelta().y; } + + int getAvailableSizeX() { return ImGui::GetContentRegionAvail().x; } + + int getAvailableSizeY() { return ImGui::GetContentRegionAvail().y; } + + void disablePannelPadding(bool value) { + if (currentDockPanelExecution) { + currentDockPanelExecution->setFlag(DockPannelFlag_PannelPadding, + value); + } + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/API_Registration.h b/DeerStudio/src/DeerStudio/StudioAPI_Registration/API_Registration.h similarity index 100% rename from DeerStudio/src/DeerStudio/EditorEngine/API_Registration/API_Registration.h rename to DeerStudio/src/DeerStudio/StudioAPI_Registration/API_Registration.h diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Registration/Engine_Register.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Registration/Engine_Register.cpp new file mode 100644 index 0000000..cfa0d7d --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Registration/Engine_Register.cpp @@ -0,0 +1,25 @@ +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/API.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "DeerStudio/StudioAPI/Engine.h" +#include "DeerStudio/StudioAPI_Registration/API_Registration.h" + +#include "angelscript.h" +#include "scriptany.h" +#include "scripthandle.h" + +namespace Deer { + namespace EditorEngine { + void registerEngineFunctions() { + + scriptEngine->SetDefaultNamespace("Engine"); + REGISTER_GLOBAL_FUNC("void print(const string&in text)", print); + REGISTER_GLOBAL_FUNC("string getParentPath(const string&in path)", getParentPath); + REGISTER_GLOBAL_FUNC("string getParentPathName(const string&in path)", getParentPathName); + REGISTER_GLOBAL_FUNC("array@ dividePath(const string&in path)", dividePath); + + scriptEngine->SetDefaultNamespace(""); + } + + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Registration/Entity_Register.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Registration/Entity_Register.cpp new file mode 100644 index 0000000..83f0682 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Registration/Entity_Register.cpp @@ -0,0 +1,214 @@ +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/API.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "DeerStudio/StudioAPI_Registration/API_Registration.h" + +#include "angelscript.h" +#include "scriptany.h" +#include "scripthandle.h" + +namespace Deer { + namespace EditorEngine { + void registerTransformComponentFunctions(); + void registerMeshComponentFunction(); + void registerShaderComponentFunctions(); + void registerComponentComponentFunctions(); + + void registerEntityStructs() { + AS_CHECK(scriptEngine->RegisterObjectType( + "Entity", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | + asGetTypeTraits() | + asOBJ_APP_CLASS_ALLINTS)); + + AS_CHECK(scriptEngine->RegisterObjectType( + "EntityChilds", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | + asGetTypeTraits() | + asOBJ_APP_CLASS_ALLINTS)); + + AS_CHECK(scriptEngine->RegisterObjectType( + "TransformComponent", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | + asGetTypeTraits() | + asOBJ_APP_CLASS_ALLINTS)); + + AS_CHECK(scriptEngine->RegisterObjectType( + "MeshComponent", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | + asGetTypeTraits() | + asOBJ_APP_CLASS_ALLINTS)); + + AS_CHECK(scriptEngine->RegisterObjectType( + "ShaderComponent", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | + asGetTypeTraits() | + asOBJ_APP_CLASS_ALLINTS)); + + AS_CHECK(scriptEngine->RegisterObjectType( + "CameraComponent", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | + asGetTypeTraits() | + asOBJ_APP_CLASS_ALLINTS)); + } + + void registerEntityFunctions() { + registerTransformComponentFunctions(); + registerMeshComponentFunction(); + registerShaderComponentFunctions(); + registerComponentComponentFunctions(); + + REGISTER_OBJECT_METHOD("Entity", "string get_name() const property", + EntityStruct, getName); + REGISTER_OBJECT_METHOD("Entity", + "void set_name(string& in) property", + EntityStruct, setName); + REGISTER_OBJECT_METHOD("Entity", "int get_id() const property", + EntityStruct, getId); + REGISTER_OBJECT_METHOD("Entity", + "Entity createChild(const string& in)", + EntityStruct, createChild); + REGISTER_OBJECT_METHOD("Entity", "bool get_isRoot() const property", + EntityStruct, isRoot); + REGISTER_OBJECT_METHOD("Entity", "void destroy()", EntityStruct, + destroy); + REGISTER_OBJECT_METHOD("Entity", "bool get_exists() const property", + EntityStruct, exists); + REGISTER_OBJECT_METHOD("Entity", "Entity get_parent() property", + EntityStruct, getParent); + REGISTER_OBJECT_METHOD("Entity", "void set_parent(Entity) property", + EntityStruct, setParent); + REGISTER_OBJECT_METHOD("Entity", "bool isDescendantOf(Entity)", + EntityStruct, isDescendantOf); + REGISTER_OBJECT_METHOD("Entity", + "bool opEquals(const Entity &in) const", + EntityStruct, opEquals); + REGISTER_OBJECT_METHOD("Entity", + "EntityChilds get_childs() const property", + EntityStruct, getSelf); + REGISTER_OBJECT_METHOD( + "Entity", "TransformComponent get_transform() const property", + EntityStruct, getSelf); + REGISTER_OBJECT_METHOD("Entity", "MeshComponent getMeshComponent()", + EntityStruct, getMeshComponent); + REGISTER_OBJECT_METHOD("Entity", + "MeshComponent createMeshComponent()", + EntityStruct, createMeshComponent); + REGISTER_OBJECT_METHOD("Entity", "bool hasMeshComponent()", + EntityStruct, hasMeshComponent); + REGISTER_OBJECT_METHOD("Entity", "void removeMeshComponent()", + EntityStruct, removeMeshComponent); + REGISTER_OBJECT_METHOD("Entity", + "ShaderComponent getShaderComponent()", + EntityStruct, getShaderComponent); + REGISTER_OBJECT_METHOD("Entity", + "ShaderComponent createShaderComponent()", + EntityStruct, createShaderComponent); + REGISTER_OBJECT_METHOD("Entity", "bool hasShaderComponent()", + EntityStruct, hasShaderComponent); + REGISTER_OBJECT_METHOD("Entity", "void removeShaderComponent()", + EntityStruct, removeShaderComponent); + REGISTER_OBJECT_METHOD("Entity", + "CameraComponent getCameraComponent()", + EntityStruct, getCameraComponent); + REGISTER_OBJECT_METHOD("Entity", + "CameraComponent createCameraComponent()", + EntityStruct, createCameraComponent); + REGISTER_OBJECT_METHOD("Entity", "bool hasCameraComponent()", + EntityStruct, hasCameraComponent); + REGISTER_OBJECT_METHOD("Entity", "void removeCameraComponent()", + EntityStruct, removeCameraComponent); + + scriptEngine->SetDefaultNamespace("Engine"); + REGISTER_GLOBAL_FUNC("Entity getRoot()", getRoot); + scriptEngine->SetDefaultNamespace(""); + + REGISTER_OBJECT_METHOD("EntityChilds", + "int get_count() const property", + EntityChildArrayStruct, getChildCount); + REGISTER_OBJECT_METHOD("EntityChilds", "Entity opIndex(int) const", + EntityChildArrayStruct, getChild); + } + + void registerMeshComponentFunction() { + REGISTER_OBJECT_METHOD("MeshComponent", + "bool get_isActive() const property", + MeshComponentStruct, isActive); + REGISTER_OBJECT_METHOD("MeshComponent", + "bool get_hasMesh() const property", + MeshComponentStruct, hasMesh); + REGISTER_OBJECT_METHOD("MeshComponent", "void clear()", + MeshComponentStruct, clear); + REGISTER_OBJECT_METHOD("MeshComponent", "string getMesh()", + MeshComponentStruct, getMesh); + REGISTER_OBJECT_METHOD("MeshComponent", "void setMesh(string&in)", + MeshComponentStruct, setMesh); + REGISTER_OBJECT_METHOD("MeshComponent", + "void set_isActive(const bool) property", + MeshComponentStruct, setActive); + } + + void registerTransformComponentFunctions() { + REGISTER_OBJECT_METHOD("TransformComponent", + "vec3 get_position() const property", + TransformComponentStruct, getPosition); + REGISTER_OBJECT_METHOD("TransformComponent", + "vec3 get_scale() const property", + TransformComponentStruct, getScale); + REGISTER_OBJECT_METHOD("TransformComponent", + "vec3 get_rotation() const property", + TransformComponentStruct, getRotation); + + REGISTER_OBJECT_METHOD("TransformComponent", + "void set_position(const vec3) property", + TransformComponentStruct, setPosition); + REGISTER_OBJECT_METHOD("TransformComponent", + "void set_scale(const vec3) property", + TransformComponentStruct, setScale); + REGISTER_OBJECT_METHOD("TransformComponent", + "void set_rotation(const vec3) property", + TransformComponentStruct, setRotation); + } + + void registerShaderComponentFunctions() { + REGISTER_OBJECT_METHOD("ShaderComponent", + "bool get_hasShader() const property", + ShaderComponentStruct, hasShader); + REGISTER_OBJECT_METHOD("ShaderComponent", "void clear()", + ShaderComponentStruct, clear); + REGISTER_OBJECT_METHOD("ShaderComponent", "string getShader()", + ShaderComponentStruct, getShader); + REGISTER_OBJECT_METHOD("ShaderComponent", + "void setShader(const string& in)", + ShaderComponentStruct, setShader); + } + + void registerComponentComponentFunctions() { + REGISTER_OBJECT_METHOD("CameraComponent", + "float get_fov() const property", + CameraComponentStruct, getFov); + REGISTER_OBJECT_METHOD("CameraComponent", + "float get_aspectRatio() const property", + CameraComponentStruct, getAspectRation); + REGISTER_OBJECT_METHOD("CameraComponent", + "float get_nearZ() const property", + CameraComponentStruct, getNearZ); + REGISTER_OBJECT_METHOD("CameraComponent", + "float get_farZ() const property", + CameraComponentStruct, getFarZ); + + REGISTER_OBJECT_METHOD("CameraComponent", + "void set_fov(float) property", + CameraComponentStruct, setFov); + REGISTER_OBJECT_METHOD("CameraComponent", + "void set_aspectRatio(float) property", + CameraComponentStruct, setAspectRation); + REGISTER_OBJECT_METHOD("CameraComponent", + "void set_nearZ(float) property", + CameraComponentStruct, setNearZ); + REGISTER_OBJECT_METHOD("CameraComponent", + "void set_farZ(float) property", + CameraComponentStruct, setFarZ); + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Registration/Environment_Register.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Registration/Environment_Register.cpp new file mode 100644 index 0000000..7def046 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Registration/Environment_Register.cpp @@ -0,0 +1,37 @@ +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "DeerStudio/StudioAPI/Environment.h" +#include "DeerStudio/StudioAPI_Registration/API_Registration.h" + +#include "angelscript.h" + +namespace Deer { + namespace EditorEngine { + void registerEnvironmentStructs(); + void registerEnvironmentFunctions(); + + void registerEnvironmentStructs() { + AS_CHECK(scriptEngine->RegisterObjectType( + "Environment", sizeof(EnvironmentStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | + asOBJ_APP_CLASS_ALLINTS)); + } + + void registerEnvironmentFunctions() { + scriptEngine->SetDefaultNamespace("Engine"); + REGISTER_GLOBAL_FUNC("Environment getMainEnvironment()", + getMainEnvironment); + REGISTER_GLOBAL_FUNC("Environment createEnvironment()", + createEnvironment); + scriptEngine->SetDefaultNamespace(""); + + REGISTER_OBJECT_METHOD("Environment", + "void render(FrameBuffer, SceneCamera&in)", + EnvironmentStruct, render); + REGISTER_OBJECT_METHOD("Environment", "Entity getRootEntity()", + EnvironmentStruct, getRootEntity); + REGISTER_OBJECT_METHOD("Environment", "Entity getEntity(int)", + EnvironmentStruct, getEntity); + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Registration/FrameBuffer_Register.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Registration/FrameBuffer_Register.cpp new file mode 100644 index 0000000..a1e9200 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Registration/FrameBuffer_Register.cpp @@ -0,0 +1,42 @@ +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "DeerStudio/StudioAPI/FrameBuffer.h" +#include "DeerStudio/StudioAPI_Registration/API_Registration.h" +#include "angelscript.h" + +namespace Deer { + namespace EditorEngine { + void registerFrameBufferStructs() { + AS_CHECK(scriptEngine->RegisterObjectType( + "FrameBuffer", sizeof(FrameBufferStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | + asOBJ_APP_CLASS_ALLINTS)); + } + + void registerFrameBufferFunctions() { + REGISTER_OBJECT_METHOD("FrameBuffer", + "void clearRGBA(int, int, int, int)", + FrameBufferStruct, clearRGBA); + REGISTER_OBJECT_METHOD("FrameBuffer", + "int get_height() const property", + FrameBufferStruct, getHeight); + REGISTER_OBJECT_METHOD("FrameBuffer", "void resize(int, int)", + FrameBufferStruct, resize); + REGISTER_OBJECT_METHOD("FrameBuffer", + "string get_name() const property", + FrameBufferStruct, getName); + REGISTER_OBJECT_METHOD("FrameBuffer", "bool isValid()", + FrameBufferStruct, isValid); + REGISTER_EXT_OBJECT_CONSTRUCTOR("FrameBuffer", "void f()", + frameBuffer_constructor); + + scriptEngine->SetDefaultNamespace("Engine"); + REGISTER_GLOBAL_FUNC( + "FrameBuffer createRGBA8FrameBuffer(const string&in, int, int)", + createRGBA8FrameBuffer); + REGISTER_GLOBAL_FUNC("FrameBuffer getFrameBuffer(const string&in)", + getFrameBuffer); + scriptEngine->SetDefaultNamespace(""); + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Registration/Math_Register.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Registration/Math_Register.cpp new file mode 100644 index 0000000..0f90b1e --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Registration/Math_Register.cpp @@ -0,0 +1,122 @@ +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/API.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "DeerStudio/StudioAPI_Registration/API_Registration.h" + +#include "angelscript.h" +#include "glm/glm.hpp" +#include "scriptany.h" +#include "scripthandle.h" + +namespace Deer { + namespace EditorEngine { + void registerMathStructs() { + AS_CHECK(scriptEngine->RegisterObjectType( + "vec3", sizeof(glm::vec3), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | + asOBJ_APP_CLASS_ALLFLOATS)); + + AS_CHECK(scriptEngine->RegisterObjectBehaviour( + "vec3", asBEHAVE_CONSTRUCT, "void f()", + asFUNCTION(vec3_constructor), asCALL_CDECL_OBJLAST)); + + AS_CHECK(scriptEngine->RegisterObjectBehaviour( + "vec3", asBEHAVE_CONSTRUCT, + "void f(float, float = 0, float = 0)", + asFUNCTION(vec3_constructor_params), asCALL_CDECL_OBJLAST)); + + AS_CHECK(scriptEngine->RegisterObjectProperty( + "vec3", "float x", asOFFSET(glm::vec3, x))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "vec3", "float y", asOFFSET(glm::vec3, y))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "vec3", "float z", asOFFSET(glm::vec3, z))); + + AS_CHECK(scriptEngine->RegisterObjectType( + "quat", sizeof(glm::quat), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | + asOBJ_APP_CLASS_ALLFLOATS)); + + AS_CHECK(scriptEngine->RegisterObjectProperty( + "quat", "float x", asOFFSET(glm::quat, x))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "quat", "float y", asOFFSET(glm::quat, y))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "quat", "float z", asOFFSET(glm::quat, z))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "quat", "float w", asOFFSET(glm::quat, w))); + + AS_CHECK(scriptEngine->RegisterObjectType( + "Transform", sizeof(TransformComponent), + asOBJ_VALUE | asOBJ_POD | + asGetTypeTraits())); + + AS_CHECK(scriptEngine->RegisterObjectProperty( + "Transform", "vec3 position", + asOFFSET(TransformComponent, position))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "Transform", "vec3 scale", + asOFFSET(TransformComponent, scale))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "Transform", "quat rotation", + asOFFSET(TransformComponent, rotation))); + + AS_CHECK(scriptEngine->RegisterObjectType( + "Camera", sizeof(CameraComponent), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits())); + + AS_CHECK(scriptEngine->RegisterObjectProperty( + "Camera", "float fov", asOFFSET(CameraComponent, fov))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "Camera", "float aspect", asOFFSET(CameraComponent, aspect))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "Camera", "float nearZ", asOFFSET(CameraComponent, nearZ))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "Camera", "float farZ", asOFFSET(CameraComponent, farZ))); + + AS_CHECK(scriptEngine->RegisterObjectType( + "SceneCamera", sizeof(SceneCamera), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits())); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "SceneCamera", "Camera camera", asOFFSET(SceneCamera, camera))); + AS_CHECK(scriptEngine->RegisterObjectProperty( + "SceneCamera", "Transform transform", + asOFFSET(SceneCamera, transform))); + } + + void registerMathFunctions() { + REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opAdd(const vec3 &in)", + vec3_add); + REGISTER_EXT_OBJECT_METHOD( + "vec3", "vec3 opSub(const vec3 &in) const", vec3_sub); + REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opNeg() const", vec3_neg); + REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opMul(float) const", + vec3_mult); + REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opMul_r(float) const", + vec3_mult); + + REGISTER_EXT_OBJECT_CONSTRUCTOR("quat", "void f()", quat_construct); + REGISTER_EXT_OBJECT_CONSTRUCTOR( + "quat", "void f(float, float, float, float)", + quat_constructFromValue); + REGISTER_EXT_OBJECT_DESTRUCTOR("quat", "void f()", quat_destruct); + + REGISTER_EXT_OBJECT_METHOD( + "quat", "quat opMul(const quat &in) const", quat_multiply); + REGISTER_EXT_OBJECT_METHOD("quat", "vec3 getEuler() const", + quat_getEuler); + REGISTER_EXT_OBJECT_METHOD("quat", "void setEuler(vec3)", + quat_setEuler); + + REGISTER_EXT_OBJECT_CONSTRUCTOR("Transform", "void f()", + transform_construct); + REGISTER_EXT_OBJECT_CONSTRUCTOR("Camera", "void f()", + camera_construct); + REGISTER_EXT_OBJECT_CONSTRUCTOR("SceneCamera", "void f()", + sceneCamera_Construct); + + REGISTER_EXT_OBJECT_METHOD("Transform", "vec3 relative(vec3)", + transform_relative); + } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Registration/RegisterFunctions.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Registration/RegisterFunctions.cpp new file mode 100644 index 0000000..6da7592 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Registration/RegisterFunctions.cpp @@ -0,0 +1,48 @@ +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/API.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "DeerStudio/StudioAPI_Registration/API_Registration.h" + +#include "angelscript.h" + +namespace Deer { + void EditorEngine::registerEditorEngineFunctions() { + registerEntityFunctions(); + registerMathFunctions(); + registerUIFunctions(); + registerFrameBufferFunctions(); + registerEnvironmentFunctions(); + registerEngineFunctions(); + + scriptEngine->SetDefaultNamespace("UI"); + REGISTER_GLOBAL_FUNC("void setupAutomaticColumns(int)", setupAutomaticColumns); + REGISTER_GLOBAL_FUNC("void setupColumns(int)", setupColumns); + REGISTER_GLOBAL_FUNC("void endColumns()", endColumns); + REGISTER_GLOBAL_FUNC("void nextColumn()", nextColumn); + scriptEngine->SetDefaultNamespace(""); + + scriptEngine->SetDefaultNamespace("Assets"); + REGISTER_GLOBAL_FUNC("int getAssetCount(AssetType, const string& in)", getAssetCount); + REGISTER_GLOBAL_FUNC("string getAssetNameById(AssetType, const string& in, int)", getAssetNameById); + REGISTER_GLOBAL_FUNC("string getAssetTypePathById(AssetType, const string& in, int)", getAssetTypePathById); + REGISTER_GLOBAL_FUNC("int getDirCount(AssetType, const string& in)", getDirCount); + REGISTER_GLOBAL_FUNC("string getDirPathById(AssetType, const string& in, int)", getDirPathById); + REGISTER_GLOBAL_FUNC("string getDirNameById(AssetType, const string& in, int)", getDirNameById); + scriptEngine->SetDefaultNamespace(""); + + scriptEngine->SetDefaultNamespace("UI"); + REGISTER_GLOBAL_FUNC("void treeNodeLeaf(const string& in, bool)", treeNode); + REGISTER_GLOBAL_FUNC("bool treeNode(const string& in, bool, any@+, ReciverFunc@+)", treeNodeRecursive); + REGISTER_GLOBAL_FUNC("bool componentNode(const string& in, any@+, ReciverFunc@+)", componentNode); + REGISTER_GLOBAL_FUNC("bool componentNode_contextMenu(const string& in, any@+, ReciverFunc@+, ReciverFunc@+)", componentNode_contextMenu); + REGISTER_GLOBAL_FUNC("void contextItemPopup(const string& in, any@+, ReciverFunc@+)", contextItemPopup); + REGISTER_GLOBAL_FUNC("void contextMenuPopup(const string& in, any@+, ReciverFunc@+)", contextMenuPopup); + REGISTER_GLOBAL_FUNC("void modalPopup(const string& in, ReciverFunc@+)", modalPopup); + REGISTER_GLOBAL_FUNC("void simplePopup(const string& in, ReciverFunc@+)", simplePopup); + REGISTER_GLOBAL_FUNC("void openPopup(const string& in, any@)", openPopup); + REGISTER_GLOBAL_FUNC("void closePopup()", closePopup); + REGISTER_GLOBAL_FUNC("void dragDropSource(const string& in, any@, const string& in)", dragDropSource); + REGISTER_GLOBAL_FUNC("void dragDropTarget(const string& in, any@+, TransferFunc@+)", dragDropTarget); + scriptEngine->SetDefaultNamespace(""); + } +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/RegisterStructs.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Registration/RegisterStructs.cpp similarity index 73% rename from DeerStudio/src/DeerStudio/EditorEngine/API_Registration/RegisterStructs.cpp rename to DeerStudio/src/DeerStudio/StudioAPI_Registration/RegisterStructs.cpp index 38246ed..2b6c76a 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Registration/RegisterStructs.cpp +++ b/DeerStudio/src/DeerStudio/StudioAPI_Registration/RegisterStructs.cpp @@ -10,12 +10,9 @@ namespace Deer { namespace EditorEngine { void registerAssetTypeEnum() { AS_RET_CHECK(scriptEngine->RegisterEnum("AssetType")); - AS_CHECK(scriptEngine->RegisterEnumValue("AssetType", "None", - (int)AssetType::NONE)); - AS_CHECK(scriptEngine->RegisterEnumValue("AssetType", "Shader", - (int)AssetType::SHADER)); - AS_CHECK(scriptEngine->RegisterEnumValue("AssetType", "Mesh", - (int)AssetType::MESH)); + AS_CHECK(scriptEngine->RegisterEnumValue("AssetType", "None", (int)AssetType::NONE)); + AS_CHECK(scriptEngine->RegisterEnumValue("AssetType", "Shader", (int)AssetType::SHADER)); + AS_CHECK(scriptEngine->RegisterEnumValue("AssetType", "Mesh", (int)AssetType::MESH)); } void registerEditorEngineStructs() { @@ -23,14 +20,12 @@ namespace Deer { RegisterScriptAny(scriptEngine); AS_RET_CHECK(scriptEngine->RegisterInterface("DockPanel")); - AS_RET_CHECK(scriptEngine->RegisterInterfaceMethod( - "DockPanel", "void onRender()")); + AS_RET_CHECK(scriptEngine->RegisterInterfaceMethod("DockPanel", "void onRender()")); AS_RET_CHECK(scriptEngine->RegisterInterface("ServiceScript")); AS_CHECK(scriptEngine->RegisterFuncdef("void ReciverFunc(any@)")); - AS_CHECK( - scriptEngine->RegisterFuncdef("void TransferFunc(any@, any@)")); + AS_CHECK(scriptEngine->RegisterFuncdef("void TransferFunc(any@, any@)")); registerUIStructs(); registerAssetTypeEnum(); diff --git a/DeerStudio/src/DeerStudio/StudioAPI_Registration/UI_Register.cpp b/DeerStudio/src/DeerStudio/StudioAPI_Registration/UI_Register.cpp new file mode 100644 index 0000000..0865ee6 --- /dev/null +++ b/DeerStudio/src/DeerStudio/StudioAPI_Registration/UI_Register.cpp @@ -0,0 +1,317 @@ +#include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/API.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "DeerStudio/StudioAPI_Registration/API_Registration.h" + +#include "angelscript.h" +#include "imgui.h" +#include "scriptany.h" +#include "scripthandle.h" + +namespace Deer { + void EditorEngine::registerUIFunctions() { + + scriptEngine->SetDefaultNamespace("UI"); + REGISTER_GLOBAL_FUNC("bool button(const string& in)", button); + REGISTER_GLOBAL_FUNC("bool buttonCenter(const string&in)", + buttonCenter); + REGISTER_GLOBAL_FUNC("bool buttonEnd(const string&in)", buttonEnd); + REGISTER_GLOBAL_FUNC("bool checkbox(const string& in, bool)", checkbox); + REGISTER_GLOBAL_FUNC("bool checkboxDisabled(const string& in, bool)", + checkboxDisabled); + REGISTER_GLOBAL_FUNC("void drawFrameBuffer(FrameBuffer, int, int)", + drawFrameBuffer); + REGISTER_GLOBAL_FUNC( + "void drawFrameBufferCentered(FrameBuffer, int, int)", + drawFrameBufferCentered); + REGISTER_GLOBAL_FUNC("void drawIcon(const string& in, int)", drawIcon); + REGISTER_GLOBAL_FUNC("void drawIconCentered(const string& in, int)", + drawIconCentered); + REGISTER_GLOBAL_FUNC( + "bool inputText(const string& in, const string& in, string& out)", + inputText); + REGISTER_GLOBAL_FUNC("bool isItemClicked(int)", isItemClicked); + REGISTER_GLOBAL_FUNC("bool isMouseDoubleClicked(int)", + isMouseDoubleClicked); + REGISTER_GLOBAL_FUNC( + "float magicSlider(const string& in, float, float)", magicSlider); + REGISTER_GLOBAL_FUNC("vec3 magicSlider3(const string& in, vec3, float)", + magicSlider3); + REGISTER_GLOBAL_FUNC("bool menuItem(const string& in)", menuItem); + REGISTER_GLOBAL_FUNC("void menuItemDisabled(const string& in)", + menuItemDisabled); + REGISTER_GLOBAL_FUNC( + "void menuSpace(const string& in, any@+, ReciverFunc@+)", + menuSpace); + REGISTER_GLOBAL_FUNC("void sameline()", sameline); + REGISTER_GLOBAL_FUNC("void separator()", separator); + REGISTER_GLOBAL_FUNC("void space()", space); + REGISTER_GLOBAL_FUNC("void space(int, int = 10)", space_params); + REGISTER_GLOBAL_FUNC("void text(const string& in)", text); + REGISTER_GLOBAL_FUNC("void textCenter(const string& in)", textCenter); + REGISTER_GLOBAL_FUNC( + "void textColor(float, float, float, const string& in)", textColor); + REGISTER_GLOBAL_FUNC("void textEnd(const string& in)", textEnd); + REGISTER_GLOBAL_FUNC("void title(const string&in)", title); + REGISTER_GLOBAL_FUNC("void titleCenter(const string&in)", titleCenter); + REGISTER_GLOBAL_FUNC("void titleCenterY(const string&in, int)", + titleCenterY); + REGISTER_GLOBAL_FUNC("void titleEnd(const string&in)", titleEnd); + REGISTER_GLOBAL_FUNC("bool isKeyDown(key)", isKeyDown); + REGISTER_GLOBAL_FUNC("bool isKeyPressed(key)", isKeyPressed); + REGISTER_GLOBAL_FUNC("bool isMouseDraggin(key)", isMouseDraggin); + REGISTER_GLOBAL_FUNC("bool isPannelActive()", isPannelActive); + REGISTER_GLOBAL_FUNC("float getMouseDragDeltaX()", getMouseDragDeltaX); + REGISTER_GLOBAL_FUNC("float getMouseDragDeltaY()", getMouseDragDeltaY); + REGISTER_GLOBAL_FUNC("float getMouseDeltaX()", getMouseDeltaX); + REGISTER_GLOBAL_FUNC("float getMouseDeltaY()", getMouseDeltaY); + REGISTER_GLOBAL_FUNC("int getAvailableSizeX()", getAvailableSizeX); + REGISTER_GLOBAL_FUNC("int getAvailableSizeY()", getAvailableSizeY); + REGISTER_GLOBAL_FUNC("void disablePannelPadding(bool)", + disablePannelPadding); + REGISTER_GLOBAL_FUNC("int sliderInt(string&in, int, int, int)", + sliderInt); + REGISTER_GLOBAL_FUNC("float slider(string&in, float, float, float)", + slider); + scriptEngine->SetDefaultNamespace(""); + } + + void EditorEngine::registerUIStructs() { + AS_CHECK(scriptEngine->RegisterEnum("key")); + + AS_CHECK(scriptEngine->RegisterEnumValue("key", "A", ImGuiKey_A)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "B", ImGuiKey_B)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "C", ImGuiKey_C)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "D", ImGuiKey_D)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "E", ImGuiKey_E)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "F", ImGuiKey_F)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "G", ImGuiKey_G)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "H", ImGuiKey_H)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "I", ImGuiKey_I)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "J", ImGuiKey_J)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K", ImGuiKey_K)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "L", ImGuiKey_L)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "M", ImGuiKey_M)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "N", ImGuiKey_N)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "O", ImGuiKey_O)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "P", ImGuiKey_P)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Q", ImGuiKey_Q)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "R", ImGuiKey_R)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "S", ImGuiKey_S)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "T", ImGuiKey_T)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "U", ImGuiKey_U)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "V", ImGuiKey_V)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "W", ImGuiKey_W)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "X", ImGuiKey_X)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Y", ImGuiKey_Y)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Z", ImGuiKey_Z)); + + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K0", ImGuiKey_0)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K1", ImGuiKey_1)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K2", ImGuiKey_2)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K3", ImGuiKey_3)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K4", ImGuiKey_4)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K5", ImGuiKey_5)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K6", ImGuiKey_6)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K7", ImGuiKey_7)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K8", ImGuiKey_8)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K9", ImGuiKey_9)); + + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Tab", ImGuiKey_Tab)); + AS_CHECK( + scriptEngine->RegisterEnumValue("key", "Enter", ImGuiKey_Enter)); + AS_CHECK( + scriptEngine->RegisterEnumValue("key", "Escape", ImGuiKey_Escape)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Backspace", + ImGuiKey_Backspace)); + AS_CHECK( + scriptEngine->RegisterEnumValue("key", "Space", ImGuiKey_Space)); + AS_CHECK( + scriptEngine->RegisterEnumValue("key", "Delete", ImGuiKey_Delete)); + AS_CHECK( + scriptEngine->RegisterEnumValue("key", "Insert", ImGuiKey_Insert)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Home", ImGuiKey_Home)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "End", ImGuiKey_End)); + AS_CHECK( + scriptEngine->RegisterEnumValue("key", "PageUp", ImGuiKey_PageUp)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "PageDown", + ImGuiKey_PageDown)); + + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Right", + ImGuiKey_RightArrow)); + AS_CHECK( + scriptEngine->RegisterEnumValue("key", "Up", ImGuiKey_UpArrow)); + AS_CHECK( + scriptEngine->RegisterEnumValue("key", "Down", ImGuiKey_DownArrow)); + AS_CHECK( + scriptEngine->RegisterEnumValue("key", "Left", ImGuiKey_LeftArrow)); + + AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightCtrl", + ImGuiKey_RightCtrl)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftShift", + ImGuiKey_LeftShift)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightShift", + ImGuiKey_RightShift)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftAlt", + ImGuiKey_LeftAlt)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightAlt", + ImGuiKey_RightAlt)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftSuper", + ImGuiKey_LeftSuper)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightSuper", + ImGuiKey_RightSuper)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftCtrl", + ImGuiKey_LeftCtrl)); + + AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseLeft", + ImGuiKey_MouseLeft)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseRight", + ImGuiKey_MouseRight)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseMiddle", + ImGuiKey_MouseMiddle)); + } +} // namespace Deer + +/* +enum ImGuiKey : int +{ + // Keyboard + ImGuiKey_None = 0, + ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN + ImGuiKey_LeftArrow, + ImGuiKey_RightArrow, + ImGuiKey_UpArrow, + ImGuiKey_DownArrow, + ImGuiKey_PageUp, + ImGuiKey_PageDown, + ImGuiKey_Home, + ImGuiKey_End, + ImGuiKey_Insert, + ImGuiKey_Delete, + ImGuiKey_Backspace, + ImGuiKey_Space, + ImGuiKey_Enter, + ImGuiKey_Escape, + ImGuiKey_LeftCtrl, ImGuiKey_LeftShift, ImGuiKey_LeftAlt, ImGuiKey_LeftSuper, + ImGuiKey_RightCtrl, ImGuiKey_RightShift, ImGuiKey_RightAlt, +ImGuiKey_RightSuper, ImGuiKey_Menu, ImGuiKey_0, ImGuiKey_1, ImGuiKey_2, +ImGuiKey_3, ImGuiKey_4, ImGuiKey_5, ImGuiKey_6, ImGuiKey_7, ImGuiKey_8, +ImGuiKey_9, ImGuiKey_A, ImGuiKey_B, ImGuiKey_C, ImGuiKey_D, ImGuiKey_E, +ImGuiKey_F, ImGuiKey_G, ImGuiKey_H, ImGuiKey_I, ImGuiKey_J, ImGuiKey_K, +ImGuiKey_L, ImGuiKey_M, ImGuiKey_N, ImGuiKey_O, ImGuiKey_P, ImGuiKey_Q, +ImGuiKey_R, ImGuiKey_S, ImGuiKey_T, ImGuiKey_U, ImGuiKey_V, ImGuiKey_W, +ImGuiKey_X, ImGuiKey_Y, ImGuiKey_Z, ImGuiKey_F1, ImGuiKey_F2, ImGuiKey_F3, +ImGuiKey_F4, ImGuiKey_F5, ImGuiKey_F6, ImGuiKey_F7, ImGuiKey_F8, ImGuiKey_F9, +ImGuiKey_F10, ImGuiKey_F11, ImGuiKey_F12, ImGuiKey_Apostrophe, // ' + ImGuiKey_Comma, // , + ImGuiKey_Minus, // - + ImGuiKey_Period, // . + ImGuiKey_Slash, // / + ImGuiKey_Semicolon, // ; + ImGuiKey_Equal, // = + ImGuiKey_LeftBracket, // [ + ImGuiKey_Backslash, // \ (this text inhibit multiline comment caused +by backslash) ImGuiKey_RightBracket, // ] ImGuiKey_GraveAccent, // ` + ImGuiKey_CapsLock, + ImGuiKey_ScrollLock, + ImGuiKey_NumLock, + ImGuiKey_PrintScreen, + ImGuiKey_Pause, + ImGuiKey_Keypad0, ImGuiKey_Keypad1, ImGuiKey_Keypad2, ImGuiKey_Keypad3, +ImGuiKey_Keypad4, ImGuiKey_Keypad5, ImGuiKey_Keypad6, ImGuiKey_Keypad7, +ImGuiKey_Keypad8, ImGuiKey_Keypad9, ImGuiKey_KeypadDecimal, + ImGuiKey_KeypadDivide, + ImGuiKey_KeypadMultiply, + ImGuiKey_KeypadSubtract, + ImGuiKey_KeypadAdd, + ImGuiKey_KeypadEnter, + ImGuiKey_KeypadEqual, + + // Gamepad (some of those are analog values, 0.0f to 1.0f) // NAVIGATION +ACTION + // (download controller mapping PNG/PSD at +http://dearimgui.org/controls_sheets) ImGuiKey_GamepadStart, // Menu +(Xbox) + (Switch) Start/Options (PS) ImGuiKey_GamepadBack, // +View (Xbox) - (Switch) Share (PS) ImGuiKey_GamepadFaceLeft, // X +(Xbox) Y (Switch) Square (PS) // Tap: Toggle Menu. Hold: +Windowing mode (Focus/Move/Resize windows) ImGuiKey_GamepadFaceRight, // B +(Xbox) A (Switch) Circle (PS) // Cancel / Close / Exit + ImGuiKey_GamepadFaceUp, // Y (Xbox) X (Switch) Triangle +(PS) // Text Input / On-screen Keyboard ImGuiKey_GamepadFaceDown, // +A (Xbox) B (Switch) Cross (PS) // Activate / Open / Toggle / +Tweak ImGuiKey_GamepadDpadLeft, // D-pad Left // Move / Tweak / Resize +Window (in Windowing mode) ImGuiKey_GamepadDpadRight, // D-pad Right // +Move / Tweak / Resize Window (in Windowing mode) ImGuiKey_GamepadDpadUp, // +D-pad Up // Move / Tweak / Resize Window +(in Windowing mode) ImGuiKey_GamepadDpadDown, // D-pad Down // Move / +Tweak / Resize Window (in Windowing mode) ImGuiKey_GamepadL1, // L +Bumper (Xbox) L (Switch) L1 (PS) // Tweak Slower / Focus Previous +(in Windowing mode) ImGuiKey_GamepadR1, // R Bumper (Xbox) R +(Switch) R1 (PS) // Tweak Faster / Focus Next (in Windowing mode) + ImGuiKey_GamepadL2, // L Trig. (Xbox) ZL (Switch) L2 (PS) +[Analog] ImGuiKey_GamepadR2, // R Trig. (Xbox) ZR (Switch) R2 +(PS) [Analog] ImGuiKey_GamepadL3, // L Stick (Xbox) L3 (Switch) L3 +(PS) ImGuiKey_GamepadR3, // R Stick (Xbox) R3 (Switch) R3 (PS) + ImGuiKey_GamepadLStickLeft, // [Analog] // Move Window (in Windowing +mode) ImGuiKey_GamepadLStickRight, // [Analog] // Move Window (in Windowing +mode) ImGuiKey_GamepadLStickUp, // [Analog] // Move Window (in Windowing +mode) ImGuiKey_GamepadLStickDown, // [Analog] // Move Window (in Windowing +mode) ImGuiKey_GamepadRStickLeft, // [Analog] ImGuiKey_GamepadRStickRight, +// [Analog] ImGuiKey_GamepadRStickUp, // [Analog] + ImGuiKey_GamepadRStickDown, // [Analog] + + // Aliases: Mouse Buttons (auto-submitted from AddMouseButtonEvent() calls) + // - This is mirroring the data also written to io.MouseDown[], +io.MouseWheel, in a format allowing them to be accessed via standard key API. + ImGuiKey_MouseLeft, ImGuiKey_MouseRight, ImGuiKey_MouseMiddle, +ImGuiKey_MouseX1, ImGuiKey_MouseX2, ImGuiKey_MouseWheelX, ImGuiKey_MouseWheelY, + + // [Internal] Reserved for mod storage + ImGuiKey_ReservedForModCtrl, ImGuiKey_ReservedForModShift, +ImGuiKey_ReservedForModAlt, ImGuiKey_ReservedForModSuper, ImGuiKey_COUNT, + + // Keyboard Modifiers (explicitly submitted by backend via AddKeyEvent() +calls) + // - This is mirroring the data also written to io.KeyCtrl, io.KeyShift, +io.KeyAlt, io.KeySuper, in a format allowing + // them to be accessed via standard key API, allowing calls such as +IsKeyPressed(), IsKeyReleased(), querying duration etc. + // - Code polling every key (e.g. an interface to detect a key press for +input mapping) might want to ignore those + // and prefer using the real keys (e.g. ImGuiKey_LeftCtrl, +ImGuiKey_RightCtrl instead of ImGuiMod_Ctrl). + // - In theory the value of keyboard modifiers should be roughly equivalent +to a logical or of the equivalent left/right keys. + // In practice: it's complicated; mods are often provided from different +sources. Keyboard layout, IME, sticky keys and + // backends tend to interfere and break that equivalence. The safer +decision is to relay that ambiguity down to the end-user... ImGuiMod_None = 0, + ImGuiMod_Ctrl = 1 << 12, // Ctrl + ImGuiMod_Shift = 1 << 13, // Shift + ImGuiMod_Alt = 1 << 14, // Option/Menu + ImGuiMod_Super = 1 << 15, // Cmd/Super/Windows + ImGuiMod_Shortcut = 1 << 11, // Alias for Ctrl (non-macOS) +_or_ Super (macOS). ImGuiMod_Mask_ = 0xF800, // 5-bits + + // [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using +their own native index + the io.KeyMap[] array. + // We are ditching this method but keeping a legacy path for user code doing +e.g. IsKeyPressed(MY_NATIVE_KEY_CODE) ImGuiKey_NamedKey_BEGIN = 512, + ImGuiKey_NamedKey_END = ImGuiKey_COUNT, + ImGuiKey_NamedKey_COUNT = ImGuiKey_NamedKey_END - +ImGuiKey_NamedKey_BEGIN, #ifdef IMGUI_DISABLE_OBSOLETE_KEYIO + ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size +of KeysData[]: only hold named keys ImGuiKey_KeysData_OFFSET = +ImGuiKey_NamedKey_BEGIN, // First key stored in io.KeysData[0]. +Accesses to io.KeysData[] must use (key - ImGuiKey_KeysData_OFFSET). #else + ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size +of KeysData[]: hold legacy 0..512 keycodes + named keys ImGuiKey_KeysData_OFFSET += 0, // First key stored in io.KeysData[0]. +Accesses to io.KeysData[] must use (key - ImGuiKey_KeysData_OFFSET). #endif + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + ImGuiKey_ModCtrl = ImGuiMod_Ctrl, ImGuiKey_ModShift = ImGuiMod_Shift, +ImGuiKey_ModAlt = ImGuiMod_Alt, ImGuiKey_ModSuper = ImGuiMod_Super, // Renamed +in 1.89 ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter, // Renamed in 1.87 +#endif +}*/ \ No newline at end of file diff --git a/roe/Editor/Panels/AssetExplorer/AssetExplorer.as b/roe/Editor/Panels/AssetExplorer/AssetExplorer.as index edeebf3..6e0c1fd 100644 --- a/roe/Editor/Panels/AssetExplorer/AssetExplorer.as +++ b/roe/Editor/Panels/AssetExplorer/AssetExplorer.as @@ -3,8 +3,62 @@ class AssetExplorer : DockPanel { string currentPath = ""; void onRender() { - UI::setupAutomaticColumns(128); + UI::text("\t"); + UI::sameline(); + if (UI::button("Assets")) { + searchAssetType = AssetType::None; + currentPath = ""; + } + if (searchAssetType != AssetType::None) { + UI::sameline(); + UI::text("/"); + UI::sameline(); + + switch (searchAssetType) { + case AssetType::Mesh : + if (UI::button("Meshes")) { + currentPath = ""; + } + break; + + case AssetType::Shader : + if (UI::button("Shaders")) { + currentPath = ""; + } + break; + + default: + UI::text("Error"); + break; + } + + if (currentPath != "") { + array@ paths = Engine::dividePath(currentPath); + + for (uint i = 0; i < paths.length(); i++) { + UI::sameline(); + UI::text("/"); + UI::sameline(); + + // If we select that path + if (UI::button(paths[i])) { + + // We obtain that pat + string changePath = ""; + for (uint z = 0; z <= i; z++) { + if (z != 0) + changePath += "/"; + changePath += paths[z]; + } + + currentPath = changePath; + } + } + } + } + + UI::setupAutomaticColumns(128); if (searchAssetType == AssetType::None) { searchAssetType = renderRootAssets(); } @@ -16,5 +70,6 @@ class AssetExplorer : DockPanel { currentPath = ""; } } + UI::setupColumns(1); } } diff --git a/roe/Editor/Panels/AssetExplorer/MeshExplorer.as b/roe/Editor/Panels/AssetExplorer/MeshExplorer.as index d295f17..6a836c8 100644 --- a/roe/Editor/Panels/AssetExplorer/MeshExplorer.as +++ b/roe/Editor/Panels/AssetExplorer/MeshExplorer.as @@ -1,16 +1,6 @@ string renderMeshExplorer(string&in dir) { string return_dir = dir; - if (dir == "") { - if (drawFolder("Assets/..")) { - return_dir = ".."; - } - } - - if (dir != "" && drawFolder(Engine::getParentPathName(dir) + "/..")) { - return_dir = Engine::getParentPath(dir); - } - AssetType resourceType = AssetType::Mesh; int dirCount = Assets::getDirCount(resourceType, dir); diff --git a/roe/Editor/Panels/AssetExplorer/ShaderExplorer.as b/roe/Editor/Panels/AssetExplorer/ShaderExplorer.as index ead62a8..d11f1e9 100644 --- a/roe/Editor/Panels/AssetExplorer/ShaderExplorer.as +++ b/roe/Editor/Panels/AssetExplorer/ShaderExplorer.as @@ -2,19 +2,9 @@ class ShaderExplorer : DockPanel { string currentPath = ""; void onRender() { - UI::setupAutomaticColumns(128); - // To avoid problems we will cache the current path const string cache_currentPath = currentPath; - if (cache_currentPath != "") { - UI::drawIconCentered("folder", 64); - if (UI::isItemClicked(0) and UI::isMouseDoubleClicked(0)) { - currentPath = ""; - } - UI::textCenter(cache_currentPath + "/.."); - UI::nextColumn(); - } - + AssetType resourceType = AssetType::Shader; int dirCount = Assets::getDirCount(resourceType, cache_currentPath); for (int i = 0; i < dirCount; i++) { diff --git a/roe/Editor/Panels/AssetExplorer/as.predefined b/roe/Editor/Panels/AssetExplorer/as.predefined index 3051b62..bf8fdeb 100644 --- a/roe/Editor/Panels/AssetExplorer/as.predefined +++ b/roe/Editor/Panels/AssetExplorer/as.predefined @@ -378,6 +378,10 @@ namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int) namespace Engine { FrameBuffer getFrameBuffer(const string&in); } namespace Engine { Environment getMainEnvironment(); } namespace Engine { Environment createEnvironment(); } +namespace Engine { void print(const string&in text); } +namespace Engine { string getParentPath(const string&in path); } +namespace Engine { string getParentPathName(const string&in path); } +namespace Engine { string[]@ dividePath(const string&in path); } namespace UI { void setupAutomaticColumns(int); } namespace UI { void setupColumns(int); } namespace UI { void endColumns(); } @@ -388,9 +392,6 @@ namespace Assets { string getAssetTypePathById(AssetType, const string&in, int); namespace Assets { int getDirCount(AssetType, const string&in); } namespace Assets { string getDirPathById(AssetType, const string&in, int); } namespace Assets { string getDirNameById(AssetType, const string&in, int); } -namespace Engine { void print(const string&in); } -namespace Engine { string getParentPath(const string&in); } -namespace Engine { string getParentPathName(const string&in); } namespace UI { void treeNodeLeaf(const string&in, bool); } namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); } namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); } @@ -783,6 +784,10 @@ namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int) namespace Engine { FrameBuffer getFrameBuffer(const string&in); } namespace Engine { Environment getMainEnvironment(); } namespace Engine { Environment createEnvironment(); } +namespace Engine { void print(const string&in text); } +namespace Engine { string getParentPath(const string&in path); } +namespace Engine { string getParentPathName(const string&in path); } +namespace Engine { string[]@ dividePath(const string&in path); } namespace UI { void setupAutomaticColumns(int); } namespace UI { void setupColumns(int); } namespace UI { void endColumns(); } @@ -793,9 +798,6 @@ namespace Assets { string getAssetTypePathById(AssetType, const string&in, int); namespace Assets { int getDirCount(AssetType, const string&in); } namespace Assets { string getDirPathById(AssetType, const string&in, int); } namespace Assets { string getDirNameById(AssetType, const string&in, int); } -namespace Engine { void print(const string&in); } -namespace Engine { string getParentPath(const string&in); } -namespace Engine { string getParentPathName(const string&in); } namespace UI { void treeNodeLeaf(const string&in, bool); } namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); } namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); } diff --git a/roe/Editor/Panels/EntityManipulation/as.predefined b/roe/Editor/Panels/EntityManipulation/as.predefined index 3051b62..bf8fdeb 100644 --- a/roe/Editor/Panels/EntityManipulation/as.predefined +++ b/roe/Editor/Panels/EntityManipulation/as.predefined @@ -378,6 +378,10 @@ namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int) namespace Engine { FrameBuffer getFrameBuffer(const string&in); } namespace Engine { Environment getMainEnvironment(); } namespace Engine { Environment createEnvironment(); } +namespace Engine { void print(const string&in text); } +namespace Engine { string getParentPath(const string&in path); } +namespace Engine { string getParentPathName(const string&in path); } +namespace Engine { string[]@ dividePath(const string&in path); } namespace UI { void setupAutomaticColumns(int); } namespace UI { void setupColumns(int); } namespace UI { void endColumns(); } @@ -388,9 +392,6 @@ namespace Assets { string getAssetTypePathById(AssetType, const string&in, int); namespace Assets { int getDirCount(AssetType, const string&in); } namespace Assets { string getDirPathById(AssetType, const string&in, int); } namespace Assets { string getDirNameById(AssetType, const string&in, int); } -namespace Engine { void print(const string&in); } -namespace Engine { string getParentPath(const string&in); } -namespace Engine { string getParentPathName(const string&in); } namespace UI { void treeNodeLeaf(const string&in, bool); } namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); } namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); } @@ -783,6 +784,10 @@ namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int) namespace Engine { FrameBuffer getFrameBuffer(const string&in); } namespace Engine { Environment getMainEnvironment(); } namespace Engine { Environment createEnvironment(); } +namespace Engine { void print(const string&in text); } +namespace Engine { string getParentPath(const string&in path); } +namespace Engine { string getParentPathName(const string&in path); } +namespace Engine { string[]@ dividePath(const string&in path); } namespace UI { void setupAutomaticColumns(int); } namespace UI { void setupColumns(int); } namespace UI { void endColumns(); } @@ -793,9 +798,6 @@ namespace Assets { string getAssetTypePathById(AssetType, const string&in, int); namespace Assets { int getDirCount(AssetType, const string&in); } namespace Assets { string getDirPathById(AssetType, const string&in, int); } namespace Assets { string getDirNameById(AssetType, const string&in, int); } -namespace Engine { void print(const string&in); } -namespace Engine { string getParentPath(const string&in); } -namespace Engine { string getParentPathName(const string&in); } namespace UI { void treeNodeLeaf(const string&in, bool); } namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); } namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); } diff --git a/roe/Editor/Panels/TreeExplorer/as.predefined b/roe/Editor/Panels/TreeExplorer/as.predefined index 3051b62..bf8fdeb 100644 --- a/roe/Editor/Panels/TreeExplorer/as.predefined +++ b/roe/Editor/Panels/TreeExplorer/as.predefined @@ -378,6 +378,10 @@ namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int) namespace Engine { FrameBuffer getFrameBuffer(const string&in); } namespace Engine { Environment getMainEnvironment(); } namespace Engine { Environment createEnvironment(); } +namespace Engine { void print(const string&in text); } +namespace Engine { string getParentPath(const string&in path); } +namespace Engine { string getParentPathName(const string&in path); } +namespace Engine { string[]@ dividePath(const string&in path); } namespace UI { void setupAutomaticColumns(int); } namespace UI { void setupColumns(int); } namespace UI { void endColumns(); } @@ -388,9 +392,6 @@ namespace Assets { string getAssetTypePathById(AssetType, const string&in, int); namespace Assets { int getDirCount(AssetType, const string&in); } namespace Assets { string getDirPathById(AssetType, const string&in, int); } namespace Assets { string getDirNameById(AssetType, const string&in, int); } -namespace Engine { void print(const string&in); } -namespace Engine { string getParentPath(const string&in); } -namespace Engine { string getParentPathName(const string&in); } namespace UI { void treeNodeLeaf(const string&in, bool); } namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); } namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); } @@ -783,6 +784,10 @@ namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int) namespace Engine { FrameBuffer getFrameBuffer(const string&in); } namespace Engine { Environment getMainEnvironment(); } namespace Engine { Environment createEnvironment(); } +namespace Engine { void print(const string&in text); } +namespace Engine { string getParentPath(const string&in path); } +namespace Engine { string getParentPathName(const string&in path); } +namespace Engine { string[]@ dividePath(const string&in path); } namespace UI { void setupAutomaticColumns(int); } namespace UI { void setupColumns(int); } namespace UI { void endColumns(); } @@ -793,9 +798,6 @@ namespace Assets { string getAssetTypePathById(AssetType, const string&in, int); namespace Assets { int getDirCount(AssetType, const string&in); } namespace Assets { string getDirPathById(AssetType, const string&in, int); } namespace Assets { string getDirNameById(AssetType, const string&in, int); } -namespace Engine { void print(const string&in); } -namespace Engine { string getParentPath(const string&in); } -namespace Engine { string getParentPathName(const string&in); } namespace UI { void treeNodeLeaf(const string&in, bool); } namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); } namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); } diff --git a/roe/Editor/Panels/Viewport/as.predefined b/roe/Editor/Panels/Viewport/as.predefined index 3051b62..bf8fdeb 100644 --- a/roe/Editor/Panels/Viewport/as.predefined +++ b/roe/Editor/Panels/Viewport/as.predefined @@ -378,6 +378,10 @@ namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int) namespace Engine { FrameBuffer getFrameBuffer(const string&in); } namespace Engine { Environment getMainEnvironment(); } namespace Engine { Environment createEnvironment(); } +namespace Engine { void print(const string&in text); } +namespace Engine { string getParentPath(const string&in path); } +namespace Engine { string getParentPathName(const string&in path); } +namespace Engine { string[]@ dividePath(const string&in path); } namespace UI { void setupAutomaticColumns(int); } namespace UI { void setupColumns(int); } namespace UI { void endColumns(); } @@ -388,9 +392,6 @@ namespace Assets { string getAssetTypePathById(AssetType, const string&in, int); namespace Assets { int getDirCount(AssetType, const string&in); } namespace Assets { string getDirPathById(AssetType, const string&in, int); } namespace Assets { string getDirNameById(AssetType, const string&in, int); } -namespace Engine { void print(const string&in); } -namespace Engine { string getParentPath(const string&in); } -namespace Engine { string getParentPathName(const string&in); } namespace UI { void treeNodeLeaf(const string&in, bool); } namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); } namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); } @@ -783,6 +784,10 @@ namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int) namespace Engine { FrameBuffer getFrameBuffer(const string&in); } namespace Engine { Environment getMainEnvironment(); } namespace Engine { Environment createEnvironment(); } +namespace Engine { void print(const string&in text); } +namespace Engine { string getParentPath(const string&in path); } +namespace Engine { string getParentPathName(const string&in path); } +namespace Engine { string[]@ dividePath(const string&in path); } namespace UI { void setupAutomaticColumns(int); } namespace UI { void setupColumns(int); } namespace UI { void endColumns(); } @@ -793,9 +798,6 @@ namespace Assets { string getAssetTypePathById(AssetType, const string&in, int); namespace Assets { int getDirCount(AssetType, const string&in); } namespace Assets { string getDirPathById(AssetType, const string&in, int); } namespace Assets { string getDirNameById(AssetType, const string&in, int); } -namespace Engine { void print(const string&in); } -namespace Engine { string getParentPath(const string&in); } -namespace Engine { string getParentPathName(const string&in); } namespace UI { void treeNodeLeaf(const string&in, bool); } namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); } namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); } diff --git a/roe/Editor/Services/ActiveEntity/as.predefined b/roe/Editor/Services/ActiveEntity/as.predefined index 73e8fef..ad5dcdc 100644 --- a/roe/Editor/Services/ActiveEntity/as.predefined +++ b/roe/Editor/Services/ActiveEntity/as.predefined @@ -378,6 +378,10 @@ namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int) namespace Engine { FrameBuffer getFrameBuffer(const string&in); } namespace Engine { Environment getMainEnvironment(); } namespace Engine { Environment createEnvironment(); } +namespace Engine { void print(const string&in text); } +namespace Engine { string getParentPath(const string&in path); } +namespace Engine { string getParentPathName(const string&in path); } +namespace Engine { string[]@ dividePath(const string&in path); } namespace UI { void setupAutomaticColumns(int); } namespace UI { void setupColumns(int); } namespace UI { void endColumns(); } @@ -388,9 +392,6 @@ namespace Assets { string getAssetTypePathById(AssetType, const string&in, int); namespace Assets { int getDirCount(AssetType, const string&in); } namespace Assets { string getDirPathById(AssetType, const string&in, int); } namespace Assets { string getDirNameById(AssetType, const string&in, int); } -namespace Engine { void print(const string&in); } -namespace Engine { string getParentPath(const string&in); } -namespace Engine { string getParentPathName(const string&in); } namespace UI { void treeNodeLeaf(const string&in, bool); } namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); } namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); }