mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Adjusted handling of field converts in the project importer to deal with fields that didn't contain quotation marks
This commit is contained in:
parent
9c243bc5e2
commit
737fd70c69
1 changed files with 20 additions and 22 deletions
|
|
@ -516,31 +516,24 @@ function testFilenameExtensions(%filename)
|
||||||
|
|
||||||
function processLegacyField(%line, %originalFieldName, %newFieldName)
|
function processLegacyField(%line, %originalFieldName, %newFieldName)
|
||||||
{
|
{
|
||||||
if(!strIsMatchExpr("*"@%originalFieldName@"=*\"*\";*", %line) &&
|
if(!strIsMatchExpr("*"@%originalFieldName@"=*;*", %line) &&
|
||||||
!strIsMatchExpr("*"@%originalFieldName@"[*=*\"*\";*", %line) &&
|
!strIsMatchExpr("*"@%originalFieldName@"[*=*;*", %line) &&
|
||||||
!strIsMatchExpr("*"@%originalFieldName@" *=*\"*\";*", %line))
|
!strIsMatchExpr("*"@%originalFieldName@" *=*;*", %line))
|
||||||
return %line;
|
return %line;
|
||||||
|
|
||||||
%outLine = strreplace(%line, %originalFieldName, %newFieldName);
|
%outLine = strreplace(%line, %originalFieldName, %newFieldName);
|
||||||
|
|
||||||
//get the value
|
//get the value
|
||||||
%value = "";
|
%value = "";
|
||||||
%pos = strpos(%outLine, "= \"");
|
%pos = strpos(%outLine, "=");
|
||||||
if(%pos != -1)
|
if(%pos != -1)
|
||||||
{
|
{
|
||||||
%endPos = strpos(%outLine, "\";", %pos);
|
%endPos = strpos(%outLine, ";", %pos);
|
||||||
|
%value = getSubStr(%outLine, %pos+1, %endPos-%pos-1);
|
||||||
|
|
||||||
%value = getSubStr(%outLine, %pos+3, %endPos-%pos-3);
|
%originalValue = %value;
|
||||||
}
|
%value = trim(%value);
|
||||||
else
|
%value = strreplace(%value, "\"", "");
|
||||||
{
|
|
||||||
%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 !$= "")
|
if(%outLine !$= %line && %pos != -1 && %endPos != -1 && %value !$= "")
|
||||||
|
|
@ -557,8 +550,13 @@ function processLegacyField(%line, %originalFieldName, %newFieldName)
|
||||||
|
|
||||||
if(isObject(%targetFilename))
|
if(isObject(%targetFilename))
|
||||||
{
|
{
|
||||||
if(%originalFieldName $= "soundProfile")
|
//likely a material name, so handle it that way
|
||||||
|
%assetId = MaterialAsset::getAssetIdByMaterialName(%targetFilename);
|
||||||
|
|
||||||
|
if(%assetId $= "" || %assetId $= "Core_Rendering:NoMaterial")
|
||||||
{
|
{
|
||||||
|
//if not, just do a lookup directly to see if it was another asset by that name
|
||||||
|
//e.g. sound profiles when converted will match names
|
||||||
$ProjectImporter::assetQuery.clear();
|
$ProjectImporter::assetQuery.clear();
|
||||||
%foundAssets = AssetDatabase.findAssetName($ProjectImporter::assetQuery, %targetFilename);
|
%foundAssets = AssetDatabase.findAssetName($ProjectImporter::assetQuery, %targetFilename);
|
||||||
if(%foundAssets != 0)
|
if(%foundAssets != 0)
|
||||||
|
|
@ -566,11 +564,6 @@ function processLegacyField(%line, %originalFieldName, %newFieldName)
|
||||||
%assetId = $ProjectImporter::assetQuery.getAsset(0);
|
%assetId = $ProjectImporter::assetQuery.getAsset(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//likely a material name, so handle it that way
|
|
||||||
%assetId = MaterialAsset::getAssetIdByMaterialName(%targetFilename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -605,6 +598,11 @@ function processLegacyField(%line, %originalFieldName, %newFieldName)
|
||||||
if(%assetId !$= "" && AssetDatabase.isDeclaredAsset(%assetId))
|
if(%assetId !$= "" && AssetDatabase.isDeclaredAsset(%assetId))
|
||||||
{
|
{
|
||||||
echo("Legacy Project Importer - processing of legacy field line's value: " @ %value @ " has found a matching AssetId: " @ %assetId);
|
echo("Legacy Project Importer - processing of legacy field line's value: " @ %value @ " has found a matching AssetId: " @ %assetId);
|
||||||
|
|
||||||
|
//double check if this already had the quotes around the value or not
|
||||||
|
if(!strIsMatchExpr("*\"*\"*", %originalValue))
|
||||||
|
%assetId = "\"" @ %assetId @ "\"";
|
||||||
|
|
||||||
//if (%assetId.getStatusString() $= "Ok")
|
//if (%assetId.getStatusString() $= "Ok")
|
||||||
%outLine = strReplace(%outLine, %value, %assetId);
|
%outLine = strReplace(%outLine, %value, %assetId);
|
||||||
//else
|
//else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue