Adjusts importer logic of assets to fill spaces in the names as underscores to avoid issues.

This commit is contained in:
Areloch 2020-06-26 23:28:53 -05:00
parent 41277fe3b8
commit 7b1c083839
2 changed files with 16 additions and 6 deletions

View file

@ -252,7 +252,11 @@ bool TerrainAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<Terrai
Torque::Path terrFilePath = fileName;
TerrainAsset* newTerrainAsset = new TerrainAsset();
newTerrainAsset->setAssetName(terrFilePath.getFileName().c_str());
String assetName = terrFilePath.getFileName();
assetName.replace(" ", "_");
newTerrainAsset->setAssetName(assetName.c_str());
String terrainPathBind = terrFilePath.getFileName() + terrFilePath.getExtension();
newTerrainAsset->mTerrainFilePath = StringTable->insert(terrainPathBind.c_str());
@ -267,7 +271,7 @@ bool TerrainAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<Terrai
// Turn-off auto-formatting.
taml.setAutoFormat(false);
String tamlPath = terrFilePath.getFullPath() + "/" + terrFilePath.getFileName() + ".asset.taml";
String tamlPath = terrFilePath.getFullPath() + "/" + assetName + ".asset.taml";
// Read object.
bool success = taml.write(newTerrainAsset, tamlPath.c_str());
@ -296,7 +300,7 @@ bool TerrainAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<Terrai
String assetId = targetModuleDef->getModuleId();
assetId += ":";
assetId += terrFilePath.getFileName().c_str();
assetId += assetName.c_str();
StringTableEntry resultingAssetId = StringTable->insert(assetId.c_str());
@ -339,7 +343,11 @@ StringTableEntry TerrainAsset::getAssetIdByFilename(StringTableEntry fileName)
Torque::Path terrFilePath = fileName;
TerrainAsset* newTerrainAsset = new TerrainAsset();
newTerrainAsset->setAssetName(terrFilePath.getFileName().c_str());
String assetName = terrFilePath.getFileName();
assetName.replace(" ", "_");
newTerrainAsset->setAssetName(assetName.c_str());
String terrainPathBind = terrFilePath.getFileName() + "." + terrFilePath.getExtension();
newTerrainAsset->mTerrainFilePath = StringTable->insert(terrainPathBind.c_str());
@ -354,7 +362,7 @@ StringTableEntry TerrainAsset::getAssetIdByFilename(StringTableEntry fileName)
// Turn-off auto-formatting.
taml.setAutoFormat(false);
String tamlPath = terrFilePath.getPath() + "/" + terrFilePath.getFileName() + ".asset.taml";
String tamlPath = terrFilePath.getPath() + "/" + assetName + ".asset.taml";
// Read object.
bool success = taml.write(newTerrainAsset, tamlPath.c_str());
@ -383,7 +391,7 @@ StringTableEntry TerrainAsset::getAssetIdByFilename(StringTableEntry fileName)
String assetId = targetModuleDef->getModuleId();
assetId += ":";
assetId += terrFilePath.getFileName().c_str();
assetId += assetName.c_str();
StringTableEntry resultingAssetId = StringTable->insert(assetId.c_str());

View file

@ -390,6 +390,8 @@ AssetImportObject* AssetImporter::addImportingAsset(String assetType, Torque::Pa
else
assetName = filePath.getFileName();
assetName.replace(" ", "_");
AssetImportObject* assetImportObj = new AssetImportObject();
assetImportObj->registerObject();