Changes
This commit is contained in:
parent
7adbc97ff2
commit
9ca8377b7e
@ -1,6 +1,6 @@
|
|||||||
[Window][DockSpace Demo]
|
[Window][DockSpace Demo]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
Size=1280,720
|
Size=2560,1371
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
@ -9,44 +9,44 @@ Size=400,400
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Terrain Editor]
|
[Window][Terrain Editor]
|
||||||
Pos=969,24
|
Pos=2107,24
|
||||||
Size=311,477
|
Size=453,1012
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
[Window][Viewport]
|
[Window][Viewport]
|
||||||
Pos=299,24
|
Pos=440,24
|
||||||
Size=668,477
|
Size=1665,1012
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][ViewportPannel]
|
[Window][ViewportPannel]
|
||||||
Pos=265,24
|
Pos=440,24
|
||||||
Size=702,477
|
Size=1665,1012
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,0
|
DockId=0x00000005,1
|
||||||
|
|
||||||
[Window][ShaderExplorer]
|
[Window][ShaderExplorer]
|
||||||
Pos=0,503
|
Pos=0,1038
|
||||||
Size=1280,217
|
Size=2560,333
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,1
|
||||||
|
|
||||||
[Window][TreePannel]
|
[Window][TreePannel]
|
||||||
Pos=0,24
|
Pos=0,24
|
||||||
Size=263,477
|
Size=438,1012
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000001,0
|
DockId=0x00000001,0
|
||||||
|
|
||||||
[Window][MeshExplorer]
|
[Window][MeshExplorer]
|
||||||
Pos=0,503
|
Pos=0,1038
|
||||||
Size=1280,217
|
Size=2560,333
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,1
|
DockId=0x00000004,0
|
||||||
|
|
||||||
[Window][PropertiesPannel]
|
[Window][PropertiesPannel]
|
||||||
Pos=969,24
|
Pos=2107,24
|
||||||
Size=311,477
|
Size=453,1012
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,1
|
DockId=0x00000006,1
|
||||||
|
|
||||||
@ -61,12 +61,17 @@ Pos=60,60
|
|||||||
Size=40,64
|
Size=40,64
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Docking][Data]
|
[Window][Rename entity]
|
||||||
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y Selected=0x34A4C10F
|
Pos=1228,651
|
||||||
DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,477 Split=X
|
Size=104,68
|
||||||
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=263,696 Selected=0xE45B9F93
|
Collapsed=0
|
||||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1015,696 Split=X Selected=0x34A4C10F
|
|
||||||
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=702,454 CentralNode=1 Selected=0x34A4C10F
|
[Docking][Data]
|
||||||
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=311,454 Selected=0xA35A27E3
|
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=2560,1347 Split=Y Selected=0x34A4C10F
|
||||||
DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,217 Selected=0xD962995A
|
DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,1012 Split=X
|
||||||
|
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=438,696 Selected=0xE45B9F93
|
||||||
|
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=2120,696 Split=X Selected=0x34A4C10F
|
||||||
|
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=1665,454 CentralNode=1 Selected=0x34A4C10F
|
||||||
|
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=453,454 Selected=0xA35A27E3
|
||||||
|
DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,333 Selected=0xD962995A
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ namespace Deer {
|
|||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
TerrainEditor::onImGui();
|
TerrainEditor::onImGui();
|
||||||
//viewport_onImGui();
|
viewport_onImGui();
|
||||||
EditorEngine::render();
|
EditorEngine::render();
|
||||||
|
|
||||||
Scene::gizmoRenderer.refresh();
|
Scene::gizmoRenderer.refresh();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptInfo.h"
|
||||||
|
|
||||||
#include "Deer/Path.h"
|
#include "Deer/Path.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
@ -8,6 +11,7 @@ namespace Deer {
|
|||||||
std::string name = "null";
|
std::string name = "null";
|
||||||
std::string author = "";
|
std::string author = "";
|
||||||
std::string version = "0.0.0";
|
std::string version = "0.0.0";
|
||||||
|
std::vector<ServiceScriptRef> services;
|
||||||
};
|
};
|
||||||
|
|
||||||
DockPanelInfo* loadDockPanelInfo(Path panelInfo);
|
DockPanelInfo* loadDockPanelInfo(Path panelInfo);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "cereal/cereal.hpp"
|
#include "cereal/cereal.hpp"
|
||||||
#include "cereal/archives/json.hpp"
|
#include "cereal/archives/json.hpp"
|
||||||
#include "cereal/types/string.hpp"
|
#include "cereal/types/string.hpp"
|
||||||
|
#include "cereal/types/vector.hpp"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -16,6 +17,13 @@ namespace Deer {
|
|||||||
ar(cereal::make_nvp("name", data.name));
|
ar(cereal::make_nvp("name", data.name));
|
||||||
ar(cereal::make_nvp("author", data.author));
|
ar(cereal::make_nvp("author", data.author));
|
||||||
ar(cereal::make_nvp("version", data.version));
|
ar(cereal::make_nvp("version", data.version));
|
||||||
|
ar(cereal::make_nvp("services", data.services));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Archive>
|
||||||
|
void serialize(Archive& ar, ServiceScriptRef& data) {
|
||||||
|
ar(cereal::make_nvp("name", data.name));
|
||||||
|
ar(cereal::make_nvp("version", data.version));
|
||||||
}
|
}
|
||||||
|
|
||||||
DockPanelInfo* loadDockPanelInfo(Path dockPanelInfoPath) {
|
DockPanelInfo* loadDockPanelInfo(Path dockPanelInfoPath) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelInfo.h"
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelInfo.h"
|
||||||
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
|
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
|
||||||
|
#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptContext.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "Deer/Log.h"
|
#include "Deer/Log.h"
|
||||||
|
|
||||||
@ -20,7 +21,20 @@ namespace fs = std::filesystem;
|
|||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
CScriptBuilder scriptBuilder;
|
CScriptBuilder scriptBuilder;
|
||||||
|
|
||||||
|
ServiceScriptContext* getServiceScriptContext(const ServiceScriptRef& ref) {
|
||||||
|
for (ServiceScriptContext& ctx : serviceScriptModules) {
|
||||||
|
const ServiceScriptInfo& info = ctx.getInfo();
|
||||||
|
|
||||||
|
if (info.name == ref.name && info.version == ref.version) {
|
||||||
|
return &ctx;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditorEngine::loadDockPanels() {
|
void EditorEngine::loadDockPanels() {
|
||||||
Path path = DataStore::rootPath / DEER_EDITOR_PANEL_PATH;
|
Path path = DataStore::rootPath / DEER_EDITOR_PANEL_PATH;
|
||||||
@ -54,6 +68,20 @@ namespace Deer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asIScriptModule* module = scriptBuilder.GetModule();
|
||||||
|
|
||||||
|
// Extract apis
|
||||||
|
for (const ServiceScriptRef& serviceRef : dockPanelInfo->services) {
|
||||||
|
ServiceScriptContext* ctx = getServiceScriptContext(serviceRef);
|
||||||
|
|
||||||
|
if (ctx == nullptr) {
|
||||||
|
DEER_EDITOR_ENGINE_ERROR("Editor engine could not find the Service with name {0} and version {1}", serviceRef.name.c_str(), serviceRef.version.c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->bindFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto& entry : fs::recursive_directory_iterator(_dir)) {
|
for (const auto& entry : fs::recursive_directory_iterator(_dir)) {
|
||||||
if (entry.is_regular_file() && entry.path().extension() == ".as") {
|
if (entry.is_regular_file() && entry.path().extension() == ".as") {
|
||||||
r = scriptBuilder.AddSectionFromFile(entry.path().string().c_str());
|
r = scriptBuilder.AddSectionFromFile(entry.path().string().c_str());
|
||||||
@ -70,7 +98,7 @@ namespace Deer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dockPanelModules.push_back(DockPanelContext(scriptEngine->GetModule(dockPanelInfo->name.c_str()), dockPanelInfo));
|
dockPanelModules.push_back({module, dockPanelInfo});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -75,5 +75,19 @@ namespace Deer {
|
|||||||
scriptService.init();
|
scriptService.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServiceScriptContext::bindFunctions() {
|
||||||
|
std::string ns;
|
||||||
|
ns = info->author + "::" + info->name +"::" + info->name;
|
||||||
|
|
||||||
|
DEER_CORE_INFO(ns.c_str());
|
||||||
|
|
||||||
|
scriptEngine->SetDefaultNamespace(ns.c_str());
|
||||||
|
for (ServiceScriptObject& object : scriptServices) {
|
||||||
|
object.bindFunctions();
|
||||||
|
}
|
||||||
|
scriptEngine->SetDefaultNamespace("");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,7 +22,10 @@ namespace Deer {
|
|||||||
void update();
|
void update();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
void bindFunctions();
|
||||||
|
|
||||||
inline const char* getName() const { return info->name.c_str(); }
|
inline const char* getName() const { return info->name.c_str(); }
|
||||||
|
inline const ServiceScriptInfo& getInfo() const { return *info; }
|
||||||
|
|
||||||
std::vector<ServiceScriptObject> scriptServices;
|
std::vector<ServiceScriptObject> scriptServices;
|
||||||
private:
|
private:
|
||||||
|
@ -10,6 +10,11 @@ namespace Deer {
|
|||||||
std::string version = "0.0.0";
|
std::string version = "0.0.0";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ServiceScriptRef {
|
||||||
|
std::string name = "";
|
||||||
|
std::string version = "0.0.0";
|
||||||
|
};
|
||||||
|
|
||||||
ServiceScriptInfo* loadServiceScriptInfo(Path panelInfo);
|
ServiceScriptInfo* loadServiceScriptInfo(Path panelInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,12 @@
|
|||||||
#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.h"
|
#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.h"
|
||||||
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
#include "DeerStudio/EditorEngine/ErrorHandle.h"
|
||||||
#include "DeerStudio/EditorEngine.h"
|
#include "DeerStudio/EditorEngine.h"
|
||||||
|
|
||||||
#include "angelscript.h"
|
#include "angelscript.h"
|
||||||
|
#include "scriptbuilder.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
@ -70,9 +73,6 @@ namespace Deer {
|
|||||||
AS_CHECK(scriptContext->Unprepare());
|
AS_CHECK(scriptContext->Unprepare());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ServiceScriptObject::getName() {
|
|
||||||
return type->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
ServiceScriptObject::ServiceScriptObject(ServiceScriptObject&& other) noexcept {
|
ServiceScriptObject::ServiceScriptObject(ServiceScriptObject&& other) noexcept {
|
||||||
type = other.type;
|
type = other.type;
|
||||||
@ -104,5 +104,65 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServiceScriptObject::bindFunctions() {
|
||||||
|
for (int i = 0; i < type->GetMethodCount(); i++) {
|
||||||
|
asIScriptFunction* func = type->GetMethodByIndex(i);
|
||||||
|
std::vector<std::string> metadata = scriptBuilder.GetMetadataForTypeMethod(type->GetTypeId(), func);
|
||||||
|
|
||||||
|
bool containsServiceAPI = false;
|
||||||
|
for (std::string& str : metadata) {
|
||||||
|
if (str != "ServiceAPI")
|
||||||
|
continue;
|
||||||
|
containsServiceAPI = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!containsServiceAPI)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
DEER_CORE_INFO("Registering function from object {0}.{1}", type->GetName(), func->GetName());
|
||||||
|
|
||||||
|
asITypeInfo* retType = EditorEngine::scriptEngine->GetTypeInfoById(func->GetReturnTypeId());
|
||||||
|
|
||||||
|
std::stringstream ext_dec;
|
||||||
|
|
||||||
|
// This means its void
|
||||||
|
if (retType == nullptr)
|
||||||
|
ext_dec << "void ";
|
||||||
|
else
|
||||||
|
ext_dec << retType->GetName() << " ";
|
||||||
|
|
||||||
|
ext_dec << func->GetName();
|
||||||
|
ext_dec << "(";
|
||||||
|
|
||||||
|
for (int i = 0; i < func->GetParamCount(); i++) {
|
||||||
|
if (i != 0)
|
||||||
|
ext_dec << ", ";
|
||||||
|
|
||||||
|
int typeId;
|
||||||
|
const char* name;
|
||||||
|
|
||||||
|
func->GetParam(i, &typeId, nullptr, &name);
|
||||||
|
asITypeInfo* paramType = scriptEngine->GetTypeInfoById(typeId);
|
||||||
|
|
||||||
|
ext_dec << paramType->GetName();
|
||||||
|
if (name != nullptr)
|
||||||
|
ext_dec << " " << name;
|
||||||
|
}
|
||||||
|
|
||||||
|
ext_dec << ")";
|
||||||
|
|
||||||
|
DEER_CORE_INFO(ext_dec.str().c_str());
|
||||||
|
//scriptEngine->RegisterGlobalFunction(ext_dec.str().c_str(), asFUNCTION(apiFunction), asEP_GENERIC_CALL_MODE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceScriptObject::apiFunction(asIScriptGeneric* gen) {
|
||||||
|
gen->GetAuxiliary();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,6 +5,8 @@ class asITypeInfo;
|
|||||||
class asIScriptObject;
|
class asIScriptObject;
|
||||||
class asIScriptFunction;
|
class asIScriptFunction;
|
||||||
class asIScriptContext;
|
class asIScriptContext;
|
||||||
|
class asIScriptGeneric;
|
||||||
|
class asIScriptModule;
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
@ -22,6 +24,8 @@ namespace Deer {
|
|||||||
void init();
|
void init();
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
void bindFunctions();
|
||||||
|
|
||||||
const char* getName();
|
const char* getName();
|
||||||
private:
|
private:
|
||||||
asITypeInfo* type = nullptr;
|
asITypeInfo* type = nullptr;
|
||||||
@ -29,6 +33,8 @@ namespace Deer {
|
|||||||
asIScriptFunction* updateFunction = nullptr;
|
asIScriptFunction* updateFunction = nullptr;
|
||||||
asIScriptFunction* initFunction = nullptr;
|
asIScriptFunction* initFunction = nullptr;
|
||||||
asIScriptContext* scriptContext = nullptr;
|
asIScriptContext* scriptContext = nullptr;
|
||||||
|
|
||||||
|
void apiFunction(asIScriptGeneric*);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,12 @@
|
|||||||
"dockPanelModule" : {
|
"dockPanelModule" : {
|
||||||
"name" : "Entity Manipulation",
|
"name" : "Entity Manipulation",
|
||||||
"author" : "Chewico",
|
"author" : "Chewico",
|
||||||
|
"version" : "1.0.0",
|
||||||
|
"services" : [
|
||||||
|
{
|
||||||
|
"name" : "ActiveEntity",
|
||||||
"version" : "1.0.0"
|
"version" : "1.0.0"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,8 +3,6 @@ class MeshExplorer : DockPanel {
|
|||||||
|
|
||||||
void onRender() {
|
void onRender() {
|
||||||
|
|
||||||
if (true)
|
|
||||||
return;
|
|
||||||
UI::setupAutomaticColumns(128);
|
UI::setupAutomaticColumns(128);
|
||||||
|
|
||||||
// To avoid problems we will cache the current path
|
// To avoid problems we will cache the current path
|
||||||
@ -43,6 +41,6 @@ class MeshExplorer : DockPanel {
|
|||||||
UI::nextColumn();
|
UI::nextColumn();
|
||||||
}
|
}
|
||||||
UI::endColumns();
|
UI::endColumns();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"dockPanelModule" : {
|
"dockPanelModule" : {
|
||||||
"name" : "Explorers",
|
"name" : "Explorers",
|
||||||
"author" : "Chewico",
|
"author" : "Chewico",
|
||||||
"version" : "1.0.0"
|
"version" : "1.0.0",
|
||||||
|
"services" : []
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
"dockPanelModule" : {
|
"dockPanelModule" : {
|
||||||
"name" : "Viewport",
|
"name" : "Viewport",
|
||||||
"author" : "Chewico",
|
"author" : "Chewico",
|
||||||
"version" : "1.0.0"
|
"version" : "1.0.0",
|
||||||
|
"services" : []
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user