diff --git a/Sources/MaxPlugin/MaxComponent/plAutoUIBase.cpp b/Sources/MaxPlugin/MaxComponent/plAutoUIBase.cpp index 136707001f..ae661536d2 100644 --- a/Sources/MaxPlugin/MaxComponent/plAutoUIBase.cpp +++ b/Sources/MaxPlugin/MaxComponent/plAutoUIBase.cpp @@ -382,7 +382,7 @@ void plAutoUIBase::AddPickLayerButton(int16_t id, const ST::string& scriptName, fDesc->AddParam(id, ST2M(scriptNameNew), TYPE_REFTARG, 0, 0, p_end, p_end); - plAutoUIParam* param = new plPickMaterialButtonParam(id, name); + plAutoUIParam* param = new plPickLayerButtonParam(id, name); param->SetVisInfo(vid, std::move(vstates)); fParams.push_back(param); } diff --git a/Sources/MaxPlugin/MaxComponent/plAutoUIParams.cpp b/Sources/MaxPlugin/MaxComponent/plAutoUIParams.cpp index 44ef15bf16..0457b60b86 100644 --- a/Sources/MaxPlugin/MaxComponent/plAutoUIParams.cpp +++ b/Sources/MaxPlugin/MaxComponent/plAutoUIParams.cpp @@ -1672,6 +1672,30 @@ bool plPickMaterialAnimationButtonParam::IsMyMessage(UINT msg, WPARAM wParam, LP /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// +plKey plPickLayerButtonParam::GetKey(IParamBlock2 *pb, int idx) +{ + // get the plKeys based on the texture map that the Texture map is on + Texmap* texmap = (Texmap* )pb->GetReferenceTarget(fID); + // make sure that there was a texmap set + if (texmap) { + plPlasmaMAXLayer *maxLayer = plPlasmaMAXLayer::GetPlasmaMAXLayer(texmap); + if (maxLayer != nullptr) { + // make sure the index is valid + if (idx >= 0 && idx < maxLayer->GetNumConversionTargets()) { + plLayerInterface* convertedLayer = maxLayer->GetConversionTarget(idx); + if (convertedLayer) + return convertedLayer->GetKey(); + } + } + } + + // otherwise we didn't find one, because of one of many reasons + return nullptr; +} + +/////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////////// + plDropDownListParam::plDropDownListParam(ParamID id, ST::string name, std::vector options) : plAutoUIParam(id, std::move(name)), fhList(), fOptions(std::move(options)) { diff --git a/Sources/MaxPlugin/MaxComponent/plAutoUIParams.h b/Sources/MaxPlugin/MaxComponent/plAutoUIParams.h index a36b5477dc..ed3a933268 100644 --- a/Sources/MaxPlugin/MaxComponent/plAutoUIParams.h +++ b/Sources/MaxPlugin/MaxComponent/plAutoUIParams.h @@ -394,6 +394,17 @@ class plPickMaterialAnimationButtonParam : public plPickButtonParam void DestroyKeyArray(); }; +class plPickLayerButtonParam : public plPickMaterialButtonParam +{ +public: + plPickLayerButtonParam(ParamID id, ST::string name) + : plPickMaterialButtonParam(id, std::move(name)) + { } + + int GetParamType() override { return kTypeLayer; } + plKey GetKey(IParamBlock2 *pb, int idx = 0) override; +}; + class plDropDownListParam : public plAutoUIParam { protected: