Further conversions of missed file fields in core and tools

Assets created for missed objects and files
Improvements to the Project Importer to correct a number of issues, including not parsing ,'s from object names, trimming whitespace, pruning script extensions from exec invokes
This commit is contained in:
Areloch 2021-07-24 02:08:23 -05:00
parent 36b31ae19d
commit 432d201569
49 changed files with 406 additions and 128 deletions

View file

@ -106,7 +106,7 @@ function T3Dpre4ProjectImporter::copyFiles(%this)
DirectoryHandler::createFolder(0, %targetFolder);
}
if(!pathCopy(%file, %targetFilePath))
if(!pathCopy(%file, %targetFilePath, false))
{
error("Legacy Project Importer, failed to copy file: " @ %file @ " to destination: " @ %targetFilePath);
}
@ -183,7 +183,7 @@ function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this)
%currentPage = ProjectImportWindow.getCurrentPage();
//First, wipe out any files inside the folder first
%file = findFirstFileMultiExpr( $ProjectImporter::modulePath @ "/*/materials.cs", true);
%file = findFirstFileMultiExpr( $ProjectImporter::modulePath @ "/*/materials.*", true);
%fileObj = new FileObject();
%objectClassStack = new ArrayObject();
@ -247,6 +247,13 @@ function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this)
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ":"));
}
if(strpos(%objectName, ",") != -1)
{
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ","));
}
%objectName = trim(%objectName);
if(%objectClassStack.count() == 1)
{
//we only process top-level objects directly
@ -295,6 +302,13 @@ function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this)
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ":"));
}
if(strpos(%objectName, ",") != -1)
{
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ","));
}
%objectName = trim(%objectName);
if(%objectClassStack.count() == 1)
{
//we only process top-level objects directly
@ -369,7 +383,7 @@ function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this)
%fileOutputLines.empty();
%objectClassStack.empty();
%file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*/materials.cs" );
%file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*/materials.*" );
}
echo("Legacy Project Importer - Processing of imported code files done!");
@ -415,9 +429,9 @@ function T3Dpre4ProjectImporter::beginCodeFilesImport(%this)
%fileExt = fileExt(%file);
%filePath = filePath(%file);
if(%filename $= "materials.cs")
if(%filename $= "materials.cs" || %filename $= "materials.tscript" )
{
//we already handled materials.cs files, so skip
//we already handled materials script files, so skip
%file = findNextFileMultiExpr( $ProjectImporter::modulePath @ "/*.*" );
continue;
}
@ -461,6 +475,13 @@ function T3Dpre4ProjectImporter::beginCodeFilesImport(%this)
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ":"));
}
if(strpos(%objectName, ",") != -1)
{
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ","));
}
%objectName = trim(%objectName);
if(%objectClassStack.count() == 1)
{
//we only process top-level objects directly
@ -533,6 +554,13 @@ function T3Dpre4ProjectImporter::beginCodeFilesImport(%this)
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ":"));
}
if(strpos(%objectName, ",") != -1)
{
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ","));
}
%objectName = trim(%objectName);
if(%objectClassStack.count() == 1)
{
//we only process top-level objects directly
@ -574,6 +602,13 @@ function T3Dpre4ProjectImporter::beginCodeFilesImport(%this)
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ":"));
}
if(strpos(%objectName, ",") != -1)
{
%objectName = getSubStr(%objectName, 0, strpos(%objectName, ","));
}
%objectName = trim(%objectName);
if(%objectClassStack.count() == 1)
{
//we only process top-level objects directly
@ -595,6 +630,12 @@ function T3Dpre4ProjectImporter::beginCodeFilesImport(%this)
//hit the end of an object, pop our object stack
%objectClassStack.pop_back();
}
else if(strIsMatchExpr("*exec(*.cs*)*", %line) || strIsMatchExpr("*exec(*.tscript*)*", %line))
{
%scriptExtRemovedLine = strReplace(%line, ".cs", "");
%scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
%line = %scriptExtRemovedLine;
}
else
{
if(%objectClassStack.count() != 0)
@ -805,7 +846,7 @@ T3Dpre4ProjectImporter::genProcessor("GuiControlProfile", "bitmap bitmapAsset");
// Datablocks
//==============================================================================
T3Dpre4ProjectImporter::genProcessor("ForestItemData", "shape shapeAsset");
T3Dpre4ProjectImporter::genProcessor("CubeMapData", "cubemapFace cubemapFaceAsset cubemap cubemapAsset");
T3Dpre4ProjectImporter::genProcessor("CubeMapData", "cubemapFace cubeMapFaceAsset cubemap cubemapAsset");
T3Dpre4ProjectImporter::genProcessor("DebrisData", "shape shapeAsset");
T3Dpre4ProjectImporter::genProcessor("DecalData", "material materialAsset");
T3Dpre4ProjectImporter::genProcessor("ExplosionData", "explosionShape explosionShapeAsset");
@ -865,7 +906,7 @@ function T3Dpre4ProjectImporter::processMaterialObject(%this, %file, %objectName
{
%matAsset = MaterialAsset::getAssetIdByMaterialName(%objectName);
if(%matAsset $= "")
if(%matAsset $= "" || %matAsset $= "Core_Rendering:NoMaterial")
{
%assetName = %objectName;

View file

@ -373,9 +373,9 @@ function testFilenameExtensions(%filename)
function processLegacyField(%line, %originalFieldName, %newFieldName)
{
if(!strIsMatchExpr("*"@%originalFieldName@"=*\"*\";", %line) &&
!strIsMatchExpr("*"@%originalFieldName@"[*=*\"*\";", %line) &&
!strIsMatchExpr("*"@%originalFieldName@" *=*\"*\";", %line))
if(!strIsMatchExpr("*"@%originalFieldName@"=*\"*\";*", %line) &&
!strIsMatchExpr("*"@%originalFieldName@"[*=*\"*\";*", %line) &&
!strIsMatchExpr("*"@%originalFieldName@" *=*\"*\";*", %line))
return %line;
%outLine = strreplace(%line, %originalFieldName, %newFieldName);
@ -435,7 +435,7 @@ function processLegacyField(%line, %originalFieldName, %newFieldName)
}
else if ((strpos(%value,"/") == -1)&&(strpos(%value,"\\") == -1))
{
%targetFilename = $ProjectImporter::currentFilePath @ "/" @ %value;
%targetFilename = $ProjectImporter::currentFilePath @ %value;
}
else if(!startsWith(%value, $ProjectImporter::modulePath @ "/"))
{
@ -465,7 +465,10 @@ function processLegacyField(%line, %originalFieldName, %newFieldName)
if(%assetId !$= "" && AssetDatabase.isDeclaredAsset(%assetId))
{
//if (%assetId.getStatusString() $= "Ok")
%outLine = strReplace(%outLine, %value, %assetId);
//else
// error("Asset assignment failure:", %assetId, getStatusString());
}
}
@ -847,6 +850,8 @@ function beginLevelImport()
%assetName = %fileBase;
%assetName = strreplace(%assetName, " ", "");
if(AssetDatabase.isDeclaredAsset(%moduleName @ ":" @ %assetName))
{
warn("Legacy Project Importer - trying to process a level into an asset that already exists");
@ -864,31 +869,42 @@ function beginLevelImport()
levelName = %assetName;
};
if(isFile(%filePath @ "/" @ %assetName @ ".decal"))
if(isFile(%filePath @ "/" @ %fileBase @ ".decal"))
{
%asset.decalsFile = %assetName @ ".decal";
%asset.decalsFile = %fileBase @ ".decal";
}
if(isFile(%filePath @ "/" @ %assetName @ ".forest"))
if(isFile(%filePath @ "/" @ %fileBase @ ".forest"))
{
%asset.forestFile = %assetName @ ".forest";
%asset.forestFile = %fileBase @ ".forest";
}
if(isFile(%filePath @ "/" @ %assetName @ ".nav"))
if(isFile(%filePath @ "/" @ %fileBase @ ".nav"))
{
%asset.decalsFile = %assetName @ ".nav";
%asset.decalsFile = %fileBase @ ".nav";
}
if(isFile(%filePath @ "/" @ %assetName @ ".postfx.preset"))
if(isFile(%filePath @ "/" @ %fileBase @ ".postfx.preset"))
{
%asset.postFXPresetFile = %assetName @ ".postfx.preset";
%asset.postFXPresetFile = %fileBase @ ".postfx.preset";
}
if(isFile(%filePath @ "/" @ %assetName @ ".png"))
if(isFile(%filePath @ "/" @ %fileBase @ ".png"))
{
%previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %assetName @ ".png");
%previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ ".png");
%asset.addAssetDependencyField(previewImageAsset, %previewImageAsset);
}
else if(isFile(%filePath @ "/" @ %assetName @ ".dds"))
else if(isFile(%filePath @ "/" @ %fileBase @ ".dds"))
{
%previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %assetName @ ".dds");
%previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ ".dds");
%asset.addAssetDependencyField(previewImageAsset, %previewImageAsset);
}
else if(isFile(%filePath @ "/" @ %fileBase @ ".jpg"))
{
%previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ ".jpg");
%asset.addAssetDependencyField(previewImageAsset, %previewImageAsset);
}
else if(isFile(%filePath @ "/" @ %fileBase @ ".jpeg"))
{
%previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ ".jpeg");
%asset.addAssetDependencyField(previewImageAsset, %previewImageAsset);
}
@ -896,8 +912,6 @@ function beginLevelImport()
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
%success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
%sdfg = true;
}
}