Quellcode durchsuchen

Fixed logic for parsing registerDatablock paths to trim script extensions during import conversion
Fixed creation of materialAsset from AB to properly generate companion script file
Fixed logic in project import that if we import in a legacy module script, we get rid of the newly generated one in favor of the old one

Areloch vor 4 Jahren
Ursprung
Commit
2f5f585aaf

+ 35 - 7
Engine/source/T3D/assets/assetImporter.cpp

@@ -3127,20 +3127,48 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
          return "";
       }
 
-      if (!isInPlace && Platform::isFile(qualifiedFromCSFile))
+      if (!isInPlace)
       {
-         if(!dPathCopy(qualifiedFromCSFile, qualifiedToCSFile, !isReimport))
+         if (Platform::isFile(qualifiedFromCSFile))
          {
-            dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", qualifiedFromCSFile);
-            activityLog.push_back(importLogBuffer);
+            if (!dPathCopy(qualifiedFromCSFile, qualifiedToCSFile, !isReimport))
+            {
+               dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", qualifiedFromCSFile);
+               activityLog.push_back(importLogBuffer);
+            }
+            else
+            {
+               //We successfully copied the original constructor file, so no extra work required
+               makeNewConstructor = false;
+               dSprintf(importLogBuffer, sizeof(importLogBuffer), "Successfully copied original TSShape Constructor file %s", qualifiedFromCSFile);
+               activityLog.push_back(importLogBuffer);
+            }
          }
-         else
+      }
+      else
+      {
+         //We're doing an in-place import, so double check we've already got a constructor file in the expected spot
+         if (Platform::isFile(qualifiedFromCSFile))
          {
-            //We successfully copied the original constructor file, so no extra work required
+            //Yup, found it, we're good to go
             makeNewConstructor = false;
-            dSprintf(importLogBuffer, sizeof(importLogBuffer), "Successfully copied original TSShape Constructor file %s", qualifiedFromCSFile);
+            dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", qualifiedFromCSFile);
             activityLog.push_back(importLogBuffer);
          }
+         else
+         {
+            //Didn't work, but it's possible it's using the old .cs extension when our extension variable is set to something else, so check that one as well just to be sure
+            Torque::Path constrFilePath = qualifiedFromCSFile;
+            constrFilePath.setExtension("cs");
+
+            if (Platform::isFile(constrFilePath.getFullPath().c_str()))
+            {
+               //Yup, found it, we're good to go
+               makeNewConstructor = false;
+               dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", constrFilePath.getFullPath().c_str());
+               activityLog.push_back(importLogBuffer);
+            }
+         }
       }
    }
 

+ 6 - 15
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.tscript

@@ -8,18 +8,21 @@ function AssetBrowser::createMaterialAsset(%this)
    %assetPath = AssetBrowser.dirHandler.currentAddress @ "/";   
    
    %tamlpath = %assetPath @ %assetName @ ".asset.taml";
-   %sgfPath = %assetPath @ %assetName @ ".sgf";
+   %scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
    
    %asset = new MaterialAsset()
    {
       AssetName = %assetName;
       versionId = 1;
-      shaderData = "";
-      shaderGraph = %sgfPath;
+      materialDefinitionName = %assetName;
+      scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
    };
    
    TamlWrite(%asset, %tamlpath);
    
+   %mat = new Material(%assetName);
+   %mat.save(%scriptPath);
+   
    %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
 	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
 
@@ -43,18 +46,6 @@ function AssetBrowser::editMaterialAsset(%this, %assetDef)
    MaterialEditorGui.setActiveMaterial( %assetDef.materialDefinitionName );
    
    AssetBrowser.hideDialog();
-   
-   //
-   //
-   /*%assetDef.materialDefinitionName.reload();
-   $Tools::materialEditorList = "";
-   EWorldEditor.clearSelection();
-   MaterialEditorGui.currentObject = 0;
-   MaterialEditorGui.currentMode = "asset";
-   MaterialEditorGui.currentMaterial = %assetDef.materialDefinitionName;
-   MaterialEditorGui.setActiveMaterial( %assetDef.materialDefinitionName);
-   EditorGui.setEditor(MaterialEditorPlugin);
-   AssetBrowser.hideDialog();*/
 }
 
 //Renames the asset

+ 1 - 1
Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.tscript

@@ -340,7 +340,7 @@ function MaterialEditorGui::prepareActiveObject( %this, %override )
       {
          %fieldName = %obj.getField(%i);
          
-         if( %obj.getFieldType(%fieldName) !$= "TypeMaterialAssetId" && %obj.getFieldType(%fieldName) !$= "TypeMaterialName")
+         if( %obj.getFieldType(%fieldName) !$= "TypeMaterialAssetId" /*&& %obj.getFieldType(%fieldName) !$= "TypeMaterialName"*/)
             continue;
       
          if( !%canSupportMaterial )

+ 1 - 1
Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript

@@ -505,7 +505,7 @@ function T3Dpre4ProjectImporter::beginCodeFilesImport(%this)
                   }
                }
             }
-            else if(strIsMatchExpr("*datablock*(*)*", %line))
+            else if(strIsMatchExpr("*datablock*(*)*", %line) && (strPos(%line, "registerDatablock") == -1))
             {
                %className = findObjectClass(%line, "datablock");
                

+ 17 - 0
Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript

@@ -263,6 +263,23 @@ function ProjectImportWizardPage4::openPage(%this)
       $ProjectImporter::importTool.copyFiles();
    else
       ProjectImportWindow.nextStep();
+      
+   //if we gen'd a new module setup, double check we didn't copy over a module script file under a legacy extension
+   if(!$ProjectImporter::useExistingModule)
+   {
+      %newModuleName = $ProjectImporter::moduleName;
+      %moduleFilePath = "data/" @ %newModuleName;
+      
+      if($TorqueScriptFileExtension !$= "cs")
+      {
+         %moduleScriptFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".cs";
+         if(isFile(%moduleScriptFilePath))
+         {
+            //yep, that exists, so we'll assume it was the file we wanted, so remove the generated one
+            fileDelete(%moduleFilePath @ "/" @ %newModuleName @ "." @ $TorqueScriptFileExtension);
+         }
+      }
+   }
 }
 
 function ProjectImportWizardPage4::processPage(%this)