Merge pull request #322 from SHADE-DP/SP3-4-Editor
Added hierarchy panel filter
This commit is contained in:
commit
f1bf9cb865
|
@ -57,9 +57,13 @@ namespace SHADE
|
||||||
skipFrame = false;
|
skipFrame = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DrawMenuBar();
|
|
||||||
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
|
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
|
||||||
|
DrawMenuBar();
|
||||||
|
if(wasFilterChanged && !filter.empty())
|
||||||
|
{
|
||||||
|
filterHighlightedEntities.clear();
|
||||||
|
filterOpenEntities.clear();
|
||||||
|
}
|
||||||
if (const auto root = sceneGraph.GetRoot())
|
if (const auto root = sceneGraph.GetRoot())
|
||||||
{
|
{
|
||||||
auto const& children = root->GetChildren();
|
auto const& children = root->GetChildren();
|
||||||
|
@ -67,7 +71,13 @@ namespace SHADE
|
||||||
for (const auto child : children)
|
for (const auto child : children)
|
||||||
{
|
{
|
||||||
if (child)
|
if (child)
|
||||||
|
{
|
||||||
|
if(wasFilterChanged && !filter.empty())
|
||||||
|
{
|
||||||
|
EntityFilterCheck(child);
|
||||||
|
}
|
||||||
RecursivelyDrawEntityNode(child);
|
RecursivelyDrawEntityNode(child);
|
||||||
|
}
|
||||||
if (skipFrame)
|
if (skipFrame)
|
||||||
{
|
{
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
@ -177,9 +187,10 @@ namespace SHADE
|
||||||
|
|
||||||
void SHHierarchyPanel::DrawHierarchyPanelFilter() noexcept
|
void SHHierarchyPanel::DrawHierarchyPanelFilter() noexcept
|
||||||
{
|
{
|
||||||
|
wasFilterChanged = false;
|
||||||
if(ImGui::InputTextWithHint("##hierarchyPanelFilter", "Filter", &filter))
|
if(ImGui::InputTextWithHint("##hierarchyPanelFilter", "Filter", &filter))
|
||||||
{
|
{
|
||||||
|
wasFilterChanged = true;
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button("x"))
|
if(ImGui::Button("x"))
|
||||||
|
@ -204,24 +215,65 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
result |= SHComponentManager::HasComponent<SHTransformComponent>(eid);
|
result |= SHComponentManager::HasComponent<SHTransformComponent>(eid);
|
||||||
}
|
}
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHColliderComponent>().get_name().data(), filter) != std::string::npos;
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHColliderComponent>().get_name().data(), filter) != std::string::npos)
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHRigidBodyComponent>().get_name().data(), filter) != std::string::npos;
|
{
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHCameraComponent>().get_name().data(), filter) != std::string::npos;
|
result |= SHComponentManager::HasComponent<SHColliderComponent>(eid);
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHCameraArmComponent>().get_name().data(), filter) != std::string::npos;
|
}
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHRenderable>().get_name().data(), filter) != std::string::npos;
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHRigidBodyComponent>().get_name().data(), filter) != std::string::npos)
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHLightComponent>().get_name().data(), filter) != std::string::npos;
|
{
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHTextRenderableComponent>().get_name().data(), filter) != std::string::npos;
|
result |= SHComponentManager::HasComponent<SHRigidBodyComponent>(eid);
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHUIComponent>().get_name().data(), filter) != std::string::npos;
|
}
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHButtonComponent>().get_name().data(), filter) != std::string::npos;
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHCameraComponent>().get_name().data(), filter) != std::string::npos)
|
||||||
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHCanvasComponent>().get_name().data(), filter) != std::string::npos;
|
{
|
||||||
|
result |= SHComponentManager::HasComponent<SHCameraComponent>(eid);
|
||||||
|
}
|
||||||
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHCameraArmComponent>().get_name().data(), filter) != std::string::npos)
|
||||||
|
{
|
||||||
|
result |= SHComponentManager::HasComponent<SHCameraArmComponent>(eid);
|
||||||
|
}
|
||||||
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHRenderable>().get_name().data(), filter) != std::string::npos)
|
||||||
|
{
|
||||||
|
result |= SHComponentManager::HasComponent<SHRenderable>(eid);
|
||||||
|
}
|
||||||
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHLightComponent>().get_name().data(), filter) != std::string::npos)
|
||||||
|
{
|
||||||
|
result |= SHComponentManager::HasComponent<SHLightComponent>(eid);
|
||||||
|
}
|
||||||
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHTextRenderableComponent>().get_name().data(), filter) != std::string::npos)
|
||||||
|
{
|
||||||
|
result |= SHComponentManager::HasComponent<SHTextRenderableComponent>(eid);
|
||||||
|
}
|
||||||
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHUIComponent>().get_name().data(), filter) != std::string::npos)
|
||||||
|
{
|
||||||
|
result |= SHComponentManager::HasComponent<SHUIComponent>(eid);
|
||||||
|
}
|
||||||
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHButtonComponent>().get_name().data(), filter) != std::string::npos)
|
||||||
|
{
|
||||||
|
result |= SHComponentManager::HasComponent<SHButtonComponent>(eid);
|
||||||
|
}
|
||||||
|
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHCanvasComponent>().get_name().data(), filter) != std::string::npos)
|
||||||
|
{
|
||||||
|
result |= SHComponentManager::HasComponent<SHCanvasComponent>(eid);
|
||||||
|
}
|
||||||
|
|
||||||
//std::vector<SHSceneNode*> const& children = entityNode->GetChildren();
|
if(result)
|
||||||
|
{
|
||||||
|
filterHighlightedEntities.push_back(eid);
|
||||||
|
}
|
||||||
|
|
||||||
//for (auto const& child : children)
|
std::vector<SHSceneNode*> const& children = entityNode->GetChildren();
|
||||||
//{
|
|
||||||
// result |= EntityFilterCheck(child);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
bool open = false;
|
||||||
|
for (auto const& child : children)
|
||||||
|
{
|
||||||
|
open |= EntityFilterCheck(child);
|
||||||
|
}
|
||||||
|
result |= open;
|
||||||
|
|
||||||
|
if(open)
|
||||||
|
{
|
||||||
|
filterOpenEntities.push_back(eid);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,31 +297,27 @@ namespace SHADE
|
||||||
|
|
||||||
const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end());
|
const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end());
|
||||||
|
|
||||||
bool highlighted = false;
|
bool highlighted = false, open = false;
|
||||||
//if(!filter.empty())
|
if(!filter.empty())
|
||||||
//{
|
{
|
||||||
// highlighted = EntityFilterCheck(currentNode);
|
highlighted = (std::ranges::find(filterHighlightedEntities, eid) != filterHighlightedEntities.end());
|
||||||
// if (highlighted)
|
if(open = std::ranges::find(filterOpenEntities, eid) != filterOpenEntities.end())
|
||||||
// {
|
{
|
||||||
// ImGui::PushStyleColor(ImGuiCol_Text, highlightedColor);
|
ImGui::SetNextItemOpen(true);
|
||||||
//
|
}
|
||||||
// ImGui::SetNextItemOpen(true);
|
|
||||||
//
|
if(!open && !highlighted)
|
||||||
//
|
{
|
||||||
// }
|
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
||||||
// else
|
}
|
||||||
// {
|
ImGui::PushStyleColor(ImGuiCol_Text, highlighted ? highlightedColor : ImVec4(0.5f, 0.5f, 0.5f, 1.f ));
|
||||||
//
|
}
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
const ImGuiTreeNodeFlags nodeFlags = ((isSelected) ? ImGuiTreeNodeFlags_Selected : 0) | ((children.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow);
|
const ImGuiTreeNodeFlags nodeFlags = ((isSelected) ? ImGuiTreeNodeFlags_Selected : 0) | ((children.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow);
|
||||||
|
|
||||||
|
|
||||||
//Draw Node
|
//Draw Node
|
||||||
bool isNodeOpen = ImGui::TreeNodeEx(reinterpret_cast<void*>(eid), nodeFlags, "%u: %s", SHEntityManager::GetEntityIndex(eid), entity->name.c_str());
|
bool isNodeOpen = ImGui::TreeNodeEx(reinterpret_cast<void*>(eid), nodeFlags, "%u: %s", SHEntityManager::GetEntityIndex(eid), entity->name.c_str());
|
||||||
|
|
||||||
if (highlighted)
|
if(!filter.empty())
|
||||||
{
|
{
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ namespace SHADE
|
||||||
std::string filter;
|
std::string filter;
|
||||||
bool isAnyNodeSelected = false;
|
bool isAnyNodeSelected = false;
|
||||||
EntityID scrollTo = MAX_EID;
|
EntityID scrollTo = MAX_EID;
|
||||||
std::vector<EntityID> draggingEntities;
|
std::vector<EntityID> draggingEntities, filterOpenEntities, filterHighlightedEntities;
|
||||||
|
bool wasFilterChanged = false;
|
||||||
|
|
||||||
};//class SHHierarchyPanel
|
};//class SHHierarchyPanel
|
||||||
|
|
||||||
|
|
|
@ -106,8 +106,8 @@ namespace SHADE
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHMaterialInspector>();
|
SHEditorWindowManager::CreateEditorWindow<SHMaterialInspector>();
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHColliderTagPanel>();
|
SHEditorWindowManager::CreateEditorWindow<SHColliderTagPanel>();
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
|
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
|
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHInputBindingsPanel>();
|
SHEditorWindowManager::CreateEditorWindow<SHInputBindingsPanel>();
|
||||||
|
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
|
||||||
|
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
|
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
|
||||||
|
|
||||||
|
|
|
@ -577,14 +577,14 @@ namespace SHADE
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::B))
|
//if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::B))
|
||||||
{
|
//{
|
||||||
auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
|
// auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
|
||||||
for (auto& comp : lightComps)
|
// for (auto& comp : lightComps)
|
||||||
{
|
// {
|
||||||
comp.SetEnableShadow(true);
|
// comp.SetEnableShadow(true);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
renderGraph->Begin(frameIndex);
|
renderGraph->Begin(frameIndex);
|
||||||
auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);
|
auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);
|
||||||
|
|
Loading…
Reference in New Issue