2017-02-24 08:40:56 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// 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.
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
// Shape Editor
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
function initializeShapeEditor()
|
|
|
|
|
{
|
|
|
|
|
echo(" % - Initializing Shape Editor");
|
|
|
|
|
|
2021-01-07 11:01:09 +00:00
|
|
|
exec("./gui/Profiles.ed." @ $TorqueScriptFileExtension);
|
2017-02-24 08:40:56 +00:00
|
|
|
|
2023-09-09 03:44:18 +00:00
|
|
|
// Order of GUI loading is important
|
2017-02-24 08:40:56 +00:00
|
|
|
exec("./gui/shapeEdPreviewWindow.ed.gui");
|
|
|
|
|
exec("./gui/ShapeEditorToolbar.ed.gui");
|
|
|
|
|
exec("./gui/shapeEdSelectWindow.ed.gui");
|
|
|
|
|
exec("./gui/shapeEdPropWindow.ed.gui");
|
2023-09-09 03:44:18 +00:00
|
|
|
exec("./gui/shapeEdAdvancedWindow.ed.gui");
|
|
|
|
|
exec("./gui/shapeEdAnimWindow.ed.gui");
|
2017-02-24 08:40:56 +00:00
|
|
|
|
2021-01-07 11:01:09 +00:00
|
|
|
exec("./scripts/shapeEditor.ed." @ $TorqueScriptFileExtension);
|
|
|
|
|
exec("./scripts/shapeEditorHints.ed." @ $TorqueScriptFileExtension);
|
|
|
|
|
exec("./scripts/shapeEditorActions.ed." @ $TorqueScriptFileExtension);
|
2017-02-24 08:40:56 +00:00
|
|
|
|
|
|
|
|
// Add windows to editor gui
|
|
|
|
|
ShapeEdPreviewGui.setVisible(false);
|
|
|
|
|
ShapeEdAnimWindow.setVisible(false);
|
|
|
|
|
ShapeEdSelectWindow.setVisible(false);
|
|
|
|
|
ShapeEdPropWindow.setVisible(false);
|
|
|
|
|
|
2023-11-15 00:58:58 +00:00
|
|
|
MainSceneTabPanel.add(ShapeEdPreviewGui);
|
|
|
|
|
MainSceneTabPanel.add(ShapeEdAnimWindow);
|
|
|
|
|
MainSceneTabPanel.add(ShapeEdAdvancedWindow);
|
2017-02-24 08:40:56 +00:00
|
|
|
|
2023-11-15 00:58:58 +00:00
|
|
|
MainSceneTabPanel.add(ShapeEdSelectWindow);
|
|
|
|
|
MainSceneTabPanel.add(ShapeEdPropWindow);
|
2017-02-24 08:40:56 +00:00
|
|
|
|
|
|
|
|
new ScriptObject(ShapeEditorPlugin)
|
|
|
|
|
{
|
|
|
|
|
superClass = "EditorPlugin";
|
|
|
|
|
editorGui = ShapeEdShapeView;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%map = new ActionMap();
|
|
|
|
|
%map.bindCmd( keyboard, "escape", "ToolsToolbarArray->WorldEditorInspectorPalette.performClick();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "1", "ShapeEditorNoneModeBtn.performClick();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "2", "ShapeEditorMoveModeBtn.performClick();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "3", "ShapeEditorRotateModeBtn.performClick();", "" );
|
|
|
|
|
//%map.bindCmd( keyboard, "4", "ShapeEditorScaleModeBtn.performClick();", "" ); // not needed for the shape editor
|
|
|
|
|
%map.bindCmd( keyboard, "n", "ShapeEditorToolbar->showNodes.performClick();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "t", "ShapeEditorToolbar->ghostMode.performClick();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "r", "ShapeEditorToolbar->wireframeMode.performClick();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "f", "ShapeEditorToolbar->fitToShapeBtn.performClick();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "g", "ShapeEditorToolbar->showGridBtn.performClick();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "h", "ShapeEdSelectWindow->tabBook.selectPage( 2 );", "" ); // Load help tab
|
|
|
|
|
%map.bindCmd( keyboard, "l", "ShapeEdSelectWindow->tabBook.selectPage( 1 );", "" ); // load Library Tab
|
|
|
|
|
%map.bindCmd( keyboard, "j", "ShapeEdSelectWindow->tabBook.selectPage( 0 );", "" ); // load scene object Tab
|
|
|
|
|
%map.bindCmd( keyboard, "SPACE", "ShapeEdAnimWindow.togglePause();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "i", "ShapeEdSequences.onEditSeqInOut(\"in\", ShapeEdSeqSlider.getValue());", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "o", "ShapeEdSequences.onEditSeqInOut(\"out\", ShapeEdSeqSlider.getValue());", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "shift -", "ShapeEdSeqSlider.setValue(ShapeEdAnimWindow-->seqIn.getText());", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "shift =", "ShapeEdSeqSlider.setValue(ShapeEdAnimWindow-->seqOut.getText());", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "=", "ShapeEdAnimWindow-->stepFwdBtn.performClick();", "" );
|
|
|
|
|
%map.bindCmd( keyboard, "-", "ShapeEdAnimWindow-->stepBkwdBtn.performClick();", "" );
|
|
|
|
|
|
|
|
|
|
ShapeEditorPlugin.map = %map;
|
|
|
|
|
|
|
|
|
|
ShapeEditorPlugin.initSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function destroyShapeEditor()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SetToggleButtonValue(%ctrl, %value)
|
|
|
|
|
{
|
|
|
|
|
if ( %ctrl.getValue() != %value )
|
|
|
|
|
%ctrl.performClick();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Replace the command field in an Editor PopupMenu item (returns the original value)
|
|
|
|
|
function ShapeEditorPlugin::replaceMenuCmd(%this, %menuTitle, %id, %newCmd)
|
|
|
|
|
{
|
|
|
|
|
%menu = EditorGui.findMenu( %menuTitle );
|
|
|
|
|
%cmd = getField( %menu.item[%id], 2 );
|
|
|
|
|
%menu.setItemCommand( %id, %newCmd );
|
|
|
|
|
|
|
|
|
|
return %cmd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ShapeEditorPlugin::onWorldEditorStartup(%this)
|
|
|
|
|
{
|
|
|
|
|
// Add ourselves to the window menu.
|
|
|
|
|
%accel = EditorGui.addToEditorsMenu("Shape Editor", "", ShapeEditorPlugin);
|
|
|
|
|
|
|
|
|
|
// Add ourselves to the ToolsToolbar
|
|
|
|
|
%tooltip = "Shape Editor (" @ %accel @ ")";
|
2021-08-02 09:20:27 +00:00
|
|
|
EditorGui.addToToolsToolbar( "ShapeEditorPlugin", "ShapeEditorPalette", "ToolsModule:shape_editor_n_image", %tooltip );
|
2017-02-24 08:40:56 +00:00
|
|
|
|
|
|
|
|
// Add ourselves to the Editor Settings window
|
|
|
|
|
exec( "./gui/ShapeEditorSettingsTab.gui" );
|
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path
Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc
Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector
Adjusted expand behavior of guiTree to be more reliable
Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields
Removed redundant PreMult translucency type code
Added setting of feature so probes work when in forward/basic lit mode
Corrected indexing error in SQLiteObject class so it properly parses with the updated console API
Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy
Fixed var when trying to bind the camera to the client
Added project setting field to dictate the default render mode between Forward or Deferred
Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field
Integrated DOF PostFX into updated PostFX Editor paradigm
Updated setting group name for vignette postFX
Shifted shaderCache to be in data/cache along with other cached files
Added helper function to replace strings in a file
Fixed ExampleCppObject asset to have correct loose file references
Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default
Fixed verve reference to root scene group
Adjusted location of a nonmodal gui profile so it loads at the correct time
Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag
Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful
Initial work into zip and folder drag-and-drop asset importing support
Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions
Updated example asset type file
Ensured all asset types have proper handling for move, rename and delete actions
Fixed double-click behavior on folders in the AB
Fixed CPP asset preview
Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser
Added ability to convert a non-module top-level folder in the AB into a module
Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules
Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake
Fixed convex editor's material handling to work with AB and reference back properly
Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow
Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open
Added some additional common text gui profiles
Disabled calls to old editor settings logic in various editors to remove spam
Added callOnModules call so tools can initialize properly when the world editor is opened
Fixed logic test for visualizers
Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
|
|
|
//ESettingsWindow.addTabPage( EShapeEditorSettingsPage );
|
2017-02-24 08:40:56 +00:00
|
|
|
|
|
|
|
|
GuiWindowCtrl::attach(ShapeEdPropWindow, ShapeEdSelectWindow);
|
|
|
|
|
ShapeEdAnimWindow.resize( -1, 526, 593, 53 );
|
|
|
|
|
|
|
|
|
|
// Initialise gui
|
|
|
|
|
ShapeEdSeqNodeTabBook.selectPage(0);
|
|
|
|
|
ShapeEdAdvancedWindow-->tabBook.selectPage(0);
|
|
|
|
|
ShapeEdSelectWindow-->tabBook.selectPage(0);
|
|
|
|
|
|
|
|
|
|
SetToggleButtonValue( ShapeEditorToolbar-->orbitNodeBtn, 0 );
|
|
|
|
|
SetToggleButtonValue( ShapeEditorToolbar-->ghostMode, 0 );
|
|
|
|
|
|
|
|
|
|
// Initialise hints menu
|
|
|
|
|
ShapeEdHintMenu.clear();
|
|
|
|
|
%count = ShapeHintGroup.getCount();
|
|
|
|
|
for (%i = 0; %i < %count; %i++)
|
|
|
|
|
{
|
|
|
|
|
%hint = ShapeHintGroup.getObject(%i);
|
|
|
|
|
ShapeEdHintMenu.add(%hint.objectType, %hint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-04 16:49:42 +00:00
|
|
|
function ShapeEditorPlugin::openShapeAsset(%this, %assetDef)
|
2018-01-28 21:25:41 +00:00
|
|
|
{
|
2019-05-04 16:49:42 +00:00
|
|
|
%this.selectedAssetDef = %assetDef;
|
2021-08-02 09:20:27 +00:00
|
|
|
%this.open(%this.selectedAssetDef);
|
2018-01-28 21:25:41 +00:00
|
|
|
}
|
|
|
|
|
|
2020-04-15 17:15:12 +00:00
|
|
|
function ShapeEditorPlugin::openShapeAssetId(%this, %assetId)
|
|
|
|
|
{
|
|
|
|
|
%this.selectedAssetDef = AssetDatabase.acquireAsset(%assetId);
|
2025-08-26 04:35:28 +00:00
|
|
|
EditorGui.setEditor( ShapeEditorPlugin );
|
|
|
|
|
ShapeEditorPlugin.openShapeAsset(%this.selectedAssetDef);
|
2020-04-15 17:15:12 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-02 09:20:27 +00:00
|
|
|
function ShapeEditorPlugin::open(%this, %shapeAsset)
|
2017-02-24 08:40:56 +00:00
|
|
|
{
|
|
|
|
|
if ( !%this.isActivated )
|
|
|
|
|
{
|
|
|
|
|
// Activate the Shape Editor
|
|
|
|
|
EditorGui.setEditor( %this, true );
|
|
|
|
|
|
|
|
|
|
// Get editor settings (note the sun angle is not configured in the settings
|
|
|
|
|
// dialog, so apply the settings here instead of in readSettings)
|
|
|
|
|
%this.readSettings();
|
|
|
|
|
ShapeEdShapeView.sunAngleX = EditorSettings.value("ShapeEditor/SunAngleX");
|
|
|
|
|
ShapeEdShapeView.sunAngleZ = EditorSettings.value("ShapeEditor/SunAngleZ");
|
|
|
|
|
EWorldEditor.forceLoadDAE = EditorSettings.value("forceLoadDAE");
|
|
|
|
|
|
|
|
|
|
$wasInWireFrameMode = $gfx::wireframe;
|
|
|
|
|
ShapeEditorToolbar-->wireframeMode.setStateOn($gfx::wireframe);
|
|
|
|
|
|
|
|
|
|
if ( GlobalGizmoProfile.getFieldValue(alignment) $= "Object" )
|
|
|
|
|
ShapeEdNodes-->objectTransform.setStateOn(1);
|
|
|
|
|
else
|
|
|
|
|
ShapeEdNodes-->worldTransform.setStateOn(1);
|
|
|
|
|
|
|
|
|
|
// Initialise and show the shape editor
|
2019-02-23 21:55:28 +00:00
|
|
|
ShapeEdShapeTreeView.open(getScene(0));
|
2017-02-24 08:40:56 +00:00
|
|
|
ShapeEdShapeTreeView.buildVisibleTree(true);
|
|
|
|
|
|
|
|
|
|
ShapeEdPreviewGui.setVisible(true);
|
|
|
|
|
ShapeEdSelectWindow.setVisible(true);
|
|
|
|
|
ShapeEdPropWindow.setVisible(true);
|
|
|
|
|
ShapeEdAnimWindow.setVisible(true);
|
|
|
|
|
ShapeEdAdvancedWindow.setVisible(ShapeEditorToolbar-->showAdvanced.getValue());
|
2023-11-15 00:58:58 +00:00
|
|
|
MainSceneTabPanel.bringToFront(ShapeEdPreviewGui);
|
2017-02-24 08:40:56 +00:00
|
|
|
|
|
|
|
|
ToolsPaletteArray->WorldEditorMove.performClick();
|
|
|
|
|
%this.map.push();
|
|
|
|
|
|
|
|
|
|
// Switch to the ShapeEditor UndoManager
|
|
|
|
|
%this.oldUndoMgr = Editor.getUndoManager();
|
|
|
|
|
Editor.setUndoManager( ShapeEdUndoManager );
|
|
|
|
|
|
|
|
|
|
ShapeEdShapeView.setDisplayType( EditorGui.currentDisplayType );
|
|
|
|
|
%this.initStatusBar();
|
|
|
|
|
|
|
|
|
|
// Customise menu bar
|
|
|
|
|
%this.oldCamFitCmd = %this.replaceMenuCmd( "Camera", 8, "ShapeEdShapeView.fitToShape();" );
|
|
|
|
|
%this.oldCamFitOrbitCmd = %this.replaceMenuCmd( "Camera", 9, "ShapeEdShapeView.fitToShape();" );
|
|
|
|
|
|
|
|
|
|
Parent::onActivated(%this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Select the new shape
|
2021-08-02 09:20:27 +00:00
|
|
|
if (isObject(ShapeEditor.shape) && (ShapeEditor.shape.baseShapeAsset $= %shapeAsset))
|
2017-02-24 08:40:56 +00:00
|
|
|
{
|
|
|
|
|
// Shape is already selected => re-highlight the selected material if necessary
|
|
|
|
|
ShapeEdMaterials.updateSelectedMaterial(ShapeEdMaterials-->highlightMaterial.getValue());
|
|
|
|
|
}
|
2021-08-02 09:20:27 +00:00
|
|
|
else if (%shapeAsset !$= "")
|
2017-02-24 08:40:56 +00:00
|
|
|
{
|
2021-08-02 09:20:27 +00:00
|
|
|
ShapeEditor.selectShape(%shapeAsset, ShapeEditor.isDirty());
|
2017-02-24 08:40:56 +00:00
|
|
|
|
|
|
|
|
// 'fitToShape' only works after the GUI has been rendered, so force a repaint first
|
|
|
|
|
Canvas.repaint();
|
|
|
|
|
ShapeEdShapeView.fitToShape();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-29 21:59:08 +00:00
|
|
|
function EditorGui::SetShapePalletBar()
|
|
|
|
|
{
|
|
|
|
|
//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("Select", "ToolsModule:arrow_n_image", "GlobalGizmoProfile.mode = \"None\";", "", "Select Arrow", "1");
|
|
|
|
|
EWToolsPaletteWindow.addButton("MoveSelection", "ToolsModule:move_point_n_image", "GlobalGizmoProfile.mode = \"Move\";", "", "Move", "2");
|
|
|
|
|
EWToolsPaletteWindow.addButton("RotateSelection", "ToolsModule:rotate_point_n_image", "GlobalGizmoProfile.mode = \"Rotate\";", "", "Rotate", "3");
|
|
|
|
|
EWToolsPaletteWindow.addButton("RotateSun", "ToolsModule:sun_btn_n_image", "ShapeEdShapeView.editSun = !ShapeEdShapeView.editSun;", "", "Rotate sun", "4");
|
|
|
|
|
EWToolsPaletteWindow.refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-24 08:40:56 +00:00
|
|
|
function ShapeEditorPlugin::onActivated(%this)
|
|
|
|
|
{
|
|
|
|
|
%this.open("");
|
|
|
|
|
|
|
|
|
|
// Try to start with the shape selected in the world editor
|
|
|
|
|
%count = EWorldEditor.getSelectionSize();
|
|
|
|
|
for (%i = 0; %i < %count; %i++)
|
|
|
|
|
{
|
|
|
|
|
%obj = EWorldEditor.getSelectedObject(%i);
|
|
|
|
|
%shapeFile = ShapeEditor.getObjectShapeFile(%obj);
|
2020-08-28 07:49:26 +00:00
|
|
|
if (%shapeFile !$= "" && isFile(%shapeFile))
|
2017-02-24 08:40:56 +00:00
|
|
|
{
|
|
|
|
|
if (!isObject(ShapeEditor.shape) || (ShapeEditor.shape.baseShape !$= %shapeFile))
|
|
|
|
|
{
|
|
|
|
|
// Call the 'onSelect' method directly if the object is not in the
|
|
|
|
|
// MissionGroup tree (such as a Player or Projectile object).
|
|
|
|
|
ShapeEdShapeTreeView.clearSelection();
|
|
|
|
|
if (!ShapeEdShapeTreeView.selectItem(%obj))
|
|
|
|
|
ShapeEdShapeTreeView.onSelect(%obj);
|
|
|
|
|
|
|
|
|
|
// 'fitToShape' only works after the GUI has been rendered, so force a repaint first
|
|
|
|
|
Canvas.repaint();
|
|
|
|
|
ShapeEdShapeView.fitToShape();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-08-28 07:49:26 +00:00
|
|
|
else if(%shapeFile !$= "")
|
|
|
|
|
{
|
|
|
|
|
%this.openShapeAssetId(%shapeFile);
|
|
|
|
|
}
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
2021-09-01 06:12:16 +00:00
|
|
|
|
|
|
|
|
EditorGuiToolbarStack.remove( EWorldEditorToolbar );
|
|
|
|
|
EditorGuiToolbarStack.add( ShapeEditorToolbar );
|
2024-12-29 21:59:08 +00:00
|
|
|
EditorGui.SetShapePalletBar();
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ShapeEditorPlugin::initStatusBar(%this)
|
|
|
|
|
{
|
|
|
|
|
EditorGuiStatusBar.setInfo("Shape editor ( Shift Click ) to speed up camera.");
|
|
|
|
|
EditorGuiStatusBar.setSelection( ShapeEditor.shape.baseShape );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ShapeEditorPlugin::onDeactivated(%this)
|
|
|
|
|
{
|
|
|
|
|
%this.writeSettings();
|
|
|
|
|
|
|
|
|
|
// Notify game objects if shape has been modified
|
|
|
|
|
if ( ShapeEditor.isDirty() )
|
|
|
|
|
ShapeEditor.shape.notifyShapeChanged();
|
|
|
|
|
|
|
|
|
|
$gfx::wireframe = $wasInWireFrameMode;
|
|
|
|
|
|
|
|
|
|
ShapeEdMaterials.updateSelectedMaterial(false);
|
2021-09-01 06:12:16 +00:00
|
|
|
|
|
|
|
|
EditorGuiToolbarStack.add( EWorldEditorToolbar );
|
|
|
|
|
EditorGuiToolbarStack.remove( ShapeEditorToolbar );
|
2017-02-24 08:40:56 +00:00
|
|
|
|
|
|
|
|
ShapeEdPreviewGui.setVisible(false);
|
|
|
|
|
ShapeEdSelectWindow.setVisible(false);
|
|
|
|
|
ShapeEdPropWindow.setVisible(false);
|
|
|
|
|
ShapeEdAnimWindow.setVisible(false);
|
|
|
|
|
ShapeEdAdvancedWindow.setVisible(false);
|
|
|
|
|
|
|
|
|
|
if( EditorGui-->MatEdPropertiesWindow.visible )
|
|
|
|
|
{
|
|
|
|
|
ShapeEdMaterials.editSelectedMaterialEnd( true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%this.map.pop();
|
|
|
|
|
|
|
|
|
|
// Restore the original undo manager
|
|
|
|
|
Editor.setUndoManager( %this.oldUndoMgr );
|
|
|
|
|
|
|
|
|
|
// Restore menu bar
|
|
|
|
|
%this.replaceMenuCmd( "Camera", 8, %this.oldCamFitCmd );
|
|
|
|
|
%this.replaceMenuCmd( "Camera", 9, %this.oldCamFitOrbitCmd );
|
|
|
|
|
|
|
|
|
|
Parent::onDeactivated(%this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ShapeEditorPlugin::onExitMission( %this )
|
|
|
|
|
{
|
|
|
|
|
// unselect the current shape
|
|
|
|
|
ShapeEdShapeView.setModel( "" );
|
2025-08-26 04:42:58 +00:00
|
|
|
if (ShapeEditor.shape != 0 && ShapeEditor.shape != -1)
|
2017-02-24 08:40:56 +00:00
|
|
|
ShapeEditor.shape.delete();
|
|
|
|
|
ShapeEditor.shape = 0;
|
|
|
|
|
ShapeEdUndoManager.clearAll();
|
|
|
|
|
ShapeEditor.setDirty( false );
|
|
|
|
|
|
|
|
|
|
ShapeEdSequenceList.clear();
|
|
|
|
|
ShapeEdNodeTreeView.removeItem( 0 );
|
|
|
|
|
ShapeEdPropWindow.update_onNodeSelectionChanged( -1 );
|
|
|
|
|
ShapeEdDetailTree.removeItem( 0 );
|
|
|
|
|
ShapeEdMaterialList.clear();
|
|
|
|
|
|
|
|
|
|
ShapeEdMountWindow-->mountList.clear();
|
|
|
|
|
ShapeEdThreadWindow-->seqList.clear();
|
|
|
|
|
ShapeEdThreadList.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ShapeEditorPlugin::openShape( %this, %path, %discardChangesToCurrent )
|
|
|
|
|
{
|
|
|
|
|
EditorGui.setEditor( ShapeEditorPlugin );
|
|
|
|
|
|
|
|
|
|
if( ShapeEditor.isDirty() && !%discardChangesToCurrent )
|
|
|
|
|
{
|
2020-07-24 05:40:03 +00:00
|
|
|
toolsMessageBoxYesNo( "Save Changes?",
|
2017-02-24 08:40:56 +00:00
|
|
|
"Save changes to current shape?",
|
|
|
|
|
"ShapeEditor.saveChanges(); ShapeEditorPlugin.openShape(\"" @ %path @ "\");",
|
|
|
|
|
"ShapeEditorPlugin.openShape(\"" @ %path @ "\");" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShapeEditor.selectShape( %path );
|
|
|
|
|
ShapeEdShapeView.fitToShape();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function shapeEditorWireframeMode()
|
|
|
|
|
{
|
|
|
|
|
$gfx::wireframe = !$gfx::wireframe;
|
|
|
|
|
ShapeEditorToolbar-->wireframeMode.setStateOn($gfx::wireframe);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Settings
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
function ShapeEditorPlugin::initSettings( %this )
|
|
|
|
|
{
|
|
|
|
|
EditorSettings.beginGroup( "ShapeEditor", true );
|
|
|
|
|
|
|
|
|
|
// Display options
|
2024-02-10 20:49:54 +00:00
|
|
|
EditorSettings.setDefaultValue( "BackgroundColor", "128 128 128 100" );
|
2017-02-24 08:40:56 +00:00
|
|
|
EditorSettings.setDefaultValue( "HighlightMaterial", 1 );
|
|
|
|
|
EditorSettings.setDefaultValue( "ShowNodes", 1 );
|
|
|
|
|
EditorSettings.setDefaultValue( "ShowBounds", 0 );
|
|
|
|
|
EditorSettings.setDefaultValue( "ShowObjBox", 1 );
|
|
|
|
|
EditorSettings.setDefaultValue( "RenderMounts", 1 );
|
|
|
|
|
EditorSettings.setDefaultValue( "RenderCollision", 0 );
|
|
|
|
|
|
|
|
|
|
// Grid
|
|
|
|
|
EditorSettings.setDefaultValue( "ShowGrid", 1 );
|
|
|
|
|
EditorSettings.setDefaultValue( "GridSize", 0.1 );
|
|
|
|
|
EditorSettings.setDefaultValue( "GridDimension", "40 40" );
|
|
|
|
|
|
|
|
|
|
// Sun
|
|
|
|
|
EditorSettings.setDefaultValue( "SunDiffuseColor", "255 255 255 255" );
|
|
|
|
|
EditorSettings.setDefaultValue( "SunAmbientColor", "180 180 180 255" );
|
|
|
|
|
EditorSettings.setDefaultValue( "SunAngleX", "45" );
|
|
|
|
|
EditorSettings.setDefaultValue( "SunAngleZ", "135" );
|
|
|
|
|
|
|
|
|
|
// Sub-windows
|
|
|
|
|
EditorSettings.setDefaultValue( "AdvancedWndVisible", "1" );
|
|
|
|
|
|
|
|
|
|
EditorSettings.endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ShapeEditorPlugin::readSettings( %this )
|
|
|
|
|
{
|
|
|
|
|
EditorSettings.beginGroup( "ShapeEditor", true );
|
|
|
|
|
|
|
|
|
|
// Display options
|
|
|
|
|
ShapeEdPreviewGui-->previewBackground.color = ColorIntToFloat( EditorSettings.value("BackgroundColor") );
|
|
|
|
|
SetToggleButtonValue( ShapeEdMaterials-->highlightMaterial, EditorSettings.value( "HighlightMaterial" ) );
|
|
|
|
|
SetToggleButtonValue( ShapeEditorToolbar-->showNodes, EditorSettings.value( "ShowNodes" ) );
|
|
|
|
|
SetToggleButtonValue( ShapeEditorToolbar-->showBounds, EditorSettings.value( "ShowBounds" ) );
|
|
|
|
|
SetToggleButtonValue( ShapeEditorToolbar-->showObjBox, EditorSettings.value( "ShowObjBox" ) );
|
|
|
|
|
SetToggleButtonValue( ShapeEditorToolbar-->renderColMeshes, EditorSettings.value( "RenderCollision" ) );
|
|
|
|
|
SetToggleButtonValue( ShapeEdMountWindow-->renderMounts, EditorSettings.value( "RenderMounts" ) );
|
|
|
|
|
|
|
|
|
|
// Grid
|
|
|
|
|
SetToggleButtonValue( ShapeEditorToolbar-->showGridBtn, EditorSettings.value( "ShowGrid" ) );
|
|
|
|
|
ShapeEdShapeView.gridSize = EditorSettings.value( "GridSize" );
|
|
|
|
|
ShapeEdShapeView.gridDimension = EditorSettings.value( "GridDimension" );
|
|
|
|
|
|
|
|
|
|
// Sun
|
|
|
|
|
ShapeEdShapeView.sunDiffuse = EditorSettings.value("SunDiffuseColor");
|
|
|
|
|
ShapeEdShapeView.sunAmbient = EditorSettings.value("SunAmbientColor");
|
|
|
|
|
|
|
|
|
|
// Sub-windows
|
|
|
|
|
SetToggleButtonValue( ShapeEditorToolbar-->showAdvanced, EditorSettings.value( "AdvancedWndVisible" ) );
|
|
|
|
|
|
|
|
|
|
EditorSettings.endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ShapeEditorPlugin::writeSettings( %this )
|
|
|
|
|
{
|
|
|
|
|
EditorSettings.beginGroup( "ShapeEditor", true );
|
|
|
|
|
|
|
|
|
|
// Display options
|
|
|
|
|
EditorSettings.setValue( "BackgroundColor", ColorFloatToInt( ShapeEdPreviewGui-->previewBackground.color ) );
|
|
|
|
|
EditorSettings.setValue( "HighlightMaterial", ShapeEdMaterials-->highlightMaterial.getValue() );
|
|
|
|
|
EditorSettings.setValue( "ShowNodes", ShapeEditorToolbar-->showNodes.getValue() );
|
|
|
|
|
EditorSettings.setValue( "ShowBounds", ShapeEditorToolbar-->showBounds.getValue() );
|
|
|
|
|
EditorSettings.setValue( "ShowObjBox", ShapeEditorToolbar-->showObjBox.getValue() );
|
|
|
|
|
EditorSettings.setValue( "RenderCollision", ShapeEditorToolbar-->renderColMeshes.getValue() );
|
|
|
|
|
EditorSettings.setValue( "RenderMounts", ShapeEdMountWindow-->renderMounts.getValue() );
|
|
|
|
|
|
|
|
|
|
// Grid
|
|
|
|
|
EditorSettings.setValue( "ShowGrid", ShapeEditorToolbar-->showGridBtn.getValue() );
|
|
|
|
|
EditorSettings.setValue( "GridSize", ShapeEdShapeView.gridSize );
|
|
|
|
|
EditorSettings.setValue( "GridDimension", ShapeEdShapeView.gridDimension );
|
|
|
|
|
|
|
|
|
|
// Sun
|
|
|
|
|
EditorSettings.setValue( "SunDiffuseColor", ShapeEdShapeView.sunDiffuse );
|
|
|
|
|
EditorSettings.setValue( "SunAmbientColor", ShapeEdShapeView.sunAmbient );
|
|
|
|
|
EditorSettings.setValue( "SunAngleX", ShapeEdShapeView.sunAngleX );
|
|
|
|
|
EditorSettings.setValue( "SunAngleZ", ShapeEdShapeView.sunAngleZ );
|
|
|
|
|
|
|
|
|
|
// Sub-windows
|
|
|
|
|
EditorSettings.setValue( "AdvancedWndVisible", ShapeEditorToolbar-->showAdvanced.getValue() );
|
|
|
|
|
|
|
|
|
|
EditorSettings.endGroup();
|
|
|
|
|
}
|