Editor fixes
Integration of mouse pick Add editor state Add editor layout
This commit is contained in:
parent
22cad78728
commit
228868604a
|
@ -0,0 +1,42 @@
|
||||||
|
[Window][MainStatusBar]
|
||||||
|
Pos=0,1060
|
||||||
|
Size=1920,20
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][SHEditorMenuBar]
|
||||||
|
Pos=0,24
|
||||||
|
Size=1920,1036
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Hierarchy Panel]
|
||||||
|
Pos=0,89
|
||||||
|
Size=286,971
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000004,0
|
||||||
|
|
||||||
|
[Window][Debug##Default]
|
||||||
|
Pos=60,60
|
||||||
|
Size=400,400
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Inspector]
|
||||||
|
Pos=1494,24
|
||||||
|
Size=426,1036
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000006,0
|
||||||
|
|
||||||
|
[Window][Profiler]
|
||||||
|
Pos=0,24
|
||||||
|
Size=286,63
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000003,0
|
||||||
|
|
||||||
|
[Docking][Data]
|
||||||
|
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=8,55 Size=1920,1036 Split=X
|
||||||
|
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1492,1036 Split=X
|
||||||
|
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=286,1036 Split=Y Selected=0xE096E5AE
|
||||||
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=140,63 Selected=0x1E6EB881
|
||||||
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=140,971 Selected=0xE096E5AE
|
||||||
|
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1204,1036 CentralNode=1
|
||||||
|
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=426,1036 Selected=0xE7039252
|
||||||
|
|
|
@ -130,18 +130,29 @@ namespace Sandbox
|
||||||
void SBApplication::Update(void)
|
void SBApplication::Update(void)
|
||||||
{
|
{
|
||||||
SHGraphicsSystem* graphicsSystem = SHADE::SHSystemManager::GetSystem<SHGraphicsSystem>();
|
SHGraphicsSystem* graphicsSystem = SHADE::SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
SHEditor* editor = SHADE::SHSystemManager::GetSystem<SHEditor>();
|
||||||
//TODO: Change true to window is open
|
//TODO: Change true to window is open
|
||||||
while (!window.WindowShouldClose())
|
while (!window.WindowShouldClose())
|
||||||
{
|
{
|
||||||
SHFrameRateController::UpdateFRC();
|
SHFrameRateController::UpdateFRC();
|
||||||
SHInputManager::UpdateInput(SHFrameRateController::GetRawDeltaTime());
|
SHInputManager::UpdateInput(SHFrameRateController::GetRawDeltaTime());
|
||||||
SHSceneManager::UpdateSceneManager();
|
SHSceneManager::UpdateSceneManager();
|
||||||
SHSceneManager::SceneUpdate(0.016f);
|
#ifdef SHEDITOR
|
||||||
|
if(editor->editorState == SHEditor::State::PLAY)
|
||||||
|
#endif
|
||||||
|
SHSceneManager::SceneUpdate(0.016f);
|
||||||
|
#ifdef SHEDITOR
|
||||||
|
SHSystemManager::RunRoutines(editor->editorState != SHEditor::State::PLAY, 0.016f);
|
||||||
|
if(auto editor = SHSystemManager::GetSystem<SHEditor>())
|
||||||
|
{
|
||||||
|
editor->PollPicking();
|
||||||
|
}
|
||||||
|
#else
|
||||||
SHSystemManager::RunRoutines(false, 0.016f);
|
SHSystemManager::RunRoutines(false, 0.016f);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish all graphics jobs first
|
// Finish all graphics jobs first
|
||||||
graphicsSystem->AwaitGraphicsExecution();
|
graphicsSystem->AwaitGraphicsExecution();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,8 @@ namespace SHADE
|
||||||
editor->selectedEntities.clear();
|
editor->selectedEntities.clear();
|
||||||
}
|
}
|
||||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);
|
ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHHierarchyPanel::Exit()
|
void SHHierarchyPanel::Exit()
|
||||||
|
@ -75,6 +75,11 @@ namespace SHADE
|
||||||
SHEditorWindow::Exit();
|
SHEditorWindow::Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHHierarchyPanel::SetScrollTo(EntityID eid)
|
||||||
|
{
|
||||||
|
scrollTo = eid;
|
||||||
|
}
|
||||||
|
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
//|| Private Member Functions ||
|
//|| Private Member Functions ||
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
|
@ -82,7 +87,20 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::BeginMenuBar())
|
||||||
{
|
{
|
||||||
if (ImGui::SmallButton(ICON_MD_ADD))
|
|
||||||
|
ImGui::SetCursorPosX(ImGui::GetContentRegionAvail().x - 35.0f);
|
||||||
|
if(ImGui::SmallButton(ICON_MD_DESELECT))
|
||||||
|
{
|
||||||
|
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
|
editor->selectedEntities.clear();
|
||||||
|
}
|
||||||
|
if (ImGui::IsItemHovered())
|
||||||
|
{
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
ImGui::Text("Clear Selections");
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
if (ImGui::SmallButton(ICON_MD_ADD_CIRCLE))
|
||||||
{
|
{
|
||||||
SHEntityManager::CreateEntity();
|
SHEntityManager::CreateEntity();
|
||||||
}
|
}
|
||||||
|
@ -103,6 +121,13 @@ namespace SHADE
|
||||||
//Get node data (Children, eid, selected)
|
//Get node data (Children, eid, selected)
|
||||||
auto& children = currentNode->GetChildren();
|
auto& children = currentNode->GetChildren();
|
||||||
EntityID eid = currentNode->GetEntityID();
|
EntityID eid = currentNode->GetEntityID();
|
||||||
|
|
||||||
|
if(scrollTo != MAX_EID && eid == scrollTo)
|
||||||
|
{
|
||||||
|
ImGui::SetScrollHereY();
|
||||||
|
scrollTo = MAX_EID;
|
||||||
|
}
|
||||||
|
|
||||||
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
|
|
||||||
const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end());
|
const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end());
|
||||||
|
@ -157,7 +182,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle node selection
|
//Handle node selection
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,11 +23,13 @@ namespace SHADE
|
||||||
void Init() override;
|
void Init() override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
void Exit() override;
|
void Exit() override;
|
||||||
|
void SetScrollTo(EntityID eid);
|
||||||
private:
|
private:
|
||||||
void DrawMenuBar() const noexcept;
|
void DrawMenuBar() const noexcept;
|
||||||
ImRect RecursivelyDrawEntityNode(SHSceneNode*);
|
ImRect RecursivelyDrawEntityNode(SHSceneNode*);
|
||||||
void CreateChildEntity(EntityID parentEID) const noexcept;
|
void CreateChildEntity(EntityID parentEID) const noexcept;
|
||||||
std::string filter;
|
std::string filter;
|
||||||
bool isAnyNodeSelected = false;
|
bool isAnyNodeSelected = false;
|
||||||
|
EntityID scrollTo = MAX_EID;
|
||||||
};//class SHHierarchyPanel
|
};//class SHHierarchyPanel
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
|
@ -207,8 +207,10 @@ namespace SHADE
|
||||||
auto& colliders = component->GetColliders();
|
auto& colliders = component->GetColliders();
|
||||||
int const size = static_cast<int>(colliders.size());
|
int const size = static_cast<int>(colliders.size());
|
||||||
ImGui::BeginChild("Colliders", {0.0f, colliders.empty() ? 1.0f : 250.0f}, true);
|
ImGui::BeginChild("Colliders", {0.0f, colliders.empty() ? 1.0f : 250.0f}, true);
|
||||||
|
std::optional<int> colliderToDelete{std::nullopt};
|
||||||
for (int i{}; i < size; ++i)
|
for (int i{}; i < size; ++i)
|
||||||
{
|
{
|
||||||
|
ImGui::PushID(i);
|
||||||
SHCollider& collider = component->GetCollider(i);
|
SHCollider& collider = component->GetCollider(i);
|
||||||
auto cursorPos = ImGui::GetCursorPos();
|
auto cursorPos = ImGui::GetCursorPos();
|
||||||
|
|
||||||
|
@ -235,9 +237,14 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
if(ImGui::Button(std::format("{} Remove Collider #{}", ICON_MD_REMOVE, i).data()))
|
if(ImGui::Button(std::format("{} Remove Collider #{}", ICON_MD_REMOVE, i).data()))
|
||||||
{
|
{
|
||||||
component->RemoveCollider(i);
|
colliderToDelete = i;
|
||||||
}
|
}
|
||||||
SHEditorWidgets::EndPanel();
|
SHEditorWidgets::EndPanel();
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
if(colliderToDelete.has_value())
|
||||||
|
{
|
||||||
|
component->RemoveCollider(colliderToDelete.value());
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,8 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditorInspector::Exit()
|
void SHEditorInspector::Exit()
|
||||||
|
|
|
@ -36,6 +36,11 @@ namespace SHADE
|
||||||
void SHEditorMenuBar::Init()
|
void SHEditorMenuBar::Init()
|
||||||
{
|
{
|
||||||
SHEditorWindow::Init();
|
SHEditorWindow::Init();
|
||||||
|
constexpr std::string_view path = "../../Assets/Editor/Layouts";
|
||||||
|
for(auto const& entry : std::filesystem::directory_iterator(path))
|
||||||
|
{
|
||||||
|
layoutPaths.push_back(entry.path());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditorMenuBar::Update()
|
void SHEditorMenuBar::Update()
|
||||||
|
@ -87,20 +92,6 @@ namespace SHADE
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
if(ImGui::BeginMenu("Theme"))
|
|
||||||
{
|
|
||||||
auto styles = rttr::type::get<SHEditor::Style>().get_enumeration();
|
|
||||||
auto values = styles.get_values();
|
|
||||||
for (auto style : values)
|
|
||||||
{
|
|
||||||
if(ImGui::Selectable(style.to_string().c_str()))
|
|
||||||
{
|
|
||||||
if(auto editor = SHSystemManager::GetSystem<SHEditor>())
|
|
||||||
editor->SetStyle(style.convert<SHEditor::Style>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::EndMenu();
|
|
||||||
}
|
|
||||||
if (ImGui::BeginMenu("Scripts"))
|
if (ImGui::BeginMenu("Scripts"))
|
||||||
{
|
{
|
||||||
if (ImGui::Selectable("Generate Visual Studio Project"))
|
if (ImGui::Selectable("Generate Visual Studio Project"))
|
||||||
|
@ -120,18 +111,79 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu("Window"))
|
||||||
|
{
|
||||||
|
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
|
||||||
|
{
|
||||||
|
if (window.get() != this)
|
||||||
|
ImGui::Checkbox(window->windowName.data(), &window->isOpen);
|
||||||
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
if (ImGui::BeginMenu("Theme"))
|
||||||
|
{
|
||||||
|
const auto styles = rttr::type::get<SHEditor::Style>().get_enumeration();
|
||||||
|
auto values = styles.get_values();
|
||||||
|
for (auto style : values)
|
||||||
|
{
|
||||||
|
if (ImGui::Selectable(style.to_string().c_str()))
|
||||||
|
{
|
||||||
|
if (auto editor = SHSystemManager::GetSystem<SHEditor>())
|
||||||
|
editor->SetStyle(style.convert<SHEditor::Style>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
if(ImGui::BeginMenu("Layout"))
|
||||||
|
{
|
||||||
|
for(auto const& entry : layoutPaths)
|
||||||
|
{
|
||||||
|
if(ImGui::Selectable(entry.stem().string().c_str()))
|
||||||
|
{
|
||||||
|
ImGui::LoadIniSettingsFromDisk(entry.string().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
ImGui::EndMainMenuBar();
|
ImGui::EndMainMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImGuiID dockspace_id = ImGui::GetID("DockSpace");
|
const ImGuiID dockspaceId = ImGui::GetID("DockSpace");
|
||||||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspaceFlags);
|
ImGui::DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditorMenuBar::DrawSecondaryBar() const noexcept
|
void SHEditorMenuBar::DrawSecondaryBar() const noexcept
|
||||||
{
|
{
|
||||||
|
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||||
|
if(ImGui::BeginViewportSideBar("##SecondaryMenuBar", viewport, ImGuiDir_Up, ImGui::GetFrameHeight(), ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_MenuBar))
|
||||||
|
{
|
||||||
|
ImGui::BeginMenuBar();
|
||||||
|
ImGui::SetCursorPosX(ImGui::GetContentRegionAvail().x * 0.5f - 80.f);
|
||||||
|
const auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
|
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PLAY);
|
||||||
|
if(ImGui::SmallButton(ICON_MD_PLAY_ARROW))
|
||||||
|
{
|
||||||
|
editor->editorState = SHEditor::State::PLAY;
|
||||||
|
}
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PAUSE);
|
||||||
|
if(ImGui::SmallButton(ICON_MD_PAUSE))
|
||||||
|
{
|
||||||
|
editor->editorState = SHEditor::State::PAUSE;
|
||||||
|
}
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
ImGui::BeginDisabled(editor->editorState == SHEditor::State::STOP);
|
||||||
|
if(ImGui::SmallButton(ICON_MD_STOP))
|
||||||
|
{
|
||||||
|
editor->editorState = SHEditor::State::STOP;
|
||||||
|
}
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditorMenuBar::DrawStatusBar() const noexcept
|
void SHEditorMenuBar::DrawStatusBar() const noexcept
|
||||||
|
@ -142,8 +194,8 @@ namespace SHADE
|
||||||
if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags))
|
if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags))
|
||||||
{
|
{
|
||||||
ImGui::Text("Entity count: ");
|
ImGui::Text("Entity count: ");
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
|
ImGui::End();
|
||||||
ImGui::PopStyleVar(3);
|
ImGui::PopStyleVar(3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,5 +18,6 @@ namespace SHADE
|
||||||
void DrawSecondaryBar() const noexcept;
|
void DrawSecondaryBar() const noexcept;
|
||||||
void DrawStatusBar() const noexcept;
|
void DrawStatusBar() const noexcept;
|
||||||
float menuBarHeight = 20.0f;
|
float menuBarHeight = 20.0f;
|
||||||
|
std::vector<std::filesystem::path> layoutPaths;
|
||||||
};//class SHEditorMenuBar
|
};//class SHEditorMenuBar
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
|
@ -37,8 +37,8 @@ namespace SHADE
|
||||||
if(Begin())
|
if(Begin())
|
||||||
{
|
{
|
||||||
ImGui::PlotLines("DT", frames.data(), static_cast<int>(frames.size()), 0, nullptr, 0.0f, 16.0f);
|
ImGui::PlotLines("DT", frames.data(), static_cast<int>(frames.size()), 0, nullptr, 0.0f, 16.0f);
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditorProfiler::Exit()
|
void SHEditorProfiler::Exit()
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace SHADE
|
||||||
//|| Public Member Functions ||
|
//|| Public Member Functions ||
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
SHEditorWindow::SHEditorWindow(std::string_view const& name, ImGuiWindowFlags const& inFlags)
|
SHEditorWindow::SHEditorWindow(std::string_view const& name, ImGuiWindowFlags const& inFlags)
|
||||||
: isOpen(true), windowName(name), windowFlags(inFlags), io(ImGui::GetIO())
|
: windowName(name), windowFlags(inFlags), io(ImGui::GetIO())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,19 @@ namespace SHADE
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
bool SHEditorWindow::Begin()
|
bool SHEditorWindow::Begin()
|
||||||
{
|
{
|
||||||
return ImGui::Begin(windowName.data(), &isOpen, windowFlags);
|
bool result = ImGui::Begin(windowName.data(), &isOpen, windowFlags);
|
||||||
|
|
||||||
|
auto wndSize = ImGui::GetWindowSize();
|
||||||
|
if(size.x != wndSize.x || size.y != wndSize.y)
|
||||||
|
{
|
||||||
|
size = {wndSize.x, wndSize.y};
|
||||||
|
OnResize();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorWindow::OnResize()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "Math/Vector/SHVec2.h"
|
||||||
|
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
//|| Forward Declarations ||
|
//|| Forward Declarations ||
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
|
@ -21,11 +23,14 @@ namespace SHADE
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void Update();
|
virtual void Update();
|
||||||
virtual void Exit();
|
virtual void Exit();
|
||||||
bool isOpen = false;
|
bool isOpen;
|
||||||
std::string_view windowName;
|
std::string_view windowName;
|
||||||
protected:
|
protected:
|
||||||
virtual bool Begin();
|
virtual bool Begin();
|
||||||
|
virtual void OnResize();
|
||||||
ImGuiWindowFlags windowFlags = 0;
|
ImGuiWindowFlags windowFlags = 0;
|
||||||
ImGuiIO& io;
|
ImGuiIO& io;
|
||||||
|
SHVec2 size;
|
||||||
|
SHVec2 pos;
|
||||||
};//class SHEditorWindow
|
};//class SHEditorWindow
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
|
@ -2,4 +2,5 @@
|
||||||
#include "MenuBar/SHEditorMenuBar.h" //Menu Bar
|
#include "MenuBar/SHEditorMenuBar.h" //Menu Bar
|
||||||
#include "HierarchyPanel/SHHierarchyPanel.h" //Hierarchy Panel
|
#include "HierarchyPanel/SHHierarchyPanel.h" //Hierarchy Panel
|
||||||
#include "Inspector/SHEditorInspector.h" //Inspector
|
#include "Inspector/SHEditorInspector.h" //Inspector
|
||||||
#include "Profiling/SHEditorProfiler.h" //Profiler
|
#include "Profiling/SHEditorProfiler.h" //Profiler
|
||||||
|
#include "ViewportWindow/SHEditorViewport.h" //Editor Viewport
|
|
@ -0,0 +1,45 @@
|
||||||
|
#include "SHpch.h"
|
||||||
|
#include "SHEditorViewport.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
SHEditorViewport::SHEditorViewport()
|
||||||
|
:SHEditorWindow("Viewport", ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoScrollbar)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::Init()
|
||||||
|
{
|
||||||
|
SHEditorWindow::Init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::Update()
|
||||||
|
{
|
||||||
|
SHEditorWindow::Update();
|
||||||
|
if(Begin())
|
||||||
|
{
|
||||||
|
DrawMenuBar();
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::Exit()
|
||||||
|
{
|
||||||
|
SHEditorWindow::Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::OnResize()
|
||||||
|
{
|
||||||
|
SHEditorWindow::OnResize();
|
||||||
|
//Get graphics system to resize swapchain image
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::DrawMenuBar() const noexcept
|
||||||
|
{
|
||||||
|
if(ImGui::BeginMenuBar())
|
||||||
|
{
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//namespace SHADE
|
|
@ -0,0 +1,28 @@
|
||||||
|
#pragma once
|
||||||
|
//#==============================================================#
|
||||||
|
//|| Library Includes ||
|
||||||
|
//#==============================================================#
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
//#==============================================================#
|
||||||
|
//|| SHADE Includes ||
|
||||||
|
//#==============================================================#
|
||||||
|
#include "imgui_internal.h"
|
||||||
|
#include "ECS_Base/SHECSMacros.h"
|
||||||
|
#include "Editor/EditorWindow/SHEditorWindow.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
class SHEditorViewport final : public SHEditorWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SHEditorViewport();
|
||||||
|
void Init() override;
|
||||||
|
void Update() override;
|
||||||
|
void Exit() override;
|
||||||
|
protected:
|
||||||
|
virtual void OnResize() override;
|
||||||
|
private:
|
||||||
|
void DrawMenuBar() const noexcept;
|
||||||
|
};//class SHEditorViewport
|
||||||
|
}//namespace SHADE
|
|
@ -43,6 +43,8 @@
|
||||||
#include <backends/imgui_impl_sdl.h>
|
#include <backends/imgui_impl_sdl.h>
|
||||||
#include <backends/imgui_impl_vulkan.h>
|
#include <backends/imgui_impl_vulkan.h>
|
||||||
|
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHMousePickSystem.h"
|
||||||
|
|
||||||
RTTR_REGISTRATION
|
RTTR_REGISTRATION
|
||||||
{
|
{
|
||||||
using namespace SHADE;
|
using namespace SHADE;
|
||||||
|
@ -73,6 +75,7 @@ namespace SHADE
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
void SHEditor::Init()
|
void SHEditor::Init()
|
||||||
{
|
{
|
||||||
|
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
if(auto context = ImGui::CreateContext())
|
if(auto context = ImGui::CreateContext())
|
||||||
{
|
{
|
||||||
|
@ -82,11 +85,21 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
//Add editor windows
|
||||||
|
SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>();
|
||||||
|
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
|
||||||
|
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
|
||||||
|
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
|
||||||
|
SHEditorWindowManager::CreateEditorWindow<SHEditorProfiler>();
|
||||||
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io = &ImGui::GetIO();
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; //Enable for Multi-Viewports
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; //Enable docking
|
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
io->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; //Enable for Multi-Viewports
|
||||||
|
io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; //Enable docking
|
||||||
|
io->IniFilename = "../../Assets/Editor/Layouts/UserLayout.ini";
|
||||||
|
|
||||||
|
InitLayout();
|
||||||
|
|
||||||
InitFonts();
|
InitFonts();
|
||||||
|
|
||||||
|
@ -98,11 +111,11 @@ namespace SHADE
|
||||||
|
|
||||||
SetStyle(Style::SHADE);
|
SetStyle(Style::SHADE);
|
||||||
|
|
||||||
//Add editor windows
|
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>();
|
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
|
{
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
|
window->Init();
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHEditorProfiler>();
|
}
|
||||||
|
|
||||||
SHLOG_INFO("Successfully initialised SHADE Engine Editor")
|
SHLOG_INFO("Successfully initialised SHADE Engine Editor")
|
||||||
}
|
}
|
||||||
|
@ -116,7 +129,7 @@ namespace SHADE
|
||||||
if(window->isOpen)
|
if(window->isOpen)
|
||||||
window->Update();
|
window->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_Z))
|
if(ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_Z))
|
||||||
{
|
{
|
||||||
SHCommandManager::RedoCommand();
|
SHCommandManager::RedoCommand();
|
||||||
|
@ -125,36 +138,46 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHCommandManager::UndoCommand();
|
SHCommandManager::UndoCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Render();
|
Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditor::Render()
|
void SHEditor::Render()
|
||||||
{
|
{
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
if (io->ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
|
||||||
{
|
{
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindowsDefault();
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHEditor::InitLayout() noexcept
|
||||||
|
{
|
||||||
|
if(!std::filesystem::exists(io->IniFilename))
|
||||||
|
{
|
||||||
|
std::filesystem::copy_file("../../Assets/Editor/Layouts/Default.ini", io->IniFilename);
|
||||||
|
}
|
||||||
|
//eventually load preferred layout here
|
||||||
|
}
|
||||||
|
|
||||||
void SHEditor::InitFonts() noexcept
|
void SHEditor::InitFonts() noexcept
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImFont* mainFont = io->Fonts->AddFontFromFileTTF("../../Assets/Editor/Fonts/Segoe UI.ttf", 20.f);//TODO: Change to config based assets path
|
||||||
ImFont* mainFont = io.Fonts->AddFontFromFileTTF("../../Assets/Editor/Fonts/Segoe UI.ttf", 20.f);//TODO: Change to config based assets path
|
|
||||||
|
|
||||||
static const ImWchar icon_ranges[] = { ICON_MIN_MD, ICON_MAX_16_MD, 0 };
|
constexpr ImWchar icon_ranges[] = { ICON_MIN_MD, ICON_MAX_16_MD, 0 };
|
||||||
ImFontConfig icons_config{}; icons_config.MergeMode = true; icons_config.GlyphOffset.y = 5.f;
|
ImFontConfig icons_config{}; icons_config.MergeMode = true; icons_config.GlyphOffset.y = 5.f;
|
||||||
ImFont* UIFont = io.Fonts->AddFontFromFileTTF("../../Assets/Editor/Fonts/MaterialIcons-Regular.ttf", 20.f, &icons_config, icon_ranges); //TODO: Change to config based assets path
|
ImFont* UIFont = io->Fonts->AddFontFromFileTTF("../../Assets/Editor/Fonts/MaterialIcons-Regular.ttf", 20.f, &icons_config, icon_ranges); //TODO: Change to config based assets path
|
||||||
|
|
||||||
io.Fonts->Build();
|
io->Fonts->Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditor::Exit()
|
void SHEditor::Exit()
|
||||||
{
|
{
|
||||||
|
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
|
||||||
|
{
|
||||||
|
window->Init();
|
||||||
|
}
|
||||||
ImGui_ImplVulkan_Shutdown();
|
ImGui_ImplVulkan_Shutdown();
|
||||||
ImGui_ImplSDL2_Shutdown();
|
ImGui_ImplSDL2_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
@ -309,6 +332,28 @@ namespace SHADE
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHEditor::PollPicking()
|
||||||
|
{
|
||||||
|
if (auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>())
|
||||||
|
{
|
||||||
|
if (!ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||||
|
{
|
||||||
|
EntityID pickedEID = gfxSystem->GetMousePickSystem()->GetPickedEntity();
|
||||||
|
if(pickedEID == MAX_EID)
|
||||||
|
return;
|
||||||
|
if (!ImGui::IsKeyDown(ImGuiKey_LeftCtrl))
|
||||||
|
{
|
||||||
|
if (const auto hierarchyPanel = SHEditorWindowManager::GetEditorWindow<SHHierarchyPanel>())
|
||||||
|
{
|
||||||
|
hierarchyPanel->SetScrollTo(pickedEID);
|
||||||
|
}
|
||||||
|
selectedEntities.clear();
|
||||||
|
}
|
||||||
|
selectedEntities.push_back(pickedEID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SHEditor::NewFrame()
|
void SHEditor::NewFrame()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
|
@ -90,11 +90,11 @@ namespace SHADE
|
||||||
return reinterpret_cast<T*>(editorWindows[GetEditorWindowID<T>()].get());
|
return reinterpret_cast<T*>(editorWindows[GetEditorWindowID<T>()].get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EditorWindowMap editorWindows;
|
||||||
private:
|
private:
|
||||||
// Number of windows; used for Editor Window ID Generation
|
// Number of windows; used for Editor Window ID Generation
|
||||||
static EditorWindowID windowCount;
|
static EditorWindowID windowCount;
|
||||||
// Map of Editor Windows
|
// Map of Editor Windows
|
||||||
static EditorWindowMap editorWindows;
|
|
||||||
friend class SHEditor;
|
friend class SHEditor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,10 +110,17 @@ namespace SHADE
|
||||||
class SH_API EditorRoutine final : public SHSystemRoutine
|
class SH_API EditorRoutine final : public SHSystemRoutine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EditorRoutine() = default;
|
EditorRoutine():SHSystemRoutine("Editor routine", true) {};
|
||||||
void Execute(double dt) noexcept override final;
|
void Execute(double dt) noexcept override final;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class State : uint8_t
|
||||||
|
{
|
||||||
|
PLAY,
|
||||||
|
PAUSE,
|
||||||
|
STOP
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Style options
|
* @brief Style options
|
||||||
*
|
*
|
||||||
|
@ -162,9 +169,13 @@ namespace SHADE
|
||||||
|
|
||||||
void SetSDLWindow(SDL_Window* inSDLWindow){sdlWindow = inSDLWindow;};
|
void SetSDLWindow(SDL_Window* inSDLWindow){sdlWindow = inSDLWindow;};
|
||||||
|
|
||||||
|
void PollPicking();
|
||||||
|
|
||||||
// List of selected entities
|
// List of selected entities
|
||||||
std::vector<EntityID> selectedEntities;
|
std::vector<EntityID> selectedEntities;
|
||||||
|
|
||||||
|
State editorState = State::STOP;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Start new frame for editor
|
* @brief Start new frame for editor
|
||||||
|
@ -177,7 +188,7 @@ namespace SHADE
|
||||||
*/
|
*/
|
||||||
void Render();
|
void Render();
|
||||||
|
|
||||||
|
void InitLayout() noexcept;
|
||||||
|
|
||||||
void InitFonts() noexcept;
|
void InitFonts() noexcept;
|
||||||
|
|
||||||
|
@ -186,6 +197,8 @@ namespace SHADE
|
||||||
// Handle to command buffer used for ImGui Vulkan Backend
|
// Handle to command buffer used for ImGui Vulkan Backend
|
||||||
Handle<SHVkCommandBuffer> imguiCommandBuffer;
|
Handle<SHVkCommandBuffer> imguiCommandBuffer;
|
||||||
|
|
||||||
SDL_Window* sdlWindow;
|
SDL_Window* sdlWindow {nullptr};
|
||||||
|
|
||||||
|
ImGuiIO* io{nullptr};
|
||||||
};//class SHEditor
|
};//class SHEditor
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
|
@ -571,7 +571,7 @@ namespace SHADE
|
||||||
/* System Routine Functions - BeginRoutine */
|
/* System Routine Functions - BeginRoutine */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
SHGraphicsSystem::BeginRoutine::BeginRoutine()
|
SHGraphicsSystem::BeginRoutine::BeginRoutine()
|
||||||
: SHSystemRoutine("Graphics System Frame Set Up", false)
|
: SHSystemRoutine("Graphics System Frame Set Up", true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void SHGraphicsSystem::BeginRoutine::Execute(double) noexcept
|
void SHGraphicsSystem::BeginRoutine::Execute(double) noexcept
|
||||||
|
@ -583,7 +583,7 @@ namespace SHADE
|
||||||
/* System Routine Functions - RenderRoutine */
|
/* System Routine Functions - RenderRoutine */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
SHGraphicsSystem::RenderRoutine::RenderRoutine()
|
SHGraphicsSystem::RenderRoutine::RenderRoutine()
|
||||||
: SHSystemRoutine("Graphics System Render", false)
|
: SHSystemRoutine("Graphics System Render", true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void SHGraphicsSystem::RenderRoutine::Execute(double dt) noexcept
|
void SHGraphicsSystem::RenderRoutine::Execute(double dt) noexcept
|
||||||
|
@ -595,7 +595,7 @@ namespace SHADE
|
||||||
/* System Routine Functions - EndRoutine */
|
/* System Routine Functions - EndRoutine */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
SHGraphicsSystem::EndRoutine::EndRoutine()
|
SHGraphicsSystem::EndRoutine::EndRoutine()
|
||||||
: SHSystemRoutine("Graphics System Frame Clean Up", false)
|
: SHSystemRoutine("Graphics System Frame Clean Up", true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void SHGraphicsSystem::EndRoutine::Execute(double) noexcept
|
void SHGraphicsSystem::EndRoutine::Execute(double) noexcept
|
||||||
|
@ -607,7 +607,7 @@ namespace SHADE
|
||||||
/* System Routine Functions - BatcherDispatcherRoutine */
|
/* System Routine Functions - BatcherDispatcherRoutine */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
SHGraphicsSystem::BatcherDispatcherRoutine::BatcherDispatcherRoutine()
|
SHGraphicsSystem::BatcherDispatcherRoutine::BatcherDispatcherRoutine()
|
||||||
: SHSystemRoutine("Graphics System Batcher Dispatcher", false)
|
: SHSystemRoutine("Graphics System Batcher Dispatcher", true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void SHGraphicsSystem::BatcherDispatcherRoutine::Execute(double) noexcept
|
void SHGraphicsSystem::BatcherDispatcherRoutine::Execute(double) noexcept
|
||||||
|
|
|
@ -11,8 +11,6 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
void SHMousePickSystem::Init(Handle<SHVkLogicalDevice> logicalDevice, std::span<Handle<SHVkCommandPool>> cmdPools, Handle<SHRenderGraphResource> eidAttachment) noexcept
|
void SHMousePickSystem::Init(Handle<SHVkLogicalDevice> logicalDevice, std::span<Handle<SHVkCommandPool>> cmdPools, Handle<SHRenderGraphResource> eidAttachment) noexcept
|
||||||
{
|
{
|
||||||
pickedEID = 0;
|
|
||||||
|
|
||||||
// Create command buffers
|
// Create command buffers
|
||||||
for (auto& pool : cmdPools)
|
for (auto& pool : cmdPools)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +32,7 @@ namespace SHADE
|
||||||
void SHMousePickSystem::Run(Handle<SHVkQueue> queue, uint32_t frameIndex) noexcept
|
void SHMousePickSystem::Run(Handle<SHVkQueue> queue, uint32_t frameIndex) noexcept
|
||||||
{
|
{
|
||||||
// if input detected
|
// if input detected
|
||||||
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::LEFT_CTRL) && SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
|
if (SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
|
||||||
{
|
{
|
||||||
afterCopyFence->Reset();
|
afterCopyFence->Reset();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace SHADE
|
||||||
Handle<SHVkBuffer> imageDataDstBuffer;
|
Handle<SHVkBuffer> imageDataDstBuffer;
|
||||||
|
|
||||||
//! eid picked from screen
|
//! eid picked from screen
|
||||||
EntityID pickedEID;
|
EntityID pickedEID = MAX_EID;
|
||||||
public:
|
public:
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* PUBLIC MEMBER FUNCTIONS */
|
/* PUBLIC MEMBER FUNCTIONS */
|
||||||
|
|
Loading…
Reference in New Issue