From 666551c31275db9b1668b29342d99ca2a485cfa7 Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 21 Feb 2021 05:25:55 +0100 Subject: [PATCH] #5532: Show/hide deform pages as needed --- install/ui/materialeditor.fbp | 12 ++++++------ install/ui/materialeditor.xrc | 6 +++--- radiant/ui/materials/MaterialEditor.cpp | 22 ++++++++++++++++++++++ radiant/ui/materials/MaterialEditor.h | 1 + 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/install/ui/materialeditor.fbp b/install/ui/materialeditor.fbp index 4584310a66..c1c4dc1fd0 100644 --- a/install/ui/materialeditor.fbp +++ b/install/ui/materialeditor.fbp @@ -5501,7 +5501,7 @@ 0 wxEXPAND 1 - + bSizer7811 wxHORIZONTAL @@ -5567,11 +5567,11 @@ -1 - + 6 wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -6176,7 +6176,7 @@ Deform - 0 + 1 1 1 @@ -6308,7 +6308,7 @@ 6 - wxALL|wxEXPAND + wxALL 1 @@ -7828,7 +7828,7 @@ Misc - 1 + 0 1 1 diff --git a/install/ui/materialeditor.xrc b/install/ui/materialeditor.xrc index 3ec4e0f447..8527db2687 100644 --- a/install/ui/materialeditor.xrc +++ b/install/ui/materialeditor.xrc @@ -1049,7 +1049,7 @@ - 0 + 1 @@ -1071,7 +1071,7 @@ - wxALL|wxEXPAND + wxALL 6 wxVERTICAL @@ -1307,7 +1307,7 @@ - 1 + 0 diff --git a/radiant/ui/materials/MaterialEditor.cpp b/radiant/ui/materials/MaterialEditor.cpp index 30e71adbcf..5aadcf06b6 100644 --- a/radiant/ui/materials/MaterialEditor.cpp +++ b/radiant/ui/materials/MaterialEditor.cpp @@ -298,6 +298,13 @@ void MaterialEditor::setupMaterialDeformPage() { dropdown->AppendString(pair.first); } + + _deformPanels[Material::DEFORM_FLARE] = getControl("DeformFlarePanel"); + _deformPanels[Material::DEFORM_EXPAND] = getControl("DeformExpandPanel"); + _deformPanels[Material::DEFORM_MOVE] = getControl("DeformMovePanel"); + _deformPanels[Material::DEFORM_TURBULENT] = getControl("DeformTurbulentPanel"); + _deformPanels[Material::DEFORM_PARTICLE] = getControl("DeformParticlePanel"); + _deformPanels[Material::DEFORM_PARTICLE2] = getControl("DeformParticle2Panel"); } void MaterialEditor::setupMaterialStageView() @@ -436,6 +443,14 @@ void MaterialEditor::updateMaterialPropertiesFromMaterial() deformDropdown->Select(0); } + // Hide the unrelated deform controls + for (const auto& pair : _deformPanels) + { + pair.second->Show(_material->getDeformType() == pair.first); + } + + getControl("DeformPage")->Layout(); + // Surround the definition with curly braces, these are not included auto definition = fmt::format("{0}\n{{{1}}}", _material->getName(), _material->getDefinition()); _sourceView->SetValue(definition); @@ -444,6 +459,13 @@ void MaterialEditor::updateMaterialPropertiesFromMaterial() { getControl("MaterialEditorDeformChoice")->Select(0); + for (const auto& pair : _deformPanels) + { + pair.second->Hide(); + } + + getControl("DeformPage")->Layout(); + getControl("MaterialHasRenderBump")->SetValue(false); getControl("MaterialRenderBumpArguments")->SetValue(""); diff --git a/radiant/ui/materials/MaterialEditor.h b/radiant/ui/materials/MaterialEditor.h index 030775da9b..0aac62caea 100644 --- a/radiant/ui/materials/MaterialEditor.h +++ b/radiant/ui/materials/MaterialEditor.h @@ -35,6 +35,7 @@ class MaterialEditor : MaterialPtr _material; std::set> _bindings; + std::map _deformPanels; private: MaterialEditor();