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