Added getShapeConstructorFilePath console function on shapeAsset

Fixed typo in import config settings for DuplicateAutoResolution
Converted TSShapeConstructor to utilize assets
Updated shape editor to work with assetified constructors
Converted guiBitmapButtonCtrl to use assets
This commit is contained in:
Areloch 2021-08-02 04:20:27 -05:00
parent 52c83d19e1
commit 88ae8a9665
181 changed files with 2343 additions and 1577 deletions

View file

@ -543,25 +543,38 @@ function T3Dpre4ProjectImporter::beginCodeFilesImport(%this)
%scriptExtRemovedLine = strReplace(%line, ".cs", "");
%scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
%line = %scriptExtRemovedLine;
%fileWasChanged = true;
}
else if(strIsMatchExpr("*queueexec(*.cs*)*", %line) || strIsMatchExpr("*queueexec(*.tscript*)*", %line))
{
%scriptExtRemovedLine = strReplace(%line, ".cs", "");
%scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
%line = %scriptExtRemovedLine;
%fileWasChanged = true;
}
else if(strIsMatchExpr("*registerDatablock(*.cs*)*", %line) || strIsMatchExpr("*registerDatablock(*.tscript*)*", %line))
{
%scriptExtRemovedLine = strReplace(%line, ".cs", "");
%scriptExtRemovedLine = strReplace(%scriptExtRemovedLine, ".tscript", "");
%line = %scriptExtRemovedLine;
%fileWasChanged = true;
}
else if(strIsMatchExpr("*%this.addSequence(\"*);", %line))
{
%outLine = processLegacyShapeConstructorField(%line);
if(%line !$= %outLine)
{
%fileWasChanged = true;
%line = %outLine;
}
}
else
{
if(%objectClassStack.count() != 0)
{
%currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1);
%inheritanceList = getClassHierarchy(%currentObjClass);
for (%classDepth =0; %classDepth<getWordCount(%inheritanceList); %classDepth++)
{
@ -716,8 +729,7 @@ T3Dpre4ProjectImporter::genProcessor("MeshRoad", "topMaterial topMaterialAsset b
T3Dpre4ProjectImporter::genProcessor("ScatterSky", "moonMat moonMatAsset");
T3Dpre4ProjectImporter::genProcessor("Sun", "coronaMaterial coronaMaterialAsset");
T3Dpre4ProjectImporter::genProcessor("VolumetricFog", "shape ShapeAsset texture textureAsset");
T3Dpre4ProjectImporter::genProcessor("WaterPlane", "rippleTex rippleTexAsset foamTex foamTexAsset depthGradientTex depthGradientTexAsset");
T3Dpre4ProjectImporter::genProcessor("WaterBlock", "rippleTex rippleTexAsset foamTex foamTexAsset depthGradientTex depthGradientTexAsset");
T3Dpre4ProjectImporter::genProcessor("WaterObject", "rippleTex rippleTexAsset foamTex foamTexAsset depthGradientTex depthGradientTexAsset");
T3Dpre4ProjectImporter::genProcessor("ConvexShape", "material materialAsset");
T3Dpre4ProjectImporter::genProcessor("RenderMesh", "material materialAsset");
T3Dpre4ProjectImporter::genProcessor("RenderShape", "shape shapeAsset");
@ -762,12 +774,21 @@ T3Dpre4ProjectImporter::genProcessor("GuiProgressBitmap", "bitmap bitmapAsset");
T3Dpre4ProjectImporter::genProcessor("GuiMissionArea", "handleBitmap handleBitmapAsset");
T3Dpre4ProjectImporter::genProcessor("WorldEditor", "selectHandle selectHandleAsset defaultHandle defaultHandleAsset lockedHandle lockedHandleAsset");
T3Dpre4ProjectImporter::genProcessor("GuiControlProfile", "bitmap bitmapAsset");
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");
T3Dpre4ProjectImporter::genProcessor("DebrisData", "shape shapeAsset");
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");
@ -779,7 +800,7 @@ T3Dpre4ProjectImporter::genProcessor("PhysicsShapeData", "shape shapeAsset");
T3Dpre4ProjectImporter::genProcessor("PlayerData", "shapeFP shapeFPAsset shapeNameFP shapeFPAsset");
T3Dpre4ProjectImporter::genProcessor("ProjectileData", "projectileShape projectileShapeAsset projectileShapeName projectileShapeAsset");
T3Dpre4ProjectImporter::genProcessor("ShapeBaseData", "shapeFile shapeAsset shape shapeAsset debrisShape debrisShapeAsset debrisShapeName debrisShapeAsset");
T3Dpre4ProjectImporter::genProcessor("ShapeBaseImageData", "shape shapeAsset shapeFP shapeAsset");
T3Dpre4ProjectImporter::genProcessor("ShapeBaseImageData", "shape shapeAsset shapeFP shapeFPAsset shapeFile shapeAsset shapeFileFP shapeFPAsset");
T3Dpre4ProjectImporter::genProcessor("WheeledVehicleTire", "shape shapeAsset shapeFile shapeAsset");
//==============================================================================
// Materials
@ -921,4 +942,136 @@ function T3Dpre4ProjectImporter::processTerrainMaterialObject(%this, %file, %obj
//==============================================================================
// PostEffects
//==============================================================================
T3Dpre4ProjectImporter::genProcessor("PostEffect", "texture textureAsset");
T3Dpre4ProjectImporter::genProcessor("PostEffect", "texture textureAsset");
//==============================================================================
// 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 !$= "")
{
echo("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;
}
//find any assets with that filename
else if(startsWith(%value, "./"))
{
%targetFilename = strReplace(%value, "./", $ProjectImporter::currentFilePath @ "/");
}
else if(startsWith(%value, "../"))
{
%slashPos = strposr($ProjectImporter::currentFilePath, "/");
if(%slashPos == strlen($ProjectImporter::currentFilePath)-1) //if it's right at the end, we'll get the next one up
{
%slashPos = strposr($ProjectImporter::currentFilePath, "/", 2);
}
%parentPath = getSubStr($ProjectImporter::currentFilePath, 0, %slashPos);
%targetFilename = strReplace(%value, "../", %parentPath @ "/");
}
else if(startsWith(%value, "~"))
{
%targetFilename = strReplace(%value, "~", $ProjectImporter::modulePath @ "/");
if(!isFile(%targetFilename))
{
%targetFilename = strReplace(%value, "~", $ProjectImporter::modulePath @ "/main/");
}
}
else if ((strpos(%value,"/") == -1)&&(strpos(%value,"\\") == -1))
{
%targetFilename = $ProjectImporter::currentFilePath @ %value;
}
else if(!startsWith(%value, $ProjectImporter::modulePath @ "/"))
{
%targetFilename = $ProjectImporter::modulePath @ "/" @ %value;
}
else
{
%targetFilename = %value;
}
%targetFilename = strReplace(%targetFilename, "//", "/");
%targetFilename = testFilenameExtensions(%targetFilename);
if(!isFile(%targetFilename)) //if our presumed file target is bad, just bail out
{
//Now we test for a suffix
%targetPath = filePath(%targetFilename);
%targetName = fileBase(%targetFilename);
%targetExt = fileExt(%targetFilename);
%targetFilename = %targetPath @ "/" @ %targetName @ "_n" @ %targetExt;
%targetFilename = strReplace(%targetFilename, "//", "/");
%targetFilename = testFilenameExtensions(%targetFilename);
}
//If we still have nothing, then we fail it out
if(!isFile(%targetFilename))
{
error("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);
echo("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)
{
echo("Legacy Project Importer - processing of legacy line: " @ %line @ " has been updated to: " @ %outLine);
return %outLine;
}
else
{
return %line;
}
}

View file

@ -247,7 +247,7 @@ function ProjectImportWizardPage4::openPage(%this)
ProjectImportWindow-->nextButton.setActive(false);
if(!$ProjectImporter::useExistingModule)
$ProjectImporter::moduleName = ProjectImportWizardPage3-->newModuleName.getText();
$ProjectImporter::moduleName = ProjectImportWizardPage3-->newModuleName.getText();
$ProjectImporter::modulePath = "data/" @ $ProjectImporter::moduleName;
@ -374,7 +374,7 @@ function testFilenameExtensions(%filename)
else if(isFile(%filename @ ".dds"))
return %filename @ ".dds";
return "";
return %filename;
}
function processLegacyField(%line, %originalFieldName, %newFieldName)
@ -489,6 +489,95 @@ function processLegacyField(%line, %originalFieldName, %newFieldName)
}
}
function processLegacyShapeConstructorField(%line)
{
if(!strIsMatchExpr("*%this.addSequence(\"*);", %line))
return %line;
%outLine = %line;
%animSourceStart = strPos(%line, "%this.addSequence(\"") + 19;
%animSourceEnd = strPos(%line, "\",", %animSourceStart);
%animationSource = getSubstr(%line, %animSourceStart, %animSourceEnd-%animSourceStart);
%animSourcePath = getWord(%animationSource, 0);
%animSourceName = getWord(%animationSource, 1);
//already uses an asset, so we'll skip
if(strPos(%animSourcePath, ":") != -1)
return %line;
//otherwise, try and see if we've got an animation source file here
if(startsWith(%animSourcePath, "./"))
{
%targetFilename = strReplace(%animSourcePath, "./", $ProjectImporter::currentFilePath @ "/");
}
else if(startsWith(%animSourcePath, "../"))
{
%slashPos = strposr($ProjectImporter::currentFilePath, "/");
if(%slashPos == strlen($ProjectImporter::currentFilePath)-1) //if it's right at the end, we'll get the next one up
{
%slashPos = strposr($ProjectImporter::currentFilePath, "/", 2);
}
%parentPath = getSubStr($ProjectImporter::currentFilePath, 0, %slashPos);
%targetFilename = strReplace(%animSourcePath, "../", %parentPath @ "/");
}
else if(startsWith(%animSourcePath, "~"))
{
%targetFilename = strReplace(%animSourcePath, "~", $ProjectImporter::modulePath @ "/");
if(!isFile(%targetFilename))
{
%targetFilename = strReplace(%animSourcePath, "~", $ProjectImporter::modulePath @ "/main/");
}
}
else if ((strpos(%animSourcePath,"/") == -1)&&(strpos(%animSourcePath,"\\") == -1))
{
%targetFilename = $ProjectImporter::currentFilePath @ %animSourcePath;
}
else if(!startsWith(%animSourcePath, $ProjectImporter::modulePath @ "/"))
{
%targetFilename = $ProjectImporter::modulePath @ "/" @ %animSourcePath;
}
else
{
%targetFilename = %animSourcePath;
}
%targetFilename = strReplace(%targetFilename, "//", "/");
%targetFilename = testFilenameExtensions(%targetFilename);
if(!isFile(%targetFilename))
{
return %line;
}
$ProjectImporter::assetQuery.clear();
%foundAssets = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %targetFilename);
if(%foundAssets != 0)
{
%assetId = $ProjectImporter::assetQuery.getAsset(0);
echo("Legacy Project Importer - processing of legacy shape constructor addSequence line's value: " @ %value @ " has found a matching AssetId: " @ %assetId);
}
if(%assetId !$= "" && AssetDatabase.isDeclaredAsset(%assetId))
{
//if (%assetId.getStatusString() $= "Ok")
%outLine = strReplace(%line, %animSourcePath, %assetId);
//else
// error("Asset assignment failure:", %assetId, getStatusString());
}
if(%outLine !$= %line)
{
echo("Legacy Project Importer - processing of legacy shape constructor addSequence line: " @ %line @ " has been updated to: " @ %outLine);
return %outLine;
}
else
{
return %line;
}
}
function findObjectClass(%line, %createWord)
{
//we have a new object, add it to the stack
@ -668,6 +757,11 @@ function beginImageImport()
if(isImageFormat(%fileExt))
{
if(%filename $= "skybox_1.png")
{
%aefgadfg = true;
}
$ProjectImporter::assetQuery.clear();
%assetsFound = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %file);
if(%assetsFound == 0)