|
@@ -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;
|
|
|
+ }
|
|
|
+}
|