Skip to content

Commit

Permalink
#5532: Custom map types are editable now
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 20, 2021
1 parent 724d653 commit f34da7a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/ishaderlayer.h
Expand Up @@ -445,4 +445,10 @@ class IEditableShaderLayer :

// Sets width and height of the mirrorRenderMap/remoteRenderMap images
virtual void setRenderMapSize(const Vector2& size) = 0;

// For stages with map type SoundMap, this is used to set the waveform flag
virtual void setSoundMapWaveForm(bool waveForm) = 0;

// For stages with map type VideoMap, this is used to update the properties
virtual void setVideoMapProperties(const std::string& filePath, bool looping) = 0;
};
30 changes: 30 additions & 0 deletions radiant/ui/materials/MaterialEditor.cpp
Expand Up @@ -565,6 +565,36 @@ void MaterialEditor::setupMaterialStageProperties()
layer->setRenderMapSize(Vector2(currentSize.x(), value));
});

getControl<wxCheckBox>("MaterialStageSoundMapWaveform")->Bind(wxEVT_CHECKBOX, [this] (wxCommandEvent& ev)
{
if (this->_stageUpdateInProgress) return;
auto stage = getEditableStageForSelection();
if (!stage) return;

stage->setSoundMapWaveForm(ev.IsChecked());
});

getControl<wxCheckBox>("MaterialStageVideoMapLoop")->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent& ev)
{
if (this->_stageUpdateInProgress) return;
auto stage = getEditableStageForSelection();
if (!stage) return;

auto filePath = getControl<wxTextCtrl>("MaterialStageVideoMapFile")->GetValue().ToStdString();
stage->setVideoMapProperties(filePath, ev.IsChecked());
});

getControl<wxTextCtrl>("MaterialStageVideoMapFile")->Bind(wxEVT_TEXT, [this](wxCommandEvent& ev)
{
if (this->_stageUpdateInProgress) return;
auto stage = getEditableStageForSelection();
if (!stage) return;

auto filePath = getControl<wxTextCtrl>("MaterialStageVideoMapFile")->GetValue().ToStdString();
bool loop = getControl<wxCheckBox>("MaterialStageVideoMapLoop")->GetValue();
stage->setVideoMapProperties(filePath, loop);
});

createSpinCtrlDoubleBinding("MaterialStagePrivatePolygonOffset",
[](const IShaderLayer::Ptr& layer) { return layer->getPrivatePolygonOffset(); },
[this](const IEditableShaderLayer::Ptr& layer, const double& value)
Expand Down
12 changes: 12 additions & 0 deletions radiantcore/shaders/Doom3ShaderLayer.cpp
@@ -1,5 +1,7 @@
#include "Doom3ShaderLayer.h"
#include "Doom3ShaderSystem.h"
#include "SoundMapExpression.h"
#include "VideoMapExpression.h"

namespace shaders
{
Expand Down Expand Up @@ -586,4 +588,14 @@ void Doom3ShaderLayer::setTexGenExpressionFromString(std::size_t index, const st
_expressionSlots.assignFromString(slot, expression, REG_ZERO);
}

void Doom3ShaderLayer::setSoundMapWaveForm(bool waveForm)
{
setBindableTexture(std::make_shared<SoundMapExpression>(waveForm));
}

void Doom3ShaderLayer::setVideoMapProperties(const std::string& filePath, bool looping)
{
setBindableTexture(std::make_shared<VideoMapExpression>(filePath, looping));
}

}
2 changes: 2 additions & 0 deletions radiantcore/shaders/Doom3ShaderLayer.h
Expand Up @@ -435,6 +435,8 @@ class Doom3ShaderLayer :
void setColourExpressionFromString(ColourComponentSelector component, const std::string& expression) override;
void setConditionExpressionFromString(const std::string& expression) override;
void setTexGenExpressionFromString(std::size_t index, const std::string& expression) override;
void setSoundMapWaveForm(bool waveForm) override;
void setVideoMapProperties(const std::string& filePath, bool looping) override;

int getParseFlags() const override;
void setParseFlag(ParseFlags flag);
Expand Down

0 comments on commit f34da7a

Please sign in to comment.