瀏覽代碼

Merge pull request #576 from JeffProgrammer/more-eval-cleanups

Clean up more evals that have local variables are not working correctly.
Brian Roberts 4 年之前
父節點
當前提交
4effefce91

+ 1 - 1
Templates/BaseGame/game/tools/VerveEditor/Scripts/Inspector/Controls.tscript

@@ -123,7 +123,7 @@ function VerveEditor::CreateField( %targetStack, %fieldName, %fieldType )
     if ( isMethod( "VerveEditor", "Create" @ %fieldType @ "Field" ) )
     {
         // Create the Input Control.
-        eval( "%fieldInput = VerveEditor::Create" @ %fieldType @ "Field( %fieldContainer, %fieldName );" );
+        %fieldInput = eval( "return VerveEditor::Create" @ %fieldType @ "Field( %fieldContainer, %fieldName );" );
     }
     else
     {

+ 2 - 4
Templates/BaseGame/game/tools/gui/materialSelector.ed.gui

@@ -1420,15 +1420,13 @@ function MaterialSelector::updateSelection( %this, %material, %previewImagePath
    // after we move away from the material. eg: if we remove a field from the material,
    // the empty checkbox will still be there until you move fro and to the material again
    
-   %isMaterialBorder = 0;
-   eval("%isMaterialBorder = isObject(MaterialSelector-->"@%material@"Border);");
+   %isMaterialBorder = eval("return isObject(MaterialSelector-->"@%material@"Border);");
    if( %isMaterialBorder )
    {
       eval( "MaterialSelector-->"@%material@"Border.setStateOn(1);");
    }
       
-   %isMaterialBorderPrevious = 0;
-   eval("%isMaterialBorderPrevious = isObject(MaterialSelector-->"@$prevSelectedMaterialHL@"Border);");
+   %isMaterialBorderPrevious = eval("return isObject(MaterialSelector-->"@$prevSelectedMaterialHL@"Border);");
    if( %isMaterialBorderPrevious )
    {
       eval( "MaterialSelector-->"@$prevSelectedMaterialHL@"Border.setStateOn(0);");

+ 1 - 1
Templates/BaseGame/game/tools/gui/scriptEditorDlg.ed.gui

@@ -205,7 +205,7 @@ function _TextPadOnOk()
    if(ScriptEditorDlg.callback !$= "")
    {
       %text = ScriptEditorDlg-->textpad.getText();
-      %command  = ScriptEditorDlg.callback @ "( %text );";
+      %command  = ScriptEditorDlg.callback @ "(\"" @ expandEscape(%text) @ "\");";
       eval(%command);
    }
    ScriptEditorDlg.callback = "";

+ 6 - 6
Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.tscript

@@ -1124,13 +1124,13 @@ function MaterialEditorGui::updateActiveMaterial(%this, %propertyField, %value,
       MaterialEditorGui.submitUndo( %action );
    }
    
-   eval("materialEd_previewMaterial." @ %propertyField @ " = " @ %value @ ";");
+   materialEd_previewMaterial.setFieldValue(%propertyField, %value);
    materialEd_previewMaterial.flush();
    materialEd_previewMaterial.reload();
    
    if (MaterialEditorGui.livePreview == true)
    {
-      eval("MaterialEditorGui.currentMaterial." @ %propertyField @ " = " @ %value @ ";");
+      MaterialEditorGui.setFieldValue(%propertyField, %value);
       MaterialEditorGui.currentMaterial.flush();
       MaterialEditorGui.currentMaterial.reload();
    }
@@ -1173,7 +1173,7 @@ function MaterialEditorGui::updateMaterialReferences( %this, %obj, %oldName, %ne
          %fieldName = %obj.getField( %i );
          if ( ( %obj.getFieldType( %fieldName ) $= "TypeMaterialName" ) && ( %obj.getFieldValue( %fieldName ) $= %oldName ) )
          {
-            eval( %obj @ "." @ %fieldName @ " = " @ %newName @ ";" );
+            %obj.setFieldValue(%fieldName, %newName);
             %objChanged = true;
          }
       }
@@ -1431,13 +1431,13 @@ function MaterialEditorGui::updateAnimationFlags(%this)
    %action.oldValue = %oldFlags;
    MaterialEditorGui.submitUndo( %action );
    
-   eval("materialEd_previewMaterial.animFlags[" @ MaterialEditorGui.currentLayer @ "] = " @ %flags @ ";");
+   materialEd_previewMaterial.animFlags[MaterialEditorGui.currentLayer] = %flags;
    materialEd_previewMaterial.flush();
    materialEd_previewMaterial.reload();
    
    if (MaterialEditorGui.livePreview == true)
    {
-      eval("MaterialEditorGui.currentMaterial.animFlags[" @ MaterialEditorGui.currentLayer @ "] = " @ %flags @ ";");
+      MaterialEditorGui.currentMaterial.animFlags[MaterialEditorGui.currentLayer] = %flags;
       MaterialEditorGui.currentMaterial.flush();
       MaterialEditorGui.currentMaterial.reload();
    }
@@ -2324,7 +2324,7 @@ function MaterialEditorGui::changeMaterial(%this, %fromMaterial, %toMaterial)
    {
       %action.mode = "editorShapes";
 
-      eval("MaterialEditorGui.currentObject." @ SubMaterialSelector.getText() @ " = " @ %toMaterial.getName() @ ";");
+      MaterialEditorGui.currentObject.setFieldValue(SubMaterialSelector.getText(), %toMaterial.getName());
       if( MaterialEditorGui.currentObject.isMethod("postApply") )
          MaterialEditorGui.currentObject.postApply();
       

+ 15 - 15
Templates/BaseGame/game/tools/materialEditor/scripts/materialEditorUndo.ed.tscript

@@ -62,13 +62,13 @@ function ActionUpdateActiveMaterial::redo(%this)
          MaterialEditorGui.setActiveMaterial(%this.material);
       }
       */
-      eval("materialEd_previewMaterial." @ %this.field @ " = " @ %this.newValue @ ";");
+      materialEd_previewMaterial.setFieldValue(%this.field, %this.newValue);
       materialEd_previewMaterial.flush();
       materialEd_previewMaterial.reload();
       
       if (MaterialEditorGui.livePreview == true)
       {
-         eval("%this.material." @ %this.field @ " = " @ %this.newValue @ ";");
+         %this.material.setFieldValue(%this.field, %this.newValue);
          MaterialEditorGui.currentMaterial.flush();
          MaterialEditorGui.currentMaterial.reload();
       }      
@@ -80,7 +80,7 @@ function ActionUpdateActiveMaterial::redo(%this)
    }
    else
    {
-      eval("%this.material." @ %this.field @ " = " @ %this.newValue @ ";");
+      %this.material.setFieldValue(%this.field, %this.newValue);
       %this.material.flush();
       %this.material.reload();
    }
@@ -100,13 +100,13 @@ function ActionUpdateActiveMaterial::undo(%this)
       }
       */
       
-      eval("materialEd_previewMaterial." @ %this.field @ " = " @ %this.oldValue @ ";");
+      materialEd_previewMaterial.setFieldValue(%this.field, %this.oldValue);
       materialEd_previewMaterial.flush();
       materialEd_previewMaterial.reload();
       
       if (MaterialEditorGui.livePreview == true)
       {
-         eval("%this.material." @ %this.field @ " = " @ %this.oldValue @ ";");
+         %this.material.setFieldValue(%this.field, %this.oldValue);
          MaterialEditorGui.currentMaterial.flush();
          MaterialEditorGui.currentMaterial.reload();
       }
@@ -115,7 +115,7 @@ function ActionUpdateActiveMaterial::undo(%this)
    }
    else
    {
-      eval("%this.material." @ %this.field @ " = " @ %this.oldValue @ ";");
+      %this.material.setFieldValue(%this.field, %this.oldValue);
       %this.material.flush();
       %this.material.reload();
    }
@@ -138,13 +138,13 @@ function ActionUpdateActiveMaterialAnimationFlags::redo(%this)
       }
       */
       
-      eval("materialEd_previewMaterial.animFlags[" @ %this.layer @ "] = " @ %this.newValue @ ";");
+      materialEd_previewMaterial.animFlags[%this.layer] = %this.newValue;
       materialEd_previewMaterial.flush();
       materialEd_previewMaterial.reload();
       
       if (MaterialEditorGui.livePreview == true)
       {
-         eval("%this.material.animFlags[" @ %this.layer @ "] = " @ %this.newValue @ ";");
+         %this.material.animFlags[%this.layer] = %this.newValue;
          MaterialEditorGui.currentMaterial.flush();
          MaterialEditorGui.currentMaterial.reload();
       }
@@ -153,7 +153,7 @@ function ActionUpdateActiveMaterialAnimationFlags::redo(%this)
    }
    else
    {
-      eval("%this.material.animFlags[" @ %this.layer @ "] = " @ %this.newValue @ ";");
+      %this.material.animFlags[%this.layer] = %this.newValue;
       %this.material.flush();
       %this.material.reload();
    }
@@ -162,14 +162,14 @@ function ActionUpdateActiveMaterialAnimationFlags::redo(%this)
 function ActionUpdateActiveMaterialAnimationFlags::undo(%this)
 {
    if( MaterialEditorPreviewWindow.isVisible() && MaterialEditorGui.currentMaterial == %this.material )
-   {      
-      eval("materialEd_previewMaterial.animFlags[" @ %this.layer @ "] = " @ %this.oldValue @ ";");
+   {  
+      materialEd_previewMaterial.animFlags[%this.layer] = %this.oldValue;
       materialEd_previewMaterial.flush();
       materialEd_previewMaterial.reload();
       
       if (MaterialEditorGui.livePreview == true)
       {
-         eval("%this.material.animFlags[" @ %this.layer @ "] = " @ %this.oldValue @ ";");
+         %this.material.animFlags[%this.layer] = %this.oldValue;
          MaterialEditorGui.currentMaterial.flush();
          MaterialEditorGui.currentMaterial.reload();
       }
@@ -178,7 +178,7 @@ function ActionUpdateActiveMaterialAnimationFlags::undo(%this)
    }
    else
    {
-      eval("%this.material.animFlags[" @ %this.layer @ "] = " @ %this.oldValue @ ";");
+      %this.material.animFlags[%this.layer] = %this.oldValue;
       %this.material.flush();
       %this.material.reload();
    }
@@ -340,7 +340,7 @@ function ActionChangeMaterial::redo(%this)
    }
    else
    {
-      eval("%this.object." @ %this.materialTarget @ " = " @ %this.toMaterial.getName() @ ";");
+      %this.object.setFieldValue(%this.materialTarget, %this.toMaterial.getName());
       MaterialEditorGui.currentObject.postApply();
    }
    
@@ -372,7 +372,7 @@ function ActionChangeMaterial::undo(%this)
    }
    else
    {
-      eval("%this.object." @ %this.materialTarget @ " = " @ %this.fromMaterial.getName() @ ";");
+      %this.object.setFieldValue(%this.materialTarget, %this.fromMaterial.getName());
       MaterialEditorGui.currentObject.postApply();
    }
    

+ 2 - 2
Templates/BaseGame/game/tools/navEditor/navEditor.tscript

@@ -262,7 +262,7 @@ function NavEditorGui::findCover(%this)
       %pos = LocalClientConnection.getControlObject().getPosition();
       %text = NavEditorOptionsWindow-->TestProperties->CoverPosition.getText();
       if(%text !$= "")
-         %pos = eval(%text);
+         %pos = eval("return " @ %text);
       %this.getPlayer().findCover(%pos, NavEditorOptionsWindow-->TestProperties->CoverRadius.getText());
    }
 }
@@ -275,7 +275,7 @@ function NavEditorGui::followObject(%this)
       %text = NavEditorOptionsWindow-->TestProperties->FollowObject.getText();
       if(%text !$= "")
       {
-         eval("%obj = " @ %text);
+         %obj = eval("return " @ %text);
          if(!isObject(%obj))
             toolsMessageBoxOk("Error", "Cannot find object" SPC %text);
       }