Skip to content

Commit

Permalink
Add ptAttribLayer to PlasmaMax.
Browse files Browse the repository at this point in the history
  • Loading branch information
Deledrius committed Jul 13, 2023
1 parent 1963d79 commit cd90541
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Sources/Tools/MaxComponent/plAutoUIBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ST::string> 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;
Expand Down
1 change: 1 addition & 0 deletions Sources/Tools/MaxComponent/plAutoUIBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class plAutoUIBase

void AddDropDownList(int16_t id, const ST::string& scriptName, const ST::string& name, int vid, std::unordered_set<ST::string> vstates, std::vector<ST::string> options);
void AddPickGrassComponentButton(int16_t id, const ST::string& scriptName, const ST::string& name, int vid, std::unordered_set<ST::string> vstates);
void AddPickLayerButton(int16_t id, const ST::string& scriptName, const ST::string& name, int vid, std::unordered_set<ST::string> vstates);

void CreateAutoRollup(IParamBlock2 *pb);
void DestroyAutoRollup();
Expand Down
1 change: 1 addition & 0 deletions Sources/Tools/MaxComponent/plAutoUIParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class plAutoUIParam
kTypeClusterComponent,
kTypeMaterialAnimation,
kTypeGrassComponent,
kTypeLayer
};

plAutoUIParam(ParamID id, ST::string name);
Expand Down
16 changes: 16 additions & 0 deletions Sources/Tools/MaxComponent/plPythonFileComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ You can contact Cyan Worlds, Inc. by email [email protected]
#include "plAvatar/plSwimRegion.h"
#include "plSurface/plGrassShaderMod.h"
#include "plGrassComponent.h"
#include "plSurface/plLayer.h"

#include "pfPython/plPythonFileMod.h"
#include "pfPython/plPythonParameter.h"
Expand Down Expand Up @@ -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;

}
}
Expand Down
11 changes: 10 additions & 1 deletion Sources/Tools/MaxMain/plPythonMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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<ST::string> vstates)
{
autoUI->AddPickLayerButton(id, {}, paramName, vid, std::move(vstates));
}

void plPythonMgr::LoadPythonFiles()
{
plFileName clientPath = plMaxConfig::GetClientPath(false, true);
Expand Down
1 change: 1 addition & 0 deletions Sources/Tools/MaxMain/plPythonMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class plPythonMgr
void IAddClusterComponent(plAutoUIBlock *autoUI, PyObject *tuple, const ST::string& paramName, int id, int vid, std::unordered_set<ST::string> vstates);
void IAddMaterialAnimation(plAutoUIBlock *autoUI, PyObject *tuple, const ST::string& paramName, int id, int vid, std::unordered_set<ST::string> vstates);
void IAddGrassComponent(plAutoUIBlock *autoUI, PyObject *objTuple, const ST::string& paramName, int id, int vid, std::unordered_set<ST::string> vstates);
void IAddLayerComponent(plAutoUIBlock *autoUI, PyObject *objTuple, const ST::string& paramName, int id, int vid, std::unordered_set<ST::string> vstates);

public:
static plPythonMgr& Instance();
Expand Down

0 comments on commit cd90541

Please sign in to comment.