Separated dock panels in isolates environments
This commit is contained in:
parent
88ba321f68
commit
b623fddd26
@ -18,7 +18,8 @@ project "DeerStudio"
|
|||||||
"../Deer/vendor/glm",
|
"../Deer/vendor/glm",
|
||||||
"../Deer/vendor/ImGuizmo",
|
"../Deer/vendor/ImGuizmo",
|
||||||
"../Deer/vendor/entt/include",
|
"../Deer/vendor/entt/include",
|
||||||
"../Deer/vendor/angelScript/include"
|
"../Deer/vendor/angelScript/include",
|
||||||
|
"../Deer/vendor/cereal/include"
|
||||||
}
|
}
|
||||||
|
|
||||||
links
|
links
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[Window][DockSpace Demo]
|
[Window][DockSpace Demo]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
Size=2560,1371
|
Size=1280,720
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
@ -9,8 +9,8 @@ Size=400,400
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Terrain Editor]
|
[Window][Terrain Editor]
|
||||||
Pos=2249,24
|
Pos=969,24
|
||||||
Size=311,1128
|
Size=311,477
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
@ -21,47 +21,52 @@ Collapsed=0
|
|||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][ViewportPannel]
|
[Window][ViewportPannel]
|
||||||
Pos=312,24
|
Pos=265,24
|
||||||
Size=1935,1128
|
Size=702,477
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][ShaderExplorer]
|
[Window][ShaderExplorer]
|
||||||
Pos=0,1154
|
Pos=0,503
|
||||||
Size=2560,217
|
Size=1280,217
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,1
|
DockId=0x00000004,0
|
||||||
|
|
||||||
[Window][TreePannel]
|
[Window][TreePannel]
|
||||||
Pos=0,24
|
Pos=0,24
|
||||||
Size=310,1128
|
Size=263,477
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000001,0
|
DockId=0x00000001,0
|
||||||
|
|
||||||
[Window][MeshExplorer]
|
[Window][MeshExplorer]
|
||||||
Pos=0,1154
|
Pos=0,503
|
||||||
Size=2560,217
|
Size=1280,217
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,1
|
||||||
|
|
||||||
[Window][PropertiesPannel]
|
[Window][PropertiesPannel]
|
||||||
Pos=2249,24
|
Pos=969,24
|
||||||
Size=311,1128
|
Size=311,477
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,1
|
DockId=0x00000006,1
|
||||||
|
|
||||||
[Window][CameraPannel]
|
[Window][CameraPannel]
|
||||||
Pos=312,24
|
Pos=265,24
|
||||||
Size=1935,1128
|
Size=702,477
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,1
|
DockId=0x00000005,1
|
||||||
|
|
||||||
|
[Window][MU]
|
||||||
|
Pos=60,60
|
||||||
|
Size=40,64
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=2560,1347 Split=Y Selected=0x34A4C10F
|
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y Selected=0x34A4C10F
|
||||||
DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,477 Split=X
|
DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,477 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=310,696 Selected=0xE45B9F93
|
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=263,696 Selected=0xE45B9F93
|
||||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=2248,696 Split=X Selected=0x34A4C10F
|
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1015,696 Split=X Selected=0x34A4C10F
|
||||||
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=1935,454 CentralNode=1 Selected=0x34A4C10F
|
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=702,454 CentralNode=1 Selected=0x34A4C10F
|
||||||
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=311,454 Selected=0xA35A27E3
|
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=311,454 Selected=0xA35A27E3
|
||||||
DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,217 Selected=0xD962995A
|
DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,217 Selected=0xD962995A
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ class CScriptBuilder;
|
|||||||
namespace Deer {
|
namespace Deer {
|
||||||
// This namespace implements all interface ported from c++ ImGui to an easier lua aproach with simplifications
|
// This namespace implements all interface ported from c++ ImGui to an easier lua aproach with simplifications
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
struct DockPanelObject;
|
class DockPanelContext;
|
||||||
|
class DockPanelObject;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void deinitialize();
|
void deinitialize();
|
||||||
@ -18,18 +19,18 @@ namespace Deer {
|
|||||||
void render();
|
void render();
|
||||||
|
|
||||||
// INTERNAL
|
// INTERNAL
|
||||||
|
// Panels
|
||||||
extern asIScriptEngine* scriptEngine;
|
extern asIScriptEngine* scriptEngine;
|
||||||
extern asIScriptModule* scriptModule;
|
extern asIScriptContext* executingScriptContext;
|
||||||
extern asIScriptContext* scriptContext;
|
extern CScriptBuilder dockPanelScriptBuilder;
|
||||||
extern CScriptBuilder builtContext;
|
|
||||||
extern std::vector<DockPanelObject> dockPanels;
|
extern std::vector<DockPanelContext> dockPanelModules;
|
||||||
extern DockPanelObject* currentDockPanelExecution;
|
extern DockPanelObject* currentDockPanelExecution;
|
||||||
|
|
||||||
void loadScripts();
|
void loadDockPanels();
|
||||||
void registerEditorEngineFunctions();
|
void registerEditorEngineFunctions();
|
||||||
void registerEditorEngineStructs();
|
void registerEditorEngineStructs();
|
||||||
void registerDockPanel();
|
void registerDockPanel();
|
||||||
void extractDockPanels();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace DataStore {
|
namespace DataStore {
|
||||||
|
6
DeerStudio/src/DeerStudio/EditorEngine/API/Service.h
Normal file
6
DeerStudio/src/DeerStudio/EditorEngine/API/Service.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Deer {
|
||||||
|
namespace EditorEngine {
|
||||||
|
}
|
||||||
|
}
|
@ -9,16 +9,16 @@ namespace Deer {
|
|||||||
|
|
||||||
void errorCallback(const asSMessageInfo *msg, void *param) {
|
void errorCallback(const asSMessageInfo *msg, void *param) {
|
||||||
if (msg->type == asMSGTYPE_WARNING) {
|
if (msg->type == asMSGTYPE_WARNING) {
|
||||||
DEER_UI_ENGINE_WARN("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message);
|
DEER_EDITOR_ENGINE_WARN("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message);
|
||||||
} else if( msg->type == asMSGTYPE_INFORMATION ) {
|
} else if( msg->type == asMSGTYPE_INFORMATION ) {
|
||||||
DEER_UI_ENGINE_ERROR("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message);
|
DEER_EDITOR_ENGINE_ERROR("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message);
|
||||||
} else if (msg->type == asMSGTYPE_INFORMATION){
|
} else if (msg->type == asMSGTYPE_INFORMATION){
|
||||||
DEER_UI_ENGINE_TRACE("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message);
|
DEER_EDITOR_ENGINE_TRACE("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(std::string& msg) {
|
void print(std::string& msg) {
|
||||||
DEER_UI_ENGINE_INFO("{0}", msg.c_str());
|
DEER_EDITOR_ENGINE_INFO("{0}", msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "DeerStudio/EditorEngine/API/Entity.h"
|
#include "DeerStudio/EditorEngine/API/Entity.h"
|
||||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
|
|
||||||
#include "DeerRender/Components.h"
|
#include "DeerRender/Components.h"
|
||||||
@ -40,7 +40,7 @@ namespace Deer {
|
|||||||
|
|
||||||
bool EntityHandleStruct::assertEntity(const char* funcName) {
|
bool EntityHandleStruct::assertEntity(const char* funcName) {
|
||||||
if (!Scene::environment.entityExists(entityId)) {
|
if (!Scene::environment.entityExists(entityId)) {
|
||||||
DEER_UI_ENGINE_ERROR("Error, invalid entity calling {0}, entityId : {1}", funcName, entityId);
|
DEER_EDITOR_ENGINE_ERROR("Error, invalid entity calling {0}, entityId : {1}", funcName, entityId);
|
||||||
if (currentDockPanelExecution)
|
if (currentDockPanelExecution)
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
return false;
|
return false;
|
||||||
@ -174,7 +174,7 @@ namespace Deer {
|
|||||||
Entity& ent = Scene::environment.getEntity(entityId);
|
Entity& ent = Scene::environment.getEntity(entityId);
|
||||||
|
|
||||||
if (!ent.hasComponent<MeshComponent>()) {
|
if (!ent.hasComponent<MeshComponent>()) {
|
||||||
DEER_UI_ENGINE_ERROR("Error, calling MeshComponent.{0} entity {1} with id {2} has no MeshComponent",
|
DEER_EDITOR_ENGINE_ERROR("Error, calling MeshComponent.{0} entity {1} with id {2} has no MeshComponent",
|
||||||
funcName,
|
funcName,
|
||||||
ent.getComponent<TagComponent>().tag.c_str(),
|
ent.getComponent<TagComponent>().tag.c_str(),
|
||||||
entityId
|
entityId
|
||||||
@ -195,7 +195,7 @@ namespace Deer {
|
|||||||
.getComponent<RelationshipComponent>();
|
.getComponent<RelationshipComponent>();
|
||||||
|
|
||||||
if (i < 0 || i >= rc.childCount) {
|
if (i < 0 || i >= rc.childCount) {
|
||||||
DEER_UI_ENGINE_ERROR("Error while executing EntityChild.getChild(..), id {0} is invalid for child count of {1}", 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)
|
if (currentDockPanelExecution)
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ namespace Deer {
|
|||||||
Entity& ent = Scene::environment.getEntity(entityId);
|
Entity& ent = Scene::environment.getEntity(entityId);
|
||||||
|
|
||||||
if (!ent.hasComponent<ShaderComponent>()) {
|
if (!ent.hasComponent<ShaderComponent>()) {
|
||||||
DEER_UI_ENGINE_ERROR("Error, calling ShaderComponent.{0} entity {1} with id {2} has no ShaderComponent",
|
DEER_EDITOR_ENGINE_ERROR("Error, calling ShaderComponent.{0} entity {1} with id {2} has no ShaderComponent",
|
||||||
funcName,
|
funcName,
|
||||||
ent.getComponent<TagComponent>().tag.c_str(),
|
ent.getComponent<TagComponent>().tag.c_str(),
|
||||||
entityId
|
entityId
|
||||||
@ -445,7 +445,7 @@ namespace Deer {
|
|||||||
Entity& ent = Scene::environment.getEntity(entityId);
|
Entity& ent = Scene::environment.getEntity(entityId);
|
||||||
|
|
||||||
if (!ent.hasComponent<CameraComponent>()) {
|
if (!ent.hasComponent<CameraComponent>()) {
|
||||||
DEER_UI_ENGINE_ERROR("Error, calling CameraComponent.{0} entity {1} with id {2} has no CameraComponent",
|
DEER_EDITOR_ENGINE_ERROR("Error, calling CameraComponent.{0} entity {1} with id {2} has no CameraComponent",
|
||||||
funcName,
|
funcName,
|
||||||
ent.getComponent<TagComponent>().tag.c_str(),
|
ent.getComponent<TagComponent>().tag.c_str(),
|
||||||
entityId
|
entityId
|
||||||
|
@ -19,7 +19,6 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool treeNodeRecursive(std::string& txt, bool active, CScriptAny *data, asIScriptFunction& func) {
|
bool treeNodeRecursive(std::string& txt, bool active, CScriptAny *data, asIScriptFunction& func) {
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||||
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnDoubleClick |
|
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnDoubleClick |
|
||||||
ImGuiTreeNodeFlags_OpenOnArrow |
|
ImGuiTreeNodeFlags_OpenOnArrow |
|
||||||
@ -31,23 +30,23 @@ namespace Deer {
|
|||||||
|
|
||||||
if (ImGui::TreeNodeEx(txt.c_str(), flags)) {
|
if (ImGui::TreeNodeEx(txt.c_str(), flags)) {
|
||||||
ImGui::PushID(txt.c_str());
|
ImGui::PushID(txt.c_str());
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
AS_CHECK_ADDITIONAL_INFO(
|
||||||
scriptContext->Prepare(&func),
|
executingScriptContext->Prepare(&func),
|
||||||
func.GetDeclaration()
|
func.GetDeclaration()
|
||||||
);
|
);
|
||||||
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
AS_CHECK_ADDITIONAL_INFO(
|
||||||
scriptContext->SetArgObject(0, data),
|
executingScriptContext->SetArgObject(0, data),
|
||||||
func.GetDeclaration()
|
func.GetDeclaration()
|
||||||
);
|
);
|
||||||
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
AS_CHECK_ADDITIONAL_INFO(
|
||||||
scriptContext->Execute(),
|
executingScriptContext->Execute(),
|
||||||
func.GetDeclaration()
|
func.GetDeclaration()
|
||||||
);
|
);
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("Something failed");
|
ImGui::Text("Something failed");
|
||||||
}
|
}
|
||||||
@ -78,15 +77,15 @@ namespace Deer {
|
|||||||
if (ImGui::TreeNodeEx(txt.c_str(), flags)){
|
if (ImGui::TreeNodeEx(txt.c_str(), flags)){
|
||||||
ImGui::Dummy(ImVec2(0, 10));
|
ImGui::Dummy(ImVec2(0, 10));
|
||||||
ImGui::PushID(txt.c_str());
|
ImGui::PushID(txt.c_str());
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
|
|
||||||
AS_CHECK( scriptContext->Prepare(func));
|
AS_CHECK( executingScriptContext->Prepare(func));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(0, data));
|
AS_CHECK(executingScriptContext->SetArgObject(0, data));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Execute());
|
AS_CHECK(executingScriptContext->Execute());
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("Something failed");
|
ImGui::Text("Something failed");
|
||||||
}
|
}
|
||||||
@ -117,15 +116,15 @@ namespace Deer {
|
|||||||
if (ImGui::TreeNodeEx(txt.c_str(), flags)){
|
if (ImGui::TreeNodeEx(txt.c_str(), flags)){
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
||||||
if (ImGui::BeginPopupContextItem(txt.c_str())) {
|
if (ImGui::BeginPopupContextItem(txt.c_str())) {
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
|
|
||||||
AS_CHECK( scriptContext->Prepare(menu));
|
AS_CHECK( executingScriptContext->Prepare(menu));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(0, data));
|
AS_CHECK(executingScriptContext->SetArgObject(0, data));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Execute());
|
AS_CHECK(executingScriptContext->Execute());
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("Something failed");
|
ImGui::Text("Something failed");
|
||||||
}
|
}
|
||||||
@ -135,15 +134,15 @@ namespace Deer {
|
|||||||
|
|
||||||
ImGui::Dummy(ImVec2(0, 10));
|
ImGui::Dummy(ImVec2(0, 10));
|
||||||
ImGui::PushID(txt.c_str());
|
ImGui::PushID(txt.c_str());
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
|
|
||||||
AS_CHECK( scriptContext->Prepare(func));
|
AS_CHECK( executingScriptContext->Prepare(func));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(0, data));
|
AS_CHECK(executingScriptContext->SetArgObject(0, data));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Execute());
|
AS_CHECK(executingScriptContext->Execute());
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("Something failed");
|
ImGui::Text("Something failed");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "DeerStudio/EditorEngine/API/Menu.h"
|
#include "DeerStudio/EditorEngine/API/Menu.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "angelscript.h"
|
#include "angelscript.h"
|
||||||
#include "scriptany.h"
|
#include "scriptany.h"
|
||||||
@ -17,15 +17,15 @@ namespace Deer {
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
||||||
if (ImGui::BeginPopupContextItem(menu_id.c_str())) {
|
if (ImGui::BeginPopupContextItem(menu_id.c_str())) {
|
||||||
|
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Prepare(func));
|
AS_CHECK(executingScriptContext->Prepare(func));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(0, data));
|
AS_CHECK(executingScriptContext->SetArgObject(0, data));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Execute());
|
AS_CHECK(executingScriptContext->Execute());
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("Something failed");
|
ImGui::Text("Something failed");
|
||||||
}
|
}
|
||||||
@ -39,15 +39,15 @@ namespace Deer {
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
||||||
if (ImGui::BeginPopupContextWindow(menu_id.c_str())) {
|
if (ImGui::BeginPopupContextWindow(menu_id.c_str())) {
|
||||||
|
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Prepare(func));
|
AS_CHECK(executingScriptContext->Prepare(func));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(0, data));
|
AS_CHECK(executingScriptContext->SetArgObject(0, data));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Execute());
|
AS_CHECK(executingScriptContext->Execute());
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("Something failed");
|
ImGui::Text("Something failed");
|
||||||
}
|
}
|
||||||
@ -94,14 +94,14 @@ namespace Deer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
AS_CHECK(scriptContext->Prepare(func));
|
AS_CHECK(executingScriptContext->Prepare(func));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(0, MenuContext::payload));
|
AS_CHECK(executingScriptContext->SetArgObject(0, MenuContext::payload));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Execute());
|
AS_CHECK(executingScriptContext->Execute());
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("Something failed");
|
ImGui::Text("Something failed");
|
||||||
}
|
}
|
||||||
@ -140,14 +140,14 @@ namespace Deer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
AS_CHECK(scriptContext->Prepare(func));
|
AS_CHECK(executingScriptContext->Prepare(func));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(0, MenuContext::payload));
|
AS_CHECK(executingScriptContext->SetArgObject(0, MenuContext::payload));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Execute());
|
AS_CHECK(executingScriptContext->Execute());
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("Something failed");
|
ImGui::Text("Something failed");
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "DeerStudio/EditorEngine/API/Resource.h"
|
#include "DeerStudio/EditorEngine/API/Resource.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "Deer/DataStore.h"
|
#include "Deer/DataStore.h"
|
||||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||||
#include "Deer/Log.h"
|
#include "Deer/Log.h"
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
@ -60,7 +60,7 @@ namespace Deer {
|
|||||||
const char* resourceExtension = getResourceExtension(type);
|
const char* resourceExtension = getResourceExtension(type);
|
||||||
|
|
||||||
if (!resourcePath || !resourceExtension) {
|
if (!resourcePath || !resourceExtension) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getResourceCount(..)");
|
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getResourceCount(..)");
|
||||||
if (currentDockPanelExecution) {
|
if (currentDockPanelExecution) {
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ namespace Deer {
|
|||||||
const char* resourceExtension = getResourceExtension(type);
|
const char* resourceExtension = getResourceExtension(type);
|
||||||
|
|
||||||
if (!resourcePath || !resourceExtension) {
|
if (!resourcePath || !resourceExtension) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getResourceNameById(..)");
|
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getResourceNameById(..)");
|
||||||
if (currentDockPanelExecution) {
|
if (currentDockPanelExecution) {
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ namespace Deer {
|
|||||||
|
|
||||||
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
||||||
if (i < 0 || i >= dirData.elements.size()) {
|
if (i < 0 || i >= dirData.elements.size()) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid element id {3} calling getResourceNameById(..) for type {0} and path {1}, element count on that dir is {2}",
|
DEER_EDITOR_ENGINE_ERROR("Invalid element id {3} calling getResourceNameById(..) for type {0} and path {1}, element count on that dir is {2}",
|
||||||
getResourceName(type),
|
getResourceName(type),
|
||||||
dir.c_str(),
|
dir.c_str(),
|
||||||
dirData.elements.size(),
|
dirData.elements.size(),
|
||||||
@ -104,7 +104,7 @@ namespace Deer {
|
|||||||
const char* resourceExtension = getResourceExtension(type);
|
const char* resourceExtension = getResourceExtension(type);
|
||||||
|
|
||||||
if (!resourcePath || !resourceExtension) {
|
if (!resourcePath || !resourceExtension) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getResourcePathById(..)");
|
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getResourcePathById(..)");
|
||||||
if (currentDockPanelExecution) {
|
if (currentDockPanelExecution) {
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ namespace Deer {
|
|||||||
|
|
||||||
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
||||||
if (i < 0 || i >= dirData.elements.size()) {
|
if (i < 0 || i >= dirData.elements.size()) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid element id {3} calling getResourcePathById(..) for type {0} and path {1}, element count on that dir is {2}",
|
DEER_EDITOR_ENGINE_ERROR("Invalid element id {3} calling getResourcePathById(..) for type {0} and path {1}, element count on that dir is {2}",
|
||||||
getResourceName(type),
|
getResourceName(type),
|
||||||
dir.c_str(),
|
dir.c_str(),
|
||||||
dirData.elements.size(),
|
dirData.elements.size(),
|
||||||
@ -133,7 +133,7 @@ namespace Deer {
|
|||||||
const char* resourceExtension = getResourceExtension(type);
|
const char* resourceExtension = getResourceExtension(type);
|
||||||
|
|
||||||
if (!resourcePath || !resourceExtension) {
|
if (!resourcePath || !resourceExtension) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getDirCount(..)");
|
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getDirCount(..)");
|
||||||
if (currentDockPanelExecution) {
|
if (currentDockPanelExecution) {
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ namespace Deer {
|
|||||||
const char* resourceExtension = getResourceExtension(type);
|
const char* resourceExtension = getResourceExtension(type);
|
||||||
|
|
||||||
if (!resourcePath || !resourceExtension) {
|
if (!resourcePath || !resourceExtension) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getDirPathById(..)");
|
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getDirPathById(..)");
|
||||||
if (currentDockPanelExecution) {
|
if (currentDockPanelExecution) {
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ namespace Deer {
|
|||||||
|
|
||||||
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
||||||
if (i < 0 || i >= dirData.dirs.size()) {
|
if (i < 0 || i >= dirData.dirs.size()) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid element id {3} calling getDirPathById(..) for type {0} and path {1}, sub_dir count on that dir is {2}",
|
DEER_EDITOR_ENGINE_ERROR("Invalid element id {3} calling getDirPathById(..) for type {0} and path {1}, sub_dir count on that dir is {2}",
|
||||||
getResourceName(type),
|
getResourceName(type),
|
||||||
dir.c_str(),
|
dir.c_str(),
|
||||||
dirData.dirs.size(),
|
dirData.dirs.size(),
|
||||||
@ -177,7 +177,7 @@ namespace Deer {
|
|||||||
const char* resourceExtension = getResourceExtension(type);
|
const char* resourceExtension = getResourceExtension(type);
|
||||||
|
|
||||||
if (!resourcePath || !resourceExtension) {
|
if (!resourcePath || !resourceExtension) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getDirNameById(..)");
|
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getDirNameById(..)");
|
||||||
if (currentDockPanelExecution) {
|
if (currentDockPanelExecution) {
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ namespace Deer {
|
|||||||
|
|
||||||
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
||||||
if (i < 0 || i >= dirData.dirs.size()) {
|
if (i < 0 || i >= dirData.dirs.size()) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid element id {3} calling getDirPathById(..) for type {0} and path {1}, sub_dir count on that dir is {2}",
|
DEER_EDITOR_ENGINE_ERROR("Invalid element id {3} calling getDirPathById(..) for type {0} and path {1}, sub_dir count on that dir is {2}",
|
||||||
getResourceName(type),
|
getResourceName(type),
|
||||||
dir.c_str(),
|
dir.c_str(),
|
||||||
dirData.dirs.size(),
|
dirData.dirs.size(),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "DeerStudio/EditorEngine/API/UI.h"
|
#include "DeerStudio/EditorEngine/API/UI.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "DeerRender/FrameBuffer.h"
|
#include "DeerRender/FrameBuffer.h"
|
||||||
#include "Deer/Log.h"
|
#include "Deer/Log.h"
|
||||||
@ -139,7 +139,7 @@ namespace Deer {
|
|||||||
int iconId = DataStore::getIconId(name);
|
int iconId = DataStore::getIconId(name);
|
||||||
|
|
||||||
if (iconId < 0) {
|
if (iconId < 0) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid icon name {0}", name.c_str());
|
DEER_EDITOR_ENGINE_ERROR("Invalid icon name {0}", name.c_str());
|
||||||
if (currentDockPanelExecution) {
|
if (currentDockPanelExecution) {
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ namespace Deer {
|
|||||||
void drawIconCentered(std::string& name, int size) {
|
void drawIconCentered(std::string& name, int size) {
|
||||||
int iconId = DataStore::getIconId(name);
|
int iconId = DataStore::getIconId(name);
|
||||||
if (iconId < 0) {
|
if (iconId < 0) {
|
||||||
DEER_UI_ENGINE_ERROR("Invalid icon name {0}", name.c_str());
|
DEER_EDITOR_ENGINE_ERROR("Invalid icon name {0}", name.c_str());
|
||||||
if (currentDockPanelExecution) {
|
if (currentDockPanelExecution) {
|
||||||
currentDockPanelExecution->invalidate();
|
currentDockPanelExecution->invalidate();
|
||||||
}
|
}
|
||||||
@ -223,15 +223,15 @@ namespace Deer {
|
|||||||
void menuSpace(std::string& txt, CScriptAny* data ,asIScriptFunction* func) {
|
void menuSpace(std::string& txt, CScriptAny* data ,asIScriptFunction* func) {
|
||||||
if (ImGui::BeginMenu(txt.c_str())) {
|
if (ImGui::BeginMenu(txt.c_str())) {
|
||||||
|
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Prepare(func));
|
AS_CHECK(executingScriptContext->Prepare(func));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(0, data));
|
AS_CHECK(executingScriptContext->SetArgObject(0, data));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Execute());
|
AS_CHECK(executingScriptContext->Execute());
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
@ -270,17 +270,17 @@ namespace Deer {
|
|||||||
if (ImGui::BeginDragDropTarget()) {
|
if (ImGui::BeginDragDropTarget()) {
|
||||||
if (ImGui::AcceptDragDropPayload(id.c_str()) && DragDropPayload::payload) {
|
if (ImGui::AcceptDragDropPayload(id.c_str()) && DragDropPayload::payload) {
|
||||||
|
|
||||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Prepare(func));
|
AS_CHECK(executingScriptContext->Prepare(func));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(0, data));
|
AS_CHECK(executingScriptContext->SetArgObject(0, data));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->SetArgObject(1, DragDropPayload::payload));
|
AS_CHECK(executingScriptContext->SetArgObject(1, DragDropPayload::payload));
|
||||||
|
|
||||||
AS_CHECK(scriptContext->Execute());
|
AS_CHECK(executingScriptContext->Execute());
|
||||||
|
|
||||||
scriptContext->PopState();
|
executingScriptContext->PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
DragDropPayload::payload->Release();
|
DragDropPayload::payload->Release();
|
||||||
@ -487,9 +487,7 @@ namespace Deer {
|
|||||||
|
|
||||||
void disablePannelPadding(bool value) {
|
void disablePannelPadding(bool value) {
|
||||||
if (currentDockPanelExecution) {
|
if (currentDockPanelExecution) {
|
||||||
if (value != (currentDockPanelExecution->flags & DockPannelFlag_PannelPadding)){
|
currentDockPanelExecution->setFlag(DockPannelFlag_PannelPadding, value);
|
||||||
currentDockPanelExecution->flags ^= DockPannelFlag_PannelPadding;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine/API.h"
|
#include "DeerStudio/EditorEngine/API.h"
|
||||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||||
|
|
||||||
#include "scripthandle.h"
|
#include "scripthandle.h"
|
||||||
#include "scriptany.h"
|
#include "scriptany.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "DeerStudio/EditorEngine/API/Environment.h"
|
#include "DeerStudio/EditorEngine/API/Environment.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||||
|
|
||||||
#include "angelscript.h"
|
#include "angelscript.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "DeerStudio/EditorEngine/API/FrameBuffer.h"
|
#include "DeerStudio/EditorEngine/API/FrameBuffer.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "angelscript.h"
|
#include "angelscript.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine/API.h"
|
#include "DeerStudio/EditorEngine/API.h"
|
||||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||||
|
|
||||||
#include "scripthandle.h"
|
#include "scripthandle.h"
|
||||||
#include "scriptany.h"
|
#include "scriptany.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "DeerStudio/EditorEngine/API.h"
|
#include "DeerStudio/EditorEngine/API.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||||
|
|
||||||
#include "angelscript.h"
|
#include "angelscript.h"
|
||||||
|
|
||||||
|
@ -27,6 +27,14 @@ namespace Deer {
|
|||||||
registerMathStructs();
|
registerMathStructs();
|
||||||
registerFrameBufferStructs();
|
registerFrameBufferStructs();
|
||||||
registerEnvironmentStructs();
|
registerEnvironmentStructs();
|
||||||
|
registerDockPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void registerDockPanel() {
|
||||||
|
AS_RET_CHECK(scriptEngine->RegisterInterface("DockPanel"));
|
||||||
|
|
||||||
|
AS_RET_CHECK(scriptEngine->RegisterInterfaceMethod("DockPanel", "void onRender()"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine/API.h"
|
#include "DeerStudio/EditorEngine/API.h"
|
||||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||||
|
|
||||||
#include "scripthandle.h"
|
#include "scripthandle.h"
|
||||||
#include "scriptany.h"
|
#include "scriptany.h"
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
|
||||||
|
#include "DeerStudio/EditorEngine.h"
|
||||||
|
#include "Deer/Log.h"
|
||||||
|
|
||||||
|
#include "angelscript.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "DockPanelObject.h"
|
||||||
|
#include "DockPanelInfo.h"
|
||||||
|
|
||||||
|
#include "Deer/Memory.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class asIScriptModule;
|
||||||
|
class asIScriptContext;
|
||||||
|
|
||||||
|
namespace Deer {
|
||||||
|
namespace EditorEngine {
|
||||||
|
class DockPanelContext {
|
||||||
|
public:
|
||||||
|
DockPanelContext(asIScriptModule*, DockPanelInfo*);
|
||||||
|
~DockPanelContext();
|
||||||
|
|
||||||
|
DockPanelContext(DockPanelContext&) = delete;
|
||||||
|
DockPanelContext& operator=(DockPanelContext&) = delete;
|
||||||
|
|
||||||
|
DockPanelContext(DockPanelContext&&);
|
||||||
|
DockPanelContext& operator=(DockPanelContext&&);
|
||||||
|
|
||||||
|
void render();
|
||||||
|
void init();
|
||||||
|
|
||||||
|
inline const char* getName() const { return info->name.c_str(); }
|
||||||
|
|
||||||
|
std::vector<DockPanelObject> dockPanels;
|
||||||
|
private:
|
||||||
|
asIScriptContext* context;
|
||||||
|
asIScriptModule* module;
|
||||||
|
DockPanelInfo* info;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Deer/Path.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Deer {
|
||||||
|
namespace EditorEngine {
|
||||||
|
struct DockPanelInfo {
|
||||||
|
std::string name = "null";
|
||||||
|
std::string author = "";
|
||||||
|
std::string version = "0.0.0";
|
||||||
|
};
|
||||||
|
|
||||||
|
DockPanelInfo* loadDockPanelInfo(Path panelInfo);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
#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 <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
namespace Deer {
|
||||||
|
namespace EditorEngine {
|
||||||
|
template <class Archive>
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
|
|
||||||
@ -10,39 +10,44 @@
|
|||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
EditorEngine::DockPanelObject::DockPanelObject(asITypeInfo* _type)
|
EditorEngine::DockPanelObject::DockPanelObject(asITypeInfo* _type, asIScriptContext* _scriptContext)
|
||||||
: type (_type), isValid(false) {
|
: type (_type), isValid(false), scriptContext(_scriptContext){
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
// "type@ type()"
|
// "type@ type()"
|
||||||
std::string callString(type->GetName());
|
std::string callString;
|
||||||
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 += type->GetName();
|
||||||
callString += "()";
|
callString += "()";
|
||||||
|
|
||||||
|
flags = DockPannelFlag_ShowPannel;
|
||||||
|
|
||||||
asIScriptFunction* factory = type->GetFactoryByDecl(callString.c_str());
|
asIScriptFunction* factory = type->GetFactoryByDecl(callString.c_str());
|
||||||
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
AS_CHECK(scriptContext->Prepare(factory));
|
||||||
scriptContext->Prepare(factory),
|
AS_CHECK(scriptContext->Execute());
|
||||||
type->GetName()
|
|
||||||
);
|
|
||||||
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
|
||||||
scriptContext->Execute(),
|
|
||||||
type->GetName()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Return value contains the ref to a asIScriptObject in the location provided
|
// Return value contains the ref to a asIScriptObject in the location provided
|
||||||
object = *(asIScriptObject**)scriptContext->GetAddressOfReturnValue();
|
object = *(asIScriptObject**)scriptContext->GetAddressOfReturnValue();
|
||||||
if (!object){
|
if (!object){
|
||||||
DEER_UI_ENGINE_ERROR("Could not create object", _type->GetName());
|
DEER_EDITOR_ENGINE_ERROR("Could not create object", type->GetName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
object->AddRef();
|
object->AddRef();
|
||||||
|
|
||||||
renderFunction = type->GetMethodByDecl("void onRender()");
|
renderFunction = type->GetMethodByDecl("void onRender()");
|
||||||
if (!renderFunction) {
|
if (!renderFunction) {
|
||||||
DEER_UI_ENGINE_ERROR("Could not load void onRender() from {0}", _type->GetName());
|
DEER_EDITOR_ENGINE_ERROR("Could not load void onRender() from {0}", type->GetName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +55,19 @@ namespace Deer {
|
|||||||
initFunction = type->GetMethodByDecl("void onInit()");
|
initFunction = type->GetMethodByDecl("void onInit()");
|
||||||
|
|
||||||
isValid = true;
|
isValid = true;
|
||||||
|
|
||||||
|
int refCount = object->AddRef(); // increments refcount by 1
|
||||||
|
refCount = object->Release();
|
||||||
|
|
||||||
|
scriptContext->Unprepare();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int EditorEngine::DockPanelObject::getRefCount() {
|
||||||
|
int refCount = object->AddRef(); // increments refcount by 1
|
||||||
|
refCount = object->Release();
|
||||||
|
|
||||||
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* EditorEngine::DockPanelObject::getName() {
|
const char* EditorEngine::DockPanelObject::getName() {
|
||||||
@ -62,31 +80,28 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorEngine::DockPanelObject::invalidate() {
|
void EditorEngine::DockPanelObject::invalidate() {
|
||||||
DEER_UI_ENGINE_ERROR("Last error was caused executing {0}", type->GetName());
|
DEER_EDITOR_ENGINE_ERROR("Last error was caused executing {0}", type->GetName());
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorEngine::DockPanelObject::init() {
|
void EditorEngine::DockPanelObject::init() {
|
||||||
|
|
||||||
if (!initFunction)
|
if (!initFunction)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
executingScriptContext = scriptContext;
|
||||||
scriptContext->Prepare(initFunction),
|
AS_CHECK(scriptContext->Prepare(initFunction));
|
||||||
type->GetName()
|
AS_CHECK(scriptContext->SetObject(object));
|
||||||
);
|
AS_CHECK(scriptContext->Execute());
|
||||||
|
AS_CHECK(scriptContext->Unprepare());
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
executingScriptContext = nullptr;
|
||||||
scriptContext->SetObject(object),
|
|
||||||
type->GetName()
|
|
||||||
);
|
|
||||||
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
|
||||||
scriptContext->Execute(),
|
|
||||||
type->GetName()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorEngine::DockPanelObject::executeRender() {
|
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
|
// We cache the result because the user can remove the flag while executing
|
||||||
bool hasPadding = flags & DockPannelFlag_PannelPadding;
|
bool hasPadding = flags & DockPannelFlag_PannelPadding;
|
||||||
if (hasPadding)
|
if (hasPadding)
|
||||||
@ -96,20 +111,12 @@ namespace Deer {
|
|||||||
ImGui::Begin(type->GetName(), (bool*)0, ImGuiWindowFlags_MenuBar);
|
ImGui::Begin(type->GetName(), (bool*)0, ImGuiWindowFlags_MenuBar);
|
||||||
|
|
||||||
if (ImGui::BeginMenuBar()) {
|
if (ImGui::BeginMenuBar()) {
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
executingScriptContext = scriptContext;
|
||||||
scriptContext->Prepare(menuBarFunction),
|
AS_CHECK(scriptContext->Prepare(menuBarFunction));
|
||||||
type->GetName()
|
AS_CHECK(scriptContext->SetObject(object));
|
||||||
);
|
AS_CHECK(scriptContext->Execute());
|
||||||
|
AS_CHECK(scriptContext->Unprepare());
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
executingScriptContext = nullptr;
|
||||||
scriptContext->SetObject(object),
|
|
||||||
type->GetName()
|
|
||||||
);
|
|
||||||
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
|
||||||
scriptContext->Execute(),
|
|
||||||
type->GetName()
|
|
||||||
);
|
|
||||||
|
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
@ -131,20 +138,12 @@ namespace Deer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
executingScriptContext = scriptContext;
|
||||||
scriptContext->Prepare(renderFunction),
|
AS_CHECK(scriptContext->Prepare(renderFunction));
|
||||||
type->GetName()
|
AS_CHECK(scriptContext->SetObject(object));
|
||||||
);
|
AS_CHECK(scriptContext->Execute());
|
||||||
|
AS_CHECK(scriptContext->Unprepare());
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
executingScriptContext = nullptr;
|
||||||
scriptContext->SetObject(object),
|
|
||||||
type->GetName()
|
|
||||||
);
|
|
||||||
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
|
||||||
scriptContext->Execute(),
|
|
||||||
type->GetName()
|
|
||||||
);
|
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
@ -153,7 +152,14 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EditorEngine::DockPanelObject::DockPanelObject(DockPanelObject&& other) noexcept
|
EditorEngine::DockPanelObject::DockPanelObject(DockPanelObject&& other) noexcept
|
||||||
: isValid(other.isValid), renderFunction(other.renderFunction), type(other.type), object(other.object), menuBarFunction(other.menuBarFunction), initFunction(other.initFunction) {
|
: 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.isValid = false;
|
||||||
other.renderFunction = nullptr;
|
other.renderFunction = nullptr;
|
||||||
@ -161,16 +167,22 @@ namespace Deer {
|
|||||||
other.object = nullptr;
|
other.object = nullptr;
|
||||||
other.menuBarFunction = nullptr;
|
other.menuBarFunction = nullptr;
|
||||||
other.initFunction = nullptr;
|
other.initFunction = nullptr;
|
||||||
|
other.scriptContext = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorEngine::DockPanelObject& EditorEngine::DockPanelObject::operator=(EditorEngine::DockPanelObject&& other) noexcept {
|
EditorEngine::DockPanelObject& EditorEngine::DockPanelObject::operator=(EditorEngine::DockPanelObject&& other) noexcept {
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
|
if (object)
|
||||||
|
object->Release();
|
||||||
|
|
||||||
isValid = other.isValid;
|
isValid = other.isValid;
|
||||||
renderFunction = other.renderFunction;
|
renderFunction = other.renderFunction;
|
||||||
type = other.type;
|
type = other.type;
|
||||||
object = other.object;
|
object = other.object;
|
||||||
menuBarFunction = other.menuBarFunction;
|
menuBarFunction = other.menuBarFunction;
|
||||||
initFunction = other.initFunction;
|
initFunction = other.initFunction;
|
||||||
|
flags = other.flags;
|
||||||
|
scriptContext = other.scriptContext;
|
||||||
|
|
||||||
other.isValid = false;
|
other.isValid = false;
|
||||||
other.renderFunction = nullptr;
|
other.renderFunction = nullptr;
|
||||||
@ -178,9 +190,18 @@ namespace Deer {
|
|||||||
other.object = nullptr;
|
other.object = nullptr;
|
||||||
other.menuBarFunction = nullptr;
|
other.menuBarFunction = nullptr;
|
||||||
other.initFunction = nullptr;
|
other.initFunction = nullptr;
|
||||||
|
other.scriptContext = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,6 +4,7 @@
|
|||||||
class asITypeInfo;
|
class asITypeInfo;
|
||||||
class asIScriptObject;
|
class asIScriptObject;
|
||||||
class asIScriptFunction;
|
class asIScriptFunction;
|
||||||
|
class asIScriptContext;
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
@ -14,10 +15,13 @@ namespace Deer {
|
|||||||
asIScriptFunction* renderFunction = nullptr;
|
asIScriptFunction* renderFunction = nullptr;
|
||||||
asIScriptFunction* menuBarFunction = nullptr;
|
asIScriptFunction* menuBarFunction = nullptr;
|
||||||
asIScriptFunction* initFunction = nullptr;
|
asIScriptFunction* initFunction = nullptr;
|
||||||
|
asIScriptContext* scriptContext = nullptr;
|
||||||
|
|
||||||
bool isValid = false;
|
bool isValid = false;
|
||||||
|
uint32_t flags = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DockPanelObject(asITypeInfo*);
|
DockPanelObject(asITypeInfo*, asIScriptContext*);
|
||||||
~DockPanelObject();
|
~DockPanelObject();
|
||||||
// Delete copy constructor
|
// Delete copy constructor
|
||||||
DockPanelObject(const DockPanelObject&) = delete;
|
DockPanelObject(const DockPanelObject&) = delete;
|
||||||
@ -26,18 +30,22 @@ namespace Deer {
|
|||||||
DockPanelObject(DockPanelObject&& other) noexcept;
|
DockPanelObject(DockPanelObject&& other) noexcept;
|
||||||
DockPanelObject& operator=(DockPanelObject&& other) noexcept;
|
DockPanelObject& operator=(DockPanelObject&& other) noexcept;
|
||||||
|
|
||||||
uint32_t flags = 0;
|
void setFlag(uint32_t, bool);
|
||||||
bool enabled = true;
|
bool getFlag(uint32_t);
|
||||||
|
|
||||||
void executeRender();
|
|
||||||
void invalidate();
|
void invalidate();
|
||||||
void init();
|
void init();
|
||||||
|
void render();
|
||||||
|
|
||||||
|
// TMP
|
||||||
|
int getRefCount();
|
||||||
|
|
||||||
const char* getName();
|
const char* getName();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DockPannelFlags {
|
enum DockPannelFlags {
|
||||||
DockPannelFlag_PannelPadding = 1 << 0
|
DockPannelFlag_PannelPadding = 1 << 0,
|
||||||
|
DockPannelFlag_ShowPannel = 1 << 1
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
#include "DeerStudio/EditorEngine.h"
|
||||||
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelInfo.h"
|
||||||
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
|
||||||
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
|
#include "Deer/Log.h"
|
||||||
|
|
||||||
|
#include "Deer/Path.h"
|
||||||
|
#include "Deer/DataStore.h"
|
||||||
|
|
||||||
|
#include "angelscript.h"
|
||||||
|
#include "scriptbuilder.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
namespace Deer {
|
||||||
|
namespace EditorEngine {
|
||||||
|
CScriptBuilder dockPanelScriptBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorEngine::loadDockPanels() {
|
||||||
|
Path path = DataStore::rootPath / DEER_EDITOR_PANEL_PATH;
|
||||||
|
|
||||||
|
if (!fs::exists(path) || !fs::is_directory(path)) {
|
||||||
|
DEER_EDITOR_ENGINE_ERROR("Could not find folder " DEER_EDITOR_PANEL_PATH);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEER_CORE_TRACE("Extracting UI Engine Scripts ");
|
||||||
|
for (const auto& _dir : fs::directory_iterator(path)) {
|
||||||
|
Path panelInfo_path = _dir.path() / "dockPanelModule.json";
|
||||||
|
|
||||||
|
// A panel info is neded to load a panel
|
||||||
|
if (!fs::exists(panelInfo_path) || !fs::is_regular_file(panelInfo_path)) {
|
||||||
|
DEER_EDITOR_ENGINE_WARN("Editor engine did not find dockPanelModule.json in folder {0}", panelInfo_path.c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DockPanelInfo* dockPanelInfo = loadDockPanelInfo(panelInfo_path);
|
||||||
|
if (dockPanelInfo->name == "null") {
|
||||||
|
DEER_EDITOR_ENGINE_ERROR("Failed to load dock panel module from {0},\n incorrect panelInfo.json file", path.string().c_str());
|
||||||
|
delete dockPanelInfo;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int r; r = dockPanelScriptBuilder.StartNewModule(scriptEngine, dockPanelInfo->name.c_str());
|
||||||
|
if (r < 0) {
|
||||||
|
DEER_EDITOR_ENGINE_ERROR("Failed to create module for dock panel module {0}", path.string().c_str());
|
||||||
|
delete dockPanelInfo;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& entry : fs::recursive_directory_iterator(_dir)) {
|
||||||
|
if (entry.is_regular_file() && entry.path().extension() == ".as") {
|
||||||
|
r = dockPanelScriptBuilder.AddSectionFromFile(entry.path().string().c_str());
|
||||||
|
if (r < 0) {
|
||||||
|
DEER_EDITOR_ENGINE_ERROR("Failed loading script for module {0}\nscript: {1}", path.string().c_str(), entry.path().string().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = dockPanelScriptBuilder.BuildModule();
|
||||||
|
if (r < 0) {
|
||||||
|
DEER_EDITOR_ENGINE_ERROR("Failed compiling module {0}", path.string().c_str());
|
||||||
|
delete dockPanelInfo;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
dockPanelModules.push_back(DockPanelContext(scriptEngine->GetModule(dockPanelInfo->name.c_str()), dockPanelInfo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,8 @@
|
|||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine/API.h"
|
#include "DeerStudio/EditorEngine/API.h"
|
||||||
|
|
||||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||||
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
|
|
||||||
#include "Deer/Log.h"
|
#include "Deer/Log.h"
|
||||||
@ -19,12 +20,12 @@ void extract_angelScript();
|
|||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
asIScriptEngine* scriptEngine = nullptr;
|
asIScriptEngine* scriptEngine = nullptr;
|
||||||
asIScriptModule* scriptModule = nullptr;
|
|
||||||
asIScriptContext* scriptContext = nullptr;
|
|
||||||
|
|
||||||
std::vector<DockPanelObject> dockPanels;
|
std::vector<DockPanelContext> dockPanelModules;
|
||||||
DockPanelObject* currentDockPanelExecution = nullptr;
|
DockPanelObject* currentDockPanelExecution = nullptr;
|
||||||
|
|
||||||
|
asIScriptContext* executingScriptContext;
|
||||||
|
|
||||||
bool active = false;
|
bool active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,47 +36,34 @@ namespace Deer {
|
|||||||
deinitialize();
|
deinitialize();
|
||||||
|
|
||||||
scriptEngine = asCreateScriptEngine();
|
scriptEngine = asCreateScriptEngine();
|
||||||
|
|
||||||
|
AS_RET_CHECK(scriptEngine->SetMessageCallback(asFUNCTION(Deer::EditorEngine::errorCallback), 0, asCALL_CDECL));
|
||||||
|
|
||||||
RegisterStdString(scriptEngine);
|
RegisterStdString(scriptEngine);
|
||||||
RegisterScriptArray(scriptEngine, true);
|
RegisterScriptArray(scriptEngine, true);
|
||||||
RegisterScriptDictionary(scriptEngine);
|
RegisterScriptDictionary(scriptEngine);
|
||||||
|
|
||||||
AS_RET_CHECK(scriptEngine->SetMessageCallback(asFUNCTION(Deer::EditorEngine::errorCallback), 0, asCALL_CDECL));
|
|
||||||
|
|
||||||
DEER_CORE_TRACE("Registering Editor Engine interface");
|
|
||||||
registerEditorEngineStructs();
|
registerEditorEngineStructs();
|
||||||
registerEditorEngineFunctions();
|
registerEditorEngineFunctions();
|
||||||
registerDockPanel();
|
|
||||||
|
|
||||||
loadScripts();
|
|
||||||
|
|
||||||
scriptModule = scriptEngine->GetModule("DeerModule");
|
|
||||||
scriptContext = scriptEngine->CreateContext();
|
|
||||||
|
|
||||||
|
// This is simply to generate the as.predefined for better experience
|
||||||
extract_angelScript();
|
extract_angelScript();
|
||||||
|
|
||||||
extractDockPanels();
|
loadDockPanels();
|
||||||
|
|
||||||
active = true;
|
active = true;
|
||||||
|
for (DockPanelContext& pannel : dockPanelModules)
|
||||||
for (auto& pannel : dockPanels) {
|
|
||||||
currentDockPanelExecution = &pannel;
|
|
||||||
pannel.init();
|
pannel.init();
|
||||||
}
|
|
||||||
currentDockPanelExecution = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorEngine::deinitialize() {
|
void EditorEngine::deinitialize() {
|
||||||
dockPanels.clear();
|
dockPanelModules.clear();
|
||||||
|
|
||||||
if (scriptContext)
|
|
||||||
scriptContext->Release();
|
|
||||||
if (scriptEngine)
|
if (scriptEngine)
|
||||||
scriptEngine->ShutDownAndRelease();
|
scriptEngine->ShutDownAndRelease();
|
||||||
|
|
||||||
scriptEngine = nullptr;
|
scriptEngine = nullptr;
|
||||||
scriptModule = nullptr;
|
|
||||||
scriptContext = nullptr;
|
|
||||||
|
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,10 +71,7 @@ namespace Deer {
|
|||||||
if (!active)
|
if (!active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto& panel : dockPanels) {
|
for (auto& panel : dockPanelModules)
|
||||||
currentDockPanelExecution = &panel;
|
panel.render();
|
||||||
panel.executeRender();
|
|
||||||
}
|
|
||||||
currentDockPanelExecution = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,19 +11,19 @@ namespace Deer {
|
|||||||
#define AS_CHECK(f) { \
|
#define AS_CHECK(f) { \
|
||||||
int __r = f; \
|
int __r = f; \
|
||||||
if (__r < 0) { \
|
if (__r < 0) { \
|
||||||
DEER_UI_ENGINE_ERROR("Error at line: {0}:{1} -> {2}", __FILE__, __LINE__, Deer::EditorEngine::getAngelScriptReturnCodeString(__r)); \
|
DEER_EDITOR_ENGINE_ERROR("Error at line: {0}:{1} -> {2}", __FILE__, __LINE__, Deer::EditorEngine::getAngelScriptReturnCodeString(__r)); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#define AS_CHECK_ADDITIONAL_INFO(f, i) { \
|
#define AS_CHECK_ADDITIONAL_INFO(f, i) { \
|
||||||
int __r = f; \
|
int __r = f; \
|
||||||
if (__r < 0) { \
|
if (__r < 0) { \
|
||||||
DEER_UI_ENGINE_ERROR("Error at line: {0}:{1} -> {2} \n {3}", __FILE__, __LINE__, Deer::EditorEngine::getAngelScriptReturnCodeString(__r), i); \
|
DEER_EDITOR_ENGINE_ERROR("Error at line: {0}:{1} -> {2} \n {3}", __FILE__, __LINE__, Deer::EditorEngine::getAngelScriptReturnCodeString(__r), i); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#define AS_RET_CHECK(f) { \
|
#define AS_RET_CHECK(f) { \
|
||||||
int __r = f; \
|
int __r = f; \
|
||||||
if (__r < 0) { \
|
if (__r < 0) { \
|
||||||
DEER_UI_ENGINE_ERROR("Error at line: {0}:{1} -> {2}", __FILE__, __LINE__, Deer::EditorEngine::getAngelScriptReturnCodeString(__r)); \
|
DEER_EDITOR_ENGINE_ERROR("Error at line: {0}:{1} -> {2}", __FILE__, __LINE__, Deer::EditorEngine::getAngelScriptReturnCodeString(__r)); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
#include "angelscript.h"
|
|
||||||
#include "DeerStudio/EditorEngine.h"
|
|
||||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
|
||||||
|
|
||||||
namespace Deer {
|
|
||||||
void EditorEngine::registerDockPanel() {
|
|
||||||
AS_RET_CHECK(scriptEngine->RegisterInterface("DockPanel"));
|
|
||||||
|
|
||||||
AS_RET_CHECK(scriptEngine->RegisterInterfaceMethod("DockPanel", "void onRender()"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorEngine::extractDockPanels() {
|
|
||||||
size_t nScripts = scriptModule->GetObjectTypeCount();
|
|
||||||
|
|
||||||
asITypeInfo* dockPanelType = scriptEngine->GetTypeInfoByName("DockPanel");
|
|
||||||
if (!dockPanelType) {
|
|
||||||
DEER_UI_ENGINE_ERROR("Could not load DockPanel interface type");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < nScripts; i++) {
|
|
||||||
asITypeInfo* info = scriptModule->GetObjectTypeByIndex(i);
|
|
||||||
|
|
||||||
// If it does not implement dock panel we are not interested int it
|
|
||||||
if (!info->Implements(dockPanelType))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dockPanels.push_back({info});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
#include "DeerStudio/EditorEngine.h"
|
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
|
||||||
|
|
||||||
#include "Deer/Path.h"
|
|
||||||
#include "Deer/DataStore.h"
|
|
||||||
|
|
||||||
#include "angelscript.h"
|
|
||||||
#include "scriptbuilder.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <filesystem>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
|
|
||||||
namespace Deer {
|
|
||||||
namespace EditorEngine {
|
|
||||||
CScriptBuilder builtContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorEngine::loadScripts() {
|
|
||||||
Path path = DataStore::rootPath / DEER_EDITOR_PATH;
|
|
||||||
|
|
||||||
AS_RET_CHECK(builtContext.StartNewModule(scriptEngine, "DeerModule"));
|
|
||||||
|
|
||||||
DEER_CORE_TRACE("Extracting UI Engine Scripts ");
|
|
||||||
for (const auto& entry : fs::recursive_directory_iterator(path)) {
|
|
||||||
if (entry.is_regular_file() && entry.path().extension() == ".as") {
|
|
||||||
//DEER_UI_ENGINE_TRACE("\t{0}", entry.path().stem().string().c_str());
|
|
||||||
// We add aditional info to check who caused the error
|
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
|
||||||
builtContext.AddSectionFromFile(entry.path().string().c_str());,
|
|
||||||
entry.path().string().c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AS_RET_CHECK(builtContext.BuildModule());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +1,44 @@
|
|||||||
#include "DeerStudio/DeerStudio.h"
|
#include "DeerStudio/DeerStudio.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||||
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace DeerStudio {
|
namespace DeerStudio {
|
||||||
void onPannelMenuBar() {
|
void panelEnable(EditorEngine::DockPanelObject& dpo);
|
||||||
if (ImGui::BeginMenu("Show/Hide")) {
|
|
||||||
for (EditorEngine::DockPanelObject& pannel : EditorEngine::dockPanels) {
|
|
||||||
const char* name = pannel.getName();
|
|
||||||
|
|
||||||
ImGui::MenuItem(name, nullptr, &pannel.enabled);
|
void onPannelMenuBar() {
|
||||||
|
if (ImGui::BeginMenu("Dock Panels Show/Hide")) {
|
||||||
|
for (EditorEngine::DockPanelContext& pc : EditorEngine::dockPanelModules) {
|
||||||
|
if (pc.dockPanels.size() == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pc.dockPanels.size() == 1){
|
||||||
|
panelEnable(pc.dockPanels[0]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* name = pc.getName();
|
||||||
|
if (ImGui::BeginMenu(name)) {
|
||||||
|
for (EditorEngine::DockPanelObject& panel : pc.dockPanels) {
|
||||||
|
panelEnable(panel);
|
||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void panelEnable(EditorEngine::DockPanelObject& dpo) {
|
||||||
|
const char* name = dpo.getName();
|
||||||
|
|
||||||
|
bool enabled = dpo.getFlag(DockPannelFlag_ShowPannel);
|
||||||
|
if (ImGui::MenuItem(name, nullptr, enabled)) {
|
||||||
|
dpo.setFlag(DockPannelFlag_ShowPannel, !enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user