Editor changes to support viewport integration
This commit is contained in:
parent
e76bc6ef58
commit
033ba48304
|
@ -0,0 +1,48 @@
|
||||||
|
[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,120
|
||||||
|
Size=225,940
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000004,0
|
||||||
|
|
||||||
|
[Window][Debug##Default]
|
||||||
|
Pos=60,60
|
||||||
|
Size=400,400
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Inspector]
|
||||||
|
Pos=1686,24
|
||||||
|
Size=234,1036
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000006,0
|
||||||
|
|
||||||
|
[Window][Profiler]
|
||||||
|
Pos=0,24
|
||||||
|
Size=225,94
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000003,0
|
||||||
|
|
||||||
|
[Window][Viewport]
|
||||||
|
Pos=227,24
|
||||||
|
Size=1457,1036
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000002,0
|
||||||
|
|
||||||
|
[Docking][Data]
|
||||||
|
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=8,55 Size=1920,1036 Split=X
|
||||||
|
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1684,1036 Split=X
|
||||||
|
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=225,1036 Split=Y Selected=0x1E6EB881
|
||||||
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,94 Selected=0x1E6EB881
|
||||||
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,940 Selected=0xE096E5AE
|
||||||
|
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1293,1036 CentralNode=1 Selected=0x13926F0B
|
||||||
|
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=234,1036 Selected=0xE7039252
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
[Window][MainStatusBar]
|
||||||
|
Pos=0,1167
|
||||||
|
Size=2314,20
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][SHEditorMenuBar]
|
||||||
|
Pos=0,48
|
||||||
|
Size=2314,1119
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Hierarchy Panel]
|
||||||
|
Pos=0,152
|
||||||
|
Size=208,1015
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000004,0
|
||||||
|
|
||||||
|
[Window][Debug##Default]
|
||||||
|
Pos=60,60
|
||||||
|
Size=400,400
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Inspector]
|
||||||
|
Pos=2044,48
|
||||||
|
Size=270,1119
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000006,0
|
||||||
|
|
||||||
|
[Window][Profiler]
|
||||||
|
Pos=0,48
|
||||||
|
Size=208,102
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000003,0
|
||||||
|
|
||||||
|
[Window][Viewport]
|
||||||
|
Pos=210,48
|
||||||
|
Size=1832,1119
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000002,0
|
||||||
|
|
||||||
|
[Docking][Data]
|
||||||
|
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=-7,358 Size=2314,1119 Split=X
|
||||||
|
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=2042,1036 Split=X
|
||||||
|
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=208,1036 Split=Y Selected=0x1E6EB881
|
||||||
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,94 Selected=0x1E6EB881
|
||||||
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,940 Selected=0xE096E5AE
|
||||||
|
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1832,1036 CentralNode=1 Selected=0x13926F0B
|
||||||
|
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=270,1036 Selected=0xE7039252
|
||||||
|
|
|
@ -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());
|
||||||
|
|
|
@ -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,29 @@ 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(windowSize.x != wndSize.x || windowSize.y != wndSize.y)
|
||||||
|
{
|
||||||
|
windowSize = {wndSize.x, wndSize.y};
|
||||||
|
OnResize();
|
||||||
|
}
|
||||||
|
auto wndPos = ImGui::GetWindowPos();
|
||||||
|
if(windowPos.x != wndPos.x || windowPos.y != wndPos.y)
|
||||||
|
{
|
||||||
|
windowPos = {wndPos.x, wndPos.y};
|
||||||
|
OnPosChange();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorWindow::OnResize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorWindow::OnPosChange()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "Math/Vector/SHVec2.h"
|
||||||
|
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
//|| Forward Declarations ||
|
//|| Forward Declarations ||
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
|
@ -21,11 +23,16 @@ 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();
|
||||||
|
virtual void OnPosChange();
|
||||||
|
|
||||||
ImGuiWindowFlags windowFlags = 0;
|
ImGuiWindowFlags windowFlags = 0;
|
||||||
ImGuiIO& io;
|
ImGuiIO& io;
|
||||||
|
SHVec2 windowSize;
|
||||||
|
SHVec2 windowPos;
|
||||||
};//class SHEditorWindow
|
};//class SHEditorWindow
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
|
@ -3,3 +3,4 @@
|
||||||
#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,60 @@
|
||||||
|
#include "SHpch.h"
|
||||||
|
#include "SHEditorViewport.h"
|
||||||
|
|
||||||
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||||
|
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
SHEditorViewport::SHEditorViewport()
|
||||||
|
:SHEditorWindow("Viewport", ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoScrollbar)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::Init()
|
||||||
|
{
|
||||||
|
SHEditorWindow::Init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::Update()
|
||||||
|
{
|
||||||
|
SHEditorWindow::Update();
|
||||||
|
if(Begin())
|
||||||
|
{
|
||||||
|
DrawMenuBar();
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
auto const& descriptorSet = gfxSystem->GetPostOffscreenRenderSystem()->GetDescriptorSetGroup()->GetVkHandle()[0];
|
||||||
|
ImGui::Image((ImTextureID)descriptorSet, ImGui::GetWindowSize());
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::Exit()
|
||||||
|
{
|
||||||
|
SHEditorWindow::Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::OnResize()
|
||||||
|
{
|
||||||
|
SHEditorWindow::OnResize();
|
||||||
|
//Get graphics system to resize swapchain image
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
|
||||||
|
gfxSystem->PrepareResize(static_cast<uint32_t>(windowSize.x), static_cast<uint32_t>(windowSize.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::OnPosChange()
|
||||||
|
{
|
||||||
|
SHEditorWindow::OnPosChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorViewport::DrawMenuBar() const noexcept
|
||||||
|
{
|
||||||
|
if(ImGui::BeginMenuBar())
|
||||||
|
{
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//namespace SHADE
|
|
@ -0,0 +1,29 @@
|
||||||
|
#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:
|
||||||
|
void OnResize() override;
|
||||||
|
void OnPosChange() 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")
|
||||||
}
|
}
|
||||||
|
@ -126,35 +139,45 @@ 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();
|
||||||
|
@ -281,10 +304,11 @@ namespace SHADE
|
||||||
imguiCommandPool = gfxSystem->GetDevice()->CreateCommandPool(SH_QUEUE_FAMILY_ARRAY_INDEX::GRAPHICS, SH_CMD_POOL_RESET::POOL_BASED, true);
|
imguiCommandPool = gfxSystem->GetDevice()->CreateCommandPool(SH_QUEUE_FAMILY_ARRAY_INDEX::GRAPHICS, SH_CMD_POOL_RESET::POOL_BASED, true);
|
||||||
imguiCommandBuffer = imguiCommandPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
|
imguiCommandBuffer = imguiCommandPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
|
||||||
|
|
||||||
auto const& renderers = gfxSystem->GetDefaultViewport()->GetRenderers();
|
//auto const& renderers = gfxSystem->GetDefaultViewport()->GetRenderers();
|
||||||
|
auto const& renderers = gfxSystem->GetEditorViewport()->GetRenderers();
|
||||||
|
|
||||||
SHASSERT(!renderers.empty(), "No Renderers available")
|
SHASSERT(!renderers.empty(), "No Renderers available")
|
||||||
auto renderGraph = renderers[0]->GetRenderGraph();
|
auto renderGraph = renderers[SHGraphicsConstants::RenderGraphIndices::EDITOR]->GetRenderGraph();
|
||||||
auto renderPass = renderGraph->GetNode("ImGui Node")->GetRenderpass();
|
auto renderPass = renderGraph->GetNode("ImGui Node")->GetRenderpass();
|
||||||
|
|
||||||
if(ImGui_ImplVulkan_Init(&initInfo, renderPass->GetVkRenderpass()) == false)
|
if(ImGui_ImplVulkan_Init(&initInfo, renderPass->GetVkRenderpass()) == false)
|
||||||
|
@ -309,6 +333,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
|
||||||
|
|
Loading…
Reference in New Issue