diff --git a/.gitignore b/.gitignore index 06ae45fd..1771ebb0 100644 --- a/.gitignore +++ b/.gitignore @@ -363,8 +363,6 @@ MigrationBackup/ *.filters -Assets/Editor/Layouts/UserLayout.ini - JSON/Schemas/Catalog/ Assets/Editor/Editor.SHConfig diff --git a/Assets/Application.SHConfig b/Assets/Application.SHConfig index ee5e42a8..5673556d 100644 --- a/Assets/Application.SHConfig +++ b/Assets/Application.SHConfig @@ -1,4 +1,4 @@ Start in Fullscreen: false -Starting Scene ID: 87244611 +Starting Scene ID: 97158628 Window Size: {x: 1920, y: 1080} Window Title: SHADE Engine \ No newline at end of file diff --git a/Assets/Editor/Editor.SHConfig b/Assets/Editor/Editor.SHConfig deleted file mode 100644 index c56772c9..00000000 --- a/Assets/Editor/Editor.SHConfig +++ /dev/null @@ -1,4 +0,0 @@ -Start Maximized: true -Working Scene ID: 97402985 -Window Size: {x: 1920, y: 1013} -Style: 0 \ No newline at end of file diff --git a/Assets/Editor/Layouts/UserLayout.ini b/Assets/Editor/Layouts/UserLayout.ini new file mode 100644 index 00000000..7c2df9e0 --- /dev/null +++ b/Assets/Editor/Layouts/UserLayout.ini @@ -0,0 +1,165 @@ +[Window][MainStatusBar] +Pos=0,989 +Size=1920,20 +Collapsed=0 + +[Window][SHEditorMenuBar] +Pos=0,48 +Size=1920,941 +Collapsed=0 + +[Window][Hierarchy Panel] +Pos=0,187 +Size=300,802 +Collapsed=0 +DockId=0x00000004,0 + +[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][Inspector] +Pos=1604,48 +Size=316,941 +Collapsed=0 +DockId=0x00000006,0 + +[Window][Profiler] +Pos=0,48 +Size=300,137 +Collapsed=0 +DockId=0x00000003,0 + +[Window][Viewport] +Pos=227,48 +Size=1457,1012 +Collapsed=0 +DockId=0x0000000B,0 + +[Window][面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面o] +Pos=60,60 +Size=32,64 +Collapsed=0 + +[Window][面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面] +Pos=60,60 +Size=999,581 +Collapsed=0 + +[Window][o] +Pos=60,60 +Size=32,64 +Collapsed=0 + +[Window][面面] +Pos=60,60 +Size=553,422 +Collapsed=0 + +[Window][] +Pos=60,60 +Size=770,394 +Collapsed=0 + +[Window][ Viewport] +Pos=227,48 +Size=1457,1012 +Collapsed=0 +DockId=0x0000000B,0 + +[Window][ Viewport] +Pos=227,48 +Size=1457,1012 +Collapsed=0 +DockId=0x0000000B,0 + +[Window][ Viewport] +Pos=302,48 +Size=1300,836 +Collapsed=0 +DockId=0x0000000B,0 + +[Window][V] +Pos=310,722 +Size=1501,338 +Collapsed=0 +DockId=0x00000008,0 + +[Window][p] +Pos=310,750 +Size=1501,310 +Collapsed=0 +DockId=0x0000000A,0 + +[Window][ Asset Browser] +Pos=302,886 +Size=1300,103 +Collapsed=0 +DockId=0x0000000C,0 + +[Window][Material Inspector] +Pos=1604,48 +Size=316,941 +Collapsed=0 +DockId=0x00000006,1 + +[Window][Save scene as...] +Pos=1197,693 +Size=165,120 +Collapsed=0 + +[Window][Create New Asset] +Pos=896,472 +Size=464,144 +Collapsed=0 + +[Window][Collider Tag Panel] +Pos=60,60 +Size=625,744 +Collapsed=0 + +[Window][Input Bindings Panel] +Pos=60,60 +Size=154,204 +Collapsed=0 + +[Window][Save Scene As] +Pos=877,444 +Size=165,120 +Collapsed=0 + +[Table][0x9D40AE32,17] +Column 0 Weight=1.0000 +Column 1 Weight=1.0000 +Column 2 Weight=1.0000 +Column 3 Weight=1.0000 +Column 4 Weight=1.0000 +Column 5 Weight=1.0000 +Column 6 Weight=1.0000 +Column 7 Weight=1.0000 +Column 8 Weight=1.0000 +Column 9 Weight=1.0000 +Column 10 Weight=1.0000 +Column 11 Weight=1.0000 +Column 12 Weight=1.0000 +Column 13 Weight=1.0000 +Column 14 Weight=1.0000 +Column 15 Weight=1.0000 +Column 16 Weight=1.0000 + +[Docking][Data] +DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,71 Size=1920,941 Split=X + DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1602,1036 Split=X + DockNode ID=0x00000001 Parent=0x00000005 SizeRef=300,1036 Split=Y Selected=0x1E6EB881 + DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,147 Selected=0x1E6EB881 + DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,863 Selected=0xE096E5AE + DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1300,1036 Split=Y Selected=0xB41284E7 + DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7 + DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7 + DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,836 CentralNode=1 Selected=0xB41284E7 + DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,103 Selected=0xB128252A + DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6 + DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532 + DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=316,1036 Selected=0xE7039252 + diff --git a/Assets/Materials/UIMat_LoseScene.shmat b/Assets/Materials/UIMat_LoseScene.shmat index b962f5ad..5be3677e 100644 --- a/Assets/Materials/UIMat_LoseScene.shmat +++ b/Assets/Materials/UIMat_LoseScene.shmat @@ -1,6 +1,6 @@ - VertexShader: 46580970 FragmentShader: 35983630 - SubPass: G-Buffer Write + SubPass: UI Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 54324293 diff --git a/Assets/Materials/UIMat_MainMenu.shmat b/Assets/Materials/UIMat_MainMenu.shmat index 625021b0..0ca4c7a1 100644 --- a/Assets/Materials/UIMat_MainMenu.shmat +++ b/Assets/Materials/UIMat_MainMenu.shmat @@ -1,6 +1,6 @@ - VertexShader: 46580970 FragmentShader: 35983630 - SubPass: G-Buffer Write + SubPass: UI Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 54429632 diff --git a/Assets/Materials/UIMat_WinScene.shmat b/Assets/Materials/UIMat_WinScene.shmat index b8d5b183..e9c36f65 100644 --- a/Assets/Materials/UIMat_WinScene.shmat +++ b/Assets/Materials/UIMat_WinScene.shmat @@ -1,6 +1,6 @@ - VertexShader: 46580970 FragmentShader: 35983630 - SubPass: G-Buffer Write + SubPass: UI Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 57302694 diff --git a/Assets/Shaders/UI_FS.glsl b/Assets/Shaders/UI_FS.glsl index 0c4c526c..a28642f4 100644 --- a/Assets/Shaders/UI_FS.glsl +++ b/Assets/Shaders/UI_FS.glsl @@ -33,18 +33,11 @@ layout (std430, set = 2, binding = 0) buffer MaterialProperties // For mater MatPropData data[]; } MatProp; -layout(location = 0) out vec4 position; +layout(location = 0) out vec4 fragColor; layout(location = 1) out uint outEntityID; -layout(location = 2) out uint lightLayerIndices; -layout(location = 3) out vec4 normals; -layout(location = 4) out vec4 albedo; void main() { - position = In.vertPos; - normals = In.normal; - albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); - + fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); outEntityID = In2.eid; - lightLayerIndices = In2.lightLayerIndex; } \ No newline at end of file diff --git a/Assets/Shaders/UI_FS.shshaderb b/Assets/Shaders/UI_FS.shshaderb index 703040e1..ce1dd7e9 100644 Binary files a/Assets/Shaders/UI_FS.shshaderb and b/Assets/Shaders/UI_FS.shshaderb differ diff --git a/SHADE_Engine/src/Assets/SHAssetManager.cpp b/SHADE_Engine/src/Assets/SHAssetManager.cpp index 44d62f66..363b7829 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.cpp +++ b/SHADE_Engine/src/Assets/SHAssetManager.cpp @@ -27,6 +27,7 @@ #include "Libraries/Compilers/SHShaderSourceCompiler.h" #include "Filesystem/SHFileSystem.h" +#include namespace SHADE { @@ -733,3 +734,25 @@ namespace SHADE } } } + +namespace rttr +{ + using namespace SHADE; + RTTR_REGISTRATION + { + registration::enumeration("Asset Type") + ( + value("Invalid", AssetType::INVALID), + value("Shader", AssetType::SHADER), + value("Shader [Built-In]", AssetType::SHADER_BUILT_IN), + value("Texture", AssetType::TEXTURE), + value("Model", AssetType::MODEL), + value("Scene", AssetType::SCENE), + value("Prefab", AssetType::PREFAB), + value("Material", AssetType::MATERIAL), + value("Mesh", AssetType::MESH), + value("Script", AssetType::SCRIPT), + value("Font", AssetType::FONT) + ); + } +} diff --git a/SHADE_Engine/src/Camera/SHCameraSystem.cpp b/SHADE_Engine/src/Camera/SHCameraSystem.cpp index 6feece48..8b78045a 100644 --- a/SHADE_Engine/src/Camera/SHCameraSystem.cpp +++ b/SHADE_Engine/src/Camera/SHCameraSystem.cpp @@ -314,7 +314,7 @@ namespace SHADE camera.orthoProjMatrix(3, 3) = 1.0f; //camera.perspProjMatrix = SHMatrix::OrthographicLH(9.0f, 9.0f, 0.1f, 20.0f); - camera.orthoProjMatrix = SHMatrix::OrthographicRH(camera.GetWidth(), camera.GetHeight(), camera.GetNear(), camera.GetFar()); + //camera.orthoProjMatrix = SHMatrix::OrthographicLH(camera.GetWidth(), camera.GetHeight(), camera.GetNear(), camera.GetFar()); //camera.perspProjMatrix = SHMatrix::OrthographicLH(5.0f, 5.0f, 0.1f, 20.0f); //camera.projMatrix.Transpose(); diff --git a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp index a7ba7dc0..791396df 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp @@ -16,6 +16,9 @@ #include "Editor/EditorWindow/SHEditorWindowManager.h" #include "Scripting/SHVSUtilities.h" #include "Scripting/SHScriptEngine.h" +#include "Tools/Utilities/SHStringUtilities.h" +#include +#include namespace SHADE { @@ -27,6 +30,13 @@ namespace SHADE void SHAssetBrowser::Init() { SHEditorWindow::Init(); + rttr::array_range typeNames = typeEnumAlign.get_names(); + + for(auto const& name : typeNames) + { + uint64_t val = typeEnumAlign.name_to_value(name).to_uint64(); + typeFilters[val] = true; + } } void SHAssetBrowser::Update() @@ -34,7 +44,10 @@ namespace SHADE SHEditorWindow::Update(); if (Begin()) { - RecursivelyDrawTree(rootFolder); + for(auto subFolder : rootFolder->subFolders) + { + RecursivelyDrawTree(subFolder); + } DrawMenuBar(); DrawCurrentFolder(); DrawAssetBeingCreated(); @@ -50,6 +63,11 @@ namespace SHADE refreshQueued = true; } + void SHAssetBrowser::SetScrollTo(AssetID assetid) + { + assetToScrollTo = assetid; + } + void SHAssetBrowser::Refresh() noexcept { SHAssetManager::RefreshDirectory(); @@ -69,6 +87,7 @@ namespace SHADE { isAssetBeingCreated = true; } + DrawAssetBrowserFilter(); ImGui::EndMenuBar(); } } @@ -81,13 +100,34 @@ namespace SHADE auto files = folder->files; const bool isSelected = std::ranges::find(selectedFolders, folder) != selectedFolders.end(); ImGuiTreeNodeFlags flags = (subFolders.empty() && files.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow; + if(!filter.empty() && (!subFolders.empty() || !files.empty())) + { + ImGui::SetNextItemOpen(true); + } if (isSelected) flags |= ImGuiTreeNodeFlags_Selected; if (folder == rootFolder) flags |= ImGuiTreeNodeFlags_DefaultOpen; - bool isOpen = ImGui::TreeNodeEx(folder, flags, "%s %s", ICON_MD_FOLDER, folder->name.data()); - ImGuiID folderID = ImGui::GetItemID(); + if(assetToScrollTo != 0) + { + if(auto asset = SHAssetManager::GetAsset(assetToScrollTo)) + { + if(!asset->path.empty()) + { + ImGui::SetNextItemOpen(SHStringUtilities::StringFindInsensitive(asset->path.string(), folder->name.data()) != std::string::npos); + } + else if(auto parent = SHAssetManager::GetAsset(asset->parent)) + { + ImGui::SetNextItemOpen(SHStringUtilities::StringFindInsensitive(parent->path.string(), folder->name.data()) != std::string::npos); + } + } + } + + bool isOpen = false; + if(filter.empty()) + isOpen = ImGui::TreeNodeEx(folder, flags, "%s %s", ICON_MD_FOLDER, folder->name.data()); + const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); //if (ImGui::BeginPopupContextItem()) @@ -101,7 +141,7 @@ namespace SHADE selectedFolders.push_back(folder); } - if (isOpen) + if (isOpen || !filter.empty()) { const ImColor treeLineColor = ImGui::GetColorU32(ImGuiCol_CheckMark); const float horizontalOffset = 0.0f; @@ -127,7 +167,8 @@ namespace SHADE } drawList->AddLine(vertLineStart, vertLineEnd, treeLineColor, 1); - ImGui::TreePop(); + if(filter.empty()) + ImGui::TreePop(); } return nodeRect; } @@ -167,8 +208,26 @@ namespace SHADE { ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf; static constexpr std::string_view icon = ICON_MD_FILE_PRESENT; + bool highlighted = false; + if (!filter.empty()) + { + if (SHStringUtilities::StringFindInsensitive(file.name.data(), filter) == std::string::npos) + { + return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); + } + else + { + highlighted = true; + ImGui::PushStyleColor(ImGuiCol_Text, highlightedColor); + } + } ImGui::PushID(file.name.data()); + bool const isOpen = ImGui::TreeNodeEx(file.name.data(), flags, "%s %s%s", icon.data(), file.name.data(), file.ext.data()); + if(highlighted) + { + ImGui::PopStyleColor(); + } const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); if(ImGui::BeginPopupContextItem()) { @@ -194,6 +253,27 @@ namespace SHADE { if (asset == nullptr) return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); + + if (!typeFilters[static_cast(asset->type)]) + { + return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); + } + + bool highlighted = false; + if(!filter.empty()) + { + ImGui::SetNextItemOpen(true); + if(SHStringUtilities::StringFindInsensitive(asset->name.data(), filter) == std::string::npos) + { + return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); + } + else + { + highlighted = true; + ImGui::PushStyleColor(ImGuiCol_Text, highlightedColor); + } + } + const bool isSelected = std::ranges::find(selectedAssets, asset->id) != selectedAssets.end(); ImGuiTreeNodeFlags flags = (!asset->subAssets.empty()) ? ImGuiTreeNodeFlags_OpenOnArrow : ImGuiTreeNodeFlags_Leaf; if (isSelected) @@ -214,8 +294,34 @@ namespace SHADE case AssetType::MAX_COUNT: break; default:; } + + if(assetToScrollTo != 0) + { + if(asset->id == assetToScrollTo) + { + ImGui::SetScrollHereY(); + selectedAssets.clear(); + selectedAssets.push_back(asset->id); + assetToScrollTo = 0; + } + else + { + for (auto const& subAsset : asset->subAssets) + { + if(subAsset->id == assetToScrollTo) + { + ImGui::SetNextItemOpen(true); + } + } + } + } bool const isOpen = ImGui::TreeNodeEx(asset, flags, "%s %s%s", icon.data(), asset->name.data(), ext.data()); + + if(highlighted) + { + ImGui::PopStyleColor(); + } const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); if (SHDragDrop::BeginSource()) { @@ -339,4 +445,43 @@ namespace SHADE // QueueRefresh(); //} } + + void SHAssetBrowser::DrawAssetBrowserFilter() + { + if (ImGui::InputTextWithHint("##hierarchyPanelFilter", "Filter", &filter)) + { + } + if (ImGui::Button("x")) + { + filter.clear(); + } + if(ImGui::BeginMenu("Type")) + { + if (ImGui::Button("All")) + { + for (auto& [id, value] : typeFilters) + value = true; + } + ImGui::SameLine(); + if (ImGui::Button("None")) + { + for (auto& [id, value] : typeFilters) + value = false; + } + for (auto& [id, value] : typeFilters) + { + if(ImGui::Checkbox(typeEnumAlign.value_to_name(id).data(), &value)) + { + + } + if(ImGui::IsItemClicked(ImGuiMouseButton_Right)) + { + for (auto& [id2, value2] : typeFilters) + value2 = false; + value = true; + } + } + ImGui::EndMenu(); + } + } } diff --git a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.h b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.h index 6d3c5eb4..0ff5225e 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.h +++ b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.h @@ -4,18 +4,21 @@ #include "Assets/SHAsset.h" #include "Editor/EditorWindow/SHEditorWindow.h" #include "Filesystem/SHFolder.h" +#include namespace SHADE { class SHAssetBrowser final : public SHEditorWindow { public: + static constexpr ImVec4 highlightedColor = ImVec4(0.f, 0.7f, 0.0f, 1.0f); SHAssetBrowser(); void Init(); void Update(); void QueueRefresh() noexcept; + void SetScrollTo(AssetID assetid); private: void DrawMenuBar(); ImRect RecursivelyDrawTree(FolderPointer folder); @@ -23,6 +26,7 @@ namespace SHADE ImRect DrawFile(SHFile& file) noexcept; ImRect DrawAsset(SHAsset const* const asset, FileExt const& ext = "") noexcept; void DrawAssetBeingCreated() noexcept; + void DrawAssetBrowserFilter(); void Refresh() noexcept; @@ -30,9 +34,13 @@ namespace SHADE std::vector selectedFolders; std::vector selectedAssets; static constexpr float tileWidth = 50.0f; + static constexpr std::string_view newAssetPopup = "Create New Asset"; + std::string nameOfAssetBeingCreated, filter; + rttr::enumeration typeEnumAlign = rttr::type::get().get_enumeration(); + std::unordered_map typeFilters; + + AssetID assetToScrollTo = 0; bool refreshQueued = false; bool isAssetBeingCreated = false; - static constexpr std::string_view newAssetPopup = "Create New Asset"; - std::string nameOfAssetBeingCreated; }; } diff --git a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h index d217a307..cf5f0980 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h +++ b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h @@ -15,11 +15,11 @@ namespace SHADE { class SHSceneNode; - constexpr ImVec4 highlightedColor = ImVec4(0.f, 0.7f, 0.0f, 1.0f); class SHHierarchyPanel final : public SHEditorWindow { public: + static constexpr ImVec4 highlightedColor = ImVec4(0.f, 0.7f, 0.0f, 1.0f); SHHierarchyPanel(); void Init() override; void Update() override; diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index a2873bd0..48d334fa 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -24,6 +24,8 @@ #include "SHInspectorCommands.h" #include "Physics/Collision/SHCollisionTagMatrix.h" #include "Animation/SHAnimatorComponent.h" +#include "../SHEditorWindowManager.h" +#include "../AssetBrowser/SHAssetBrowser.h" namespace SHADE { template @@ -502,6 +504,15 @@ namespace SHADE SHResourceManager::FinaliseChanges(); }, SHDragDrop::DRAG_RESOURCE); + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) + { + if(Handle const& mesh = component->GetMesh()) + { + AssetID assetID = SHResourceManager::GetAssetID(mesh).value_or(0); + SHEditorWindowManager::GetEditorWindow()->SetScrollTo(assetID); + } + } + const auto MAT_NAME = mat ? SHResourceManager::GetAssetName(mat->GetBaseMaterial()).value_or("") : ""; SHEditorWidgets::DragDropReadOnlyField("Material", MAT_NAME, [component]() @@ -521,6 +532,15 @@ namespace SHADE auto gfxSystem = SHSystemManager::GetSystem(); component->SetMaterial(gfxSystem->AddOrGetBaseMaterialInstance(SHResourceManager::LoadOrGet(id))); }, SHDragDrop::DRAG_RESOURCE); + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) + { + if(Handle const& mat = component->GetMaterial()) + { + AssetID assetID = SHResourceManager::GetAssetID(mat->GetBaseMaterial()).value_or(0); + SHEditorWindowManager::GetEditorWindow()->SetScrollTo(assetID); + } + } + } else { @@ -558,7 +578,14 @@ namespace SHADE component->SetFont(SHResourceManager::LoadOrGet(id)); SHResourceManager::FinaliseChanges(); }, SHDragDrop::DRAG_RESOURCE); - + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) + { + if (Handle const& font = component->GetFont()) + { + AssetID assetID = SHResourceManager::GetAssetID(font).value_or(0); + SHEditorWindowManager::GetEditorWindow()->SetScrollTo(assetID); + } + } SHEditorWidgets::InputText("Text", [component](void) { @@ -606,7 +633,14 @@ namespace SHADE component->SetRig(SHResourceManager::LoadOrGet(id)); SHResourceManager::FinaliseChanges(); }, SHDragDrop::DRAG_RESOURCE); - + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) + { + if (Handle const& rig = component->GetRig()) + { + AssetID assetID = SHResourceManager::GetAssetID(rig).value_or(0); + SHEditorWindowManager::GetEditorWindow()->SetScrollTo(assetID); + } + } Handle const& clip = component->GetCurrentClip(); const auto CLIP_NAME = clip ? SHResourceManager::GetAssetName(clip).value_or("") : ""; SHEditorWidgets::DragDropReadOnlyField("Clip", CLIP_NAME, @@ -624,6 +658,14 @@ namespace SHADE } component->SetClip(SHResourceManager::LoadOrGet(id)); }, SHDragDrop::DRAG_RESOURCE); + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) + { + if (Handle const& clip = component->GetCurrentClip()) + { + AssetID assetID = SHResourceManager::GetAssetID(clip).value_or(0); + SHEditorWindowManager::GetEditorWindow()->SetScrollTo(assetID); + } + } } else { diff --git a/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp b/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp index af77f17f..18323fa1 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp @@ -1,8 +1,11 @@ #include "SHpch.h" + +#include +#include + #include "Serialization/SHSerializationHelper.hpp" #include "SHMaterialInspector.h" #include "Editor/SHImGuiHelpers.hpp" -#include #include "Assets/SHAssetManager.h" #include "Editor/IconsMaterialDesign.h" @@ -89,11 +92,17 @@ namespace SHADE if (vertShader && fragShader && gfxSystem) { // - Retrieve pipeline from pipeline library - auto renderPass = gfxSystem->GetPrimaryRenderpass(); - auto subPass = renderPass->GetSubpass(currentMatSpec->subpassName); - auto pipeline = renderPass->GetOrCreatePipeline({ vertShader, fragShader }, subPass); - // - Set Pipeline - matHandle->SetPipeline(pipeline); + auto subPass = gfxSystem->GetUsableSubpass(currentMatSpec->subpassName); + if (subPass) + { + // Set Pipeline if valid + auto pipeline = subPass->GetParentNode()->GetOrCreatePipeline({vertShader, fragShader}, subPass); + matHandle->SetPipeline(pipeline); + } + else + { + SHLOG_ERROR("[SHMaterialInspector] Failed to find material subpass of type \"{}\"", currentMatSpec->subpassName); + } } } @@ -176,7 +185,7 @@ namespace SHADE const std::string VERT_SHADER_NAME = VERT_SHADER_INFO ? VERT_SHADER_INFO->name : "Unknown Shader"; isDirty |= SHEditorWidgets::DragDropReadOnlyField ( - "Fragment Shader", VERT_SHADER_NAME.data(), + "Vertex Shader", VERT_SHADER_NAME.data(), [this]() { return currentMatSpec->vertexShader; }, [this](const AssetID& id) { currentMatSpec->vertexShader = id; }, SHDragDrop::DRAG_RESOURCE @@ -191,6 +200,37 @@ namespace SHADE SHDragDrop::DRAG_RESOURCE ); + // Subpass + const auto& SP_NAMES = SHGraphicsConstants::RenderGraphEntityNames::USABLE_SUBPASSES; + ImGui::Text("Subpass"); + ImGui::SameLine(); + if (ImGui::BeginCombo("##", currentMatSpec->subpassName.data(), ImGuiComboFlags_None)) + { + for (const auto& NAME : SP_NAMES) + { + const bool IS_SELECTED = currentMatSpec->subpassName == NAME; + if (ImGui::Selectable(NAME.data(), IS_SELECTED)) + { + isDirty = true; + SHCommandManager::PerformCommand + ( + std::reinterpret_pointer_cast(std::make_shared> + ( + currentMatSpec->subpassName, + std::string(NAME), + [&](const std::string& newName){ currentMatSpec->subpassName = newName; } + )), + false + ); + } + if (IS_SELECTED) + { + ImGui::SetItemDefaultFocus(); + } + } + ImGui::EndCombo(); + } + // Load the shader to access it's data auto fragShader = SHResourceManager::LoadOrGet(currentMatSpec->fragShader); if (!fragShader) diff --git a/SHADE_Engine/src/Editor/SHEditor.cpp b/SHADE_Engine/src/Editor/SHEditor.cpp index 4d180635..d151fd64 100644 --- a/SHADE_Engine/src/Editor/SHEditor.cpp +++ b/SHADE_Engine/src/Editor/SHEditor.cpp @@ -96,8 +96,10 @@ namespace SHADE SHLOG_CRITICAL("Failed to create ImGui Context") } } - + +#ifdef SHEDITOR editorConfig = &SHConfigurationManager::LoadEditorConfig(); +#endif //Add editor windows SHEditorWindowManager::CreateEditorWindow(); @@ -131,8 +133,9 @@ namespace SHADE InitBackend(); +#ifdef SHEDITOR SetStyle(static_cast