| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- //-----------------------------------------------------------------------------
- // 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.
- //-----------------------------------------------------------------------------
- function initializeDecalEditor()
- {
- echo(" % - Initializing Decal Editor");
-
- $decalDataFile = "data/managedDecalData." @ $TorqueScriptFileExtension;
-
- exec( "./decalEditor." @ $TorqueScriptFileExtension );
- exec( "./decalEditorGui.gui" );
- exec( "./decalEditorGui." @ $TorqueScriptFileExtension );
- exec( "./decalEditorActions." @ $TorqueScriptFileExtension );
-
- // Add ourselves to EditorGui, where all the other tools reside
- DecalEditorGui.setVisible( false );
- DecalPreviewWindow.setVisible( false );
- DecalEditorWindow.setVisible( false );
- MainSceneTabPanel.add( DecalEditorGui );
- MainSceneTabPanel.add( DecalEditorWindow );
- MainSceneTabPanel.add( DecalPreviewWindow );
- DecalEditorTabBook.selectPage( 0 );
-
- new ScriptObject( DecalEditorPlugin )
- {
- superClass = "EditorPlugin";
- editorGui = DecalEditorGui;
- };
-
- %map = new ActionMap();
- %map.bindCmd( keyboard, "5", "EDecalEditorAddDecalBtn.performClick();", "" );
- %map.bindCmd( keyboard, "1", "EDecalEditorSelectDecalBtn.performClick();", "" );
- %map.bindCmd( keyboard, "2", "EDecalEditorMoveDecalBtn.performClick();", "" );
- %map.bindCmd( keyboard, "3", "EDecalEditorRotateDecalBtn.performClick();", "" );
- %map.bindCmd( keyboard, "4", "EDecalEditorScaleDecalBtn.performClick();", "" );
-
- DecalEditorPlugin.map = %map;
-
- new PersistenceManager( DecalPMan );
-
- }
- function destroyDecalEditor()
- {
- }
- // JCF: helper for during development
- function reinitDecalEditor()
- {
- exec( "./main." @ $TorqueScriptFileExtension );
- exec( "./decalEditor." @ $TorqueScriptFileExtension );
- exec( "./decalEditorGui." @ $TorqueScriptFileExtension );
- }
- function DecalEditorPlugin::onWorldEditorStartup( %this )
- {
- // Add ourselves to the window menu.
- %accel = EditorGui.addToEditorsMenu( "Decal Editor", "", DecalEditorPlugin );
-
- // Add ourselves to the ToolsToolbar
- %tooltip = "Decal Editor (" @ %accel @ ")";
- EditorGui.addToToolsToolbar( "DecalEditorPlugin", "DecalEditorPalette", "ToolsModule:decal_editor_n_image", %tooltip );
- //connect editor windows
- GuiWindowCtrl::attach( DecalPreviewWindow, DecalEditorWindow );
-
- //set initial palette setting
- %this.paletteSelection = "AddDecalMode";
- }
- function EditorGui::SetDecalPalletBar()
- {
- //Clears the button pallete stack
- EWToolsPaletteWindow.setStackCtrl(ToolsPaletteArray); //legacy ctrl adhereance
- EWToolsPaletteWindow.clearButtons();
-
- EWToolsPaletteWindow.setActionMap(WorldEditorInspectorPlugin.map);
-
- //Adds a button to the pallete stack
- //Name Icon Click Command Tooltip text Keybind
- EWToolsPaletteWindow.addButton("SelectDecal", "ToolsModule:arrow_n_image", "DecalEditorGui.setMode(\"SelectDecalMode\");", "", "Select Decal", "1");
- EWToolsPaletteWindow.addButton("MoveDecal", "ToolsModule:move_point_n_image", "DecalEditorGui.setMode(\"MoveDecalMode\");", "", "Move Decal", "2");
- EWToolsPaletteWindow.addButton("RotateDecal", "ToolsModule:rotate_point_n_image", "DecalEditorGui.setMode(\"RotateDecalMode\");", "", "Rotate Decal", "3");
- EWToolsPaletteWindow.addButton("ScaleDecal", "ToolsModule:scale_point_n_image", "DecalEditorGui.setMode(\"ScaleDecalMode\");", "", "Scale Decal", "4");
- EWToolsPaletteWindow.addButton("AddDecal", "ToolsModule:add_decal_n_image", "DecalEditorGui.setMode(\"AddDecalMode\");", "", "Add Decal", "5");
- EWToolsPaletteWindow.refresh();
- }
- function DecalEditorPlugin::onActivated( %this )
- {
- EditorGui.bringToFront( DecalEditorGui );
- DecalEditorGui.setVisible( true );
- DecalEditorGui.makeFirstResponder( true );
- DecalPreviewWindow.setVisible( true );
- DecalEditorWindow.setVisible( true );
-
- %this.map.push();
-
- //WORKAROUND: due to the gizmo mode being stored on its profile (which may be shared),
- // we may end up with a mismatch between the editor mode and gizmo mode here.
- // Reset mode explicitly here to work around this.
- DecalEditorGui.setMode( DecalEditorGui.getMode() );
-
- // Set the current palette selection
- DecalEditorGui.paletteSync( %this.paletteSelection );
-
- // Store this on a dynamic field
- // in order to restore whatever setting
- // the user had before.
- %this.prevGizmoAlignment = GlobalGizmoProfile.alignment;
-
- // The DecalEditor always uses Object alignment.
- GlobalGizmoProfile.alignment = "Object";
-
- DecalEditorGui.rebuildInstanceTree();
-
- // These could perhaps be the node details like the shape editor
- //ShapeEdPropWindow.syncNodeDetails(-1);
-
- Parent::onActivated(%this);
- EditorGui.SetDecalPalletBar();
- }
- function DecalEditorPlugin::onDeactivated( %this )
- {
- DecalEditorGui.setVisible(false);
- DecalPreviewWindow.setVisible( false );
- DecalEditorWindow.setVisible( false );
-
- %this.map.pop();
-
- // Remember last palette selection
- %this.paletteSelection = DecalEditorGui.getMode();
-
- // Restore the previous Gizmo
- // alignment settings.
- GlobalGizmoProfile.alignment = %this.prevGizmoAlignment;
-
- Parent::onDeactivated(%this);
- }
- function DecalEditorPlugin::isDirty( %this )
- {
- %dirty = DecalPMan.hasDirty();
-
- %dirty |= decalManagerDirty();
-
- return %dirty;
- }
- function DecalEditorPlugin::onSaveMission( %this, %file )
- {
- DecalPMan.saveDirty();
- decalManagerSave( %file @ ".decals" );
- }
- function DecalEditorPlugin::onEditMenuSelect( %this, %editMenu )
- {
- %hasSelection = false;
-
- if ( DecalEditorGui.getSelectionCount() > 0 )
- %hasSelection = true;
-
- %editMenu.enableItem( 3, false ); // Cut
- %editMenu.enableItem( 4, false ); // Copy
- %editMenu.enableItem( 5, false ); // Paste
- %editMenu.enableItem( 6, %hasSelection ); // Delete
- %editMenu.enableItem( 8, false ); // Deselect
-
- // NOTE: If you want to implement Cut, Copy, Paste, or Deselect
- // for this editor simply enable the menu items when it is appropriate
- // and fill in the method stubs below.
- }
- function DecalEditorPlugin::handleDelete( %this )
- {
- DecalEditorGui.deleteSelectedDecal();
- }
- function DecalEditorPlugin::handleDeselect( %this )
- {
- }
- function DecalEditorPlugin::handleCut( %this )
- {
- }
- function DecalEditorPlugin::handleCopy( %this )
- {
- }
- function DecalEditorPlugin::handlePaste( %this )
- {
- }
- function DecalEditorPlugin::handleEscape( %this )
- {
- }
|