Преглед на файлове

Updates the shape editor to support editing a shape via assetID, as well as adding support for shape animation assets being selected when adding a new animation sequence to a shape.

Areloch преди 7 години
родител
ревизия
5f5b90794e

+ 7 - 0
Templates/BaseGame/game/tools/shapeEditor/main.cs

@@ -145,6 +145,13 @@ function ShapeEditorPlugin::onWorldEditorStartup(%this)
    }
 }
 
+function ShapeEditorPlugin::openShapeAsset(%this, %assetId)
+{
+   %this.selectedAssetId = %assetId;
+   %this.selectedAssetDef = AssetDatabase.acquireAsset(%assetId);
+   %this.open(%this.selectedAssetDef.fileName);
+}
+
 function ShapeEditorPlugin::open(%this, %filename)
 {
    if ( !%this.isActivated )

+ 15 - 1
Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditor.ed.cs

@@ -611,6 +611,19 @@ function ShapeEdPropWindow::update_onShapeSelectionChanged( %this )
          ShapeEdSequenceList.addItem( %name );
    }
    ShapeEdThreadWindow.onAddThread();        // add thread 0
+   
+   //Now, fetch any animation assets if we're utilizing a shape asset
+   if(ShapeEditorPlugin.selectedAssetId !$= "")
+   {
+      %animationAssetCount = ShapeEditorPlugin.selectedAssetDef.getAnimationCount();
+      
+      for(%animIdx = 0; %animIdx < %animationAssetCount; %animIdx++)
+      {
+         %animAsset = ShapeEditorPlugin.selectedAssetDef.getAnimation(%animIdx);
+         
+         //ShapeEdSequenceList.addItem( %animAsset.assetName );
+      }
+   }
 
    // --- DETAILS TAB ---
    // Add detail levels and meshes to tree
@@ -789,7 +802,8 @@ function ShapeEdSeqNodeTabBook::onTabSelected( %this, %name, %index )
    {
       case "Seq":
          ShapeEdPropWindow-->newBtn.ToolTip = "Add new sequence";
-         ShapeEdPropWindow-->newBtn.Command = "ShapeEdSequences.onAddSequence();";
+         //ShapeEdPropWindow-->newBtn.Command = "ShapeEdSequences.onAddSequence();"; 
+         ShapeEdPropWindow-->newBtn.Command = "AssetBrowser.showDialog(\"ShapeAnimationAsset\", \"onAddAnimationAssetShapeEditor\", \"\", \"\", \"\");"; 
          ShapeEdPropWindow-->newBtn.setActive( true );
          ShapeEdPropWindow-->deleteBtn.ToolTip = "Delete selected sequence (cannot be undone)";
          ShapeEdPropWindow-->deleteBtn.Command = "ShapeEdSequences.onDeleteSequence();";

+ 40 - 13
Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditorActions.ed.cs

@@ -299,6 +299,12 @@ function ActionEditNodeTransform::undo( %this )
 
 //------------------------------------------------------------------------------
 // Add sequence
+function onAddAnimationAssetShapeEditor(%selectedAnimation)
+{
+   echo("SELECTED MUH ASSET");
+   ShapeEditor.doAddSequence(%selectedAnimation, 0, 0, 0);
+}
+
 function ShapeEditor::doAddSequence( %this, %seqName, %from, %start, %end )
 {
    %action = %this.createAction( ActionAddSequence, "Add sequence" );
@@ -313,23 +319,44 @@ function ShapeEditor::doAddSequence( %this, %seqName, %from, %start, %end )
 
 function ActionAddSequence::doit( %this )
 {
-   // If adding this sequence from an existing sequence, make a backup copy of
-   // the existing sequence first, so we can edit the start/end frames later
-   // without having to worry if the original source sequence has changed.
-   if ( ShapeEditor.shape.getSequenceIndex( %this.from ) >= 0 )
+   if(ShapeEditorPlugin.selectedAssetId $= "")
    {
-      %this.from = ShapeEditor.getUniqueName( "sequence", "__backup__" @ %this.origFrom @ "_" );
-      ShapeEditor.shape.addSequence( %this.origFrom, %this.from );
-   }
+      // If adding this sequence from an existing sequence, make a backup copy of
+      // the existing sequence first, so we can edit the start/end frames later
+      // without having to worry if the original source sequence has changed.
+      if ( ShapeEditor.shape.getSequenceIndex( %this.from ) >= 0 )
+      {
+         %this.from = ShapeEditor.getUniqueName( "sequence", "__backup__" @ %this.origFrom @ "_" );
+         ShapeEditor.shape.addSequence( %this.origFrom, %this.from );
+      }
 
-   // Add the sequence
-   $collada::forceLoadDAE = EditorSettings.value( "forceLoadDAE" );
-   %success = ShapeEditor.shape.addSequence( %this.from, %this.seqName, %this.start, %this.end );
-   $collada::forceLoadDAE = false;
+      // Add the sequence
+      $collada::forceLoadDAE = EditorSettings.value( "forceLoadDAE" );
+      %success = ShapeEditor.shape.addSequence( %this.from, %this.seqName, %this.start, %this.end );
+      $collada::forceLoadDAE = false;
 
-   if ( %success )
+      if ( %success )
+      {
+         ShapeEdPropWindow.update_onSequenceAdded( %this.seqName, -1 );
+         return true;
+      }
+   }
+   else
    {
-      ShapeEdPropWindow.update_onSequenceAdded( %this.seqName, -1 );
+      %assetDef = AssetDatabase.acquireAsset(%this.seqName);
+      %moduleName = getWord(getToken(%this.seqName, ":", 0),0);
+      
+      %idx = ShapeEdSequenceList.rowCount();
+      
+      %matSet = "ShapeEditorPlugin.selectedAssetDef.animationSequence"@%idx@"=\"@Asset="@%moduleName@":"@%this.seqName.assetName@"\";";
+      eval(%matSet);
+      
+      %assetPath = AssetDatabase.getAssetFilePath(ShapeEditorPlugin.selectedAssetId);
+      
+      %assetImportSuccessful = TAMLWrite(ShapeEditorPlugin.selectedAssetDef, %assetPath); 
+      
+      AssetDatabase.refreshAsset(ShapeEditorPlugin.selectedAssetId);
+      
       return true;
    }
    return false;