From b8b94fdec90863c8c58148fee3095f2d42eddd00 Mon Sep 17 00:00:00 2001 From: JeffR Date: Fri, 25 Feb 2022 00:03:33 -0600 Subject: [PATCH] Standardizes project import copy behavior to validate if we're in-place importing to avoid erroring out needlessly with a new utility function Fixed wrong variable preventing ImportConfig Editor from refreshing when selecting different configs Standardized DefaultImportConfig's settings against Legacy Import setting, specifically collision resolution behavior and appending _mat suffix to materials --- .../tools/assetBrowser/assetImportConfigs.xml | 648 ++++++++++++------ .../assetBrowser/scripts/assetBrowser.tscript | 4 +- .../scripts/assetImportConfigEditor.tscript | 6 +- .../importers/pre40/pre40ImporterGuis.tscript | 7 +- .../scripts/projectImporter.tscript | 57 +- 5 files changed, 467 insertions(+), 255 deletions(-) diff --git a/Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml b/Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml index 3cfa5da83..5c91b3d2a 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml +++ b/Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml @@ -1,243 +1,459 @@ - - - 2 - Seconds - 1 - 1 + + + 2 + Seconds + 1 + 1 - - Col - CollisionMesh - 1 - 1 - CollisionMesh - LOS + + Col + CollisionMesh + 1 + 1 + CollisionMesh + LOS - - 0 - 0 - AutoPrune - AutoPrune - 1 - 0 + + 0 + 0 + AutoPrune + FolderPrefix + 1 + 0 - - _image - 1 - _AO,_AMBIENT,_AMBIENTOCCLUSION - _COMP,_COMPOSITE,_PBR,-COMP,-COMPOSITE,-PBR,_ORM,-ORM,_C - 1 - _ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL - 0 - N/A - 1 - 0 - _METAL,_MET,_METALNESS,_METALLIC,_M - _NORMAL,_NORM,_N - _ROUGH,_ROUGHNESS,_R - 1.0 - _SMOOTH,_SMOOTHNESS,_S - Bilinear - 1 + + _image + 1 + _AO,_AMBIENT,_AMBIENTOCCLUSION + _COMP,_COMPOSITE,_PBR,-COMP,-COMPOSITE,-PBR,_ORM,-ORM,_C + 1 + _ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL + 0 + N/A + 1 + 0 + _METAL,_MET,_METALNESS,_METALLIC,_M + _NORMAL,_NORM,_N + _ROUGH,_ROUGHNESS,_R + 1.0 + _SMOOTH,_SMOOTHNESS,_S + Bilinear + 1 - - _mat - 0 - 1 - 1 - DefaultMaterial,ColorEffect* - 1 - 1 - 1 - 1 + + _mat + 1 + 1 + 1 + DefaultMaterial,ColorEffect* + 1 + 1 + 1 + 1 - - _shape - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - TrailingNumber - 0 - 0 - 1 - 0 - Z_AXIS + + _shape + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + TrailingNumber + 0 + 0 + 1 + 0 + Z_AXIS - - 0 - 1.0 - 1.0 + + 0 + 1.0 + 1.0 - - - 2 - Seconds - 1 - 1 + + + 2 + Seconds + 1 + 1 - - Col - CollisionMesh - 1 - 1 - CollisionMesh - LOS + + Col + CollisionMesh + 1 + 1 + CollisionMesh + LOS - - 0 - 0 - FolderPrefix - 1 - 0 + + 0 + 0 + FolderPrefix + 1 + 0 - - _image - 1 - _AO,_AMBIENT,_AMBIENTOCCLUSION - _COMP,_COMPOSITE - 1 - _ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL - 0 - N/A - 1 - 0 - _METAL,_MET,_METALNESS,_METALLIC - _NORMAL,_NORM - _ROUGH,_ROUGHNESS - 1.0 - _SMOOTH,_SMOOTHNESS - Bilinear - 1 + + _image + 1 + _AO,_AMBIENT,_AMBIENTOCCLUSION + _COMP,_COMPOSITE + 1 + _ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL + 0 + N/A + 1 + 0 + _METAL,_MET,_METALNESS,_METALLIC + _NORMAL,_NORM + _ROUGH,_ROUGHNESS + 1.0 + _SMOOTH,_SMOOTHNESS + Bilinear + 1 - - _mat - 1 - 1 - 1 - DefaultMaterial,ColorEffect* - 1 - 1 - 1 + + _mat + 1 + 1 + DefaultMaterial,ColorEffect* + 1 + 1 + 1 + 1 - - _shape - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - TrailingNumber - 0 - 0 - 1 - 0 - Z_AXIS + + _shape + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + TrailingNumber + 0 + 0 + 1 + 0 + Z_AXIS - - 0 - 1.0 - 1.0 + + 0 + 1.0 + 1.0 - - - 2 - Seconds - 1 - 1 + + + 2 + Seconds + 1 + 1 - - Col - CollisionMesh - 1 - 1 - CollisionMesh - LOS + + Col + CollisionMesh + 1 + 1 + CollisionMesh + LOS - - 0 - 0 - AutoPrune - 1 - 0 + + 0 + 0 + AutoPrune + 1 + 0 - - _AO,_AMBIENT,_AMBIENTOCCLUSION - 1 - _ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL - 1 - N/A - 0 - _METAL,_MET,_METALNESS,_METALLIC - _NORMAL,_NORM - _COMP,_COMPOSITE,_PBR,-COMP,-COMPOSITE,-PBR,_ORM,-ORM - _ROUGH,_ROUGHNESS - 1.0 - _SMOOTH,_SMOOTHNESS - Bilinear - 1 + + _AO,_AMBIENT,_AMBIENTOCCLUSION + 1 + _ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL + 1 + N/A + 0 + _METAL,_MET,_METALNESS,_METALLIC + _NORMAL,_NORM + _COMP,_COMPOSITE,_PBR,-COMP,-COMPOSITE,-PBR,_ORM,-ORM + _ROUGH,_ROUGHNESS + 1.0 + _SMOOTH,_SMOOTHNESS + Bilinear + 1 - - 1 - 1 - 1 - 1 - 1 + + 1 + 1 + 1 + 1 + 1 - - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - TrailingNumber - 0 - 0 - 1 - 0 - Z_AXIS + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + TrailingNumber + 0 + 0 + 1 + 0 + Z_AXIS - - 0 - 1.0 - 1.0 + + 0 + 1.0 + 1.0 diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript index c385a5f0c..7d0c1e3da 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript @@ -2491,8 +2491,10 @@ function AssetBrowser::autoImportSimpleLooseFiles(%this) while( %file !$= "" ) { - if(!strIsMatchExpr("*.asset.taml", %file) && !strIsMatchExpr("*.taml", %file) && !strIsMatchExpr("*.cached.dts", %file)) + if(!strIsMatchExpr("*.asset.taml", %file) && !strIsMatchExpr("*.taml", %file) && !strIsMatchExpr("*.cached.dts", %file) + && !strIsMatchExpr("*.cs", %file) && !strIsMatchExpr("*.tscript", %file) && !strIsMatchExpr("*.module", %file)) { + %aq.clear(); %assetsFound = AssetDatabase.findAssetLooseFile(%aq, %file); if(%assetsFound == 0) diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfigEditor.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfigEditor.tscript index 929c1ddfe..d664cfa05 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfigEditor.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfigEditor.tscript @@ -33,8 +33,8 @@ function AssetImportConfigEditor::apply(%this) function AssetImportConfigList::onSelect( %this, %id, %text ) { - ImportOptionsConfigList.clearFields(); - ImportOptionsConfigList.setAutoUpdate(false); //we don't want to be updating every time we add a field in here + AssetImportConfigEditorInspector.clearFields(); + AssetImportConfigEditorInspector.setAutoUpdate(false); //we don't want to be updating every time we add a field in here %this.currentConfig = %text; @@ -46,7 +46,7 @@ function AssetImportConfigList::onSelect( %this, %id, %text ) %this.populateConfigListByGroup("Animations"); //%this.populateConfigListByGroup("Collision"); - ImportOptionsConfigList.update(); + AssetImportConfigEditorInspector.update(); } function AssetImportConfigList::populateConfigListByGroup(%this, %groupName) diff --git a/Templates/BaseGame/game/tools/projectImporter/importers/pre40/pre40ImporterGuis.tscript b/Templates/BaseGame/game/tools/projectImporter/importers/pre40/pre40ImporterGuis.tscript index 10b7fb96a..4835889e8 100644 --- a/Templates/BaseGame/game/tools/projectImporter/importers/pre40/pre40ImporterGuis.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/importers/pre40/pre40ImporterGuis.tscript @@ -46,12 +46,7 @@ function Pre40ImporterPage0::openPage(%this) %targetFolder = filePath(%targetFilePath); - if(!isDirectory(%targetFolder)) - { - DirectoryHandler::createFolder(0, %targetFolder); - } - - if(!pathCopy(%file, %targetFilePath, false)) + if(!copyFileToDestination(%file, %targetFilePath)) { $ProjectImporter::log.add("Legacy Project Importer, failed to copy file: " @ %file @ " to destination: " @ %targetFilePath); continue; diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript index 13797d2a2..eccb3b0f6 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript @@ -373,6 +373,28 @@ function ProjectImportWindow::addImporterPage(%this, %page) // functions that'll pretty much be used regardless of version being targeted //============================================================================== //============================================================================== +// Takes a source file and attempts to copy it to the destination path. +// If the paths are the same, we just exit out with a success indicator +//============================================================================== +function copyFileToDestination(%sourceFile, %destinationFile) +{ + %fullSourcePath = makeFullPath(%sourceFile); + %fullDestPath = makeFullPath(%destinationFile); + + if(!IsDirectory(filePath(%fullDestPath))) + { + DirectoryHandler::createFolder(0, filePath(%fullDestPath)); + } + + if(%fullSourcePath $= %fullDestPath) + return true; //no need to copy, we're already here! + + if(!pathCopy(%fullSourcePath, %fullDestPath, false)) + return false; + + return true; +} +//============================================================================== // Runs through the files in the source directory and preprocessing them. // All valid files are added to a list, and script-based files are pre-parsed // so the importer can easily process their contents later @@ -1436,12 +1458,7 @@ function beginShapeImport() %destinationPath = %rootFileSectionObject.fileDestination; if(isFile(%file) && %rootFileSectionObject.isShapeFile == true && %rootFileSectionObject.imported == false) { - if(!IsDirectory(filePath(%destinationPath))) - { - DirectoryHandler::createFolder(0, filePath(%destinationPath)); - } - - if(!pathCopy(%file, %destinationPath, false)) + if(!copyFileToDestination(%file, %destinationPath)) { projectImporterLog("ProjectImporter::beginShapeImport() - failed to copy shape: " @ %file @ " to destination: " @ %destinationPath); @@ -1502,12 +1519,7 @@ function beginImageImport() %destinationPath = %rootFileSectionObject.fileDestination; if(isFile(%file) && %rootFileSectionObject.isImageFile == true && %rootFileSectionObject.imported == false) { - if(!IsDirectory(filePath(%destinationPath))) - { - DirectoryHandler::createFolder(0, filePath(%destinationPath)); - } - - if(!pathCopy(%file, %destinationPath, false)) + if(!copyFileToDestination(%file, %destinationPath)) { projectImporterLog("ProjectImporter::beginImageImport() - failed to copy image: " @ %file @ " to destination: " @ %destinationPath); @@ -1577,12 +1589,8 @@ function beginTerrainImport() %fileName = fileName(%file); %filePath = filePath(%file); }*/ - if(!IsDirectory(filePath(%destinationPath))) - { - DirectoryHandler::createFolder(0, filePath(%destinationPath)); - } - if(!pathCopy(%file, %destinationPath, false)) + if(!copyFileToDestination(%file, %destinationPath)) { projectImporterLog("ProjectImporter::beginTerrainImport() - failed to copy terrain: " @ %file @ " to destination: " @ %destinationPath); @@ -1666,12 +1674,8 @@ function beginSoundImport() %fileName = fileName(%file); %filePath = filePath(%file); }*/ - if(!IsDirectory(filePath(%destinationPath))) - { - DirectoryHandler::createFolder(0, filePath(%destinationPath)); - } - if(!pathCopy(%file, %destinationPath, false)) + if(!copyFileToDestination(%file, %destinationPath)) { projectImporterLog("ProjectImporter::beginSoundImport() - failed to copy sound: " @ %file @ " to destination: " @ %destinationPath); @@ -1775,7 +1779,7 @@ function beginGUIImport() //Check if we need to even copy in the first place. If we do, ensure //the copy actually worked - if((makeRelativePath(%file) !$= %destinationPath) && !pathCopy(%file, %destinationPath, false)) + if(!copyFileToDestination(%file, %destinationPath)) { projectImporterLog("ProjectImporter::beginGUIImport() - failed to copy GUI: " @ %file @ " to destination: " @ %destinationPath); @@ -1888,12 +1892,7 @@ function beginLevelImport() %fileBase = fileBase(%destinationPath); %filePath = filePath(%destinationPath); - if(!IsDirectory(filePath(%destinationPath))) - { - DirectoryHandler::createFolder(0, filePath(%destinationPath)); - } - - if(!pathCopy(%file, %destinationPath, false)) + if(!copyFileToDestination(%file, %destinationPath)) { projectImporterLog("ProjectImporter::beginLevelImport() - failed to copy level: " @ %file @ " to destination: " @ %destinationPath);