From 70d06b38e1922d32cf7fb49c8917557355004843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Sat, 18 Nov 2023 14:39:24 +0100 Subject: [PATCH] editor and gui improvements --- Editor/OptionsWindow.cpp | 256 ++----------------------------------- Editor/OptionsWindow.h | 1 + WickedEngine/wiGUI.cpp | 9 ++ WickedEngine/wiGUI.h | 1 + WickedEngine/wiVersion.cpp | 2 +- 5 files changed, 21 insertions(+), 248 deletions(-) diff --git a/Editor/OptionsWindow.cpp b/Editor/OptionsWindow.cpp index 53cb2bc0c..0b7a4ddad 100644 --- a/Editor/OptionsWindow.cpp +++ b/Editor/OptionsWindow.cpp @@ -1,9 +1,9 @@ #include "stdafx.h" #include "OptionsWindow.h" -using namespace wi::graphics; using namespace wi::ecs; using namespace wi::scene; +using namespace wi::graphics; void OptionsWindow::Create(EditorComponent* _editor) { @@ -458,7 +458,7 @@ void OptionsWindow::ResizeLayout() entityTree.SetPos(pos); - entityTree.SetSize(XMFLOAT2(width, std::max(editor->GetLogicalHeight() * 0.75f, editor->GetLogicalHeight() - pos.y))); + entityTree.SetSize(XMFLOAT2(width, editor->GetLogicalHeight() - pos.y - this->translation_local.y - this->control_size - padding)); pos.y += entityTree.GetSize().y; pos.y += padding; } @@ -681,254 +681,16 @@ void OptionsWindow::RefreshEntityTree() entityTree.ClearItems(); - if (has_flag(filter, Filter::All)) - { - // Add hierarchy: - for (size_t i = 0; i < scene.hierarchy.GetCount(); ++i) - { - if (scene.hierarchy[i].parentID == INVALID_ENTITY) - continue; - PushToEntityTree(scene.hierarchy[i].parentID, 0); - } - } + entitytree_temp_items.clear(); + scene.FindAllEntities(entitytree_temp_items); - // Add any left over entities that might not have had a hierarchy: - - if (has_flag(filter, Filter::Terrain)) + // Add items to level 0 that are not in hierarchy (not in hierarchy can also mean top level parent): + // Note that PushToEntityTree will add children recursively, so this is all we need + for (auto& x : entitytree_temp_items) { - // Any transform left that is not part of a hierarchy: - for (size_t i = 0; i < scene.terrains.GetCount(); ++i) + if (!scene.hierarchy.Contains(x)) { - PushToEntityTree(scene.terrains.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Transform)) - { - // Any transform left that is not part of a hierarchy: - for (size_t i = 0; i < scene.transforms.GetCount(); ++i) - { - PushToEntityTree(scene.transforms.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Light)) - { - for (size_t i = 0; i < scene.lights.GetCount(); ++i) - { - PushToEntityTree(scene.lights.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Decal)) - { - for (size_t i = 0; i < scene.decals.GetCount(); ++i) - { - PushToEntityTree(scene.decals.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Camera)) - { - for (size_t i = 0; i < scene.cameras.GetCount(); ++i) - { - PushToEntityTree(scene.cameras.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Material)) - { - for (size_t i = 0; i < scene.materials.GetCount(); ++i) - { - PushToEntityTree(scene.materials.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Mesh)) - { - for (size_t i = 0; i < scene.meshes.GetCount(); ++i) - { - PushToEntityTree(scene.meshes.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Armature)) - { - for (size_t i = 0; i < scene.armatures.GetCount(); ++i) - { - PushToEntityTree(scene.armatures.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Object)) - { - for (size_t i = 0; i < scene.objects.GetCount(); ++i) - { - PushToEntityTree(scene.objects.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Weather)) - { - for (size_t i = 0; i < scene.weathers.GetCount(); ++i) - { - PushToEntityTree(scene.weathers.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Sound)) - { - for (size_t i = 0; i < scene.sounds.GetCount(); ++i) - { - PushToEntityTree(scene.sounds.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Video)) - { - for (size_t i = 0; i < scene.videos.GetCount(); ++i) - { - PushToEntityTree(scene.videos.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Hairparticle)) - { - for (size_t i = 0; i < scene.hairs.GetCount(); ++i) - { - PushToEntityTree(scene.hairs.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Emitter)) - { - for (size_t i = 0; i < scene.emitters.GetCount(); ++i) - { - PushToEntityTree(scene.emitters.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Animation)) - { - for (size_t i = 0; i < scene.animations.GetCount(); ++i) - { - PushToEntityTree(scene.animations.GetEntity(i), 0); - } - for (size_t i = 0; i < scene.animation_datas.GetCount(); ++i) - { - PushToEntityTree(scene.animation_datas.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::EnvironmentProbe)) - { - for (size_t i = 0; i < scene.probes.GetCount(); ++i) - { - PushToEntityTree(scene.probes.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Force)) - { - for (size_t i = 0; i < scene.forces.GetCount(); ++i) - { - PushToEntityTree(scene.forces.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::All)) - { - for (size_t i = 0; i < scene.rigidbodies.GetCount(); ++i) - { - PushToEntityTree(scene.rigidbodies.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::All)) - { - for (size_t i = 0; i < scene.softbodies.GetCount(); ++i) - { - PushToEntityTree(scene.softbodies.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Spring)) - { - for (size_t i = 0; i < scene.springs.GetCount(); ++i) - { - PushToEntityTree(scene.springs.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Collider)) - { - for (size_t i = 0; i < scene.colliders.GetCount(); ++i) - { - PushToEntityTree(scene.colliders.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::IK)) - { - for (size_t i = 0; i < scene.inverse_kinematics.GetCount(); ++i) - { - PushToEntityTree(scene.inverse_kinematics.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::All)) - { - for (size_t i = 0; i < scene.names.GetCount(); ++i) - { - PushToEntityTree(scene.names.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Script)) - { - for (size_t i = 0; i < scene.scripts.GetCount(); ++i) - { - PushToEntityTree(scene.scripts.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Humanoid)) - { - for (size_t i = 0; i < scene.humanoids.GetCount(); ++i) - { - PushToEntityTree(scene.humanoids.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Expression)) - { - for (size_t i = 0; i < scene.expressions.GetCount(); ++i) - { - PushToEntityTree(scene.expressions.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Terrain)) - { - for (size_t i = 0; i < scene.terrains.GetCount(); ++i) - { - PushToEntityTree(scene.terrains.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Sprite)) - { - for (size_t i = 0; i < scene.sprites.GetCount(); ++i) - { - PushToEntityTree(scene.sprites.GetEntity(i), 0); - } - } - - if (has_flag(filter, Filter::Font)) - { - for (size_t i = 0; i < scene.fonts.GetCount(); ++i) - { - PushToEntityTree(scene.fonts.GetEntity(i), 0); + PushToEntityTree(x, 0); } } diff --git a/Editor/OptionsWindow.h b/Editor/OptionsWindow.h index 79c0364d1..b393d94cd 100644 --- a/Editor/OptionsWindow.h +++ b/Editor/OptionsWindow.h @@ -57,6 +57,7 @@ public: wi::gui::TextInputField filterInput; wi::gui::CheckBox filterCaseCheckBox; wi::gui::TreeList entityTree; + wi::unordered_set entitytree_temp_items; wi::unordered_set entitytree_added_items; wi::unordered_set entitytree_opened_items; void PushToEntityTree(wi::ecs::Entity entity, int level); diff --git a/WickedEngine/wiGUI.cpp b/WickedEngine/wiGUI.cpp index 1401b79f2..c1cfc55cb 100644 --- a/WickedEngine/wiGUI.cpp +++ b/WickedEngine/wiGUI.cpp @@ -4419,6 +4419,14 @@ namespace wi::gui scrollbar.sprites_knob[ScrollBar::SCROLLBAR_GRABBED].params.color = wi::Color::White(); scrollbar.SetOverScroll(0.25f); } + bool TreeList::DoesItemHaveChildren(int index) const + { + if (items.size() <= size_t(index + 1)) // if item doesn't exist or last then no children + return false; + if (items[index].level + 1 == items[index + 1].level) // if item after index is exactly one level down, then it is its child + return true; + return false; + } float TreeList::GetItemOffset(int index) const { return 2 + scrollbar.GetOffset() + index * item_height(); @@ -4730,6 +4738,7 @@ namespace wi::gui } // opened flag triangle: + if(DoesItemHaveChildren(i)) { device->BindPipelineState(&gui_internal().PSO_colored, cmd); diff --git a/WickedEngine/wiGUI.h b/WickedEngine/wiGUI.h index 8b97cd3c8..8abedb621 100644 --- a/WickedEngine/wiGUI.h +++ b/WickedEngine/wiGUI.h @@ -751,6 +751,7 @@ namespace wi::gui wi::vector items; float GetItemOffset(int index) const; + bool DoesItemHaveChildren(int index) const; public: void Create(const std::string& name); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index b1af34d67..fd5e73c57 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 346; + const int revision = 347; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);