Browse Source

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

Areloch 5 years ago
parent
commit
a43233d9c9

+ 1 - 3
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"

+ 2 - 4
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();
-}
+}

+ 18 - 0
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());
+   }
 }

+ 1 - 1
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

+ 52 - 0
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<lineCache.count(); %i++)
+         {
+            %line = lineCache.getKey(%i);
+
+            %fileObj.writeline(%line);
+         }
+         
+         %fileObj.close();
+      }
+      
+      %file = findNextFileMultiExpr( %fullPath @ "/*.*" );
+   }
+   
+   lineCache.delete();
+   %fileObj.delete();
+}

+ 50 - 1
Templates/BaseGame/game/tools/assetBrowser/scripts/editModule.cs

@@ -134,11 +134,60 @@ function AssetBrowser::deleteModule(%this)
    
 }
 
-function AssetBrowser::RefreshModuleDependencies(%this)
+function AssetBrowser::RefreshModuleDependencies(%this, %moduleDef)
 {
    //Iterate through all our modules
    
    //then, iterate through the module's assets
    
    //if an asset has a module that isn't us, queue that into the dependencies list  
+   
+   //AssetBrowser.RefreshModuleDependencies(16823);
+   %modulePath = filePath(%moduleDef.ModuleFilePath);
+   
+   %filePattern = "*.cs" TAB "*.taml" TAB "*.mis";
+   
+   //First, wipe out any files inside the folder first
+   %file = makeFullPath(findFirstFileMultiExpr( %filePattern, true));
+   %fileObj = new FileObject();
+   
+   %modulesList = ModuleDatabase.findModules(false);
+   
+   new ArrayObject(moduleDepList);
+
+   while( %file !$= "" )
+   {      
+      if(startsWith(%file, %modulePath))
+      {
+         if(%fileObj.openForRead(%file))
+         {
+            while( !%fileObj.isEOF() )
+            {
+               %line = %fileObj.readLine();
+               
+               if(%line $= "")
+                  continue;
+               
+               for(%i=0; %i < getWordCount(%modulesList); %i++)
+               {
+                  %moduleName = getWord(%modulesList, %i).moduleID;
+                  
+                  //if(%moduleName $= %moduleDef.moduleID)
+                  //   continue;
+                     
+                  %hasMatch = strIsMatchExpr( "*"@%moduleName@":*", %line );
+                  
+                  if(%hasMatch)
+                  {
+                     moduleDepList.add(%moduleName);
+                  }
+               }
+            }
+         }
+      }
+      
+      %file = makeFullPath(findNextFileMultiExpr( %filePattern ));
+   }
+   
+   %fileObj.delete();
 }

+ 6 - 0
Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.cs

@@ -181,7 +181,13 @@ function SettingsInspector::changeEditorSetting(%this, %varName, %value)
       ProjectSettings.setValue(%varName, %value);
    
    if(ESettingsWindow.mode $= "Editor")
+   {
       %success = EditorSettings.write();
+      
+      //Bit of a hack, but if we were editing the theme, reexec the profiles for GUI
+      if(ESettingsWindow.selectedPageText $= "Theme")
+         exec("tools/gui/profiles.ed.cs");
+   }
    else
       %success = ProjectSettings.write();
       

+ 0 - 7
Tools/CMake/torque3d.cmake

@@ -135,13 +135,6 @@ mark_as_advanced(TORQUE_HIFI)
 option(TORQUE_EXTENDED_MOVE "Extended move support" OFF)
 mark_as_advanced(TORQUE_EXTENDED_MOVE)
 
-option(TORQUE_ALLOW_DIRECT_FILENAMES "Allows gameclasses to use direct filenames instead of assets" OFF)
-mark_as_advanced(TORQUE_ALLOW_DIRECT_FILENAMES)
-
-if(TORQUE_ALLOW_DIRECT_FILENAMES)
-    addDef(TORQUE_ALLOW_DIRECT_FILENAMES)
-endif()
-
 set(TORQUE_SDL ON) # we need sdl to do our platform interop
 
 if(WIN32)