From c0d6cc36f56e617321382dca75b30eb5840069ea Mon Sep 17 00:00:00 2001 From: Areloch Date: Sun, 8 Dec 2019 15:54:37 -0600 Subject: [PATCH] Updated move folder behavior to better update the module and asset databases of changes added dynamic reload on editor profiles when the theme is changed via editor Adjusted direct filename fields to just be hidden, not disabled(avoids breaking legacy content) Added ability to update asset references in a given folder path Added WIP ability to scan for and update module dependencies --- Engine/source/T3D/tsStatic.cpp | 4 +- Engine/source/environment/VolumetricFog.cpp | 6 +-- .../assetBrowser/scripts/assetTypes/folder.cs | 18 +++++++ .../assetBrowser/scripts/directoryHandling.cs | 2 +- .../tools/assetBrowser/scripts/editAsset.cs | 52 +++++++++++++++++++ .../tools/assetBrowser/scripts/editModule.cs | 51 +++++++++++++++++- .../game/tools/gui/editorSettingsWindow.ed.cs | 6 +++ Tools/CMake/torque3d.cmake | 7 --- 8 files changed, 130 insertions(+), 16 deletions(-) diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index b81e2f555..114fe1972 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -171,10 +171,8 @@ void TSStatic::initPersistFields() &TSStatic::_setShapeAsset, &defaultProtectedGetFn, "The source shape asset."); -#ifdef TORQUE_ALLOW_DIRECT_FILENAMES addField("shapeName", TypeShapeFilename, Offset( mShapeName, TSStatic ), - "%Path and filename of the model file (.DTS, .DAE) to use for this TSStatic." ); -#endif + "%Path and filename of the model file (.DTS, .DAE) to use for this TSStatic.", AbstractClassRep::FieldFlags::FIELD_HideInInspectors ); addProtectedField( "skin", TypeRealString, Offset( mAppliedSkinName, TSStatic ), &_setFieldSkin, &_getFieldSkin, "@brief The skin applied to the shape.\n\n" diff --git a/Engine/source/environment/VolumetricFog.cpp b/Engine/source/environment/VolumetricFog.cpp index 3fc6389a0..2d1a0623a 100644 --- a/Engine/source/environment/VolumetricFog.cpp +++ b/Engine/source/environment/VolumetricFog.cpp @@ -171,10 +171,8 @@ void VolumetricFog::initPersistFields() addProtectedField("shapeAsset", TypeShapeAssetPtr, Offset(mShapeAsset, VolumetricFog), &VolumetricFog::_setShapeAsset, &defaultProtectedGetFn, "The source shape asset."); -#ifdef TORQUE_ALLOW_DIRECT_FILENAMES addField("shapeName", TypeShapeFilename, Offset(mShapeName, VolumetricFog), - "Path and filename of the model file (.DTS, .DAE) to use for this Volume."); -#endif + "Path and filename of the model file (.DTS, .DAE) to use for this Volume.", AbstractClassRep::FieldFlags::FIELD_HideInInspectors ); addField("FogColor", TypeColorI, Offset(mFogColor, VolumetricFog), "Fog color RGBA (Alpha is ignored)"); @@ -1374,4 +1372,4 @@ DefineEngineMethod(VolumetricFog, isInsideFog, bool, (), , "@brief returns true if control object is inside the fog\n\n.") { return object->isInsideFog(); -} \ No newline at end of file +} diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/folder.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/folder.cs index 124384545..209c56b0c 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/folder.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/folder.cs @@ -135,4 +135,22 @@ function AssetBrowser::moveFolder(%this, %folderPath, %newFolderPath) %this.deleteFolder(%fullPath); //thrash the modules and reload them + %oldModule = %this.dirHandler.getModuleFromAddress(%folderPath); + %newModule = %this.dirHandler.getModuleFromAddress(%newFolderPath); + + //if we didn't move modules, then we don't need to do anything other than refresh the assets within it + if(%oldModule == %newModule) + { + //only do a refresh to update asset loose file paths + AssetDatabase.refreshAllAssets(); + } + else + { + //they're different moduels now, so we gotta unload/reload both + ModuleDatabase.unloadExplicit(%oldModule.getModuleId()); + ModuleDatabase.loadExplicit(%oldModule.getModuleId()); + + ModuleDatabase.unloadExplicit(%newModule.getModuleId()); + ModuleDatabase.loadExplicit(%newModule.getModuleId()); + } } \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.cs index e6d8a6fb1..2bea81bc6 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.cs @@ -46,7 +46,7 @@ function directoryHandler::loadFolders(%this, %path, %parentId) { %folderID = %this.treeCtrl.insertItem(%parentId, %folderName, %path, "", %iconIdx, %iconIdx+1); - %this.loadFolders(%path @ "/" @ %folderName, %folderID); + %this.loadFolders(%path @ "/" @ %folderName, %folderID); } } else diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs index 1203696d1..2061e2cc0 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs @@ -241,3 +241,55 @@ function AssetBrowser::confirmDeleteAsset(%this) %this.refresh(); } + +//------------------------------------------------------------ +function AssetBrowser::updateAssetReference(%this, %targetPath, %oldAssetId, %newAssetId) +{ + //assetbrowser.updateAssetReference("data/pbr/levels", "pbr:material_ball", "TreeTest:TestTree"); + //this will go through every file in the game directory and swap the assetIDs to update the reference in the event something was renamed, or something was moved + //This is potentially disastrous and break a lot of things if done hapazardly, so be careful + %fullPath = makeFullPath(%targetPath); + + //First, wipe out any files inside the folder first + %file = findFirstFileMultiExpr( %fullPath @ "/*.*", true); + %fileObj = new FileObject(); + + new ArrayObject(lineCache); + + while( %file !$= "" ) + { + lineCache.empty(); + + %fileModified = false; + if(%fileObj.openForRead(%file)) + { + while( !%fileObj.isEOF() ) + { + %unModLine = %fileObj.readLine(); + %line = strreplace( %unModLine, %oldAssetId, %newAssetId ); + + if(%unModLine !$= %line) + %fileModified = true; + + lineCache.add(%line); + } + } + + if(%fileModified && %fileObj.openForWrite(%file)) + { + for(%i=0; %i