Implements misc fixes for the particle editor and particlesList inspector field

- Clicking the [...] button from the Particle Emitter tab now opens to the Particle tab *and* properly selects the particle data to be edited
- Selecting an emitter object in the map and opening the particle editor now selects the Particle Data to be edited
- Selecting a new Particle Data for a particles slot on a Particle Emitter in the editor now correctly updates the values and updates the field display
- Made it so if clicking [...] button on the ParticleEmitterData or other similar fields for objects, it will now open to the Particle editor instead of the Datablock editor
This commit is contained in:
JeffR 2026-04-19 02:18:05 -05:00
parent 12dddd07b5
commit defbaea2fe
7 changed files with 145 additions and 45 deletions

View file

@ -907,6 +907,9 @@ GuiControl* GuiInspectorTypeParticleDataList::constructEditControl()
mNewParticleBtn->registerObject();
mNewParticleBtn->_setBitmap(StringTable->insert("ToolsModule:iconAdd_image"));
mNewParticleBtn->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiDefaultProfile");
mNewParticleBtn->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
mNewParticleBtn->setDataField(StringTable->insert("hovertime"), NULL, "1000");
mNewParticleBtn->setDataField(StringTable->insert("tooltip"), NULL, "Add new particle slot");
mNewParticleBtn->setHorizSizing(horizResizeRight);
mNewParticleBtn->mMakeIconSquare = true;
mNewParticleBtn->mFitBitmapToButton = true;
@ -914,7 +917,7 @@ GuiControl* GuiInspectorTypeParticleDataList::constructEditControl()
char szBuffer[512];
dSprintf(szBuffer, sizeof(szBuffer), "ParticleEditor.addParticleSlot(%s, %s);",
mNewParticleBtn->getIdString(), mInspector->getInspectObject()->getIdString());
this->getIdString(), mInspector->getInspectObject()->getIdString());
mNewParticleBtn->setField("Command", szBuffer);
GuiContainer* newBtnCtnr = new GuiContainer();
@ -924,39 +927,16 @@ GuiControl* GuiInspectorTypeParticleDataList::constructEditControl()
mStack->addObject(newBtnCtnr);
//Particle 0
mParticleSlot0Ctrl = _buildParticleEntryField(0);
mStack->addObject(mParticleSlot0Ctrl);
//Now the non-default entries if we already have some
Parent::updateValue();
const char* data = getData();
if (data != NULL && !String::isEmpty(data))
{
U32 particlesCount = StringUnit::getUnitCount(data, " ");
for (U32 i=1; i < particlesCount; i++)
{
GuiControl* particleSlotCtrl = _buildParticleEntryField(i);
mStack->addObject(particleSlotCtrl);
}
}
_rebuildParticleEntryList();
_registerEditControl(mStack);
//constructEditControlChildren(retCtrl, getWidth());
//retCtrl->addObject(mScriptValue);
/*char szBuffer[512];
dSprintf(szBuffer, 512, "setClipboard(%d.getText());", mScriptValue->getId());
mCopyButton->setField("Command", szBuffer);
addObject(mCopyButton);*/
mUseHeightOverride = true;
mHeightOverride = (mStack->getCount() * 23) + 6;
//Now the non-default entries if we already have some
//Parent::updateValue();
return mStack;
}
@ -980,7 +960,7 @@ GuiControl* GuiInspectorTypeParticleDataList::_buildParticleEntryField(const S32
char szBuffer[512];
dSprintf(szBuffer, sizeof(szBuffer), "ParticleEditor.changeParticleSlot(%s, %s, %d);",
listBtn->getIdString(), mInspector->getInspectObject()->getIdString(), index);
this->getIdString(), mInspector->getInspectObject()->getIdString(), index);
listBtn->setField("Command", szBuffer);
if (mField && index != -1)
@ -1001,6 +981,9 @@ GuiControl* GuiInspectorTypeParticleDataList::_buildParticleEntryField(const S32
editSlotBtn->registerObject();
editSlotBtn->setText(StringTable->insert("..."));
editSlotBtn->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiButtonProfile");
editSlotBtn->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
editSlotBtn->setDataField(StringTable->insert("hovertime"), NULL, "1000");
editSlotBtn->setDataField(StringTable->insert("tooltip"), NULL, "Edit this particle");
editSlotBtn->setHorizSizing(horizResizeRight);
editSlotBtn->setInternalName("editBtn");
editSlotBtn->setPosition(editExtent.x - 40, 0);
@ -1019,6 +1002,9 @@ GuiControl* GuiInspectorTypeParticleDataList::_buildParticleEntryField(const S32
deleteSlotBtn->registerObject();
deleteSlotBtn->_setBitmap(StringTable->insert("ToolsModule:iconCancel_image"));
deleteSlotBtn->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiDefaultProfile");
deleteSlotBtn->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
deleteSlotBtn->setDataField(StringTable->insert("hovertime"), NULL, "1000");
deleteSlotBtn->setDataField(StringTable->insert("tooltip"), NULL, "Delete this particle slot");
deleteSlotBtn->setHorizSizing(horizResizeRight);
deleteSlotBtn->setInternalName("deleteBtn");
deleteSlotBtn->mMakeIconSquare = true;
@ -1062,6 +1048,38 @@ void GuiInspectorTypeParticleDataList::_populateMenu(GuiPopUpMenuCtrlEx* menu)
menu->sort();
}
void GuiInspectorTypeParticleDataList::_rebuildParticleEntryList()
{
const char* data = getData();
//whoops it's misaligned, force a rebuild
mParticleSlot0Ctrl = NULL;
for (U32 i = 0; i < mParticleSlotList.size(); i++)
{
mStack->removeObject(mParticleSlotList[i]);
mParticleSlotList[i]->deleteObject();
}
mParticleSlotList.clear();
//Particle 0
mParticleSlot0Ctrl = _buildParticleEntryField(0);
mStack->addObject(mParticleSlot0Ctrl);
mParticleSlotList.push_back(mParticleSlot0Ctrl);
if (data != NULL && !String::isEmpty(data))
{
U32 particlesCount = StringUnit::getUnitCount(data, " ");
for (U32 i = 1; i < particlesCount; i++)
{
GuiControl* particleSlotCtrl = _buildParticleEntryField(i);
mStack->addObject(particleSlotCtrl);
mParticleSlotList.push_back(particleSlotCtrl);
}
}
}
bool GuiInspectorTypeParticleDataList::updateRects()
{
S32 rowSize = 18;
@ -1109,14 +1127,43 @@ bool GuiInspectorTypeParticleDataList::updateRects()
mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
mUseHeightOverride = true;
mHeightOverride = (mStack->getCount() * 23) + 6;
//mCopyButton->resize(Point2I(mProfile->mTextOffset.x, rowSize + 3), Point2I(45, 15));
//mPasteButton->resize(Point2I(mProfile->mTextOffset.x, rowSize + rowSize + 6), Point2I(45, 15));
RectI bnds = getBounds();
setBounds(bnds.point.x, bnds.point.y, bnds.extent.x, mHeightOverride);
return true;
}
void GuiInspectorTypeParticleDataList::updateValue()
{
const char* data = getData();
if (data != NULL && !String::isEmpty(data))
{
U32 particlesCount = StringUnit::getUnitCount(data, " ");
if (particlesCount != mParticleSlotList.size())
{
_rebuildParticleEntryList();
}
else
{
for (U32 i = 0; i < particlesCount; i++)
{
GuiButtonCtrl* listBtn = dynamic_cast<GuiButtonCtrl*>(mParticleSlotList[i]->getObject(0));
if (!listBtn) //This *really* shouldn't happen
continue;
const char* particleName = StringUnit::getUnit(data, i, " ");
listBtn->setText(particleName);
}
}
}
updateRects();
}
void GuiInspectorTypeParticleDataList::consoleInit()
{

View file

@ -33,8 +33,10 @@ public:
GuiControl* constructEditControl() override;
bool updateRects() override;
void updateValue() override;
void _populateMenu(GuiPopUpMenuCtrlEx* menu);
GuiControl* _buildParticleEntryField(const S32& index);
void _rebuildParticleEntryList();
};
#endif