Przeglądaj źródła

Implementation of updated handling of Legacy Project importer to better seperate out importer versions as well as more explicit processing of incoming content

JeffR 3 lat temu
rodzic
commit
ecd35df7e9

+ 1 - 1
Engine/source/T3D/assets/GUIAsset.cpp

@@ -102,7 +102,7 @@ void GUIAsset::initPersistFields()
       &setScriptFile, &getScriptFile, "Path to the script file for the gui");
 
    addProtectedField("GUIFile", TypeAssetLooseFilePath, Offset(mGUIFile, GUIAsset),
-      &setScriptFile, &getScriptFile, "Path to the gui file");
+      &setGUIFile, &getGUIFile, "Path to the gui file");
 }
 
 //------------------------------------------------------------------------------

+ 2 - 2
Engine/source/T3D/assets/ShapeAsset.cpp

@@ -623,8 +623,8 @@ const char* ShapeAsset::generateCachedPreviewImage(S32 resolution, String overri
 
    String dumpPath = String(mFilePath) + "_Preview.dds";
 
-   char* returnBuffer = Con::getReturnBuffer(dumpPath.length());
-   dSprintf(returnBuffer, dumpPath.length(), "%s", dumpPath.c_str());
+   char* returnBuffer = Con::getReturnBuffer(128);
+   dSprintf(returnBuffer, 128, "%s", dumpPath.c_str());
 
    /*FileStream stream;
    if (stream.open(dumpPath, Torque::FS::File::Write))

+ 16 - 10
Engine/source/T3D/assets/assetImporter.cpp

@@ -2099,22 +2099,28 @@ void AssetImporter::processShapeMaterialInfo(AssetImportObject* assetItem, S32 m
                String imgFileName = AssetImporter::findImagePath(testFilePath.getPath() + "/" + testFilePath.getFileName());
                if (imgFileName.isNotEmpty())
                   filePath = imgFileName;
+               else
+                  filePath = ""; //no luck, so we just won't try importing in the image
             }
          }
  
          matAssetItem = addImportingAsset("MaterialAsset", shapePathBase + "/" + matName, assetItem, matName);
-         AssetImportObject* imageAssetItem = addImportingAsset("ImageAsset", filePath, matAssetItem, "");
 
-         String suffixType;
-         String suffix = parseImageSuffixes(imageAssetItem->assetName, &suffixType);
-         if (suffix.isNotEmpty())
+         if (!filePath.isEmpty())
          {
-            imageAssetItem->imageSuffixType = suffixType;
-         }
-         else
-         {
-            //we'll assume it's albedo
-            imageAssetItem->imageSuffixType = "Albedo";
+            AssetImportObject* imageAssetItem = addImportingAsset("ImageAsset", filePath, matAssetItem, "");
+
+            String suffixType;
+            String suffix = parseImageSuffixes(imageAssetItem->assetName, &suffixType);
+            if (suffix.isNotEmpty())
+            {
+               imageAssetItem->imageSuffixType = suffixType;
+            }
+            else
+            {
+               //we'll assume it's albedo
+               imageAssetItem->imageSuffixType = "Albedo";
+            }
          }
       }
       else

+ 5 - 0
Engine/source/persistence/taml/taml.cpp

@@ -217,6 +217,11 @@ ImplementEnumType(_TamlFormatMode,
 
       FileStream stream;
 
+      if (StringTable->insert("c://.asset.taml") == StringTable->insert(mFilePathBuffer))
+      {
+         bool asdfasdf = true;
+      }
+
       // File opened?
       if (!stream.open(mFilePathBuffer, Torque::FS::File::Write))
       {

+ 4 - 2
Engine/source/persistence/taml/taml_ScriptBinding.h

@@ -256,8 +256,10 @@ DefineEngineFunction(TamlWrite, bool, (SimObject* simObject, const char* filenam
    }
    else
    {
-         // No, so warn.
-         Con::warnf( "TamlWrite() - Setting binary compression is only valid for XML formatting." );
+#ifdef TORQUE_DEBUG
+      // No, so warn.
+      Con::warnf( "TamlWrite() - Setting binary compression is only valid for XML formatting." );
+#endif
    }
 
    // Turn-off auto-formatting.

+ 1 - 1
Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml

@@ -100,7 +100,7 @@
             <Setting name="LOSCollisionMeshPrefix">LOS</Setting>
         </Group>
         <Group name="General">
-            <Setting name="AddDirectoryPrefixToAssetName">1</Setting>
+            <Setting name="AddDirectoryPrefixToAssetName">0</Setting>
             <Setting name="AutomaticallyPromptMissingFiles">0</Setting>
             <Setting name="DuplicateAutoResolution">FolderPrefix</Setting>
             <Setting name="PreventImportWithErrors">1</Setting>

Plik diff jest za duży
+ 444 - 789
Templates/BaseGame/game/tools/projectImporter/guis/projectImporter.gui


+ 1376 - 0
Templates/BaseGame/game/tools/projectImporter/importers/pre40/T3Dpre4ProjectImporter.tscript

@@ -0,0 +1,1376 @@
+function T3Dpre4ProjectImporter::init()
+{
+   //register this importer option to the project importer listing
+   if(isObject(T3Dpre4ProjectImporter))
+      T3Dpre4ProjectImporter.delete();
+      
+   new ScriptObject(T3Dpre4ProjectImporter);
+   
+   //Now we register the importer so it shows in the listing
+   $ProjectImporter::importerList.add("Pre-4.0 T3D Project", T3Dpre4ProjectImporter); 
+   
+   %result = AssetDatabase.acquireAsset("ToolsModule:pre40ImporterGuis");
+}
+
+T3Dpre4ProjectImporter::init(); //kick off the setup
+
+function T3Dpre4ProjectImporter::setupPages(%this)
+{
+   ProjectImportWindow.addImporterPage(Pre40ImporterPage0);
+   ProjectImportWindow.addImporterPage(Pre40ImporterPage1);
+   
+   ProjectImportWindow.refreshPage();
+}
+
+//
+//
+function T3Dpre4ProjectImporter::setupModule(%this)
+{
+   %newModuleName = $ProjectImporter::moduleName;
+      
+   projectImporterLog("Setup up Module named: " @ %newModuleName);
+   
+   %moduleFilePath = "data/" @ %newModuleName;
+   %moduleDefinitionFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".module";
+   %moduleScriptFilePath = %moduleFilePath @ "/" @ %newModuleName @ "." @ $TorqueScriptFileExtension;
+   
+   if(!isImportingFile($ProjectImporter::sourceContentFolder @ "/" @ %newModuleName @ ".module"))
+   {
+      %newModule = new ModuleDefinition()
+      {
+         ModuleId = %newModuleName;
+         versionId = 1;
+         ScriptFile = %newModuleName @ "." @ $TorqueScriptFileExtension;
+         CreateFunction="onCreate";
+         DestroyFunction="onDestroy";
+         Group = "Game";
+         
+         new DeclaredAssets()
+         {
+            Extension = "asset.taml";
+            Recurse = true;
+         };
+      };
+      
+      TAMLWrite(%newModule, %moduleDefinitionFilePath); 
+   }
+   
+   //if we don't already have a incoming file that matches this, then we'll want to make a new one
+   if(!isImportingFile($ProjectImporter::sourceContentFolder @ "/" @ %newModuleName @ ".cs") && 
+      !isImportingFile($ProjectImporter::sourceContentFolder @ "/" @ %newModuleName @ "." @ $TorqueScriptFileExtension))
+   {
+      //Now generate the script file for it
+      %file = new FileObject();
+      %templateFile = new FileObject();
+      
+      %moduleTemplateCodeFilePath = AssetBrowser.templateFilesPath @ "module.tscript.template";
+      
+      if(%file.openForWrite(%moduleScriptFilePath) && %templateFile.openForRead(%moduleTemplateCodeFilePath))
+      {
+         while( !%templateFile.isEOF() )
+         {
+            %line = %templateFile.readline();
+            %line = strreplace( %line, "@@", %newModuleName );
+            
+            %file.writeline(%line);
+            //projectImporterLog(%line);
+         }
+         
+         %file.close();
+         %templateFile.close();
+      }
+      else
+      {
+         %file.close();
+         %templateFile.close();
+         
+         projectImporterLog("CreateNewModule - Something went wrong and we couldn't write the script file!");
+      }
+   }
+   
+   //force a refresh of our modules list
+   ModuleDatabase.ignoreLoadedGroups(true);
+   ModuleDatabase.scanModules( "data", false );
+   %success = ModuleDatabase.loadExplicit(%newModuleName, 1);
+   ModuleDatabase.ignoreLoadedGroups(false);
+   
+   //force a reload of the Module lists
+   AssetBrowser.refresh();
+}
+
+/*function T3Dpre4ProjectImporter::copyFiles(%this)
+{
+   %currentPage = ProjectImportWindow.getCurrentPage();
+   
+   %currentPage-->fileCopyText.setText("Beginning copy of files to new module folder now. This may take a few minutes...");
+   Canvas.repaint();
+   
+   %file = findFirstFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*", true);
+   
+   while( %file !$= "" )
+   {
+      %filePath = filePath(%file);
+      %fileName = fileName(%file);
+      %fileBase = fileBase(%file);
+      %fileExt = fileExt(%file);
+      
+      if(endsWith(%fileName, ".asset.taml"))
+      {
+         %fileBase = strreplace(%fileBase, ".asset", "");
+         %fileExt = ".asset.taml";
+      }
+      
+      if(%fileExt $= ".dll" || %fileExt $= ".log" || %fileExt $= ".exe" || %fileExt $= ".manifest"|| %fileExt $= ".h" ||
+         %fileExt $= ".cpp" || %fileExt $= ".so" || %fileExt $= ".do" || %fileExt $= ".lib" ||%fileExt $= ".exp")
+      {
+         %file = findNextFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*" );
+         continue;
+      }
+      
+      //filter out some unneeded folders
+      %slashCount = getTokenCount(%filePath, "/");
+      %topFolder = getToken(%filePath, "/", %slashCount-1);
+      if(%topFolder $= "")
+         %topFolder = getToken(%filePath, "/", %slashCount-2);
+         
+      if(%topFolder $= "creator" || %topFolder $= "tools" || %topFolder $= "web")
+      {
+         %file = findNextFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*" );
+         continue;
+      }
+      
+      %targetFilePath = strReplace(%file, $ProjectImporter::sourceContentFolder, $ProjectImporter::modulePath);
+      
+      %sanitizedFilename = sanitizeString(%fileBase);
+      if(startsWith(%sanitizedFilename, "_"))
+      {
+         %sanitizedFilename = substr(%sanitizedFilename, 1, -1);
+      }
+      if(%sanitizedFilename !$= %fileBase)
+      {
+         %targetFilePath = filePath(%targetFilePath) @ "/" @ %sanitizedFilename @ %fileExt;
+      }
+      
+      %targetFolder = filePath(%targetFilePath);
+      
+      if(!isDirectory(%targetFolder))
+      {
+         DirectoryHandler::createFolder(0, %targetFolder);
+      }
+      
+      if(!pathCopy(%file, %targetFilePath, false))
+      {
+         projectImporterLog("Legacy Project Importer, failed to copy file: " @ %file @ " to destination: " @ %targetFilePath);
+      }
+      
+      %file = findNextFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*" );
+   }
+   
+   //
+   //Now that we've done that, we'll load and scan the module for asset defs
+   %file = findFirstFileMultiExpr( $ProjectImporter::modulePath @ "/*.asset.taml", true);
+   
+   while( %file !$= "" )
+   {
+      %moduleName = AssetBrowser.dirHandler.getModuleFromAddress(%file).ModuleId;
+      %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
+      
+      AssetDatabase.addDeclaredAsset(%moduleDef, %file);
+      
+      %file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*.asset.taml" );
+   }
+   //
+   
+   %currentPage-->fileCopyText.setValue("File copy done! Press Next to continue.");
+   
+   ProjectImportWindow-->nextButton.setActive(true);
+   Canvas.repaint();
+}
+
+function T3Dpre4ProjectImporter::processImportedFiles(%this)
+{
+   if($ProjectImporter::importMode $= "CoreAndTools")
+   {
+      $ProjectImporter::modulePath = "Core";
+      %this.doImport();
+      
+      $ProjectImporter::modulePath = "Tools";
+      %this.doImport();
+   }
+   else
+   {
+      %this.doImport();
+   }
+   
+   %currentPage = ProjectImportWindow.getCurrentPage();
+   
+   %currentPage-->processingText.setText("Processing of files done! Press Next to continue.");
+   ProjectImportWindow-->nextButton.setActive(true);
+   Canvas.repaint();
+}*/
+
+function T3Dpre4ProjectImporter::doContentImport(%this)
+{
+   //Store off the current default import config
+   %this.defaultConfig = EditorSettings.value("Assets/AssetImporDefaultConfig", "");
+   EditorSettings.setValue("Assets/AssetImporDefaultConfig", "LegacyProjectImport");
+
+   //Update asset content
+   beginImageImport();
+   
+   %this.beginMaterialFilesImport();
+   
+   beginShapeImport();
+   beginTerrainImport();
+   
+   %this.beginSoundProfilesImport();
+}
+
+function T3Dpre4ProjectImporter::doScriptImport(%this)
+{
+   beginLevelImport();
+   beginGUIImport();
+   
+   %this.beginScriptFilesImport();
+   
+   %this.beginAssetAndModuleImport();
+   
+   %this.writeImportingFiles();
+   
+   EditorSettings.setValue("Assets/AssetImporDefaultConfig", %this.defaultConfig);
+}
+
+function T3Dpre4ProjectImporter::writeImportingObject(%this, %arrayObj)
+{
+   if(!isObject(%arrayObj) || %arrayObj.skip)
+      return;
+      
+   for(%i=0; %i < %arrayObj.count(); %i++)
+   {
+      %objectLine = %arrayObj.getKey(%i);
+      if(isObject(%objectLine))
+      {
+         if(%objectLine.skip == false)
+         {
+            %this.writeImportingObject(%objectLine);
+         }
+      }
+      else
+      {
+         $ProjectImporter::fileObject.writeLine(%objectLine);
+      }
+   }
+}  
+
+function T3Dpre4ProjectImporter::writeImportingFiles(%this)
+{
+   //First, we need to go through and process all loose image files. This will
+   //get us shape assets, and if the import config deigns, material assets.
+   %currentAddress = $ProjectImporter::modulePath;
+   
+   for(%i=0; %i < $ProjectImporter::FileList.count(); %i++)
+   {
+      %file = $ProjectImporter::FileList.getKey(%i);
+      %rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
+      
+      if(!%rootFileSectionObject.skip && !%rootFileSectionObject.binaryFile)
+      {
+         %path = filePath(%rootFileSectionObject.fileDestination);
+            
+         if(!IsDirectory(%path))
+         {
+            DirectoryHandler::createFolder(0, %path);  
+         }
+         
+         if ( $ProjectImporter::fileObject.openForWrite( %rootFileSectionObject.fileDestination ) ) 
+         {
+            %this.writeImportingObject(%rootFileSectionObject);
+            
+            $ProjectImporter::fileObject.close();
+         }
+      }
+      
+      if($ProjectImporter::useExistingModule)
+      {
+         //clean up legact files if they've been renamed or whatnot
+         if(%file !$= %rootFileSectionObject.fileDestination)
+         {
+            fileDelete(%file);  
+         }
+      }
+   }
+}
+
+//
+function T3Dpre4ProjectImporter::processMaterialObjects(%this, %arrayObj)
+{
+   if(!isObject(%arrayObj))
+      return;
+      
+   //We only really care about materials for this
+   if(%arrayObj.elementType $= "function" ||
+      (%arrayObj.elementType $= "Object" && %arrayObj.classType !$= "Material" && %arrayObj.classType !$= "CustomMaterial"))
+   {
+      return;  
+   }
+   
+   for(%e=0; %e < %arrayObj.count(); %e++)
+   {
+      %lineObj = %arrayObj.getKey(%e);
+      if(isObject(%lineObj))
+      {
+         if( %lineObj.elementType $= "Object")
+         {
+            if(%lineObj.classType $= "Material" || %lineObj.classType $= "CustomMaterial")
+            {
+               %materialName = %lineObj.objectName;
+               if(%materialName $= "")
+               {
+                  %mapToName = findObjectField(%lineObj, "mapTo");
+                  %lineObj.objectName = %mapToName @ "_mat";
+               }
+               
+               %sanitizedName = sanitizeString(%materialName);
+               if(startsWith(%sanitizedName, "_"))
+               {
+                  %sanitizedName = getSubStr(%sanitizedName, 1, -1);
+               }
+               
+               projectImporterLog("processMaterialObjects() - beginning processing of material: " @ %sanitizedName);
+               
+               if(%lineObj.objectName !$= %sanitizedName)
+                  renameObjectName(%lineObj, %sanitizedName);
+                  
+               //Now, we process the fields to be asset-ified on our object
+               for(%l=0; %l < %lineObj.count(); %l++)
+               {
+                  %objectCodeLine = %lineObj.getKey(%l);
+                  if(!isObject(%objectCodeLine))
+                  {
+                     %resultLine = T3Dpre4ProjectImporter.processMaterialLine(%objectCodeLine);
+                     if(%resultLine !$= %objectCodeLine)
+                     {
+                        projectImporterLog("   processed line: " @ %resultLine @ " from: " @ %objectCodeLine);
+                        %lineObj.setKey(%resultLine, %l);
+                     }
+                  }
+               }
+               
+               //This walks through the class heirarchy so in the event we get a
+               //class that has a shared common root class like with water or materials
+               //we can process with that class to cover the probability space
+               
+               %inheritanceList = getClassHierarchy(%lineObj.classType);
+               for (%classDepth = 0; %classDepth < getWordCount(%inheritanceList); %classDepth++)
+               {
+                  %subclass = getWord(%inheritanceList, %classDepth);
+                  %processFunction = "process" @ %subclass @ "Object";
+                  if(T3Dpre4ProjectImporter.isMethod(%processFunction))
+                  {
+                     T3Dpre4ProjectImporter.call(%processFunction, %lineObj, %sanitizedName);
+                  }
+               }
+            }
+            else if(%lineObj.classType $= "TerrainMaterial")
+            {
+               %intName = findObjectField(%lineObj, "internalName");
+               %materialName = %intName @ "_terrainMat";
+               
+               %sanitizedName = sanitizeString(%materialName);
+               if(startsWith(%sanitizedName, "_"))
+               {
+                  %sanitizedName = getSubStr(%sanitizedName, 1, -1);
+               }
+               
+               if(%intName !$= %sanitizedName)
+                  setObjectField(%lineObj, "internalName", %sanitizedName);
+                  
+               //Now, we process the fields to be asset-ified on our object
+               for(%l=0; %l < %lineObj.count(); %l++)
+               {
+                  %objectCodeLine = %lineObj.getKey(%l);
+                  if(!isObject(%objectCodeLine))
+                  {
+                     %resultLine = T3Dpre4ProjectImporter.processTerrainMaterialLine(%objectCodeLine);
+                     if(%resultLine !$= %objectCodeLine)
+                     {
+                        projectImporterLog("   processed line: " @ %resultLine @ " from: " @ %objectCodeLine);
+                        %lineObj.setKey(%resultLine, %l);
+                     }
+                  }
+               }
+               
+               //This walks through the class heirarchy so in the event we get a
+               //class that has a shared common root class like with water or materials
+               //we can process with that class to cover the probability space
+               
+               %inheritanceList = getClassHierarchy(%lineObj.classType);
+               for (%classDepth = 0; %classDepth < getWordCount(%inheritanceList); %classDepth++)
+               {
+                  %subclass = getWord(%inheritanceList, %classDepth);
+                  %processFunction = "process" @ %subclass @ "Object";
+                  if(T3Dpre4ProjectImporter.isMethod(%processFunction))
+                  {
+                     T3Dpre4ProjectImporter.call(%processFunction, %lineObj, %sanitizedName);
+                  }
+               }
+            }
+            else
+            {
+               continue;  
+            }
+            /**/
+            %oN = %lineObj.objectName;
+            
+            %lineObj.processed = true;
+            %lineObj.skip = true;
+         }
+         
+         //Recurse down as needed
+         %this.processMaterialObjects(%lineObj);
+      }
+   }
+}
+
+function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this)
+{
+   projectImporterLog("===========================================");
+   projectImporterLog("Importing Material definitions");
+   projectImporterLog("===========================================");
+   
+   for(%i=0; %i < $ProjectImporter::FileList.count(); %i++)
+   {
+      %file = $ProjectImporter::FileList.getKey(%i);
+      %rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
+      
+      $ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/"; //give context to the file we're processing
+      
+      if(%rootFileSectionObject.binaryFile == true || %rootFileSectionObject.imported == true)
+         continue;
+         
+      %this.processMaterialObjects(%rootFileSectionObject);
+   }
+   
+   projectImporterLog("===========================================");
+   projectImporterLog("Importing Material definitions finished");
+   projectImporterLog("===========================================");
+}
+
+//
+function T3Dpre4ProjectImporter::processSoundProfileObjects(%this, %arrayObj)
+{
+   if(!isObject(%arrayObj))
+      return;
+      
+   //We only really care about materials for this
+   if((%arrayObj.elementType $= "Object" && %arrayObj.classType !$= "SFXProfile"))
+   {
+      return;  
+   }
+   
+   for(%e=0; %e < %arrayObj.count(); %e++)
+   {
+      %lineObj = %arrayObj.getKey(%e);
+      if(isObject(%lineObj))
+      {
+         if( %lineObj.elementType $= "Object")
+         {
+            if(%lineObj.classType $= "SFXProfile")
+            {
+               %profileName = %lineObj.objectName;
+               
+               %sanitizedName = sanitizeString(%profileName);
+               if(startsWith(%sanitizedName, "_"))
+               {
+                  %sanitizedName = getSubStr(%sanitizedName, 1, -1);
+               }
+               
+               projectImporterLog("processSoundProfileObjects() - beginning processing of SFXProfile: " @ %sanitizedName);
+               
+               if(%lineObj.objectName !$= %sanitizedName)
+                  renameObjectName(%lineObj, %sanitizedName);
+               
+               //This walks through the class heirarchy so in the event we get a
+               //class that has a shared common root class like with water or materials
+               //we can process with that class to cover the probability space
+               %inheritanceList = getClassHierarchy(%lineObj.classType);
+               for (%classDepth = 0; %classDepth < getWordCount(%inheritanceList); %classDepth++)
+               {
+                  %subclass = getWord(%inheritanceList, %classDepth);
+                  %processFunction = "process" @ %subclass @ "Object";
+                  if(T3Dpre4ProjectImporter.isMethod(%processFunction))
+                  {
+                     T3Dpre4ProjectImporter.call(%processFunction, %lineObj, %sanitizedName);
+                  }
+               }
+               
+               //Now, we process the fields to be asset-ified on our object
+               for(%l=0; %l < %lineObj.count(); %l++)
+               {
+                  %objectCodeLine = %lineObj.getKey(%l);
+                  if(!isObject(%objectCodeLine))
+                  {
+                     %resultLine = T3Dpre4ProjectImporter.processSFXProfileLine(%objectCodeLine);
+                     if(%resultLine !$= %objectCodeLine)
+                     {
+                        projectImporterLog("   processed line: " @ %resultLine @ " from: " @ %objectCodeLine);
+                        %lineObj.setKey(%resultLine, %l);
+                     }
+                  }
+               }
+            }
+            else
+            {
+               continue;  
+            }
+            
+            %lineObj.processed = true;
+            %lineObj.skip = true;
+         }
+         
+         //Recurse down as needed
+         %this.processSoundProfileObjects(%lineObj);
+      }
+   }
+}
+
+function T3Dpre4ProjectImporter::beginSoundProfilesImport(%this)
+{
+   projectImporterLog("===========================================");
+   projectImporterLog("Importing Sound Profiles");
+   projectImporterLog("===========================================");
+   
+   for(%i=0; %i < $ProjectImporter::FileList.count(); %i++)
+   {
+      %file = $ProjectImporter::FileList.getKey(%i);
+      %rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
+      
+      $ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/"; //give context to the file we're processing
+      
+      if(%rootFileSectionObject.binaryFile == true || %rootFileSectionObject.imported == true)
+         continue;
+         
+      %this.processSoundProfileObjects(%rootFileSectionObject);
+   }
+   
+   projectImporterLog("===========================================");
+   projectImporterLog("Importing Sound Profiles finished");
+   projectImporterLog("===========================================");
+}
+
+//
+function T3Dpre4ProjectImporter::processScripts(%this, %arrayObj)
+{
+   if(!isObject(%arrayObj))
+      return;
+      
+   //We only really care about materials for this
+   if((%arrayObj.elementType $= "Object" && (%arrayObj.classType $= "Material" || %arrayObj.classType $= "CustomMaterial" || %arrayObj.classType $= "TerrainMaterial")))
+   {
+      return;  
+   }
+   
+   for(%e=0; %e < %arrayObj.count(); %e++)
+   {
+      %lineObj = %arrayObj.getKey(%e);
+      if(isObject(%lineObj) && !%lineObj.skip)
+      {
+         if( %lineObj.elementType $= "Object")
+         {
+            %sanitizedName = sanitizeString(%lineObj.objectName);
+            if(startsWith(%sanitizedName, "_"))
+            {
+               %sanitizedName = getSubStr(%sanitizedName, 1, -1);
+            }
+            
+            if(%sanitizedName !$= "")
+               projectImporterLog("processScriptObjects() - beginning processing of object: " @ %lineObj.classType @ "(" @ %sanitizedName @ ")");
+            else
+               projectImporterLog("processScriptObjects() - beginning processing of object: " @ %lineObj.classType @ "()");
+            
+            if(%lineObj.objectName !$= %sanitizedName && %lineObj.objectName !$= "")
+               renameObjectName(%lineObj, %sanitizedName);
+            
+            //This walks through the class heirarchy so in the event we get a
+            //class that has a shared common root class like with water or materials
+            //we can process with that class to cover the probability space
+            
+            %inheritanceList = getClassHierarchy(%lineObj.classType);
+            for (%classDepth = 0; %classDepth < getWordCount(%inheritanceList); %classDepth++)
+            {
+               %subclass = getWord(%inheritanceList, %classDepth);
+               %processFunction = "process" @ %subclass @ "Object";
+               
+               if(T3Dpre4ProjectImporter.isMethod(%processFunction))
+               {
+                  T3Dpre4ProjectImporter.call(%processFunction, %lineObj, %sanitizedName);
+               }
+               
+               //Now, we process the fields to be asset-ified on our object
+               for(%l=0; %l < %lineObj.count(); %l++)
+               {
+                  %objectCodeLine = %lineObj.getKey(%l);
+                  if(!isObject(%objectCodeLine))
+                  {
+                     %processLineFunction = "process" @ %subclass @ "Line";
+                     if(T3Dpre4ProjectImporter.isMethod(%processLineFunction))
+                     {
+                        %resultLine = T3Dpre4ProjectImporter.call(%processLineFunction, %objectCodeLine);
+
+                        if(%resultLine !$= %objectCodeLine)
+                        {
+                           projectImporterLog("   processed line: " @ %resultLine @ " from: " @ %objectCodeLine);
+                           %lineObj.setKey(%resultLine, %l);
+                        }
+                     }
+                  }
+               }
+            }
+            
+            %lineObj.processed = true;
+         }
+         else if(%lineObj.elementType $= "function")
+         {
+            //Now, we process the fields to be asset-ified on our object
+            for(%l=0; %l < %lineObj.count(); %l++)
+            {
+               %functionCodeLine = %lineObj.getKey(%l);
+               if(!isObject(%functionCodeLine))
+               {
+                  %resultLine = %functionCodeLine;
+                  
+                  if(strIsMatchExpr("*exec(*.cs*)*", %functionCodeLine) || strIsMatchExpr("*exec(*.tscript*)*", %functionCodeLine))
+                  {
+                     %scriptExtRemovedLine = strReplace(%functionCodeLine, ".cs", "");
+                     %scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
+                     %resultLine = %scriptExtRemovedLine;
+                  }
+                  else if(strIsMatchExpr("*queueexec(*.cs*)*", %functionCodeLine) || strIsMatchExpr("*queueexec(*.tscript*)*", %functionCodeLine))
+                  {
+                     %scriptExtRemovedLine = strReplace(%functionCodeLine, ".cs", "");
+                     %scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
+                     %resultLine = %scriptExtRemovedLine;
+                  }
+                  else if(strIsMatchExpr("*registerDatablock(*.cs*)*", %functionCodeLine) || strIsMatchExpr("*registerDatablock(*.tscript*)*", %functionCodeLine))
+                  {
+                     %scriptExtRemovedLine = strReplace(%functionCodeLine, ".cs", "");
+                     %scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
+                     %resultLine = %scriptExtRemovedLine;
+                  }
+                  else if(strIsMatchExpr("*%this.addSequence(\"*);", %functionCodeLine))
+                  {
+                     %resultLine = processLegacyShapeConstructorField(%functionCodeLine);
+                  }
+                  
+                  if(%resultLine !$= %functionCodeLine)
+                  {
+                     %lineObj.setKey(%resultLine, %l);
+                  }
+               }
+            } 
+            
+            %lineObj.processed = true; 
+         }
+         
+         //Recurse down as needed
+         %this.processScripts(%lineObj);
+      }
+   }
+}
+
+function T3Dpre4ProjectImporter::beginScriptFilesImport(%this)
+{
+   //First, we need to go through and process all loose image files. This will
+   //get us shape assets, and if the import config deigns, material assets.
+   %currentAddress = $ProjectImporter::modulePath;
+   
+   for(%i=0; %i < $ProjectImporter::FileList.count(); %i++)
+   {
+      %file = $ProjectImporter::FileList.getKey(%i);
+      %rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
+      //%file = %rootFileSectionObject.fileDestination;
+      
+      //if(%rootFileSectionObject.imported == true)
+      //   continue;
+      
+      %filename = %rootFileSectionObject.fileName;
+      %fileExt = %rootFileSectionObject.fileExt;
+      %fileBase = %rootFileSectionObject.fileBase;
+      %filePath = filePath(%file);
+      
+      if(%fileExt !$= ".cs" && 
+         %fileExt !$= ".tscript" && 
+         %fileExt !$= ".mis" && 
+         %fileExt !$= ".gui" && 
+         %fileExt !$= ".prefab")
+      {
+         continue;
+      }
+      
+      $ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/";
+      
+      projectImporterLog("T3Dpre4ProjectImporter::beginScriptFilesImport() - Processing script file: " @ %file);
+      %this.processScripts(%rootFileSectionObject);
+   }
+   
+   projectImporterLog("Legacy Project Importer - Processing of imported code files done!");
+}
+
+//
+function T3Dpre4ProjectImporter::processModuleFile(%this, %moduleObj)
+{
+   if(!isObject(%moduleObj))
+      return;
+      
+   %moduleObj.echo();
+      
+   //really, we only care here about ensuring the file extensions are cleaned up
+   for(%l=0; %l < %moduleObj.count(); %l++)
+   {
+      %line = %moduleObj.getKey(%l);
+      if(strIsMatchExpr("*.cs\"", %line))
+      {
+         %resultLine = strReplace(%line, ".cs\"", "\"");
+         %moduleObj.setKey(%resultLine, %l);
+      }
+   }
+}
+
+function T3Dpre4ProjectImporter::processAssetFile(%this, %assetObj)
+{
+   if(!isObject(%assetObj))
+      return;
+      
+   %assetObj.echo();
+      
+   //really, we only care here about ensuring the file extensions are cleaned up
+   for(%l=0; %l < %assetObj.count(); %l++)
+   {
+      %line = %assetObj.getKey(%l);
+      if(strIsMatchExpr("*.cs\"", %line))
+      {
+         %resultLine = strReplace(%line, ".cs\"", "\"");
+         %assetObj.setKey(%resultLine, %l);
+      }
+   }
+}
+
+function T3Dpre4ProjectImporter::beginAssetAndModuleImport(%this)
+{
+   //First, we need to go through and process all loose image files. This will
+   //get us shape assets, and if the import config deigns, material assets.
+   %currentAddress = $ProjectImporter::modulePath;
+   
+   for(%i=0; %i < $ProjectImporter::FileList.count(); %i++)
+   {
+      %file = $ProjectImporter::FileList.getKey(%i);
+      %rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
+      
+      %filename = %rootFileSectionObject.fileName;
+      %fileExt = %rootFileSectionObject.fileExt;
+      %fileBase = %rootFileSectionObject.fileBase;
+      %filePath = filePath(%file);
+      
+      if(%fileExt $= ".module")
+      {
+         projectImporterLog("T3Dpre4ProjectImporter::beginAssetAndModuleImport() - processing file: " @ %file);
+         $ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/";
+         %this.processModuleFile(%rootFileSectionObject);
+         %rootFileSectionObject.processed = true;
+      }
+      else if(%fileExt $= ".asset.taml")
+      {
+         projectImporterLog("T3Dpre4ProjectImporter::beginAssetAndModuleImport() - processing file: " @ %file);
+         $ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/";
+         %this.processAssetFile(%rootFileSectionObject);
+         %rootFileSectionObject.processed = true;
+      }
+   }
+   
+   projectImporterLog("Legacy Project Importer - Processing of imported asset and module files done!");
+}
+
+//To implement a custom class to have it's fields processed, just utilize this template function
+//and replace the class/field spaces as appropriate
+/*
+function T3Dpre4ProjectImporter::process<ClassName>Line(%this, %line)
+{
+   %outLine = processLegacyField(%line, "<originalFilenameField>", "<newAssetField>");
+  
+   if(%outLine !$= %line)
+      return %outLine;
+   else
+      return %line;
+}
+*/
+//==============================================================================
+// Misc Object Classes
+//==============================================================================
+function T3Dpre4ProjectImporter::genProcessor(%classType, %conversionMap)
+{
+    %stryng = "function T3Dpre4ProjectImporter::process" @%classType@ "Line(%this, %line){\n";
+    %count = getWordCount(%conversionMap);
+    for (%i = 0; %i<%count; %i+=2)
+    {
+        %stryng = %stryng @ " %outLine = processLegacyField(%line,\""@ getWord(%conversionMap,%i)@ "\",\""@ getWord(%conversionMap,%i+1)@"\");\n";
+        %stryng = %stryng @ "  if(%outLine !$= %line) return %outLine;\n";
+    }
+    %stryng = %stryng @ " return %line;\n}";
+    eval(%stryng);
+}
+
+T3Dpre4ProjectImporter::genProcessor("TSShapeConstructor", "baseShape baseShapeAsset shapeName shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("BasicClouds", "texture textureAsset");
+T3Dpre4ProjectImporter::genProcessor("CloudLayer", "texture textureAsset");
+T3Dpre4ProjectImporter::genProcessor("DecalRoad", "material materialAsset");
+T3Dpre4ProjectImporter::genProcessor("MeshRoad", "topMaterial topMaterialAsset bottomMaterial bottomMaterialAsset sideMaterial sideMaterialAsset");
+T3Dpre4ProjectImporter::genProcessor("ScatterSky", "moonMat moonMatAsset");
+T3Dpre4ProjectImporter::genProcessor("Sun", "coronaMaterial coronaMaterialAsset");
+T3Dpre4ProjectImporter::genProcessor("VolumetricFog", "shape ShapeAsset texture textureAsset");
+T3Dpre4ProjectImporter::genProcessor("WaterObject", "rippleTex rippleTexAsset foamTex foamTexAsset depthGradientTex depthGradientTexAsset");
+T3Dpre4ProjectImporter::genProcessor("ConvexShape", "material materialAsset");
+T3Dpre4ProjectImporter::genProcessor("RenderMesh", "material materialAsset");
+T3Dpre4ProjectImporter::genProcessor("RenderShape", "shape shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("GroundCover", "material materialAsset shape shapeAsset shapeFilename shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("GroundPlane", "material materialAsset");
+T3Dpre4ProjectImporter::genProcessor("LevelInfo", "accuTexture accuTextureAsset");
+T3Dpre4ProjectImporter::genProcessor("TSStatic", "shape shapeAsset shapeName shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("TSForestItemData", "shape shapeAsset shapeName shapeAsset shapeFile shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("TerrainBlock", "terrainFile terrainAsset");
+T3Dpre4ProjectImporter::genProcessor("afxMagicMissileData", "projectileShape projectileShapeAsset projectileShapeName projectileShapeAsset sound projectileSoundAsset");
+T3Dpre4ProjectImporter::genProcessor("afxBillboardData", "texture textureAsset");
+T3Dpre4ProjectImporter::genProcessor("afxModelData", "shapeName shapeAsset shapeFile shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("afxZodiacData", "texture textureAsset");
+T3Dpre4ProjectImporter::genProcessor("afxZodiacPlaneData", "texture textureAsset");
+T3Dpre4ProjectImporter::genProcessor("sfxEmitter", "track soundAsset filename soundAsset");
+T3Dpre4ProjectImporter::genProcessor("LightningData", "thunderSounds ThunderSoundAsset strikeSound StrikeSoundAsset");
+//==============================================================================
+// Levels
+//==============================================================================
+function T3Dpre4ProjectImporter::processMissionGroupLine(%this, %line, %missionName)
+{
+   %outline = strreplace(%line, "SimGroup(MissionGroup)", "Scene(" @ %missionName @ ")");
+   
+   if(%outLine !$= %line)
+      return %outLine;
+   else
+      return %line;
+}
+
+function T3Dpre4ProjectImporter::processLevelInfoLine(%this, %line)
+{
+   %outline = strreplace(%line, "ScriptObject(MissionInfo)", "LevelInfo(theLevelInfo)");
+   
+   if(%outLine !$= %line)
+      return %outLine;
+   else
+      return %line;
+}
+
+function T3Dpre4ProjectImporter::processSkyLine(%this, %line)
+{
+   %outline = strreplace(%line, "Sky", "Skybox");
+   
+   if(%outLine !$= %line)
+      return %outLine;
+   else
+      return %line;
+}
+
+function T3Dpre4ProjectImporter::processWaterLine(%this, %line)
+{
+   %outline = strreplace(%line, "Water", "WaterPlane");
+   
+   if(%outLine !$= %line)
+      return %outLine;
+   else
+      return %line;
+}
+
+//==============================================================================
+// GUIs
+//==============================================================================
+T3Dpre4ProjectImporter::genProcessor("GuiIconButtonCtrl", "bitmap bitmapAsset iconBitmap bitmapAsset");
+T3Dpre4ProjectImporter::genProcessor("GuiToolboxButtonCtrl", "normalBitmap normalBitmapAsset loweredBitmap loweredBitmapAsset hoverBitmap hoverBitmapAsset");
+T3Dpre4ProjectImporter::genProcessor("GuiBitmapCtrl", "bitmap bitmapAsset");
+T3Dpre4ProjectImporter::genProcessor("GuiMaterialCtrl", "material materialAsset");
+T3Dpre4ProjectImporter::genProcessor("GuiCursor", "bitmap bitmapAsset");
+T3Dpre4ProjectImporter::genProcessor("GuiChunkedBitmapCtrl", "bitmap bitmapAsset");
+T3Dpre4ProjectImporter::genProcessor("GuiProgressBitmap", "bitmap bitmapAsset");
+T3Dpre4ProjectImporter::genProcessor("GuiMissionArea", "handleBitmap handleBitmapAsset");
+T3Dpre4ProjectImporter::genProcessor("WorldEditor", "selectHandle selectHandleAsset defaultHandle defaultHandleAsset lockedHandle lockedHandleAsset");
+T3Dpre4ProjectImporter::genProcessor("GuiControlProfile", "bitmap bitmapAsset");
+T3Dpre4ProjectImporter::genProcessor("GuiMLTextCtrl", "deniedSound deniedSoundAsset");
+
+function T3Dpre4ProjectImporter::processGuiBitmapButtonCtrlLine(%this, %line)
+{
+   %outLine = processGuiBitmapButtonCtrlField(%line, "bitmap", "bitmapAsset");
+   if(%outLine !$= %line) return %outLine;
+   
+   return %line;
+}
+
+//==============================================================================
+// Datablocks
+//==============================================================================
+T3Dpre4ProjectImporter::genProcessor("ForestItemData", "shape shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("CubeMapData", "cubemapFace cubeMapFaceAsset cubemap cubemapAsset cubeFace cubeMapFaceAsset");
+T3Dpre4ProjectImporter::genProcessor("DebrisData", "shape shapeAsset shapeFile shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("DecalData", "material materialAsset");
+T3Dpre4ProjectImporter::genProcessor("ExplosionData", "explosionShape explosionShapeAsset");
+T3Dpre4ProjectImporter::genProcessor("ParticleData", "texture textureAsset textureName textureAsset textureExt textureExtAsset textureExtName textureExtAsset");
+T3Dpre4ProjectImporter::genProcessor("PrecipitationData", "drop dropAsset dropTexture dropAsset splash splashAsset splashTexture splashAsset soundProfile soundAsset");
+T3Dpre4ProjectImporter::genProcessor("SplashData", "texture textureAsset soundProfile SoundAsset");
+T3Dpre4ProjectImporter::genProcessor("LightFlareData", "flareTexture flareTextureAsset");
+T3Dpre4ProjectImporter::genProcessor("PhysicsDebrisData", "shape shapeAsset shapeFile shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("PhysicsShapeData", "shape shapeAsset shapeName shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("ProjectileData", "projectileShape projectileShapeAsset projectileShapeName projectileShapeAsset sound projectileSoundAsset");
+T3Dpre4ProjectImporter::genProcessor("ShapeBaseData", "shapeFile shapeAsset shape shapeAsset debrisShape debrisShapeAsset debrisShapeName debrisShapeAsset");
+T3Dpre4ProjectImporter::genProcessor("ShapeBaseImageData", "shape shapeAsset[0] shapeFP shapeAsset[1] shapeFile shapeAsset[0] shapeFileFP shapeAsset[1] stateSound stateSoundAsset");
+T3Dpre4ProjectImporter::genProcessor("ProximityMineData","armingSound ArmSoundAsset TriggerSound TriggerSoundAsset");
+T3Dpre4ProjectImporter::genProcessor("WheeledVehicleTire", "shape shapeAsset shapeFile shapeAsset");
+T3Dpre4ProjectImporter::genProcessor("WheeledVehicleData", "engineSound engineSoundAsset squealSound squealSoundAsset");
+T3Dpre4ProjectImporter::genProcessor("FlyingVehicleData", "engineSound engineSoundAsset jetSound jetSoundAsset");
+T3Dpre4ProjectImporter::genProcessor("HoverVehicleData", "engineSound engineSoundAsset jetSound jetSoundAsset floatSound floatSoundAsset");
+
+//==============================================================================
+// Datablocks - Long Lists
+//==============================================================================
+// - RigidShapeData
+$rigidEntriesList = "softImpactSound softImpactSoundAsset hardImpactSound hardImpactSoundAsset";
+$rigidEntriesList = $rigidEntriesList SPC "exitingWater exitingWaterAsset impactWaterEasy impactWaterEasyAsset";
+$rigidEntriesList = $rigidEntriesList SPC "impactWaterMedium impactWaterMediumAsset impactWaterHard impactWaterHardAsset";
+$rigidEntriesList = $rigidEntriesList SPC "waterWakeSound waterWakeSoundAsset";
+T3Dpre4ProjectImporter::genProcessor("RigidShapeData",$rigidEntriesList);
+// - PlayerData
+$PlayerEntriesList = "shapeFP shapeFPAsset shapeNameFP shapeFPAsset";
+$PlayerEntriesList = $PlayerEntriesList SPC "FootSoftSound FootSoftAsset FootHardSound FootHardAsset FootMetalSound FootMetalAsset";
+$PlayerEntriesList = $PlayerEntriesList SPC "FootSnowSound FootSnowAsset FootShallowSound FootShallowSplashAsset";
+$PlayerEntriesList = $PlayerEntriesList SPC "FootWadingSound FootWadingAsset FootUnderwaterSound FootUnderWaterAsset";
+$PlayerEntriesList = $PlayerEntriesList SPC "FootBubblesSound FootBubblesAsset movingBubblesSound MoveBubblesAsset";
+$PlayerEntriesList = $PlayerEntriesList SPC "waterBreathSound WaterBreathAsset";
+$PlayerEntriesList = $PlayerEntriesList SPC "impactSoftSound ImpactSoftAsset impactHardSound impactHardAsset";
+$PlayerEntriesList = $PlayerEntriesList SPC "impactMetalSound ImpactMetalAsset impactSnowSound impactSnowAsset";
+$PlayerEntriesList = $PlayerEntriesList SPC "impactWaterEasy impactWaterEasyAsset impactWaterMedium impactWaterMediumAsset impactWaterHard impactWaterHardAsset";
+$PlayerEntriesList = $PlayerEntriesList SPC "exitingWater ExitWaterAsset";
+T3Dpre4ProjectImporter::genProcessor("PlayerData", $PlayerEntriesList);
+// - Material
+$MaterialEntriesList = "baseTex diffuseMapAsset diffuseMap diffuseMapAsset";
+$MaterialEntriesList = $MaterialEntriesList SPC "lightMap lightMapAsset toneMap toneMapAsset";
+$MaterialEntriesList = $MaterialEntriesList SPC "detailTex detailMapAsset detailMap detailMapAsset detailNormalMap detailNormalMapAsset";
+$MaterialEntriesList = $MaterialEntriesList SPC "overlayTex overlayMapAsset overlayMap overlayMapAsset";
+$MaterialEntriesList = $MaterialEntriesList SPC "bumpTex normalMapAsset normalMap normalMapAsset";
+$MaterialEntriesList = $MaterialEntriesList SPC "ormConfigMap ormConfigMapAsset roughMap roughMapAsset";
+$MaterialEntriesList = $MaterialEntriesList SPC "aoMap aoMapAsset metalMap metalMapAsset";
+$MaterialEntriesList = $MaterialEntriesList SPC "glowMap glowMapAsset";
+$MaterialEntriesList = $MaterialEntriesList SPC "customFootstepSound customFootstepSoundAsset customImpactSound customImpactSoundAsset";
+T3Dpre4ProjectImporter::genProcessor("Material", $MaterialEntriesList);
+//==============================================================================
+// Materials
+//==============================================================================
+function T3Dpre4ProjectImporter::processMaterialObject(%this, %fileObject, %objectName)
+{
+   %matAsset = MaterialAsset::getAssetIdByMaterialName(%objectName);
+   
+   if(%matAsset $= "" || %matAsset $= "Core_Rendering:NoMaterial")
+   {
+      %assetName = %objectName;
+   
+      %moduleName = AssetBrowser.dirHandler.getModuleFromAddress($ProjectImporter::modulePath).ModuleId;
+      
+      %assetPath = $ProjectImporter::currentFilePath @ "/";   
+      
+      %tamlpath = %assetPath @ %assetName @ ".asset.taml";
+      %scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;//%fileObject.fileDestination;
+      
+      if(isFile(%tamlpath))
+      {
+         projectImporterLog("T3Dpre4ProjectImporter::processMaterialObject() - Failed to create as taml file already exists: " @ %fileObject.fileName);
+         return false;
+      }
+      
+      %asset = new MaterialAsset()
+      {
+         AssetName = %assetName;
+         versionId = 1;
+         shaderData = "";
+         materialDefinitionName = %assetName;
+         scriptFile = fileBase(%scriptPath);
+      };
+      
+      //Now we make our scripted definition "real", and append it to our asset
+      //so it is serialized.
+      /*%objectDefinition = "";
+      for(%l=0; %l < %fileObject.count(); %l++)
+      {
+         %objectLine = %fileObject.getKey(%l);  
+         if(!isObject(%objectLine))
+         {
+            %objectDefinition = %objectDefinition @ %objectLine;
+         }
+      }
+      
+      eval(%objectDefinition);
+      
+      if(isObject(%objectName))
+      {
+         %asset.add(%objectName);
+      }*/
+      
+      if(!isDirectory(%assetPath))
+      {
+         DirectoryHandler::createFolder(0, %assetPath);
+      }
+      
+      %success = false;
+      if(TamlWrite(%asset, %tamlpath))
+      {
+         //now write the script file
+         if ( $ProjectImporter::fileObject.openForWrite( %scriptPath ) ) 
+         {
+            for(%i=0; %i < %fileObject.count(); %i++)
+            {
+               %objectLine = %fileObject.getKey(%i);
+               if(isObject(%objectLine))
+               {
+                  %defineLine = %fileObject.getKey(0);
+                  $ProjectImporter::fileObject.writeLine(%defineLine);
+               }
+               else
+               {
+                  $ProjectImporter::fileObject.writeLine(%objectLine);
+               }
+            }
+            
+            $ProjectImporter::fileObject.close();
+         }
+         
+         %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
+                  
+         %success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
+      }
+         
+      if(!%success)
+         return false;
+   }
+   
+   return false;
+}
+
+function T3Dpre4ProjectImporter::processTerrainMaterialLine(%this, %line)
+{
+   %outLine = processLegacyField(%line, "diffuseMap", "diffuseMapAsset");
+   if(%outLine !$= %line) return %outLine;
+   %outLine = processLegacyField(%line, "normalMap", "normalMapAsset");
+   if(%outLine !$= %line) return %outLine;
+   %outLine = processLegacyField(%line, "detailMap", "detailMapAsset");
+   if(%outLine !$= %line) return %outLine;
+   %outLine = processLegacyField(%line, "ORMConfigMap", "ORMConfigMapAsset");
+   if(%outLine !$= %line) return %outLine;
+   %outLine = processLegacyField(%line, "macroMap", "macroMapAsset");
+   if(%outLine !$= %line) return %outLine;
+   return %line;
+}
+
+function T3Dpre4ProjectImporter::processTerrainMaterialObject(%this, %fileObject, %objectName)
+{
+   %matAsset = TerrainMaterialAsset::getAssetIdByMaterialName(%objectName);
+   
+   if(%matAsset $= "" || %matAsset $= "Core_Rendering:noMaterial")
+   {
+      %assetName = %objectName;
+   
+      %moduleName = AssetBrowser.dirHandler.getModuleFromAddress($ProjectImporter::modulePath).ModuleId;
+      
+      %assetPath = $ProjectImporter::currentFilePath @ "/"; 
+      
+      %tamlpath = %assetPath @ %assetName @ ".asset.taml";
+      %scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;//%fileObject.fileDestination;
+      
+      if(isFile(%tamlpath))
+      {
+         projectImporterLog("T3Dpre4ProjectImporter::processTerrainMaterialObject() - Failed to create as taml file already exists: " @ %fileObject.fileName);
+         return false;
+      }
+      
+      %asset = new TerrainMaterialAsset()
+      {
+         AssetName = %assetName;
+         versionId = 1;
+         shaderData = "";
+         materialDefinitionName = %objectName;
+         scriptFile = fileName(%scriptPath);
+      };
+      
+      %success = false;
+      if(TamlWrite(%asset, %tamlpath))
+      {
+         %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
+         
+         %success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
+      }
+      
+      if(!%success)
+         return false;
+   }
+   
+   return false;
+}
+//==============================================================================
+// PostEffects
+//==============================================================================
+T3Dpre4ProjectImporter::genProcessor("PostEffect", "texture textureAsset");
+
+//==============================================================================
+// Sounds
+// Sounds are a little weird because there's so much data tied up in a given sound
+// source. So our approach is find old SFXProfiles and process those into sound assets
+// by cross-referencing the filename for existing asset definitions.
+// Using existing SFXProfiles allows us to also injest the descriptions, giving us
+// our meta-properties on the sound asset itself.
+//==============================================================================
+T3Dpre4ProjectImporter::genProcessor("SFXAmbience", "soundTrack soundTrackAsset");
+T3Dpre4ProjectImporter::genProcessor("SFXPlayList", "track trackAsset");
+
+function T3Dpre4ProjectImporter::processSFXProfileLine(%this, %line)
+{
+   return %line;
+}
+
+function T3Dpre4ProjectImporter::processSFXProfileObject(%this, %file, %objectName)
+{
+   %soundFilename = findObjectField(%file, "filename");
+   
+   %soundFilename = sanitizeFilename(%soundFilename);
+   
+   if(fileExt(%soundFilename) $= "")
+   {
+      %soundFilename = testFilenameExtensions(%soundFilename);  
+   }
+
+   %soundAsset = SoundAsset::getAssetIdByFilename(%soundFilename);
+   
+   //Throw a warn that this file's already been claimed and move on
+   if(%soundAsset !$= "")
+   {
+      projectImporterLog("T3Dpre4ProjectImporter::processSFXProfileObject() - attempting to process SFXProfile " @ %objectName 
+               @ " but its filename is already associated to another sound asset. Continuing, but be aware.");
+   }  
+
+   %assetName = %objectName;
+
+   %moduleName = AssetBrowser.dirHandler.getModuleFromAddress(%soundFilename).ModuleId;
+   
+   %assetPath = filePath(%soundFilename) @ "/";   
+   
+   %tamlpath = %assetPath @ %assetName @ ".asset.taml";
+   
+   if(isFile(%tamlpath))
+   {
+      projectImporterLog("T3Dpre4ProjectImporter::processSFXProfileObject() - Failed to create as taml file already exists: " @ %soundFilename);
+      return false;
+   }
+   
+   %asset = new SoundAsset()
+   {
+      AssetName = %assetName;
+      versionId = 1;
+      shaderData = "";
+      soundFile = fileBase(%soundFilename) @ fileExt(%soundFilename);
+   };
+   
+   %descriptionName = findObjectField(%file, "description");
+   
+   if(%descriptionName !$= "")
+   {
+      //Optimization, see if we already have this description by happenstance
+      if(isObject(%descriptionName))
+      {
+         %asset.sourceGroup = %descriptionName.sourceGroup;
+         %asset.volume = %descriptionName.volume;
+         %asset.pitch = %descriptionName.pitch;
+         %asset.isLooping = %descriptionName.isLooping;
+         %asset.priority = %descriptionName.priority;
+         %asset.useHardware = %descriptionName.useHardware;
+         %asset.is3D = %descriptionName.is3D;
+         %asset.minDistance = %descriptionName.minDistance;
+         %asset.maxDistance = %descriptionName.maxDistance;
+         %asset.scatterDistance = %descriptionName.scatterDistance;
+         %asset.coneInsideAngle = %descriptionName.coneInsideAngle;            
+         %asset.coneOutsideAngle = %descriptionName.coneOutsideAngle;         
+         %asset.coneOutsideVolume = %descriptionName.coneOutsideVolume;
+         %asset.rolloffFactor = %descriptionName.rolloffFactor;
+         %asset.isStreaming = %descriptionName.isStreaming;
+      }
+      else
+      {
+         %objFileFinder = "";
+         //first check our cache
+         if(isObject($ProjectImporter::SFXDescriptionCache) && 
+            $ProjectImporter::SFXDescriptionCache.getIndexFromKey(%descriptionName) !$= "")
+         {
+            %key = $ProjectImporter::SFXDescriptionCache.getIndexFromKey(%descriptionName);
+            %objFileFinder = $ProjectImporter::SFXDescriptionCache.getValue(%key);
+         }
+         else
+         {
+            %objFileFinder = findObjectInFiles(%descriptionName);
+         }
+         
+         if(%objFileFinder !$= "")
+         {
+            %valueArray = new ArrayObject();
+               
+            %fileObj = getField(%objFileFinder, 0);
+               
+            %valueArray.add("sourceGroup" SPC findObjectField(%fileObj, "sourceGroup"));
+            %valueArray.add("volume" SPC findObjectField(%fileObj, "volume"));
+            %valueArray.add("pitch" SPC findObjectField(%fileObj, "pitch"));
+            %valueArray.add("isLooping" SPC findObjectField(%fileObj, "isLooping"));
+            %valueArray.add("priority" SPC findObjectField(%fileObj, "priority"));
+            %valueArray.add("useHardware" SPC findObjectField(%fileObj, "useHardware"));
+            %valueArray.add("is3D" SPC findObjectField(%fileObj, "is3D"));
+            %valueArray.add("minDistance" SPC findObjectField(%fileObj, "minDistance"));
+            %valueArray.add("maxDistance" SPC findObjectField(%fileObj, "maxDistance"));
+            %valueArray.add("scatterDistance" SPC findObjectField(%fileObj, "scatterDistance"));
+            %valueArray.add("coneInsideAngle" SPC findObjectField(%fileObj, "coneInsideAngle"));
+            %valueArray.add("coneOutsideAngle" SPC findObjectField(%fileObj, "coneOutsideAngle"));
+            %valueArray.add("coneOutsideVolume" SPC findObjectField(%fileObj, "coneOutsideVolume"));
+            %valueArray.add("rolloffFactor" SPC findObjectField(%fileObj, "rolloffFactor"));
+            %valueArray.add("isStreaming" SPC findObjectField(%fileObj, "isStreaming"));
+            
+            if(isObject($ProjectImporter::SFXDescriptionCache))
+            {
+               $ProjectImporter::SFXDescriptionCache.add(%descriptionName, %objFileFinder);
+            }
+            
+            for(%v=0; %v < %valueArray.Count(); %v++)
+            {
+               %varSet = %valueArray.getKey(%v);
+               %var = getWord(%varSet, 0);
+               %varVal = getWord(%varSet, 1);
+
+               if(%varVal !$= "")
+                  %asset.setFieldValue(%var, %varVal);
+            }
+         
+            %valueArray.delete();
+         }
+      }
+   }
+  
+   %success = false; 
+   if(TamlWrite(%asset, %tamlpath))
+   {
+      %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
+      
+      %success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
+   }
+   
+   if(!%success)
+      return false;
+   
+   %file.skip = true;
+   
+   return true;
+}
+
+function T3Dpre4ProjectImporter::processAudioProfileObject(%this, %file, %objectName)
+{
+   return %this.processSFXProfileObject(%file, %objectName);
+}
+      
+function T3Dpre4ProjectImporter::processSFXDescriptionObject(%this, %file, %objectName)
+{
+   //$ProjectImporter::ToRemoveObjectList.add(%objectName, %file TAB 0);
+   
+   return true;
+}
+
+function T3Dpre4ProjectImporter::processAudioDescriptionObject(%this, %file, %objectName)
+{
+   $ProjectImporter::ToRemoveObjectList.add(%objectName, %file TAB 0);
+   
+   return true;
+}
+
+//==============================================================================
+// Misc Utility functions
+//==============================================================================
+//This is functionally identical to processLegacyField, but we have to special-snowflake our asset lookups
+//due to it using suffix-based indirections
+function processGuiBitmapButtonCtrlField(%line, %originalFieldName, %newFieldName)
+{
+   if(!strIsMatchExpr("*"@%originalFieldName@"=*\"*\";*", %line) && 
+      !strIsMatchExpr("*"@%originalFieldName@"[*=*\"*\";*", %line) &&
+      !strIsMatchExpr("*"@%originalFieldName@" *=*\"*\";*", %line))
+      return %line;
+      
+   %outLine = strreplace(%line, %originalFieldName, %newFieldName);
+   
+   //get the value
+   %value = "";
+   %pos = strpos(%outLine, "= \"");
+   if(%pos != -1)
+   {
+     %endPos = strpos(%outLine, "\";", %pos); 
+     
+     %value = getSubStr(%outLine, %pos+3, %endPos-%pos-3);
+   }
+   else
+   {
+      %pos = strpos(%outLine, "=\"");
+      if(%pos != -1)
+      {
+        %endPos = strpos(%outLine, "\";", %pos); 
+        
+        %value = getSubStr(%outLine, %pos+2, %endPos-%pos-2);
+      }
+   }
+   
+   if(%outLine !$= %line && %pos != -1 && %endPos != -1 && %value !$= "")
+   {
+      projectImporterLog("Legacy Project Importer - processing legacy field line: " @ %line);
+      
+      if(startsWith(%value, "$") || startsWith(%value, "#"))
+      {
+         //These are going to be texture/render targets, and we can leave them alone
+         return %line;
+      }
+      
+      %targetFilename = sanitizeFilename(%value);
+      
+      //If we still have nothing, then we fail it out
+      if(!isFile(%targetFilename))
+      {
+         projectImporterLog("Legacy Project Importer - file described in line could not be found/is not valid");
+         return %line;
+      }
+      
+      $ProjectImporter::assetQuery.clear();
+      %foundAssets = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %targetFilename);
+      if(%foundAssets != 0)
+      {
+         %assetId = $ProjectImporter::assetQuery.getAsset(0);
+         projectImporterLog("Legacy Project Importer - processing of legacy field line's value: " @ %value @ " has found a matching AssetId: " @ %assetId);
+      }
+     
+      if(%assetId !$= "" && AssetDatabase.isDeclaredAsset(%assetId))
+      {
+         //if (%assetId.getStatusString() $= "Ok")
+         %outLine = strReplace(%outLine, %value, %assetId);
+         //else
+         //   error("Asset assignment failure:", %assetId, getStatusString());
+      }
+   }
+   
+   if(%outLine !$= %line)
+   {
+      projectImporterLog("Legacy Project Importer - processing of legacy line: " @ %line @ " has been updated to: " @ %outLine);
+      return %outLine;  
+   }
+   else
+   {
+      return %line;  
+   }
+}

+ 7 - 0
Templates/BaseGame/game/tools/projectImporter/importers/pre40/pre40ImporterGuis.asset.taml

@@ -0,0 +1,7 @@
+<GUIAsset
+    canSave="true"
+    canSaveDynamicFields="true"
+    AssetName="pre40ImporterGuis"
+    GUIFile="@assetFile=pre40ImporterGuis.gui"
+    ScriptFile="@assetFile=pre40ImporterGuis.tscript"
+    VersionId="1" />

+ 129 - 0
Templates/BaseGame/game/tools/projectImporter/importers/pre40/pre40ImporterGuis.gui

@@ -0,0 +1,129 @@
+//--- OBJECT WRITE BEGIN ---
+new GuiContainer(Pre40ImporterPage0) {
+   margin = "0 0 0 0";
+   padding = "0 0 0 0";
+   anchorTop = "1";
+   anchorBottom = "0";
+   anchorLeft = "1";
+   anchorRight = "0";
+   position = "1 1";
+   extent = "539 429";
+   minExtent = "8 2";
+   horizSizing = "width";
+   vertSizing = "bottom";
+   profile = "GuiDefaultProfile";
+   visible = "1";
+   active = "1";
+   tooltipProfile = "GuiToolTipProfile";
+   hovertime = "1000";
+   isContainer = "1";
+   canSave = "1";
+   canSaveDynamicFields = "1";
+
+   new GuiMLTextCtrl() {
+      lineSpacing = "2";
+      allowColorChars = "0";
+      maxChars = "-1";
+      text = "Next, we'll import in content files, such as image, models and sounds.";
+      useURLMouseCursor = "0";
+      position = "111 21";
+      extent = "328 28";
+      minExtent = "8 2";
+      horizSizing = "right";
+      vertSizing = "bottom";
+      profile = "ToolsGuiMLTextProfile";
+      visible = "1";
+      active = "1";
+      tooltipProfile = "GuiToolTipProfile";
+      hovertime = "1000";
+      isContainer = "0";
+      canSave = "1";
+      canSaveDynamicFields = "0";
+   };
+   new GuiMLTextCtrl() {
+      lineSpacing = "2";
+      allowColorChars = "0";
+      maxChars = "-1";
+      text = "Processing...";
+      useURLMouseCursor = "0";
+      position = "152 141";
+      extent = "245 14";
+      minExtent = "8 2";
+      horizSizing = "right";
+      vertSizing = "bottom";
+      profile = "ToolsGuiDefaultProfile";
+      visible = "1";
+      active = "1";
+      tooltipProfile = "GuiToolTipProfile";
+      hovertime = "1000";
+      isContainer = "0";
+      internalName = "processingText";
+      canSave = "1";
+      canSaveDynamicFields = "0";
+   };
+};
+
+new GuiContainer(Pre40ImporterPage1) {
+   margin = "0 0 0 0";
+   padding = "0 0 0 0";
+   anchorTop = "1";
+   anchorBottom = "0";
+   anchorLeft = "1";
+   anchorRight = "0";
+   position = "1 1";
+   extent = "539 429";
+   minExtent = "8 2";
+   horizSizing = "width";
+   vertSizing = "bottom";
+   profile = "GuiDefaultProfile";
+   visible = "1";
+   active = "1";
+   tooltipProfile = "GuiToolTipProfile";
+   hovertime = "1000";
+   isContainer = "1";
+   canSave = "1";
+   canSaveDynamicFields = "1";
+
+   new GuiMLTextCtrl() {
+      lineSpacing = "2";
+      allowColorChars = "0";
+      maxChars = "-1";
+      text = "Now, we'll import in script-based files such as guis, levels and scripts.";
+      useURLMouseCursor = "0";
+      position = "111 21";
+      extent = "328 28";
+      minExtent = "8 2";
+      horizSizing = "right";
+      vertSizing = "bottom";
+      profile = "ToolsGuiMLTextProfile";
+      visible = "1";
+      active = "1";
+      tooltipProfile = "GuiToolTipProfile";
+      hovertime = "1000";
+      isContainer = "0";
+      canSave = "1";
+      canSaveDynamicFields = "0";
+   };
+   new GuiMLTextCtrl() {
+      lineSpacing = "2";
+      allowColorChars = "0";
+      maxChars = "-1";
+      text = "Processing...";
+      useURLMouseCursor = "0";
+      position = "152 141";
+      extent = "245 14";
+      minExtent = "8 2";
+      horizSizing = "right";
+      vertSizing = "bottom";
+      profile = "ToolsGuiDefaultProfile";
+      visible = "1";
+      active = "1";
+      tooltipProfile = "GuiToolTipProfile";
+      hovertime = "1000";
+      isContainer = "0";
+      internalName = "processingText";
+      canSave = "1";
+      canSaveDynamicFields = "0";
+   };
+};
+//--- OBJECT WRITE END ---

+ 92 - 0
Templates/BaseGame/game/tools/projectImporter/importers/pre40/pre40ImporterGuis.tscript

@@ -0,0 +1,92 @@
+function Pre40ImporterPage0::openPage(%this)
+{
+   ProjectImportWindow-->nextButton.setActive(false);
+   %this-->processingText.setText("Processing...");
+   Canvas.repaint();
+   
+   //copy binary files over
+   for(%i=0; %i < $ProjectImporter::FileList.count(); %i++)
+   {
+      %file = $ProjectImporter::FileList.getKey(%i);
+      %rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
+      if(%rootFileSectionObject.binaryFile == true)
+      {
+         %filePath = filePath(%file);
+         %fileName = %rootFileSectionObject.fileName;
+         %fileBase = %rootFileSectionObject.fileBase;
+         %fileExt = %rootFileSectionObject.fileExt;
+         
+         //filter out some unneeded folders
+         %slashCount = getTokenCount(%filePath, "/");
+         %topFolder = getToken(%filePath, "/", %slashCount-1);
+         if(%topFolder $= "")
+            %topFolder = getToken(%filePath, "/", %slashCount-2);
+            
+         if(%topFolder $= "creator" || %topFolder $= "tools" || %topFolder $= "web")
+         {
+            %file = findNextFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*" );
+            continue;
+         }
+         
+         %targetFilePath = strReplace(%file, $ProjectImporter::sourceContentFolder, $ProjectImporter::modulePath);
+         
+         %sanitizedFilename = sanitizeString(%fileBase);
+         if(startsWith(%sanitizedFilename, "_"))
+         {
+            %sanitizedFilename = substr(%sanitizedFilename, 1, -1);
+         }
+         if(%sanitizedFilename !$= %fileBase)
+         {
+            %targetFilePath = filePath(%targetFilePath) @ "/" @ %sanitizedFilename @ %fileExt;
+         }
+         
+         %targetFolder = filePath(%targetFilePath);
+         
+         if(!isDirectory(%targetFolder))
+         {
+            DirectoryHandler::createFolder(0, %targetFolder);
+         }
+         
+         if(!pathCopy(%file, %targetFilePath, false))
+         {
+            $ProjectImporter::log.add("Legacy Project Importer, failed to copy file: " @ %file @ " to destination: " @ %targetFilePath);
+            continue;
+         }
+         
+         %rootFileSectionObject.localPath = %targetFilePath;
+         
+         //If it was an asset definition file, go ahead and register it
+         if(%rootFileSectionObject.isAssetFile)
+         {
+            %moduleName = AssetBrowser.dirHandler.getModuleFromAddress(%targetFilePath).ModuleId;
+            %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
+            
+            AssetDatabase.addDeclaredAsset(%moduleDef, %targetFilePath);
+         }
+      }
+   } 
+   
+   //Now, we need to do some initial importing processing
+   T3Dpre4ProjectImporter.doContentImport(); 
+   
+   //Once that's done, update the text of the UI
+   %this-->processingText.setText("Done!");
+   ProjectImportWindow-->nextButton.setActive(true);
+   Canvas.repaint();
+}
+
+function Pre40ImporterPage1::openPage(%this)
+{
+   ProjectImportWindow-->nextButton.setActive(false);
+   %this-->processingText.setText("Processing...");
+   Canvas.repaint();
+   
+   //Now, we need to do some initial importing processing
+   T3Dpre4ProjectImporter.doScriptImport();
+   
+   //Once that's done, update the text of the UI
+   %this-->processingText.setText("Done!");
+   ProjectImportWindow-->nextButton.setActive(true);
+   Canvas.repaint();
+}
+

+ 0 - 5
Templates/BaseGame/game/tools/projectImporter/main.tscript

@@ -24,11 +24,6 @@ function initializeProjectImporter()
    echo(" % - Initializing Project Importer");  
    
    exec("./scripts/projectImporter." @ $TorqueScriptFileExtension);
-   
-   //Versioned actions
-   exec("./scripts/pre40/T3Dpre4ProjectImporter." @ $TorqueScriptFileExtension);
-   
-   
    exec("./guis/projectImporter.gui");
    
    new ScriptObject( ProjectImporterPlugin )

+ 0 - 1320
Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript

@@ -1,1320 +0,0 @@
-function T3Dpre4ProjectImporter::setupModule(%this)
-{
-   %newModuleName = $ProjectImporter::moduleName;
-      
-   $ProjectImporter::log.add("Creating a new Module named: " @ %newModuleName);
-   
-   %moduleFilePath = "data/" @ %newModuleName;
-   %moduleDefinitionFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".module";
-   %moduleScriptFilePath = %moduleFilePath @ "/" @ %newModuleName @ "." @ $TorqueScriptFileExtension;
-   
-   %newModule = new ModuleDefinition()
-   {
-      ModuleId = %newModuleName;
-      versionId = 1;
-      ScriptFile = %newModuleName @ "." @ $TorqueScriptFileExtension;
-      CreateFunction="onCreate";
-	   DestroyFunction="onDestroy";
-	   Group = "Game";
-      
-      new DeclaredAssets()
-      {
-         Extension = "asset.taml";
-         Recurse = true;
-      };
-   };
-   
-   TAMLWrite(%newModule, %moduleDefinitionFilePath); 
-   
-   //Now generate the script file for it
-   %file = new FileObject();
-   %templateFile = new FileObject();
-   
-   %moduleTemplateCodeFilePath = AssetBrowser.templateFilesPath @ "module.tscript.template";
-   
-   if(%file.openForWrite(%moduleScriptFilePath) && %templateFile.openForRead(%moduleTemplateCodeFilePath))
-   {
-      while( !%templateFile.isEOF() )
-      {
-         %line = %templateFile.readline();
-         %line = strreplace( %line, "@@", %newModuleName );
-         
-         %file.writeline(%line);
-         //$ProjectImporter::log.add(%line);
-      }
-      
-      %file.close();
-      %templateFile.close();
-   }
-   else
-   {
-      %file.close();
-      %templateFile.close();
-      
-      $ProjectImporter::log.add("CreateNewModule - Something went wrong and we couldn't write the script file!");
-   }
-   
-   //force a refresh of our modules list
-   ModuleDatabase.ignoreLoadedGroups(true);
-   ModuleDatabase.scanModules( "data", false );
-   %success = ModuleDatabase.loadExplicit(%newModuleName, 1);
-   ModuleDatabase.ignoreLoadedGroups(false);
-   
-   //force a reload of the Module lists
-   AssetBrowser.refresh();
-}
-
-function T3Dpre4ProjectImporter::copyFiles(%this)
-{
-   %currentPage = ProjectImportWindow.getCurrentPage();
-   
-   %currentPage-->fileCopyText.setText("Beginning copy of files to new module folder now. This may take a few minutes...");
-   Canvas.repaint();
-   
-   %file = findFirstFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*", true);
-   
-   while( %file !$= "" )
-   {
-      %filePath = filePath(%file);
-      %fileName = fileName(%file);
-      %fileBase = fileBase(%file);
-      %fileExt = fileExt(%file);
-      
-      if(endsWith(%fileName, ".asset.taml"))
-      {
-         %fileBase = strreplace(%fileBase, ".asset", "");
-         %fileExt = ".asset.taml";
-      }
-      
-      if(%fileExt $= ".dll" || %fileExt $= ".log" || %fileExt $= ".exe" || %fileExt $= ".manifest"|| %fileExt $= ".h" ||
-         %fileExt $= ".cpp" || %fileExt $= ".so" || %fileExt $= ".do" || %fileExt $= ".lib" ||%fileExt $= ".exp")
-      {
-         %file = findNextFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*" );
-         continue;
-      }
-      
-      //filter out some unneeded folders
-      %slashCount = getTokenCount(%filePath, "/");
-      %topFolder = getToken(%filePath, "/", %slashCount-1);
-      if(%topFolder $= "")
-         %topFolder = getToken(%filePath, "/", %slashCount-2);
-         
-      if(%topFolder $= "creator" || %topFolder $= "tools" || %topFolder $= "web")
-      {
-         %file = findNextFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*" );
-         continue;
-      }
-      
-      %targetFilePath = strReplace(%file, $ProjectImporter::sourceContentFolder, $ProjectImporter::modulePath);
-      
-      %sanitizedFilename = sanitizeString(%fileBase);
-      if(startsWith(%sanitizedFilename, "_"))
-      {
-         %sanitizedFilename = substr(%sanitizedFilename, 1, -1);
-      }
-      if(%sanitizedFilename !$= %fileBase)
-      {
-         %targetFilePath = filePath(%targetFilePath) @ "/" @ %sanitizedFilename @ %fileExt;
-      }
-      
-      %targetFolder = filePath(%targetFilePath);
-      
-      if(!isDirectory(%targetFolder))
-      {
-         DirectoryHandler::createFolder(0, %targetFolder);
-      }
-      
-      if(!pathCopy(%file, %targetFilePath, false))
-      {
-         $ProjectImporter::log.add("Legacy Project Importer, failed to copy file: " @ %file @ " to destination: " @ %targetFilePath);
-      }
-      
-      %file = findNextFileMultiExpr( $ProjectImporter::sourceContentFolder @ "/*.*" );
-   }
-   
-   //
-   //Now that we've done that, we'll load and scan the module for asset defs
-   %file = findFirstFileMultiExpr( $ProjectImporter::modulePath @ "/*.asset.taml", true);
-   
-   while( %file !$= "" )
-   {
-      %moduleName = AssetBrowser.dirHandler.getModuleFromAddress(%file).ModuleId;
-      %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
-      
-      AssetDatabase.addDeclaredAsset(%moduleDef, %file);
-      
-      %file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*.asset.taml" );
-   }
-   //
-   
-   %currentPage-->fileCopyText.setValue("File copy done! Press Next to continue.");
-   
-   ProjectImportWindow-->nextButton.setActive(true);
-   Canvas.repaint();
-}
-
-function T3Dpre4ProjectImporter::processImportedFiles(%this)
-{
-   if($ProjectImporter::importMode $= "CoreAndTools")
-   {
-      $ProjectImporter::modulePath = "Core";
-      %this.doImport();
-      
-      $ProjectImporter::modulePath = "Tools";
-      %this.doImport();
-   }
-   else
-   {
-      %this.doImport();
-   }
-   
-   %currentPage = ProjectImportWindow.getCurrentPage();
-   
-   %currentPage-->processingText.setText("Processing of files done! Press Next to continue.");
-   ProjectImportWindow-->nextButton.setActive(true);
-   Canvas.repaint();
-}
-
-function T3Dpre4ProjectImporter::doImport(%this)
-{
-   //Store off the current default import config
-   %defaultConfig = EditorSettings.value("Assets/AssetImporDefaultConfig", "");
-   EditorSettings.setValue("Assets/AssetImporDefaultConfig", "LegacyProjectImport");
-
-   //Update asset content
-   beginImageImport();
-   
-   %this.beginMaterialFilesImport();
-   
-   beginShapeImport();
-   beginTerrainImport();
-   beginLevelImport();
-   beginGUIImport();
-   
-   %this.beginCodeFilesImport();
-   
-   EditorSettings.setValue("Assets/AssetImporDefaultConfig", %defaultConfig);
-}
-
-function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this)
-{
-   %currentPage = ProjectImportWindow.getCurrentPage();
-   
-   //First, wipe out any files inside the folder first
-   %file = findFirstFileMultiExpr( $ProjectImporter::modulePath @ "/*/materials.*", true);
-   
-   %objectClassStack = new ArrayObject();
-   %fileOutputLines = new ArrayObject();
-   
-   $ProjectImporter::log.add("Legacy Project Importer - Beginning processing of imported code files");
-   
-   //Walk through and process all code files to update references
-   while( %file !$= "" )
-   {      
-      %fileWasChanged = false;
-      
-      %filename = fileName(%file);
-      %fileBase = fileBase(%file);
-      %fileExt = fileExt(%file);
-      %filePath = filePath(%file);
-      
-      $ProjectImporter::currentFilePath = %filePath @ "/";
-      
-      %currentPage-->processingText.setText("Processing material script file: " @ %file);
-      Canvas.repaint();
-      
-      if ( $ProjectImporter::fileObject.openForRead( %file ) ) 
-      {
-         $ProjectImporter::log.add("Legacy Project Importer - Beginning process of file: " @ %file);
-         %lineNum = 0;
-         while ( !$ProjectImporter::fileObject.isEOF() ) 
-         {
-            %line = $ProjectImporter::fileObject.readLine();
-            %trimmedLine = trim(%line);
-            
-            if(strIsMatchExpr("*new*(*)*", %line) && strpos(%line, "::") == -1)
-            {
-               %className = findObjectClass(%line, "new");
-               if (%className $= "") continue;
-
-               if(%className !$= "Material" && %className !$= "CustomMaterial" && %className !$= "TerrainMaterial" && %className !$= "CubemapData")
-                  {
-                     %lineNum++;
-                     %fileOutputLines.push_back(%line);
-                     continue;
-                  }
-                  
-                  %objectClassStack.push_back(%className);
-               
-               %objectName = findObjectName(%line, "new");
-               
-               if(%objectName $= "" && %className $= "TerrainMaterial")
-                  {
-                  %intName = findObjectField("internalName");
-                  %objectName = %intName @ "_terrainMat";
-                  %line = strReplace(%line, "()", "(" @ %intName @ ")");
-                  
-                  %fileWasChanged = true;
-                  }
-               else if(%objectName $= "" && %className $= "Material")
-               {
-                  %mapToName = findObjectField("mapTo");
-                  %objectName = %mapToName @ "_mat";
-                  %line = strReplace(%line, "()", "(" @ %mapToName @ ")");
-                  
-                  %fileWasChanged = true;
-               }
-                  
-               %sanitizedName = sanitizeString(%objectName);
-               if(startsWith(%sanitizedName, "_"))
-               {
-                  %sanitizedName = substr(%sanitizedName, 1, -1);
-               }
-               if(%sanitizedName !$= %objectName)
-               {
-                  %line = strReplace(%line, %objectName, %sanitizedName);
-                  
-                  %fileWasChanged = true;
-               }
-                  
-                  if(%objectClassStack.count() == 1)
-                  {
-                  %currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1);
-                  
-                     //we only process top-level objects directly                 
-                     %inheritanceList = getClassHierarchy(%currentObjClass);
-                     for (%classDepth =0; %classDepth<getWordCount(%inheritanceList); %classDepth++)
-                     {
-                        %subclass = getWord(%inheritanceList, %classDepth);
-                        %processFunction = "process" @ %subclass @ "Object";
-                        if(%this.isMethod(%processFunction))
-                        {
-                           %this.call(%processFunction, %file, %objectName);
-                        }
-                     }
-                  }
-               }
-            else if(strIsMatchExpr("*singleton*(*)*", %line))
-            {
-               %className = findObjectClass(%line, "singleton");
-               
-               if(%className !$= "Material" && %className !$= "CustomMaterial" && %className !$= "TerrainMaterial" && %className !$= "CubemapData")
-                  {
-                     %lineNum++;
-                     %fileOutputLines.push_back(%line);
-                     continue;
-                  }
-                  
-                  %objectClassStack.push_back(%className);
-               
-               %objectName = findObjectName(%line, "singleton");
-                  
-               %sanitizedName = sanitizeString(%objectName);
-               if(startsWith(%sanitizedName, "_"))
-               {
-                  %sanitizedName = substr(%sanitizedName, 1, -1);
-               }
-               if(%sanitizedName !$= %objectName)
-               {
-                  %line = strReplace(%line, %objectName, %sanitizedName);
-                  
-                  %fileWasChanged = true;
-               }
-               
-                  if(%objectClassStack.count() == 1)
-                  {
-                  %currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1);
-                  
-                     //we only process top-level objects directly                 
-                     %inheritanceList = getClassHierarchy(%currentObjClass);
-                     for (%classDepth =0; %classDepth<getWordCount(%inheritanceList); %classDepth++)
-                     {
-                        %subclass = getWord(%inheritanceList, %classDepth);
-                        %processFunction = "process" @ %subclass @ "Object";
-                        if(%this.isMethod(%processFunction))
-                        {
-                           %this.call(%processFunction, %file, %objectName);
-                        }
-                     }
-                  }
-               }
-            else if(strIsMatchExpr("*};*", %line))
-            {
-               //hit the end of an object, pop our object stack
-               %objectClassStack.pop_back();
-            }
-            else
-            {
-               if(%objectClassStack.count() != 0)
-               {
-                  %currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1);
-                  
-                  %inheritanceList = getClassHierarchy(%currentObjClass);
-                  for (%classDepth =0; %classDepth<getWordCount(%inheritanceList); %classDepth++)
-                  {
-                     %subclass = getWord(%inheritanceList, %classDepth);
-                     %processFunction = "process" @ %subclass @ "Line";
-                     if(%this.isMethod(%processFunction))
-                     {
-                        %outLine = %this.call(%processFunction, %line);
-
-                        if(%line !$= %outLine)
-                        {
-                           %fileWasChanged = true;
-                           %line = %outLine;
-                        }
-                     }
-                  }
-               }
-            }
-            %lineNum++;
-            
-            %fileOutputLines.push_back(%line);
-         }
-         
-         $ProjectImporter::fileObject.close();
-      }
-      else
-      {
-         $ProjectImporter::log.add("Legacy Project Importer - File not able to be opened: " @ %file);  
-      }
-      
-      if(%fileWasChanged)
-      {
-         $ProjectImporter::fileObject.openForWrite(%file);
-
-         for(%l = 0; %l < %fileOutputLines.count(); %l++)
-         {
-            %outLine = %fileOutputLines.getKey(%l);
-            
-            $ProjectImporter::fileObject.writeline(%outLine);
-         }
-         
-         $ProjectImporter::fileObject.close();
-      }
-      
-      %fileOutputLines.empty();
-      %objectClassStack.empty();
-      
-      %file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*/materials.*" );
-   }
-   
-   $ProjectImporter::log.add("Legacy Project Importer - Processing of imported code files done!");
-   
-   %fileOutputLines.delete();
-   %objectClassStack.delete();
-   
-   //now exec the materials
-   loadModuleMaterials("Game");
-}
-
-function T3Dpre4ProjectImporter::beginCodeFilesImport(%this)
-{
-   %currentPage = ProjectImportWindow.getCurrentPage();
-   
-   //First, wipe out any files inside the folder first
-   %file = findFirstFileMultiExpr( $ProjectImporter::modulePath @ "/*.*", true);
-   
-   %objectClassStack = new ArrayObject();
-   %fileOutputLines = new ArrayObject();
-   
-   $ProjectImporter::log.add("Legacy Project Importer - Beginning processing of imported code files");
-   
-   //Walk through and process all code files to update references
-   while( %file !$= "" )
-   {      
-      if(!endsWith(%file, "cs") && 
-         !endsWith(%file, "tscript") && 
-         !endsWith(%file, "mis") && 
-         !endsWith(%file, "gui") && 
-         !endsWith(%file, "prefab"))
-      {
-         %file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*.*" );
-         continue;
-      }
-      
-      %fileWasChanged = false;
-      
-      %filename = fileName(%file);
-      %fileBase = fileBase(%file);
-      %fileExt = fileExt(%file);
-      %filePath = filePath(%file);
-      
-      if(%filename $= "materials.cs" || %filename $= "materials.tscript" )
-      {
-         //we already handled materials script files, so skip
-         %file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*.*" );
-         continue;
-      }
-      
-      $ProjectImporter::currentFilePath = %filePath @ "/";
-      
-      %currentPage-->processingText.setText("Processing file: " @ %file);
-      Canvas.repaint();
-      
-      if ( $ProjectImporter::fileObject.openForRead( %file ) ) 
-      {
-         $ProjectImporter::log.add("Legacy Project Importer - Beginning process of file: " @ %file);
-         %lineNum = 0;
-         while ( !$ProjectImporter::fileObject.isEOF() ) 
-         {
-            %line = $ProjectImporter::fileObject.readLine();
-            %trimmedLine = trim(%line);
-            
-            if(strIsMatchExpr("*new*(*)*", %line) && strpos(%line, "::") == -1)
-            {
-               %className = findObjectClass(%line, "new");
-               if (%className $= "") continue;
-               
-               %objectClassStack.push_back(%className);
-               
-               %objectName = findObjectName(%line, "new");
-               
-               if(strIsMatchExpr("*%guiContent*=*new*", %line))
-               {
-                  %line = strReplace(%line, "%guiContent", "$guiContent");
-                  %fileWasChanged = true;
-               }
-               
-               if(%objectName !$= "")
-               {
-                  %sanitizedName = sanitizeString(%objectName);
-                  if(startsWith(%sanitizedName, "_"))
-                  {
-                     %sanitizedName = substr(%sanitizedName, 1, -1);
-                  }
-                  if(%sanitizedName !$= %objectName)
-                  {
-                     %line = strReplace(%line, %objectName, %sanitizedName);
-                     
-                     %fileWasChanged = true;
-                  }
-                  
-                  if(%objectClassStack.count() == 1)
-                  {
-                     %currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1);
-                     
-                     //we only process top-level objects directly                     
-                     %inheritanceList = getClassHierarchy(%currentObjClass);
-                     for (%classDepth =0; %classDepth<getWordCount(%inheritanceList); %classDepth++)
-                     {
-                        %subclass = getWord(%inheritanceList, %classDepth);
-                        %processFunction = "process" @ %subclass @ "Object";
-                        if(%this.isMethod(%processFunction))
-                        {
-                           %this.call(%processFunction, %file, %objectName);
-                        }
-                     }
-                  }
-               }
-               
-               //special handling here
-               if(%fileExt $= ".mis")
-               {
-                  if(%className $= "SimGroup" && %objectName $= "MissionGroup") 
-                  {
-                     if(%this.isMethod("processMissionGroupLine"))
-                     {
-                        %outLine = %this.call("processMissionGroupLine", %line, %fileBase);
-                        
-                        if(%line !$= %outLine)
-                        {
-                           %fileWasChanged = true;
-                           %line = %outLine;
-                        }
-                     }
-                  }
-                  else if(%className $= "ScriptObject" && %objectName $= "MissionInfo") 
-                  {
-                     if(%this.isMethod("processLevelInfoLine"))
-                     {
-                        %outLine = %this.call("processLevelInfoLine", %line);
-                        
-                        if(%line !$= %outLine)
-                        {
-                           %fileWasChanged = true;
-                           %line = %outLine;
-                        }
-                     }
-                  }
-                  else if(%className $= "Sky") 
-                  {
-                     if(%this.isMethod("processSkyLine"))
-                     {
-                        %outLine = %this.call("processSkyLine", %line);
-                        
-                        if(%line !$= %outLine)
-                        {
-                           %fileWasChanged = true;
-                           %line = %outLine;
-                        }
-                     }
-                  }
-                  else if(%className $= "Water") 
-                  {
-                     if(%this.isMethod("processWaterLine"))
-                     {
-                        %outLine = %this.call("processWaterLine", %line);
-                        
-                        if(%line !$= %outLine)
-                        {
-                           %fileWasChanged = true;
-                           %line = %outLine;
-                        }
-                     }
-                  }
-               }
-            }
-            else if(strIsMatchExpr("*singleton*(*)*", %line))
-            {
-               %className = findObjectClass(%line, "singleton");
-               
-               %objectClassStack.push_back(%className);
-               
-               %objectName = findObjectName(%line, "singleton");
-               
-               if(%objectName !$= "")
-               {
-                  %sanitizedName = sanitizeString(%objectName);
-                  if(startsWith(%sanitizedName, "_"))
-                  {
-                     %sanitizedName = substr(%sanitizedName, 1, -1);
-                  }
-                  if(%sanitizedName !$= %objectName)
-                  {
-                     %line = strReplace(%line, %objectName, %sanitizedName);
-                     
-                     %fileWasChanged = true;
-                  }
-               
-                  if(%objectClassStack.count() == 1)
-                  {
-                     %currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1);
-                     
-                     //we only process top-level objects directly
-                     %inheritanceList = getClassHierarchy(%currentObjClass);
-                     for (%classDepth =0; %classDepth<getWordCount(%inheritanceList); %classDepth++)
-                     {
-                        %subclass = getWord(%inheritanceList, %classDepth);
-                        %processFunction = "process" @ %subclass @ "Object";
-                        if(%this.isMethod(%processFunction))
-                        {
-                           %this.call(%processFunction, %file, %objectName);
-                        }
-                     }
-                  }
-               }
-            }
-            else if(strIsMatchExpr("*datablock*(*)*", %line) && (strPos(%line, "registerDatablock") == -1))
-            {
-               %className = findObjectClass(%line, "datablock");
-               
-               %objectClassStack.push_back(%className);
-               
-               %objectName = findObjectName(%line, "datablock");
-               
-               if(%objectName !$= "")
-               {
-                  if(%objectClassStack.count() == 1)
-                  {
-                     %currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1);
-                     
-                     //we only process top-level objects directly
-                     %inheritanceList = getClassHierarchy(%currentObjClass);
-                     for (%classDepth =0; %classDepth<getWordCount(%inheritanceList); %classDepth++)
-                     {
-                        %subclass = getWord(%inheritanceList, %classDepth);
-                        %processFunction = "process" @ %subclass @ "Object";
-                        if(%this.isMethod(%processFunction))
-                        {
-                           %this.call(%processFunction, %file, %objectName);
-                        } 
-                     }
-                  }
-               }
-            }
-            else if(strIsMatchExpr("*};*", %line))
-            {
-               //hit the end of an object, pop our object stack
-               %objectClassStack.pop_back();
-            }
-            else if(strIsMatchExpr("*exec(*.cs*)*", %line) || strIsMatchExpr("*exec(*.tscript*)*", %line))
-            {
-               %scriptExtRemovedLine = strReplace(%line, ".cs", "");
-               %scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
-               %line = %scriptExtRemovedLine;
-               %fileWasChanged = true;
-            }
-            else if(strIsMatchExpr("*queueexec(*.cs*)*", %line) || strIsMatchExpr("*queueexec(*.tscript*)*", %line))
-            {
-               %scriptExtRemovedLine = strReplace(%line, ".cs", "");
-               %scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
-               %line = %scriptExtRemovedLine;
-               %fileWasChanged = true;
-            }
-            else if(strIsMatchExpr("*registerDatablock(*.cs*)*", %line) || strIsMatchExpr("*registerDatablock(*.tscript*)*", %line))
-            {
-               %scriptExtRemovedLine = strReplace(%line, ".cs", "");
-               %scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
-               %line = %scriptExtRemovedLine;
-               %fileWasChanged = true;
-               
-            }
-            else if(strIsMatchExpr("*%this.addSequence(\"*);", %line))
-            {
-               %outLine = processLegacyShapeConstructorField(%line);
-               if(%line !$= %outLine)
-               {
-                  %fileWasChanged = true;
-                  %line = %outLine;
-               }
-            }
-            else
-            {
-               if(%objectClassStack.count() != 0)
-               {
-                  %currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1);
-                  
-                  %inheritanceList = getClassHierarchy(%currentObjClass);
-                  for (%classDepth =0; %classDepth<getWordCount(%inheritanceList); %classDepth++)
-                  {
-                     %subclass = getWord(%inheritanceList, %classDepth);
-                     %processFunction = "process" @ %subclass @ "Line";
-                     if(%this.isMethod(%processFunction))
-                     {
-                        %outLine = %this.call(%processFunction, %line);
-
-                        if(%line !$= %outLine)
-                        {
-                           %fileWasChanged = true;
-                           %line = %outLine;
-                        }
-                      }
-                  }
-               }
-            }
-            %lineNum++;
-            
-            %fileOutputLines.push_back(%line);
-         }
-         
-         $ProjectImporter::fileObject.close();
-      }
-      else
-      {
-         $ProjectImporter::log.add("Legacy Project Importer - File not able to be opened: " @ %file);  
-      }
-      
-      if(%fileWasChanged)
-      {
-         $ProjectImporter::fileObject.openForWrite(%file);
-
-         for(%l = 0; %l < %fileOutputLines.count(); %l++)
-         {
-            %outLine = %fileOutputLines.getKey(%l);
-            
-            $ProjectImporter::fileObject.writeline(%outLine);
-         }
-         
-         $ProjectImporter::fileObject.close();
-      }
-      
-      %fileOutputLines.empty();
-      %objectClassStack.empty();
-      
-      %file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*.*" );
-   }
-   
-   $ProjectImporter::log.add("Legacy Project Importer - Processing of imported code files done!");
-   
-   //exec common loader files, process the remainder into assets
-   
-   //beginMaterialImport();
-   //beginGUIImport();
-   //beginTerrainMaterialImport();
-   //beginTerrainImport();
-   
-   %fileOutputLines.delete();
-   %objectClassStack.delete();
-}
-
-function T3Dpre4ProjectImporter::processScriptExtensions(%this)
-{
-   %currentPage = ProjectImportWindow.getCurrentPage();
-   
-   if($TorqueScriptFileExtension $= "tscript")
-      %file = findFirstFileMultiExpr( $ProjectImporter::modulePath @ "/*/*.cs", true);
-   else
-      %file = findFirstFileMultiExpr( $ProjectImporter::modulePath @ "/*/*.tscript", true);
-   
-   $ProjectImporter::log.add("Legacy Project Importer - Beginning processing of script files that utilize extensions other than: " @ $TorqueScriptFileExtension);
-   
-   //Walk through and process all code files to update references
-   while( %file !$= "" )
-   {      
-      %fileWasChanged = false;
-      
-      %filename = fileName(%file);
-      %fileBase = fileBase(%file);
-      %fileExt = fileExt(%file);
-      %filePath = filePath(%file);
-      
-      $ProjectImporter::currentFilePath = %filePath @ "/";
-      
-      %currentPage-->processingText.setText("Processing material script file: " @ %file);
-      Canvas.repaint();
-      
-      %targetFilePath = %filePath @ "/" @ %fileBase @ "." @ $TorqueScriptFileExtension;
-      if(!pathCopy(%file, %targetFilePath))
-      {
-         $ProjectImporter::log.add("T3Dpre4ProjectImporter::processScriptExtensions() - Failed to create renamed script file for file: " @ %file);
-      }
-      else
-      {
-         if(!fileDelete(%file))
-         {
-            $ProjectImporter::log.add("T3Dpre4ProjectImporter::processScriptExtensions() - Failed to remove old script file for rename: " @ %file);
-         }         
-      }
-      
-      if($TorqueScriptFileExtension $= "tscript")
-         %file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*/*.cs");
-      else
-         %file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*/*.tscript");
-   }
-   
-   %currentPage = ProjectImportWindow.getCurrentPage();
-   
-   %currentPage-->processingText.setText("Processing of script files done! Press Next to continue.");
-   ProjectImportWindow-->nextButton.setActive(true);
-   Canvas.repaint();
-   
-   $ProjectImporter::log.add("Legacy Project Importer - Beginning processing of script files extensions complete");
-}
-
-//To implement a custom class to have it's fields processed, just utilize this template function
-//and replace the class/field spaces as appropriate
-/*
-function T3Dpre4ProjectImporter::process<ClassName>Line(%this, %line)
-{
-   %outLine = processLegacyField(%line, "<originalFilenameField>", "<newAssetField>");
-  
-   if(%outLine !$= %line)
-      return %outLine;
-   else
-      return %line;
-}
-*/
-//==============================================================================
-// Misc Object Classes
-//==============================================================================
-function T3Dpre4ProjectImporter::genProcessor(%classType, %conversionMap)
-{
-    %stryng = "function T3Dpre4ProjectImporter::process" @%classType@ "Line(%this, %line){\n";
-    %count = getWordCount(%conversionMap);
-    for (%i = 0; %i<%count; %i+=2)
-    {
-        %stryng = %stryng @ " %outLine = processLegacyField(%line,\""@ getWord(%conversionMap,%i)@ "\",\""@ getWord(%conversionMap,%i+1)@"\");\n";
-        %stryng = %stryng @ "  if(%outLine !$= %line) return %outLine;\n";
-    }
-    %stryng = %stryng @ " return %line;\n}";
-    eval(%stryng);
-}
-
-T3Dpre4ProjectImporter::genProcessor("TSShapeConstructor", "baseShape baseShapeAsset shapeName shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("BasicClouds", "texture textureAsset");
-T3Dpre4ProjectImporter::genProcessor("CloudLayer", "texture textureAsset");
-T3Dpre4ProjectImporter::genProcessor("DecalRoad", "material materialAsset");
-T3Dpre4ProjectImporter::genProcessor("MeshRoad", "topMaterial topMaterialAsset bottomMaterial bottomMaterialAsset sideMaterial sideMaterialAsset");
-T3Dpre4ProjectImporter::genProcessor("ScatterSky", "moonMat moonMatAsset");
-T3Dpre4ProjectImporter::genProcessor("Sun", "coronaMaterial coronaMaterialAsset");
-T3Dpre4ProjectImporter::genProcessor("VolumetricFog", "shape ShapeAsset texture textureAsset");
-T3Dpre4ProjectImporter::genProcessor("WaterObject", "rippleTex rippleTexAsset foamTex foamTexAsset depthGradientTex depthGradientTexAsset");
-T3Dpre4ProjectImporter::genProcessor("ConvexShape", "material materialAsset");
-T3Dpre4ProjectImporter::genProcessor("RenderMesh", "material materialAsset");
-T3Dpre4ProjectImporter::genProcessor("RenderShape", "shape shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("GroundCover", "material materialAsset shape shapeAsset shapeFilename shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("GroundPlane", "material materialAsset");
-T3Dpre4ProjectImporter::genProcessor("LevelInfo", "accuTexture accuTextureAsset");
-T3Dpre4ProjectImporter::genProcessor("TSStatic", "shape shapeAsset shapeName shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("TSForestItemData", "shape shapeAsset shapeName shapeAsset shapeFile shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("TerrainBlock", "terrainFile terrainAsset");
-T3Dpre4ProjectImporter::genProcessor("afxMagicMissileData", "projectileShape projectileShapeAsset projectileShapeName projectileShapeAsset sound projectileSoundAsset");
-T3Dpre4ProjectImporter::genProcessor("afxBillboardData", "texture textureAsset");
-T3Dpre4ProjectImporter::genProcessor("afxModelData", "shapeName shapeAsset shapeFile shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("afxZodiacData", "texture textureAsset");
-T3Dpre4ProjectImporter::genProcessor("afxZodiacPlaneData", "texture textureAsset");
-T3Dpre4ProjectImporter::genProcessor("sfxEmitter", "track soundAsset filename soundAsset");
-T3Dpre4ProjectImporter::genProcessor("LightningData", "thunderSounds ThunderSoundAsset strikeSound StrikeSoundAsset");
-//==============================================================================
-// Levels
-//==============================================================================
-function T3Dpre4ProjectImporter::processMissionGroupLine(%this, %line, %missionName)
-{
-   %outline = strreplace(%line, "SimGroup(MissionGroup)", "Scene(" @ %missionName @ ")");
-   
-   if(%outLine !$= %line)
-      return %outLine;
-   else
-      return %line;
-}
-
-function T3Dpre4ProjectImporter::processLevelInfoLine(%this, %line)
-{
-   %outline = strreplace(%line, "ScriptObject(MissionInfo)", "LevelInfo(theLevelInfo)");
-   
-   if(%outLine !$= %line)
-      return %outLine;
-   else
-      return %line;
-}
-
-function T3Dpre4ProjectImporter::processSkyLine(%this, %line)
-{
-   %outline = strreplace(%line, "Sky", "Skybox");
-   
-   if(%outLine !$= %line)
-      return %outLine;
-   else
-      return %line;
-}
-
-function T3Dpre4ProjectImporter::processWaterLine(%this, %line)
-{
-   %outline = strreplace(%line, "Water", "WaterPlane");
-   
-   if(%outLine !$= %line)
-      return %outLine;
-   else
-      return %line;
-}
-
-//==============================================================================
-// GUIs
-//==============================================================================
-T3Dpre4ProjectImporter::genProcessor("GuiIconButtonCtrl", "bitmap bitmapAsset iconBitmap bitmapAsset");
-T3Dpre4ProjectImporter::genProcessor("GuiToolboxButtonCtrl", "normalBitmap normalBitmapAsset loweredBitmap loweredBitmapAsset hoverBitmap hoverBitmapAsset");
-T3Dpre4ProjectImporter::genProcessor("GuiBitmapCtrl", "bitmap bitmapAsset");
-T3Dpre4ProjectImporter::genProcessor("GuiMaterialCtrl", "material materialAsset");
-T3Dpre4ProjectImporter::genProcessor("GuiCursor", "bitmap bitmapAsset");
-T3Dpre4ProjectImporter::genProcessor("GuiChunkedBitmapCtrl", "bitmap bitmapAsset");
-T3Dpre4ProjectImporter::genProcessor("GuiProgressBitmap", "bitmap bitmapAsset");
-T3Dpre4ProjectImporter::genProcessor("GuiMissionArea", "handleBitmap handleBitmapAsset");
-T3Dpre4ProjectImporter::genProcessor("WorldEditor", "selectHandle selectHandleAsset defaultHandle defaultHandleAsset lockedHandle lockedHandleAsset");
-T3Dpre4ProjectImporter::genProcessor("GuiControlProfile", "bitmap bitmapAsset");
-T3Dpre4ProjectImporter::genProcessor("GuiMLTextCtrl", "deniedSound deniedSoundAsset");
-
-function T3Dpre4ProjectImporter::processGuiBitmapButtonCtrlLine(%this, %line)
-{
-   %outLine = processGuiBitmapButtonCtrlField(%line, "bitmap", "bitmapAsset");
-   if(%outLine !$= %line) return %outLine;
-   
-   return %line;
-}
-
-//==============================================================================
-// Datablocks
-//==============================================================================
-T3Dpre4ProjectImporter::genProcessor("ForestItemData", "shape shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("CubeMapData", "cubemapFace cubeMapFaceAsset cubemap cubemapAsset cubeFace cubeMapFaceAsset");
-T3Dpre4ProjectImporter::genProcessor("DebrisData", "shape shapeAsset shapeFile shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("DecalData", "material materialAsset");
-T3Dpre4ProjectImporter::genProcessor("ExplosionData", "explosionShape explosionShapeAsset");
-T3Dpre4ProjectImporter::genProcessor("ParticleData", "texture textureAsset textureName textureAsset textureExt textureExtAsset textureExtName textureExtAsset");
-T3Dpre4ProjectImporter::genProcessor("PrecipitationData", "drop dropAsset dropTexture dropAsset splash splashAsset splashTexture splashAsset soundProfile soundAsset");
-T3Dpre4ProjectImporter::genProcessor("SplashData", "texture textureAsset soundProfile SoundAsset");
-T3Dpre4ProjectImporter::genProcessor("LightFlareData", "flareTexture flareTextureAsset");
-T3Dpre4ProjectImporter::genProcessor("PhysicsDebrisData", "shape shapeAsset shapeFile shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("PhysicsShapeData", "shape shapeAsset shapeName shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("ProjectileData", "projectileShape projectileShapeAsset projectileShapeName projectileShapeAsset sound projectileSoundAsset");
-T3Dpre4ProjectImporter::genProcessor("ShapeBaseData", "shapeFile shapeAsset shape shapeAsset debrisShape debrisShapeAsset debrisShapeName debrisShapeAsset");
-T3Dpre4ProjectImporter::genProcessor("ShapeBaseImageData", "shape shapeAsset[0] shapeFP shapeAsset[1] shapeFile shapeAsset[0] shapeFileFP shapeAsset[1] stateSound stateSoundAsset");
-T3Dpre4ProjectImporter::genProcessor("ProximityMineData","armingSound ArmSoundAsset TriggerSound TriggerSoundAsset");
-T3Dpre4ProjectImporter::genProcessor("WheeledVehicleTire", "shape shapeAsset shapeFile shapeAsset");
-T3Dpre4ProjectImporter::genProcessor("WheeledVehicleData", "engineSound engineSoundAsset squealSound squealSoundAsset");
-T3Dpre4ProjectImporter::genProcessor("FlyingVehicleData", "engineSound engineSoundAsset jetSound jetSoundAsset");
-T3Dpre4ProjectImporter::genProcessor("HoverVehicleData", "engineSound engineSoundAsset jetSound jetSoundAsset floatSound floatSoundAsset");
-
-//==============================================================================
-// Datablocks - Long Lists
-//==============================================================================
-// - RigidShapeData
-$rigidEntriesList = "softImpactSound softImpactSoundAsset hardImpactSound hardImpactSoundAsset";
-$rigidEntriesList = $rigidEntriesList SPC "exitingWater exitingWaterAsset impactWaterEasy impactWaterEasyAsset";
-$rigidEntriesList = $rigidEntriesList SPC "impactWaterMedium impactWaterMediumAsset impactWaterHard impactWaterHardAsset";
-$rigidEntriesList = $rigidEntriesList SPC "waterWakeSound waterWakeSoundAsset";
-T3Dpre4ProjectImporter::genProcessor("RigidShapeData",$rigidEntriesList);
-// - PlayerData
-$PlayerEntriesList = "shapeFP shapeFPAsset shapeNameFP shapeFPAsset";
-$PlayerEntriesList = $PlayerEntriesList SPC "FootSoftSound FootSoftAsset FootHardSound FootHardAsset FootMetalSound FootMetalAsset";
-$PlayerEntriesList = $PlayerEntriesList SPC "FootSnowSound FootSnowAsset FootShallowSound FootShallowSplashAsset";
-$PlayerEntriesList = $PlayerEntriesList SPC "FootWadingSound FootWadingAsset FootUnderwaterSound FootUnderWaterAsset";
-$PlayerEntriesList = $PlayerEntriesList SPC "FootBubblesSound FootBubblesAsset movingBubblesSound MoveBubblesAsset";
-$PlayerEntriesList = $PlayerEntriesList SPC "waterBreathSound WaterBreathAsset";
-$PlayerEntriesList = $PlayerEntriesList SPC "impactSoftSound ImpactSoftAsset impactHardSound impactHardAsset";
-$PlayerEntriesList = $PlayerEntriesList SPC "impactMetalSound ImpactMetalAsset impactSnowSound impactSnowAsset";
-$PlayerEntriesList = $PlayerEntriesList SPC "impactWaterEasy impactWaterEasyAsset impactWaterMedium impactWaterMediumAsset impactWaterHard impactWaterHardAsset";
-$PlayerEntriesList = $PlayerEntriesList SPC "exitingWater ExitWaterAsset";
-T3Dpre4ProjectImporter::genProcessor("PlayerData", $PlayerEntriesList);
-// - Material
-$MaterialEntriesList = "baseTex diffuseMapAsset diffuseMap diffuseMapAsset";
-$MaterialEntriesList = $MaterialEntriesList SPC "lightMap lightMapAsset toneMap toneMapAsset";
-$MaterialEntriesList = $MaterialEntriesList SPC "detailTex detailMapAsset detailMap detailMapAsset detailNormalMap detailNormalMapAsset";
-$MaterialEntriesList = $MaterialEntriesList SPC "overlayTex overlayMapAsset overlayMap overlayMapAsset";
-$MaterialEntriesList = $MaterialEntriesList SPC "bumpTex normalMapAsset normalMap normalMapAsset";
-$MaterialEntriesList = $MaterialEntriesList SPC "ormConfigMap ormConfigMapAsset roughMap roughMapAsset";
-$MaterialEntriesList = $MaterialEntriesList SPC "aoMap aoMapAsset metalMap metalMapAsset";
-$MaterialEntriesList = $MaterialEntriesList SPC "glowMap glowMapAsset";
-$MaterialEntriesList = $MaterialEntriesList SPC "customFootstepSound customFootstepSoundAsset customImpactSound customImpactSoundAsset";
-T3Dpre4ProjectImporter::genProcessor("Material", $MaterialEntriesList);
-//==============================================================================
-// Materials
-//==============================================================================
-function T3Dpre4ProjectImporter::processMaterialObject(%this, %file, %objectName)
-{
-   %matAsset = MaterialAsset::getAssetIdByMaterialName(%objectName);
-   
-   if(%matAsset $= "" || %matAsset $= "Core_Rendering:NoMaterial")
-   {
-      %assetName = %objectName;
-   
-      %moduleName = AssetBrowser.dirHandler.getModuleFromAddress(%file).ModuleId;
-      
-      %assetPath = filePath(%file) @ "/";   
-      
-      %tamlpath = %assetPath @ %assetName @ ".asset.taml";
-      
-      if(isFile(%tamlpath))
-      {
-         $ProjectImporter::log.add("T3Dpre4ProjectImporter::processMaterialObject() - Failed to create as taml file already exists: " @ %file);
-         return false;
-      }
-      
-      %asset = new MaterialAsset()
-      {
-         AssetName = %assetName;
-         versionId = 1;
-         shaderData = "";
-         materialDefinitionName = %assetName;
-         scriptFile = fileBase(%file);
-      };
-      
-      TamlWrite(%asset, %tamlpath);
-      
-      %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
-      %success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
-      
-      if(!%success)
-         return false;
-   }
-   
-   return false;
-}
-
-function T3Dpre4ProjectImporter::processTerrainMaterialLine(%this, %line)
-{
-   %outLine = processLegacyField(%line, "diffuseMap", "diffuseMapAsset");
-   if(%outLine !$= %line) return %outLine;
-   %outLine = processLegacyField(%line, "normalMap", "normalMapAsset");
-   if(%outLine !$= %line) return %outLine;
-   %outLine = processLegacyField(%line, "detailMap", "detailMapAsset");
-   if(%outLine !$= %line) return %outLine;
-   %outLine = processLegacyField(%line, "ORMConfigMap", "ORMConfigMapAsset");
-   if(%outLine !$= %line) return %outLine;
-   %outLine = processLegacyField(%line, "macroMap", "macroMapAsset");
-   if(%outLine !$= %line) return %outLine;
-   return %line;
-}
-
-function T3Dpre4ProjectImporter::processTerrainMaterialObject(%this, %file, %objectName)
-{
-   %matAsset = TerrainMaterialAsset::getAssetIdByMaterialName(%objectName);
-   
-   if(%matAsset $= "" || %matAsset $= "Core_Rendering:noMaterial")
-   {
-      %assetName = %objectName;
-   
-      %moduleName = AssetBrowser.dirHandler.getModuleFromAddress(%file).ModuleId;
-      
-      %assetPath = filePath(%file) @ "/";   
-      
-      %tamlpath = %assetPath @ %assetName @ ".asset.taml";
-      
-      if(isFile(%tamlpath))
-      {
-         $ProjectImporter::log.add("T3Dpre4ProjectImporter::processTerrainMaterialObject() - Failed to create as taml file already exists: " @ %file);
-         return false;
-      }
-      
-      %asset = new TerrainMaterialAsset()
-      {
-         AssetName = %assetName;
-         versionId = 1;
-         shaderData = "";
-         materialDefinitionName = %objectName;
-         scriptFile = fileName(%file);
-      };
-      
-      TamlWrite(%asset, %tamlpath);
-      
-      %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
-      %success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
-      
-      if(!%success)
-         return false;
-   }
-   
-   return false;
-}
-//==============================================================================
-// PostEffects
-//==============================================================================
-T3Dpre4ProjectImporter::genProcessor("PostEffect", "texture textureAsset");
-
-//==============================================================================
-// Sounds
-// Sounds are a little weird because there's so much data tied up in a given sound
-// source. So our approach is find old SFXProfiles and process those into sound assets
-// by cross-referencing the filename for existing asset definitions.
-// Using existing SFXProfiles allows us to also injest the descriptions, giving us
-// our meta-properties on the sound asset itself.
-//==============================================================================
-T3Dpre4ProjectImporter::genProcessor("SFXAmbience", "soundTrack soundTrackAsset");
-T3Dpre4ProjectImporter::genProcessor("SFXPlayList", "track trackAsset");
-
-function T3Dpre4ProjectImporter::processSFXProfileLine(%this, %line)
-{
-   return %line;
-}
-
-function T3Dpre4ProjectImporter::processSFXProfileObject(%this, %file, %objectName)
-{
-   %soundFilename = findObjectField("filename");
-   
-   %soundFilename = sanitizeFilename(%soundFilename);
-
-   %soundAsset = SoundAsset::getAssetIdByFilename(%soundFilename);
-   
-   //Throw a warn that this file's already been claimed and move on
-   if(%soundAsset !$= "")
-   {
-      $ProjectImporter::log.add("T3Dpre4ProjectImporter::processSFXProfileObject() - attempting to process SFXProfile " @ %objectName 
-               @ " but its filename is already associated to another sound asset. Continuing, but be aware.");
-   }  
-
-      %assetName = %objectName;
-   
-      %moduleName = AssetBrowser.dirHandler.getModuleFromAddress(%soundFilename).ModuleId;
-      
-      %assetPath = filePath(%soundFilename) @ "/";   
-      
-      %tamlpath = %assetPath @ %assetName @ ".asset.taml";
-      
-      if(isFile(%tamlpath))
-      {
-         $ProjectImporter::log.add("T3Dpre4ProjectImporter::processSFXProfileObject() - Failed to create as taml file already exists: " @ %soundFilename);
-         return false;
-      }
-      
-      %asset = new SoundAsset()
-      {
-         AssetName = %assetName;
-         versionId = 1;
-         shaderData = "";
-         soundFile = fileBase(%soundFilename) @ fileExt(%soundFilename);
-      };
-      
-      %descriptionName = findObjectField("description");
-      
-      if(%descriptionName !$= "")
-      {
-         //Optimization, see if we already have this description by happenstance
-         if(isObject(%descriptionName))
-         {
-            %asset.sourceGroup = %descriptionName.sourceGroup;
-            %asset.volume = %descriptionName.volume;
-            %asset.pitch = %descriptionName.pitch;
-            %asset.isLooping = %descriptionName.isLooping;
-            %asset.priority = %descriptionName.priority;
-            %asset.useHardware = %descriptionName.useHardware;
-            %asset.is3D = %descriptionName.is3D;
-            %asset.minDistance = %descriptionName.minDistance;
-            %asset.maxDistance = %descriptionName.maxDistance;
-            %asset.scatterDistance = %descriptionName.scatterDistance;
-            %asset.coneInsideAngle = %descriptionName.coneInsideAngle;            
-            %asset.coneOutsideAngle = %descriptionName.coneOutsideAngle;         
-            %asset.coneOutsideVolume = %descriptionName.coneOutsideVolume;
-            %asset.rolloffFactor = %descriptionName.rolloffFactor;
-            %asset.isStreaming = %descriptionName.isStreaming;
-         }
-         else
-         {
-         %objFileFinder = "";
-         //first check our cache
-         if(isObject($ProjectImporter::SFXDescriptionCache) && 
-            $ProjectImporter::SFXDescriptionCache.getIndexFromKey(%descriptionName) !$= "")
-         {
-            %key = $ProjectImporter::SFXDescriptionCache.getIndexFromKey(%descriptionName);
-            %objFileFinder = $ProjectImporter::SFXDescriptionCache.getValue(%key);
-         }
-         else
-         {
-            %objFileFinder = findObjectInFiles(%descriptionName);
-         }
-         
-            if(%objFileFinder !$= "")
-            {
-               %valueArray = new ArrayObject();
-               
-            %fileObj = getField(%objFileFinder, 0);
-               
-            %valueArray.add("sourceGroup" SPC findObjectField("sourceGroup", %fileObj));
-            %valueArray.add("volume" SPC findObjectField("volume", %fileObj));
-            %valueArray.add("pitch" SPC findObjectField("pitch", %fileObj));
-            %valueArray.add("isLooping" SPC findObjectField("isLooping", %fileObj));
-            %valueArray.add("priority" SPC findObjectField("priority", %fileObj));
-            %valueArray.add("useHardware" SPC findObjectField("useHardware", %fileObj));
-            %valueArray.add("is3D" SPC findObjectField("is3D", %fileObj));
-            %valueArray.add("minDistance" SPC findObjectField("minDistance", %fileObj));
-            %valueArray.add("maxDistance" SPC findObjectField("maxDistance", %fileObj));
-            %valueArray.add("scatterDistance" SPC findObjectField("scatterDistance", %fileObj));
-            %valueArray.add("coneInsideAngle" SPC findObjectField("coneInsideAngle", %fileObj));
-            %valueArray.add("coneOutsideAngle" SPC findObjectField("coneOutsideAngle", %fileObj));
-            %valueArray.add("coneOutsideVolume" SPC findObjectField("coneOutsideVolume", %fileObj));
-            %valueArray.add("rolloffFactor" SPC findObjectField("rolloffFactor", %fileObj));
-            %valueArray.add("isStreaming" SPC findObjectField("isStreaming", %fileObj));
-            
-            if(isObject($ProjectImporter::SFXDescriptionCache))
-            {
-               $ProjectImporter::SFXDescriptionCache.add(%descriptionName, %objFileFinder);
-            }
-               
-               for(%v=0; %v < %valueArray.Count(); %v++)
-               {
-                  %varSet = %valueArray.getKey(%v);
-                  %var = getWord(%varSet, 0);
-                  %varVal = getWord(%varSet, 1);
-
-                  if(%varVal !$= "")
-                     %asset.setFieldValue(%var, %varVal);
-               }
-            
-            %valueArray.delete();
-            }
-         }
-      }
-      
-      TamlWrite(%asset, %tamlpath);
-      
-      %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
-      %success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
-      
-      if(!%success)
-         return false;
-   
-   //Now mark the original SFXProfile for removal from the file as it's redundant
-   //now that we have the asset def
-   $ProjectImporter::ToRemoveObjectList.add(%objectName, %file TAB 0);
-   
-   return true;
-}
-
-function T3Dpre4ProjectImporter::processAudioProfileObject(%this, %file, %objectName)
-   {
-   return %this.processSFXProfileObject(%file, %objectName);
-      }
-      
-function T3Dpre4ProjectImporter::processSFXDescriptionObject(%this, %file, %objectName)
-      {
-   $ProjectImporter::ToRemoveObjectList.add(%objectName, %file TAB 0);
-   
-   return true;
-}
-
-function T3Dpre4ProjectImporter::processAudioDescriptionObject(%this, %file, %objectName)
-{
-   $ProjectImporter::ToRemoveObjectList.add(%objectName, %file TAB 0);
-   
-   return true;
-}
-
-//==============================================================================
-// Misc Utility functions
-//==============================================================================
-//This is functionally identical to processLegacyField, but we have to special-snowflake our asset lookups
-//due to it using suffix-based indirections
-function processGuiBitmapButtonCtrlField(%line, %originalFieldName, %newFieldName)
-{
-   if(!strIsMatchExpr("*"@%originalFieldName@"=*\"*\";*", %line) && 
-      !strIsMatchExpr("*"@%originalFieldName@"[*=*\"*\";*", %line) &&
-      !strIsMatchExpr("*"@%originalFieldName@" *=*\"*\";*", %line))
-      return %line;
-      
-   %outLine = strreplace(%line, %originalFieldName, %newFieldName);
-   
-   //get the value
-   %value = "";
-   %pos = strpos(%outLine, "= \"");
-   if(%pos != -1)
-   {
-     %endPos = strpos(%outLine, "\";", %pos); 
-     
-     %value = getSubStr(%outLine, %pos+3, %endPos-%pos-3);
-   }
-   else
-   {
-      %pos = strpos(%outLine, "=\"");
-      if(%pos != -1)
-      {
-        %endPos = strpos(%outLine, "\";", %pos); 
-        
-        %value = getSubStr(%outLine, %pos+2, %endPos-%pos-2);
-      }
-   }
-   
-   if(%outLine !$= %line && %pos != -1 && %endPos != -1 && %value !$= "")
-   {
-      $ProjectImporter::log.add("Legacy Project Importer - processing legacy field line: " @ %line);
-      
-      if(startsWith(%value, "$") || startsWith(%value, "#"))
-      {
-         //These are going to be texture/render targets, and we can leave them alone
-         return %line;
-      }
-      
-      %targetFilename = sanitizeFilename(%value);
-      
-      //If we still have nothing, then we fail it out
-      if(!isFile(%targetFilename))
-      {
-         $ProjectImporter::log.add("Legacy Project Importer - file described in line could not be found/is not valid");
-         return %line;
-      }
-      
-      $ProjectImporter::assetQuery.clear();
-      %foundAssets = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %targetFilename);
-      if(%foundAssets != 0)
-      {
-         %assetId = $ProjectImporter::assetQuery.getAsset(0);
-         $ProjectImporter::log.add("Legacy Project Importer - processing of legacy field line's value: " @ %value @ " has found a matching AssetId: " @ %assetId);
-      }
-     
-      if(%assetId !$= "" && AssetDatabase.isDeclaredAsset(%assetId))
-      {
-         //if (%assetId.getStatusString() $= "Ok")
-         %outLine = strReplace(%outLine, %value, %assetId);
-         //else
-         //   error("Asset assignment failure:", %assetId, getStatusString());
-      }
-   }
-   
-   if(%outLine !$= %line)
-   {
-      $ProjectImporter::log.add("Legacy Project Importer - processing of legacy line: " @ %line @ " has been updated to: " @ %outLine);
-      return %outLine;  
-   }
-   else
-   {
-      return %line;  
-   }
-}

Plik diff jest za duży
+ 696 - 291
Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików