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/ImGuizmo",
|
||||
"../Deer/vendor/entt/include",
|
||||
"../Deer/vendor/angelScript/include"
|
||||
"../Deer/vendor/angelScript/include",
|
||||
"../Deer/vendor/cereal/include"
|
||||
}
|
||||
|
||||
links
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Window][DockSpace Demo]
|
||||
Pos=0,0
|
||||
Size=2560,1371
|
||||
Size=1280,720
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug##Default]
|
||||
@ -9,8 +9,8 @@ Size=400,400
|
||||
Collapsed=0
|
||||
|
||||
[Window][Terrain Editor]
|
||||
Pos=2249,24
|
||||
Size=311,1128
|
||||
Pos=969,24
|
||||
Size=311,477
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
@ -21,47 +21,52 @@ Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
|
||||
[Window][ViewportPannel]
|
||||
Pos=312,24
|
||||
Size=1935,1128
|
||||
Pos=265,24
|
||||
Size=702,477
|
||||
Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
|
||||
[Window][ShaderExplorer]
|
||||
Pos=0,1154
|
||||
Size=2560,217
|
||||
Pos=0,503
|
||||
Size=1280,217
|
||||
Collapsed=0
|
||||
DockId=0x00000004,1
|
||||
DockId=0x00000004,0
|
||||
|
||||
[Window][TreePannel]
|
||||
Pos=0,24
|
||||
Size=310,1128
|
||||
Size=263,477
|
||||
Collapsed=0
|
||||
DockId=0x00000001,0
|
||||
|
||||
[Window][MeshExplorer]
|
||||
Pos=0,1154
|
||||
Size=2560,217
|
||||
Pos=0,503
|
||||
Size=1280,217
|
||||
Collapsed=0
|
||||
DockId=0x00000004,0
|
||||
DockId=0x00000004,1
|
||||
|
||||
[Window][PropertiesPannel]
|
||||
Pos=2249,24
|
||||
Size=311,1128
|
||||
Pos=969,24
|
||||
Size=311,477
|
||||
Collapsed=0
|
||||
DockId=0x00000006,1
|
||||
|
||||
[Window][CameraPannel]
|
||||
Pos=312,24
|
||||
Size=1935,1128
|
||||
Pos=265,24
|
||||
Size=702,477
|
||||
Collapsed=0
|
||||
DockId=0x00000005,1
|
||||
|
||||
[Window][MU]
|
||||
Pos=60,60
|
||||
Size=40,64
|
||||
Collapsed=0
|
||||
|
||||
[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=0x00000001 Parent=0x00000003 SizeRef=310,696 Selected=0xE45B9F93
|
||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=2248,696 Split=X Selected=0x34A4C10F
|
||||
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=1935,454 CentralNode=1 Selected=0x34A4C10F
|
||||
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=263,696 Selected=0xE45B9F93
|
||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1015,696 Split=X 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=0x00000004 Parent=0xA1672E74 SizeRef=1280,217 Selected=0xD962995A
|
||||
|
||||
|
@ -10,7 +10,8 @@ class CScriptBuilder;
|
||||
namespace Deer {
|
||||
// This namespace implements all interface ported from c++ ImGui to an easier lua aproach with simplifications
|
||||
namespace EditorEngine {
|
||||
struct DockPanelObject;
|
||||
class DockPanelContext;
|
||||
class DockPanelObject;
|
||||
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
@ -18,18 +19,18 @@ namespace Deer {
|
||||
void render();
|
||||
|
||||
// INTERNAL
|
||||
// Panels
|
||||
extern asIScriptEngine* scriptEngine;
|
||||
extern asIScriptModule* scriptModule;
|
||||
extern asIScriptContext* scriptContext;
|
||||
extern CScriptBuilder builtContext;
|
||||
extern std::vector<DockPanelObject> dockPanels;
|
||||
extern asIScriptContext* executingScriptContext;
|
||||
extern CScriptBuilder dockPanelScriptBuilder;
|
||||
|
||||
extern std::vector<DockPanelContext> dockPanelModules;
|
||||
extern DockPanelObject* currentDockPanelExecution;
|
||||
|
||||
void loadScripts();
|
||||
void loadDockPanels();
|
||||
void registerEditorEngineFunctions();
|
||||
void registerEditorEngineStructs();
|
||||
void registerDockPanel();
|
||||
void extractDockPanels();
|
||||
}
|
||||
|
||||
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) {
|
||||
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 ) {
|
||||
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){
|
||||
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) {
|
||||
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/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine.h"
|
||||
|
||||
#include "DeerRender/Components.h"
|
||||
@ -40,7 +40,7 @@ namespace Deer {
|
||||
|
||||
bool EntityHandleStruct::assertEntity(const char* funcName) {
|
||||
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)
|
||||
currentDockPanelExecution->invalidate();
|
||||
return false;
|
||||
@ -174,7 +174,7 @@ namespace Deer {
|
||||
Entity& ent = Scene::environment.getEntity(entityId);
|
||||
|
||||
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,
|
||||
ent.getComponent<TagComponent>().tag.c_str(),
|
||||
entityId
|
||||
@ -195,7 +195,7 @@ namespace Deer {
|
||||
.getComponent<RelationshipComponent>();
|
||||
|
||||
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)
|
||||
currentDockPanelExecution->invalidate();
|
||||
|
||||
@ -406,7 +406,7 @@ namespace Deer {
|
||||
Entity& ent = Scene::environment.getEntity(entityId);
|
||||
|
||||
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,
|
||||
ent.getComponent<TagComponent>().tag.c_str(),
|
||||
entityId
|
||||
@ -445,7 +445,7 @@ namespace Deer {
|
||||
Entity& ent = Scene::environment.getEntity(entityId);
|
||||
|
||||
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,
|
||||
ent.getComponent<TagComponent>().tag.c_str(),
|
||||
entityId
|
||||
|
@ -19,7 +19,6 @@ namespace Deer {
|
||||
}
|
||||
|
||||
bool treeNodeRecursive(std::string& txt, bool active, CScriptAny *data, asIScriptFunction& func) {
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnDoubleClick |
|
||||
ImGuiTreeNodeFlags_OpenOnArrow |
|
||||
@ -31,23 +30,23 @@ namespace Deer {
|
||||
|
||||
if (ImGui::TreeNodeEx(txt.c_str(), flags)) {
|
||||
ImGui::PushID(txt.c_str());
|
||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
||||
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Prepare(&func),
|
||||
executingScriptContext->Prepare(&func),
|
||||
func.GetDeclaration()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->SetArgObject(0, data),
|
||||
executingScriptContext->SetArgObject(0, data),
|
||||
func.GetDeclaration()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Execute(),
|
||||
executingScriptContext->Execute(),
|
||||
func.GetDeclaration()
|
||||
);
|
||||
|
||||
scriptContext->PopState();
|
||||
executingScriptContext->PopState();
|
||||
} else {
|
||||
ImGui::Text("Something failed");
|
||||
}
|
||||
@ -78,15 +77,15 @@ namespace Deer {
|
||||
if (ImGui::TreeNodeEx(txt.c_str(), flags)){
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
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 {
|
||||
ImGui::Text("Something failed");
|
||||
}
|
||||
@ -117,15 +116,15 @@ namespace Deer {
|
||||
if (ImGui::TreeNodeEx(txt.c_str(), flags)){
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
||||
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 {
|
||||
ImGui::Text("Something failed");
|
||||
}
|
||||
@ -135,15 +134,15 @@ namespace Deer {
|
||||
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
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 {
|
||||
ImGui::Text("Something failed");
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "DeerStudio/EditorEngine/API/Menu.h"
|
||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine.h"
|
||||
#include "angelscript.h"
|
||||
#include "scriptany.h"
|
||||
@ -17,15 +17,15 @@ namespace Deer {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
||||
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 {
|
||||
ImGui::Text("Something failed");
|
||||
}
|
||||
@ -39,15 +39,15 @@ namespace Deer {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
||||
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 {
|
||||
ImGui::Text("Something failed");
|
||||
}
|
||||
@ -94,14 +94,14 @@ namespace Deer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
||||
AS_CHECK(scriptContext->Prepare(func));
|
||||
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||
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 {
|
||||
ImGui::Text("Something failed");
|
||||
}
|
||||
@ -140,14 +140,14 @@ namespace Deer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
|
||||
AS_CHECK(scriptContext->Prepare(func));
|
||||
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
|
||||
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 {
|
||||
ImGui::Text("Something failed");
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "DeerStudio/EditorEngine/API/Resource.h"
|
||||
#include "DeerStudio/EditorEngine.h"
|
||||
#include "Deer/DataStore.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||
#include "Deer/Log.h"
|
||||
|
||||
namespace Deer {
|
||||
@ -60,7 +60,7 @@ namespace Deer {
|
||||
const char* resourceExtension = getResourceExtension(type);
|
||||
|
||||
if (!resourcePath || !resourceExtension) {
|
||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getResourceCount(..)");
|
||||
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getResourceCount(..)");
|
||||
if (currentDockPanelExecution) {
|
||||
currentDockPanelExecution->invalidate();
|
||||
}
|
||||
@ -75,7 +75,7 @@ namespace Deer {
|
||||
const char* resourceExtension = getResourceExtension(type);
|
||||
|
||||
if (!resourcePath || !resourceExtension) {
|
||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getResourceNameById(..)");
|
||||
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getResourceNameById(..)");
|
||||
if (currentDockPanelExecution) {
|
||||
currentDockPanelExecution->invalidate();
|
||||
}
|
||||
@ -84,7 +84,7 @@ namespace Deer {
|
||||
|
||||
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
||||
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),
|
||||
dir.c_str(),
|
||||
dirData.elements.size(),
|
||||
@ -104,7 +104,7 @@ namespace Deer {
|
||||
const char* resourceExtension = getResourceExtension(type);
|
||||
|
||||
if (!resourcePath || !resourceExtension) {
|
||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getResourcePathById(..)");
|
||||
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getResourcePathById(..)");
|
||||
if (currentDockPanelExecution) {
|
||||
currentDockPanelExecution->invalidate();
|
||||
}
|
||||
@ -113,7 +113,7 @@ namespace Deer {
|
||||
|
||||
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
||||
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),
|
||||
dir.c_str(),
|
||||
dirData.elements.size(),
|
||||
@ -133,7 +133,7 @@ namespace Deer {
|
||||
const char* resourceExtension = getResourceExtension(type);
|
||||
|
||||
if (!resourcePath || !resourceExtension) {
|
||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getDirCount(..)");
|
||||
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getDirCount(..)");
|
||||
if (currentDockPanelExecution) {
|
||||
currentDockPanelExecution->invalidate();
|
||||
}
|
||||
@ -148,7 +148,7 @@ namespace Deer {
|
||||
const char* resourceExtension = getResourceExtension(type);
|
||||
|
||||
if (!resourcePath || !resourceExtension) {
|
||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getDirPathById(..)");
|
||||
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getDirPathById(..)");
|
||||
if (currentDockPanelExecution) {
|
||||
currentDockPanelExecution->invalidate();
|
||||
}
|
||||
@ -157,7 +157,7 @@ namespace Deer {
|
||||
|
||||
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
||||
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),
|
||||
dir.c_str(),
|
||||
dirData.dirs.size(),
|
||||
@ -177,7 +177,7 @@ namespace Deer {
|
||||
const char* resourceExtension = getResourceExtension(type);
|
||||
|
||||
if (!resourcePath || !resourceExtension) {
|
||||
DEER_UI_ENGINE_ERROR("Invalid resource type calling getDirNameById(..)");
|
||||
DEER_EDITOR_ENGINE_ERROR("Invalid resource type calling getDirNameById(..)");
|
||||
if (currentDockPanelExecution) {
|
||||
currentDockPanelExecution->invalidate();
|
||||
}
|
||||
@ -186,7 +186,7 @@ namespace Deer {
|
||||
|
||||
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
|
||||
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),
|
||||
dir.c_str(),
|
||||
dirData.dirs.size(),
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "DeerStudio/EditorEngine/API/UI.h"
|
||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine.h"
|
||||
#include "DeerRender/FrameBuffer.h"
|
||||
#include "Deer/Log.h"
|
||||
@ -139,7 +139,7 @@ namespace Deer {
|
||||
int iconId = DataStore::getIconId(name);
|
||||
|
||||
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) {
|
||||
currentDockPanelExecution->invalidate();
|
||||
}
|
||||
@ -186,7 +186,7 @@ namespace Deer {
|
||||
void drawIconCentered(std::string& name, int size) {
|
||||
int iconId = DataStore::getIconId(name);
|
||||
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) {
|
||||
currentDockPanelExecution->invalidate();
|
||||
}
|
||||
@ -223,15 +223,15 @@ namespace Deer {
|
||||
void menuSpace(std::string& txt, CScriptAny* data ,asIScriptFunction* func) {
|
||||
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();
|
||||
@ -270,17 +270,17 @@ namespace Deer {
|
||||
if (ImGui::BeginDragDropTarget()) {
|
||||
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();
|
||||
@ -487,9 +487,7 @@ namespace Deer {
|
||||
|
||||
void disablePannelPadding(bool value) {
|
||||
if (currentDockPanelExecution) {
|
||||
if (value != (currentDockPanelExecution->flags & DockPannelFlag_PannelPadding)){
|
||||
currentDockPanelExecution->flags ^= DockPannelFlag_PannelPadding;
|
||||
}
|
||||
currentDockPanelExecution->setFlag(DockPannelFlag_PannelPadding, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "DeerStudio/EditorEngine.h"
|
||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||
#include "DeerStudio/EditorEngine/API.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||
|
||||
#include "scripthandle.h"
|
||||
#include "scriptany.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "DeerStudio/EditorEngine/API/Environment.h"
|
||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||
#include "DeerStudio/EditorEngine.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||
|
||||
#include "angelscript.h"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "DeerStudio/EditorEngine/API/FrameBuffer.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 "angelscript.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "DeerStudio/EditorEngine.h"
|
||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||
#include "DeerStudio/EditorEngine/API.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||
|
||||
#include "scripthandle.h"
|
||||
#include "scriptany.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "DeerStudio/EditorEngine/API.h"
|
||||
#include "DeerStudio/EditorEngine.h"
|
||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||
|
||||
#include "angelscript.h"
|
||||
|
||||
|
@ -27,6 +27,14 @@ namespace Deer {
|
||||
registerMathStructs();
|
||||
registerFrameBufferStructs();
|
||||
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/ErrorHandle.h"
|
||||
#include "DeerStudio/EditorEngine/API.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration.h"
|
||||
#include "DeerStudio/EditorEngine/API_Registration/API_Registration.h"
|
||||
|
||||
#include "scripthandle.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.h"
|
||||
|
||||
@ -10,39 +10,44 @@
|
||||
#include "imgui.h"
|
||||
|
||||
namespace Deer {
|
||||
EditorEngine::DockPanelObject::DockPanelObject(asITypeInfo* _type)
|
||||
: type (_type), isValid(false) {
|
||||
EditorEngine::DockPanelObject::DockPanelObject(asITypeInfo* _type, asIScriptContext* _scriptContext)
|
||||
: type (_type), isValid(false), scriptContext(_scriptContext){
|
||||
|
||||
// Constructor
|
||||
// "type@ type()"
|
||||
std::string callString(type->GetName());
|
||||
callString += " @";
|
||||
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_ADDITIONAL_INFO(
|
||||
scriptContext->Prepare(factory),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Execute(),
|
||||
type->GetName()
|
||||
);
|
||||
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_UI_ENGINE_ERROR("Could not create object", _type->GetName());
|
||||
DEER_EDITOR_ENGINE_ERROR("Could not create object", type->GetName());
|
||||
return;
|
||||
}
|
||||
object->AddRef();
|
||||
|
||||
renderFunction = type->GetMethodByDecl("void onRender()");
|
||||
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;
|
||||
}
|
||||
|
||||
@ -50,6 +55,19 @@ namespace Deer {
|
||||
initFunction = type->GetMethodByDecl("void onInit()");
|
||||
|
||||
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() {
|
||||
@ -57,36 +75,33 @@ namespace Deer {
|
||||
}
|
||||
|
||||
EditorEngine::DockPanelObject::~DockPanelObject() {
|
||||
if (object)
|
||||
if (object)
|
||||
object->Release();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void EditorEngine::DockPanelObject::init() {
|
||||
void EditorEngine::DockPanelObject::init() {
|
||||
|
||||
if (!initFunction)
|
||||
return;
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Prepare(initFunction),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->SetObject(object),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Execute(),
|
||||
type->GetName()
|
||||
);
|
||||
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::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
|
||||
bool hasPadding = flags & DockPannelFlag_PannelPadding;
|
||||
if (hasPadding)
|
||||
@ -96,20 +111,12 @@ namespace Deer {
|
||||
ImGui::Begin(type->GetName(), (bool*)0, ImGuiWindowFlags_MenuBar);
|
||||
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Prepare(menuBarFunction),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->SetObject(object),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Execute(),
|
||||
type->GetName()
|
||||
);
|
||||
executingScriptContext = scriptContext;
|
||||
AS_CHECK(scriptContext->Prepare(menuBarFunction));
|
||||
AS_CHECK(scriptContext->SetObject(object));
|
||||
AS_CHECK(scriptContext->Execute());
|
||||
AS_CHECK(scriptContext->Unprepare());
|
||||
executingScriptContext = nullptr;
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
@ -131,20 +138,12 @@ namespace Deer {
|
||||
return;
|
||||
}
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Prepare(renderFunction),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->SetObject(object),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Execute(),
|
||||
type->GetName()
|
||||
);
|
||||
executingScriptContext = scriptContext;
|
||||
AS_CHECK(scriptContext->Prepare(renderFunction));
|
||||
AS_CHECK(scriptContext->SetObject(object));
|
||||
AS_CHECK(scriptContext->Execute());
|
||||
AS_CHECK(scriptContext->Unprepare());
|
||||
executingScriptContext = nullptr;
|
||||
|
||||
ImGui::End();
|
||||
|
||||
@ -153,7 +152,14 @@ namespace Deer {
|
||||
}
|
||||
|
||||
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.renderFunction = nullptr;
|
||||
@ -161,16 +167,22 @@ namespace Deer {
|
||||
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;
|
||||
@ -178,9 +190,18 @@ namespace Deer {
|
||||
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;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
class asITypeInfo;
|
||||
class asIScriptObject;
|
||||
class asIScriptFunction;
|
||||
class asIScriptContext;
|
||||
|
||||
namespace Deer {
|
||||
namespace EditorEngine {
|
||||
@ -14,10 +15,13 @@ namespace Deer {
|
||||
asIScriptFunction* renderFunction = nullptr;
|
||||
asIScriptFunction* menuBarFunction = nullptr;
|
||||
asIScriptFunction* initFunction = nullptr;
|
||||
asIScriptContext* scriptContext = nullptr;
|
||||
|
||||
bool isValid = false;
|
||||
uint32_t flags = 0;
|
||||
|
||||
public:
|
||||
DockPanelObject(asITypeInfo*);
|
||||
DockPanelObject(asITypeInfo*, asIScriptContext*);
|
||||
~DockPanelObject();
|
||||
// Delete copy constructor
|
||||
DockPanelObject(const DockPanelObject&) = delete;
|
||||
@ -26,18 +30,22 @@ namespace Deer {
|
||||
DockPanelObject(DockPanelObject&& other) noexcept;
|
||||
DockPanelObject& operator=(DockPanelObject&& other) noexcept;
|
||||
|
||||
uint32_t flags = 0;
|
||||
bool enabled = true;
|
||||
|
||||
void executeRender();
|
||||
void setFlag(uint32_t, bool);
|
||||
bool getFlag(uint32_t);
|
||||
|
||||
void invalidate();
|
||||
void init();
|
||||
void render();
|
||||
|
||||
// TMP
|
||||
int getRefCount();
|
||||
|
||||
const char* getName();
|
||||
};
|
||||
}
|
||||
|
||||
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/API.h"
|
||||
|
||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
|
||||
#include "DeerStudio/EditorEngine.h"
|
||||
|
||||
#include "Deer/Log.h"
|
||||
@ -19,12 +20,12 @@ void extract_angelScript();
|
||||
namespace Deer {
|
||||
namespace EditorEngine {
|
||||
asIScriptEngine* scriptEngine = nullptr;
|
||||
asIScriptModule* scriptModule = nullptr;
|
||||
asIScriptContext* scriptContext = nullptr;
|
||||
|
||||
std::vector<DockPanelObject> dockPanels;
|
||||
std::vector<DockPanelContext> dockPanelModules;
|
||||
DockPanelObject* currentDockPanelExecution = nullptr;
|
||||
|
||||
asIScriptContext* executingScriptContext;
|
||||
|
||||
bool active = false;
|
||||
}
|
||||
|
||||
@ -35,47 +36,34 @@ namespace Deer {
|
||||
deinitialize();
|
||||
|
||||
scriptEngine = asCreateScriptEngine();
|
||||
|
||||
AS_RET_CHECK(scriptEngine->SetMessageCallback(asFUNCTION(Deer::EditorEngine::errorCallback), 0, asCALL_CDECL));
|
||||
|
||||
RegisterStdString(scriptEngine);
|
||||
RegisterScriptArray(scriptEngine, true);
|
||||
RegisterScriptDictionary(scriptEngine);
|
||||
|
||||
AS_RET_CHECK(scriptEngine->SetMessageCallback(asFUNCTION(Deer::EditorEngine::errorCallback), 0, asCALL_CDECL));
|
||||
|
||||
DEER_CORE_TRACE("Registering Editor Engine interface");
|
||||
registerEditorEngineStructs();
|
||||
registerEditorEngineFunctions();
|
||||
registerDockPanel();
|
||||
|
||||
loadScripts();
|
||||
|
||||
scriptModule = scriptEngine->GetModule("DeerModule");
|
||||
scriptContext = scriptEngine->CreateContext();
|
||||
|
||||
// This is simply to generate the as.predefined for better experience
|
||||
extract_angelScript();
|
||||
|
||||
extractDockPanels();
|
||||
loadDockPanels();
|
||||
|
||||
active = true;
|
||||
|
||||
for (auto& pannel : dockPanels) {
|
||||
currentDockPanelExecution = &pannel;
|
||||
for (DockPanelContext& pannel : dockPanelModules)
|
||||
pannel.init();
|
||||
}
|
||||
currentDockPanelExecution = nullptr;
|
||||
|
||||
}
|
||||
|
||||
void EditorEngine::deinitialize() {
|
||||
dockPanels.clear();
|
||||
dockPanelModules.clear();
|
||||
|
||||
if (scriptContext)
|
||||
scriptContext->Release();
|
||||
if (scriptEngine)
|
||||
scriptEngine->ShutDownAndRelease();
|
||||
|
||||
scriptEngine = nullptr;
|
||||
scriptModule = nullptr;
|
||||
scriptContext = nullptr;
|
||||
|
||||
active = false;
|
||||
}
|
||||
|
||||
@ -83,10 +71,7 @@ namespace Deer {
|
||||
if (!active)
|
||||
return;
|
||||
|
||||
for (auto& panel : dockPanels) {
|
||||
currentDockPanelExecution = &panel;
|
||||
panel.executeRender();
|
||||
}
|
||||
currentDockPanelExecution = nullptr;
|
||||
for (auto& panel : dockPanelModules)
|
||||
panel.render();
|
||||
}
|
||||
}
|
@ -11,19 +11,19 @@ namespace Deer {
|
||||
#define AS_CHECK(f) { \
|
||||
int __r = f; \
|
||||
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) { \
|
||||
int __r = f; \
|
||||
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) { \
|
||||
int __r = f; \
|
||||
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; \
|
||||
} \
|
||||
}
|
||||
|
@ -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/EditorEngine.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
|
||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
namespace Deer {
|
||||
namespace DeerStudio {
|
||||
void panelEnable(EditorEngine::DockPanelObject& dpo);
|
||||
|
||||
void onPannelMenuBar() {
|
||||
if (ImGui::BeginMenu("Show/Hide")) {
|
||||
for (EditorEngine::DockPanelObject& pannel : EditorEngine::dockPanels) {
|
||||
const char* name = pannel.getName();
|
||||
if (ImGui::BeginMenu("Dock Panels Show/Hide")) {
|
||||
for (EditorEngine::DockPanelContext& pc : EditorEngine::dockPanelModules) {
|
||||
if (pc.dockPanels.size() == 0)
|
||||
continue;
|
||||
|
||||
ImGui::MenuItem(name, nullptr, &pannel.enabled);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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