diff --git a/Sources/Tools/MaxComponent/plAutoUIBase.cpp b/Sources/Tools/MaxComponent/plAutoUIBase.cpp index 645d4ad103..510c8f4c9f 100644 --- a/Sources/Tools/MaxComponent/plAutoUIBase.cpp +++ b/Sources/Tools/MaxComponent/plAutoUIBase.cpp @@ -375,6 +375,18 @@ void plAutoUIBase::AddPickGrassComponentButton(int16_t id, const ST::string& scr fParams.push_back(param); } +void plAutoUIBase::AddPickLayerButton(int16_t id, const ST::string& scriptName, const ST::string& name, int vid, std::unordered_set vstates) +{ + ST::string scriptNameNew = !scriptName.empty() ? scriptName : IMakeScriptName(name); + + fDesc->AddParam(id, ST2M(scriptNameNew), TYPE_REFTARG, 0, 0, + p_end, + p_end); + plAutoUIParam* param = new plPickMaterialButtonParam(id, name); + param->SetVisInfo(vid, std::move(vstates)); + fParams.push_back(param); +} + INT_PTR CALLBACK plAutoUIBase::ForwardDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { plAutoUIBase *pthis = nullptr; diff --git a/Sources/Tools/MaxComponent/plAutoUIBase.h b/Sources/Tools/MaxComponent/plAutoUIBase.h index 024362f9e7..e76955bd68 100644 --- a/Sources/Tools/MaxComponent/plAutoUIBase.h +++ b/Sources/Tools/MaxComponent/plAutoUIBase.h @@ -120,6 +120,7 @@ class plAutoUIBase void AddDropDownList(int16_t id, const ST::string& scriptName, const ST::string& name, int vid, std::unordered_set vstates, std::vector options); void AddPickGrassComponentButton(int16_t id, const ST::string& scriptName, const ST::string& name, int vid, std::unordered_set vstates); + void AddPickLayerButton(int16_t id, const ST::string& scriptName, const ST::string& name, int vid, std::unordered_set vstates); void CreateAutoRollup(IParamBlock2 *pb); void DestroyAutoRollup(); diff --git a/Sources/Tools/MaxComponent/plAutoUIParams.h b/Sources/Tools/MaxComponent/plAutoUIParams.h index 1323308651..a36b5477dc 100644 --- a/Sources/Tools/MaxComponent/plAutoUIParams.h +++ b/Sources/Tools/MaxComponent/plAutoUIParams.h @@ -92,6 +92,7 @@ class plAutoUIParam kTypeClusterComponent, kTypeMaterialAnimation, kTypeGrassComponent, + kTypeLayer }; plAutoUIParam(ParamID id, ST::string name); diff --git a/Sources/Tools/MaxComponent/plPythonFileComponent.cpp b/Sources/Tools/MaxComponent/plPythonFileComponent.cpp index ae3f9339d1..21d3405f45 100644 --- a/Sources/Tools/MaxComponent/plPythonFileComponent.cpp +++ b/Sources/Tools/MaxComponent/plPythonFileComponent.cpp @@ -80,6 +80,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plAvatar/plSwimRegion.h" #include "plSurface/plGrassShaderMod.h" #include "plGrassComponent.h" +#include "plSurface/plLayer.h" #include "pfPython/plPythonFileMod.h" #include "pfPython/plPythonParameter.h" @@ -988,6 +989,21 @@ bool plPythonFileComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) } } break; + case plAutoUIParam::kTypeLayer: + { + int numKeys = param->GetCount(pb); + for (int i = 0; i < numKeys; i++) + { + plKey key = param->GetKey(pb, i); + // make sure we got a key and that it is a plLayer + if (key && plLayer::ConvertNoRef(key->GetObjectPtr())) + { + pyParam.SetToLayer(key); + mod->AddParameter(pyParam); + } + } + } + break; } } diff --git a/Sources/Tools/MaxMain/plPythonMgr.cpp b/Sources/Tools/MaxMain/plPythonMgr.cpp index 990c9dddcb..8cdd847468 100644 --- a/Sources/Tools/MaxMain/plPythonMgr.cpp +++ b/Sources/Tools/MaxMain/plPythonMgr.cpp @@ -180,7 +180,8 @@ enum ParamTypes kTypeSwimCurrentInterface, // 21 kTypeClusterComponent, // 22 kTypeMaterialAnimation, // 23 - kTypeGrassComponent, // 24 + kTypeGrassComponent, // 24 + kTypeLayer, // 25 }; bool IGetTupleInt(PyObject *tuple, int pos, int& val) @@ -451,6 +452,9 @@ bool plPythonMgr::IQueryPythonFile(const ST::string& fileName) case kTypeGrassComponent: IAddGrassComponent(autoUI, ret, paramName, paramID, ddlParamID, vec); break; + case kTypeLayer: + IAddLayerComponent(autoUI, ret, paramName, paramID, ddlParamID, vec); + break; } } } @@ -624,6 +628,11 @@ void plPythonMgr::IAddGrassComponent(plAutoUIBlock *autoUI, PyObject *objTuple, autoUI->AddPickGrassComponentButton(id, {}, paramName, vid, std::move(vstates)); } +void plPythonMgr::IAddLayerComponent(plAutoUIBlock* autoUI, PyObject* objTuple, const ST::string& paramName, int id, int vid, std::unordered_set vstates) +{ + autoUI->AddPickLayerButton(id, {}, paramName, vid, std::move(vstates)); +} + void plPythonMgr::LoadPythonFiles() { plFileName clientPath = plMaxConfig::GetClientPath(false, true); diff --git a/Sources/Tools/MaxMain/plPythonMgr.h b/Sources/Tools/MaxMain/plPythonMgr.h index eff45edb57..6b7dded958 100644 --- a/Sources/Tools/MaxMain/plPythonMgr.h +++ b/Sources/Tools/MaxMain/plPythonMgr.h @@ -81,6 +81,7 @@ class plPythonMgr void IAddClusterComponent(plAutoUIBlock *autoUI, PyObject *tuple, const ST::string& paramName, int id, int vid, std::unordered_set vstates); void IAddMaterialAnimation(plAutoUIBlock *autoUI, PyObject *tuple, const ST::string& paramName, int id, int vid, std::unordered_set vstates); void IAddGrassComponent(plAutoUIBlock *autoUI, PyObject *objTuple, const ST::string& paramName, int id, int vid, std::unordered_set vstates); + void IAddLayerComponent(plAutoUIBlock *autoUI, PyObject *objTuple, const ST::string& paramName, int id, int vid, std::unordered_set vstates); public: static plPythonMgr& Instance();