//----------------------------------------------------------------------------- // 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( "./guis/ParticleEditor.ed.gui" ); exec( "./guis/particleEditor.ed." @ $TorqueScriptFileExtension ); exec( "./guis/createNewPrompt.ed.gui" ); exec( "./guis/createNewPrompt.ed." @ $TorqueScriptFileExtension ); exec( "./scripts/particleEditorUndo.ed." @ $TorqueScriptFileExtension ); exec( "./scripts/particleEmitterEditor.ed." @ $TorqueScriptFileExtension ); exec( "./scripts/particleParticleEditor.ed." @ $TorqueScriptFileExtension ); exec( "./scripts/explosionEditor.ed." @ $TorqueScriptFileExtension ); exec( "./scripts/particleRibbonEditor.ed." @ $TorqueScriptFileExtension ); exec( "./scripts/afxZodiacEditor.ed." @ $TorqueScriptFileExtension ); exec( "./scripts/afxChoreoEditor.ed." @ $TorqueScriptFileExtension ); 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 ); ParticleEditor.registerParticleEdType("Emitter", "ParticleEmitterData", "PE_EmitterEditor"); ParticleEditor.registerParticleEdType("Particle", "ParticleData", "PE_ParticleEditor"); ParticleEditor.registerParticleEdType("Explosion", "ExplosionData", "PE_ExplosionEditor"); ParticleEditor.registerParticleEdType("Ribbon", "RibbonData", "PE_RibbonParticleEditor"); ParticleEditor.registerParticleEdType("Zodiac", "afxZodiacData", "PE_AFXZodiacEditor"); ParticleEditor.registerParticleEdType("Choreography", "afxChoreographerData", "PE_AFXChoreoEditor"); } //--------------------------------------------------------------------------------------------- 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", "ToolsModule:particleeditor_n_image", %tooltip ); } //--------------------------------------------------------------------------------------------- function ParticleEditorPlugin::onActivated( %this ) { if( !ParticleEditor.isInitialized ) { ParticleEditor.initEditor(); ParticleEditor.isInitialized = true; } EditorGui-->WorldEditorToolbar.setVisible( true ); Canvas.pushDialog(ParticleEditorGui); 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 ); ParticleEditor.selectedEditor.closeEditorTab(); Canvas.popDialog(ParticleEditorGui); ParticleEditorGui.quit(); %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 ) ) PE_EmitterEditor.loadNewEmitter( %selectedEmitter.getId() ); %selectedParticle = EditorSettings.value( "selectedParticle" ); if( isObject( %selectedParticle ) ) PE_EmitterEditor.loadNewParticle( %selectedParticle.getId() ); %selectedExplosion = EditorSettings.value( "selectedExplosion" ); if( isObject( %selectedExplosion ) ) PE_ExplosionEditor.loadNewExplosion( %selectedExplosion.getId() ); %selectedRibbon = EditorSettings.value( "selectedRibbon" ); if( isObject( %selectedRibbon ) ) PE_RibbonParticleEditor.loadNewRibbon( %selectedRibbon.getId() ); PE_TabBook.selectPage( EditorSettings.value( "selectedPage" ) ); EditorSettings.endGroup(); } //--------------------------------------------------------------------------------------------- function ParticleEditorPlugin::writeSettings( %this ) { EditorSettings.beginGroup( "ParticleEditor", true ); EditorSettings.setValue( "selectedEmitter", PE_EmitterEditor-->popupMenu.getText() ); EditorSettings.setValue( "selectedParticle", PE_EmitterEditor-->popupMenu.getText() ); EditorSettings.setValue( "selectedExplosion", PE_ExplosionEditor-->popupMenu.getText() ); EditorSettings.setValue( "selectedRibbon", PE_RibbonParticleEditor-->popupMenu.getText() ); EditorSettings.setValue( "selectedTab", PE_TabBook.getSelectedPage() ); EditorSettings.endGroup(); } //------------------------------------------------------------------------------ function ParticleEditor::registerParticleEdType(%this, %groupName, %typesList, %editorName) { if(!isObject(PE_ParticleDataTypes)) { new ArrayObject(PE_ParticleDataTypes){}; } if(PE_ParticleDataTypes.getIndexFromKey(%groupName) != -1) { error("ParticleEditor::registerParticleEdType() - Attempted to register an existing group name of a particle type!"); return; } PE_ParticleDataTypes.add(%groupName, %typesList TAB %editorName); }