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

This commit is contained in:
JeffR 2022-01-20 01:14:43 -06:00
parent 3812ce2e82
commit ecd35df7e9
14 changed files with 3107 additions and 2663 deletions

View file

@ -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>

View file

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

View file

@ -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 ---

View file

@ -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();
}

View file

@ -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 )