mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
Comments and cleanup
This commit is contained in:
parent
ecd35df7e9
commit
728aa83481
|
|
@ -1,3 +1,7 @@
|
|||
//==============================================================================
|
||||
// Initialization function that registers this importer to the main Project Importer
|
||||
// allowing it to be selected/invoked in the main Project Importer wizard
|
||||
//==============================================================================
|
||||
function T3Dpre4ProjectImporter::init()
|
||||
{
|
||||
//register this importer option to the project importer listing
|
||||
|
|
@ -14,6 +18,10 @@ function T3Dpre4ProjectImporter::init()
|
|||
|
||||
T3Dpre4ProjectImporter::init(); //kick off the setup
|
||||
|
||||
//==============================================================================
|
||||
// Sets up and registers the pages for this particular version importer
|
||||
// to the Project Importer for navigating through with the import process
|
||||
//==============================================================================
|
||||
function T3Dpre4ProjectImporter::setupPages(%this)
|
||||
{
|
||||
ProjectImportWindow.addImporterPage(Pre40ImporterPage0);
|
||||
|
|
@ -22,8 +30,9 @@ function T3Dpre4ProjectImporter::setupPages(%this)
|
|||
ProjectImportWindow.refreshPage();
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//==============================================================================
|
||||
// Sets up the target module
|
||||
//==============================================================================
|
||||
function T3Dpre4ProjectImporter::setupModule(%this)
|
||||
{
|
||||
%newModuleName = $ProjectImporter::moduleName;
|
||||
|
|
@ -98,117 +107,9 @@ function T3Dpre4ProjectImporter::setupModule(%this)
|
|||
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();
|
||||
}*/
|
||||
|
||||
//==============================================================================
|
||||
// Import content file types such as images, sounds, materials, etc
|
||||
//==============================================================================
|
||||
function T3Dpre4ProjectImporter::doContentImport(%this)
|
||||
{
|
||||
//Store off the current default import config
|
||||
|
|
@ -226,6 +127,9 @@ function T3Dpre4ProjectImporter::doContentImport(%this)
|
|||
%this.beginSoundProfilesImport();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Import script-based files like guis, levels and scripts
|
||||
//==============================================================================
|
||||
function T3Dpre4ProjectImporter::doScriptImport(%this)
|
||||
{
|
||||
beginLevelImport();
|
||||
|
|
@ -240,6 +144,9 @@ function T3Dpre4ProjectImporter::doScriptImport(%this)
|
|||
EditorSettings.setValue("Assets/AssetImporDefaultConfig", %this.defaultConfig);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Writes out the importing file to the new destination
|
||||
//==============================================================================
|
||||
function T3Dpre4ProjectImporter::writeImportingObject(%this, %arrayObj)
|
||||
{
|
||||
if(!isObject(%arrayObj) || %arrayObj.skip)
|
||||
|
|
@ -301,7 +208,10 @@ function T3Dpre4ProjectImporter::writeImportingFiles(%this)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
//==============================================================================
|
||||
// Processes through the importing files for material definitions and generates
|
||||
// the new assets into the destination module
|
||||
//==============================================================================
|
||||
function T3Dpre4ProjectImporter::processMaterialObjects(%this, %arrayObj)
|
||||
{
|
||||
if(!isObject(%arrayObj))
|
||||
|
|
@ -456,7 +366,10 @@ function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this)
|
|||
projectImporterLog("===========================================");
|
||||
}
|
||||
|
||||
//
|
||||
//==============================================================================
|
||||
// Processes through the importing files for SFXProfile definitions and
|
||||
// generates the new assest into the destination module
|
||||
//==============================================================================
|
||||
function T3Dpre4ProjectImporter::processSoundProfileObjects(%this, %arrayObj)
|
||||
{
|
||||
if(!isObject(%arrayObj))
|
||||
|
|
@ -558,7 +471,11 @@ function T3Dpre4ProjectImporter::beginSoundProfilesImport(%this)
|
|||
projectImporterLog("===========================================");
|
||||
}
|
||||
|
||||
//
|
||||
//==============================================================================
|
||||
// Processes through the importing files for scripted object definitions and
|
||||
// updates their names and fields to be asset-compliant, converting filepaths
|
||||
// to assetIds where valid
|
||||
//==============================================================================
|
||||
function T3Dpre4ProjectImporter::processScripts(%this, %arrayObj)
|
||||
{
|
||||
if(!isObject(%arrayObj))
|
||||
|
|
@ -716,14 +633,15 @@ function T3Dpre4ProjectImporter::beginScriptFilesImport(%this)
|
|||
projectImporterLog("Legacy Project Importer - Processing of imported code files done!");
|
||||
}
|
||||
|
||||
//
|
||||
//==============================================================================
|
||||
// Processes through the importing files for module and asset definitions and
|
||||
// updates them to be compliant
|
||||
//==============================================================================
|
||||
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++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
//==============================================================================
|
||||
// We first copy over binary files(images, shapes, sounds, etc) to the destination
|
||||
// module, then run the processing/import on them to generate the assets
|
||||
//==============================================================================
|
||||
function Pre40ImporterPage0::openPage(%this)
|
||||
{
|
||||
ProjectImportWindow-->nextButton.setActive(false);
|
||||
|
|
@ -75,6 +79,9 @@ function Pre40ImporterPage0::openPage(%this)
|
|||
Canvas.repaint();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// This page actually invokes the processing of the script-based files and objects
|
||||
//==============================================================================
|
||||
function Pre40ImporterPage1::openPage(%this)
|
||||
{
|
||||
ProjectImportWindow-->nextButton.setActive(false);
|
||||
|
|
|
|||
|
|
@ -7,8 +7,24 @@ function ProjectImporter::beginProjectImport()
|
|||
Canvas.pushDialog(ProjectImportCtrl);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Wake-up and initial setup
|
||||
//==============================================================================
|
||||
function ProjectImportWindow::onWake(%this)
|
||||
{
|
||||
if(isObject($ProjectImporter::assetQuery))
|
||||
$ProjectImporter::assetQuery.delete();
|
||||
$ProjectImporter::assetQuery = new AssetQuery();
|
||||
|
||||
if(isObject($ProjectImporter::importer))
|
||||
$ProjectImporter::importer.delete();
|
||||
$ProjectImporter::importer = new AssetImporter();
|
||||
$ProjectImporter::importer.dumpLogs = false; //we handle the log dump outselves here
|
||||
|
||||
if(isObject($ProjectImporter::persistMgr))
|
||||
$ProjectImporter::persistMgr.delete();
|
||||
$ProjectImporter::persistMgr = new PersistenceManager();
|
||||
|
||||
if(!isObject($ProjectImporter::fileObject))
|
||||
$ProjectImporter::fileObject = new FileObject();
|
||||
|
||||
|
|
@ -49,6 +65,9 @@ function ProjectImportWindow::onWake(%this)
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Page Navigation
|
||||
//==============================================================================
|
||||
function ProjectImportWindow::previousStep(%this)
|
||||
{
|
||||
if(%this.importStepNumber == 0)
|
||||
|
|
@ -63,7 +82,7 @@ function ProjectImportWindow::previousStep(%this)
|
|||
|
||||
function ProjectImportWindow::nextStep(%this)
|
||||
{
|
||||
if(%this.importStepNumber == $ProjectImporter::importerPageList.count())
|
||||
if(%this.importStepNumber == $ProjectImporter::importerPageList.count()-1)
|
||||
{
|
||||
Canvas.popDialog(ProjectImportCtrl);
|
||||
return;
|
||||
|
|
@ -157,11 +176,17 @@ function ProjectImportWindow::getCurrentPage(%this)
|
|||
return $ProjectImporter::importerPageList.getKey(%this.importStepNumber);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Welcome page
|
||||
//==============================================================================
|
||||
function ProjectImportWizardPage0::openPage(%this)
|
||||
{
|
||||
ProjectImportWindow-->backButton.setHidden(true);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Select the specific version importer
|
||||
//==============================================================================
|
||||
function ProjectImportWizardPage1::openPage(%this)
|
||||
{
|
||||
ProjectImportWindow-->backButton.setHidden(false);
|
||||
|
|
@ -174,7 +199,9 @@ function ProjectImportWizardPage1::openPage(%this)
|
|||
}
|
||||
}
|
||||
|
||||
//Select destination folder
|
||||
//==============================================================================
|
||||
// Set Source Folder
|
||||
//==============================================================================
|
||||
function ProjectImportWizardPage2::openPage(%this)
|
||||
{
|
||||
%version = ProjectImportWizardPage1-->previousContentVersionPopup.getSelected();
|
||||
|
|
@ -197,24 +224,21 @@ function ProjectImportWizardPage2::openPage(%this)
|
|||
|
||||
$ProjectImporter::importTool = $ProjectImporter::importerList.getValue(%version);
|
||||
|
||||
//if(isObject($ProjectImporter::SFXDescriptionCache))
|
||||
// $ProjectImporter::SFXDescriptionCache.delete();
|
||||
|
||||
//$ProjectImporter::SFXDescriptionCache = new ArrayObject();
|
||||
|
||||
//if(isObject($ProjectImporter::ToRemoveObjectList))
|
||||
// $ProjectImporter::ToRemoveObjectList.delete();
|
||||
|
||||
//$ProjectImporter::ToRemoveObjectList = new ArrayObject();
|
||||
|
||||
$ProjectImporter::importTool.setupPages(); //Have the importer register it's pages
|
||||
|
||||
//And then add our final page
|
||||
$ProjectImporter::importerPageList.add(ProjectImportWizardFinalPage);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Prepwork for import and getting the target module name
|
||||
//==============================================================================
|
||||
function ProjectImportWizardPage3::openPage(%this)
|
||||
{
|
||||
projectImporterLog("===========================================");
|
||||
projectImporterLog("Beginning Project Import");
|
||||
projectImporterLog("===========================================");
|
||||
|
||||
%dataFullPath = makeFullPath("data/");
|
||||
%coreFullPath = makeFullPath("core/");
|
||||
%toolsFullPath = makeFullPath("tools/");
|
||||
|
|
@ -251,67 +275,108 @@ function ProjectImportWizardPage3::openPage(%this)
|
|||
|
||||
ProjectImportWizardPage3-->newModuleName.setText($ProjectImporter::moduleName);
|
||||
}
|
||||
/*if(ProjectImportWizardPage2-->internalFolderBtn.isStateOn())
|
||||
{
|
||||
$ProjectImporter::importMode = "InternalFolder";
|
||||
}
|
||||
else if(ProjectImportWizardPage2-->externalFolderBtn.isStateOn())
|
||||
{
|
||||
$ProjectImporter::importMode = "ExternalFolder";
|
||||
}
|
||||
else if(ProjectImportWizardPage2-->coreAndToolsBtn.isStateOn())
|
||||
{
|
||||
$ProjectImporter::importMode = "CoreAndTools";
|
||||
}
|
||||
else
|
||||
{
|
||||
ProjectImportWindow.previousStep();
|
||||
toolsMessageBoxOK("Folder Type Required", "You must indicate if the folder is an internal or external folder.");
|
||||
return;
|
||||
}
|
||||
|
||||
if($ProjectImporter::sourceContentFolder $= "" && $ProjectImporter::importMode !$= "CoreAndTools")
|
||||
{
|
||||
ProjectImportWindow.previousStep();
|
||||
toolsMessageBoxOK("Source Folder Required", "You must select the original folder to import files from.");
|
||||
return;
|
||||
}
|
||||
|
||||
if($ProjectImporter::importMode $= "InternalFolder")
|
||||
{
|
||||
%moduleDef = AssetBrowser.dirHandler.getModuleFromAddress(makeRelativePath($ProjectImporter::sourceContentFolder));
|
||||
if(isObject(%moduleDef))
|
||||
{
|
||||
//already a valid module in place so just skip this step
|
||||
$ProjectImporter::useExistingModule = true;
|
||||
$ProjectImporter::moduleName = %moduleDef.moduleId;
|
||||
$ProjectImporter::modulePath = "data/" @ $ProjectImporter::moduleName;
|
||||
ProjectImportWindow.setStep(4);
|
||||
}
|
||||
}
|
||||
else if($ProjectImporter::importMode $= "ExternalFolder")
|
||||
{
|
||||
%slashCount = getTokenCount($ProjectImporter::sourceContentFolder, "/");
|
||||
%topFolder = getToken($ProjectImporter::sourceContentFolder, "/", %slashCount-1);
|
||||
if(%topFolder $= "")
|
||||
%topFolder = getToken($ProjectImporter::sourceContentFolder, "/", %slashCount-2);
|
||||
|
||||
//clean up invalid characters and stuff
|
||||
%topFolder = sanitizeString(%topFolder);
|
||||
|
||||
$ProjectImporter::useExistingModule = false;
|
||||
$ProjectImporter::moduleName = %topFolder; //preseed the module name
|
||||
$ProjectImporter::modulePath = "data/" @ $ProjectImporter::moduleName;
|
||||
|
||||
ProjectImportWizardPage3-->newModuleName.setText($ProjectImporter::moduleName);
|
||||
}
|
||||
else if($ProjectImporter::importMode $= "CoreAndTools")
|
||||
{
|
||||
ProjectImportWindow.setStep(5);
|
||||
}*/
|
||||
}
|
||||
|
||||
//
|
||||
//==============================================================================
|
||||
// Run the preprocessing of all incoming files
|
||||
//==============================================================================
|
||||
function ProjectImportWizardPage4::openPage(%this)
|
||||
{
|
||||
ProjectImportWindow-->preprocessCompleteText.setHidden(true);
|
||||
|
||||
Canvas.repaint();
|
||||
|
||||
ProjectImportWindow-->backButton.setHidden(true);
|
||||
ProjectImportWindow-->nextButton.setActive(false);
|
||||
|
||||
if(!$ProjectImporter::useExistingModule)
|
||||
$ProjectImporter::moduleName = ProjectImportWizardPage3-->newModuleName.getText();
|
||||
|
||||
$ProjectImporter::modulePath = "data/" @ $ProjectImporter::moduleName;
|
||||
|
||||
if(!$ProjectImporter::useExistingModule)
|
||||
$ProjectImporter::importTool.setupModule();
|
||||
|
||||
//Do some sanity checking here to sidestep the copy if we're already in-place
|
||||
%sourcePath = $ProjectImporter::sourceContentFolder;
|
||||
%targetPath = makeFullPath($ProjectImporter::modulePath);
|
||||
|
||||
preprocessImportingFiles();
|
||||
|
||||
//if we gen'd a new module setup, double check we didn't copy over a module script file under a legacy extension
|
||||
/*if(!$ProjectImporter::useExistingModule)
|
||||
{
|
||||
%newModuleName = $ProjectImporter::moduleName;
|
||||
%moduleFilePath = "data/" @ %newModuleName;
|
||||
|
||||
if($TorqueScriptFileExtension !$= "cs")
|
||||
{
|
||||
%moduleScriptFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".cs";
|
||||
if(isFile(%moduleScriptFilePath))
|
||||
{
|
||||
//yep, that exists, so we'll assume it was the file we wanted, so remove the generated one
|
||||
fileDelete(%moduleFilePath @ "/" @ %newModuleName @ "." @ $TorqueScriptFileExtension);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
ProjectImportWindow-->nextButton.setActive(true);
|
||||
ProjectImportWindow-->preprocessCompleteText.setHidden(false);
|
||||
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Write out the logs and clean up
|
||||
//==============================================================================
|
||||
function ProjectImportWizardFinalPage::openPage(%this)
|
||||
{
|
||||
projectImporterLog("===========================================");
|
||||
projectImporterLog("Finished Project Import");
|
||||
projectImporterLog("===========================================");
|
||||
|
||||
//writing console log
|
||||
%logFileObj = new FileObject();
|
||||
|
||||
%logFileName = "tools/logs/LegacyProjectImport_" @ getTimestamp() @ ".log";
|
||||
|
||||
if(%logFileObj.openForWrite(%logFileName))
|
||||
{
|
||||
for(%i=0; %i < $ProjectImporter::log.count(); %i++)
|
||||
{
|
||||
%logFileObj.writeLine($ProjectImporter::log.getKey(%i));
|
||||
}
|
||||
|
||||
%logFileObj.close();
|
||||
}
|
||||
|
||||
%logFileObj.delete();
|
||||
|
||||
$ProjectImporter::assetQuery.delete();
|
||||
$ProjectImporter::importer.delete();
|
||||
$ProjectImporter::persistMgr.delete();
|
||||
|
||||
AssetBrowser.refresh(); //update the AB just in case
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Registers a version importer's page for display in the wizard
|
||||
//==============================================================================
|
||||
function ProjectImportWindow::addImporterPage(%this, %page)
|
||||
{
|
||||
ProejctImportPageContainer.add(%page);
|
||||
$ProjectImporter::importerPageList.add(%page);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Utility functions needed for processing and importing files. These are common
|
||||
// functions that'll pretty much be used regardless of version being targeted
|
||||
//==============================================================================
|
||||
//==============================================================================
|
||||
// Runs through the files in the source directory and preprocessing them.
|
||||
// All valid files are added to a list, and script-based files are pre-parsed
|
||||
// so the importer can easily process their contents later
|
||||
//==============================================================================
|
||||
function preprocessImportingFiles()
|
||||
{
|
||||
//========================================================
|
||||
|
|
@ -667,173 +732,11 @@ function preprocessImportingFiles()
|
|||
$ProjectImporter::fileObject.close();
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
function ProjectImportWizardPage4::openPage(%this)
|
||||
{
|
||||
ProjectImportWindow-->preprocessCompleteText.setHidden(true);
|
||||
|
||||
Canvas.repaint();
|
||||
|
||||
ProjectImportWindow-->backButton.setHidden(true);
|
||||
ProjectImportWindow-->nextButton.setActive(false);
|
||||
|
||||
if(!$ProjectImporter::useExistingModule)
|
||||
$ProjectImporter::moduleName = ProjectImportWizardPage3-->newModuleName.getText();
|
||||
|
||||
$ProjectImporter::modulePath = "data/" @ $ProjectImporter::moduleName;
|
||||
|
||||
if(!$ProjectImporter::useExistingModule)
|
||||
$ProjectImporter::importTool.setupModule();
|
||||
|
||||
//Do some sanity checking here to sidestep the copy if we're already in-place
|
||||
%sourcePath = $ProjectImporter::sourceContentFolder;
|
||||
%targetPath = makeFullPath($ProjectImporter::modulePath);
|
||||
|
||||
preprocessImportingFiles();
|
||||
|
||||
//if we gen'd a new module setup, double check we didn't copy over a module script file under a legacy extension
|
||||
/*if(!$ProjectImporter::useExistingModule)
|
||||
{
|
||||
%newModuleName = $ProjectImporter::moduleName;
|
||||
%moduleFilePath = "data/" @ %newModuleName;
|
||||
|
||||
if($TorqueScriptFileExtension !$= "cs")
|
||||
{
|
||||
%moduleScriptFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".cs";
|
||||
if(isFile(%moduleScriptFilePath))
|
||||
{
|
||||
//yep, that exists, so we'll assume it was the file we wanted, so remove the generated one
|
||||
fileDelete(%moduleFilePath @ "/" @ %newModuleName @ "." @ $TorqueScriptFileExtension);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
ProjectImportWindow-->nextButton.setActive(true);
|
||||
ProjectImportWindow-->preprocessCompleteText.setHidden(false);
|
||||
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
function ProjectImportWizardPage5::openPage(%this)
|
||||
{
|
||||
ProjectImportWindow-->nextButton.setActive(false);
|
||||
Canvas.repaint();
|
||||
|
||||
$ProjectImporter::importTool.processImportedFiles();
|
||||
}
|
||||
|
||||
function ProjectImportWizardPage6::openPage(%this)
|
||||
{
|
||||
ProjectImportWindow-->nextButton.setActive(false);
|
||||
Canvas.repaint();
|
||||
|
||||
if($ProjectImporter::importMode $= "CoreAndTools")
|
||||
{
|
||||
$ProjectImporter::modulePath = "Core";
|
||||
$ProjectImporter::importTool.processScriptExtensions();
|
||||
|
||||
$ProjectImporter::modulePath = "Tools";
|
||||
$ProjectImporter::importTool.processScriptExtensions();
|
||||
}
|
||||
else
|
||||
{
|
||||
$ProjectImporter::importTool.processScriptExtensions();
|
||||
}
|
||||
|
||||
//All good? now go through and wipe any objects flagged in our files for deletion
|
||||
%objRemovePM = new PersistenceManager();
|
||||
|
||||
for(%o = 0; %o < $ProjectImporter::ToRemoveObjectList.count(); %o++)
|
||||
{
|
||||
%name = $ProjectImporter::ToRemoveObjectList.getKey(%o);
|
||||
%file = getField($ProjectImporter::ToRemoveObjectList.getValue(%o),0);
|
||||
|
||||
if(%name !$= "" && isFile(%file))
|
||||
{
|
||||
if(!isObject(%name))
|
||||
{
|
||||
//spoof it
|
||||
%tmpObj = new SimObject(%name);
|
||||
%objRemovePM.setDirty(%name, %file);
|
||||
}
|
||||
%objRemovePM.removeObjectFromFile(%name, %file);
|
||||
|
||||
%tmpObj.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ProjectImportWizardFinalPage::openPage(%this)
|
||||
{
|
||||
//writing console log
|
||||
%logFileObj = new FileObject();
|
||||
|
||||
%logFileName = "tools/logs/LegacyProjectImport_" @ getTimestamp() @ ".log";
|
||||
|
||||
if(%logFileObj.openForWrite(%logFileName))
|
||||
{
|
||||
for(%i=0; %i < $ProjectImporter::log.count(); %i++)
|
||||
{
|
||||
%logFileObj.writeLine($ProjectImporter::log.getKey(%i));
|
||||
}
|
||||
|
||||
%logFileObj.close();
|
||||
}
|
||||
|
||||
%logFileObj.delete();
|
||||
}
|
||||
|
||||
//
|
||||
function ProjectImportWindow::addImporterPage(%this, %page)
|
||||
{
|
||||
ProejctImportPageContainer.add(%page);
|
||||
$ProjectImporter::importerPageList.add(%page);
|
||||
}
|
||||
//
|
||||
|
||||
function beginProjectImport()
|
||||
{
|
||||
projectImporterLog("===========================================");
|
||||
projectImporterLog("Beginning Project Import");
|
||||
projectImporterLog("===========================================");
|
||||
|
||||
$ProjectImporter::assetQuery = new AssetQuery();
|
||||
$ProjectImporter::importer = new AssetImporter();
|
||||
$ProjectImporter::importer.dumpLogs = false; //we handle the log dump outselves here
|
||||
$ProjectImporter::persistMgr = new PersistenceManager();
|
||||
|
||||
//beginMaterialImport();
|
||||
|
||||
//beginTerrainMaterialImport();
|
||||
|
||||
//beginShapeImport();
|
||||
|
||||
beginImageImport();
|
||||
|
||||
beginDatablockImport();
|
||||
|
||||
beginGUIImport();
|
||||
|
||||
beginTerrainImport();
|
||||
|
||||
//postFX imports'll need to look up render target names and ensure assets for those exist
|
||||
//otherwise they need to be generated
|
||||
beginPostFXImport();
|
||||
|
||||
beginMiscObjectImport();
|
||||
|
||||
$ProjectImporter::assetQuery.delete();
|
||||
$ProjectImporter::importer.delete();
|
||||
$ProjectImporter::persistMgr.delete();
|
||||
|
||||
projectImporterLog("===========================================");
|
||||
projectImporterLog("Finished Project Import");
|
||||
projectImporterLog("===========================================");
|
||||
|
||||
AssetBrowser.refresh(); //update the AB just in case
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// Sanitized a filename so that it doesn't contain any invalid formatting/characters
|
||||
//==============================================================================
|
||||
function sanitizeFilename(%file)
|
||||
{
|
||||
if(startsWith(%file, "./"))
|
||||
|
|
@ -919,6 +822,9 @@ function sanitizeFilename(%file)
|
|||
//}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Checks if the file in question is part of our pre-scanned list of importing files
|
||||
//==============================================================================
|
||||
function isImportingFile(%checkFile)
|
||||
{
|
||||
for(%i=0; %i < $ProjectImporter::FileList.count(); %i++)
|
||||
|
|
@ -932,6 +838,10 @@ function isImportingFile(%checkFile)
|
|||
return false;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Takes a filename lacking an extension and then checks common file extensions
|
||||
// to see if we can find the actual file in question
|
||||
//==============================================================================
|
||||
function testFilenameExtensions(%filename)
|
||||
{
|
||||
%ext = fileExt(%filename);
|
||||
|
|
@ -966,6 +876,9 @@ function testFilenameExtensions(%filename)
|
|||
return %filename;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Parses a line from a script to replace the original field name with the new one
|
||||
//==============================================================================
|
||||
function processLegacyField(%line, %originalFieldName, %newFieldName)
|
||||
{
|
||||
if(!strIsMatchExpr("*"@%originalFieldName@"=*;*", %line) &&
|
||||
|
|
@ -1078,6 +991,9 @@ function processLegacyField(%line, %originalFieldName, %newFieldName)
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Parses a line from a shape constructor file to asset-ify addSequence() calls
|
||||
//==============================================================================
|
||||
function processLegacyShapeConstructorField(%line)
|
||||
{
|
||||
if(!strIsMatchExpr("*%this.addSequence(\"*);", %line))
|
||||
|
|
@ -1129,6 +1045,9 @@ function processLegacyShapeConstructorField(%line)
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Replaces the name of the object in the declaration line
|
||||
//==============================================================================
|
||||
function renameObjectName(%object, %newName)
|
||||
{
|
||||
for(%e=0; %e < %object.count(); %e++)
|
||||
|
|
@ -1153,6 +1072,9 @@ function renameObjectName(%object, %newName)
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Find the value of an object's field
|
||||
//==============================================================================
|
||||
function findObjectField(%object, %fieldName)
|
||||
{
|
||||
%return = "";
|
||||
|
|
@ -1213,6 +1135,9 @@ function findObjectField(%object, %fieldName)
|
|||
return %return;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Sets the value of an object's field
|
||||
//==============================================================================
|
||||
function setObjectField(%object, %fieldName, %newValue)
|
||||
{
|
||||
for(%e=0; %e < %object.count(); %e++)
|
||||
|
|
@ -1278,6 +1203,10 @@ function setObjectField(%object, %fieldName, %newValue)
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Takes a string and adds it to the importer's log. Optionally can print the line
|
||||
// directly to console for debugging purposes
|
||||
//==============================================================================
|
||||
function projectImporterLog(%line)
|
||||
{
|
||||
if($ProjectImporter::writeToConsole)
|
||||
|
|
@ -1701,12 +1630,6 @@ function processGUIntoAsset(%guiName, %file)
|
|||
}
|
||||
//==============================================================================
|
||||
|
||||
//==============================================================================
|
||||
//Misc Object Type Converion
|
||||
//==============================================================================
|
||||
|
||||
//==============================================================================
|
||||
|
||||
//==============================================================================
|
||||
//PostFX conversion
|
||||
//==============================================================================
|
||||
|
|
@ -1885,6 +1808,10 @@ function beginLevelImport()
|
|||
}
|
||||
//==============================================================================
|
||||
|
||||
//==============================================================================
|
||||
// Cleas out existing *.asset.taml files from a target. Only really used for
|
||||
// testing purposes currently.
|
||||
//==============================================================================
|
||||
function deleteAssetDefinitions()
|
||||
{
|
||||
%dlg = new OpenFolderDialog()
|
||||
|
|
@ -1954,6 +1881,10 @@ function doDeleteAssetDefinitions()
|
|||
projectImporterLog("===========================================");
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Tests a file in the game dir to see if there's a possible duplicate file that
|
||||
// may cause an asset collision
|
||||
//==============================================================================
|
||||
function scanForDuplicateFiles(%toTestFile)
|
||||
{
|
||||
projectImporterLog("===========================================");
|
||||
|
|
@ -2012,6 +1943,10 @@ function scanForDuplicateFiles(%toTestFile)
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Pulls the logs from the asset importer and adds it to the project importer's
|
||||
// logs
|
||||
//==============================================================================
|
||||
function getImporterLogs()
|
||||
{
|
||||
%lineCount = $ProjectImporter::importer.getActivityLogLineCount();
|
||||
|
|
|
|||
Loading…
Reference in a new issue