mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
(Mostly) updated verve implementation.
This commit is contained in:
parent
775ca57047
commit
87ee749801
538 changed files with 68727 additions and 49 deletions
228
Templates/BaseGame/game/tools/VPathEditor/Scripts/Editor.cs
Normal file
228
Templates/BaseGame/game/tools/VPathEditor/Scripts/Editor.cs
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) - Violent Tulip
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function EVPathEditor::onDeleteKey( %this )
|
||||
{
|
||||
%editPath = EVPathEditor.getSelectedPath();
|
||||
%editNode = EVPathEditor.getSelectedNode();
|
||||
if ( isObject( %editPath ) && %editNode != -1 )
|
||||
{
|
||||
// Delete the Node.
|
||||
%this.deleteSelection();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear Selection.
|
||||
%this.clearSelection();
|
||||
|
||||
// Delete the Path.
|
||||
MEDeleteUndoAction::submit( %editPath );
|
||||
}
|
||||
}
|
||||
|
||||
function EVPathEditor::onUpdateSelection( %this, %editPath, %editNode )
|
||||
{
|
||||
// Clear World Editor Selection.
|
||||
EWorldEditor.clearSelection();
|
||||
|
||||
%clearNode = true;
|
||||
if ( isObject( %editPath ) )
|
||||
{
|
||||
// Reset Type.
|
||||
VPathEditorToolbarPathTypeMenu.setText( %editPath.PathType );
|
||||
|
||||
// Set World Editor Selection.
|
||||
EWorldEditor.selectObject( %editPath );
|
||||
|
||||
// Inspect.
|
||||
VPathInspector.inspect( %editPath );
|
||||
|
||||
// Update the Node Inspector.
|
||||
if ( %editNode != -1 )
|
||||
{
|
||||
// Valid Node.
|
||||
%clearNode = false;
|
||||
|
||||
VPathEditorOptionsWindow-->position.setActive( true );
|
||||
VPathEditorOptionsWindow-->position.setValue( %editPath.getNodeLocalPosition( %editNode ) );
|
||||
|
||||
VPathEditorOptionsWindow-->rotation.setActive( true );
|
||||
VPathEditorOptionsWindow-->rotation.setValue( %editPath.getNodeLocalRotation( %editNode ) );
|
||||
|
||||
VPathEditorOptionsWindow-->weight.setActive( true );
|
||||
VPathEditorOptionsWindow-->weight.setValue( %editPath.getNodeWeight( %editNode ) );
|
||||
|
||||
%orientationMode = %editPath.getNodeOrientationMode( %editNode );
|
||||
%orientationType = EPathEditorNodeOrientationMode.findText( strupr( getField( %orientationMode, 0 ) ) );
|
||||
%orientationData = getField( %orientationMode, 1 );
|
||||
|
||||
EPathEditorNodeOrientationMode.setSelected( %orientationType, false );
|
||||
EPathEditorNodeOrientationData.Text = %orientationData;
|
||||
}
|
||||
}
|
||||
|
||||
// Invalid Node?
|
||||
if ( %clearNode )
|
||||
{
|
||||
VPathEditorOptionsWindow-->position.setActive( false );
|
||||
VPathEditorOptionsWindow-->position.setValue( "" );
|
||||
|
||||
VPathEditorOptionsWindow-->rotation.setActive( true );
|
||||
VPathEditorOptionsWindow-->rotation.setValue( "" );
|
||||
|
||||
VPathEditorOptionsWindow-->weight.setActive( true );
|
||||
VPathEditorOptionsWindow-->weight.setValue( "" );
|
||||
}
|
||||
}
|
||||
|
||||
function VPathEditorToolbarPathTypeMenu::onSelect( %this )
|
||||
{
|
||||
%editPath = EVPathEditor.getSelectedPath();
|
||||
if ( isObject( %editPath ) )
|
||||
{
|
||||
// Apply Type.
|
||||
%editPath.PathType = %this.getText();
|
||||
}
|
||||
}
|
||||
|
||||
function VPathTreeView::onInspect( %this, %object )
|
||||
{
|
||||
// VPath?
|
||||
if ( !%object.isMemberOfClass( "VPath" ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Select Object.
|
||||
EVPathEditor.setSelection( %object );
|
||||
}
|
||||
|
||||
function VPathTreeView::DeleteSelectedPaths( %this )
|
||||
{
|
||||
// Clear the Selection.
|
||||
EVPathEditor.clearSelection();
|
||||
|
||||
// Iterate over Selection.
|
||||
%selectionList = %this.getSelectedItemList();
|
||||
%selectionCount = getWordCount( %selectionList );
|
||||
for ( %i = 0; %i < %selectionCount; %i++ )
|
||||
{
|
||||
// Fetch Index.
|
||||
%itemIndex = getWord( %selectionList, %i );
|
||||
|
||||
// Fetch Object.
|
||||
%itemObject = %this.getItemValue( %itemIndex );
|
||||
|
||||
// Skip Non-Path Objects.
|
||||
if ( !%itemObject.isMemberOfClass( "VPath" ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Delete the Object.
|
||||
MEDeleteUndoAction::submit( %itemObject );
|
||||
}
|
||||
|
||||
// Clear the Selection.
|
||||
%this.clearSelection();
|
||||
EVPathEditor.clearSelection();
|
||||
|
||||
// Build the Tree.
|
||||
%this.open( GetServerPathSet(), true );
|
||||
}
|
||||
|
||||
function VPathTreeView::CreatePath( %this )
|
||||
{
|
||||
// Create Path Object.
|
||||
EWCreatorWindow.createObject( "ObjectBuilderGui.buildObject( \"VPath\" );" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Node Editing
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function EVPathEditor::onUpdateNode( %this, %editPath, %editNode, %selected )
|
||||
{
|
||||
if ( %selected )
|
||||
{
|
||||
%this.onUpdateNodePosition( %editPath, %editNode, %selected );
|
||||
%this.onUpdateNodeRotation( %editPath, %editNode, %selected );
|
||||
%this.onUpdateNodeWeight( %editPath, %editNode, %selected );
|
||||
%this.onUpdateNodeOrientation( %editPath, %editNode, %selected );
|
||||
}
|
||||
}
|
||||
|
||||
function EVPathEditor::onUpdateNodePosition( %this, %editPath, %editNode, %selected )
|
||||
{
|
||||
if ( %selected )
|
||||
{
|
||||
VPathEditorOptionsWindow-->position.setValue( %editPath.getNodeLocalPosition( %editNode ) );
|
||||
}
|
||||
}
|
||||
|
||||
function EVPathEditor::onUpdateNodeRotation( %this, %editPath, %editNode, %selected )
|
||||
{
|
||||
if ( %selected )
|
||||
{
|
||||
VPathEditorOptionsWindow-->rotation.setValue( %editPath.getNodeLocalRotation( %editNode ) );
|
||||
}
|
||||
}
|
||||
|
||||
function EVPathEditor::onUpdateNodeWeight( %this, %editPath, %editNode, %selected )
|
||||
{
|
||||
if ( %selected )
|
||||
{
|
||||
VPathEditorOptionsWindow-->weight.setValue( %editPath.getNodeWeight( %editNode ) );
|
||||
}
|
||||
}
|
||||
|
||||
function EVPathEditor::onUpdateNodeOrientation( %this, %editPath, %editNode, %selected )
|
||||
{
|
||||
if ( %selected )
|
||||
{
|
||||
%orientationMode = %editPath.getNodeOrientationMode( %editNode );
|
||||
%orientationType = EPathEditorNodeOrientationMode.findText( strupr( getField( %orientationMode, 0 ) ) );
|
||||
%orientationData = getField( %orientationMode, 1 );
|
||||
|
||||
// Change?
|
||||
if ( EPathEditorNodeOrientationMode.getSelected() != %orientationType )
|
||||
{
|
||||
// Update.
|
||||
EPathEditorNodeOrientationMode.setSelected( %orientationType );
|
||||
}
|
||||
|
||||
// Change?
|
||||
if ( EPathEditorNodeOrientationData.getText() !$= %orientationData )
|
||||
{
|
||||
// Update.
|
||||
EPathEditorNodeOrientationData.setText( %orientationData );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Inspector
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function VPathInspector::inspect( %this, %obj )
|
||||
{
|
||||
VPathFieldInfoControl.setText( "" );
|
||||
Parent::inspect( %this, %obj );
|
||||
}
|
||||
|
||||
function VPathInspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue )
|
||||
{
|
||||
// Same work to do as for the regular WorldEditor Inspector.
|
||||
Inspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue );
|
||||
}
|
||||
|
||||
function VPathInspector::onFieldSelected( %this, %fieldName, %fieldTypeStr, %fieldDoc )
|
||||
{
|
||||
VPathFieldInfoControl.setText( "<font:ArialBold:14>" @ %fieldName @ "<font:ArialItalic:14> (" @ %fieldTypeStr @ ") " NL "<font:Arial:14>" @ %fieldDoc );
|
||||
}
|
||||
178
Templates/BaseGame/game/tools/VPathEditor/Scripts/Plugin.cs
Normal file
178
Templates/BaseGame/game/tools/VPathEditor/Scripts/Plugin.cs
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) - Violent Tulip
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
new ScriptObject( VPathEditorPlugin )
|
||||
{
|
||||
SuperClass = "EditorPlugin";
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function VPathEditorPlugin::onWorldEditorStartup( %this )
|
||||
{
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Editor Init
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
EditorGui.add( EVPathEditor );
|
||||
EVPathEditor.setVisible( false );
|
||||
|
||||
%this.EditorMap = new ActionMap();
|
||||
%this.EditorMap.bindCmd( keyboard, "backspace", "EVPathEditor.onDeleteKey();", "" );
|
||||
%this.EditorMap.bindCmd( keyboard, "delete", "EVPathEditor.onDeleteKey();", "" );
|
||||
%this.EditorMap.bindCmd( keyboard, "1", "EVPathEditorSelectButton.performClick();", "" );
|
||||
%this.EditorMap.bindCmd( keyboard, "2", "EVPathEditorMoveButton.performClick();", "" );
|
||||
%this.EditorMap.bindCmd( keyboard, "3", "EVPathEditorRotateButton.performClick();", "" );
|
||||
%this.EditorMap.bindCmd( keyboard, "4", "EVPathEditorScaleButton.performClick();", "" );
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Editor Toggles
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Add ourselves to the window menu.
|
||||
%accel = EditorGui.addToEditorsMenu( "Path Editor", "", VPathEditorPlugin );
|
||||
|
||||
// Add ourselves to the ToolsToolbar
|
||||
%tooltip = "Path Editor (" @ %accel @ ")";
|
||||
EditorGui.addToToolsToolbar( "VPathEditorPlugin", "VPathEditorPalette", expandFilename( "tools/VPathEditor/GUI/Images/btn_Palette" ), %tooltip );
|
||||
|
||||
// Find and Store the Button.
|
||||
%this.ToolbarButton = ToolsToolbarArray.findObjectByInternalName( "VPathEditorPalette", false );
|
||||
|
||||
// Extend Width.
|
||||
%extent = EWToolsToolbar.getExtent();
|
||||
EWToolsToolbar.setExtent( ( getWord( %extent, 0 ) + 33 ) SPC getWord( %extent, 1 ) );
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Initialise Toolbar
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
if ( !isObject( VPathEditorToolbar ) )
|
||||
{
|
||||
exec( "~/VPathEditor/GUI/VPathEditorToolbar.gui" );
|
||||
}
|
||||
|
||||
// Add Toolbar.
|
||||
EditorGuiToolbar.add( VPathEditorToolbar );
|
||||
|
||||
// Populate Type Menu.
|
||||
VPathEditorToolbarPathTypeMenu.clear();
|
||||
VPathEditorToolbarPathTypeMenu.add( "BEZIER", 0 );
|
||||
VPathEditorToolbarPathTypeMenu.add( "LINEAR", 1 );
|
||||
VPathEditorToolbarPathTypeMenu.setFirstSelected();
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Initialise Editor Palette
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
if ( !isObject( VPathEditorPalette ) )
|
||||
{
|
||||
exec( "~/VPathEditor/GUI/VPathEditorPalette.gui" );
|
||||
}
|
||||
|
||||
// Use Existing Group Number + 1.
|
||||
%groupNum = ToolsPaletteArray.getObject( ToolsPaletteArray.getCount() - 1 ).GroupNum + 1;
|
||||
|
||||
%paletteGroup = VPathEditorPalette;
|
||||
while ( VPathEditorPalette.getCount() > 0 )
|
||||
{
|
||||
// Fetch Button.
|
||||
%paletteButton = %paletteGroup.getObject( 0 );
|
||||
|
||||
// Setup.
|
||||
%paletteButton.Visible = false;
|
||||
%paletteButton.GroupNum = %groupNum;
|
||||
%paletteButton.PaletteName = VPathEditorPalette;
|
||||
|
||||
// Add To Palette Array.
|
||||
ToolsPaletteArray.addGuiControl( %paletteButton );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Initialise Library
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
EWCreatorWindow.registerMissionObject( "VPath", "VPath", "", "Level" );
|
||||
}
|
||||
|
||||
//EditorGui.setEditor(\"VPathEditorPlugin\");
|
||||
function VPathEditorPlugin::onActivated( %this )
|
||||
{
|
||||
if ( !isObject( EVPathEditor ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Display Editor.
|
||||
EVPathEditor.setVisible( true );
|
||||
EVPathEditor.makeFirstResponder( true );
|
||||
EditorGui.bringToFront( EVPathEditor );
|
||||
VPathEditorToolbar.setVisible( true );
|
||||
VPathTreeView.open( GetServerPathSet(), true );
|
||||
|
||||
// Sync Gizmo.
|
||||
%this.syncGizmo();
|
||||
|
||||
// Enable Map.
|
||||
%this.EditorMap.push();
|
||||
|
||||
// Valid Selection?
|
||||
if ( EWorldEditor.getSelectionSize() )
|
||||
{
|
||||
%selection = EWorldEditor.getSelectedObject( 0 );
|
||||
if ( isObject( %selection ) && %selection.isMemberOfClass( "VPath" ) )
|
||||
{
|
||||
// Select Object.
|
||||
EVPathEditor.setSelection( %selection );
|
||||
}
|
||||
}
|
||||
|
||||
// Parent Call.
|
||||
Parent::onActivated( %this );
|
||||
}
|
||||
|
||||
function VPathEditorPlugin::onDeactivated( %this )
|
||||
{
|
||||
// Hide Editor.
|
||||
EVPathEditor.setVisible( false );
|
||||
VPathEditorToolbar.setVisible( false );
|
||||
|
||||
// Disable Map.
|
||||
%this.EditorMap.pop();
|
||||
|
||||
// Parent Call.
|
||||
Parent::onDeactivated( %this );
|
||||
}
|
||||
|
||||
function VPathEditorPlugin::isDirty( %this )
|
||||
{
|
||||
return EVPathEditor.isDirty;
|
||||
}
|
||||
|
||||
function VPathEditorPlugin::clearDirty( %this )
|
||||
{
|
||||
EVPathEditor.isDirty = false;
|
||||
}
|
||||
|
||||
function VPathEditorPlugin::syncGizmo( %this )
|
||||
{
|
||||
switch$( GlobalGizmoProfile.Mode )
|
||||
{
|
||||
case "None" : EVPathEditorSelectButton.performClick();
|
||||
case "Move" : EVPathEditorMoveButton.performClick();
|
||||
case "Rotate" : EVPathEditorRotateButton.performClick();
|
||||
case "Scale" : EVPathEditorScaleButton.performClick();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue