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

@ -111,6 +111,19 @@ function DatablockEditorPlugin::onExitMission( %this )
function DatablockEditorPlugin::openDatablock( %this, %datablock )
{
//We want to do a special-case catch here for any datablock types that have their own unique editor.
//The main culprit is the particle editor, but this could be expanded later
if(%datablock.isMemberOfClass("ParticleData") ||
%datablock.isMemberOfClass("ParticleEmitterData") ||
%datablock.isMemberOfClass("ExplosionData") ||
%datablock.isMemberOfClass("RibbonData") ||
%datablock.isMemberOfClass("afxZodiacData") ||
%datablock.isMemberOfClass("afxChoreographerData"))
{
EditorGui.setEditor( ParticleEditorPlugin );
return;
}
EditorGui.setEditor( DatablockEditorPlugin );
%this.selectDatablock( %datablock );
DatablockEditorTreeTabBook.selectedPage = 0;
@ -631,6 +644,21 @@ function DatablockEditorPlugin::deleteDatablock( %this )
//---------------------------------------------------------------------------------------------
function DatablockEditorPlugin::createNewDatablockOfType(%this, %class, %inheritFrom)
{
//We want to do a special-case catch here for any datablock types that have their own unique editor.
//The main culprit is the particle editor, but this could be expanded later
if(%class.isMemberOfClass("ParticleData") ||
%class.isMemberOfClass("ParticleEmitterData") ||
%class.isMemberOfClass("ExplosionData") ||
%class.isMemberOfClass("RibbonData") ||
%class.isMemberOfClass("afxZodiacData") ||
%class.isMemberOfClass("afxChoreographerData"))
{
EditorGui.setEditor( ParticleEditorPlugin );
ParticleEditorPlugin::createNewDatablockOfType(%class, %inheritFrom);
return;
}
$DATABLOCK_EDITOR_NEWDB_CLASS = %class;
$DATABLOCK_EDITOR_NEWDB_INHERITFROM = %inheritFrom;

View file

@ -51,8 +51,6 @@ function ParticleEditor::initEditor( %this )
if(exec("./PETabTemplate.gui"))
{
echo("MADE A NEW TAB PAGE: " @ $guiContent);
$guiContent.text = %groupName;
$guiContent.typesList = %typesList;
$guiContent.setName(%editorName);
@ -199,7 +197,7 @@ function ParticleEditor::open(%this, %datablock)
for(%t=0; %t < %typesListCount; %t++)
{
%type = getWord(%typesList, %t);
if( %datablock.isMemberOfClass( %type ) )
{
PE_TabBook.selectPage(%i);

View file

@ -113,6 +113,19 @@ function ParticleEditorPlugin::onActivated( %this )
EditorGuiStatusBar.setInfo( "Particle editor." );
EditorGuiStatusBar.setSelection( "" );
// Try to start with the object selected in the world editor
%count = EWorldEditor.getSelectionSize();
for (%i = 0; %i < %count; %i++)
{
%obj = EWorldEditor.getSelectedObject(%i);
%datablock = ParticleEditor.getObjectParticleData(%obj);
if (%datablock !$= "" && isObject(%datablock))
{
ParticleEditor.open(%datablock);
break;
}
}
Parent::onActivated( %this );
}
@ -213,3 +226,12 @@ function ParticleEditor::registerParticleEdType(%this, %groupName, %typesList, %
PE_ParticleDataTypes.add(%groupName, %typesList TAB %editorName);
}
//------------------------------------------------------------------------------
function ParticleEditor::getObjectParticleData( %this, %obj )
{
%datablock = "";
if ( %obj.isMemberOfClass( "ParticleEmitterNode" ) )
%datablock = %obj.emitter;
return %datablock;
}

View file

@ -122,7 +122,6 @@ function PE_EmitterEditor::selectObject(%this, %obj)
&& %obj.getName() $= %this-->popupMenu.text )
return;
//FIXME: disregards particle tab dirty state
if( %this.dirty )
{
if( PE_ParticleEditor.dirty )
@ -483,6 +482,8 @@ function ParticleEditor::addParticleSlot(%this, %field, %emitterObj)
%action.oldValue = %emitterObj.particles;
ParticleEditor.submitUndo( %action );
%field.apply(%action.newValue);
}
function ParticleEditor::changeParticleSlot(%this, %field, %emitterObj, %slotIdx)
@ -495,7 +496,6 @@ function ParticleEditor::changeParticleSlot(%this, %field, %emitterObj, %slotIdx
foreach( %obj in DatablockGroup )
{
echo(%typesList);
%typesListCount = getWordCount(%typesList);
for(%i=0; %i < %typesListCount; %i++)
{
@ -552,7 +552,7 @@ function ParticleEditor::changeParticleSlot(%this, %field, %emitterObj, %slotIdx
}
}
ContextedDropdownListGui.show(%listSet, "Edit Particle Slot[" @ %slotIdx @ "]", "ParticleEditor.editSlot = " @ %slotIdx @ ";ParticleEditor.updateParticleSlot", %field);
ContextedDropdownListGui.show(%listSet, "Edit Particle Slot[" @ %slotIdx @ "]", "ParticleEditor.fieldObj = " @ %field @ ";ParticleEditor.editSlot = " @ %slotIdx @ ";ParticleEditor.updateParticleSlot", %field);
%particleData = getWord(%emitterObj.particles, %slotIdx);
if(%particleData !$= "")
{
@ -562,10 +562,10 @@ function ParticleEditor::changeParticleSlot(%this, %field, %emitterObj, %slotIdx
function ParticleEditor::updateParticleSlot(%this, %newParticle)
{
if(ParticleEditor.editSlot $= "")
if(ParticleEditor.editSlot $= "" || !isObject(%newParticle))
return;
%updatedParticlesList = setWord(PE_EmitterEditor.currEmitter.particles, ParticleEditor.editSlot, %newParticle);
%updatedParticlesList = setWord(PE_EmitterEditor.currEmitter.particles, ParticleEditor.editSlot, %newParticle.getName());
%action = ParticleEditor.createUndo(ActionUpdateActiveEmitter, "Edit Active Emitter Particle Slot");
%action.emitter = PE_EmitterEditor.currEmitter;
@ -575,16 +575,19 @@ function ParticleEditor::updateParticleSlot(%this, %newParticle)
ParticleEditor.submitUndo( %action );
ParticleEditor.editSlot = "";
ParticleEditor.fieldObj.apply(%action.newValue);
//%field.apply(%updatedParticlesList, %slotIdx);
//%this-->inspector.refresh();
ParticleEditor.editSlot = "";
ParticleEditor.fieldObj = "";
}
function ParticleEditor::editParticleSlot(%this, %field, %emitterObj, %slotIdx)
{
%particleName = getWord(%emitterObj.particles, %slotIdx);
ParticleEditor.editSlot = "";
ParticleEditor.fieldObj = "";
ParticleEditor.open(%particleName);
}
@ -600,6 +603,5 @@ function ParticleEditor::clearParticleSlot(%this, %field, %emitterObj, %slotIdx)
ParticleEditor.submitUndo( %action );
//%field.apply(%updatedParticlesList, %slotIdx);
//%this-->inspector.refresh();
%field.apply(%action.newValue);
}

View file

@ -74,7 +74,8 @@ function PE_ParticleEditor::updateVizNode(%this)
function PE_ParticleEditor::selectObject(%this, %obj)
{
// Bail if the user selected the same particle.
if( %obj == %this.currParticle )
if( isObject(%obj )
&& %obj.getName() $= %this-->popupMenu.text )
return;
// Load new particle if we're not in a dirty state