Made Editor a system and create editor routine so that the editor routine will run between graphics routines
This commit is contained in:
parent
e027318d22
commit
49575893fe
|
@ -56,46 +56,58 @@ namespace Sandbox
|
|||
)
|
||||
{
|
||||
// Set working directory
|
||||
SHADE::SHFileUtilities::SetWorkDirToExecDir();
|
||||
SHFileUtilities::SetWorkDirToExecDir();
|
||||
|
||||
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||
|
||||
// Create Systems
|
||||
SHADE::SHSystemManager::CreateSystem<SHADE::SHGraphicsSystem>();
|
||||
SHADE::SHSystemManager::CreateSystem<SHADE::SHScriptEngine>();
|
||||
SHADE::SHSystemManager::CreateSystem<SHADE::SHPhysicsSystem>();
|
||||
SHADE::SHSystemManager::CreateSystem<SHADE::SHTransformSystem>();
|
||||
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
|
||||
SHADE::SHSystemManager::CreateSystem<SHADE::SHAudioSystem>();
|
||||
SHSystemManager::CreateSystem<SHGraphicsSystem>();
|
||||
SHSystemManager::CreateSystem<SHScriptEngine>();
|
||||
SHSystemManager::CreateSystem<SHPhysicsSystem>();
|
||||
SHSystemManager::CreateSystem<SHTransformSystem>();
|
||||
SHGraphicsSystem* graphicsSystem = static_cast<SHGraphicsSystem*>(SHSystemManager::GetSystem<SHGraphicsSystem>());
|
||||
SHSystemManager::CreateSystem<SHAudioSystem>();
|
||||
|
||||
#ifdef SHEDITOR
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
sdlWindow = SDL_CreateWindowFrom(window.GetHWND());
|
||||
SHSystemManager::CreateSystem<SHEditor>();
|
||||
SHSystemManager::GetSystem<SHEditor>()->SetSDLWindow(sdlWindow);
|
||||
#endif
|
||||
|
||||
// Create Routines
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::FrameSetUpRoutine>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::UpdateRoutine>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::LateUpdateRoutine>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::FrameCleanUpRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHScriptEngine, SHScriptEngine::FrameSetUpRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHScriptEngine, SHScriptEngine::UpdateRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHScriptEngine, SHScriptEngine::LateUpdateRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHScriptEngine, SHScriptEngine::FrameCleanUpRoutine>();
|
||||
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHPhysicsSystem, SHADE::SHPhysicsSystem::PhysicsPreUpdate>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHPhysicsSystem, SHADE::SHPhysicsSystem::PhysicsFixedUpdate>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHPhysicsSystem, SHADE::SHPhysicsSystem::PhysicsPostUpdate>();
|
||||
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsPreUpdate>();
|
||||
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsFixedUpdate>();
|
||||
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsPostUpdate>();
|
||||
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHTransformSystem, SHADE::SHTransformSystem::TransformUpdateRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHTransformSystem, SHTransformSystem::TransformUpdateRoutine>();
|
||||
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::BatcherDispatcherRoutine>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::BeginRoutine>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::RenderRoutine>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::EndRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BatcherDispatcherRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BeginRoutine>();
|
||||
|
||||
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHRigidBodyComponent>();
|
||||
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHColliderComponent>();
|
||||
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHTransformComponent>();
|
||||
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHRenderable>();
|
||||
#ifdef SHEDITOR
|
||||
SHSystemManager::RegisterRoutine<SHEditor, SHEditor::EditorRoutine>();
|
||||
#endif
|
||||
|
||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::RenderRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::EndRoutine>();
|
||||
|
||||
SHComponentManager::CreateComponentSparseSet<SHRigidBodyComponent>();
|
||||
SHComponentManager::CreateComponentSparseSet<SHColliderComponent>();
|
||||
SHComponentManager::CreateComponentSparseSet<SHTransformComponent>();
|
||||
SHComponentManager::CreateComponentSparseSet<SHRenderable>();
|
||||
|
||||
//TODO: REMOVE AFTER PRESENTATION
|
||||
//SHADE::SHAssetManager::LoadDataTemp("../../Assets/racoon.gltf");
|
||||
SHADE::SHAssetManager::LoadDataTemp("../../Assets/Cube.012.shmesh");
|
||||
//SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonBag_Color_Ver4.dds");
|
||||
//SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.dds");
|
||||
SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.shtex");
|
||||
//SHAssetManager::LoadDataTemp("../../Assets/racoon.gltf");
|
||||
SHAssetManager::LoadDataTemp("../../Assets/Cube.012.shmesh");
|
||||
//SHAssetManager::LoadDataTemp("../../Assets/RaccoonBag_Color_Ver4.dds");
|
||||
//SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.dds");
|
||||
SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.shtex");
|
||||
//TODO: REMOVE AFTER PRESENTATION
|
||||
|
||||
|
||||
|
@ -103,19 +115,12 @@ namespace Sandbox
|
|||
auto id2 = SHFamilyID<SHSystem>::GetID<SHGraphicsSystem>();
|
||||
auto id3 = SHFamilyID<SHSystem>::GetID<SHGraphicsSystem>();
|
||||
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHAudioSystem, SHADE::SHAudioSystem::AudioRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHAudioSystem, SHAudioSystem::AudioRoutine>();
|
||||
|
||||
// Set up graphics system and windows
|
||||
graphicsSystem->SetWindow(&window);
|
||||
|
||||
SHADE::SHSystemManager::Init();
|
||||
#ifdef SHEDITOR
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
sdlWindow = SDL_CreateWindowFrom(window.GetHWND());
|
||||
SHADE::SHEditor::Initialise(sdlWindow);
|
||||
#else
|
||||
#endif
|
||||
|
||||
SHSystemManager::Init();
|
||||
|
||||
SHSceneManager::InitSceneManager<SBTestScene>("TestScene");
|
||||
|
||||
|
@ -124,7 +129,7 @@ namespace Sandbox
|
|||
|
||||
void SBApplication::Update(void)
|
||||
{
|
||||
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
|
||||
SHGraphicsSystem* graphicsSystem = SHADE::SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||
//TODO: Change true to window is open
|
||||
while (!window.WindowShouldClose())
|
||||
{
|
||||
|
@ -134,16 +139,16 @@ namespace Sandbox
|
|||
SHSceneManager::SceneUpdate(1/60.0f);
|
||||
//#ifdef SHEDITOR
|
||||
//#endif
|
||||
graphicsSystem->BeginRender();
|
||||
//graphicsSystem->BeginRender();
|
||||
|
||||
#ifdef SHEDITOR
|
||||
SHADE::SHEditor::Update(0.16f);
|
||||
//SHADE::SHEditor::Update(0.16f);
|
||||
#endif
|
||||
|
||||
graphicsSystem->Run(1.0f);
|
||||
graphicsSystem->EndRender();
|
||||
//graphicsSystem->Run(1.0f);
|
||||
//graphicsSystem->EndRender();
|
||||
|
||||
SHADE::SHSystemManager::RunRoutines(false, 0.016f);
|
||||
SHSystemManager::RunRoutines(false, 0.016f);
|
||||
}
|
||||
|
||||
// Finish all graphics jobs first
|
||||
|
@ -154,13 +159,12 @@ namespace Sandbox
|
|||
void SBApplication::Exit(void)
|
||||
{
|
||||
#ifdef SHEDITOR
|
||||
SHADE::SHEditor::Exit();
|
||||
SDL_DestroyWindow(sdlWindow);
|
||||
SDL_Quit();
|
||||
#endif
|
||||
|
||||
SHSceneManager::Exit();
|
||||
SHADE::SHSystemManager::Exit();
|
||||
SHSystemManager::Exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
//#==============================================================#
|
||||
//|| SHADE Includes ||
|
||||
//#==============================================================#
|
||||
#include "Editor/SHEditor.hpp"
|
||||
#include "Editor/SHImGuiHelpers.hpp"
|
||||
#include "Editor/SHEditorWidgets.hpp"
|
||||
#include "SHHierarchyPanel.h"
|
||||
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||
#include "Editor/SHEditor.hpp"
|
||||
#include "Scene/SHSceneManager.h"
|
||||
#include "Editor/DragDrop/SHDragDrop.hpp"
|
||||
#include "Tools/SHException.h"
|
||||
|
@ -62,7 +62,8 @@ namespace SHADE
|
|||
|
||||
if(ImGui::IsWindowHovered() && !SHDragDrop::hasDragDrop && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||
{
|
||||
SHEditor::selectedEntities.clear();
|
||||
if(auto editor = SHSystemManager::GetSystem<SHEditor>())
|
||||
editor->selectedEntities.clear();
|
||||
}
|
||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);
|
||||
ImGui::End();
|
||||
|
@ -102,7 +103,9 @@ namespace SHADE
|
|||
//Get node data (Children, eid, selected)
|
||||
auto& children = currentNode->GetChildren();
|
||||
EntityID eid = currentNode->GetEntityID();
|
||||
const bool isSelected = (std::ranges::find(SHEditor::selectedEntities, eid) != SHEditor::selectedEntities.end());
|
||||
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||
|
||||
const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end());
|
||||
|
||||
const ImGuiTreeNodeFlags nodeFlags = ((isSelected) ? ImGuiTreeNodeFlags_Selected : 0) | ((children.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow);
|
||||
|
||||
|
@ -140,8 +143,8 @@ namespace SHADE
|
|||
{
|
||||
if(!isSelected)
|
||||
{
|
||||
SHEditor::selectedEntities.clear();
|
||||
SHEditor::selectedEntities.push_back(eid);
|
||||
editor->selectedEntities.clear();
|
||||
editor->selectedEntities.push_back(eid);
|
||||
}
|
||||
if(ImGui::Selectable(std::format("{} Delete", ICON_MD_DELETE).data()))
|
||||
{
|
||||
|
@ -163,19 +166,19 @@ namespace SHADE
|
|||
if (!isSelected)
|
||||
{
|
||||
if (!ImGui::IsKeyDown(ImGuiKey_LeftCtrl))
|
||||
SHEditor::selectedEntities.clear();
|
||||
SHEditor::selectedEntities.push_back(eid);
|
||||
editor->selectedEntities.clear();
|
||||
editor->selectedEntities.push_back(eid);
|
||||
}//if not selected
|
||||
else
|
||||
{
|
||||
if (!ImGui::IsKeyDown(ImGuiKey_LeftCtrl))
|
||||
{
|
||||
auto it = std::ranges::remove(SHEditor::selectedEntities, eid).begin();
|
||||
auto it = std::ranges::remove(editor->selectedEntities, eid).begin();
|
||||
}//if mod ctrl is not pressed
|
||||
else
|
||||
{
|
||||
SHEditor::selectedEntities.clear();
|
||||
SHEditor::selectedEntities.push_back(eid);
|
||||
editor->selectedEntities.clear();
|
||||
editor->selectedEntities.push_back(eid);
|
||||
}
|
||||
}//if selected
|
||||
}//if left mouse button released
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "SHpch.h"
|
||||
|
||||
#include "Editor/SHEditor.hpp"
|
||||
#include "SHEditorInspector.h"
|
||||
|
||||
#include "ECS_Base/SHECSMacros.h"
|
||||
|
@ -7,7 +8,6 @@
|
|||
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||
#include "Math/Transform/SHTransformComponent.h"
|
||||
|
||||
#include "Editor/SHEditor.hpp"
|
||||
#include "Editor/SHImGuiHelpers.hpp"
|
||||
#include "Editor/SHEditorWidgets.hpp"
|
||||
#include "SHEditorComponentView.hpp"
|
||||
|
@ -50,10 +50,10 @@ namespace SHADE
|
|||
SHEditorWindow::Update();
|
||||
if (Begin())
|
||||
{
|
||||
|
||||
if (!SHEditor::selectedEntities.empty())
|
||||
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||
if (editor && !editor->selectedEntities.empty())
|
||||
{
|
||||
EntityID const& eid = SHEditor::selectedEntities[0];
|
||||
EntityID const& eid = editor->selectedEntities[0];
|
||||
SHEntity* entity = SHEntityManager::GetEntityByID(eid);
|
||||
|
||||
ImGui::TextColored(ImGuiColors::green, "EID: %zu", eid);
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
//#==============================================================#
|
||||
//|| SHADE Includes ||
|
||||
//#==============================================================#
|
||||
#include "Editor/SHEditor.hpp"
|
||||
#include "SHEditorMenuBar.h"
|
||||
#include "Editor/IconsMaterialDesign.h"
|
||||
#include "Editor/Command/SHCommandManager.h"
|
||||
#include "Scripting/SHScriptEngine.h"
|
||||
#include "Editor/SHEditor.hpp"
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
|
||||
//#==============================================================#
|
||||
|
@ -95,7 +95,8 @@ namespace SHADE
|
|||
{
|
||||
if(ImGui::Selectable(style.to_string().c_str()))
|
||||
{
|
||||
SHEditor::SetStyle(style.convert<SHEditor::Style>());
|
||||
if(auto editor = SHSystemManager::GetSystem<SHEditor>())
|
||||
editor->SetStyle(style.convert<SHEditor::Style>());
|
||||
}
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
|
|
|
@ -60,18 +60,18 @@ RTTR_REGISTRATION
|
|||
namespace SHADE
|
||||
{
|
||||
//#==============================================================#
|
||||
//|| Initialise static members ||
|
||||
//|| Init static members ||
|
||||
//#==============================================================#
|
||||
Handle<SHVkCommandPool> SHEditor::imguiCommandPool;
|
||||
Handle<SHVkCommandBuffer> SHEditor::imguiCommandBuffer;
|
||||
SHEditor::EditorWindowMap SHEditor::editorWindows{};
|
||||
SHEditor::EditorWindowID SHEditor::windowCount{};
|
||||
std::vector<EntityID> SHEditor::selectedEntities;
|
||||
//Handle<SHVkCommandPool> SHEditor::imguiCommandPool;
|
||||
//Handle<SHVkCommandBuffer> SHEditor::imguiCommandBuffer;
|
||||
SHEditorWindowManager::EditorWindowMap SHEditorWindowManager::editorWindows{};
|
||||
SHEditorWindowManager::EditorWindowID SHEditorWindowManager::windowCount{};
|
||||
//std::vector<EntityID> SHEditor::selectedEntities;
|
||||
|
||||
//#==============================================================#
|
||||
//|| Public Member Functions ||
|
||||
//#==============================================================#
|
||||
void SHEditor::Initialise(SDL_Window* const sdlWindow)
|
||||
void SHEditor::Init()
|
||||
{
|
||||
IMGUI_CHECKVERSION();
|
||||
if(auto context = ImGui::CreateContext())
|
||||
|
@ -90,28 +90,28 @@ namespace SHADE
|
|||
|
||||
InitFonts();
|
||||
|
||||
|
||||
auto id = SHFamilyID<SHSystem>::GetID<SHGraphicsSystem>();
|
||||
auto id2 = SHFamilyID<SHSystem>::GetID<SHTransformSystem>();
|
||||
auto id3 = SHFamilyID<SHSystem>::GetID<SHGraphicsSystem>();
|
||||
InitBackend(sdlWindow);
|
||||
|
||||
InitBackend();
|
||||
|
||||
SetStyle(Style::SHADE);
|
||||
|
||||
//Add editor windows
|
||||
CreateEditorWindow<SHEditorMenuBar>();
|
||||
CreateEditorWindow<SHHierarchyPanel>();
|
||||
CreateEditorWindow<SHEditorInspector>();
|
||||
CreateEditorWindow<SHEditorProfiler>();
|
||||
SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>();
|
||||
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
|
||||
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
|
||||
SHEditorWindowManager::CreateEditorWindow<SHEditorProfiler>();
|
||||
|
||||
SHLOG_INFO("Successfully initialised SHADE Engine Editor")
|
||||
}
|
||||
|
||||
void SHEditor::Update(float const dt)
|
||||
void SHEditor::Update(double const dt)
|
||||
{
|
||||
(void)dt;
|
||||
NewFrame();
|
||||
for (const auto& window : editorWindows | std::views::values)
|
||||
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
|
||||
{
|
||||
if(window->isOpen)
|
||||
window->Update();
|
||||
|
@ -260,7 +260,7 @@ namespace SHADE
|
|||
//#==============================================================#
|
||||
//|| Private Member Functions ||
|
||||
//#==============================================================#
|
||||
void SHEditor::InitBackend(SDL_Window* sdlWindow)
|
||||
void SHEditor::InitBackend()
|
||||
{
|
||||
if(ImGui_ImplSDL2_InitForVulkan(sdlWindow) == false)
|
||||
{
|
||||
|
@ -322,4 +322,9 @@ namespace SHADE
|
|||
}
|
||||
|
||||
|
||||
void SHEditor::EditorRoutine::Execute(double dt) noexcept
|
||||
{
|
||||
reinterpret_cast<SHEditor*>(system)->Update(dt);
|
||||
}
|
||||
|
||||
}//namespace SHADE
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
//#==============================================================#
|
||||
#include "SH_API.h"
|
||||
#include "ECS_Base/SHECSMacros.h"
|
||||
#include "ECS_Base/System/SHSystem.h"
|
||||
#include "ECS_Base/System/SHSystemRoutine.h"
|
||||
#include "Resource/Handle.h"
|
||||
#include "EditorWindow/SHEditorWindow.h"
|
||||
#include "Tools/SHLogger.h"
|
||||
|
@ -28,11 +30,7 @@ namespace SHADE
|
|||
class SHVkCommandBuffer;
|
||||
class SHVkCommandPool;
|
||||
|
||||
/**
|
||||
* @brief SHEditor static class contains editor variables and implementation of editor functions.
|
||||
*
|
||||
*/
|
||||
class SH_API SHEditor
|
||||
class SHEditorWindowManager
|
||||
{
|
||||
public:
|
||||
//#==============================================================#
|
||||
|
@ -41,46 +39,6 @@ namespace SHADE
|
|||
using EditorWindowID = uint8_t;
|
||||
using EditorWindowPtr = std::unique_ptr<SHEditorWindow>;
|
||||
using EditorWindowMap = std::unordered_map<EditorWindowID, EditorWindowPtr>;
|
||||
|
||||
/**
|
||||
* @brief Style options
|
||||
*
|
||||
*/
|
||||
enum class Style : uint8_t
|
||||
{
|
||||
SHADE,
|
||||
DARK,
|
||||
LIGHT,
|
||||
CLASSIC
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialise the editor
|
||||
*
|
||||
* @param sdlWindow pointer to SDL_Window object created in application
|
||||
*/
|
||||
static void Initialise(SDL_Window* sdlWindow);
|
||||
|
||||
/**
|
||||
* @brief Update the editor and add to ImGui DrawList
|
||||
*
|
||||
* @param dt Delta-time of the frame
|
||||
*/
|
||||
static void Update(float dt);
|
||||
|
||||
/**
|
||||
* @brief Safely shutdown the editor
|
||||
*
|
||||
*/
|
||||
static void Exit();
|
||||
|
||||
/**
|
||||
* @brief Set the Style for the editor
|
||||
*
|
||||
* @param style Desired style
|
||||
*/
|
||||
static void SetStyle(Style style);
|
||||
|
||||
/**
|
||||
* @brief Get ID for the Editor Window Type
|
||||
*
|
||||
|
@ -100,39 +58,6 @@ namespace SHADE
|
|||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get pointer to the Editor Window
|
||||
*
|
||||
* @tparam T Type of editor window to retrieve
|
||||
* @return T* Pointer to the editor window
|
||||
*/
|
||||
template <typename T, std::enable_if_t<std::is_base_of_v<SHEditorWindow, T>, bool> = true>
|
||||
static T* GetEditorWindow()
|
||||
{
|
||||
return reinterpret_cast<T*>(editorWindows[GetEditorWindowID<T>()].get());
|
||||
}
|
||||
|
||||
// List of selected entities
|
||||
static std::vector<EntityID> selectedEntities;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Initialise Backend for ImGui (SDL and Vulkan backend)
|
||||
*
|
||||
* @param sdlWindow Pointer to SDL_Window
|
||||
*/
|
||||
static void InitBackend(SDL_Window* sdlWindow);
|
||||
/**
|
||||
* @brief Start new frame for editor
|
||||
*
|
||||
*/
|
||||
static void NewFrame();
|
||||
/**
|
||||
* @brief Perform ImGui and ImGui Backend Render
|
||||
*
|
||||
*/
|
||||
static void Render();
|
||||
|
||||
/**
|
||||
* @brief Create an Editor Window
|
||||
*
|
||||
|
@ -153,16 +78,114 @@ namespace SHADE
|
|||
}
|
||||
}
|
||||
|
||||
static void InitFonts() noexcept;
|
||||
|
||||
// Handle to command pool used for ImGui Vulkan Backend
|
||||
static Handle<SHVkCommandPool> imguiCommandPool;
|
||||
// Handle to command buffer used for ImGui Vulkan Backend
|
||||
static Handle<SHVkCommandBuffer> imguiCommandBuffer;
|
||||
/**
|
||||
* @brief Get pointer to the Editor Window
|
||||
*
|
||||
* @tparam T Type of editor window to retrieve
|
||||
* @return T* Pointer to the editor window
|
||||
*/
|
||||
template <typename T, std::enable_if_t<std::is_base_of_v<SHEditorWindow, T>, bool> = true>
|
||||
static T* GetEditorWindow()
|
||||
{
|
||||
return reinterpret_cast<T*>(editorWindows[GetEditorWindowID<T>()].get());
|
||||
}
|
||||
|
||||
private:
|
||||
// Number of windows; used for Editor Window ID Generation
|
||||
static EditorWindowID windowCount;
|
||||
// Map of Editor Windows
|
||||
static EditorWindowMap editorWindows;
|
||||
friend class SHEditor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief SHEditor static class contains editor variables and implementation of editor functions.
|
||||
*
|
||||
*/
|
||||
class SH_API SHEditor final : public SHSystem
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
class SH_API EditorRoutine final : public SHSystemRoutine
|
||||
{
|
||||
public:
|
||||
EditorRoutine() = default;
|
||||
void Execute(double dt) noexcept override final;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Style options
|
||||
*
|
||||
*/
|
||||
enum class Style : uint8_t
|
||||
{
|
||||
SHADE,
|
||||
DARK,
|
||||
LIGHT,
|
||||
CLASSIC
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialise the editor
|
||||
*
|
||||
* @param sdlWindow pointer to SDL_Window object created in application
|
||||
*/
|
||||
void Init();
|
||||
|
||||
/**
|
||||
* @brief Update the editor and add to ImGui DrawList
|
||||
*
|
||||
* @param dt Delta-time of the frame
|
||||
*/
|
||||
void Update(double dt);
|
||||
|
||||
/**
|
||||
* @brief Safely shutdown the editor
|
||||
*
|
||||
*/
|
||||
void Exit();
|
||||
|
||||
/**
|
||||
* @brief Set the Style for the editor
|
||||
*
|
||||
* @param style Desired style
|
||||
*/
|
||||
void SetStyle(Style style);
|
||||
|
||||
/**
|
||||
* @brief Initialise Backend for ImGui (SDL and Vulkan backend)
|
||||
*
|
||||
* @param sdlWindow Pointer to SDL_Window
|
||||
*/
|
||||
void InitBackend();
|
||||
|
||||
void SetSDLWindow(SDL_Window* inSDLWindow){sdlWindow = inSDLWindow;};
|
||||
|
||||
// List of selected entities
|
||||
std::vector<EntityID> selectedEntities;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Start new frame for editor
|
||||
*
|
||||
*/
|
||||
void NewFrame();
|
||||
/**
|
||||
* @brief Perform ImGui and ImGui Backend Render
|
||||
*
|
||||
*/
|
||||
void Render();
|
||||
|
||||
|
||||
|
||||
void InitFonts() noexcept;
|
||||
|
||||
// Handle to command pool used for ImGui Vulkan Backend
|
||||
Handle<SHVkCommandPool> imguiCommandPool;
|
||||
// Handle to command buffer used for ImGui Vulkan Backend
|
||||
Handle<SHVkCommandBuffer> imguiCommandBuffer;
|
||||
|
||||
SDL_Window* sdlWindow;
|
||||
};//class SHEditor
|
||||
}//namespace SHADE
|
||||
|
|
Loading…
Reference in New Issue