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

script fixes from latest merge and more tests

Jeff Hutchinson преди 4 години
родител
ревизия
838395840d

+ 53 - 0
Engine/source/console/test/ScriptTest.cpp

@@ -647,5 +647,58 @@ TEST(Script, Sugar_Syntax)
    ASSERT_EQ(valueSetArray.getInt(), 5);
 }
 
+TEST(Script, InnerObjectTests)
+{
+   ConsoleValue theObject = RunScript(R"(
+      function a()
+      {
+         %obj = new SimObject(TheOuterObject)
+         {
+            innerObject = new SimObject(TheInnerObject)
+            {
+               testField = 123;
+               position = "1 2 3";
+            };
+         };
+         return %obj;
+      }
+      return a();
+   )");
+
+   SimObject* outerObject = Sim::findObject("TheOuterObject");
+   ASSERT_NE(outerObject, (SimObject*)NULL);
+   if (outerObject)
+   {
+      ASSERT_EQ(theObject.getInt(), Sim::findObject("TheOuterObject")->getId());
+   }
+   ASSERT_NE(Sim::findObject("TheInnerObject"), (SimObject*)NULL);
+
+   ConsoleValue positionValue = RunScript(R"(
+      function TheOuterObject::getInnerPosition(%this)
+      {
+         return %this.innerObject.position;
+      }
+
+      function a()
+      {
+         %position = TheOuterObject.getInnerPosition();
+         return %position.y;
+      }
+      return a();
+   )");
+
+   ASSERT_EQ(positionValue.getInt(), 2);
+
+   ConsoleValue nestedFuncCall = RunScript(R"(
+      function TheInnerObject::test(%this)
+      {
+         return %this.testField;
+      }
+
+      return TheOuterObject.innerObject.test();
+   )");
+
+   ASSERT_EQ(nestedFuncCall.getInt(), 123);
+}
 
 #endif

+ 1 - 1
Templates/BaseGame/game/tools/projectImporter/guis/projectImporter.gui

@@ -1,5 +1,5 @@
 //--- OBJECT WRITE BEGIN ---
-%guiContent = new GuiControl(ProjectImportCtrl) {
+$guiContent = new GuiControl(ProjectImportCtrl) {
    position = "0 0";
    extent = "1024 768";
    minExtent = "8 2";

+ 4 - 3
Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript

@@ -70,7 +70,7 @@ function ProjectImportWindow::selectOGFolder(%this)
    %dlg = new OpenFolderDialog()
    {
       Title = "Select Export Folder";
-      Filters = %filter;
+      Filters = "";
       DefaultFile = "data/";
       ChangePath = false;
       MustExist = true;
@@ -588,7 +588,7 @@ function processLegacyShapeConstructorField(%line)
    if(%foundAssets != 0)
    {
       %assetId = $ProjectImporter::assetQuery.getAsset(0);
-      echo("Legacy Project Importer - processing of legacy shape constructor addSequence line's value: " @ %value @ " has found a matching AssetId: " @ %assetId);
+      echo("Legacy Project Importer - processing of legacy shape constructor addSequence line's value: " @ %animSourcePath @ " has found a matching AssetId: " @ %assetId);
    }
   
    if(%assetId !$= "" && AssetDatabase.isDeclaredAsset(%assetId))
@@ -981,6 +981,7 @@ function processGUIntoAsset(%guiName, %file)
    warn("Processing GUI into asset: " @ %guiName @ ", file: " @ %file);
    
    %filePath = filePath(%file);
+   %fileName = fileBase(%file);
    %moduleDef = AssetBrowser.dirHandler.getModuleFromAddress(%file);
    %moduleName = %moduleDef.ModuleId;
    %modulePath = %moduleDef.ModulePath;
@@ -1182,7 +1183,7 @@ function deleteAssetDefinitions()
    %dlg = new OpenFolderDialog()
    {
       Title = "Select Folder";
-      Filters = %filter;
+      Filters = "";
       DefaultFile = "data/";
       ChangePath = false;
       MustExist = true;