Adjusts the ShapeAsset autoImport invoke logic to actually use the C++-side autoImport logic

Changed originalImportingAssets to originalImportingFiles in the AssetImporter for naming clarity
Made autoImportFile properly return the assetId that was made
Additional logging in the AssetImporter
Adjusted the asset registration logic to support reimports, which merely refreshes the assetID
Added logic to shape asset importing to be able to import in an existing companion constructor cs file
Tweaked the TSStatic setShapeName logic so it will properly set fields depending on if the assetID was correctly set, or if we have the noShape fallback in use
This commit is contained in:
Areloch 2020-05-17 01:38:17 -05:00
parent 3f0195475d
commit 9b7b09dce8
4 changed files with 227 additions and 127 deletions

View file

@ -44,6 +44,7 @@
// Debug Profiling.
#include "platform/profiler.h"
#include "T3D/assets/assetImporter.h"
//-----------------------------------------------------------------------------
@ -329,19 +330,21 @@ bool ShapeAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAss
Con::warnf("ShapeAsset::getAssetByFilename - Attempted to in-place import a shapefile(%s) that had no associated asset", fileName);
#endif
ConsoleValueRef result = Con::executef("importLooseFile", fileName, true);
if (result.getBoolValue())
AssetImporter* autoAssetImporter;
if (!Sim::findObject("autoAssetImporter", autoAssetImporter))
{
StringTableEntry resultingAssetId = StringTable->insert(Con::getVariable("$importedLooseFileAsset"));
autoAssetImporter = new AssetImporter();
autoAssetImporter->registerObject("autoAssetImporter");
}
if (resultingAssetId != StringTable->EmptyString())
{
shapeAsset->setAssetId(resultingAssetId);
StringTableEntry resultingAssetId = autoAssetImporter->autoImportFile(fileName);
if (!shapeAsset->isNull())
return true;
}
if (resultingAssetId != StringTable->EmptyString())
{
shapeAsset->setAssetId(resultingAssetId);
if (!shapeAsset->isNull())
return true;
}
//Didn't work, so have us fall back to a placeholder asset
@ -375,17 +378,19 @@ StringTableEntry ShapeAsset::getAssetIdByFilename(StringTableEntry fileName)
Con::warnf("ShapeAsset::getAssetByFilename - Attempted to in-place import a shapefile(%s) that had no associated asset", fileName);
#endif
ConsoleValueRef result = Con::executef("importLooseFile", fileName, true);
if (result.getBoolValue())
AssetImporter* autoAssetImporter;
if (!Sim::findObject("autoAssetImporter", autoAssetImporter))
{
StringTableEntry resultingAssetId = StringTable->insert(Con::getVariable("$importedLooseFileAsset"));
autoAssetImporter = new AssetImporter();
autoAssetImporter->registerObject("autoAssetImporter");
}
if (resultingAssetId != StringTable->EmptyString())
{
shapeAssetId = resultingAssetId;
return shapeAssetId;
}
StringTableEntry resultingAssetId = autoAssetImporter->autoImportFile(fileName);
if (resultingAssetId != StringTable->EmptyString())
{
shapeAssetId = resultingAssetId;
return shapeAssetId;
}
//Didn't work, so have us fall back to a placeholder asset