Jelajahi Sumber

Merge pull request #1643 from Azaezel/TriggerTrouble

corrects https://github.com/GarageGames/Torque3D/issues/1273
Areloch 9 tahun lalu
induk
melakukan
80dcf3eba5

+ 16 - 9
Templates/Empty/game/tools/shapeEditor/scripts/shapeEditor.ed.cs

@@ -2206,15 +2206,22 @@ function ShapeEdTriggerList::updateItem( %this, %oldFrame, %oldState, %frame, %s
 
 function ShapeEdSequences::onAddTrigger( %this )
 {
-   // Can only add triggers if a sequence is selected
-   %seqName = ShapeEdSequenceList.getSelectedName();
-   if ( %seqName !$= "" )
-   {
-      // Add a new trigger at the current frame
-      %frame = mRound( ShapeEdSeqSlider.getValue() );
-      %state = ShapeEdTriggerList.rowCount() % 30;
-      ShapeEditor.doAddTrigger( %seqName, %frame, %state );
-   }
+    // Can only add triggers if a sequence is selected
+    %seqName = ShapeEdSequenceList.getSelectedName();
+    if ( %seqName !$= "" )
+    {
+        // Add a new trigger at the current frame
+        %frame = mRound( ShapeEdSeqSlider.getValue() ) - %this-->startFrame.getText();
+        if ((%frame < 0) || (%frame > %this-->endFrame.getText() - %this-->startFrame.getText()))
+        {
+            MessageBoxOK( "Error", "Trigger out of range of the selected animation." );
+        }
+        else
+        {
+        %state = ShapeEdTriggerList.rowCount() % 30;
+        ShapeEditor.doAddTrigger( %seqName, %frame, %state );
+        }
+    }
 }
 
 function ShapeEdTriggerList::onDeleteSelection( %this )

+ 16 - 9
Templates/Full/game/tools/shapeEditor/scripts/shapeEditor.ed.cs

@@ -2206,15 +2206,22 @@ function ShapeEdTriggerList::updateItem( %this, %oldFrame, %oldState, %frame, %s
 
 function ShapeEdSequences::onAddTrigger( %this )
 {
-   // Can only add triggers if a sequence is selected
-   %seqName = ShapeEdSequenceList.getSelectedName();
-   if ( %seqName !$= "" )
-   {
-      // Add a new trigger at the current frame
-      %frame = mRound( ShapeEdSeqSlider.getValue() );
-      %state = ShapeEdTriggerList.rowCount() % 30;
-      ShapeEditor.doAddTrigger( %seqName, %frame, %state );
-   }
+    // Can only add triggers if a sequence is selected
+    %seqName = ShapeEdSequenceList.getSelectedName();
+    if ( %seqName !$= "" )
+    {
+        // Add a new trigger at the current frame
+        %frame = mRound( ShapeEdSeqSlider.getValue() ) - %this-->startFrame.getText();
+        if ((%frame < 0) || (%frame > %this-->endFrame.getText() - %this-->startFrame.getText()))
+        {
+            MessageBoxOK( "Error", "Trigger out of range of the selected animation." );
+        }
+        else
+        {
+        %state = ShapeEdTriggerList.rowCount() % 30;
+        ShapeEditor.doAddTrigger( %seqName, %frame, %state );
+        }
+    }
 }
 
 function ShapeEdTriggerList::onDeleteSelection( %this )