Working on tree pannel implementation in angelscript

This commit is contained in:
Arnau Alier Torres 2025-05-02 16:39:54 +02:00
parent a0e49a2690
commit 0ce75eeec8
57 changed files with 908 additions and 547 deletions

View File

@ -13,11 +13,11 @@
#define DEER_VOXEL_ASPECT_PATH "voxels/aspect"
#define DEER_VOXEL_TEXTURE_PATH "voxels/textures"
#define DEER_VOXEL_SHADER_PATH "voxels/shaders"
#define DEER_DOCK_PANEL_PATH "editor"
#define DEER_UI_SCRIPT_PATH DEER_DOCK_PANEL_PATH
#define DEER_UI_ICON_PATH DEER_DOCK_PANEL_PATH
#define DEER_EDITOR_PATH "editor"
#define DEER_MESH_PATH "meshes"
#define DEER_MESH_EXTENSION ".dmesh"
#define DEER_BIN_PATH "bin"
#define DEER_TEMP_PATH "tmp"
#define DEER_NULL_PATH "null"

View File

@ -13,14 +13,14 @@ namespace Deer {
Core::argv = argv;
Log::init();
DEER_CORE_TRACE("Initializing");
DEER_CORE_INFO("Initializing");
Application* app = createApplication(argc, argv);
int runResult = app->run();
delete app;
DEER_CORE_TRACE("Deinitializing");
DEER_CORE_INFO("Deinitializing");
Log::shutdown();
return runResult;

View File

@ -26,15 +26,15 @@ namespace Deer {
static inline Ref<spdlog::logger>& getScriptLogger() {
return scriptLogger;
}
static inline Ref<spdlog::logger>& getUiEngineLogger() {
return uiEngineLogger;
static inline Ref<spdlog::logger>& getEditorEngineLogger() {
return EditorEngineLogger;
}
private:
static Ref<spdlog::logger> coreLogger;
static Ref<spdlog::logger> clientLogger;
static Ref<spdlog::logger> scriptLogger;
static Ref<spdlog::logger> uiEngineLogger;
static Ref<spdlog::logger> EditorEngineLogger;
};
} // namespace Deer
@ -49,10 +49,10 @@ namespace Deer {
#define DEER_SCRIPT_ERROR(...) Deer::Log::getScriptLogger()->error(__VA_ARGS__)
#define DEER_UI_ENGINE_TRACE(...) Deer::Log::getUiEngineLogger()->trace(__VA_ARGS__)
#define DEER_UI_ENGINE_INFO(...) Deer::Log::getUiEngineLogger()->info(__VA_ARGS__)
#define DEER_UI_ENGINE_WARN(...) Deer::Log::getUiEngineLogger()->warn(__VA_ARGS__)
#define DEER_UI_ENGINE_ERROR(...) Deer::Log::getUiEngineLogger()->error(__VA_ARGS__)
#define DEER_UI_ENGINE_TRACE(...) Deer::Log::getEditorEngineLogger()->trace(__VA_ARGS__)
#define DEER_UI_ENGINE_INFO(...) Deer::Log::getEditorEngineLogger()->info(__VA_ARGS__)
#define DEER_UI_ENGINE_WARN(...) Deer::Log::getEditorEngineLogger()->warn(__VA_ARGS__)
#define DEER_UI_ENGINE_ERROR(...) Deer::Log::getEditorEngineLogger()->error(__VA_ARGS__)
#ifdef LINUX
#define DEER_CORE_ASSERT(condition, ...) \

View File

@ -1,17 +0,0 @@
#pragma once
#include <string>
namespace Deer {
// This namespace implements all interface ported from c++ ImGui to an easier lua aproach with simplifications
namespace UIEngine {
void initialize();
void deinitialize();
void execute();
}
namespace DataStore {
int getIconId(const std::string& name);
}
}

View File

@ -4,7 +4,7 @@ namespace Deer {
std::shared_ptr<spdlog::logger> Log::coreLogger;
std::shared_ptr<spdlog::logger> Log::clientLogger;
std::shared_ptr<spdlog::logger> Log::scriptLogger;
std::shared_ptr<spdlog::logger> Log::uiEngineLogger;
std::shared_ptr<spdlog::logger> Log::EditorEngineLogger;
void Log::init()
{
@ -13,19 +13,19 @@ namespace Deer {
coreLogger = spdlog::stdout_color_mt("Core");
clientLogger = spdlog::stdout_color_mt("Client");
scriptLogger = spdlog::stdout_color_mt("Script");
uiEngineLogger = spdlog::stdout_color_mt("UI Engine");
EditorEngineLogger = spdlog::stdout_color_mt("UI Engine");
coreLogger->set_level(spdlog::level::level_enum::trace);
clientLogger->set_level(spdlog::level::level_enum::trace);
scriptLogger->set_level(spdlog::level::level_enum::trace);
uiEngineLogger->set_level(spdlog::level::level_enum::trace);
EditorEngineLogger->set_level(spdlog::level::level_enum::trace);
}
void Log::shutdown() {
coreLogger.reset();
clientLogger.reset();
scriptLogger.reset();
uiEngineLogger.reset();
EditorEngineLogger.reset();
spdlog::drop_all();
}

View File

@ -28,12 +28,9 @@ namespace Deer {
return dirData_cache[dirId];
}
Path idPath = rootPath;
if (id != "")
idPath /= id;
Path searchPath = idPath;
if (subDir != "")
searchPath /= subDir;
Path idPath = rootPath / id;
Path searchPath = idPath / subDir;
DirectoryData& dirData = dirData_cache[dirId];
for (const auto& entry : std::filesystem::directory_iterator(searchPath)) {

View File

@ -129,7 +129,7 @@ namespace Deer {
moduleName);
try {
DEER_CORE_INFO("=== Loading Scripts ===");
DEER_CORE_TRACE("Loading Scripts ");
for (const auto& entry :
fs::recursive_directory_iterator(modulePath)) {
if (fs::is_regular_file(entry) &&
@ -141,8 +141,8 @@ namespace Deer {
"script and try again. {0}",
entry.path().generic_string().c_str());
DEER_CORE_TRACE(" {0}",
entry.path().filename().string().c_str());
//DEER_CORE_TRACE(" {0}",
// entry.path().filename().string().c_str());
}
}
} catch (const fs::filesystem_error& e) {

View File

@ -34,8 +34,8 @@ namespace Deer {
std::vector<Path> voxelsData;
voxelsData = DataStore::getFiles(DEER_VOXEL_DATA_PATH, ".voxel");
DEER_CORE_INFO("=== Loading voxels ===");
DEER_CORE_TRACE(" default - air");
DEER_CORE_TRACE("Loading voxels");
//DEER_CORE_TRACE(" default - air");
for (Path& voxel : voxelsData) {
VoxelInfo voxelData;
@ -61,9 +61,9 @@ namespace Deer {
voxelData.name.c_str());
continue;
}
DEER_CORE_TRACE(" {0} - {1}",
voxel.filename().generic_string().c_str(),
voxelData.name);
//DEER_CORE_TRACE(" {0} - {1}",
// voxel.filename().generic_string().c_str(),
// voxelData.name);
uint32_t id = voxelsInfo.size();

View File

@ -1,131 +0,0 @@
#include "DeerRender/UIEngine/UIEngine_Functions.h"
#include "DeerRender/UIEngine/UIEngine.h"
#include "DeerRender/UIEngine.h"
#include "DeerRender/UIEngine/DockPanelObject.h"
#include "Deer/Log.h"
#include "Deer/DataStore.h"
#include "angelscript.h"
#include "imgui.h"
namespace Deer {
namespace UIEngine {
int getMeshCount(std::string& dir) {
return DataStore::getDirData(DEER_MESH_PATH, dir, ".dmesh").elements.size();
}
std::string getMeshPath(std::string& dir, int i) {
const DirectoryData& dirData = DataStore::getDirData(DEER_MESH_PATH, dir, ".dmesh");
if (i < 0 || i >= dirData.elements.size()){
DEER_UI_ENGINE_ERROR("Invalid id {0} calling getMeshPath(..), mas size {1}", i, dirData.dirs.size());
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return "";
}
return dirData.elements[i].string();
}
std::string getMeshName(std::string& dir, int i) {
const DirectoryData& dirData = DataStore::getDirData(DEER_MESH_PATH, dir, ".dmesh");
if (i < 0 || i >= dirData.elements.size()){
DEER_UI_ENGINE_ERROR("Invalid id {0} calling getMeshName(..), mas size {1}", i, dirData.dirs.size());
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return "";
}
return dirData.elements[i].stem().string();
}
int getMeshDirCount(std::string& dir) {
return DataStore::getDirData(DEER_MESH_PATH, dir, ".dmesh").dirs.size();
}
std::string getMeshDirPath(std::string& dir, int i) {
const DirectoryData& dirData = DataStore::getDirData(DEER_MESH_PATH, dir, ".dmesh");
if (i < 0 || i >= dirData.dirs.size()){
DEER_UI_ENGINE_ERROR("Invalid id {0} calling getMeshDirPath(..), mas size {1}", i, dirData.dirs.size());
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return "";
}
return dirData.dirs[i].string();
}
std::string getMeshDirName(std::string& dir, int i) {
const DirectoryData& dirData = DataStore::getDirData(DEER_MESH_PATH, dir, ".dmesh");
if (i < 0 || i >= dirData.dirs.size()){
DEER_UI_ENGINE_ERROR("Invalid id {0} calling getMeshDirName(..), mas size {1}", i, dirData.dirs.size());
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return "";
}
return dirData.dirs[i].filename().string();
}
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());
}
void drawIcon(std::string& name, int size) {
int iconId = DataStore::getIconId(name);
if (iconId < 0) {
DEER_UI_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));
}
// Interaction
bool isMouseClicked(int mouse) {
return ImGui::IsItemClicked(mouse);
}
bool isMouseDoubleClicked(int mouse) {
return ImGui::IsMouseDoubleClicked(mouse);
}
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 errorCallback(const asSMessageInfo *msg, void *param) {
if (msg->type == asMSGTYPE_WARNING) {
DEER_UI_ENGINE_WARN("{0} : ({1}, {2}) : {3}", msg->section, msg->row, msg->col, msg->message);
} else if( msg->type == asMSGTYPE_INFORMATION ) {
DEER_UI_ENGINE_ERROR("{0} : ({1}, {2}) : {3}", msg->section, msg->row, msg->col, msg->message);
}
}
void print(std::string& msg) {
DEER_UI_ENGINE_INFO("{0}", msg.c_str());
}
}
}

View File

@ -1,41 +0,0 @@
#pragma once
#include <string>
#include "DeerRender/UIEngine/Functions/UIEngine_TextFunctions.h"
#include "DeerRender/UIEngine/Functions/UIEngine_ColumnFunctions.h"
#include "DeerRender/UIEngine/Functions/UIEngine_ButtonFunctions.h"
#include "DeerRender/UIEngine/Functions/UIEngine_ButtonFunctions.h"
class asSMessageInfo;
namespace Deer {
namespace UIEngine {
// --- Mesh Data Store ---
// Returns the count of meshes in the dir relative to the mesh root dir
int getMeshCount(std::string& dir);
// Returns the path to the mesh with id i
std::string getMeshPath(std::string& dir, int i);
// Returns the name of the mesh with id i
std::string getMeshName(std::string& dir, int i);
// Returns the count of sub dirs in the dir relative to the mesh root dir
int getMeshDirCount(std::string& dir);
// Returns the path to the subDir in the dir relative to the mesh root dir
std::string getMeshDirPath(std::string& dir, int i);
// Returns the name of the subDir in the dir relative to the mesh root dir
std::string getMeshDirName(std::string& dir, int i);
// --- RENDERING ---
// TEXT
// Images
// TODO: Implement
void drawIcon(std::string& iconId, int size);
void errorCallback(const asSMessageInfo *msg, void *param);
// Prints in console a mesage
void print(std::string& msg);
}
}

View File

@ -1,128 +0,0 @@
#include "DeerRender/UIEngine/UIEngine_Functions.h"
#include "DeerRender/UIEngine/UIEngine.h"
#include "DeerRender/UIEngine/UIEngine_ErrorHandle.h"
namespace Deer {
void UIEngine::registerUIEngineFunctions() {
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void textColor(float, float, float, const string& in)",
asFUNCTION(
Deer::UIEngine::textColor
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void text(const string& in)",
asFUNCTION(
text
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void drawIcon(const string& in, int)",
asFUNCTION(
Deer::UIEngine::drawIcon
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"bool isMouseClicked(int)",
asFUNCTION(
isMouseClicked
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"bool isMouseDoubleClicked(int)",
asFUNCTION(
isMouseDoubleClicked
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void setupAutomaticColumns(int)",
asFUNCTION(
setupAutomaticColumns
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void endColumns()",
asFUNCTION(
endColumns
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void nextColumn()",
asFUNCTION(
nextColumn
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void print(const string& in)",
asFUNCTION (
Deer::UIEngine::print
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"int getMeshCount(const string& in)",
asFUNCTION(
Deer::UIEngine::getMeshCount
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"string getMeshPath(const string& in, int)",
asFUNCTION(
Deer::UIEngine::getMeshPath
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"string getMeshName(const string& in, int)",
asFUNCTION(
Deer::UIEngine::getMeshName
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"int getMeshDirCount(const string& in)",
asFUNCTION(
Deer::UIEngine::getMeshDirCount
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"string getMeshDirPath(const string& in, int)",
asFUNCTION(
Deer::UIEngine::getMeshDirPath
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"string getMeshDirName(const string& in, int)",
asFUNCTION(
Deer::UIEngine::getMeshDirName
),
asCALL_CDECL
));
}
}

View File

@ -25,8 +25,8 @@ namespace Deer {
voxelsAspect[0].definition.voxelName = VOXEL_INFO_TYPE_AIR;
DEER_CORE_INFO("=== Loading voxel aspect ===");
DEER_CORE_TRACE(" default - air");
DEER_CORE_TRACE("Loading voxel aspect ");
//DEER_CORE_TRACE(" default - air");
for (Path& voxelAspectPath : voxelsAspectPath) {
uint32_t size;
uint8_t* data = DataStore::readFile(voxelAspectPath, &size);
@ -56,14 +56,14 @@ namespace Deer {
continue;
}
DEER_CORE_TRACE(" {0} - {1}",
voxelAspectPath.filename().generic_string().c_str(),
aspectDefinition.voxelName.c_str());
//DEER_CORE_TRACE(" {0} - {1}",
// voxelAspectPath.filename().generic_string().c_str(),
// aspectDefinition.voxelName.c_str());
voxelsAspect[voxelID].definition = aspectDefinition;
}
DEER_CORE_INFO("=== Extracting textures ===");
DEER_CORE_TRACE("Extracting textures ");
for (VoxelAspect& voxelAspect : voxelsAspect) {
if (voxelsInfo[DataStore::getVoxelID(
voxelAspect.definition.voxelName)]
@ -93,8 +93,8 @@ namespace Deer {
texturesIDs[faceTextureString] = textureID;
voxelAspect.textureFacesIDs[i] = textureID;
DEER_CORE_TRACE(" texture {0} - id: {1}",
faceTextureString.c_str(), textureID);
//DEER_CORE_TRACE(" texture {0} - id: {1}",
// faceTextureString.c_str(), textureID);
}
}
}

View File

@ -36,15 +36,15 @@ namespace Deer {
stbi_set_flip_vertically_on_load(true);
stbi_flip_vertically_on_write(true);
DEER_CORE_INFO("=== Creating Texture Atlas ===");
DEER_CORE_TRACE("Creating Texture Atlas ");
for (auto& texture : texturesIDs) {
uint32_t size;
uint8_t* fileData = DataStore::readFile(
Path(DEER_VOXEL_TEXTURE_PATH) / (texture.first + ".png"),
&size);
DEER_CORE_TRACE(" {0}.png - {1}", texture.first.c_str(),
texture.second);
//DEER_CORE_TRACE(" {0}.png - {1}", texture.first.c_str(),
// texture.second);
if (fileData == nullptr) {
DEER_CORE_ERROR("{0}.png does not exists",
texture.first.c_str());

View File

@ -16,7 +16,6 @@ namespace Deer {
}
DEER_CORE_TRACE("OpenGL driver: {0}", (char*)glGetString(GL_VENDOR));
DEER_CORE_TRACE("Initialized glad");
}
void OpenGLContext::swapBuffers() {

View File

@ -210,7 +210,7 @@ namespace Deer {
// Either of them. Don't leak shaders.
glDeleteShader(vertexShader);
DEER_CORE_INFO(source);
DEER_CORE_TRACE(source);
// Use the infoLog as you see fit.
DEER_CORE_ERROR("Error compiling fragment shader. \n{0}", infoLog);

View File

@ -17,7 +17,8 @@ project "DeerStudio"
"../Deer/vendor/imgui",
"../Deer/vendor/glm",
"../Deer/vendor/ImGuizmo",
"../Deer/vendor/entt/include"
"../Deer/vendor/entt/include",
"../Deer/vendor/angelScript/include"
}
links

View File

@ -8,12 +8,11 @@
#include "Deer/Voxel.h"
#include "Deer/VoxelWorld.h"
#include "DeerRender/Mesh.h"
#include "DeerRender/UIEngine.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/Editor/Fonts.h"
#include "DeerStudio/Editor/GamePanel.h"
#include "DeerStudio/Editor/Icons.h"
#include "DeerStudio/Editor/MeshExplorer/MeshExplorer.h"
#include "DeerStudio/Editor/PropertiesPanel.h"
#include "DeerStudio/Editor/SceneExplorer.h"
#include "DeerStudio/Editor/Terrain/TerrainEditor.h"
@ -31,7 +30,7 @@ namespace Deer {
DataStore::loadVoxelsData();
DataStore::loadVoxelsAspect();
UIEngine::initialize();
EditorEngine::initialize();
return 0;
}
@ -78,7 +77,7 @@ namespace Deer {
ScriptEngine::shutdownScriptEngine();
Panels.clear();
UIEngine::deinitialize();
EditorEngine::deinitialize();
}
void DeerStudioApplication::onRender(Timestep delta) {
@ -145,11 +144,9 @@ namespace Deer {
}
// ---- PanelS -----
// sceneExplorer_onImGUI();
UIEngine::execute();
EditorEngine::execute();
TreePanel::onImgui();
PropertiesPanel::onImgui();
MeshExplorer::onImGui();
TerrainEditor::onImGui();
viewport_onImGui();
// ---- PanelS -----
@ -228,7 +225,7 @@ namespace Deer {
if (ImGui::BeginMenu("Interface")) {
if (ImGui::MenuItem("Reload interface")) {
UIEngine::initialize();
EditorEngine::initialize();
}
ImGui::EndMenu();
}

View File

@ -7,6 +7,14 @@
#include "DeerStudio/Editor/ActiveEntity.h"
#include "DeerStudio/Editor/EditorPanel.h"
#include <vector>
class asIScriptEngine;
class asIScriptObject;
class asIScriptModule;
class asIScriptContext;
namespace Deer {
class DeerStudioApplication : public Deer::Application {
public:

View File

@ -1,73 +0,0 @@
#include "MeshExplorer.h"
#include "Deer/DataStore.h"
#include "Deer/Path.h"
#include "DeerStudio/Editor/EditorUtils.h"
#include "DeerStudio/Editor/Icons.h"
#include "imgui.h"
namespace Deer {
namespace MeshExplorer {
Path m_meshExplorerPath(DEER_NULL_PATH);
void drawFolder(const Path& path);
} // namespace MeshExplorer
void MeshExplorer::onImGui() {
if (m_meshExplorerPath == DEER_NULL_PATH) {
DataStore::createFolder(DataStore::rootPath / DEER_MESH_PATH);
m_meshExplorerPath = DEER_MESH_PATH;
}
ImGui::Begin("Mesh Explorer", (bool*)0); // ImGuiWindowFlags_MenuBar
ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.0f), "%s",
m_meshExplorerPath.generic_string().c_str());
setupColumns(ICON_MIN_SIZE + 80);
if (m_meshExplorerPath != DEER_MESH_PATH) {
drawFolder("..");
float cursorOffset =
(ICON_MIN_SIZE - ImGui::CalcTextSize("..").x) / 2;
ImGui::SetCursorPos(ImVec2(cursorOffset + ImGui::GetCursorPos().x,
ImGui::GetCursorPos().y));
ImGui::Text("..");
ImGui::NextColumn();
}
for (const auto& entry : std::filesystem::directory_iterator(
DataStore::rootPath / m_meshExplorerPath)) {
if (entry.is_directory())
drawFolder(entry.path());
else {
}
float cursorOffset =
(ICON_MIN_SIZE -
ImGui::CalcTextSize(entry.path().stem().string().c_str()).x) /
2;
ImGui::SetCursorPos(ImVec2(cursorOffset + ImGui::GetCursorPos().x,
ImGui::GetCursorPos().y));
ImGui::Text("%s", entry.path().stem().string().c_str());
ImGui::NextColumn();
}
ImGui::Columns();
ImGui::End();
}
void MeshExplorer::drawFolder(const Path& path) {
ImGui::Image((void*)(uint64_t)Icons::folder_icon->getTextureID(),
ImVec2(ICON_MIN_SIZE, ICON_MIN_SIZE), ImVec2(0, 1),
ImVec2(1, 0));
if (ImGui::IsItemClicked(0) && ImGui::IsMouseDoubleClicked(0)) {
if (path == "..")
m_meshExplorerPath = m_meshExplorerPath.parent_path();
else
m_meshExplorerPath = path;
}
}
} // namespace Deer

View File

@ -1,7 +0,0 @@
#pragma once
namespace Deer {
namespace MeshExplorer {
void onImGui();
}
} // namespace Deer

View File

@ -1,15 +1,21 @@
#pragma once
#include <string>
#include <vector>
class asIScriptEngine;
class asIScriptObject;
class asIScriptModule;
class asIScriptContext;
namespace Deer {
namespace UIEngine {
// This namespace implements all interface ported from c++ ImGui to an easier lua aproach with simplifications
namespace EditorEngine {
struct DockPanelObject;
void initialize();
void deinitialize();
void execute();
extern asIScriptEngine* scriptEngine;
extern asIScriptModule* scriptModule;
extern asIScriptContext* scriptContext;
@ -17,8 +23,13 @@ namespace Deer {
extern DockPanelObject* currentDockPanelExecution;
void loadScripts();
void registerUIEngineFunctions();
void registerEditorEngineFunctions();
void registerEditorEngineStructs();
void registerDockPanel();
void extractDockPanels();
}
namespace DataStore {
int getIconId(const std::string& name);
}
}

View File

@ -2,7 +2,7 @@
#include <string>
namespace Deer {
namespace UIEngine {
namespace EditorEngine {
// TO IMPLEMENT
bool button(std::string&);
}

View File

@ -1,7 +1,7 @@
#pragma once
namespace Deer {
namespace UIEngine {
namespace EditorEngine {
// Set up the colums to fit the pixelSize elements
void setupAutomaticColumns(int pixelSize);
// Iterates to the next column

View File

@ -0,0 +1,30 @@
#pragma once
#include <stdint.h>
#include <string>
namespace Deer {
namespace EditorEngine {
enum ResourceType : uint32_t {
NOTHING = 0,
MESH = 1
};
// Returns the count of meshes in the dir relative to the mesh root dir
int getResourceCount(ResourceType, std::string& dir);
// Returns the path to the mesh with id i
std::string getResourceNameById(ResourceType, std::string& dir, int i);
// Returns the name of the mesh with id i
std::string getResourcePathById(ResourceType, std::string& dir, int i);
// Returns the count of sub dirs in the dir relative to the mesh root dir
int getDirCount(ResourceType, std::string&);
// Returns the path to the subDir in the dir relative to the mesh root dir
std::string getDirPathById(ResourceType, std::string& dir, int i);
// Returns the name of the subDir in the dir relative to the mesh root dir
std::string getDirNameById(ResourceType, std::string& dir, int i);
const char* getResourcePath(ResourceType);
const char* getResourceExtension(ResourceType);
const char* getResourceName(ResourceType);
}
}

View File

@ -0,0 +1,16 @@
#pragma once
#include <stdint.h>
namespace Deer {
namespace EditorEngine {
struct EntityStruct {
uint16_t entityId;
};
EntityStruct getRoot();
int getChildCount(EntityStruct&);
EntityStruct getChild(EntityStruct&, int);
}
}

View File

@ -0,0 +1,11 @@
#pragma once
#include <string>
class asSMessageInfo;
namespace Deer {
namespace EditorEngine {
void errorCallback(const asSMessageInfo *msg, void *param);
// Prints in console a mesage
void print(std::string& msg);
}
}

View File

@ -0,0 +1,9 @@
#pragma once
#include <string>
namespace Deer {
namespace EditorEngine {
void drawIcon(std::string& iconId, int size);
void drawIconCentered(std::string& iconId, int size);
}
}

View File

@ -1,7 +1,7 @@
#pragma once
namespace Deer {
namespace UIEngine {
namespace EditorEngine {
// Returns if the specified mouse button is clicked on the last element
bool isMouseClicked(int mouse);

View File

@ -0,0 +1,8 @@
#pragma once
#include <string>
namespace Deer {
namespace EditorEngine {
bool menuItem(std::string&);
}
}

View File

@ -0,0 +1,9 @@
#pragma once
#include <string>
namespace Deer {
namespace EditorEngine {
}
}

View File

@ -2,13 +2,16 @@
#include <string>
namespace Deer {
namespace UIEngine {
namespace EditorEngine {
// 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 text
void text(std::string& msg);
// Renders a text
void textCentered(std::string& msg);
}
}

View File

@ -0,0 +1,11 @@
#pragma once
#include <string>
class asIScriptFunction;
namespace Deer {
namespace EditorEngine {
void treeNode(std::string&);
void treeNode(std::string&, asIScriptFunction);
}
}

View File

@ -0,0 +1,11 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Button.h"
#include "imgui.h"
#include <string>
namespace Deer {
namespace EditorEngine {
bool button(std::string& txt) {
return ImGui::Button(txt.c_str());
}
}
}

View File

@ -0,0 +1,28 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Column.h"
#include "imgui.h"
namespace Deer {
namespace EditorEngine {
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();
}
}
}

View File

@ -0,0 +1,195 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Directory.h"
#include "DeerStudio/EditorEngine.h"
#include "Deer/DataStore.h"
#include "DeerStudio/EditorEngine/DockPanelObject.h"
#include "Deer/Log.h"
namespace Deer {
namespace EditorEngine {
const char* getResourcePath(ResourceType resource) {
switch (resource)
{
case ResourceType::NOTHING:
return nullptr;
case ResourceType::MESH :
return DEER_MESH_PATH;
}
return nullptr;
}
const char* getResourceExtension(ResourceType resource) {
switch (resource)
{
case ResourceType::NOTHING:
return nullptr;
case ResourceType::MESH :
return ".dmesh";
}
return nullptr;
}
const char* getResourceName(ResourceType resource) {
switch (resource)
{
case ResourceType::NOTHING:
return "???";
case ResourceType::MESH :
return "Mesh";
}
return nullptr;
}
int getResourceCount(ResourceType type, std::string& dir) {
const char* resourcePath = getResourcePath(type);
const char* resourceExtension = getResourceExtension(type);
if (!resourcePath || !resourceExtension) {
DEER_UI_ENGINE_ERROR("Invalid resource type calling getResourceCount(..)");
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return 0;
}
return DataStore::getDirData(resourcePath, dir, resourceExtension).elements.size();
}
std::string getResourceNameById(ResourceType type, std::string& dir, int i) {
const char* resourcePath = getResourcePath(type);
const char* resourceExtension = getResourceExtension(type);
if (!resourcePath || !resourceExtension) {
DEER_UI_ENGINE_ERROR("Invalid resource type calling getResourceNameById(..)");
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return "";
}
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
if (i < 0 || i >= dirData.elements.size()) {
DEER_UI_ENGINE_ERROR("Invalid element id {3} calling getResourceNameById(..) for type {0} and path {1}, element count on that dir is {2}",
getResourceName(type),
dir.c_str(),
dirData.elements.size(),
i
);
if (currentDockPanelExecution)
currentDockPanelExecution->invalidate();
return "";
}
return dirData.elements[i].stem().string();
}
std::string getResourcePathById(ResourceType type, std::string& dir, int i) {
const char* resourcePath = getResourcePath(type);
const char* resourceExtension = getResourceExtension(type);
if (!resourcePath || !resourceExtension) {
DEER_UI_ENGINE_ERROR("Invalid resource type calling getResourcePathById(..)");
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return "";
}
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
if (i < 0 || i >= dirData.elements.size()) {
DEER_UI_ENGINE_ERROR("Invalid element id {3} calling getResourcePathById(..) for type {0} and path {1}, element count on that dir is {2}",
getResourceName(type),
dir.c_str(),
dirData.elements.size(),
i
);
if (currentDockPanelExecution)
currentDockPanelExecution->invalidate();
return "";
}
return dirData.elements[i].string();
}
int getDirCount(ResourceType type, std::string& dir) {
const char* resourcePath = getResourcePath(type);
const char* resourceExtension = getResourceExtension(type);
if (!resourcePath || !resourceExtension) {
DEER_UI_ENGINE_ERROR("Invalid resource type calling getDirCount(..)");
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return 0;
}
return DataStore::getDirData(resourcePath, dir, resourceExtension).dirs.size();
}
std::string getDirPathById(ResourceType type, std::string& dir, int i) {
const char* resourcePath = getResourcePath(type);
const char* resourceExtension = getResourceExtension(type);
if (!resourcePath || !resourceExtension) {
DEER_UI_ENGINE_ERROR("Invalid resource type calling getDirPathById(..)");
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return "";
}
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
if (i < 0 || i >= dirData.dirs.size()) {
DEER_UI_ENGINE_ERROR("Invalid element id {3} calling getDirPathById(..) for type {0} and path {1}, sub_dir count on that dir is {2}",
getResourceName(type),
dir.c_str(),
dirData.dirs.size(),
i)
;
if (currentDockPanelExecution)
currentDockPanelExecution->invalidate();
return "";
}
return dirData.dirs[i].string();
}
std::string getDirNameById(ResourceType type, std::string& dir, int i) {
const char* resourcePath = getResourcePath(type);
const char* resourceExtension = getResourceExtension(type);
if (!resourcePath || !resourceExtension) {
DEER_UI_ENGINE_ERROR("Invalid resource type calling getDirNameById(..)");
if (currentDockPanelExecution) {
currentDockPanelExecution->invalidate();
}
return "";
}
const DirectoryData& dirData = DataStore::getDirData(resourcePath, dir, resourceExtension);
if (i < 0 || i >= dirData.dirs.size()) {
DEER_UI_ENGINE_ERROR("Invalid element id {3} calling getDirPathById(..) for type {0} and path {1}, sub_dir count on that dir is {2}",
getResourceName(type),
dir.c_str(),
dirData.dirs.size(),
i
);
if (currentDockPanelExecution)
currentDockPanelExecution->invalidate();
return "";
}
return dirData.dirs[i].stem().string();
}
}
}

View File

@ -0,0 +1,7 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Environment.h"
namespace Deer {
namespace EditorEngine {
}
}

View File

@ -0,0 +1,23 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Functions.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_UI_ENGINE_WARN("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message);
} else if( msg->type == asMSGTYPE_INFORMATION ) {
DEER_UI_ENGINE_ERROR("{0}:{1}:{2}) : {3}", msg->section, msg->row, msg->col, msg->message);
}
}
void print(std::string& msg) {
DEER_UI_ENGINE_INFO("{0}", msg.c_str());
}
}
}

View File

@ -0,0 +1,51 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Icon.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/DockPanelObject.h"
#include "Deer/Log.h"
#include "Deer/DataStore.h"
#include "imgui.h"
namespace Deer {
namespace EditorEngine {
void drawIcon(std::string& name, int size) {
int iconId = DataStore::getIconId(name);
if (iconId < 0) {
DEER_UI_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 drawIconCentered(std::string& name, int size) {
int iconId = DataStore::getIconId(name);
if (iconId < 0) {
DEER_UI_ENGINE_ERROR("Invalid icon name {0}", name.c_str());
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);
}
}
}

View File

@ -0,0 +1,14 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Input.h"
#include "imgui.h"
namespace Deer {
namespace EditorEngine {
bool isMouseClicked(int mouse) {
return ImGui::IsItemClicked(mouse);
}
bool isMouseDoubleClicked(int mouse) {
return ImGui::IsMouseDoubleClicked(mouse);
}
}
}

View File

@ -0,0 +1,10 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_MenuBar.h"
#include "imgui.h"
namespace Deer {
namespace EditorEngine {
bool menuItem(std::string& txt) {
return ImGui::MenuItem(txt.c_str());
}
}
}

View File

@ -0,0 +1,8 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Mesh.h"
namespace Deer {
namespace EditorEngine {
}
}

View File

@ -0,0 +1,30 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Text.h"
#include "imgui.h"
namespace Deer {
namespace EditorEngine {
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());
}
void textCentered(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());
}
}
}

View File

@ -0,0 +1,35 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_TreeNode.h"
#include "DeerStudio/EditorEngine.h"
#include "angelscript.h"
#include "imgui.h"
namespace Deer {
namespace EditorEngine {
void treeNode(std::string& txt) {
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf |
ImGuiTreeNodeFlags_NoTreePushOnOpen |
ImGuiTreeNodeFlags_SpanFullWidth;
ImGui::TreeNodeEx((void*)0, flags, "%s", txt.c_str());
}
void treeNode(std::string& txt, asIScriptFunction& func) {
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnDoubleClick |
ImGuiTreeNodeFlags_OpenOnArrow |
ImGuiTreeNodeFlags_SpanFullWidth;
if (ImGui::TreeNodeEx((void*)0, flags, "%s", txt.c_str())) {
if (scriptContext && scriptContext->PushState() == asSUCCESS) {
scriptContext->PopState();
} else {
ImGui::Text("Something failed");
}
ImGui::TreePop();
}
}
}
}

View File

@ -1,6 +1,8 @@
#include "DeerRender/UIEngine/DockPanelObject.h"
#include "DeerRender/UIEngine/UIEngine.h"
#include "DeerRender/UIEngine/UIEngine_ErrorHandle.h"
#include "DeerStudio/EditorEngine/DockPanelObject.h"
#include "DeerStudio/EditorEngine/EditorEngine_ErrorHandle.h"
#include "DeerStudio/EditorEngine.h"
#include "Deer/Log.h"
#include "angelscript.h"
#include <string>
@ -8,7 +10,7 @@
#include "imgui.h"
namespace Deer {
UIEngine::DockPanelObject::DockPanelObject(asITypeInfo* _type)
EditorEngine::DockPanelObject::DockPanelObject(asITypeInfo* _type)
: type (_type), isValid(false) {
// Constructor
@ -44,19 +46,52 @@ namespace Deer {
return;
}
menuBarFunction = type->GetMethodByDecl("void onMenuBar()");
isValid = true;
}
UIEngine::DockPanelObject::~DockPanelObject() {
EditorEngine::DockPanelObject::~DockPanelObject() {
if (object)
object->Release();
}
void UIEngine::DockPanelObject::executeRender() {
ImGui::Begin(type->GetName());
void EditorEngine::DockPanelObject::invalidate() {
DEER_UI_ENGINE_ERROR("Last error was caused executing {0}", type->GetName());
isValid = false;
}
void EditorEngine::DockPanelObject::executeRender() {
if (menuBarFunction) {
ImGui::Begin(type->GetName(), (bool*)0, ImGuiWindowFlags_MenuBar);
if (ImGui::BeginMenuBar()) {
AS_CHECK_ADDITIONAL_INFO(
scriptContext->Prepare(menuBarFunction),
type->GetName()
);
AS_CHECK_ADDITIONAL_INFO(
scriptContext->SetObject(object),
type->GetName()
);
AS_CHECK_ADDITIONAL_INFO(
scriptContext->Execute(),
type->GetName()
);
ImGui::EndMenuBar();
}
} else {
ImGui::Begin(type->GetName());
}
if (!isValid) {
ImGui::TextColored(ImVec4(1, 0.3f, 0.3f, 1), "There was an error, please check the logs or reload the interface");
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;
}
@ -79,28 +114,32 @@ namespace Deer {
ImGui::End();
}
UIEngine::DockPanelObject::DockPanelObject(DockPanelObject&& other) noexcept
: isValid(other.isValid), renderFunction(other.renderFunction), type(other.type), object(other.object) {
EditorEngine::DockPanelObject::DockPanelObject(DockPanelObject&& other) noexcept
: isValid(other.isValid), renderFunction(other.renderFunction), type(other.type), object(other.object), menuBarFunction(other.menuBarFunction) {
other.isValid = false;
other.renderFunction = nullptr;
other.type = nullptr;
other.object = nullptr;
other.menuBarFunction = nullptr;
}
UIEngine::DockPanelObject& UIEngine::DockPanelObject::operator=(UIEngine::DockPanelObject&& other) noexcept {
EditorEngine::DockPanelObject& EditorEngine::DockPanelObject::operator=(EditorEngine::DockPanelObject&& other) noexcept {
if (this != &other) {
isValid = other.isValid;
renderFunction = other.renderFunction;
type = other.type;
object = other.object;
menuBarFunction = other.menuBarFunction;
other.isValid = false;
other.renderFunction = nullptr;
other.type = nullptr;
other.object = nullptr;
other.menuBarFunction = nullptr;
}
return *this;
}
}

View File

@ -4,14 +4,14 @@ class asIScriptObject;
class asIScriptFunction;
namespace Deer {
namespace UIEngine {
namespace EditorEngine {
struct DockPanelObject {
private:
asITypeInfo* type = nullptr;
asIScriptObject* object = nullptr;
asIScriptFunction* renderFunction = nullptr;
asIScriptFunction* menuBarFunction = nullptr;
bool isValid = false;
public:
DockPanelObject(asITypeInfo*);
@ -22,9 +22,9 @@ namespace Deer {
DockPanelObject(DockPanelObject&& other) noexcept;
DockPanelObject& operator=(DockPanelObject&& other) noexcept;
void executeRender();
inline void invalidate() { isValid = false; }
void invalidate();
};
}
}

View File

@ -1,8 +1,8 @@
#include "DeerRender/UIEngine.h"
#include "DeerRender/UIEngine/UIEngine_ErrorHandle.h"
#include "DeerRender/UIEngine/UIEngine_Functions.h"
#include "DeerRender/UIEngine/UIEngine.h"
#include "DeerRender/UIEngine/DockPanelObject.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/EditorEngine_ErrorHandle.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Functions.h"
#include "DeerStudio/EditorEngine/DockPanelObject.h"
#include "DeerStudio/EditorEngine.h"
#include "Deer/Log.h"
#include <vector>
@ -12,7 +12,7 @@
#include "scriptstdstring.h"
namespace Deer {
namespace UIEngine {
namespace EditorEngine {
asIScriptEngine* scriptEngine = nullptr;
asIScriptModule* scriptModule = nullptr;
asIScriptContext* scriptContext = nullptr;
@ -23,7 +23,7 @@ namespace Deer {
bool active = false;
}
void UIEngine::initialize() {
void EditorEngine::initialize() {
int err = 0;
// If it exist we will reload it
@ -32,9 +32,10 @@ namespace Deer {
scriptEngine = asCreateScriptEngine();
RegisterStdString(scriptEngine);
AS_RET_CHECK(scriptEngine->SetMessageCallback(asFUNCTION(Deer::UIEngine::errorCallback), 0, asCALL_CDECL));
AS_RET_CHECK(scriptEngine->SetMessageCallback(asFUNCTION(Deer::EditorEngine::errorCallback), 0, asCALL_CDECL));
registerUIEngineFunctions();
registerEditorEngineStructs();
registerEditorEngineFunctions();
registerDockPanel();
loadScripts();
@ -46,7 +47,7 @@ namespace Deer {
active = true;
}
void UIEngine::deinitialize() {
void EditorEngine::deinitialize() {
dockPanels.clear();
if (scriptContext)
@ -61,7 +62,7 @@ namespace Deer {
active = false;
}
void UIEngine::execute() {
void EditorEngine::execute() {
if (!active)
return;

View File

@ -1,9 +1,9 @@
#include "DeerRender/UIEngine/UIEngine_ErrorHandle.h"
#include "DeerStudio/EditorEngine/EditorEngine_ErrorHandle.h"
#include "angelscript.h"
namespace Deer {
namespace UIEngine {
namespace EditorEngine {
const char* getAngelScriptReturnCodeString(int code)
{
switch (code)

View File

@ -1,9 +1,9 @@
#pragma once
#include "Deer/Log.h"
#include <angelscript.h>
#include "angelscript.h"
namespace Deer {
namespace UIEngine {
namespace EditorEngine {
const char* getAngelScriptReturnCodeString(int code);
}
}
@ -11,19 +11,19 @@ namespace Deer {
#define AS_CHECK(f) { \
int __r = f; \
if (__r < 0) { \
DEER_UI_ENGINE_ERROR("Error at line: {0}:{1} -> {2}", __FILE__, __LINE__, Deer::UIEngine::getAngelScriptReturnCodeString(__r)); \
DEER_UI_ENGINE_ERROR("Error at line: {0}:{1} -> {2}", __FILE__, __LINE__, Deer::EditorEngine::getAngelScriptReturnCodeString(__r)); \
} \
}
#define AS_CHECK_ADDITIONAL_INFO(f, i) { \
int __r = f; \
if (__r < 0) { \
DEER_UI_ENGINE_ERROR("Error at line: {0}:{1} -> {2} \n {3}", __FILE__, __LINE__, Deer::UIEngine::getAngelScriptReturnCodeString(__r), i); \
DEER_UI_ENGINE_ERROR("Error at line: {0}:{1} -> {2} \n {3}", __FILE__, __LINE__, Deer::EditorEngine::getAngelScriptReturnCodeString(__r), i); \
} \
}
#define AS_RET_CHECK(f) { \
int __r = f; \
if (__r < 0) { \
DEER_UI_ENGINE_ERROR("Error at line: {0}:{1} -> {2}", __FILE__, __LINE__, Deer::UIEngine::getAngelScriptReturnCodeString(__r)); \
DEER_UI_ENGINE_ERROR("Error at line: {0}:{1} -> {2}", __FILE__, __LINE__, Deer::EditorEngine::getAngelScriptReturnCodeString(__r)); \
return; \
} \
}

View File

@ -1,4 +1,4 @@
#include "DeerRender/UIEngine.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerRender/Render/Texture.h"
#include "Deer/DataStore.h"
@ -16,7 +16,7 @@ namespace Deer {
uint8_t* data;
uint32_t size;
if (!DataStore::loadGlobalFileData(DEER_UI_ICON_PATH, name, &data, &size))
if (!DataStore::loadGlobalFileData(DEER_EDITOR_PATH, name, &data, &size))
return -1;
icons[name] = Texture2D::create(data, size);

View File

@ -1,16 +1,16 @@
#include "angelscript.h"
#include "DeerRender/UIEngine/UIEngine.h"
#include "DeerRender/UIEngine/DockPanelObject.h"
#include "DeerRender/UIEngine/UIEngine_ErrorHandle.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/DockPanelObject.h"
#include "DeerStudio/EditorEngine/EditorEngine_ErrorHandle.h"
namespace Deer {
void UIEngine::registerDockPanel() {
void EditorEngine::registerDockPanel() {
AS_RET_CHECK(scriptEngine->RegisterInterface("DockPanel"));
AS_RET_CHECK(scriptEngine->RegisterInterfaceMethod("DockPanel", "void onRender()"));
}
void UIEngine::extractDockPanels() {
void EditorEngine::extractDockPanels() {
size_t nScripts = scriptModule->GetObjectTypeCount();
asITypeInfo* dockPanelType = scriptEngine->GetTypeInfoByName("DockPanel");

View File

@ -1,5 +1,5 @@
#include "DeerRender/UIEngine/UIEngine.h"
#include "DeerRender/UIEngine/UIEngine_ErrorHandle.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/EditorEngine_ErrorHandle.h"
#include "Deer/Path.h"
#include "Deer/DataStore.h"
@ -15,16 +15,16 @@
namespace fs = std::filesystem;
namespace Deer {
void UIEngine::loadScripts() {
Path path = DataStore::rootPath / DEER_UI_SCRIPT_PATH;
void EditorEngine::loadScripts() {
Path path = DataStore::rootPath / DEER_EDITOR_PATH;
CScriptBuilder builder;
AS_RET_CHECK(builder.StartNewModule(scriptEngine, "DeerModule"));
DEER_UI_ENGINE_INFO("=== Extracting UI Engine Scripts ===");
DEER_CORE_TRACE("Extracting UI Engine Scripts ");
for (const auto& entry : fs::recursive_directory_iterator(path)) {
if (entry.is_regular_file() && entry.path().extension() == ".as") {
DEER_UI_ENGINE_TRACE("\t{0}", entry.path().stem().string().c_str());
//DEER_UI_ENGINE_TRACE("\t{0}", entry.path().stem().string().c_str());
// We add aditional info to check who caused the error
AS_CHECK_ADDITIONAL_INFO(
builder.AddSectionFromFile(entry.path().string().c_str());,

View File

@ -0,0 +1,135 @@
#include "DeerStudio/EditorEngine/API/EditorEngine_Functions.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/EditorEngine_ErrorHandle.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Button.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Column.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Directory.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Environment.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Environment.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Functions.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Functions.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Icon.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Input.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Mesh.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Text.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_MenuBar.h"
#include "angelscript.h"
namespace Deer {
void EditorEngine::registerEditorEngineFunctions() {
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"bool menuItem(const string& in)",
asFUNCTION(Deer::EditorEngine::menuItem),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void textColor(float, float, float, const string& in)",
asFUNCTION(Deer::EditorEngine::textColor),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void text(const string& in)",
asFUNCTION(text),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void drawIcon(const string& in, int)",
asFUNCTION(Deer::EditorEngine::drawIcon),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"bool isMouseClicked(int)",
asFUNCTION(
isMouseClicked
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"bool isMouseDoubleClicked(int)",
asFUNCTION(
isMouseDoubleClicked
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void setupAutomaticColumns(int)",
asFUNCTION(
setupAutomaticColumns
),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void endColumns()",
asFUNCTION(endColumns),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void nextColumn()",
asFUNCTION(nextColumn),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void print(const string& in)",
asFUNCTION (Deer::EditorEngine::print),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void textCentered(const string& in)",
asFUNCTION(Deer::EditorEngine::textCentered),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void drawIconCentered(const string& in, int)",
asFUNCTION(Deer::EditorEngine::drawIconCentered),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"int getResourceCount(ResourceType, const string& in)",
asFUNCTION(Deer::EditorEngine::getResourceCount),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"string getResourceNameById(ResourceType, const string& in, int)",
asFUNCTION(Deer::EditorEngine::getResourceNameById),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"string getResourcePathById(ResourceType, const string& in, int)",
asFUNCTION(Deer::EditorEngine::getResourcePathById),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"int getDirCount(ResourceType, const string& in)",
asFUNCTION(Deer::EditorEngine::getDirCount),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"string getDirPathById(ResourceType, const string& in, int)",
asFUNCTION(Deer::EditorEngine::getDirPathById),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"string getDirNameById(ResourceType, const string& in, int)",
asFUNCTION(Deer::EditorEngine::getDirNameById),
asCALL_CDECL
));
}
}

View File

@ -0,0 +1,25 @@
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/EditorEngine_ErrorHandle.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Mesh.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Environment.h"
#include "DeerStudio/EditorEngine/API/EditorEngine_Directory.h"
#include "angelscript.h"
namespace Deer {
namespace EditorEngine {
void registerResourceTypeEnum() {
AS_RET_CHECK(scriptEngine->RegisterEnum("ResourceType"));
AS_CHECK(scriptEngine->RegisterEnumValue("ResourceType", "Mesh", (int)ResourceType::MESH));
}
void registerEntityStruct() {
AS_CHECK(scriptEngine->RegisterObjectType("Entity", sizeof(EntityStruct),
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityStruct>()));
}
void registerEditorEngineStructs() {
registerResourceTypeEnum();
}
}
}

View File

@ -0,0 +1,42 @@
class MeshExplorer : DockPanel {
string currentPath = "";
void onRender() {
setupAutomaticColumns(128);
// To avoid problems we will cache the current path
const string cache_currentPath = currentPath;
if (cache_currentPath != "") {
drawIconCentered("folder", 64);
if (isMouseClicked(0) and isMouseDoubleClicked(0)) {
currentPath = "";
}
textCentered(cache_currentPath + "/..");
nextColumn();
}
ResourceType resourceType = ResourceType::Mesh;
int dirCount = getDirCount(resourceType, cache_currentPath);
for (int i = 0; i < dirCount; i++) {
drawIconCentered("folder", 64);
if (isMouseClicked(0) and isMouseDoubleClicked(0)) {
print(getDirPathById(ResourceType::Mesh, cache_currentPath, i));
currentPath = getDirPathById(ResourceType::Mesh, cache_currentPath, i);
}
textCentered(getDirNameById(ResourceType::Mesh, cache_currentPath, i));
nextColumn();
}
int meshCount = getResourceCount(ResourceType::Mesh, cache_currentPath);
for (int i = 0; i < meshCount; i++) {
drawIconCentered("file", 64);
textCentered(getResourceNameById(ResourceType::Mesh, cache_currentPath, i));
nextColumn();
}
endColumns();
}
}

View File

@ -1,28 +0,0 @@
class MeshExplorer : DockPanel {
string currentPath = "";
void onRender() {
textColor(0.5, 0.5, 0.5, currentPath);
setupAutomaticColumns(180);
int dirCount = getMeshDirCount(currentPath);
for (int i = 0; i < dirCount; i++) {
drawIcon("folder", 64);
text(getMeshDirName(currentPath, i));
nextColumn();
}
int meshCount = getMeshCount(currentPath);
for (int i = 0; i < meshCount; i++) {
drawIcon("file", 64);
text(getMeshName(currentPath, i));
nextColumn();
}
endColumns();
}
}

View File

@ -0,0 +1,16 @@
class TreePannel : DockPanel {
void onMenuBar() {
if (menuItem("Hey!")) {
print("clicked");
}
}
void onRender() {
root = getRoot();
renderEntity(root);
}
void renderEntity(Entity entity) {
}
}

View File

@ -10,31 +10,31 @@ Collapsed=0
[Window][Properties]
Pos=968,24
Size=312,214
Size=312,110
Collapsed=0
DockId=0x00000009,0
[Window][Game Window]
Pos=304,24
Size=662,368
Size=662,392
Collapsed=0
DockId=0x00000006,1
[Window][Tree Panel]
Pos=0,24
Size=302,368
Size=302,392
Collapsed=0
DockId=0x00000005,0
[Window][Terrain Editor]
Pos=968,240
Size=312,152
Pos=968,136
Size=312,280
Collapsed=0
DockId=0x0000000A,0
[Window][Viewport]
Pos=304,24
Size=662,368
Size=662,392
Collapsed=0
DockId=0x00000006,0
@ -45,8 +45,8 @@ Collapsed=0
DockId=0x00000002,0
[Window][Mesh Explorer]
Pos=0,394
Size=1280,326
Pos=0,418
Size=1280,302
Collapsed=0
DockId=0x00000008,0
@ -57,21 +57,27 @@ Collapsed=0
DockId=0x00000008,1
[Window][MeshExplorer]
Pos=0,394
Size=1280,326
Pos=0,418
Size=1280,302
Collapsed=0
DockId=0x00000008,1
DockId=0x00000008,0
[Window][TreePannel]
Pos=0,24
Size=302,392
Collapsed=0
DockId=0x00000005,1
[Docking][Data]
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y
DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,368 Split=Y
DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,392 Split=Y
DockNode ID=0x00000001 Parent=0x00000007 SizeRef=2560,363 Split=X Selected=0x13926F0B
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=966,779 Split=X Selected=0x13926F0B
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=302,779 Selected=0xF278DC36
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=302,779 Selected=0xE45B9F93
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=662,779 CentralNode=1 Selected=0x13926F0B
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=312,779 Split=Y Selected=0x199AB496
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=392,214 Selected=0x199AB496
DockNode ID=0x0000000A Parent=0x00000004 SizeRef=392,152 Selected=0x2A2C795E
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=392,110 Selected=0x199AB496
DockNode ID=0x0000000A Parent=0x00000004 SizeRef=392,280 Selected=0x2A2C795E
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702
DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,326 Selected=0xD962995A
DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,302 Selected=0xD962995A