From abf5a09bc3cbd2239b0c4b9c28b3273f4f954c63 Mon Sep 17 00:00:00 2001 From: Areloch Date: Wed, 28 Jul 2021 09:26:13 -0500 Subject: [PATCH] Removed duplicate checkbox image Added asset import conflict resolution option to prepend folder name Cleanups of Project Importer and fixed importing of material and terrain materials, specifically, fallbacks in the event they are unnamed to utilize the mapTo and internalName fields, respectively Fixed typos in guiTerrainMaterialDlg Added AssetBrowser button to GuiEditor Improved FileObject's PeekLine function to be able to peek forward further via an optional lineOffset argument --- Engine/source/T3D/assets/assetImporter.cpp | 23 +- Engine/source/core/fileObject.cpp | 31 ++- Engine/source/core/fileObject.h | 2 +- .../source/gui/controls/guiTextEditCtrl.cpp | 2 + .../game/tools/assetBrowser/art/checkbox.png | Bin 3943 -> 0 bytes .../images}/checkbox_image.asset.taml | 0 .../game/tools/gui/profiles.ed.tscript | 2 +- .../game/tools/guiEditor/gui/guiEditor.ed.gui | 27 ++- .../pre40/T3Dpre4ProjectImporter.tscript | 228 ++++++------------ .../scripts/projectImporter.tscript | 155 ++++++++++-- .../gui/guiTerrainMaterialDlg.ed.gui | 2 +- .../interfaces/terrainMaterialDlg.ed.tscript | 20 +- 12 files changed, 298 insertions(+), 194 deletions(-) delete mode 100644 Templates/BaseGame/game/tools/assetBrowser/art/checkbox.png rename Templates/BaseGame/game/tools/{assetBrowser/art => gui/images}/checkbox_image.asset.taml (100%) diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index 88b0d1976..b0405785c 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -132,7 +132,7 @@ void AssetImportConfig::initPersistFields() Parent::initPersistFields(); addGroup("General"); - addField("DuplicatAutoResolution", TypeRealString, Offset(DuplicatAutoResolution, AssetImportConfig), "Duplicate Asset Auto-Resolution Action. Options are None, AutoPrune, AutoRename"); + addField("DuplicatAutoResolution", TypeRealString, Offset(DuplicatAutoResolution, AssetImportConfig), "Duplicate Asset Auto-Resolution Action. Options are None, AutoPrune, AutoRename, FolderPrefix"); addField("WarningsAsErrors", TypeBool, Offset(WarningsAsErrors, AssetImportConfig), "Indicates if warnings should be treated as errors"); addField("PreventImportWithErrors", TypeBool, Offset(PreventImportWithErrors, AssetImportConfig), "Indicates if importing should be prevented from completing if any errors are detected at all"); addField("AutomaticallyPromptMissingFiles", TypeBool, Offset(AutomaticallyPromptMissingFiles, AssetImportConfig), "Should the importer automatically prompt to find missing files if they are not detected automatically by the importer"); @@ -2379,6 +2379,27 @@ void AssetImporter::resolveAssetItemIssues(AssetImportObject* assetItem) { } + else if (activeImportConfig->DuplicatAutoResolution == String("FolderPrefix")) + { + //Set trailing number + String renamedAssetName = assetItem->assetName; + String owningFolder = assetItem->filePath.getDirectory(assetItem->filePath.getDirectoryCount() - 1); + + renamedAssetName = owningFolder + "_" + renamedAssetName; + + //Log it's renaming + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Asset %s was renamed due to %s as part of the Import Configuration", assetItem->assetName.c_str(), humanReadableReason.c_str()); + activityLog.push_back(importLogBuffer); + + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Asset %s was renamed to %s", assetItem->assetName.c_str(), renamedAssetName.c_str()); + activityLog.push_back(importLogBuffer); + + assetItem->assetName = renamedAssetName; + + //Whatever status we had prior is no longer relevent, so reset the status + resetAssetValidationStatus(assetItem); + importIssues = false; + } } else if (assetItem->statusType == String("MissingFile")) { diff --git a/Engine/source/core/fileObject.cpp b/Engine/source/core/fileObject.cpp index dc6ff5cf4..1305074c9 100644 --- a/Engine/source/core/fileObject.cpp +++ b/Engine/source/core/fileObject.cpp @@ -177,7 +177,7 @@ const U8 *FileObject::readLine() return mFileBuffer + tokPos; } -void FileObject::peekLine( U8* line, S32 length ) +void FileObject::peekLine( S32 peekLineOffset, U8* line, S32 length ) { if(!mFileBuffer) { @@ -189,6 +189,31 @@ void FileObject::peekLine( U8* line, S32 length ) // we can't modify the file buffer. S32 i = 0; U32 tokPos = mCurPos; + S32 lineOffset = 0; + + //Lets push our tokPos up until we've offset the requested number of lines + while (lineOffset < peekLineOffset && tokPos <= mBufferSize) + { + if (mFileBuffer[tokPos] == '\r') + { + tokPos++; + if (mFileBuffer[tokPos] == '\n') + tokPos++; + lineOffset++; + continue; + } + + if (mFileBuffer[tokPos] == '\n') + { + tokPos++; + lineOffset++; + continue; + } + + tokPos++; + } + + //now peek that line, then return the results while( ( tokPos != mBufferSize ) && ( mFileBuffer[tokPos] != '\r' ) && ( mFileBuffer[tokPos] != '\n' ) && ( i < ( length - 1 ) ) ) line[i++] = mFileBuffer[tokPos++]; @@ -317,7 +342,7 @@ DefineEngineMethod( FileObject, readLine, const char*, (),, return (const char *) object->readLine(); } -DefineEngineMethod( FileObject, peekLine, const char*, (),, +DefineEngineMethod( FileObject, peekLine, const char*, (S32 peekOffset), (0), "@brief Read a line from the file without moving the stream position.\n\n" "Emphasis on *line*, as in you cannot parse individual characters or chunks of data. " @@ -345,7 +370,7 @@ DefineEngineMethod( FileObject, peekLine, const char*, (),, { static const U32 bufSize = 512; char *line = Con::getReturnBuffer( bufSize ); - object->peekLine( (U8*)line, bufSize ); + object->peekLine(peekOffset, (U8*)line, bufSize ); return line; } diff --git a/Engine/source/core/fileObject.h b/Engine/source/core/fileObject.h index ca2952a4f..64559e7db 100644 --- a/Engine/source/core/fileObject.h +++ b/Engine/source/core/fileObject.h @@ -46,7 +46,7 @@ public: bool readMemory(const char *fileName); const U8 *buffer() { return mFileBuffer; } const U8 *readLine(); - void peekLine(U8 *line, S32 length); + void peekLine(S32 peekLineOffset, U8 *line, S32 length); bool isEOF(); void writeLine(const U8 *line); void close(); diff --git a/Engine/source/gui/controls/guiTextEditCtrl.cpp b/Engine/source/gui/controls/guiTextEditCtrl.cpp index 65fd32017..da42f8f27 100644 --- a/Engine/source/gui/controls/guiTextEditCtrl.cpp +++ b/Engine/source/gui/controls/guiTextEditCtrl.cpp @@ -151,6 +151,8 @@ GuiTextEditCtrl::GuiTextEditCtrl() mPasswordMask = StringTable->insert( "*" ); #endif Sim::findObject( "InputDeniedSound", mDeniedSound ); + + mValidateCommand = ""; } GuiTextEditCtrl::~GuiTextEditCtrl() diff --git a/Templates/BaseGame/game/tools/assetBrowser/art/checkbox.png b/Templates/BaseGame/game/tools/assetBrowser/art/checkbox.png deleted file mode 100644 index 46e0ac959fc26d224015f316df050c2f137af4d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3943 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 S3QYOT0XMIk>c74QkN6*F=2BAt diff --git a/Templates/BaseGame/game/tools/assetBrowser/art/checkbox_image.asset.taml b/Templates/BaseGame/game/tools/gui/images/checkbox_image.asset.taml similarity index 100% rename from Templates/BaseGame/game/tools/assetBrowser/art/checkbox_image.asset.taml rename to Templates/BaseGame/game/tools/gui/images/checkbox_image.asset.taml diff --git a/Templates/BaseGame/game/tools/gui/profiles.ed.tscript b/Templates/BaseGame/game/tools/gui/profiles.ed.tscript index 0849a52d5..75223fcf8 100644 --- a/Templates/BaseGame/game/tools/gui/profiles.ed.tscript +++ b/Templates/BaseGame/game/tools/gui/profiles.ed.tscript @@ -424,7 +424,7 @@ new GuiControlProfile( ToolsGuiCheckBoxProfile ) fontColorNA = EditorSettings.value("Theme/fieldTextSELColor"); fixedExtent = true; justify = "left"; - bitmapAsset = "./images/checkbox"; + bitmapAsset = "ToolsModule:checkbox_image"; hasBitmapArray = true; category = "Tools"; }; diff --git a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui index 20a35123d..24f005009 100644 --- a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui +++ b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui @@ -135,6 +135,29 @@ hovertime = "1000"; canSaveDynamicFields = "0"; }; + new GuiBitmapButtonCtrl() { + canSaveDynamicFields = "0"; + internalName = AssetBrowserBtn; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiButtonProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "98 3"; + Extent = "29 27"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "AssetBrowser.ShowDialog();"; + tooltipprofile = "ToolsGuiToolTipProfile"; + ToolTip = "Asset Browser"; + hovertime = "750"; + bitmap = "tools/gui/images/stencilIcons/menuGrid"; + bitmapMode = "Stretched"; + buttonType = "PushButton"; + groupNum = "0"; + useMouseEvents = "0"; + }; new GuiBitmapCtrl() { bitmapAsset = "ToolsModule:separator_h_image"; wrap = "0"; @@ -142,7 +165,7 @@ profile = "ToolsGuiDefaultProfile"; horizSizing = "right"; vertSizing = "bottom"; - position = "98 3"; + position = "130 3"; extent = "2 26"; minExtent = "1 1"; canSave = "1"; @@ -157,7 +180,7 @@ profile = "ToolsGuiDefaultProfile"; horizSizing = "width"; vertSizing = "bottom"; - position = "99 0"; + position = "131 0"; extent = "723 32"; minExtent = "8 2"; canSave = "1"; diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript index ad44a398d..3f8e8a831 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript @@ -185,7 +185,6 @@ function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this) //First, wipe out any files inside the folder first %file = findFirstFileMultiExpr( $ProjectImporter::modulePath @ "/*/materials.*", true); - %fileObj = new FileObject(); %objectClassStack = new ArrayObject(); %fileOutputLines = new ArrayObject(); @@ -206,27 +205,25 @@ function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this) %currentPage-->processingText.setText("Processing material script file: " @ %file); Canvas.repaint(); - if ( %fileObj.openForRead( %file ) ) + if(%file $= "data/FPSGameplay/art/terrains/materials.tscript") + { + %agafdgadfgsdfg = true; + } + + if ( $ProjectImporter::fileObject.openForRead( %file ) ) { echo("Legacy Project Importer - Beginning process of file: " @ %file); %lineNum = 0; - while ( !%fileObj.isEOF() ) + while ( !$ProjectImporter::fileObject.isEOF() ) { - %line = %fileObj.readLine(); + %line = $ProjectImporter::fileObject.readLine(); %trimmedLine = trim(%line); if(strIsMatchExpr("*new*(*)*", %line)) { - //we have a new object, add it to the stack - //substr to peel the class name - %start = strpos(%line, "new "); - %end = strpos(%line, "(", %start); + %className = findObjectClass(%line, "new"); - if(%start != -1 && %end != -1) - { - %className = getSubStr(%line, %start + 4, %end-%start-4); - - if(%className !$= "Material" && %className !$= "CustomMaterial") + if(%className !$= "Material" && %className !$= "CustomMaterial" && %className !$= "TerrainMaterial") { %lineNum++; %fileOutputLines.push_back(%line); @@ -234,28 +231,30 @@ function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this) } %objectClassStack.push_back(%className); - } - %nameEnd = strpos(%line, ")", %end); + %objectName = findObjectName(%line, "new"); - %objectName = getSubStr(%line, %end+1, %nameEnd-%end-1); - - if(%objectName !$= "") + if(%objectName $= "" && %className $= "TerrainMaterial") + { + %intName = findObjectField("internalName"); + %objectName = %intName @ "_terrainMat"; + %line = strReplace(%line, "()", "(" @ %intName @ ")"); + + %fileWasChanged = true; + } + else if(%objectName $= "" && %className $= "Material") { - if(strpos(%objectName, ":") != -1) - { - %objectName = getSubStr(%objectName, 0, strpos(%objectName, ":")); - } + %mapToName = findObjectField("mapTo"); + %objectName = %mapToName @ "_mat"; + %line = strReplace(%line, "()", "(" @ %mapToName @ ")"); - if(strpos(%objectName, ",") != -1) - { - %objectName = getSubStr(%objectName, 0, strpos(%objectName, ",")); - } - - %objectName = trim(%objectName); + %fileWasChanged = true; + } if(%objectClassStack.count() == 1) { + %currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1); + //we only process top-level objects directly %inheritanceList = getClassHierarchy(%currentObjClass); for (%classDepth =0; %classDepthprocessingText.setText("Processing file: " @ %file); Canvas.repaint(); - if ( %fileObj.openForRead( %file ) ) + if ( $ProjectImporter::fileObject.openForRead( %file ) ) { echo("Legacy Project Importer - Beginning process of file: " @ %file); %lineNum = 0; - while ( !%fileObj.isEOF() ) + while ( !$ProjectImporter::fileObject.isEOF() ) { - %line = %fileObj.readLine(); + %line = $ProjectImporter::fileObject.readLine(); %trimmedLine = trim(%line); if(strIsMatchExpr("*new*(*)*", %line)) { - //we have a new object, add it to the stack - //substr to peel the class name - %start = strpos(%line, "new "); - %end = strpos(%line, "(", %start); - - if(%start != -1 && %end != -1) - { - %className = getSubStr(%line, %start + 4, %end-%start-4); - - %objectClassStack.push_back(%className); - } - - %nameEnd = strpos(%line, ")", %end); - - %objectName = getSubStr(%line, %end+1, %nameEnd-%end-1); + %className = findObjectClass(%line, "new"); + %objectName = findObjectName(%line, "new"); if(%objectName !$= "") { - if(strpos(%objectName, ":") != -1) - { - %objectName = getSubStr(%objectName, 0, strpos(%objectName, ":")); - } - - if(strpos(%objectName, ",") != -1) - { - %objectName = getSubStr(%objectName, 0, strpos(%objectName, ",")); - } - - %objectName = trim(%objectName); - if(%objectClassStack.count() == 1) { + %currentObjClass = %objectClassStack.getKey(%objectClassStack.count()-1); + //we only process top-level objects directly %inheritanceList = getClassHierarchy(%currentObjClass); for (%classDepth =0; %classDepthstepsList.clear(); %this-->stepsList.addRow(0, "Welcome"); @@ -465,11 +468,14 @@ function processLegacyField(%line, %originalFieldName, %newFieldName) if(%assetId !$= "" && AssetDatabase.isDeclaredAsset(%assetId)) { + //if (%assetId.getStatusString() $= "Ok") %outLine = strReplace(%outLine, %value, %assetId); + //else + // error("Asset assignment failure:", %assetId, getStatusString()); } } - if((%outLine !$= %line)&&(%assetId.getStatusString() !$= "BadFileReference")&&(%assetId.getStatusString() !$= "Failed")) + if(%outLine !$= %line) { echo("Legacy Project Importer - processing of legacy line: " @ %line @ " has been updated to: " @ %outLine); return %outLine; @@ -480,6 +486,98 @@ function processLegacyField(%line, %originalFieldName, %newFieldName) } } +function findObjectClass(%line, %createWord) +{ + //we have a new object, add it to the stack + //substr to peel the class name + %start = strpos(%line, %createWord @ " "); + %end = strpos(%line, "(", %start); + %createLen = strlen(%createWord @ " "); + + if(%start != -1 && %end != -1) + { + %className = getSubStr(%line, %start + %createLen, %end-%start-%createLen); + + %className = trim(%className); + + return %className; + } + + return ""; +} + +function findObjectName(%line, %createWord) +{ + //we have a new object, add it to the stack + //substr to peel the class name + %start = strpos(%line, %createWord @ " "); + %end = strpos(%line, "(", %start); + + %nameEnd = strpos(%line, ")", %end); + + %objectName = getSubStr(%line, %end+1, %nameEnd-%end-1); + + if(%objectName !$= "") + { + if(strpos(%objectName, ":") != -1) + { + %objectName = getSubStr(%objectName, 0, strpos(%objectName, ":")); + } + + if(strpos(%objectName, ",") != -1) + { + %objectName = getSubStr(%objectName, 0, strpos(%objectName, ",")); + } + + %objectName = trim(%objectName); + } + + return %objectName; +} + +function findObjectField(%fieldName) +{ + %value = ""; + %peekLineOffset = 0; + %peekLine = $ProjectImporter::fileObject.peekLine(%peekLineOffset); + while(!strIsMatchExpr("*};*", %peekLine) && + !strIsMatchExpr("*singleton*(*)*", %peekLine) && + !strIsMatchExpr("*new*(*)*", %peekLine) && + !strIsMatchExpr("*datablock*(*)*", %peekLine)&& + !strIsMatchExpr("\n", %peekLine) && + !strIsMatchExpr("\r", %peekLine)) + { + if(strpos(%peekLine, %fieldName) != -1) + { + %value = ""; + %pos = strpos(%peekLine, "= \""); + if(%pos != -1) + { + %endPos = strpos(%peekLine, "\";", %pos); + + %value = getSubStr(%peekLine, %pos+3, %endPos-%pos-3); + break; + } + else + { + %pos = strpos(%peekLine, "=\""); + if(%pos != -1) + { + %endPos = strpos(%peekLine, "\";", %pos); + + %value = getSubStr(%peekLine, %pos+2, %endPos-%pos-2); + break; + } + } + } + + %peekLineOffset++; + %peekLine = $ProjectImporter::fileObject.peekLine(%peekLineOffset); + } + + return %value; +} + //============================================================================== //Shape Importing //============================================================================== @@ -516,6 +614,7 @@ function beginShapeImport() if(isShapeFormat(%fileExt)) { + $ProjectImporter::assetQuery.clear(); %assetsFound = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %file); if(%assetsFound == 0) { @@ -566,6 +665,7 @@ function beginImageImport() if(isImageFormat(%fileExt)) { + $ProjectImporter::assetQuery.clear(); %assetsFound = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %file); if(%assetsFound == 0) { @@ -614,6 +714,7 @@ function beginTerrainImport() %filePath = filePath(%file); if(%fileExt $= ".ter") { + $ProjectImporter::assetQuery.clear(); %assetsFound = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %file); if(%assetsFound == 0) { @@ -685,18 +786,18 @@ function beginGUIImport() %filePath = filePath(%file); if(%fileExt $= ".gui") { + $ProjectImporter::assetQuery.clear(); %assetsFound = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %file); if(%assetsFound == 0) { ProjectImportWizardPage5-->processingText.setText("Processing GUI Asset file: " @ %file); Canvas.repaint(); - %fileObj = new FileObject(); - if ( %fileObj.openForRead( %file ) ) + if ( $ProjectImporter::fileObject.openForRead( %file ) ) { - while ( !%fileObj.isEOF() ) + while ( !$ProjectImporter::fileObject.isEOF() ) { - %line = %fileObj.readLine(); + %line = $ProjectImporter::fileObject.readLine(); if(strIsMatchExpr("*new*(*)*", %line)) { @@ -726,8 +827,7 @@ function beginGUIImport() } } - %fileObj.close(); - %fileObj.delete(); + $ProjectImporter::fileObject.close(); } } @@ -835,6 +935,9 @@ function beginLevelImport() if(%fileExt $= ".mis") { + %newAsset = false; + + $ProjectImporter::assetQuery.clear(); %assetsFound = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, %file); if(%assetsFound == 0) { @@ -866,6 +969,16 @@ function beginLevelImport() levelName = %assetName; }; + %newAsset = true; + } + else + { + %assetId = $ProjectImporter::assetQuery.getAsset(0); + %asset = AssetDatabase.acquireAsset(%assetId); + %tamlpath = AssetDatabase.getAssetFilePath(%assetId); + } + + //Time to process the associated files if(isFile(%filePath @ "/" @ %fileBase @ ".decal")) { %asset.decalsFile = %fileBase @ ".decal"; @@ -884,32 +997,38 @@ function beginLevelImport() } if(isFile(%filePath @ "/" @ %fileBase @ ".png")) - { %previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ ".png"); - %asset.addAssetDependencyField(previewImageAsset, %previewImageAsset); - } + else if(isFile(%filePath @ "/" @ %fileBase @ "_preview.png")) + %previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ "_preview.png"); else if(isFile(%filePath @ "/" @ %fileBase @ ".dds")) - { %previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ ".dds"); - %asset.addAssetDependencyField(previewImageAsset, %previewImageAsset); - } + else if(isFile(%filePath @ "/" @ %fileBase @ "_preview.dds")) + %previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ "_preview.dds"); else if(isFile(%filePath @ "/" @ %fileBase @ ".jpg")) - { %previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ ".jpg"); - %asset.addAssetDependencyField(previewImageAsset, %previewImageAsset); - } - + else if(isFile(%filePath @ "/" @ %fileBase @ "_preview.jpg")) + %previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ "_preview.jpg"); else if(isFile(%filePath @ "/" @ %fileBase @ ".jpeg")) - { %previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ ".jpeg"); + else if(isFile(%filePath @ "/" @ %fileBase @ "_preview.jpeg")) + %previewImageAsset = ImageAsset::getAssetIdByFilename(%filePath @ "/" @ %fileBase @ "_preview.jpeg"); + + if(%previewImageAsset !$= "") + { %asset.addAssetDependencyField(previewImageAsset, %previewImageAsset); } TamlWrite(%asset, %tamlpath); + if(%newAsset) + { %moduleDef = ModuleDatabase.findModule(%moduleName, 1); %success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath); } + else + { + %asset.refreshAsset(); + } } %file = findNextFileMultiExpr( %currentAddress @ "/*.*" ); diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui index 32bae596f..c954e8237 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui @@ -164,7 +164,7 @@ canSaveDynamicFields = "0"; new GuiBitmapCtrl() { - bitmap = "core/gui/images/separator-v"; + bitmap = "ToolsModule:separator_v_image"; color = "White"; wrap = "0"; position = "1 0"; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript index d9c91a89b..3670c6ada 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript @@ -409,10 +409,10 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat ) // %imgPath = %mat.getDiffuseMap(); - %this-->baseTexCtrl.setBitmap( %mat.diffuseMap ); + if(%imgPath $= "") %imgPath = $TerrainMaterialEditor::emptyMaterialImage; - %this-->texBaseMap.setBitmapAsset( %imgPath ); + %this-->texBaseMap.setBitmap( %imgPath ); if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage) { @@ -423,7 +423,7 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat ) } else { - %this-->normalMapAssetId.setText( "None" ); + %this-->diffuseMapAssetId.setText( "None" ); } // @@ -431,7 +431,7 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat ) if(%imgPath $= "") %imgPath = $TerrainMaterialEditor::emptyMaterialImage; - %this-->texNormalMap.setBitmapAsset( %imgPath ); + %this-->texNormalMap.setBitmap( %imgPath ); if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage) { @@ -450,7 +450,7 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat ) if(%imgPath $= "") %imgPath = $TerrainMaterialEditor::emptyMaterialImage; - %this-->texORMConfigMap.setBitmapAsset( %imgPath ); + %this-->texORMConfigMap.setBitmap( %imgPath ); if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage) { @@ -461,7 +461,7 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat ) } else { - %this-->normalMapAssetId.setText( "None" ); + %this-->ORMMapAssetId.setText( "None" ); } // @@ -469,7 +469,7 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat ) if(%imgPath $= "") %imgPath = $TerrainMaterialEditor::emptyMaterialImage; - %this-->texDetailMap.setBitmapAsset( %imgPath ); + %this-->texDetailMap.setBitmap( %imgPath ); if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage) { @@ -480,7 +480,7 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat ) } else { - %this-->normalMapAssetId.setText( "None" ); + %this-->detailMapAssetId.setText( "None" ); } // @@ -488,7 +488,7 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat ) if(%imgPath $= "") %imgPath = $TerrainMaterialEditor::emptyMaterialImage; - %this-->texMacroMap.setBitmapAsset( %imgPath ); + %this-->texMacroMap.setBitmap( %imgPath ); if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage) { @@ -499,7 +499,7 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat ) } else { - %this-->normalMapAssetId.setText( "None" ); + %this-->macroMapAssetId.setText( "None" ); } %this-->detSizeCtrl.setText( %mat.detailSize );