diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 2fea4ddf1..73dc36bc5 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -32,6 +32,7 @@ set (SOURCE_FILES RigidBodyWindow.cpp SoftBodyWindow.cpp ColliderWindow.cpp + HierarchyWindow.cpp OptionsWindow.cpp ComponentsWindow.cpp TerrainGenerator.cpp diff --git a/Editor/ComponentsWindow.cpp b/Editor/ComponentsWindow.cpp index 2f9b6985f..7f1dee075 100644 --- a/Editor/ComponentsWindow.cpp +++ b/Editor/ComponentsWindow.cpp @@ -36,6 +36,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) rigidWnd.Create(editor); softWnd.Create(editor); colliderWnd.Create(editor); + hierarchyWnd.Create(editor); newComponentCombo.Create("Add: "); @@ -46,6 +47,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) newComponentCombo.SetInvalidSelectionText("..."); newComponentCombo.AddItem("Name", 0); newComponentCombo.AddItem("Layer " ICON_LAYER, 1); + newComponentCombo.AddItem("Hierarchy " ICON_HIERARCHY, 19); newComponentCombo.AddItem("Transform " ICON_TRANSFORM, 2); newComponentCombo.AddItem("Light " ICON_POINTLIGHT, 3); newComponentCombo.AddItem("Matetial " ICON_MATERIAL, 4); @@ -154,6 +156,10 @@ void ComponentsWindow::Create(EditorComponent* _editor) if (scene.colliders.Contains(entity)) return; break; + case 19: + if (scene.hierarchy.Contains(entity)) + return; + break; default: return; } @@ -244,6 +250,9 @@ void ComponentsWindow::Create(EditorComponent* _editor) case 18: scene.colliders.Create(entity); break; + case 19: + scene.hierarchy.Create(entity); + break; default: break; } @@ -277,6 +286,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) AddWidget(&rigidWnd); AddWidget(&softWnd); AddWidget(&colliderWnd); + AddWidget(&hierarchyWnd); materialWnd.SetVisible(false); weatherWnd.SetVisible(false); @@ -299,6 +309,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) rigidWnd.SetVisible(false); softWnd.SetVisible(false); colliderWnd.SetVisible(false); + hierarchyWnd.SetVisible(false); SetSize(editor->optionsWnd.GetSize()); @@ -335,7 +346,6 @@ void ComponentsWindow::ResizeLayout() nameWnd.SetVisible(true); nameWnd.SetPos(pos); nameWnd.SetSize(XMFLOAT2(width, nameWnd.GetScale().y)); - nameWnd.Update(); pos.y += nameWnd.GetSize().y; pos.y += padding; } @@ -344,6 +354,19 @@ void ComponentsWindow::ResizeLayout() nameWnd.SetVisible(false); } + if (scene.hierarchy.Contains(hierarchyWnd.entity)) + { + hierarchyWnd.SetVisible(true); + hierarchyWnd.SetPos(pos); + hierarchyWnd.SetSize(XMFLOAT2(width, hierarchyWnd.GetScale().y)); + pos.y += hierarchyWnd.GetSize().y; + pos.y += padding; + } + else + { + hierarchyWnd.SetVisible(false); + } + if (scene.layers.Contains(layerWnd.entity)) { layerWnd.SetVisible(true); diff --git a/Editor/ComponentsWindow.h b/Editor/ComponentsWindow.h index e95fe53be..72015810c 100644 --- a/Editor/ComponentsWindow.h +++ b/Editor/ComponentsWindow.h @@ -21,6 +21,7 @@ #include "RigidBodyWindow.h" #include "SoftBodyWindow.h" #include "ColliderWindow.h" +#include "HierarchyWindow.h" class EditorComponent; @@ -55,4 +56,5 @@ public: RigidBodyWindow rigidWnd; SoftBodyWindow softWnd; ColliderWindow colliderWnd; + HierarchyWindow hierarchyWnd; }; diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 77c7d42aa..375f068e5 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -366,6 +366,7 @@ void EditorComponent::Load() componentsWnd.rigidWnd.SetEntity(INVALID_ENTITY); componentsWnd.softWnd.SetEntity(INVALID_ENTITY); componentsWnd.colliderWnd.SetEntity(INVALID_ENTITY); + componentsWnd.hierarchyWnd.SetEntity(INVALID_ENTITY); optionsWnd.RefreshEntityTree(); ResetHistory(); @@ -1317,6 +1318,7 @@ void EditorComponent::Update(float dt) componentsWnd.rigidWnd.SetEntity(INVALID_ENTITY); componentsWnd.softWnd.SetEntity(INVALID_ENTITY); componentsWnd.colliderWnd.SetEntity(INVALID_ENTITY); + componentsWnd.hierarchyWnd.SetEntity(INVALID_ENTITY); } else { @@ -1352,6 +1354,7 @@ void EditorComponent::Update(float dt) componentsWnd.scriptWnd.SetEntity(picked.entity); componentsWnd.rigidWnd.SetEntity(picked.entity); componentsWnd.colliderWnd.SetEntity(picked.entity); + componentsWnd.hierarchyWnd.SetEntity(picked.entity); if (picked.subsetIndex >= 0) { diff --git a/Editor/Editor_SOURCE.vcxitems b/Editor/Editor_SOURCE.vcxitems index 3cba77e98..bf370772b 100644 --- a/Editor/Editor_SOURCE.vcxitems +++ b/Editor/Editor_SOURCE.vcxitems @@ -24,6 +24,7 @@ + @@ -139,6 +140,7 @@ + diff --git a/Editor/Editor_SOURCE.vcxitems.filters b/Editor/Editor_SOURCE.vcxitems.filters index fbd565c65..b9b1df101 100644 --- a/Editor/Editor_SOURCE.vcxitems.filters +++ b/Editor/Editor_SOURCE.vcxitems.filters @@ -80,6 +80,7 @@ + @@ -124,6 +125,7 @@ + diff --git a/Editor/HierarchyWindow.cpp b/Editor/HierarchyWindow.cpp new file mode 100644 index 000000000..b5ee3acd9 --- /dev/null +++ b/Editor/HierarchyWindow.cpp @@ -0,0 +1,126 @@ +#include "stdafx.h" +#include "HierarchyWindow.h" +#include "Editor.h" + +using namespace wi::ecs; +using namespace wi::scene; + + +void HierarchyWindow::Create(EditorComponent* _editor) +{ + editor = _editor; + wi::gui::Window::Create(ICON_HIERARCHY " Hierarchy", wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE); + SetSize(XMFLOAT2(480, 60)); + + closeButton.SetTooltip("Delete HierarchyComponent"); + OnClose([=](wi::gui::EventArgs args) { + + wi::Archive& archive = editor->AdvanceHistory(); + archive << EditorComponent::HISTORYOP_COMPONENT_DATA; + editor->RecordEntity(archive, entity); + + editor->GetCurrentScene().hierarchy.Remove(entity); + + editor->RecordEntity(archive, entity); + + editor->optionsWnd.RefreshEntityTree(); + }); + + float x = 80; + float xx = x; + float y = 4; + float step = 25; + float siz = 50; + float hei = 20; + float wid = 200; + + parentCombo.Create("Parent: "); + parentCombo.SetSize(XMFLOAT2(wid, hei)); + parentCombo.SetPos(XMFLOAT2(x, y)); + parentCombo.OnSelect([&](wi::gui::EventArgs args) { + + wi::Archive& archive = editor->AdvanceHistory(); + archive << EditorComponent::HISTORYOP_COMPONENT_DATA; + editor->RecordEntity(archive, entity); + + Scene& scene = editor->GetCurrentScene(); + if (args.iValue == 0) + { + scene.Component_Detach(entity); + } + else + { + scene.Component_Attach(entity, (Entity)args.userdata); + } + + editor->RecordEntity(archive, entity); + + editor->optionsWnd.RefreshEntityTree(); + + }); + parentCombo.SetTooltip("Choose a parent entity (also works if selected entity has no transform)"); + AddWidget(&parentCombo); + + + + SetMinimized(true); + SetVisible(false); + + SetEntity(INVALID_ENTITY); +} + +void HierarchyWindow::SetEntity(Entity entity) +{ + if (this->entity == entity) + return; + this->entity = entity; + + Scene& scene = editor->GetCurrentScene(); + + entities.clear(); + scene.FindAllEntities(entities); + + parentCombo.ClearItems(); + parentCombo.AddItem("NO PARENT " ICON_DISABLED); + HierarchyComponent* hier = scene.hierarchy.GetComponent(entity); + for (auto candidate_parent_entity : entities) + { + if (candidate_parent_entity == entity) + { + continue; // Don't list selected (don't allow attach to self) + } + + // Don't allow creating a loop: + bool loop = false; + const HierarchyComponent* candidate_hier = scene.hierarchy.GetComponent(candidate_parent_entity); + while (candidate_hier != nullptr && loop == false) + { + if (candidate_hier->parentID == entity) + { + loop = true; + break; + } + candidate_hier = scene.hierarchy.GetComponent(candidate_hier->parentID); + } + if (loop) + { + continue; + } + + const NameComponent* name = scene.names.GetComponent(candidate_parent_entity); + parentCombo.AddItem(name == nullptr ? std::to_string(candidate_parent_entity) : name->name, candidate_parent_entity); + + if (hier != nullptr && hier->parentID == candidate_parent_entity) + { + parentCombo.SetSelectedWithoutCallback((int)parentCombo.GetItemCount() - 1); + } + } +} + +void HierarchyWindow::ResizeLayout() +{ + wi::gui::Window::ResizeLayout(); + + parentCombo.SetPos(XMFLOAT2(60, 4)); + parentCombo.SetSize(XMFLOAT2(GetSize().x - 86, parentCombo.GetSize().y)); +} diff --git a/Editor/HierarchyWindow.h b/Editor/HierarchyWindow.h new file mode 100644 index 000000000..a8b5ca2ac --- /dev/null +++ b/Editor/HierarchyWindow.h @@ -0,0 +1,21 @@ +#pragma once +#include "WickedEngine.h" + +class EditorComponent; + +class HierarchyWindow : public wi::gui::Window +{ +private: + wi::unordered_set entities; +public: + void Create(EditorComponent* editor); + + EditorComponent* editor = nullptr; + wi::ecs::Entity entity; + void SetEntity(wi::ecs::Entity entity); + + wi::gui::ComboBox parentCombo; + + void ResizeLayout() override; +}; + diff --git a/Editor/IconDefinitions.h b/Editor/IconDefinitions.h index 27fc62d87..57ae45eb7 100644 --- a/Editor/IconDefinitions.h +++ b/Editor/IconDefinitions.h @@ -28,6 +28,7 @@ #define ICON_NAME ICON_FA_COMMENT_DOTS #define ICON_COLLIDER ICON_FA_CAPSULES #define ICON_SCRIPT ICON_FA_SCROLL +#define ICON_HIERARCHY ICON_FA_ARROWS_DOWN_TO_PEOPLE #define ICON_TERRAIN ICON_FA_MOUNTAIN_SUN diff --git a/Editor/LightWindow.cpp b/Editor/LightWindow.cpp index aba85bf2f..86d93cbbd 100644 --- a/Editor/LightWindow.cpp +++ b/Editor/LightWindow.cpp @@ -13,7 +13,7 @@ void LightWindow::Create(EditorComponent* _editor) { editor = _editor; wi::gui::Window::Create(ICON_POINTLIGHT " Light", wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE); - SetSize(XMFLOAT2(650, 700)); + SetSize(XMFLOAT2(650, 740)); closeButton.SetTooltip("Delete LightComponent"); OnClose([=](wi::gui::EventArgs args) { @@ -306,9 +306,6 @@ void LightWindow::SetEntity(Entity entity) else { rangeSlider.SetEnabled(false); - radiusSlider.SetEnabled(false); - widthSlider.SetEnabled(false); - heightSlider.SetEnabled(false); outerConeAngleSlider.SetEnabled(false); innerConeAngleSlider.SetEnabled(false); shadowCheckBox.SetEnabled(false); @@ -336,9 +333,6 @@ void LightWindow::SetLightType(LightComponent::LightType type) else { rangeSlider.SetEnabled(true); - radiusSlider.SetEnabled(false); - widthSlider.SetEnabled(false); - heightSlider.SetEnabled(false); if (type == LightComponent::SPOT) { outerConeAngleSlider.SetEnabled(true); @@ -352,3 +346,65 @@ void LightWindow::SetLightType(LightComponent::LightType type) } } + +void LightWindow::ResizeLayout() +{ + wi::gui::Window::ResizeLayout(); + const float padding = 4; + const float width = GetWidgetAreaSize().x; + float y = padding; + float jump = 20; + + auto add = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_left = 140; + const float margin_right = 40; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + y += widget.GetSize().y; + y += padding; + }; + auto add_right = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_right = 45; + widget.SetPos(XMFLOAT2(width - margin_right - widget.GetSize().x, y)); + y += widget.GetSize().y; + y += padding; + }; + auto add_fullwidth = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_left = padding; + const float margin_right = padding; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + y += widget.GetSize().y; + y += padding; + }; + + add_fullwidth(colorPicker); + add(typeSelectorComboBox); + add(intensitySlider); + add(rangeSlider); + add(outerConeAngleSlider); + add(innerConeAngleSlider); + add_right(shadowCheckBox); + add_right(haloCheckBox); + add_right(volumetricsCheckBox); + add_right(staticCheckBox); + add(shadowResolutionComboBox); + + y += jump; + + add_fullwidth(lensflare_Label); + add_fullwidth(lensflare_Button[0]); + add_fullwidth(lensflare_Button[1]); + add_fullwidth(lensflare_Button[2]); + add_fullwidth(lensflare_Button[3]); + add_fullwidth(lensflare_Button[4]); + add_fullwidth(lensflare_Button[5]); + add_fullwidth(lensflare_Button[6]); + +} diff --git a/Editor/LightWindow.h b/Editor/LightWindow.h index 6bd2aa16b..ab9f1feed 100644 --- a/Editor/LightWindow.h +++ b/Editor/LightWindow.h @@ -16,9 +16,6 @@ public: wi::gui::Slider intensitySlider; wi::gui::Slider rangeSlider; - wi::gui::Slider radiusSlider; - wi::gui::Slider widthSlider; - wi::gui::Slider heightSlider; wi::gui::Slider outerConeAngleSlider; wi::gui::Slider innerConeAngleSlider; wi::gui::CheckBox shadowCheckBox; @@ -31,5 +28,7 @@ public: wi::gui::Label lensflare_Label; wi::gui::Button lensflare_Button[7]; + + void ResizeLayout() override; }; diff --git a/Editor/MaterialWindow.cpp b/Editor/MaterialWindow.cpp index f3174cc67..f9b577999 100644 --- a/Editor/MaterialWindow.cpp +++ b/Editor/MaterialWindow.cpp @@ -10,7 +10,7 @@ void MaterialWindow::Create(EditorComponent* _editor) { editor = _editor; wi::gui::Window::Create(ICON_MATERIAL " Material", wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE); - SetSize(XMFLOAT2(300, 1200)); + SetSize(XMFLOAT2(300, 1300)); closeButton.SetTooltip("Delete MaterialComponent"); OnClose([=](wi::gui::EventArgs args) { @@ -691,8 +691,6 @@ void MaterialWindow::Create(EditorComponent* _editor) SetEntity(INVALID_ENTITY); } - - void MaterialWindow::SetEntity(Entity entity) { this->entity = entity; @@ -841,3 +839,83 @@ void MaterialWindow::SetEntity(Entity entity) } } + + +void MaterialWindow::ResizeLayout() +{ + wi::gui::Window::ResizeLayout(); + const float padding = 4; + const float width = GetWidgetAreaSize().x; + float y = padding; + float jump = 20; + + auto add = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_left = 150; + const float margin_right = 40; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + y += widget.GetSize().y; + y += padding; + }; + auto add_right = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_right = 45; + widget.SetPos(XMFLOAT2(width - margin_right - widget.GetSize().x, y)); + y += widget.GetSize().y; + y += padding; + }; + auto add_fullwidth = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_left = padding; + const float margin_right = padding; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + y += widget.GetSize().y; + y += padding; + }; + + add_fullwidth(materialNameField); + add_right(shadowReceiveCheckBox); + add_right(shadowCasterCheckBox); + add_right(useVertexColorsCheckBox); + add_right(specularGlossinessCheckBox); + add_right(occlusionPrimaryCheckBox); + add_right(occlusionSecondaryCheckBox); + add_right(windCheckBox); + add_right(doubleSidedCheckBox); + add_right(outlineCheckBox); + add(shaderTypeComboBox); + add(blendModeComboBox); + add(shadingRateComboBox); + add(alphaRefSlider); + add(normalMapSlider); + add(roughnessSlider); + add(reflectanceSlider); + add(metalnessSlider); + add(emissiveSlider); + add(transmissionSlider); + add(refractionSlider); + add(pomSlider); + add(displacementMappingSlider); + add(subsurfaceScatteringSlider); + add(texAnimFrameRateSlider); + add(texAnimDirectionSliderU); + add(texAnimDirectionSliderV); + add(texMulSliderX); + add(texMulSliderY); + add(sheenRoughnessSlider); + add(clearcoatSlider); + add(clearcoatRoughnessSlider); + add(colorComboBox); + add_fullwidth(colorPicker); + add(textureSlotComboBox); + add_fullwidth(textureSlotButton); + add_fullwidth(textureSlotLabel); + textureSlotLabel.SetSize(XMFLOAT2(textureSlotLabel.GetSize().x - textureSlotLabel.GetSize().y - 2, textureSlotLabel.GetSize().y)); + textureSlotUvsetField.SetPos(XMFLOAT2(textureSlotLabel.GetPos().x + textureSlotLabel.GetSize().x + 2, textureSlotLabel.GetPos().y)); + +} diff --git a/Editor/MaterialWindow.h b/Editor/MaterialWindow.h index b7eb53577..f4c199479 100644 --- a/Editor/MaterialWindow.h +++ b/Editor/MaterialWindow.h @@ -22,6 +22,9 @@ public: wi::gui::CheckBox windCheckBox; wi::gui::CheckBox doubleSidedCheckBox; wi::gui::CheckBox outlineCheckBox; + wi::gui::ComboBox shaderTypeComboBox; + wi::gui::ComboBox blendModeComboBox; + wi::gui::ComboBox shadingRateComboBox; wi::gui::Slider normalMapSlider; wi::gui::Slider roughnessSlider; wi::gui::Slider reflectanceSlider; @@ -38,9 +41,6 @@ public: wi::gui::Slider texMulSliderX; wi::gui::Slider texMulSliderY; wi::gui::Slider alphaRefSlider; - wi::gui::ComboBox shaderTypeComboBox; - wi::gui::ComboBox blendModeComboBox; - wi::gui::ComboBox shadingRateComboBox; wi::gui::Slider sheenRoughnessSlider; wi::gui::Slider clearcoatSlider; wi::gui::Slider clearcoatRoughnessSlider; @@ -52,5 +52,7 @@ public: wi::gui::Button textureSlotButton; wi::gui::Label textureSlotLabel; wi::gui::TextInputField textureSlotUvsetField; + + void ResizeLayout() override; }; diff --git a/Editor/ModelImporter_OBJ.cpp b/Editor/ModelImporter_OBJ.cpp index 31a923b04..286ab75bd 100644 --- a/Editor/ModelImporter_OBJ.cpp +++ b/Editor/ModelImporter_OBJ.cpp @@ -155,6 +155,7 @@ void ImportModel_OBJ(const std::string& fileName, Scene& scene) { // Create default material if nothing was found: Entity materialEntity = scene.Entity_CreateMaterial("OBJImport_defaultMaterial"); + scene.Component_Attach(materialEntity, rootEntity); MaterialComponent& material = *scene.materials.GetComponent(materialEntity); materialLibrary.push_back(materialEntity); // for subset-indexing... } diff --git a/Editor/NameWindow.cpp b/Editor/NameWindow.cpp index 69b4cfcdc..3446a7a45 100644 --- a/Editor/NameWindow.cpp +++ b/Editor/NameWindow.cpp @@ -75,8 +75,10 @@ void NameWindow::SetEntity(Entity entity) } } -void NameWindow::Update() +void NameWindow::ResizeLayout() { + wi::gui::Window::ResizeLayout(); + nameInput.SetPos(XMFLOAT2(60, 4)); nameInput.SetSize(XMFLOAT2(GetSize().x - 65, nameInput.GetSize().y)); } diff --git a/Editor/NameWindow.h b/Editor/NameWindow.h index bf7bf0afa..109d4767c 100644 --- a/Editor/NameWindow.h +++ b/Editor/NameWindow.h @@ -14,6 +14,6 @@ public: wi::gui::TextInputField nameInput; - void Update(); + void ResizeLayout() override; }; diff --git a/Editor/OptionsWindow.cpp b/Editor/OptionsWindow.cpp index abf9bf923..b2aea5147 100644 --- a/Editor/OptionsWindow.cpp +++ b/Editor/OptionsWindow.cpp @@ -580,7 +580,7 @@ void OptionsWindow::Create(EditorComponent* _editor) theme_color_idle = wi::Color(200, 180, 190, 190); theme_color_focus = wi::Color(240, 190, 200, 230); dark_point = wi::Color(100, 80, 90, 220); - theme.shadow_color = wi::Color(240, 190, 200, 100); + theme.shadow_color = wi::Color(240, 190, 200, 180); theme.font.color = wi::Color(255, 230, 240, 255); break; case Theme::Hacking: @@ -944,6 +944,8 @@ void OptionsWindow::RefreshEntityTree() // 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); } } diff --git a/Editor/PaintToolWindow.cpp b/Editor/PaintToolWindow.cpp index 046704af6..64764c8c9 100644 --- a/Editor/PaintToolWindow.cpp +++ b/Editor/PaintToolWindow.cpp @@ -1615,6 +1615,7 @@ void PaintToolWindow::ResizeLayout() add(modeComboBox); add_fullwidth(infoLabel); + add_fullwidth(colorPicker); add(radiusSlider); add(amountSlider); add(smoothnessSlider); @@ -1630,6 +1631,4 @@ void PaintToolWindow::ResizeLayout() add(saveTextureButton); add_right(brushTextureButton); add_right(revealTextureButton); - - colorPicker.SetPos(XMFLOAT2(padding, y)); } diff --git a/Editor/TransformWindow.cpp b/Editor/TransformWindow.cpp index 0b67f9d05..310b66f14 100644 --- a/Editor/TransformWindow.cpp +++ b/Editor/TransformWindow.cpp @@ -28,7 +28,7 @@ void TransformWindow::Create(EditorComponent* _editor) float x = 80; float xx = x; - float y = 0; + float y = 4; float step = 25; float siz = 50; float hei = 20; @@ -54,32 +54,6 @@ void TransformWindow::Create(EditorComponent* _editor) }); AddWidget(&clearButton); - parentCombo.Create("Parent: "); - parentCombo.SetSize(XMFLOAT2(wid, hei)); - parentCombo.SetPos(XMFLOAT2(x, y += step)); - parentCombo.SetEnabled(false); - parentCombo.OnSelect([&](wi::gui::EventArgs args) { - - wi::Archive& archive = editor->AdvanceHistory(); - archive << EditorComponent::HISTORYOP_COMPONENT_DATA; - editor->RecordEntity(archive, entity); - - Scene& scene = editor->GetCurrentScene(); - if (args.iValue == 0) - { - scene.Component_Detach(entity); - } - else - { - scene.Component_Attach(entity, (Entity)args.userdata); - } - - editor->RecordEntity(archive, entity); - - }); - parentCombo.SetTooltip("Choose a parent entity (also works if selected entity has no transform)"); - AddWidget(&parentCombo); - txInput.Create(""); txInput.SetValue(0); txInput.SetDescription("Position X: "); @@ -126,12 +100,12 @@ void TransformWindow::Create(EditorComponent* _editor) AddWidget(&tzInput); x = 250; - y = step; + y = 4 + step; sxInput.Create(""); sxInput.SetValue(1); sxInput.SetDescription("Scale X: "); - sxInput.SetPos(XMFLOAT2(x, y += step)); + sxInput.SetPos(XMFLOAT2(x, y)); sxInput.SetSize(XMFLOAT2(siz, hei)); sxInput.OnInputAccepted([&](wi::gui::EventArgs args) { TransformComponent* transform = editor->GetCurrentScene().transforms.GetComponent(entity); @@ -174,7 +148,7 @@ void TransformWindow::Create(EditorComponent* _editor) AddWidget(&szInput); x = xx; - y = step * 4.5f; + y = step * 4; rollInput.Create(""); @@ -241,7 +215,7 @@ void TransformWindow::Create(EditorComponent* _editor) AddWidget(&yawInput); x = 250; - y = step * 4.5f; + y = step * 4; rxInput.Create(""); rxInput.SetValue(0); @@ -391,39 +365,4 @@ void TransformWindow::SetEntity(Entity entity) { SetEnabled(false); } - - parentCombo.SetEnabled(true); - parentCombo.ClearItems(); - parentCombo.AddItem("NO PARENT"); - HierarchyComponent* hier = scene.hierarchy.GetComponent(entity); - for (size_t i = 0; i < scene.transforms.GetCount(); ++i) - { - Entity candidate_parent_entity = scene.transforms.GetEntity(i); - if (candidate_parent_entity == entity) - { - continue; // Don't list selected (don't allow attach to self) - } - - bool loop = false; - for (size_t j = 0; j < scene.hierarchy.GetCount(); ++j) - { - if (scene.hierarchy[j].parentID == entity) - { - loop = true; - break; - } - } - if (loop) - { - continue; - } - - const NameComponent* name = scene.names.GetComponent(candidate_parent_entity); - parentCombo.AddItem(name == nullptr ? std::to_string(candidate_parent_entity) : name->name, candidate_parent_entity); - - if (hier != nullptr && hier->parentID == candidate_parent_entity) - { - parentCombo.SetSelectedWithoutCallback((int)parentCombo.GetItemCount() - 1); - } - } } diff --git a/Editor/TransformWindow.h b/Editor/TransformWindow.h index 4240885bc..527b35caf 100644 --- a/Editor/TransformWindow.h +++ b/Editor/TransformWindow.h @@ -14,8 +14,6 @@ public: wi::gui::Button clearButton; - wi::gui::ComboBox parentCombo; - wi::gui::TextInputField txInput; wi::gui::TextInputField tyInput; wi::gui::TextInputField tzInput; diff --git a/WickedEngine/wiECS.h b/WickedEngine/wiECS.h index d881b9493..77a22ca3c 100644 --- a/WickedEngine/wiECS.h +++ b/WickedEngine/wiECS.h @@ -76,10 +76,16 @@ namespace wi::ecs } else { +#ifndef _WIN32 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif // _WIN32 + archive << entity; + +#ifndef _WIN32 #pragma GCC diagnostic pop +#endif // _WIN32 } } diff --git a/WickedEngine/wiGUI.cpp b/WickedEngine/wiGUI.cpp index 1ef1a4799..5336ae761 100644 --- a/WickedEngine/wiGUI.cpp +++ b/WickedEngine/wiGUI.cpp @@ -3070,6 +3070,7 @@ namespace wi::gui XMFLOAT2 Window::GetWidgetAreaSize() const { XMFLOAT2 size = GetSize(); + size.y -= control_size; if (scrollbar_horizontal.IsScrollbarRequired()) { size.y -= control_size; @@ -3783,12 +3784,12 @@ namespace wi::gui } // preview { - float _width = 20; + float _width = 50; Vertex vertices[] = { - { XMFLOAT4(-_width, -_width, 0, 1),XMFLOAT4(1,1,1,1) }, - { XMFLOAT4(_width, -_width, 0, 1),XMFLOAT4(1,1,1,1) }, { XMFLOAT4(-_width, _width, 0, 1),XMFLOAT4(1,1,1,1) }, - { XMFLOAT4(_width, _width, 0, 1),XMFLOAT4(1,1,1,1) }, + { XMFLOAT4(0, _width, 0, 1),XMFLOAT4(1,1,1,1) }, + { XMFLOAT4(-_width, 0, 0, 1),XMFLOAT4(1,1,1,1) }, + { XMFLOAT4(0, 0, 0, 1),XMFLOAT4(1,1,1,1) }, }; GPUBufferDesc desc; @@ -3959,7 +3960,7 @@ namespace wi::gui { XMStoreFloat4x4(&cb.g_xTransform, XMMatrixScaling(sca, sca, 1) * - XMMatrixTranslation(translation.x + scale.x - 40 * sca, translation.y + 50, 0) * + XMMatrixTranslation(translation.x + scale.x - sca - 4, translation.y + control_size + 4, 0) * Projection ); cb.g_xColor = final_color.toFloat4(); @@ -3974,6 +3975,47 @@ namespace wi::gui device->Draw((uint32_t)(vb_preview.GetDesc().size / sizeof(Vertex)), 0, cmd); } } + void ColorPicker::ResizeLayout() + { + wi::gui::Window::ResizeLayout(); + const float padding = 4; + const float width = GetWidgetAreaSize().x; + float y = GetWidgetAreaSize().y; + float jump = 20; + + auto add = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_left = 20; + const float margin_right = 120; + y -= widget.GetSize().y; + y -= padding; + widget.SetPos(XMFLOAT2(margin_left, y)); + widget.SetSize(XMFLOAT2(width - margin_left - margin_right, widget.GetScale().y)); + }; + auto add_right = [&](wi::gui::Widget& widget) { + if (!widget.IsVisible()) + return; + const float margin_right = padding; + y -= widget.GetSize().y; + y -= padding; + widget.SetPos(XMFLOAT2(width - margin_right - widget.GetSize().x, y)); + }; + + add(alphaSlider); + y += alphaSlider.GetSize().y; + y += padding; + + add_right(text_V); + add_right(text_S); + add_right(text_H); + + y -= jump; + + add_right(text_B); + add_right(text_G); + add_right(text_R); + } wi::Color ColorPicker::GetPickColor() const { hsv source; diff --git a/WickedEngine/wiGUI.h b/WickedEngine/wiGUI.h index 0326f46bd..c76b8747e 100644 --- a/WickedEngine/wiGUI.h +++ b/WickedEngine/wiGUI.h @@ -647,6 +647,7 @@ namespace wi::gui void Update(const wi::Canvas& canvas, float dt) override; void Render(const wi::Canvas& canvas, wi::graphics::CommandList cmd) const override; + void ResizeLayout() override; wi::Color GetPickColor() const; void SetPickColor(wi::Color value);