mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Full Template for ticket #1
This commit is contained in:
parent
74f265b3b3
commit
f439dc8dcd
2150 changed files with 286240 additions and 0 deletions
3060
Templates/Full/game/tools/particleEditor/ParticleEditor.ed.gui
Normal file
3060
Templates/Full/game/tools/particleEditor/ParticleEditor.ed.gui
Normal file
File diff suppressed because it is too large
Load diff
BIN
Templates/Full/game/tools/particleEditor/images/play_btn_d.png
Normal file
BIN
Templates/Full/game/tools/particleEditor/images/play_btn_d.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 450 B |
BIN
Templates/Full/game/tools/particleEditor/images/play_btn_h.png
Normal file
BIN
Templates/Full/game/tools/particleEditor/images/play_btn_h.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 492 B |
BIN
Templates/Full/game/tools/particleEditor/images/play_btn_n.png
Normal file
BIN
Templates/Full/game/tools/particleEditor/images/play_btn_n.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 401 B |
178
Templates/Full/game/tools/particleEditor/main.cs
Normal file
178
Templates/Full/game/tools/particleEditor/main.cs
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Initialization and shutdown code for particle editor plugin.
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function initializeParticleEditor()
|
||||
{
|
||||
echo( " % - Initializing Particle Editor" );
|
||||
|
||||
exec( "./ParticleEditor.ed.gui" );
|
||||
exec( "./particleEditor.ed.cs" );
|
||||
exec( "./particleEditorUndo.ed.cs" );
|
||||
exec( "./particleEmitterEditor.ed.cs" );
|
||||
exec( "./particleParticleEditor.ed.cs" );
|
||||
|
||||
PE_Window.setVisible( false );
|
||||
EditorGui.add( PE_Window );
|
||||
|
||||
new ScriptObject( ParticleEditorPlugin )
|
||||
{
|
||||
superClass = "WorldEditorPlugin";
|
||||
editorGui = EWorldEditor;
|
||||
};
|
||||
|
||||
%map = new ActionMap();
|
||||
%map.bindCmd( keyboard, "1", "EWorldEditorNoneModeBtn.performClick();", "" ); // Select
|
||||
%map.bindCmd( keyboard, "2", "EWorldEditorMoveModeBtn.performClick();", "" ); // Move
|
||||
%map.bindCmd( keyboard, "3", "EWorldEditorRotateModeBtn.performClick();", "" ); // Rotate
|
||||
%map.bindCmd( keyboard, "4", "EWorldEditorScaleModeBtn.performClick();", "" ); // Scale
|
||||
|
||||
ParticleEditorPlugin.map = %map;
|
||||
|
||||
new ScriptObject( ParticleEditor );
|
||||
|
||||
new PersistenceManager( PE_EmitterSaver );
|
||||
new PersistenceManager( PE_ParticleSaver );
|
||||
|
||||
new SimSet( PE_UnlistedParticles );
|
||||
new SimSet( PE_UnlistedEmitters );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function destroyParticleEditor()
|
||||
{
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ParticleEditorPlugin.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditorPlugin::onWorldEditorStartup( %this )
|
||||
{
|
||||
// Add ourselves to the window menu.
|
||||
%accel = EditorGui.addToEditorsMenu( "Particle Editor", "", ParticleEditorPlugin );
|
||||
|
||||
// Add ourselves to the ToolsToolbar
|
||||
%tooltip = "Particle Editor (" @ %accel @ ")";
|
||||
EditorGui.addToToolsToolbar( "ParticleEditorPlugin", "ParticleEditorPalette", expandFilename("tools/worldEditor/images/toolbar/particleeditor"), %tooltip );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditorPlugin::onActivated( %this )
|
||||
{
|
||||
if( !ParticleEditor.isInitialized )
|
||||
{
|
||||
ParticleEditor.initEditor();
|
||||
ParticleEditor.isInitialized = true;
|
||||
}
|
||||
|
||||
EditorGui-->WorldEditorToolbar.setVisible( true );
|
||||
EditorGui.bringToFront( PE_Window);
|
||||
PE_Window.setVisible( true );
|
||||
PE_Window.makeFirstResponder( true );
|
||||
|
||||
%this.map.push();
|
||||
|
||||
ParticleEditor.resetEmitterNode();
|
||||
|
||||
// Set the status bar here
|
||||
EditorGuiStatusBar.setInfo( "Particle editor." );
|
||||
EditorGuiStatusBar.setSelection( "" );
|
||||
|
||||
Parent::onActivated( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditorPlugin::onDeactivated( %this )
|
||||
{
|
||||
EditorGui-->WorldEditorToolbar.setVisible( false );
|
||||
PE_Window.setVisible( false );
|
||||
|
||||
if( isObject( $ParticleEditor::emitterNode) )
|
||||
$ParticleEditor::emitterNode.delete();
|
||||
|
||||
%this.map.pop();
|
||||
|
||||
Parent::onDeactivated( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditorPlugin::onExitMission( %this )
|
||||
{
|
||||
// Force Particle Editor to re-initialize.
|
||||
ParticleEditor.isInitialized = false;
|
||||
|
||||
Parent::onExitMission( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditorPlugin::initSettings( %this )
|
||||
{
|
||||
EditorSettings.beginGroup( "ParticleEditor", true );
|
||||
|
||||
EditorSettings.setDefaultValue( "selectedTab", 0 );
|
||||
|
||||
EditorSettings.endGroup();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditorPlugin::readSettings( %this )
|
||||
{
|
||||
EditorSettings.beginGroup( "ParticleEditor", true );
|
||||
|
||||
%selectedEmitter = EditorSettings.value( "selectedEmitter" );
|
||||
if( isObject( %selectedEmitter ) )
|
||||
PEE_EmitterSelector.setSelected( %selectedEmitter.getId() );
|
||||
|
||||
%selectedParticle = EditorSettings.value( "selectedParticle" );
|
||||
if( isObject( %selectedParticle ) )
|
||||
PEP_ParticleSelector.setSelected( %selectedParticle.getId() );
|
||||
|
||||
PE_TabBook.selectPage( EditorSettings.value( "selectedPage" ) );
|
||||
|
||||
EditorSettings.endGroup();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditorPlugin::writeSettings( %this )
|
||||
{
|
||||
EditorSettings.beginGroup( "ParticleEditor", true );
|
||||
|
||||
EditorSettings.setValue( "selectedEmitter", PEE_EmitterSelector.getText() );
|
||||
EditorSettings.setValue( "selectedParticle", PEP_ParticleSelector.getText() );
|
||||
EditorSettings.setValue( "selectedTab", PE_TabBook.getSelectedPage() );
|
||||
|
||||
EditorSettings.endGroup();
|
||||
}
|
||||
255
Templates/Full/game/tools/particleEditor/particleEditor.ed.cs
Normal file
255
Templates/Full/game/tools/particleEditor/particleEditor.ed.cs
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Open the particle editor to spawn a test emitter in front of the player.
|
||||
// Edit the sliders, check boxes, and text fields and see the results in
|
||||
// realtime. Switch between emitters and particles with the buttons in the
|
||||
// top left corner. When in particle mode, the only particles available will
|
||||
// be those assigned to the current emitter to avoid confusion. In the top
|
||||
// right corner, there is a button marked "Drop Emitter", which will spawn the
|
||||
// test emitter in front of the player again, and a button marked "Restart
|
||||
// Emitter", which will play the particle animation again.
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// ParticleEditor.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditor::initEditor( %this )
|
||||
{
|
||||
echo( "Initializing ParticleEmitterData and ParticleData DataBlocks..." );
|
||||
|
||||
datablock ParticleEmitterData(PE_EmitterEditor_NotDirtyEmitter)
|
||||
{
|
||||
particles = "RocketProjSmokeTrail";
|
||||
};
|
||||
datablock ParticleData(PE_ParticleEditor_NotDirtyParticle)
|
||||
{
|
||||
textureName = "art/shapes/particles/smoke";
|
||||
};
|
||||
|
||||
PE_UnlistedEmitters.add( PE_EmitterEditor_NotDirtyEmitter );
|
||||
PE_UnlistedEmitters.add( PE_ParticleEditor_NotDirtyParticle );
|
||||
|
||||
PEE_EmitterSelector.clear();
|
||||
PEE_EmitterParticleSelector1.clear();
|
||||
PEE_EmitterParticleSelector2.clear();
|
||||
PEE_EmitterParticleSelector3.clear();
|
||||
PEE_EmitterParticleSelector4.clear();
|
||||
|
||||
PEP_ParticleSelector.clear();
|
||||
|
||||
ParticleEditor.createParticleList();
|
||||
|
||||
PEE_EmitterParticleSelector2.add( "None", 0 );
|
||||
PEE_EmitterParticleSelector3.add( "None", 0 );
|
||||
PEE_EmitterParticleSelector4.add( "None", 0 );
|
||||
|
||||
PEE_EmitterParticleSelector1.sort();
|
||||
PEE_EmitterParticleSelector2.sort();
|
||||
PEE_EmitterParticleSelector3.sort();
|
||||
PEE_EmitterParticleSelector4.sort();
|
||||
|
||||
PE_EmitterEditor-->PEE_blendType.clear();
|
||||
PE_EmitterEditor-->PEE_blendType.add( "NORMAL", 0 );
|
||||
PE_EmitterEditor-->PEE_blendType.add( "ADDITIVE", 1 );
|
||||
PE_EmitterEditor-->PEE_blendType.add( "SUBTRACTIVE", 2 );
|
||||
PE_EmitterEditor-->PEE_blendType.add( "PREMULTALPHA", 3 );
|
||||
|
||||
|
||||
PEE_EmitterSelector.setFirstSelected();
|
||||
|
||||
PE_Window-->EditorTabBook.selectPage( 0 );
|
||||
}
|
||||
|
||||
function ParticleEditor::createParticleList( %this )
|
||||
{
|
||||
// This function creates the list of all particles and particle emitters
|
||||
|
||||
%emitterCount = 0;
|
||||
%particleCount = 0;
|
||||
|
||||
foreach( %obj in DatablockGroup )
|
||||
{
|
||||
if( %obj.isMemberOfClass( "ParticleEmitterData" ) )
|
||||
{
|
||||
// Filter out emitters on the PE_UnlistedEmitters list.
|
||||
|
||||
%unlistedFound = false;
|
||||
foreach( %unlisted in PE_UnlistedEmitters )
|
||||
if( %unlisted.getId() == %obj.getId() )
|
||||
{
|
||||
%unlistedFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if( %unlistedFound )
|
||||
continue;
|
||||
|
||||
// To prevent our default emitters from getting changed,
|
||||
// prevent them from populating the list. Default emitters
|
||||
// should only be used as a template for creating new ones.
|
||||
if ( %obj.getName() $= "DefaultEmitter")
|
||||
continue;
|
||||
|
||||
PEE_EmitterSelector.add( %obj.getName(), %obj.getId() );
|
||||
%emitterCount ++;
|
||||
}
|
||||
else if( %obj.isMemberOfClass( "ParticleData" ) )
|
||||
{
|
||||
%unlistedFound = false;
|
||||
foreach( %unlisted in PE_UnlistedParticles )
|
||||
if( %unlisted.getId() == %obj.getId() )
|
||||
{
|
||||
%unlistedFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if( %unlistedFound )
|
||||
continue;
|
||||
|
||||
%name = %obj.getName();
|
||||
%id = %obj.getId();
|
||||
|
||||
if ( %name $= "DefaultParticle")
|
||||
continue;
|
||||
|
||||
// Add to particle dropdown selectors.
|
||||
|
||||
PEE_EmitterParticleSelector1.add( %name, %id );
|
||||
PEE_EmitterParticleSelector2.add( %name, %id );
|
||||
PEE_EmitterParticleSelector3.add( %name, %id );
|
||||
PEE_EmitterParticleSelector4.add( %name, %id );
|
||||
|
||||
%particleCount ++;
|
||||
}
|
||||
}
|
||||
|
||||
PEE_EmitterSelector.sort();
|
||||
PEE_EmitterParticleSelector1.sort();
|
||||
PEE_EmitterParticleSelector2.sort();
|
||||
PEE_EmitterParticleSelector3.sort();
|
||||
PEE_EmitterParticleSelector4.sort();
|
||||
|
||||
echo( "Found" SPC %emitterCount SPC "emitters and" SPC %particleCount SPC "particles." );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditor::openEmitterPane( %this )
|
||||
{
|
||||
PE_Window.text = "Particle Editor - Emitters";
|
||||
PE_EmitterEditor.guiSync();
|
||||
ParticleEditor.activeEditor = PE_EmitterEditor;
|
||||
|
||||
if( !PE_EmitterEditor.dirty )
|
||||
PE_EmitterEditor.setEmitterNotDirty();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditor::openParticlePane( %this )
|
||||
{
|
||||
PE_Window.text = "Particle Editor - Particles";
|
||||
|
||||
PE_ParticleEditor.guiSync();
|
||||
ParticleEditor.activeEditor = PE_ParticleEditor;
|
||||
|
||||
if( !PE_ParticleEditor.dirty )
|
||||
PE_ParticleEditor.setParticleNotDirty();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditor::resetEmitterNode( %this )
|
||||
{
|
||||
%tform = ServerConnection.getControlObject().getEyeTransform();
|
||||
%vec = VectorNormalize( ServerConnection.getControlObject().getForwardVector() );
|
||||
%vec = VectorScale( %vec, 4 );
|
||||
%tform = setWord( %tform, 0, getWord( %tform, 0 ) + getWord( %vec, 0 ) );
|
||||
%tform = setWord( %tform, 1, getWord( %tform, 1 ) + getWord( %vec, 1 ) );
|
||||
%tform = setWord( %tform, 2, getWord( %tform, 2 ) + getWord( %vec, 2 ) );
|
||||
|
||||
if( !isObject( $ParticleEditor::emitterNode ) )
|
||||
{
|
||||
if( !isObject( TestEmitterNodeData ) )
|
||||
{
|
||||
datablock ParticleEmitterNodeData( TestEmitterNodeData )
|
||||
{
|
||||
timeMultiple = 1;
|
||||
};
|
||||
}
|
||||
|
||||
$ParticleEditor::emitterNode = new ParticleEmitterNode()
|
||||
{
|
||||
emitter = PEE_EmitterSelector.getText();
|
||||
velocity = 1;
|
||||
position = getWords( %tform, 0, 2 );
|
||||
rotation = getWords( %tform, 3, 6 );
|
||||
datablock = TestEmitterNodeData;
|
||||
parentGroup = MissionCleanup;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
$ParticleEditor::emitterNode.setTransform( %tform );
|
||||
|
||||
%clientObject = $ParticleEditor::emitterNode.getClientObject();
|
||||
if( isObject( %clientObject ) )
|
||||
%clientObject.setTransform( %tform );
|
||||
|
||||
ParticleEditor.updateEmitterNode();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditor::updateEmitterNode( %this )
|
||||
{
|
||||
if( isObject( $ParticleEditor::emitterNode ) )
|
||||
{
|
||||
%id = PEE_EmitterSelector_Control-->PopUpMenu.getSelected();
|
||||
|
||||
%clientObject = $ParticleEditor::emitterNode.getClientObject();
|
||||
if( isObject( %clientObject ) )
|
||||
%clientObject.setEmitterDataBlock( %id );
|
||||
}
|
||||
else
|
||||
%this.resetEmitterNode();
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// PE_TabBook.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_TabBook::onTabSelected( %this, %text, %idx )
|
||||
{
|
||||
if( %idx == 0 )
|
||||
ParticleEditor.openEmitterPane();
|
||||
else
|
||||
ParticleEditor.openParticlePane();
|
||||
}
|
||||
|
|
@ -0,0 +1,606 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// ParticleEditor.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditor::createUndo( %this, %class, %desc )
|
||||
{
|
||||
pushInstantGroup();
|
||||
%action = new UndoScriptAction()
|
||||
{
|
||||
class = %class;
|
||||
superClass = BaseParticleEdAction;
|
||||
actionName = %desc;
|
||||
};
|
||||
popInstantGroup();
|
||||
return %action;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ParticleEditor::submitUndo( %this, %action )
|
||||
{
|
||||
%action.addToManager( Editor.getUndoManager() );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// BaseParticleEdAction.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function BaseParticleEdAction::sync( %this )
|
||||
{
|
||||
// Sync particle state.
|
||||
|
||||
if( isObject( %this.particle ) )
|
||||
{
|
||||
%this.particle.reload();
|
||||
PE_ParticleEditor.guiSync();
|
||||
|
||||
if( %this.particle.getId() == PE_ParticleEditor.currParticle.getId() )
|
||||
PE_ParticleEditor.setParticleDirty();
|
||||
}
|
||||
|
||||
// Sync emitter state.
|
||||
|
||||
if( isObject( %this.emitter ) )
|
||||
{
|
||||
%this.emitter.reload();
|
||||
|
||||
PE_EmitterEditor.guiSync();
|
||||
|
||||
if( %this.emitter.getId() == PE_EmitterEditor.currEmitter.getId() )
|
||||
PE_EmitterEditor.setEmitterDirty();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function BaseParticleEdAction::redo( %this )
|
||||
{
|
||||
%this.sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function BaseParticleEdAction::undo( %this )
|
||||
{
|
||||
%this.sync();
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionRenameEmitter.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
//TODO
|
||||
|
||||
//=============================================================================================
|
||||
// ActionCreateNewEmitter.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionCreateNewEmitter::redo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
// Assign name.
|
||||
|
||||
%emitter.name = %this.emitterName;
|
||||
|
||||
// Remove from unlisted.
|
||||
|
||||
PE_UnlistedEmitters.remove( %emitter );
|
||||
|
||||
// Drop it in the dropdown and select it.
|
||||
|
||||
%popup = PEE_EmitterSelector;
|
||||
|
||||
%popup.add( %emitter.getName(), %emitter.getId() );
|
||||
%popup.sort();
|
||||
%popup.setSelected( %emitter.getId() );
|
||||
|
||||
// Sync up.
|
||||
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionCreateNewEmitter::undo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
// Prevent a save dialog coming up on the emitter.
|
||||
|
||||
if( %emitter == PE_EmitterEditor.currEmitter )
|
||||
PE_EmitterEditor.setEmitterNotDirty();
|
||||
|
||||
// Add to unlisted.
|
||||
|
||||
PE_UnlistedEmitters.add( %emitter );
|
||||
|
||||
// Remove it from in the dropdown and select prev emitter.
|
||||
|
||||
%popup = PEE_EmitterSelector;
|
||||
|
||||
if( isObject( %this.prevEmitter ) )
|
||||
%popup.setSelected( %this.prevEmitter.getId() );
|
||||
else
|
||||
%popup.setFirstSelected();
|
||||
|
||||
%popup.clearEntry( %emitter.getId() );
|
||||
|
||||
// Unassign name.
|
||||
|
||||
%this.emitterName = %emitter.name;
|
||||
%emitter.name = "";
|
||||
|
||||
// Sync up.
|
||||
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionDeleteEmitter.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionDeleteEmitter::redo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
// Unassign name.
|
||||
|
||||
%this.emitterName = %emitter.name;
|
||||
%emitter.name = "";
|
||||
|
||||
// Add to unlisted.
|
||||
|
||||
PE_UnlistedEmitters.add( %emitter );
|
||||
|
||||
// Remove from file.
|
||||
|
||||
if( %emitter.getFileName() !$= ""
|
||||
&& %emitter.getFilename() !$= "tools/particleEditor/particleEmitterEditor.ed.cs" )
|
||||
PE_EmitterSaver.removeObjectFromFile( %emitter );
|
||||
|
||||
// Select DefaultEmitter or first in list.
|
||||
|
||||
%popup = PEE_EmitterSelector_Control-->PopUpMenu;
|
||||
|
||||
%popup.setFirstSelected();
|
||||
|
||||
// Remove from dropdown.
|
||||
|
||||
%popup.clearEntry( %emitter );
|
||||
|
||||
// Sync up.
|
||||
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionDeleteEmitter::undo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
// Re-assign name.
|
||||
|
||||
%emitter.name = %this.emitterName;
|
||||
|
||||
// Remove from unlisted.
|
||||
|
||||
PE_UnlistedEmitters.remove( %emitter );
|
||||
|
||||
// Resave to file.
|
||||
|
||||
if( %this.emitterFname !$= ""
|
||||
&& %this.emitterFname !$= "tools/particleEditor/particleEmitterEditor.ed.gui" )
|
||||
{
|
||||
PE_EmitterSaver.setDirty( %emitter, %this.emitterFname );
|
||||
PE_EmitterSaver.saveDirty();
|
||||
}
|
||||
|
||||
// Add it to the dropdown and selet it.
|
||||
|
||||
%popup = PEE_EmitterSelector_Control-->PopUpMenu;
|
||||
%popup.add( %emitter.getName(), %emitter.getId() );
|
||||
%popup.sort();
|
||||
%popup.setSelected( %emitter.getId() );
|
||||
|
||||
// Sync up.
|
||||
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionUpdateActiveEmitter.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveEmitter::redo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
%emitter.setFieldValue( %this.field, %this.newValue );
|
||||
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveEmitter::undo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
%emitter.setFieldValue( %this.field, %this.oldValue );
|
||||
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionUpdateActiveEmitterLifeFields.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveEmitterLifeFields::redo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
%emitter.lifetimeMS = %this.newValueLifetimeMS;
|
||||
%emitter.lifetimeVarianceMS = %this.newValueLifetimeVarianceMS;
|
||||
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveEmitterLifeFields::undo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
%emitter.lifetimeMS = %this.oldValueLifetimeMS;
|
||||
%emitter.lifetimeVarianceMS = %this.oldValueLifetimeVarianceMS;
|
||||
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionUpdateActiveEmitterAmountFields.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveEmitterAmountFields::redo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
%emitter.ejectionPeriodMS = %this.newValueEjectionPeriodMS;
|
||||
%emitter.periodVarianceMS = %this.newValuePeriodVarianceMS;
|
||||
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveEmitterAmountFields::undo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
%emitter.ejectionPeriodMS = %this.oldValueEjectionPeriodMS;
|
||||
%emitter.periodVarianceMS = %this.oldValuePeriodVarianceMS;
|
||||
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionUpdateActiveEmitterSpeedFields.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveEmitterSpeedFields::redo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
%emitter.ejectionVelocity = %this.newValueEjectionVelocity;
|
||||
%emitter.velocityVariance = %this.newValueVelocityVariance;
|
||||
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveEmitterSpeedFields::undo( %this )
|
||||
{
|
||||
%emitter = %this.emitter;
|
||||
|
||||
%emitter.ejectionVelocity = %this.oldValueEjectionVelocity;
|
||||
%emitter.velocityVariance = %this.oldValueVelocityVariance;
|
||||
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionCreateNewParticle.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionCreateNewParticle::redo( %this )
|
||||
{
|
||||
%particle = %this.particle.getName();
|
||||
%particleId = %this.particle.getId();
|
||||
%particleIndex = %this.particleIndex;
|
||||
%emitter = %this.emitter;
|
||||
|
||||
// Remove from unlisted.
|
||||
|
||||
PE_UnlistedParticles.remove( %particleId );
|
||||
|
||||
// Add it to the dropdown.
|
||||
|
||||
PEP_ParticleSelector.add( %particle, %particleId );
|
||||
PEP_ParticleSelector.sort();
|
||||
PEP_ParticleSelector.setSelected( %particleId, false );
|
||||
|
||||
// Add particle to dropdowns in the emitter editor.
|
||||
|
||||
for( %i = 1; %i < 5; %i ++ )
|
||||
{
|
||||
%emitterParticle = "PEE_EmitterParticle" @ %i;
|
||||
%popup = %emitterParticle-->PopupMenu;
|
||||
|
||||
%popup.add( %particle, %particleId );
|
||||
%popup.sort();
|
||||
|
||||
if( %i == %particleIndex + 1 )
|
||||
%popup.setSelected( %particleId );
|
||||
}
|
||||
|
||||
// Sync up.
|
||||
|
||||
PE_ParticleEditor.loadNewParticle();
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionCreateNewParticle::undo( %this )
|
||||
{
|
||||
%particle = %this.particle.getName();
|
||||
%particleId = %this.particle.getId();
|
||||
%emitter = %this.emitter;
|
||||
|
||||
// Add to unlisted.
|
||||
|
||||
PE_UnlistedParticles.add( %particleId );
|
||||
|
||||
// Remove from dropdown.
|
||||
|
||||
PEP_ParticleSelector.clearEntry( %particleId );
|
||||
PEP_ParticleSelector.setFirstSelected( false );
|
||||
|
||||
// Remove from particle dropdowns in emitter editor.
|
||||
|
||||
for( %i = 1; %i < 5; %i ++ )
|
||||
{
|
||||
%emitterParticle = "PEE_EmitterParticle" @ %i;
|
||||
%popup = %emitterParticle-->PopUpMenu;
|
||||
|
||||
if( %popup.getSelected() == %particleId )
|
||||
%popup.setSelected( %this.prevParticle );
|
||||
|
||||
%popup.clearEntry( %particleId );
|
||||
}
|
||||
|
||||
// Sync up.
|
||||
|
||||
PE_ParticleEditor.loadNewParticle();
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionDeleteParticle.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionDeleteParticle::redo( %this )
|
||||
{
|
||||
%particle = %this.particle.getName();
|
||||
%particleId = %this.particle.getId();
|
||||
%emitter = %this.emitter;
|
||||
|
||||
// Add to unlisted.
|
||||
|
||||
PE_UnlistedParticles.add( %particleId );
|
||||
|
||||
// Remove from file.
|
||||
|
||||
if( %particle.getFileName() !$= ""
|
||||
&& %particle.getFilename() !$= "tools/particleEditor/particleParticleEditor.ed.cs" )
|
||||
PE_ParticleSaver.removeObjectFromFile( %particleId );
|
||||
|
||||
// Remove from dropdown.
|
||||
|
||||
PEP_ParticleSelector.clearEntry( %particleId );
|
||||
PEP_ParticleSelector.setFirstSelected();
|
||||
|
||||
// Remove from particle selectors in emitter.
|
||||
|
||||
for( %i = 1; %i < 5; %i ++ )
|
||||
{
|
||||
%emitterParticle = "PEE_EmitterParticle" @ %i;
|
||||
%popup = %emitterParticle-->PopUpMenu;
|
||||
|
||||
if( %popup.getSelected() == %particleId )
|
||||
{
|
||||
%this.particleIndex = %i - 1;
|
||||
%popup.setSelected( 0 ); // Select "None".
|
||||
}
|
||||
|
||||
%popup.clearEntry( %particleId );
|
||||
}
|
||||
|
||||
// Sync up.
|
||||
|
||||
PE_ParticleEditor.loadNewParticle();
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionDeleteParticle::undo( %this )
|
||||
{
|
||||
%particle = %this.particle.getName();
|
||||
%particleId = %this.particle.getId();
|
||||
%particleIndex = %this.particleIndex;
|
||||
%emitter = %this.emitter;
|
||||
|
||||
// Remove from unlisted.
|
||||
|
||||
PE_UnlistedParticles.remove( %particleId );
|
||||
|
||||
// Resave to file.
|
||||
|
||||
if( %particle.getFilename() !$= ""
|
||||
&& %particle.getFilename() !$= "tools/particleEditor/particleParticleEditor.ed.gui" )
|
||||
{
|
||||
PE_ParticleSaver.setDirty( %particle );
|
||||
PE_ParticleSaver.saveDirty();
|
||||
}
|
||||
|
||||
// Add to dropdown.
|
||||
|
||||
PEP_ParticleSelector.add( %particle, %particleId );
|
||||
PEP_ParticleSelector.sort();
|
||||
PEP_ParticleSelector.setSelected( %particleId );
|
||||
|
||||
// Add particle to dropdowns in the emitter editor.
|
||||
|
||||
for( %i = 1; %i < 5; %i ++ )
|
||||
{
|
||||
%emitterParticle = "PEE_EmitterParticle" @ %i;
|
||||
%popup = %emitterParticle-->PopUpMenu;
|
||||
|
||||
%popup.add( %particle, %particleId );
|
||||
%popup.sort();
|
||||
|
||||
if( %i == %particleIndex + 1 )
|
||||
%popup.setSelected( %particleId );
|
||||
}
|
||||
|
||||
// Sync up.
|
||||
|
||||
PE_ParticleEditor.loadNewParticle();
|
||||
Parent::undo( %This );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionUpdateActiveParticle.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveParticle::redo( %this )
|
||||
{
|
||||
%particle = %this.particle;
|
||||
%particle.setFieldValue( %this.field, %this.newValue );
|
||||
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
function ActionUpdateActiveParticle::undo( %this )
|
||||
{
|
||||
%particle = %this.particle;
|
||||
%particle.setFieldValue( %this.field, %this.oldValue );
|
||||
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionUpdateActiveParticleLifeFields.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveParticleLifeFields::redo( %this )
|
||||
{
|
||||
%particle = %this.particle;
|
||||
|
||||
%particle.lifetimeMS = %this.newValueLifetimeMS;
|
||||
%particle.lifetimeVarianceMS = %this.newValueLifetimeVarianceMS;
|
||||
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveParticleLifeFields::undo( %this )
|
||||
{
|
||||
%particle = %this.particle;
|
||||
|
||||
%particle.lifetimeMS = %this.oldValueLifetimeMS;
|
||||
%particle.lifetimeVarianceMS = %this.oldValueLifetimeVarianceMS;
|
||||
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// ActionUpdateActiveParticleSpinFields.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveParticleSpinFields::redo( %this )
|
||||
{
|
||||
%particle = %this.particle;
|
||||
|
||||
%particle.spinRandomMax = %this.newValueSpinRandomMax;
|
||||
%particle.spinRandomMin = %this.newValueSpinRandomMin;
|
||||
|
||||
Parent::redo( %this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function ActionUpdateActiveParticleSpinFields::undo( %this )
|
||||
{
|
||||
%particle = %this.particle;
|
||||
|
||||
%particle.spinRandomMax = %this.oldValueSpinRandomMax;
|
||||
%particle.spinRandomMin = %this.oldValueSpinRandomMin;
|
||||
|
||||
Parent::undo( %this );
|
||||
}
|
||||
|
|
@ -0,0 +1,654 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
$PE_EMITTEREDITOR_DEFAULT_FILENAME = "art/shapes/particles/managedParticleEmitterData.cs";
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// PE_EmitterEditor.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::guiSync( %this )
|
||||
{
|
||||
%data = PE_EmitterEditor.currEmitter;
|
||||
|
||||
// Sync up sliders and number boxes.
|
||||
|
||||
if( PE_EmitterEditor-->PEE_infiniteLoop.isStateOn() )
|
||||
{
|
||||
PE_EmitterEditor-->PEE_lifetimeMS_slider.setActive( false );
|
||||
PE_EmitterEditor-->PEE_lifetimeMS_textEdit.setActive( false );
|
||||
PE_EmitterEditor-->PEE_lifetimeVarianceMS_slider.setActive( false );
|
||||
PE_EmitterEditor-->PEE_lifetimeVarianceMS_textEdit.setActive( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
PE_EmitterEditor-->PEE_lifetimeMS_slider.setActive( true );
|
||||
PE_EmitterEditor-->PEE_lifetimeMS_textEdit.setActive( true );
|
||||
PE_EmitterEditor-->PEE_lifetimeVarianceMS_slider.setActive( true );
|
||||
PE_EmitterEditor-->PEE_lifetimeVarianceMS_textEdit.setActive( true );
|
||||
|
||||
PE_EmitterEditor-->PEE_lifetimeMS_slider.setValue( %data.lifetimeMS );
|
||||
PE_EmitterEditor-->PEE_lifetimeMS_textEdit.setText( %data.lifetimeMS );
|
||||
PE_EmitterEditor-->PEE_lifetimeVarianceMS_slider.setValue( %data.lifetimeVarianceMS );
|
||||
PE_EmitterEditor-->PEE_lifetimeVarianceMS_textEdit.setText( %data.lifetimeVarianceMS );
|
||||
}
|
||||
|
||||
PE_EmitterEditor-->PEE_ejectionPeriodMS_slider.setValue( %data.ejectionPeriodMS );
|
||||
PE_EmitterEditor-->PEE_ejectionPeriodMS_textEdit.setText( %data.ejectionPeriodMS );
|
||||
|
||||
PE_EmitterEditor-->PEE_periodVarianceMS_slider.setValue( %data.periodVarianceMS );
|
||||
PE_EmitterEditor-->PEE_periodVarianceMS_textEdit.setText( %data.periodVarianceMS );
|
||||
|
||||
PE_EmitterEditor-->PEE_ejectionVelocity_slider.setValue( %data.ejectionVelocity );
|
||||
PE_EmitterEditor-->PEE_ejectionVelocity_textEdit.setText( %data.ejectionVelocity );
|
||||
|
||||
PE_EmitterEditor-->PEE_velocityVariance_slider.setValue( %data.velocityVariance );
|
||||
PE_EmitterEditor-->PEE_velocityVariance_textEdit.setText( %data.velocityVariance );
|
||||
|
||||
PE_EmitterEditor-->PEE_orientParticles.setValue( %data.orientParticles );
|
||||
PE_EmitterEditor-->PEE_alignParticles.setValue( %data.alignParticles );
|
||||
PE_EmitterEditor-->PEE_alignDirection.setText( %data.alignDirection );
|
||||
|
||||
PE_EmitterEditor-->PEE_thetaMin_slider.setValue( %data.thetaMin );
|
||||
PE_EmitterEditor-->PEE_thetaMin_textEdit.setText( %data.thetaMin );
|
||||
|
||||
PE_EmitterEditor-->PEE_thetaMax_slider.setValue( %data.thetaMax );
|
||||
PE_EmitterEditor-->PEE_thetaMax_textEdit.setText( %data.thetaMax );
|
||||
|
||||
PE_EmitterEditor-->PEE_phiVariance_slider.setValue( %data.phiVariance );
|
||||
PE_EmitterEditor-->PEE_phiVariance_textEdit.setText( %data.phiVariance );
|
||||
|
||||
PE_EmitterEditor-->PEE_ejectionOffset_slider.setValue( %data.ejectionOffset );
|
||||
PE_EmitterEditor-->PEE_ejectionOffset_textEdit.setText( %data.ejectionOffset );
|
||||
|
||||
%blendTypeId = PE_EmitterEditor-->PEE_blendType.findText( %data.blendStyle );
|
||||
PE_EmitterEditor-->PEE_blendType.setSelected( %blendTypeId, false );
|
||||
|
||||
PE_EmitterEditor-->PEE_softnessDistance_slider.setValue( %data.softnessDistance );
|
||||
PE_EmitterEditor-->PEE_softnessDistance_textEdit.setText( %data.softnessDistance );
|
||||
|
||||
PE_EmitterEditor-->PEE_ambientFactor_slider.setValue( %data.ambientFactor );
|
||||
PE_EmitterEditor-->PEE_ambientFactor_textEdit.setText( %data.ambientFactor );
|
||||
|
||||
PE_EmitterEditor-->PEE_softParticles.setValue( %data.softParticles );
|
||||
PE_EmitterEditor-->PEE_reverseOrder.setValue( %data.reverseOrder );
|
||||
PE_EmitterEditor-->PEE_useEmitterSizes.setValue( %data.useEmitterSizes );
|
||||
PE_EmitterEditor-->PEE_useEmitterColors.setValue( %data.useEmitterColors );
|
||||
|
||||
// Sync up particle selectors.
|
||||
|
||||
for( %index = 0; %index < 4; %index ++ )
|
||||
{
|
||||
%ctrl = "PEE_EmitterParticle" @ ( %index + 1 );
|
||||
%popup = %ctrl-->PopUpMenu;
|
||||
|
||||
%particle = getWord( %data.particles, %index );
|
||||
if( isObject( %particle ) )
|
||||
%popup.setSelected( %particle.getId(), false );
|
||||
else
|
||||
%popup.setSelected( 0, false ); // Select "None".
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// Generic updateEmitter method
|
||||
function PE_EmitterEditor::updateEmitter( %this, %propertyField, %value, %isSlider, %onMouseUp )
|
||||
{
|
||||
PE_EmitterEditor.setEmitterDirty();
|
||||
|
||||
%emitter = PE_EmitterEditor.currEmitter;
|
||||
|
||||
%last = Editor.getUndoManager().getUndoAction(Editor.getUndoManager().getUndoCount() - 1);
|
||||
if( (%isSlider) && (%last.isSlider) && (!%last.onMouseUp) )
|
||||
{
|
||||
%last.field = %propertyField;
|
||||
%last.isSlider = %isSlider;
|
||||
%last.onMouseUp = %onMouseUp;
|
||||
%last.newValue = %value;
|
||||
}
|
||||
else
|
||||
{
|
||||
%action = ParticleEditor.createUndo(ActionUpdateActiveEmitter, "Update Active Emitter");
|
||||
%action.emitter = %emitter;
|
||||
%action.field = %propertyField;
|
||||
%action.isSlider = %isSlider;
|
||||
%action.onMouseUp = %onMouseUp;
|
||||
%action.newValue = %value;
|
||||
%action.oldValue = %emitter.getFieldValue( %propertyField );
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
}
|
||||
|
||||
%emitter.setFieldValue( %propertyField, %value );
|
||||
%emitter.reload();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// Special case updateEmitter methods
|
||||
function PE_EmitterEditor::updateLifeFields( %this, %isRandom, %value, %isSlider, %onMouseUp )
|
||||
{
|
||||
PE_EmitterEditor.setEmitterDirty();
|
||||
|
||||
%emitter = PE_EmitterEditor.currEmitter;
|
||||
|
||||
// Transfer values over to gui controls.
|
||||
|
||||
if( %isRandom )
|
||||
{
|
||||
if( %value > 0 )
|
||||
%value++;
|
||||
|
||||
if( %value > PE_EmitterEditor-->PEE_lifetimeMS_slider.getValue() )
|
||||
{
|
||||
PE_EmitterEditor-->PEE_lifetimeMS_textEdit.setText( %value );
|
||||
PE_EmitterEditor-->PEE_lifetimeMS_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( %value > 0 )
|
||||
%value --;
|
||||
|
||||
if( %value < PE_EmitterEditor-->PEE_lifetimeVarianceMS_slider.getValue() )
|
||||
{
|
||||
PE_EmitterEditor-->PEE_lifetimeVarianceMS_textEdit.setText( %value );
|
||||
PE_EmitterEditor-->PEE_lifetimeVarianceMS_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
|
||||
// Submit undo.
|
||||
|
||||
%last = Editor.getUndoManager().getUndoAction(Editor.getUndoManager().getUndoCount() - 1);
|
||||
if( (%isSlider) && (%last.isSlider) && (!%last.onMouseUp) )
|
||||
{
|
||||
%last.isSlider = %isSlider;
|
||||
%last.onMouseUp = %onMouseUp;
|
||||
%last.newValueLifetimeMS = PE_EmitterEditor-->PEE_lifetimeMS_textEdit.getText();
|
||||
%last.newValueLifetimeVarianceMS = PE_EmitterEditor-->PEE_lifetimeVarianceMS_textEdit.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
%action = ParticleEditor.createUndo(ActionUpdateActiveEmitterLifeFields, "Update Active Emitter");
|
||||
%action.emitter = %emitter;
|
||||
%action.isSlider = %isSlider;
|
||||
%action.onMouseUp = %onMouseUp;
|
||||
|
||||
%action.newValueLifetimeMS = PE_EmitterEditor-->PEE_lifetimeMS_textEdit.getText();
|
||||
%action.oldValueLifetimeMS = %emitter.lifetimeMS;
|
||||
|
||||
%action.newValueLifetimeVarianceMS = PE_EmitterEditor-->PEE_lifetimeVarianceMS_textEdit.getText();
|
||||
%action.oldValueLifetimeVarianceMS = %emitter.lifetimeVarianceMS;
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
}
|
||||
|
||||
// Set the values on the current emitter.
|
||||
|
||||
%emitter.lifetimeMS = PE_EmitterEditor-->PEE_lifetimeMS_textEdit.getText();
|
||||
%emitter.lifetimeVarianceMS = PE_EmitterEditor-->PEE_lifetimeVarianceMS_textEdit.getText();
|
||||
%emitter.reload();
|
||||
|
||||
// Keep the infiniteLoop checkbox up to date.
|
||||
|
||||
PE_EmitterEditor-->PEE_infiniteLoop.setStateOn(
|
||||
%emitter.lifetimeMS == 0
|
||||
);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::updateLifeFieldsInfiniteLoop( %this )
|
||||
{
|
||||
%emitter = PE_EmitterEditor.currEmitter;
|
||||
%isEnabled = PE_EmitterEditor-->PEE_infiniteLoop.isStateOn();
|
||||
|
||||
// Submit undo.
|
||||
|
||||
%action = ParticleEditor.createUndo( ActionUpdateActiveEmitterLifeFields, "Update Active Emitter" );
|
||||
%action.emitter = %emitter;
|
||||
|
||||
if( %isEnabled )
|
||||
{
|
||||
%action.newValueLifetimeMS = 0;
|
||||
%action.newvalueLifetimeVarianceMS = 0;
|
||||
%action.oldValueLifetimeMS = PE_EmitterEditor-->PEE_lifetimeMS_textEdit.getText();
|
||||
%action.oldValueLifetimeVarianceMS = PE_EmitterEditor-->PEE_lifetimeVarianceMS_textEdit.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
%action.newValueLifetimeMS = PE_EmitterEditor-->PEE_lifetimeMS_textEdit.getText();
|
||||
%action.newvalueLifetimeVarianceMS = PE_EmitterEditor-->PEE_lifetimeVarianceMS_textEdit.getText();
|
||||
%action.oldValueLifetimeMS = 0;
|
||||
%action.oldValueLifetimeVarianceMS = 0;
|
||||
}
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
|
||||
// Execute action.
|
||||
|
||||
%action.redo();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::updateAmountFields( %this, %isRandom, %value, %isSlider, %onMouseUp )
|
||||
{
|
||||
PE_EmitterEditor.setEmitterDirty();
|
||||
%emitter = PE_EmitterEditor.currEmitter;
|
||||
|
||||
// Transfer values over to gui controls.
|
||||
|
||||
if( %isRandom )
|
||||
{
|
||||
%value ++;
|
||||
if( %value > PE_EmitterEditor-->PEE_ejectionPeriodMS_slider.getValue() )
|
||||
{
|
||||
PE_EmitterEditor-->PEE_ejectionPeriodMS_textEdit.setText( %value );
|
||||
PE_EmitterEditor-->PEE_ejectionPeriodMS_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
%value --;
|
||||
if( %value < PE_EmitterEditor-->PEE_periodVarianceMS_slider.getValue() )
|
||||
{
|
||||
PE_EmitterEditor-->PEE_periodVarianceMS_textEdit.setText( %value );
|
||||
PE_EmitterEditor-->PEE_periodVarianceMS_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
|
||||
// Submit undo.
|
||||
|
||||
%last = Editor.getUndoManager().getUndoAction(Editor.getUndoManager().getUndoCount() - 1);
|
||||
if( (%isSlider) && (%last.isSlider) && (!%last.onMouseUp) )
|
||||
{
|
||||
%last.isSlider = %isSlider;
|
||||
%last.onMouseUp = %onMouseUp;
|
||||
%last.newValueEjectionPeriodMS = PE_EmitterEditor-->PEE_ejectionPeriodMS_textEdit.getText();
|
||||
%last.newValuePeriodVarianceMS = PE_EmitterEditor-->PEE_periodVarianceMS_textEdit.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
%action = ParticleEditor.createUndo(ActionUpdateActiveEmitterAmountFields, "Update Active Emitter");
|
||||
%action.emitter = %emitter;
|
||||
%action.isSlider = %isSlider;
|
||||
%action.onMouseUp = %onMouseUp;
|
||||
|
||||
%action.newValueEjectionPeriodMS = PE_EmitterEditor-->PEE_ejectionPeriodMS_textEdit.getText();
|
||||
%action.oldValueEjectionPeriodMS = %emitter.ejectionPeriodMS;
|
||||
|
||||
%action.newValuePeriodVarianceMS = PE_EmitterEditor-->PEE_periodVarianceMS_textEdit.getText();
|
||||
%action.oldValuePeriodVarianceMS = %emitter.periodVarianceMS;
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
}
|
||||
|
||||
// Set the values on the current emitter.
|
||||
|
||||
%emitter.ejectionPeriodMS = PE_EmitterEditor-->PEE_ejectionPeriodMS_textEdit.getText();
|
||||
%emitter.periodVarianceMS = PE_EmitterEditor-->PEE_periodVarianceMS_textEdit.getText();
|
||||
%emitter.reload();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::updateSpeedFields( %this, %isRandom, %value, %isSlider, %onMouseUp )
|
||||
{
|
||||
PE_EmitterEditor.setEmitterDirty();
|
||||
%emitter = PE_EmitterEditor.currEmitter;
|
||||
|
||||
// Transfer values over to gui controls.
|
||||
|
||||
if( %isRandom )
|
||||
{
|
||||
if( %value > PE_EmitterEditor-->PEE_ejectionVelocity_slider.getValue() )
|
||||
{
|
||||
PE_EmitterEditor-->PEE_ejectionVelocity_textEdit.setText( %value );
|
||||
PE_EmitterEditor-->PEE_ejectionVelocity_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( %value < PE_EmitterEditor-->PEE_velocityVariance_slider.getValue() )
|
||||
{
|
||||
PE_EmitterEditor-->PEE_velocityVariance_textEdit.setText( %value );
|
||||
PE_EmitterEditor-->PEE_velocityVariance_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
|
||||
// Submit undo.
|
||||
|
||||
%last = Editor.getUndoManager().getUndoAction(Editor.getUndoManager().getUndoCount() - 1);
|
||||
if( (%isSlider) && (%last.isSlider) && (!%last.onMouseUp) )
|
||||
{
|
||||
%last.isSlider = %isSlider;
|
||||
%last.onMouseUp = %onMouseUp;
|
||||
%last.newValueEjectionVelocity = PE_EmitterEditor-->PEE_ejectionVelocity_textEdit.getText();
|
||||
%last.newValueVelocityVariance = PE_EmitterEditor-->PEE_velocityVariance_textEdit.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
%action = ParticleEditor.createUndo(ActionUpdateActiveEmitterSpeedFields, "Update Active Emitter");
|
||||
%action.emitter = %emitter;
|
||||
%action.isSlider = %isSlider;
|
||||
%action.onMouseUp = %onMouseUp;
|
||||
|
||||
%action.newValueEjectionVelocity = PE_EmitterEditor-->PEE_ejectionVelocity_textEdit.getText();
|
||||
%action.oldValueEjectionVelocity = %emitter.ejectionVelocity;
|
||||
|
||||
%action.newValueVelocityVariance = PE_EmitterEditor-->PEE_velocityVariance_textEdit.getText();
|
||||
%action.oldValueVelocityVariance = %emitter.velocityVariance;
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
}
|
||||
|
||||
// Set the values on the current emitter.
|
||||
|
||||
%emitter.ejectionVelocity = PE_EmitterEditor-->PEE_ejectionVelocity_textEdit.getText();
|
||||
%emitter.velocityVariance = PE_EmitterEditor-->PEE_velocityVariance_textEdit.getText();
|
||||
%emitter.reload();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::updateParticlesFields( %this )
|
||||
{
|
||||
%particles = "";
|
||||
for( %i = 1; %i < 5; %i ++ )
|
||||
{
|
||||
%emitterParticle = "PEE_EmitterParticle" @ %i;
|
||||
%popup = %emitterParticle-->PopUpMenu;
|
||||
%text = %popup.getText();
|
||||
|
||||
if( %text $= "" || %text $= "None" )
|
||||
continue;
|
||||
|
||||
if( %particles $= "" )
|
||||
%particles = %text;
|
||||
else
|
||||
%particles = %particles SPC %text;
|
||||
}
|
||||
|
||||
%changedEditParticle = 1;
|
||||
%currParticle = PE_ParticleEditor.currParticle.getName();
|
||||
|
||||
foreach$( %particleName in %particles )
|
||||
{
|
||||
if( %particleName $= %currParticle )
|
||||
{
|
||||
%changedEditParticle = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// True only if the currently edited particle has not been found and the
|
||||
// ParticleEditor is dirty.
|
||||
|
||||
if( %changedEditParticle && PE_ParticleEditor.dirty )
|
||||
{
|
||||
MessageBoxYesNoCancel("Save Particle Changes?",
|
||||
"Do you wish to save the changes made to the <br>current particle before changing the particle?",
|
||||
"PE_ParticleEditor.saveParticle( " @ PE_ParticleEditor.currParticle.getName() @ " ); PE_EmitterEditor.updateEmitter( \"particles\"," @ %particles @ ");",
|
||||
"PE_ParticleEditor.saveParticleDialogDontSave( " @ PE_ParticleEditor.currParticle.getName() @ " ); PE_EmitterEditor.updateEmitter( \"particles\"," @ %particles @ ");",
|
||||
"PE_EmitterEditor.guiSync();" );
|
||||
}
|
||||
else
|
||||
{
|
||||
PE_EmitterEditor.updateEmitter( "particles", %particles );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::onNewEmitter( %this )
|
||||
{
|
||||
if( isObject( PE_EmitterEditor.currEmitter )
|
||||
&& PE_EmitterEditor.currEmitter $= PEE_EmitterSelector.getSelected() )
|
||||
return;
|
||||
|
||||
//FIXME: disregards particle tab dirty state
|
||||
|
||||
if( PE_EmitterEditor.dirty )
|
||||
{
|
||||
|
||||
if( PE_ParticleEditor.dirty )
|
||||
{
|
||||
MessageBoxYesNo("Save Existing Particle?",
|
||||
"Do you want to save changes to <br><br>" @ PE_ParticleEditor.currParticle.getName(),
|
||||
"PE_ParticleEditor.saveParticle(" @ PE_ParticleEditor.currParticle @ ");"
|
||||
);
|
||||
}
|
||||
|
||||
%savedEmitter = PE_EmitterEditor.currEmitter;
|
||||
MessageBoxYesNoCancel("Save Existing Emitter?",
|
||||
"Do you want to save changes to <br><br>" @ %savedEmitter.getName(),
|
||||
"PE_EmitterEditor.saveEmitter(" @ %savedEmitter@ "); PE_EmitterEditor.loadNewEmitter();",
|
||||
"PE_EmitterEditor.saveEmitterDialogDontSave(" @ %savedEmitter @ "); PE_EmitterEditor.loadNewEmitter();"
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
PE_EmitterEditor.loadNewEmitter();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::loadNewEmitter( %this, %emitter )
|
||||
{
|
||||
if( isObject( %emitter ) )
|
||||
%current = %emitter.getId();
|
||||
else
|
||||
%current = PEE_EmitterSelector.getSelected();
|
||||
|
||||
PE_EmitterEditor.currEmitter = %current;
|
||||
PE_EmitterEditor_NotDirtyEmitter.assignFieldsFrom( %current );
|
||||
PE_EmitterEditor_NotDirtyEmitter.originalName = %current.name;
|
||||
|
||||
PE_EmitterEditor.guiSync();
|
||||
PE_EmitterEditor.setEmitterNotDirty();
|
||||
|
||||
PE_ParticleEditor.loadNewParticle( getWord( %current.particles, 0 ) );
|
||||
|
||||
ParticleEditor.updateEmitterNode();
|
||||
|
||||
PE_EmitterEditor-->PEE_infiniteLoop.setStateOn( %current.lifetimeMS == 0 );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::setEmitterDirty( %this )
|
||||
{
|
||||
PE_EmitterEditor.text = "Emitter *";
|
||||
PE_EmitterEditor.dirty = true;
|
||||
|
||||
%emitter = PE_EmitterEditor.currEmitter;
|
||||
|
||||
if( %emitter.getFilename() $= "" || %emitter.getFilename() $= "tools/particleEditor/particleEmitterEditor.ed.cs" )
|
||||
PE_EmitterSaver.setDirty( %emitter, $PE_EMITTEREDITOR_DEFAULT_FILENAME );
|
||||
else
|
||||
PE_EmitterSaver.setDirty( %emitter );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::setEmitterNotDirty( %this )
|
||||
{
|
||||
PE_EmitterEditor.text = "Emitter";
|
||||
PE_EmitterEditor.dirty = false;
|
||||
|
||||
PE_EmitterSaver.clearAll();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// Create Functionality
|
||||
function PE_EmitterEditor::showNewDialog( %this )
|
||||
{
|
||||
//FIXME: disregards particle tab dirty state
|
||||
|
||||
// Open a dialog if the current emitter is dirty.
|
||||
|
||||
if( PE_ParticleEditor.dirty )
|
||||
{
|
||||
MessageBoxYesNo("Save Existing Particle?",
|
||||
"Do you want to save changes to <br><br>" @ PE_ParticleEditor.currParticle.getName(),
|
||||
"PE_ParticleEditor.saveParticle(" @ PE_ParticleEditor.currParticle @ ");"
|
||||
);
|
||||
}
|
||||
|
||||
if( PE_EmitterEditor.dirty )
|
||||
{
|
||||
MessageBoxYesNoCancel("Save Emitter Changes?",
|
||||
"Do you wish to save the changes made to the <br>current emitter before changing the emitter?",
|
||||
"PE_EmitterEditor.saveEmitter( " @ PE_EmitterEditor.currEmitter.getName() @ " ); PE_EmitterEditor.createEmitter();",
|
||||
"PE_EmitterEditor.saveEmitterDialogDontSave( " @ PE_EmitterEditor.currEmitter.getName() @ " ); PE_EmitterEditor.createEmitter();"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
PE_EmitterEditor.createEmitter();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::createEmitter( %this )
|
||||
{
|
||||
// Create a new emitter.
|
||||
%emitter = getUniqueName( "newEmitter" );
|
||||
datablock ParticleEmitterData( %emitter : DefaultEmitter )
|
||||
{
|
||||
};
|
||||
|
||||
// Submit undo.
|
||||
|
||||
%action = ParticleEditor.createUndo( ActionCreateNewEmitter, "Create New Emitter" );
|
||||
%action.prevEmitter = PE_EmitterEditor.currEmitter;
|
||||
%action.emitter = %emitter.getId();
|
||||
%action.emitterName = %emitter;
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
|
||||
// Execute action.
|
||||
|
||||
%action.redo();
|
||||
|
||||
PE_ParticleEditor.createParticle(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::showDeleteDialog( %this )
|
||||
{
|
||||
if( PE_EmitterEditor.currEmitter.getName() $= "DefaultEmitter" )
|
||||
{
|
||||
MessageBoxOK( "Error", "Cannot delete DefaultEmitter");
|
||||
return;
|
||||
}
|
||||
|
||||
if( isObject( PE_EmitterEditor.currEmitter ) )
|
||||
{
|
||||
MessageBoxYesNoCancel("Delete Emitter?",
|
||||
"Are you sure you want to delete<br><br>" @ PE_EmitterEditor.currEmitter.getName() @ "<br><br> Emitter deletion won't take affect until the level is exited.",
|
||||
"PE_EmitterEditor.saveEmitterDialogDontSave( " @ PE_EmitterEditor.currEmitter.getName() @ " ); PE_EmitterEditor.deleteEmitter();"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::deleteEmitter( %this )
|
||||
{
|
||||
%emitter = PE_EmitterEditor.currEmitter;
|
||||
|
||||
// Create undo.
|
||||
|
||||
%action = ParticleEditor.createUndo( ActionDeleteEmitter, "Delete Emitter" );
|
||||
%action.emitter = %emitter;
|
||||
%action.emitterFname = %emitter.getFilename();
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
|
||||
// Execute action.
|
||||
|
||||
%action.redo();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::saveEmitter( %this, %emitter )
|
||||
{
|
||||
|
||||
|
||||
if ( %emitter $= "" )
|
||||
%newName = PEE_EmitterSelector_Control->TextEdit.getText();
|
||||
else
|
||||
%newName = %emitter.getName();
|
||||
|
||||
PE_EmitterEditor.currEmitter.setName( %newName );
|
||||
PE_EmitterEditor_NotDirtyEmitter.assignFieldsFrom( %emitter );
|
||||
PE_EmitterEditor_NotDirtyEmitter.originalName = %newName;
|
||||
|
||||
PE_EmitterSaver.saveDirty();
|
||||
|
||||
PE_EmitterEditor.currEmitter = %newName.getId();
|
||||
PE_EmitterEditor.setEmitterNotDirty();
|
||||
|
||||
ParticleEditor.createParticleList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_EmitterEditor::saveEmitterDialogDontSave( %this, %emitter)
|
||||
{
|
||||
%emitter.setName( PE_EmitterEditor_NotDirtyEmitter.originalName );
|
||||
%emitter.assignFieldsFrom( PE_EmitterEditor_NotDirtyEmitter );
|
||||
PE_EmitterEditor.setEmitterNotDirty();
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// PEE_EmitterSelector_Control.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PEE_EmitterSelector_Control::onRenameItem( %this )
|
||||
{
|
||||
Parent::onRenameItem( %this );
|
||||
|
||||
//FIXME: need to check for validity of name and name clashes
|
||||
|
||||
PE_EmitterEditor.setEmitterDirty();
|
||||
|
||||
// Resort menu.
|
||||
|
||||
%this-->PopupMenu.sort();
|
||||
}
|
||||
|
|
@ -0,0 +1,589 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
$PE_PARTICLEEDITOR_DEFAULT_FILENAME = "art/shapes/particles/managedParticleData.cs";
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// PE_ParticleEditor.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::guiSync( %this )
|
||||
{
|
||||
// Populate the selector with the particles assigned
|
||||
// to the current emitter.
|
||||
|
||||
%containsCurrParticle = false;
|
||||
%popup = PEP_ParticleSelector;
|
||||
%popup.clear();
|
||||
|
||||
foreach$( %particle in PE_EmitterEditor.currEmitter.particles )
|
||||
{
|
||||
if( %particle.getId() == PE_ParticleEditor.currParticle )
|
||||
%containsCurrParticle = true;
|
||||
|
||||
%popup.add( %particle, %particle.getId() );
|
||||
}
|
||||
|
||||
// Just in case the particle doesn't exist, fallback gracefully
|
||||
|
||||
if( !%containsCurrParticle )
|
||||
PE_ParticleEditor.currParticle = getWord( PE_EmitterEditor.currEmitter.particles, 0 ).getId();
|
||||
|
||||
%data = PE_ParticleEditor.currParticle;
|
||||
|
||||
%popup.sort();
|
||||
%popup.setSelected( %data );
|
||||
|
||||
%bitmap = MaterialEditorGui.searchForTexture( %data.getName(), %data.textureName );
|
||||
if( %bitmap !$= "" )
|
||||
{
|
||||
PE_ParticleEditor-->PEP_previewImage.setBitmap( %bitmap );
|
||||
PE_ParticleEditor-->PEP_previewImageName.setText( %bitmap );
|
||||
PE_ParticleEditor-->PEP_previewImageName.tooltip = %bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
PE_ParticleEditor-->PEP_previewImage.setBitmap( "" );
|
||||
PE_ParticleEditor-->PEP_previewImageName.setText( "None" );
|
||||
PE_ParticleEditor-->PEP_previewImageName.tooltip = "None";
|
||||
}
|
||||
|
||||
PE_ParticleEditor-->PEP_inverseAlpha.setValue( %data.useInvAlpha );
|
||||
|
||||
PE_ParticleEditor-->PEP_lifetimeMS_slider.setValue( %data.lifetimeMS );
|
||||
PE_ParticleEditor-->PEP_lifetimeMS_textEdit.setText( %data.lifetimeMS );
|
||||
|
||||
PE_ParticleEditor-->PEP_lifetimeVarianceMS_slider.setValue( %data.lifetimeVarianceMS );
|
||||
PE_ParticleEditor-->PEP_lifetimeVarianceMS_textEdit.setText( %data.lifetimeVarianceMS );
|
||||
|
||||
PE_ParticleEditor-->PEP_inheritedVelFactor_slider.setValue( %data.inheritedVelFactor );
|
||||
PE_ParticleEditor-->PEP_inheritedVelFactor_textEdit.setText( %data.inheritedVelFactor );
|
||||
|
||||
PE_ParticleEditor-->PEP_constantAcceleration_slider.setValue( %data.constantAcceleration );
|
||||
PE_ParticleEditor-->PEP_constantAcceleration_textEdit.setText( %data.constantAcceleration );
|
||||
|
||||
PE_ParticleEditor-->PEP_gravityCoefficient_slider.setValue( %data.gravityCoefficient );
|
||||
PE_ParticleEditor-->PEP_gravityCoefficient_textEdit.setText( %data.gravityCoefficient );
|
||||
|
||||
PE_ParticleEditor-->PEP_dragCoefficient_slider.setValue( %data.dragCoefficient );
|
||||
PE_ParticleEditor-->PEP_dragCoefficient_textEdit.setText( %data.dragCoefficient );
|
||||
|
||||
PE_ParticleEditor-->PEP_spinRandomMin_slider.setValue( %data.spinRandomMin );
|
||||
PE_ParticleEditor-->PEP_spinRandomMin_textEdit.setText( %data.spinRandomMin );
|
||||
|
||||
PE_ParticleEditor-->PEP_spinRandomMax_slider.setValue( %data.spinRandomMax );
|
||||
PE_ParticleEditor-->PEP_spinRandomMax_textEdit.setText( %data.spinRandomMax );
|
||||
|
||||
PE_ParticleEditor-->PEP_spinRandomMax_slider.setValue( %data.spinRandomMax );
|
||||
PE_ParticleEditor-->PEP_spinRandomMax_textEdit.setText( %data.spinRandomMax );
|
||||
|
||||
PE_ParticleEditor-->PEP_spinSpeed_slider.setValue( %data.spinSpeed );
|
||||
PE_ParticleEditor-->PEP_spinSpeed_textEdit.setText( %data.spinSpeed );
|
||||
|
||||
PE_ColorTintSwatch0.color = %data.colors[ 0 ];
|
||||
PE_ColorTintSwatch1.color = %data.colors[ 1 ];
|
||||
PE_ColorTintSwatch2.color = %data.colors[ 2 ];
|
||||
PE_ColorTintSwatch3.color = %data.colors[ 3 ];
|
||||
|
||||
PE_ParticleEditor-->PEP_pointSize_slider0.setValue( %data.sizes[ 0 ] );
|
||||
PE_ParticleEditor-->PEP_pointSize_textEdit0.setText( %data.sizes[ 0 ] );
|
||||
|
||||
PE_ParticleEditor-->PEP_pointSize_slider1.setValue( %data.sizes[ 1 ] );
|
||||
PE_ParticleEditor-->PEP_pointSize_textEdit1.setText( %data.sizes[ 1 ] );
|
||||
|
||||
PE_ParticleEditor-->PEP_pointSize_slider2.setValue( %data.sizes[ 2 ] );
|
||||
PE_ParticleEditor-->PEP_pointSize_textEdit2.setText( %data.sizes[ 2 ] );
|
||||
|
||||
PE_ParticleEditor-->PEP_pointSize_slider3.setValue( %data.sizes[ 3 ] );
|
||||
PE_ParticleEditor-->PEP_pointSize_textEdit3.setText( %data.sizes[ 3 ] );
|
||||
|
||||
PE_ParticleEditor-->PEP_pointTime_slider0.setValue( %data.times[ 0 ] );
|
||||
PE_ParticleEditor-->PEP_pointTime_textEdit0.setText( %data.times[ 0 ] );
|
||||
|
||||
PE_ParticleEditor-->PEP_pointTime_slider1.setValue( %data.times[ 1 ] );
|
||||
PE_ParticleEditor-->PEP_pointTime_textEdit1.setText( %data.times[ 1 ] );
|
||||
|
||||
PE_ParticleEditor-->PEP_pointTime_slider2.setValue( %data.times[ 2 ] );
|
||||
PE_ParticleEditor-->PEP_pointTime_textEdit2.setText( %data.times[ 2 ] );
|
||||
|
||||
PE_ParticleEditor-->PEP_pointTime_slider3.setValue( %data.times[ 3 ] );
|
||||
PE_ParticleEditor-->PEP_pointTime_textEdit3.setText( %data.times[ 3 ] );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// Generic updateParticle method
|
||||
function PE_ParticleEditor::updateParticle(%this, %propertyField, %value, %isSlider, %onMouseUp)
|
||||
{
|
||||
PE_ParticleEditor.setParticleDirty();
|
||||
%particle = PE_ParticleEditor.currParticle;
|
||||
|
||||
%last = Editor.getUndoManager().getUndoAction(Editor.getUndoManager().getUndoCount() - 1);
|
||||
if( (%isSlider) && (%last.isSlider) && (!%last.onMouseUp) )
|
||||
{
|
||||
%last.field = %propertyField;
|
||||
%last.isSlider = %isSlider;
|
||||
%last.onMouseUp = %onMouseUp;
|
||||
%last.newValue = %value;
|
||||
}
|
||||
else
|
||||
{
|
||||
%action = ParticleEditor.createUndo(ActionUpdateActiveParticle, "Update Active Particle");
|
||||
%action.particle = %particle;
|
||||
%action.field = %propertyField;
|
||||
%action.isSlider = %isSlider;
|
||||
%action.onMouseUp = %onMouseUp;
|
||||
%action.newValue = %value;
|
||||
%action.oldValue = %particle.getFieldValue( %propertyField );
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
}
|
||||
|
||||
%particle.setFieldValue( %propertyField, %value );
|
||||
%particle.reload();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// Special case updateEmitter methods
|
||||
function PE_ParticleEditor::updateParticleTexture( %this, %action )
|
||||
{
|
||||
if( %action )
|
||||
{
|
||||
%texture = MaterialEditorGui.openFile("texture");
|
||||
if( %texture !$= "" )
|
||||
{
|
||||
PE_ParticleEditor-->PEP_previewImage.setBitmap(%texture);
|
||||
PE_ParticleEditor-->PEP_previewImageName.setText(%texture);
|
||||
PE_ParticleEditor-->PEP_previewImageName.tooltip = %texture;
|
||||
|
||||
PE_ParticleEditor.updateParticle( "textureName", %texture );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PE_ParticleEditor-->PEP_previewImage.setBitmap("");
|
||||
PE_ParticleEditor-->PEP_previewImageName.setText("");
|
||||
PE_ParticleEditor-->PEP_previewImageName.tooltip = "";
|
||||
|
||||
PE_ParticleEditor.updateParticle( "textureName", "" );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::updateLifeFields( %this, %isRandom, %value, %isSlider, %onMouseUp )
|
||||
{
|
||||
PE_ParticleEditor.setParticleDirty();
|
||||
%particle = PE_ParticleEditor.currParticle;
|
||||
|
||||
//Transfer values over to gui controls.
|
||||
|
||||
if( %isRandom )
|
||||
{
|
||||
%value ++;
|
||||
if( %value > PE_ParticleEditor-->PEP_lifetimeMS_slider.getValue() )
|
||||
{
|
||||
PE_ParticleEditor-->PEP_lifetimeMS_textEdit.setText( %value );
|
||||
PE_ParticleEditor-->PEP_lifetimeMS_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
%value --;
|
||||
if( %value < PE_ParticleEditor-->PEP_lifetimeVarianceMS_slider.getValue() )
|
||||
{
|
||||
PE_ParticleEditor-->PEP_lifetimeVarianceMS_textEdit.setText( %value );
|
||||
PE_ParticleEditor-->PEP_lifetimeVarianceMS_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
|
||||
// Submit undo.
|
||||
|
||||
%last = Editor.getUndoManager().getUndoAction(Editor.getUndoManager().getUndoCount() - 1);
|
||||
if( (%isSlider) && (%last.isSlider) && (!%last.onMouseUp) )
|
||||
{
|
||||
%last.isSlider = %isSlider;
|
||||
%last.onMouseUp = %onMouseUp;
|
||||
%last.newValueLifetimeMS = PE_ParticleEditor-->PEP_lifetimeMS_textEdit.getText();
|
||||
%last.newValueLifetimeVarianceMS = PE_ParticleEditor-->PEP_lifetimeVarianceMS_textEdit.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
%action = ParticleEditor.createUndo(ActionUpdateActiveParticleLifeFields, "Update Active Particle");
|
||||
%action.particle = %particle;
|
||||
%action.isSlider = %isSlider;
|
||||
%action.onMouseUp = %onMouseUp;
|
||||
|
||||
%action.newValueLifetimeMS = PE_ParticleEditor-->PEP_lifetimeMS_textEdit.getText();
|
||||
%action.oldValueLifetimeMS = %particle.lifetimeMS;
|
||||
|
||||
%action.newValueLifetimeVarianceMS = PE_ParticleEditor-->PEP_lifetimeVarianceMS_textEdit.getText();
|
||||
%action.oldValueLifetimeVarianceMS = %particle.lifetimeVarianceMS;
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
}
|
||||
|
||||
%particle.lifetimeMS = PE_ParticleEditor-->PEP_lifetimeMS_textEdit.getText();
|
||||
%particle.lifetimeVarianceMS = PE_ParticleEditor-->PEP_lifetimeVarianceMS_textEdit.getText();
|
||||
%particle.reload();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::updateSpinFields( %this, %isMax, %value, %isSlider, %onMouseUp )
|
||||
{
|
||||
PE_ParticleEditor.setParticleDirty();
|
||||
%particle = PE_ParticleEditor.currParticle;
|
||||
|
||||
// Transfer values over to gui controls.
|
||||
if( %isMax )
|
||||
{
|
||||
%value ++;
|
||||
if( %value > PE_ParticleEditor-->PEP_spinRandomMax_slider.getValue() )
|
||||
{
|
||||
PE_ParticleEditor-->PEP_spinRandomMax_textEdit.setText( %value );
|
||||
PE_ParticleEditor-->PEP_spinRandomMax_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
%value --;
|
||||
if( %value < PE_ParticleEditor-->PEP_spinRandomMin_slider.getValue() )
|
||||
{
|
||||
PE_ParticleEditor-->PEP_spinRandomMin_textEdit.setText( %value );
|
||||
PE_ParticleEditor-->PEP_spinRandomMin_slider.setValue( %value );
|
||||
}
|
||||
}
|
||||
|
||||
// Submit undo.
|
||||
|
||||
%last = Editor.getUndoManager().getUndoAction(Editor.getUndoManager().getUndoCount() - 1);
|
||||
if( (%isSlider) && (%last.isSlider) && (!%last.onMouseUp) )
|
||||
{
|
||||
%last.isSlider = %isSlider;
|
||||
%last.onMouseUp = %onMouseUp;
|
||||
%last.newValueSpinRandomMax = PE_ParticleEditor-->PEP_spinRandomMax_textEdit.getText();
|
||||
%last.newValueSpinRandomMin = PE_ParticleEditor-->PEP_spinRandomMin_textEdit.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
%action = ParticleEditor.createUndo(ActionUpdateActiveParticleSpinFields, "Update Active Particle");
|
||||
%action.particle = %particle;
|
||||
%action.isSlider = %isSlider;
|
||||
%action.onMouseUp = %onMouseUp;
|
||||
|
||||
%action.newValueSpinRandomMax = PE_ParticleEditor-->PEP_spinRandomMax_textEdit.getText();
|
||||
%action.oldValueSpinRandomMax = %particle.spinRandomMax;
|
||||
|
||||
%action.newValueSpinRandomMin = PE_ParticleEditor-->PEP_spinRandomMin_textEdit.getText();
|
||||
%action.oldValueSpinRandomMin = %particle.spinRandomMin;
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
}
|
||||
|
||||
%particle.spinRandomMax = PE_ParticleEditor-->PEP_spinRandomMax_textEdit.getText();
|
||||
%particle.spinRandomMin = PE_ParticleEditor-->PEP_spinRandomMin_textEdit.getText();
|
||||
|
||||
%particle.reload();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::onNewParticle( %this )
|
||||
{
|
||||
// Bail if the user selected the same particle.
|
||||
|
||||
%id = PEP_ParticleSelector.getSelected();
|
||||
if( %id == PE_ParticleEditor.currParticle )
|
||||
return;
|
||||
|
||||
// Load new particle if we're not in a dirty state
|
||||
if( PE_ParticleEditor.dirty )
|
||||
{
|
||||
MessageBoxYesNoCancel("Save Existing Particle?",
|
||||
"Do you want to save changes to <br><br>" @ PE_ParticleEditor.currParticle.getName(),
|
||||
"PE_ParticleEditor.saveParticle(" @ PE_ParticleEditor.currParticle @ ");",
|
||||
"PE_ParticleEditor.saveParticleDialogDontSave(" @ PE_ParticleEditor.currParticle @ "); PE_ParticleEditor.loadNewParticle();"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
PE_ParticleEditor.loadNewParticle();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::loadNewParticle( %this, %particle )
|
||||
{
|
||||
if( isObject( %particle ) )
|
||||
%particle = %particle.getId();
|
||||
else
|
||||
%particle = PEP_ParticleSelector.getSelected();
|
||||
|
||||
PE_ParticleEditor.currParticle = %particle;
|
||||
|
||||
%particle.reload();
|
||||
|
||||
PE_ParticleEditor_NotDirtyParticle.assignFieldsFrom( %particle );
|
||||
PE_ParticleEditor_NotDirtyParticle.originalName = %particle.getName();
|
||||
|
||||
PE_ParticleEditor.guiSync();
|
||||
PE_ParticleEditor.setParticleNotDirty();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::setParticleDirty( %this )
|
||||
{
|
||||
PE_ParticleEditor.text = "Particle *";
|
||||
PE_ParticleEditor.dirty = true;
|
||||
|
||||
%particle = PE_ParticleEditor.currParticle;
|
||||
|
||||
if( %particle.getFilename() $= "" || %particle.getFilename() $= "tools/particleEditor/particleParticleEditor.ed.cs" )
|
||||
PE_ParticleSaver.setDirty( %particle, $PE_PARTICLEEDITOR_DEFAULT_FILENAME );
|
||||
else
|
||||
PE_ParticleSaver.setDirty( %particle );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::setParticleNotDirty( %this )
|
||||
{
|
||||
PE_ParticleEditor.text = "Particle";
|
||||
PE_ParticleEditor.dirty = false;
|
||||
|
||||
PE_ParticleSaver.clearAll();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::showNewDialog( %this, %replaceSlot )
|
||||
{
|
||||
// Open a dialog if the current Particle is dirty
|
||||
if( PE_ParticleEditor.dirty )
|
||||
{
|
||||
MessageBoxYesNoCancel("Save Particle Changes?",
|
||||
"Do you wish to save the changes made to the <br>current particle before changing the particle?",
|
||||
"PE_ParticleEditor.saveParticle( " @ PE_ParticleEditor.currParticle.getName() @ " ); PE_ParticleEditor.createParticle( " @ %replaceSlot @ " );",
|
||||
"PE_ParticleEditor.saveParticleDialogDontSave( " @ PE_ParticleEditor.currParticle.getName() @ " ); PE_ParticleEditor.createParticle( " @ %replaceSlot @ " );"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
PE_ParticleEditor.createParticle( %replaceSlot );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::createParticle( %this, %replaceSlot )
|
||||
{
|
||||
// Make sure we have a spare slot on the current emitter.
|
||||
|
||||
if( !%replaceSlot )
|
||||
{
|
||||
%numExistingParticles = getWordCount( PE_EmitterEditor.currEmitter.particles );
|
||||
if( %numExistingParticles > 3 )
|
||||
{
|
||||
MessageBoxOK( "Error", "An emitter cannot have more than 4 particles assigned to it." );
|
||||
return;
|
||||
}
|
||||
|
||||
%particleIndex = %numExistingParticles;
|
||||
}
|
||||
else
|
||||
%particleIndex = %replaceSlot - 1;
|
||||
|
||||
// Create the particle datablock and add to the emitter.
|
||||
|
||||
%newParticle = getUniqueName( "newParticle" );
|
||||
|
||||
datablock ParticleData( %newParticle : DefaultParticle )
|
||||
{
|
||||
};
|
||||
|
||||
// Submit undo.
|
||||
|
||||
%action = ParticleEditor.createUndo( ActionCreateNewParticle, "Create New Particle" );
|
||||
%action.particle = %newParticle.getId();
|
||||
%action.particleIndex = %particleIndex;
|
||||
%action.prevParticle = ( "PEE_EmitterParticleSelector" @ ( %particleIndex + 1 ) ).getSelected();
|
||||
%action.emitter = PE_EmitterEditor.currEmitter;
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
|
||||
// Execute action.
|
||||
|
||||
%action.redo();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::showDeleteDialog( %this )
|
||||
{
|
||||
// Don't allow deleting DefaultParticle.
|
||||
|
||||
if( PE_ParticleEditor.currParticle.getName() $= "DefaultParticle" )
|
||||
{
|
||||
MessageBoxOK( "Error", "Cannot delete DefaultParticle");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check to see if the particle emitter has more than 1 particle on it.
|
||||
|
||||
if( getWordCount( PE_EmitterEditor.currEmitter.particles ) == 1 )
|
||||
{
|
||||
MessageBoxOK( "Error", "At least one particle must remain on the particle emitter.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Bring up requester for confirmation.
|
||||
|
||||
if( isObject( PE_ParticleEditor.currParticle ) )
|
||||
{
|
||||
MessageBoxYesNoCancel( "Delete Particle?",
|
||||
"Are you sure you want to delete<br><br>" @ PE_ParticleEditor.currParticle.getName() @ "<br><br> Particle deletion won't take affect until the engine is quit.",
|
||||
"PE_ParticleEditor.saveParticleDialogDontSave( " @ PE_ParticleEditor.currParticle.getName() @ " ); PE_ParticleEditor.deleteParticle();",
|
||||
"",
|
||||
""
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::deleteParticle( %this )
|
||||
{
|
||||
%particle = PE_ParticleEditor.currParticle;
|
||||
|
||||
// Submit undo.
|
||||
|
||||
%action = ParticleEditor.createUndo( ActionDeleteParticle, "Delete Particle" );
|
||||
%action.particle = %particle;
|
||||
%action.emitter = PE_EmitterEditor.currEmitter;
|
||||
|
||||
ParticleEditor.submitUndo( %action );
|
||||
|
||||
// Execute action.
|
||||
|
||||
%action.redo();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::saveParticle( %this, %particle )
|
||||
{
|
||||
%particle.setName( PEP_ParticleSelector.getText() );
|
||||
|
||||
PE_ParticleEditor_NotDirtyParticle.assignFieldsFrom( %particle );
|
||||
PE_ParticleEditor_NotDirtyParticle.originalName = %particle.getName();
|
||||
|
||||
PE_ParticleSaver.saveDirty();
|
||||
PE_ParticleEditor.setParticleNotDirty();
|
||||
|
||||
ParticleEditor.createParticleList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ParticleEditor::saveParticleDialogDontSave( %this, %particle )
|
||||
{
|
||||
%particle.setName( PE_ParticleEditor_NotDirtyParticle.originalName );
|
||||
%particle.assignFieldsFrom( PE_ParticleEditor_NotDirtyParticle );
|
||||
|
||||
PE_ParticleEditor.setParticleNotDirty();
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// PE_ColorTintSwatch.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PE_ColorTintSwatch::updateParticleColor( %this, %color )
|
||||
{
|
||||
%arrayNum = %this.arrayNum;
|
||||
|
||||
%r = getWord( %color, 0 );
|
||||
%g = getWord( %color, 1 );
|
||||
%b = getWord( %color, 2 );
|
||||
%a = getWord( %color, 3 );
|
||||
|
||||
%color = %r SPC %g SPC %b SPC %a;
|
||||
%this.color = %color;
|
||||
|
||||
PE_ParticleEditor.updateParticle( "colors[" @ %arrayNum @ "]", %color );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// PEP_ParticleSelector_Control.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PEP_ParticleSelector_Control::onRenameItem( %this )
|
||||
{
|
||||
Parent::onRenameItem( %this );
|
||||
|
||||
//FIXME: need to check for validity of name and name clashes
|
||||
|
||||
PE_ParticleEditor.setParticleDirty();
|
||||
|
||||
// Resort menu.
|
||||
|
||||
%this-->PopupMenu.sort();
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// PEP_NewParticleButton.
|
||||
//=============================================================================================
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PEP_NewParticleButton::onDefaultClick( %this )
|
||||
{
|
||||
PE_ParticleEditor.showNewDialog();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function PEP_NewParticleButton::onCtrlClick( %this )
|
||||
{
|
||||
for( %i = 1; %i < 5; %i ++ )
|
||||
{
|
||||
%popup = "PEE_EmitterParticleSelector" @ %i;
|
||||
if( %popup.getSelected() == PEP_ParticleSelector.getSelected() )
|
||||
{
|
||||
%replaceSlot = %i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PE_ParticleEditor.showNewDialog( %replaceSlot );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue