diff --git a/radiant/ui/materials/MapExpressionEntry.h b/radiant/ui/materials/MapExpressionEntry.h index 2f80604ee6..7004b5c809 100644 --- a/radiant/ui/materials/MapExpressionEntry.h +++ b/radiant/ui/materials/MapExpressionEntry.h @@ -39,6 +39,11 @@ class MapExpressionEntry : GetSizer()->Add(_browseButton, 0, wxALIGN_CENTER_VERTICAL, 0); } + wxTextCtrl* GetTextCtrl() + { + return _textEntry; + } + wxString GetValue() { return _textEntry->GetValue(); diff --git a/radiant/ui/materials/MaterialEditor.cpp b/radiant/ui/materials/MaterialEditor.cpp index ea2d67f170..facddbc330 100644 --- a/radiant/ui/materials/MaterialEditor.cpp +++ b/radiant/ui/materials/MaterialEditor.cpp @@ -250,6 +250,7 @@ void MaterialEditor::setupMaterialProperties() // Place map expression controls where needed convertTextCtrlToMapExpressionEntry("MaterialStageImageMap"); + convertTextCtrlToMapExpressionEntry("MaterialLightFalloffMap"); auto* typeDropdown = getControl("MaterialType"); @@ -327,7 +328,8 @@ void MaterialEditor::setupMaterialProperties() _material->setLightFalloffCubeMapType(shaders::getMapTypeForString(lightFallOffCubeMapType->GetStringSelection().ToStdString())); }); - _materialBindings.emplace(std::make_shared>(getControl("MaterialLightFalloffMap"), + auto lightFalloffMap = getControl("MaterialLightFalloffMap"); + _materialBindings.emplace(std::make_shared>(lightFalloffMap->GetTextCtrl(), [](const MaterialPtr& material) { auto expr = material->getLightFalloffExpression(); @@ -704,6 +706,21 @@ void MaterialEditor::createSpinCtrlDoubleBinding(const std::string& ctrlName, void MaterialEditor::setupMaterialStageProperties() { + auto stageImageMap = getControl("MaterialStageImageMap"); + _stageBindings.emplace(std::make_shared>(stageImageMap->GetTextCtrl(), + [](const IShaderLayer::Ptr& stage) + { + auto expr = stage->getMapExpression(); + return expr ? expr->getExpressionString() : std::string(); + }, + [this](const IEditableShaderLayer::Ptr& stage, const std::string& value) + { + if (_stageUpdateInProgress) return; + stage->setMapExpressionFromString(value); + }, + [this]() { onMaterialChanged(); }, + std::bind(&MaterialEditor::getEditableStageForSelection, this))); + setupStageFlag("MaterialStageFlagMaskRed", IShaderLayer::FLAG_MASK_RED); setupStageFlag("MaterialStageFlagMaskGreen", IShaderLayer::FLAG_MASK_GREEN); setupStageFlag("MaterialStageFlagMaskBlue", IShaderLayer::FLAG_MASK_BLUE); @@ -1600,20 +1617,8 @@ void MaterialEditor::updateStageControls() if (selectedStage) { selectedStage->evaluateExpressions(0); // initialise the values of this stage - - auto mapExpr = selectedStage->getMapExpression(); + auto imageMap = getControl("MaterialStageImageMap"); - imageMap->SetValue(mapExpr ? mapExpr->getExpressionString() : ""); - - imageMap->Bind(wxEVT_TEXT, [imageMap, this](wxCommandEvent&) - { - if (_stageUpdateInProgress) return; - - auto stage = getEditableStageForSelection(); - stage->setMapExpressionFromString(imageMap->GetValue().ToStdString()); - onMaterialChanged(); - }); - auto videoMapLoop = getControl("MaterialStageVideoMapLoop"); auto soundMapWave = getControl("MaterialStageSoundMapWaveform"); @@ -1680,7 +1685,6 @@ void MaterialEditor::updateStageControls() else { getControl("MaterialStageNoVertexColourFlag")->SetValue(true); - getControl("MaterialStageImageMap")->SetValue(""); } }