Skip to content

Commit

Permalink
#5565: Bind editor image controls
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 26, 2021
1 parent 51ac2ff commit 7d0aeaf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions radiant/ui/materials/editor/MaterialEditor.cpp
Expand Up @@ -261,6 +261,21 @@ void MaterialEditor::setupMaterialProperties()
// Place map expression controls where needed
convertTextCtrlToMapExpressionEntry("MaterialStageImageMap");
convertTextCtrlToMapExpressionEntry("MaterialLightFalloffMap");
convertTextCtrlToMapExpressionEntry("MaterialEditorImage");

auto editorImage = getControl<MapExpressionEntry>("MaterialEditorImage");
_materialBindings.emplace(std::make_shared<ExpressionBinding<MaterialPtr>>(editorImage->GetTextCtrl(),
[](const MaterialPtr& material)
{
auto expr = material->getEditorImageExpression();
return expr ? expr->getExpressionString() : std::string();
},
[this](const MaterialPtr& material, const std::string& value)
{
if (_materialUpdateInProgress || !_material) return;
material->setEditorImageExpressionFromString(value);
},
[this]() { onMaterialChanged(); }));

auto* typeDropdown = getControl<wxChoice>("MaterialType");

Expand Down
2 changes: 2 additions & 0 deletions radiantcore/shaders/CShader.cpp
Expand Up @@ -96,6 +96,8 @@ IMapExpression::Ptr CShader::getEditorImageExpression()
void CShader::setEditorImageExpressionFromString(const std::string& editorImagePath)
{
ensureTemplateCopy();

_editorTexture.reset();
_template->setEditorImageExpressionFromString(editorImagePath);
}

Expand Down

0 comments on commit 7d0aeaf

Please sign in to comment.