From ab9fc302fc4f303d48146e67aa3cca830fd12441 Mon Sep 17 00:00:00 2001 From: Areloch Date: Mon, 12 Aug 2019 01:04:17 -0500 Subject: [PATCH] Added D3D error code interpreter Added sanity check for findMatch Finished most of asset importer logic to utilize settings system Cleaned up code for finding associated files Added General importer settings category and integrated logic for those settings fields Updated logic in variableGroup to support callbacks in custom fields Updated logic in variableInspector to better handle callbacks, as well as being able to manually update when manipulating fields Updated scripts to utilize project settings values for playGUI and mainMenuGUI names Improved module-oriented loading of materials Added util function for populating custom fonts --- Engine/source/core/strings/findMatch.cpp | 3 + Engine/source/gfx/D3D11/gfxD3D11Device.cpp | 73 +++ Engine/source/gfx/D3D11/gfxD3D11Device.h | 1 + .../source/gfx/D3D11/gfxD3D11StateBlock.cpp | 2 +- Engine/source/gfx/gfxDevice.h | 2 +- Engine/source/gfx/gl/gfxGLDevice.h | 2 +- .../gui/editor/inspector/variableGroup.cpp | 2 +- .../editor/inspector/variableInspector.cpp | 23 +- .../gui/editor/inspector/variableInspector.h | 6 +- .../clientServer/scripts/server/server.cs | 5 + .../core/utility/scripts/helperFunctions.cs | 34 +- .../game/core/utility/scripts/module.cs | 39 ++ .../tools/assetBrowser/assetImportConfigs.xml | 78 +-- .../tools/assetBrowser/guis/assetImport.gui | 5 +- .../tools/assetBrowser/scripts/assetImport.cs | 474 +++++++++++------- .../assetBrowser/scripts/assetImportConfig.cs | 250 ++------- .../scripts/assetTypes/material.cs | 183 +++---- .../assetBrowser/scripts/assetTypes/shape.cs | 19 +- .../tools/assetBrowser/scripts/fieldTypes.cs | 17 +- 19 files changed, 620 insertions(+), 598 deletions(-) diff --git a/Engine/source/core/strings/findMatch.cpp b/Engine/source/core/strings/findMatch.cpp index 97829a5ca..25a3c1e14 100644 --- a/Engine/source/core/strings/findMatch.cpp +++ b/Engine/source/core/strings/findMatch.cpp @@ -100,6 +100,9 @@ inline bool IsCharMatch( char e, char s, bool caseSensitive ) bool FindMatch::isMatch( const char *exp, const char *str, bool caseSensitive ) { + if (str == NULL || exp == NULL) + return false; + while ( *str && ( *exp != '*' ) ) { if ( !IsCharMatch( *exp++, *str++, caseSensitive ) ) diff --git a/Engine/source/gfx/D3D11/gfxD3D11Device.cpp b/Engine/source/gfx/D3D11/gfxD3D11Device.cpp index c0b3ee338..01bb795d7 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Device.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11Device.cpp @@ -1764,3 +1764,76 @@ void GFXD3D11Device::setDebugMarker(ColorI color, const char *name) D3DPERF_SetMarker(D3DCOLOR_ARGB(color.alpha, color.red, color.green, color.blue), (LPCWSTR)&eventName); } + +const char* GFXD3D11Device::interpretDebugResult(long result) +{ + const char* error; + + switch (result) { + case S_OK: + error = "S_OK"; + break; + case S_FALSE: + error = "S_FALSE"; + break; + //generics + case E_UNEXPECTED: + error = "E_UNEXPECTED"; + break; + case E_NOTIMPL: + error = "E_NOTIMPL"; + break; + case E_OUTOFMEMORY: + error = "E_OUTOFMEMORY"; + break; + case E_INVALIDARG: + error = "E_INVALIDARG"; + break; + case E_NOINTERFACE: + error = "E_NOINTERFACE"; + break; + case E_POINTER: + error = "E_POINTER"; + break; + case E_HANDLE: + error = "E_HANDLE"; + break; + case E_ABORT: + error = "E_ABORT"; + break; + case E_FAIL: + error = "E_FAIL"; + break; + case E_ACCESSDENIED: + error = "E_ACCESSDENIED"; + break; + + //graphics specific + case DXGI_ERROR_INVALID_CALL: + error = "DXGI_ERROR_INVALID_CALL"; + break; + case DXGI_ERROR_WAS_STILL_DRAWING: + error = "DXGI_ERROR_WAS_STILL_DRAWING"; + break; + + //dx11 specific + case D3D11_ERROR_FILE_NOT_FOUND: + error = "D3D11_ERROR_FILE_NOT_FOUND"; + break; + case D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS: + error = "D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS"; + break; + case D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS: + error = "D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS"; + break; + case D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD: + error = "D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD"; + break; + + + default: + error = "UNKNOWN"; + break; + } + return error; +} diff --git a/Engine/source/gfx/D3D11/gfxD3D11Device.h b/Engine/source/gfx/D3D11/gfxD3D11Device.h index 3ecc76ca9..2225793ec 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Device.h +++ b/Engine/source/gfx/D3D11/gfxD3D11Device.h @@ -325,6 +325,7 @@ public: // grab the sampler map const SamplerMap &getSamplersMap() const { return mSamplersMap; } SamplerMap &getSamplersMap(){ return mSamplersMap; } + const char* interpretDebugResult(long result); }; #endif diff --git a/Engine/source/gfx/D3D11/gfxD3D11StateBlock.cpp b/Engine/source/gfx/D3D11/gfxD3D11StateBlock.cpp index 810cd17d5..b5cc29725 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11StateBlock.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11StateBlock.cpp @@ -77,7 +77,7 @@ GFXD3D11StateBlock::GFXD3D11StateBlock(const GFXStateBlockDesc& desc) if (FAILED(hr)) { - AssertFatal(false, "GFXD3D11StateBlock::GFXD3D11StateBlock - CreateBlendState call failure."); + AssertFatal(false, avar("GFXD3D11StateBlock::GFXD3D11StateBlock - CreateBlendState call failure: %s.", GFX->interpretDebugResult(hr))); } ZeroMemory(&mDepthStencilDesc, sizeof(D3D11_DEPTH_STENCIL_DESC)); diff --git a/Engine/source/gfx/gfxDevice.h b/Engine/source/gfx/gfxDevice.h index 1cb7a41fc..7b80aef3d 100644 --- a/Engine/source/gfx/gfxDevice.h +++ b/Engine/source/gfx/gfxDevice.h @@ -428,7 +428,7 @@ public: virtual void enterDebugEvent(ColorI color, const char *name) = 0; virtual void leaveDebugEvent() = 0; virtual void setDebugMarker(ColorI color, const char *name) = 0; - + virtual const char* interpretDebugResult(long result) { return "Not Implemented"; }; /// @} /// @name Resource debug methods diff --git a/Engine/source/gfx/gl/gfxGLDevice.h b/Engine/source/gfx/gl/gfxGLDevice.h index 179957db2..df35ad724 100644 --- a/Engine/source/gfx/gl/gfxGLDevice.h +++ b/Engine/source/gfx/gl/gfxGLDevice.h @@ -160,7 +160,7 @@ public: const U32 getNumVertexStreams() const { return mNumVertexStream; } bool glUseMap() const { return mUseGlMap; } - + const char* interpretDebugResult(long result) { return "Not Implemented"; }; protected: /// Called by GFXDevice to create a device specific stateblock virtual GFXStateBlockRef createStateBlockInternal(const GFXStateBlockDesc& desc); diff --git a/Engine/source/gui/editor/inspector/variableGroup.cpp b/Engine/source/gui/editor/inspector/variableGroup.cpp index cb23d9c6e..5cb9e34ba 100644 --- a/Engine/source/gui/editor/inspector/variableGroup.cpp +++ b/Engine/source/gui/editor/inspector/variableGroup.cpp @@ -117,7 +117,7 @@ bool GuiInspectorVariableGroup::inspectGroup() Con::executef(this, "onConstructField", mFields[i]->mFieldName, mFields[i]->mFieldLabel, mFields[i]->mFieldTypeName, mFields[i]->mFieldDescription, - mFields[i]->mDefaultValue, mFields[i]->mDataValues, mFields[i]->mOwnerObject); + mFields[i]->mDefaultValue, mFields[i]->mDataValues, mFields[i]->mSetCallbackName, mFields[i]->mOwnerObject); } continue; } diff --git a/Engine/source/gui/editor/inspector/variableInspector.cpp b/Engine/source/gui/editor/inspector/variableInspector.cpp index 717dc8bb4..340de765e 100644 --- a/Engine/source/gui/editor/inspector/variableInspector.cpp +++ b/Engine/source/gui/editor/inspector/variableInspector.cpp @@ -23,7 +23,7 @@ #include "gui/editor/inspector/variableInspector.h" #include "console/engineAPI.h" -GuiVariableInspector::GuiVariableInspector() +GuiVariableInspector::GuiVariableInspector() : mAutoUpdate(true) { } @@ -117,7 +117,7 @@ void GuiVariableInspector::endGroup() } void GuiVariableInspector::addField(const char* name, const char* label, const char* typeName, const char* description, - const char* defaultValue, const char* dataValues, SimObject* ownerObj) + const char* defaultValue, const char* dataValues, const char* callbackName, SimObject* ownerObj) { VariableField newField; newField.mFieldName = StringTable->insert(name); @@ -127,7 +127,7 @@ void GuiVariableInspector::addField(const char* name, const char* label, const c newField.mDefaultValue = StringTable->insert(defaultValue); newField.mDataValues = String(dataValues); newField.mGroup = mCurrentGroup; - newField.mSetCallbackName = StringTable->EmptyString(); + newField.mSetCallbackName = StringTable->insert(callbackName); newField.mEnabled = true; newField.mOwnerObject = ownerObj; @@ -184,18 +184,14 @@ void GuiVariableInspector::addField(const char* name, const char* label, const c mFields.push_back(newField); - update(); + if(mAutoUpdate) + update(); } void GuiVariableInspector::addCallbackField(const char* name, const char* label, const char* typeName, const char* description, const char* defaultValue, const char* dataValues, const char* callbackName, SimObject* ownerObj) { - addField(name, label, typeName, description, defaultValue, dataValues, ownerObj); - - //Add the callback name - mFields.last().mSetCallbackName = StringTable->insert(callbackName); - - update(); + addField(name, label, typeName, description, defaultValue, dataValues, callbackName, ownerObj); } void GuiVariableInspector::clearFields() @@ -238,7 +234,7 @@ DefineEngineMethod(GuiVariableInspector, addField, void, (const char* name, cons if (name == "" || typeName == "") return; - object->addField(name, label, typeName, description, defaultValue, dataValues, ownerObj); + object->addField(name, label, typeName, description, defaultValue, dataValues, "", ownerObj); } DefineEngineMethod(GuiVariableInspector, addCallbackField, void, (const char* name, const char* label, const char* typeName, @@ -270,3 +266,8 @@ DefineEngineMethod( GuiVariableInspector, loadVars, void, ( const char * searchS { object->loadVars( searchString ); } + +DefineEngineMethod(GuiVariableInspector, setAutoUpdate, void, (bool doAutoUpdate), (true), "setAutoUpdate( doAutoUpdate ) - Dictates if the inspector automatically updates when changes happen, or if it must be called manually") +{ + object->setAutoUpdate(doAutoUpdate); +} diff --git a/Engine/source/gui/editor/inspector/variableInspector.h b/Engine/source/gui/editor/inspector/variableInspector.h index 58cdcda81..35a0c2681 100644 --- a/Engine/source/gui/editor/inspector/variableInspector.h +++ b/Engine/source/gui/editor/inspector/variableInspector.h @@ -53,18 +53,22 @@ public: void endGroup(); void addField(const char* name, const char* label, const char* typeName, const char* description, - const char* defaultValue, const char* dataValues, SimObject* ownerObj); + const char* defaultValue, const char* dataValues, const char* callbackName, SimObject* ownerObj); void addCallbackField(const char* name, const char* label, const char* typeName, const char* description, const char* defaultValue, const char* dataValues, const char* callbackName, SimObject* ownerObj); void setFieldEnabled(const char* name, bool enabled); void clearFields(); + void setAutoUpdate(bool doAutoUpdate) { mAutoUpdate = doAutoUpdate; } + protected: Vector mFields; String mCurrentGroup; + bool mAutoUpdate; + }; #endif // _GUI_VARIABLEINSPECTOR_H_ \ No newline at end of file diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs index 0c4b45ed1..06721bc4b 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs @@ -54,6 +54,11 @@ function initServer() $Server::MissionFileSpec = "data/levels/*.mis"; callOnModules("initServer"); + + //Maybe this should be a pref for better per-project control + //But many physically based/gameplay things utilize materials being detected + //So we'll load on the server as well + loadModuleMaterials(); } //----------------------------------------------------------------------------- diff --git a/Templates/BaseGame/game/core/utility/scripts/helperFunctions.cs b/Templates/BaseGame/game/core/utility/scripts/helperFunctions.cs index a12e902c5..50e3fb947 100644 --- a/Templates/BaseGame/game/core/utility/scripts/helperFunctions.cs +++ b/Templates/BaseGame/game/core/utility/scripts/helperFunctions.cs @@ -33,27 +33,8 @@ function isScriptFile(%path) function loadMaterials() { - // Load any materials files for which we only have DSOs. - - for( %file = findFirstFile( "*/materials.cs.dso" ); - %file !$= ""; - %file = findNextFile( "*/materials.cs.dso" )) - { - // Only execute, if we don't have the source file. - %csFileName = getSubStr( %file, 0, strlen( %file ) - 4 ); - if( !isFile( %csFileName ) ) - exec( %csFileName ); - } - - // Load all source material files. - - for( %file = findFirstFile( "*/materials.cs" ); - %file !$= ""; - %file = findNextFile( "*/materials.cs" )) - { - exec( %file ); - } - + loadModuleMaterials(); + // Load all materials created by the material editor if // the folder exists if( IsDirectory( "materialEditor" ) ) @@ -251,7 +232,7 @@ function validateDatablockName(%name) %name = strreplace( %name, " ", "_" ); // remove any other invalid characters - %invalidCharacters = "-+*/%$&§=()[].?\"#,;!~<>|°^{}"; + %invalidCharacters = "-+*/%$&�=()[].?\"#,;!~<>|�^{}"; %name = stripChars( %name, %invalidCharacters ); if( %name $= "" ) @@ -621,4 +602,13 @@ function switchControlObject(%client, %newControlEntity) return error("SwitchControlObject: Target controller has no conrol object behavior!"); %control.setConnectionControlObject(%client); +} + +function populateAllFonts(%font) +{ + populateFontCacheRange(%font,14,0,65535); + populateFontCacheRange(%font,18,0,65535); + populateFontCacheRange(%font,24,0,65535); + populateFontCacheRange(%font,32,0,65535); + populateFontCacheRange(%font,36,0,65535); } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/utility/scripts/module.cs b/Templates/BaseGame/game/core/utility/scripts/module.cs index 91f869498..fcbfb12df 100644 --- a/Templates/BaseGame/game/core/utility/scripts/module.cs +++ b/Templates/BaseGame/game/core/utility/scripts/module.cs @@ -17,4 +17,43 @@ function callOnModules(%functionName, %moduleGroup) eval(%module.scopeSet @ "." @ %functionName @ "();"); } } +} + +function loadModuleMaterials(%moduleGroup) +{ + //Get our modules so we can exec any specific client-side loading/handling + %modulesList = ModuleDatabase.findModules(false); + for(%i=0; %i < getWordCount(%modulesList); %i++) + { + %module = getWord(%modulesList, %i); + + if(%moduleGroup !$= "") + { + if(%module.group !$= %moduleGroup) + continue; + } + + %modulePath = %module.ModulePath; + + // Load any materials files for which we only have DSOs. + + for( %file = findFirstFile( %modulePath @ "/*/materials.cs.dso" ); + %file !$= ""; + %file = findNextFile( %modulePath @ "/*/materials.cs.dso" )) + { + // Only execute, if we don't have the source file. + %csFileName = getSubStr( %file, 0, strlen( %file ) - 4 ); + if( !isFile( %csFileName ) ) + exec( %csFileName ); + } + + // Load all source material files. + + for( %file = findFirstFile( %modulePath @ "/*/materials.cs" ); + %file !$= ""; + %file = findNextFile( %modulePath @ "/*/materials.cs" )) + { + exec( %file ); + } + } } \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml b/Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml index 80ad5ae94..dbf259fe9 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml +++ b/Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml @@ -1,55 +1,59 @@ - - LOS - 1 - CollisionMesh - 1 - Col - CollisionMesh - - - 0 - 1 - TrailingNumber - 0 - Z_AXIS - 0 - 0 - 0 - - - 1.0 - 0 - 1.0 - - _AO,_AMBIENT,_AMBIENTOCCLUSION - _NORMAL,_NORM - 1 - _SMOOTH,_SMOOTHNESS 1 - 1.0 - _ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL - Bilinear - 1 - _ROUGH,_ROUGHNESS - _COMP,_COMPOSITE - N/A + _NORMAL,_NORM 0 _METAL,_MET,_METALNESS,_METALLIC + _SMOOTH,_SMOOTHNESS + 1.0 1 + N/A + 1 + 1 + _COMP,_COMPOSITE + _ROUGH,_ROUGHNESS + Bilinear + _AO,_AMBIENT,_AMBIENTOCCLUSION + _ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL + + + 1 + 1 + + + CollisionMesh + Col + LOS + 1 + 1 + CollisionMesh 1 1 1 1 + ColorEffect*, - - 1 - 1 + + 0 + 1 + TrailingNumber + 0 + 0 + Z_AXIS + 0 + 0 + + + 0 + 1.0 + 1.0 + + + AutoPrune diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/assetImport.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/assetImport.gui index 9f355396d..45cb15e73 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/assetImport.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/assetImport.gui @@ -127,7 +127,7 @@ resizeWidth = "1"; resizeHeight = "1"; canMove = "1"; - canClose = "0"; + canClose = "1"; canMinimize = "0"; canMaximize = "0"; canCollapse = "0"; @@ -152,6 +152,7 @@ hidden = "1"; canSave = "1"; canSaveDynamicFields = "0"; + closeCommand = "ImportAssetConfigEditorWindow.close();"; new GuiTextCtrl() { text = "Configuration Name:"; @@ -614,7 +615,7 @@ resizeWidth = "1"; resizeHeight = "1"; canMove = "1"; - canClose = "0"; + canClose = "1"; canMinimize = "0"; canMaximize = "0"; canCollapse = "0"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs index 788f38bf4..86afa80bf 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs @@ -441,6 +441,8 @@ function AssetBrowser::addImportingAsset( %this, %assetType, %filePath, %parentA %this.unprocessedAssetsCount++; + ImportAssetWindow.assetValidationList.add(%assetItem); + return %assetItem; } @@ -498,10 +500,22 @@ function ImportAssetWindow::onWake(%this) $AssetBrowser::importConfigsFile = "tools/assetBrowser/assetImportConfigs.xml"; $AssetBrowser::currentImportConfig = ""; - new Settings(AssetImportSettings) { file = $AssetBrowser::importConfigsFile; }; + + if(!isObject(AssetImportSettings)) + { + new Settings(AssetImportSettings) + { + file = $AssetBrowser::importConfigsFile; + }; + } AssetImportSettings.read(); %this.reloadImportOptionConfigs(); + + if(!isObject(%this.assetValidationList)) + { + %this.assetValidationList = new ArrayObject(); + } } function ImportAssetWindow::reloadImportOptionConfigs(%this) @@ -798,10 +812,11 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem) function ImportAssetWindow::parseImagePathSuffixes(%this, %filePath) { //diffuse - %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.DiffuseTypeSuffixes, ","); + %diffuseSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""); + %suffixCount = getTokenCount(%diffuseSuffixes, ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(ImportAssetWindow.activeImportConfig.DiffuseTypeSuffixes, ",", %sfx); + %suffixToken = getToken(%diffuseSuffixes, ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %filePath)) { return "diffuse"; @@ -809,10 +824,10 @@ function ImportAssetWindow::parseImagePathSuffixes(%this, %filePath) } //normal - %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.NormalTypeSuffixes, ","); + %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.NormalTypeSuffixes, ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(ImportAssetWindow.activeImportConfig.NormalTypeSuffixes, ",", %sfx); + %suffixToken = getToken(ImportAssetWindow.activeImportConfig.NormalTypeSuffixes, ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %filePath)) { return "normal"; @@ -820,10 +835,10 @@ function ImportAssetWindow::parseImagePathSuffixes(%this, %filePath) } //roughness - %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ","); + %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ",", %sfx); + %suffixToken = getToken(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %filePath)) { return "roughness"; @@ -831,10 +846,10 @@ function ImportAssetWindow::parseImagePathSuffixes(%this, %filePath) } //Ambient Occlusion - %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ","); + %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ",", %sfx); + %suffixToken = getToken(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %filePath)) { return "AO"; @@ -842,10 +857,10 @@ function ImportAssetWindow::parseImagePathSuffixes(%this, %filePath) } //metalness - %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ","); + %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ",", %sfx); + %suffixToken = getToken(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %filePath)) { return "metalness"; @@ -853,10 +868,10 @@ function ImportAssetWindow::parseImagePathSuffixes(%this, %filePath) } //composite - %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ","); + %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ",", %sfx); + %suffixToken = getToken(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %filePath)) { return "composite"; @@ -864,10 +879,10 @@ function ImportAssetWindow::parseImagePathSuffixes(%this, %filePath) } //specular - %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ","); + %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",", %sfx); + %suffixToken = getToken(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %filePath)) { return "specular"; @@ -888,11 +903,14 @@ function ImportAssetWindow::refresh(%this) %id = ImportAssetTree.getChild(1); ImportAssetWindow.assetHeirarchyChanged = false; + AssetBrowser.importAssetFinalListArray.empty(); %this.processNewImportAssets(%id); %this.indentCount = 0; + %this.validateAssets(); + ImportingAssetList.clear(); if(AssetBrowser.importAssetUnprocessedListArray.count() == 0) @@ -927,9 +945,6 @@ function ImportAssetWindow::refreshChildItem(%this, %id) %filePath = %assetItem.filePath; %assetName = %assetItem.assetName; - //validate - %this.validateAsset(%assetItem); - //Once validated, attempt any fixes for issues %this.resolveIssue(%assetItem); @@ -947,40 +962,39 @@ function ImportAssetWindow::refreshChildItem(%this, %id) if(%assetType $= "Model" || %assetType $= "Animation" || %assetType $= "Image" || %assetType $= "Sound") { - /*if(%assetItem.status $= "Error") + if(%assetItem.status $= "Error") { %iconPath = "tools/gui/images/iconError"; - %configCommand = "ImportAssetOptionsWindow.findMissingFile(" @ %assetItem @ ");"; } - else*/ - if(%assetItem.status $= "Warning") + else if(%assetItem.status $= "Warning") { %iconPath = "tools/gui/images/iconWarn"; - %configCommand = "ImportAssetOptionsWindow.fixIssues(" @ %assetItem @ ");"; + } + + %configCommand = "ImportAssetOptionsWindow.fixIssues(" @ %assetItem @ ");"; if(%assetItem.statusType $= "DuplicateAsset" || %assetItem.statusType $= "DuplicateImportAsset") %assetName = %assetItem.assetName @ " "; - } - - %toolTip = %assetItem.statusInfo; } else { if(%assetItem.status $= "Error") { %iconPath = "tools/gui/images/iconError"; - %configCommand = "";//"ImportAssetOptionsWindow.findMissingFile(" @ %assetItem @ ");"; } else if(%assetItem.status $= "Warning") { %iconPath = "tools/gui/images/iconWarn"; - %configCommand = "";//"ImportAssetOptionsWindow.fixIssues(" @ %assetItem @ ");"; + } + + %configCommand = "";//"ImportAssetOptionsWindow.fixIssues(" @ %assetItem @ ");"; if(%assetItem.statusType $= "DuplicateAsset" || %assetItem.statusType $= "DuplicateImportAsset") %assetName = %assetItem.assetName @ " "; - } } + %toolTip = %assetItem.statusInfo; + %inputCellPos = %indent; %inputCellWidth = (ImportingAssetList.extent.x * 0.3) - %indent; @@ -1088,7 +1102,7 @@ function ImportAssetWindow::refreshChildItem(%this, %id) { position = %delBtnPos SPC "0"; extent = %height SPC %height; - command = "ImportAssetOptionsWindow.deleteImportingAsset(" @ %assetItem @ ");"; + command = "ImportAssetWindow.deleteImportingAsset(" @ %assetItem @ ");"; bitmap = "tools/gui/images/iconDelete"; horzSizing = "width"; vertSizing = "bottom"; @@ -1096,6 +1110,7 @@ function ImportAssetWindow::refreshChildItem(%this, %id) }; ImportingAssetList.add(%importEntry); + AssetBrowser.importAssetFinalListArray.add(%assetItem); if(ImportAssetTree.isParentItem(%id)) { @@ -1141,45 +1156,51 @@ function ImportAssetWindow::importResolution(%this, %assetItem) ImportAssetResolutionsPopup.showPopup(Canvas); } +// function ImportAssetWindow::validateAssets(%this) { - %assetCount = AssetBrowser.importAssetFinalListArray.count(); + //Clear any status + %this.resetAssetsValidationStatus(); + + %id = ImportAssetTree.getChild(1); + %hasIssues = %this.validateAsset(%id); + + if(%hasIssues) + return false; + else + return true; +} + +function ImportAssetWindow::validateAsset(%this, %id) +{ %moduleName = ImportAssetModuleList.getText(); - %assetQuery = new AssetQuery(); - %hasIssues = false; - - //First, check the obvious: name collisions. We should have no asset that shares a similar name. - //If we do, prompt for it be renamed first before continuing - - for(%i=0; %i < %assetCount; %i++) + while (%id > 0) { - %assetItemA = AssetBrowser.importAssetFinalListArray.getKey(%i); + %assetItem = ImportAssetTree.getItemObject(%id); - //First, check our importing assets for name collisions - for(%j=0; %j < %assetCount; %j++) + if(!isObject(%assetItem) || %assetItem.skip) { - %assetItemB = AssetBrowser.importAssetFinalListArray.getKey(%j); - if( (%assetItemA.assetName $= %assetItemB.assetName) && (%i != %j) ) - { - //yup, a collision, prompt for the change and bail out - /*MessageBoxOK( "Error!", "Duplicate asset names found with importing assets!\nAsset \"" @ - %assetItemA.assetName @ "\" of type \"" @ %assetItemA.assetType @ "\" and \"" @ - %assetItemB.assetName @ "\" of type \"" @ %assetItemB.assetType @ "\" have matching names.\nPlease rename one of them and try again!");*/ - - %assetItemA.status = "Warning"; - %assetItemA.statusType = "DuplicateImportAsset"; - %assetItemA.statusInfo = "Duplicate asset names found with importing assets!\nAsset \"" @ - %assetItemA.assetName @ "\" of type \"" @ %assetItemA.assetType @ "\" and \"" @ - %assetItemB.assetName @ "\" of type \"" @ %assetItemB.assetType @ "\" have matching names.\nPlease rename one of them and try again!"; - - %hasIssues = true; - } + %id = ImportAssetTree.getNextSibling(%id); + continue; + } + + //First, check the obvious: name collisions. We should have no asset that shares a similar name. + //If we do, prompt for it be renamed first before continuing + %hasCollision = %this.checkAssetsForCollision(%assetItem); + + //Ran into a problem, so end checks on this one and move on + if(%hasCollision) + { + %id = ImportAssetTree.getNextSibling(%id); + continue; } //No collisions of for this name in the importing assets. Now, check against the existing assets in the target module if(!AssetBrowser.isAssetReImport) { + %assetQuery = new AssetQuery(); + %numAssetsFound = AssetDatabase.findAllAssets(%assetQuery); %foundCollision = false; @@ -1198,16 +1219,18 @@ function ImportAssetWindow::validateAssets(%this) %testAssetName = AssetDatabase.getAssetName(%assetId); - if(%testAssetName $= %assetItemA.assetName) + if(%testAssetName $= %assetItem.assetName) { %foundCollision = true; - %assetItemA.status = "Warning"; - %assetItemA.statusType = "DuplicateAsset"; - %assetItemA.statusInfo = "Duplicate asset names found with the target module!\nAsset \"" @ - %assetItemA.assetName @ "\" of type \"" @ %assetItemA.assetType @ "\" has a matching name.\nPlease rename it and try again!"; + %assetItem.status = "Warning"; + %assetItem.statusType = "DuplicateAsset"; + %assetItem.statusInfo = "Duplicate asset names found with the target module!\nAsset \"" @ + %assetItem.assetName @ "\" of type \"" @ %assetItem.assetType @ "\" has a matching name.\nPlease rename it and try again!"; - break; + //Clean up our queries + %assetQuery.delete(); + break; } } @@ -1222,27 +1245,141 @@ function ImportAssetWindow::validateAssets(%this) //%assetQuery.delete(); //return false; } + + //Clean up our queries + %assetQuery.delete(); } - + //Check if we were given a file path(so not generated) but somehow isn't a valid file - if(%assetItemA.filePath !$= "" && !isFile(%assetItemA.filePath)) + if(%assetItem.filePath !$= "" && %assetItem.AssetType !$= "Material" && !isFile(%assetItem.filePath)) { %hasIssues = true; - %assetItemA.status = "error"; - %assetItemA.statusType = "MissingFile"; - %assetItemA.statusInfo = "Unable to find file to be imported. Please select asset file."; + %assetItem.status = "error"; + %assetItem.statusType = "MissingFile"; + %assetItem.statusInfo = "Unable to find file to be imported. Please select asset file."; } + + if(%assetItem.status $= "Warning") + { + if(getAssetImportConfigValue("General/WarningsAsErrors", "0") == 1) + { + %assetItem.status = "error"; + } + } + + if(ImportAssetTree.isParentItem(%id)) + { + %childItem = ImportAssetTree.getChild(%id); + + //recurse! + %this.validateAsset(%childItem); + } + + %id = ImportAssetTree.getNextSibling(%id); } - - //Clean up our queries - %assetQuery.delete(); - - if(%hasIssues) - return false; - else - return true; } + +function ImportAssetWindow::resetAssetsValidationStatus(%this) +{ + %id = ImportAssetTree.getChild(1); + + %this.resetAssetValidationStatus(%id); +} + +function ImportAssetWindow::resetAssetValidationStatus(%this, %id) +{ + %moduleName = ImportAssetModuleList.getText(); + + %id = ImportAssetTree.getChild(%id); + while (%id > 0) + { + %assetItem = ImportAssetTree.getItemObject(%id); + + if(!isObject(%assetItem) || %assetItem.skip) + { + %id = ImportAssetTree.getNextSibling(%id); + continue; + } + + %assetItem.status = ""; + %assetItem.statusType = ""; + %assetItem.statusInfo = ""; + + if(ImportAssetTree.isParentItem(%id)) + { + %childItem = ImportAssetTree.getChild(%id); + + //recurse! + %this.resetAssetValidationStatus(%childItem); + } + + %id = ImportAssetTree.getNextSibling(%id); + } +} + +function ImportAssetWindow::checkAssetsForCollision(%this, %assetItem) +{ + %id = ImportAssetTree.getChild(1); + + return %this.checkAssetForCollision(%assetItem, %id); +} + +function ImportAssetWindow::checkAssetForCollision(%this, %assetItem, %id) +{ + %moduleName = ImportAssetModuleList.getText(); + + %id = ImportAssetTree.getChild(%id); + while (%id > 0) + { + %assetItemB = ImportAssetTree.getItemObject(%id); + + if(!isObject(%assetItemB) || %assetItemB.skip) + { + %id = ImportAssetTree.getNextSibling(%id); + continue; + } + + if( (%assetItem.assetName $= %assetItemB.assetName) && (%assetItem.getId() != %assetItemB.getId()) ) + { + //yup, a collision, prompt for the change and bail out + %assetItem.status = "Warning"; + %assetItem.statusType = "DuplicateImportAsset"; + %assetItem.statusInfo = "Duplicate asset names found with importing assets!\nAsset \"" @ + %assetItemB.assetName @ "\" of type \"" @ %assetItemB.assetType @ "\" and \"" @ + %assetItem.assetName @ "\" of type \"" @ %assetItem.assetType @ "\" have matching names.\nPlease rename one of them and try again!"; + + return true; + } + + if(ImportAssetTree.isParentItem(%id)) + { + %childItem = ImportAssetTree.getChild(%id); + + //recurse! + %this.checkAssetForCollision(%assetItem, %childItem); + } + + %id = ImportAssetTree.getNextSibling(%id); + } + + return false; +} + +// +function ImportAssetWindow::deleteImportingAsset(%this, %assetItem) +{ + %item = ImportAssetTree.findItemByObjectId(%assetItem); + + ImportAssetTree.removeAllChildren(%item); + ImportAssetTree.removeItem(%item); + + schedule(10, 0, "refreshImportAssetWindow"); + //ImportAssetWindow.refresh(); + ImportAssetOptionsWindow.setVisible(0); +} + +// function ImportAssetWindow::ImportAssets(%this) { //do the actual importing, now! @@ -1422,127 +1559,100 @@ function ImportAssetWindow::doImportAssets(%this, %id) function ImportAssetWindow::Close(%this) { //Some cleanup - AssetBrowser.importingFilesArray.clear(); + AssetBrowser.importingFilesArray.empty(); Canvas.popDialog(); } -// -function ImportAssetWindow::validateAsset(%this, %assetItem) -{ - %assetCount = AssetBrowser.importAssetFinalListArray.count(); - %moduleName = ImportAssetModuleList.getText(); - - %hasIssues = false; - - //First, check the obvious: name collisions. We should have no asset that shares a similar name. - //If we do, prompt for it be renamed first before continuing - - for(%i=0; %i < %assetCount; %i++) - { - %assetItemA = AssetBrowser.importAssetFinalListArray.getKey(%i); - - if( (%assetItemA.assetName $= %assetItem.assetName) && (%assetItemA.getId() != %assetItem.getId()) ) - { - //yup, a collision, prompt for the change and bail out - /*MessageBoxOK( "Error!", "Duplicate asset names found with importing assets!\nAsset \"" @ - %assetItemA.assetName @ "\" of type \"" @ %assetItemA.assetType @ "\" and \"" @ - %assetItemB.assetName @ "\" of type \"" @ %assetItemB.assetType @ "\" have matching names.\nPlease rename one of them and try again!");*/ - - %assetItem.status = "Warning"; - %assetItem.statusType = "DuplicateImportAsset"; - %assetItem.statusInfo = "Duplicate asset names found with importing assets!\nAsset \"" @ - %assetItemA.assetName @ "\" of type \"" @ %assetItemA.assetType @ "\" and \"" @ - %assetItem.assetName @ "\" of type \"" @ %assetItem.assetType @ "\" have matching names.\nPlease rename one of them and try again!"; - - %hasIssues = true; - return false; - } - } - - //No collisions of for this name in the importing assets. Now, check against the existing assets in the target module - if(!AssetBrowser.isAssetReImport) - { - %assetQuery = new AssetQuery(); - - %numAssetsFound = AssetDatabase.findAllAssets(%assetQuery); - - %foundCollision = false; - for( %f=0; %f < %numAssetsFound; %f++) - { - %assetId = %assetQuery.getAsset(%f); - - //first, get the asset's module, as our major categories - %module = AssetDatabase.getAssetModule(%assetId); - - %testModuleName = %module.moduleId; - - //These are core, native-level components, so we're not going to be messing with this module at all, skip it - if(%moduleName !$= %testModuleName) - continue; - - %testAssetName = AssetDatabase.getAssetName(%assetId); - - if(%testAssetName $= %assetItem.assetName) - { - %foundCollision = true; - - %assetItem.status = "Warning"; - %assetItem.statusType = "DuplicateAsset"; - %assetItem.statusInfo = "Duplicate asset names found with the target module!\nAsset \"" @ - %assetItem.assetName @ "\" of type \"" @ %assetItem.assetType @ "\" has a matching name.\nPlease rename it and try again!"; - - //Clean up our queries - %assetQuery.delete(); - - return false; - } - } - - if(%foundCollision == true) - { - %hasIssues = true; - - //yup, a collision, prompt for the change and bail out - /*MessageBoxOK( "Error!", "Duplicate asset names found with the target module!\nAsset \"" @ - %assetItemA.assetName @ "\" of type \"" @ %assetItemA.assetType @ "\" has a matching name.\nPlease rename it and try again!");*/ - - //%assetQuery.delete(); - //return false; - } - - //Clean up our queries - %assetQuery.delete(); - } - - //Check if we were given a file path(so not generated) but somehow isn't a valid file - if(%assetItem.filePath !$= "" && !isFile(%assetItem.filePath)) - { - %hasIssues = true; - %assetItem.status = "error"; - %assetItem.statusType = "MissingFile"; - %assetItem.statusInfo = "Unable to find file to be imported. Please select asset file."; - - return false; - } - - return true; -} function ImportAssetWindow::resolveIssue(%this, %assetItem) { - if(%assetItem.status !$= "Warning") - return; - //Ok, we actually have a warning, so lets resolve if(%assetItem.statusType $= "DuplicateImportAsset" || %assetItem.statusType $= "DuplicateAsset") { + %resolutionAction = getAssetImportConfigValue("General/DuplicatAutoResolution", "AutoPrune"); + if(%resolutionAction $= "AutoPrune") + { + %this.deleteImportingAsset(%assetItem); + } + else if(%resolutionAction $= "AutoRename") + { + %noNum = stripTrailingNumber(%assetItem.assetName); + %num = getTrailingNumber(%assetItem.assetName); + + if(%num == -1) + { + %assetItem.assetName = %noNum @ "1"; + } + else + { + %num++; + %assetItem.assetName = %noNum @ %num; + } + } } else if(%assetItem.statusType $= "MissingFile") { - %this.findMissingFile(%assetItem); + if(getAssetImportConfigValue("General/AutomaticallyPromptMissingFiles", "0") == 1) + { + %this.findMissingFile(%assetItem); + } } } + +function ImportAssetWindow::findMissingFile(%this, %assetItem) +{ + if(%assetItem.assetType $= "Model") + %filters = "Shape Files(*.dae, *.cached.dts)|*.dae;*.cached.dts"; + else if(%assetItem.assetType $= "Image") + %filters = "Images Files(*.jpg,*.png,*.tga,*.bmp,*.dds)|*.jpg;*.png;*.tga;*.bmp;*.dds"; + + %dlg = new OpenFileDialog() + { + Filters = %filters; + DefaultPath = $Pref::WorldEditor::LastPath; + DefaultFile = ""; + ChangePath = true; + OverwritePrompt = true; + forceRelativePath = false; + fileName=""; + //MultipleFiles = true; + }; + + %ret = %dlg.Execute(); + + if ( %ret ) + { + $Pref::WorldEditor::LastPath = filePath( %dlg.FileName ); + %fullPath = %dlg.FileName;//makeRelativePath( %dlg.FileName, getMainDotCSDir() ); + } + + %dlg.delete(); + + if ( !%ret ) + return; + + %assetItem.filePath = %fullPath; + %assetItem.assetName = fileBase(%assetItem.filePath); + + if(%assetItem.assetType $= "Image") + { + //See if we have anything important to update for our material parent(if we have one) + %treeItem = ImportAssetTree.findItemByObjectId(%assetItem); + %parentItem = ImportAssetTree.getParentItem(%treeItem); + + if(%parentItem != 0) + { + %parentAssetItem = ImportAssetTree.getItemObject(%parentItem); + if(%parentAssetItem.assetType $= "Material") + { + AssetBrowser.prepareImportMaterialAsset(%parentAssetItem); + } + } + } + + ImportAssetWindow.refresh(); +} // // diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.cs index 69f45259f..332f4266c 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.cs @@ -17,8 +17,13 @@ function setupImportConfigSettingsList() if(!isObject(ImportAssetConfigSettingsList)) { new ArrayObject(ImportAssetConfigSettingsList); + + ImportAssetConfigSettingsList.addNewConfigSetting("General/DuplicatAutoResolution", "Duplicate Asset Auto-Resolution Action", "list", "", "AutoPrune", "None,AutoPrune,AutoRename"); + ImportAssetConfigSettingsList.addNewConfigSetting("General/WarningsAsErrors", "Warnings As Errors", "bool", "", "0", "", ""); + ImportAssetConfigSettingsList.addNewConfigSetting("General/PreventImportWithErrors", "Prevent Import With Errors", "bool", "", "1", "", ""); + ImportAssetConfigSettingsList.addNewConfigSetting("General/AutomaticallyPromptMissingFiles", "Automatically Prompt Missing Files", "bool", "", "0", "", ""); - ImportAssetConfigSettingsList.addNewConfigSetting("Mesh/ImportMesh", "Import Mesh", "bool", "", "1", "", "ToggleImportMesh"); + ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/ImportMesh", "Import Mesh", "bool", "", "1", "", "ToggleImportMesh"); ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/DoUpAxisOverride", "Do Up-axis Override", "bool", "", "0", ""); ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/UpAxisOverride", "Up-axis Override", "list", "", "Z_AXIS", "X_AXIS,Y_AXIS,Z_AXIS"); ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/ScaleOverride", "Do Scale Override", "bool", "", "0", ""); @@ -85,61 +90,12 @@ function ImportAssetConfigSettingsList::addNewConfigSetting(%this, %settingName, %this.add(%settingName TAB %settingFieldLabel TAB %type TAB %tooltip, %defaultValue TAB %fieldData); } -function ImportAssetOptionsWindow::findMissingFile(%this, %assetItem) +// +function ImportAssetConfigEditorWindow::close(%this) { - if(%assetItem.assetType $= "Model") - %filters = "Shape Files(*.dae, *.cached.dts)|*.dae;*.cached.dts"; - else if(%assetItem.assetType $= "Image") - %filters = "Images Files(*.jpg,*.png,*.tga,*.bmp,*.dds)|*.jpg;*.png;*.tga;*.bmp;*.dds"; - - %dlg = new OpenFileDialog() - { - Filters = %filters; - DefaultPath = $Pref::WorldEditor::LastPath; - DefaultFile = ""; - ChangePath = true; - OverwritePrompt = true; - forceRelativePath = false; - fileName=""; - //MultipleFiles = true; - }; - - %ret = %dlg.Execute(); - - if ( %ret ) - { - $Pref::WorldEditor::LastPath = filePath( %dlg.FileName ); - %fullPath = %dlg.FileName;//makeRelativePath( %dlg.FileName, getMainDotCSDir() ); - } - - %dlg.delete(); - - if ( !%ret ) - return; - - %assetItem.filePath = %fullPath; - %assetItem.assetName = fileBase(%assetItem.filePath); - - if(%assetItem.assetType $= "Image") - { - //See if we have anything important to update for our material parent(if we have one) - %treeItem = ImportAssetTree.findItemByObjectId(%assetItem); - %parentItem = ImportAssetTree.getParentItem(%treeItem); - - if(%parentItem != 0) - { - %parentAssetItem = ImportAssetTree.getItemObject(%parentItem); - if(%parentAssetItem.assetType $= "Material") - { - AssetBrowser.prepareImportMaterialAsset(%parentAssetItem); - } - } - } - - ImportAssetWindow.refresh(); + %this.setVisible(0); } -// function ImportAssetOptionsWindow::editImportSettings(%this, %assetItem) { ImportAssetOptionsWindow.setVisible(1); @@ -237,20 +193,10 @@ function ImportAssetOptionsWindow::editImportSettings(%this, %assetItem) } } -function ImportAssetOptionsWindow::deleteImportingAsset(%this, %assetItem) -{ - %item = ImportAssetTree.findItemByObjectId(%assetItem); - - ImportAssetTree.removeAllChildren(%item); - ImportAssetTree.removeItem(%item); - - schedule(10, 0, "refreshImportAssetWindow"); - //ImportAssetWindow.refresh(); - ImportAssetOptionsWindow.setVisible(0); -} - function ImportAssetOptionsWindow::saveAssetOptions(%this) { + %success = AssetImportSettings.write(); + ImportAssetWindow.refresh(); ImportAssetOptionsWindow.setVisible(0); } @@ -276,7 +222,9 @@ function ImportAssetConfigEditorWindow::populateConfigList(%this, %configName) AssetImportConfigName.setText(%configName); ImportOptionsConfigList.clearFields(); + ImportOptionsConfigList.setAutoUpdate(false); //we don't want to be updating every time we add a field in here + %this.populateConfigListByGroup("General"); %this.populateConfigListByGroup("Meshes"); %this.populateConfigListByGroup("Materials"); %this.populateConfigListByGroup("Animations"); @@ -284,83 +232,7 @@ function ImportAssetConfigEditorWindow::populateConfigList(%this, %configName) %this.populateConfigListByGroup("Collision"); %this.populateConfigListByGroup("Sound"); - /*ImportOptionsConfigList.addCallbackField("ImportMesh", "Import Mesh", "bool", "", "1", "", "ToggleImportMesh", %optionsObj); - ImportOptionsConfigList.addField("DoUpAxisOverride", "Do Up-axis Override", "bool", "", "0", "", %optionsObj); - ImportOptionsConfigList.addField("UpAxisOverride", "Up-axis Override", "list", "", "Z_AXIS", "X_AXIS,Y_AXIS,Z_AXIS", %optionsObj); - ImportOptionsConfigList.addField("DoScaleOverride", "Do Scale Override", "bool", "", "0", "", %optionsObj); - ImportOptionsConfigList.addField("ScaleOverride", "Scale Override", "float", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("IgnoreNodeScale", "Ignore Node Scale", "bool", "", "0", "", %optionsObj); - ImportOptionsConfigList.addField("AdjustCenter", "Adjust Center", "bool", "", "0", "", %optionsObj); - ImportOptionsConfigList.addField("AdjustFloor", "Adjust Floor", "bool", "", "0", "", %optionsObj); - ImportOptionsConfigList.addField("CollapseSubmeshes", "Collapse Submeshes", "bool", "", "0", "", %optionsObj); - ImportOptionsConfigList.addField("LODType", "LOD Type", "list", "", "TrailingNumber", "TrailingNumber,DetectDTS", %optionsObj); - //ImportOptionsConfigList.addField("TrailingNumber", "Trailing Number", "float", "", "2", "", %optionsObj, "Mesh"); - ImportOptionsConfigList.addField("ImportedNodes", "Imported Nodes", "command", "", "", "", %optionsObj); - ImportOptionsConfigList.addField("IgnoreNodes", "Ignore Nodes", "command", "", "", "", %optionsObj); - ImportOptionsConfigList.addField("ImportMeshes", "Import Meshes", "command", "", "", "", %optionsObj); - ImportOptionsConfigList.addField("IgnoreMeshes", "Imported Meshes", "command", "", "", "", %optionsObj); - ImportOptionsConfigList.endGroup(); - - //Materials - ImportOptionsConfigList.startGroup("Material"); - ImportOptionsConfigList.addField("ImportMaterials", "Import Materials", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("CreateComposites", "Create Composites", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("UseDiffuseSuffixOnOriginImg", "Use Diffuse Suffix for Origin Image", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("UseExistingMaterials", "Use Existing Materials", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("IgnoreMaterials", "Ignore Materials", "command", "", "", "", %optionsObj); - ImportOptionsConfigList.endGroup(); - - //Animations - ImportOptionsConfigList.startGroup("Animations"); - ImportOptionsConfigList.addField("ImportAnimations", "Import Animations", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("SeparateAnimations", "Separate Animations", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("SeparateAnimationPrefix", "Separate Animation Prefix", "string", "", "", "", %optionsObj); - ImportOptionsConfigList.endGroup(); - - //Collision - ImportOptionsConfigList.startGroup("Collision"); - ImportOptionsConfigList.addField("GenerateCollisions", "Generate Collisions", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("GenCollisionType", "Generate Collision Type", "list", "", "CollisionMesh", "CollisionMesh,ConvexHull", %optionsObj); - ImportOptionsConfigList.addField("CollisionMeshPrefix", "CollisionMesh Prefix", "string", "", "Col", "", %optionsObj); - ImportOptionsConfigList.addField("GenerateLOSCollisions", "Generate LOS Collisions", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("GenLOSCollisionType", "Generate LOS Collision Type", "list", "", "CollisionMesh", "CollisionMesh,ConvexHull", %optionsObj); - ImportOptionsConfigList.addField("LOSCollisionMeshPrefix", "LOS CollisionMesh Prefix", "string", "", "LOS", "", %optionsObj); - ImportOptionsConfigList.endGroup(); - - //Images - ImportOptionsConfigList.startGroup("Image"); - ImportOptionsConfigList.addField("ImageType", "Image Type", "list", "", "N/A", "N/A,Diffuse,Normal,Specular,Metalness,Roughness,AO,Composite,GUI", %optionsObj); - ImportOptionsConfigList.addField("DiffuseTypeSuffixes", "Diffuse Type Suffixes", "command", "", "_ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL", "", %optionsObj); - ImportOptionsConfigList.addField("NormalTypeSuffixes", "Normal Type Suffixes", "command", "", "_NORMAL,_NORM", "", %optionsObj); - - if(EditorSettings.lightingModel $= "Legacy") - { - ImportOptionsConfigList.addField("SpecularTypeSuffixes", "Specular Type Suffixes", "command", "", "_SPECULAR,_SPEC", "", %optionsObj); - } - else - { - ImportOptionsConfigList.addField("MetalnessTypeSuffixes", "Metalness Type Suffixes", "command", "", "_METAL,_MET,_METALNESS,_METALLIC", "", %optionsObj); - ImportOptionsConfigList.addField("RoughnessTypeSuffixes", "Roughness Type Suffixes", "command", "", "_ROUGH,_ROUGHNESS", "", %optionsObj); - ImportOptionsConfigList.addField("SmoothnessTypeSuffixes", "Smoothness Type Suffixes", "command", "", "_SMOOTH,_SMOOTHNESS", "", %optionsObj); - ImportOptionsConfigList.addField("AOTypeSuffixes", "AO Type Suffixes", "command", "", "_AO,_AMBIENT,_AMBIENTOCCLUSION", "", %optionsObj); - ImportOptionsConfigList.addField("CompositeTypeSuffixes", "Composite Type Suffixes", "command", "", "_COMP,_COMPOSITE", "", %optionsObj); - } - - ImportOptionsConfigList.addField("TextureFilteringMode", "Texture Filtering Mode", "list", "", "Bilinear", "None,Bilinear,Trilinear", %optionsObj); - ImportOptionsConfigList.addField("UseMips", "Use Mipmaps", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("IsHDR", "Is HDR", "bool", "", "0", "", %optionsObj); - ImportOptionsConfigList.addField("Scaling", "Scaling", "float", "", "1.0", "", %optionsObj); - ImportOptionsConfigList.addField("Compressed", "Is Compressed", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("GenerateMaterialOnImport", "Generate Material On Import", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.addField("PopulateMaterialMaps", "Populate Material Maps", "bool", "", "1", "", %optionsObj); - ImportOptionsConfigList.endGroup(); - - //Sounds - ImportOptionsConfigList.startGroup("Sound"); - ImportOptionsConfigList.addField("VolumeAdjust", "Volume Adjustment", "float", "", "1.0", "", %optionsObj); - ImportOptionsConfigList.addField("PitchAdjust", "Pitch Adjustment", "float", "", "1.0", "", %optionsObj); - ImportOptionsConfigList.addField("Compressed", "Is Compressed", "bool", "", "0", "", %optionsObj); - ImportOptionsConfigList.endGroup();*/ + ImportOptionsConfigList.update(); } function ImportAssetConfigEditorWindow::populateConfigListByGroup(%this, %groupName) @@ -459,6 +331,21 @@ function ImportAssetConfigEditorWindow::addNewConfig(%this) //%this.populateConfigList(%optionsObj); } +function ImportAssetConfigEditorWindow::setDefaultValuesByGroup(%this, %groupName) +{ + %configList = ImportAssetConfigSettingsList; + + for(%i=0; %i < %configList.count(); %i++) + { + %settingName = getField(%configList.getKey(%i),0); + if(startsWith(%settingName, %groupName @ "/")) + { + %defaultValue = getField(%configList.getValue(%i), 0); + AssetImportSettings.setValue(%settingName, %defaultValue); + } + } +} + function ImportAssetConfigEditorWindow::editConfig(%this) { //Ensure our list is set up @@ -495,65 +382,13 @@ function ImportAssetConfigEditorWindow::createNewImportConfig(%this) AssetImportSettings.beginGroup(%configName); - for(%i=0; %i < %configList.count(); %i++) - { - %settingName = getField(%configList.getKey(%i),0); - if(startsWith(%settingName, "Meshes/")) - { - %defaultValue = getField(%configList.getValue(%i), 0); - AssetImportSettings.setValue(%settingName, %defaultValue); - } - } - - for(%i=0; %i < %configList.count(); %i++) - { - %settingName = getField(%configList.getKey(%i),0); - if(startsWith(%settingName, "Materials/")) - { - %defaultValue = getField(%configList.getValue(%i), 0); - AssetImportSettings.setValue(%settingName, %defaultValue); - } - } - - for(%i=0; %i < %configList.count(); %i++) - { - %settingName = getField(%configList.getKey(%i),0); - if(startsWith(%settingName, "Animations/")) - { - %defaultValue = getField(%configList.getValue(%i), 0); - AssetImportSettings.setValue(%settingName, %defaultValue); - } - } - - for(%i=0; %i < %configList.count(); %i++) - { - %settingName = getField(%configList.getKey(%i),0); - if(startsWith(%settingName, "Collision/")) - { - %defaultValue = getField(%configList.getValue(%i), 0); - AssetImportSettings.setValue(%settingName, %defaultValue); - } - } - - for(%i=0; %i < %configList.count(); %i++) - { - %settingName = getField(%configList.getKey(%i),0); - if(startsWith(%settingName, "Images/")) - { - %defaultValue = getField(%configList.getValue(%i), 0); - AssetImportSettings.setValue(%settingName, %defaultValue); - } - } - - for(%i=0; %i < %configList.count(); %i++) - { - %settingName = getField(%configList.getKey(%i),0); - if(startsWith(%settingName, "Sounds/")) - { - %defaultValue = getField(%configList.getValue(%i), 0); - AssetImportSettings.setValue(%settingName, %defaultValue); - } - } + %this.setDefaultValuesByGroup("General"); + %this.setDefaultValuesByGroup("Meshes"); + %this.setDefaultValuesByGroup("Materials"); + %this.setDefaultValuesByGroup("Animations"); + %this.setDefaultValuesByGroup("Collision"); + %this.setDefaultValuesByGroup("Images"); + %this.setDefaultValuesByGroup("Sounds"); AssetImportSettings.endGroup(); @@ -566,10 +401,13 @@ function ImportOptionsConfigList::addSettingsField(%this, %settingsFieldName, %l { %moddedSettingsFieldName = strreplace(%settingsFieldName, "/", "-"); - %value = AssetImportSettings.value(%settingsFieldName); + %configGroup = AssetImportConfigName.getText(); + + %value = AssetImportSettings.value(%configGroup @ "/" @ %settingsFieldName); if(%value $= "") %value = %fieldValue; - + + //%this.addCallbackField(%moddedSettingsFieldName, %labelText, %fieldType, "", %value, %fieldData, %this @ ".changeEditorSetting"); %this.addCallbackField(%moddedSettingsFieldName, %labelText, %fieldType, "", %value, %fieldData, "changeEditorSetting"); } @@ -579,9 +417,11 @@ function ImportOptionsConfigList::changeEditorSetting(%this, %varName, %value) echo("Set " @ %varName @ " to be " @ %value); - AssetImportSettings.setValue(%varName, %value); + %configGroup = AssetImportConfigName.getText(); - %success = AssetImportSettings.write(); + AssetImportSettings.setValue(%configGroup @ "/" @ %varName, %value); + + //%success = AssetImportSettings.write(); } function ImportOptionsConfigList::ToggleImportMesh(%this, %fieldName, %newValue, %ownerObject) diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs index 90d585ef9..5cbd3689e 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs @@ -78,7 +78,7 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem) } } - if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "") == 1) + if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "1") == 1) { %materialItemId = ImportAssetTree.findItemByObjectId(%assetItem); @@ -92,9 +92,14 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem) if(getAssetImportConfigValue("Images/UseDiffuseSuffixOnOriginImage", "1") == 1 && %diffuseImageSuffix $= "") { - %diffuseToken = getToken(getAssetImportConfigValue("Materials/DiffuseTypeSuffixes", ""), ",;", 0); + %diffuseTypeSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""); - %diffuseAsset = AssetBrowser.addImportingAsset("Image", %diffuseImagePath, %assetItem, %filename @ %diffuseToken); + %diffuseFilename = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %diffuseTypeSuffixes); + + if(%diffuseFilename !$= "") + %diffuseAsset = AssetBrowser.addImportingAsset("Image", %diffuseFilename, %assetItem, fileBase(%diffuseFilename)); + else + %diffuseAsset = AssetBrowser.addImportingAsset("Image", %diffuseImagePath, %assetItem, %filename @ getToken(%diffuseTypeSuffixes, ",;", 0)); } else { @@ -107,35 +112,10 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem) //Now, iterate over our comma-delimited suffixes to see if we have any matches. We'll use the first match in each case, if any. if(%assetItem.normalImageAsset $= "") { - //First, normal map - %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, ImportAssetWindow.activeImportConfig.NormalTypeSuffixes); + %normalTypeSuffixes = getAssetImportConfigValue("Images/NormalTypeSuffixes", ""); - if(%targetFilePath $= "") - { - //Didn't find it for the presumed file path, so lets angle it from the diffuse map's texture name, if it has one - if(isObject(%assetItem.diffuseImageAsset)) - { - if(isFile(%assetItem.diffuseImageAsset.filePath)) - { - %diffFileDir = filePath(%assetItem.diffuseImageAsset.filePath); - %diffFileName = fileBase(%assetItem.diffuseImageAsset.filePath); - %diffFileExt = fileExt(%assetItem.diffuseImageAsset.filePath); - - %suffixCount = getTokenCount(getAssetImportConfigValue("Materials/DiffuseTypeSuffixes", ""), ",;"); - for(%sfx = 0; %sfx < %suffixCount; %sfx++) - { - %suffixToken = getToken(getAssetImportConfigValue("Materials/DiffuseTypeSuffixes", ""), ",;", %sfx); - if(strIsMatchExpr("*"@%suffixToken, %diffFileName)) - { - %diffFileName = strreplace(%diffFileName, %suffixToken, ""); - break; - } - } - - %targetFilePath = %this.findMaterialMapFileWSuffix(%diffFileDir, %diffFileName, %diffFileExt, ImportAssetWindow.activeImportConfig.NormalTypeSuffixes); - } - } - } + //First, normal map + %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %normalTypeSuffixes); if(%targetFilePath !$= "") { @@ -167,136 +147,97 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem) if(%assetItem.metalImageAsset $= "") { - //Metal - %listCount = getTokenCount(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ",;"); - - %foundFile = 0; - for(%i=0; %i < %listCount; %i++) + %metalnessTypeSuffixes = getAssetImportConfigValue("Images/MetalnessTypeSuffixes", ""); + + %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %metalnessTypeSuffixes); + + if(%targetFilePath !$= "") { - %entryText = getToken(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ",;", %i); - - %targetFilePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt; - %foundFile = isFile(%targetFilePath); - - if(%foundFile) - { - %metalAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); - %assetItem.metalImageAsset = %metalAsset; - break; - } + %metalAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); + %assetItem.metalImageAsset = %metalAsset; } } if(%assetItem.roughnessImageAsset $= "") { - //Roughness - %listCount = getTokenCount(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ",;"); - - %foundFile = 0; - for(%i=0; %i < %listCount; %i++) + %roughnessTypeSuffixes = getAssetImportConfigValue("Images/RoughnessTypeSuffixes", ""); + + %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %roughnessTypeSuffixes); + + if(%targetFilePath !$= "") { - %entryText = getToken(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ",;", %i); - - %targetFilePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt; - %foundFile = isFile(%targetFilePath); - - if(%foundFile) - { - %roughnessAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); - %assetItem.roughnessImageAsset = %roughnessAsset; - break; - } + %roughnessAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); + %assetItem.roughnessImageAsset = %roughnessAsset; } } if(%assetItem.smoothnessImageAsset $= "") { - //Smoothness - %listCount = getTokenCount(ImportAssetWindow.activeImportConfig.SmoothnessTypeSuffixes, ",;"); - - %foundFile = 0; - for(%i=0; %i < %listCount; %i++) + %smoothnessTypeSuffixes = getAssetImportConfigValue("Images/SmoothnessTypeSuffixes", ""); + + %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %smoothnessTypeSuffixes); + + if(%targetFilePath !$= "") { - %entryText = getToken(ImportAssetWindow.activeImportConfig.SmoothnessTypeSuffixes, ",;", %i); - - %targetFilePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt; - %foundFile = isFile(%targetFilePath); - - if(%foundFile) - { - %smoothnessAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); - %assetItem.SmoothnessImageAsset = %smoothnessAsset; - break; - } + %smoothnessAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); + %assetItem.SmoothnessImageAsset = %smoothnessAsset; } } if(%assetItem.AOImageAsset $= "") { - //AO - %listCount = getTokenCount(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ",;"); - - %foundFile = 0; - for(%i=0; %i < %listCount; %i++) + %aoTypeSuffixes = getAssetImportConfigValue("Images/AOTypeSuffixes", ""); + + %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %aoTypeSuffixes); + + if(%targetFilePath !$= "") { - %entryText = getToken(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ",;", %i); - - %targetFilePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt; - %foundFile = isFile(%targetFilePath); - - if(%foundFile) - { - %AOAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); - %assetItem.AOImageAsset = %AOAsset; - break; - } + %AOAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); + %assetItem.AOImageAsset = %AOAsset; } } if(%assetItem.compositeImageAsset $= "") { - //Composite - %listCount = getTokenCount(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ",;"); - - %foundFile = 0; - for(%i=0; %i < %listCount; %i++) + %compositeTypeSuffixes = getAssetImportConfigValue("Images/CompositeTypeSuffixes", ""); + + %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %compositeTypeSuffixes); + + if(%targetFilePath !$= "") { - %entryText = getToken(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ",;", %i); - - %targetFilePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt; - %foundFile = isFile(%targetFilePath); - - if(%foundFile) - { - %compositeAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); - %assetItem.compositeImageAsset = %compositeAsset; - break; - } + %compositeAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); + %assetItem.compositeImageAsset = %compositeAsset; } } } } -function AssetBrowser::findMaterialMapFileWSuffix(%this, %fileDir, %filename, %fileExt, %suffixList) +function AssetBrowser::findMaterialMapFileWSuffix(%this, %fileDir, %filename, %fileExt, %suffixesList) { - //Now, iterate over our comma-delimited suffixes to see if we have any matches. We'll use the first match in each case, if any. - //First, normal map - %listCount = getTokenCount(%suffixList, ",;"); + %listCount = getTokenCount(%suffixesList, ",;"); %foundFile = 0; + %filePath = ""; for(%i=0; %i < %listCount; %i++) { - %entryText = getToken(%suffixList, ",;", %i); + %entryText = getToken(%suffixesList, ",;", %i); - %targetFilePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt; - %foundFile = isFile(%targetFilePath); + if(%fileExt $= "") + { + %filePath = findFirstFile(%fileDir @ "/" @ %filename @ %entryText @ ".*"); + %foundFile = isFile(%filePath); + } + else + { + %filePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt; + %foundFile = isFile(%filePath); + } if(%foundFile) { - return %targetFilePath; - break; + return %filePath; } - } + } return ""; } diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.cs index 26b11e25e..affe50239 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.cs @@ -69,7 +69,7 @@ function AssetBrowser::prepareImportShapeAsset(%this, %assetItem) %shapeId = ImportAssetTree.findItemByObjectId(%assetItem); - if(ImportAssetWindow.activeImportConfig.ImportMesh == 1 && %shapeCount > 0) + if(getAssetImportConfigValue("Meshes/ImportMesh", "1") == 1 && %shapeCount > 0) { } @@ -77,7 +77,7 @@ function AssetBrowser::prepareImportShapeAsset(%this, %assetItem) %animCount = %assetItem.shapeInfo._animCount; %animItem = %assetItem.shapeInfo.findItemByName("Animations"); - if(ImportAssetWindow.activeImportConfig.ImportAnimations == 1 && %animCount > 0) + if(getAssetImportConfigValue("Animations/ImportAnimations", "1") == 1 && %animCount > 0) { /*%animationItem = %assetItem.shapeInfo.getChild(%animItem); @@ -101,7 +101,7 @@ function AssetBrowser::prepareImportShapeAsset(%this, %assetItem) %matCount = %assetItem.shapeInfo._materialCount; %matItem = %assetItem.shapeInfo.findItemByName("Materials"); - if(ImportAssetWindow.activeImportConfig.importMaterials == 1 && %matCount > 0) + if(getAssetImportConfigValue("Materials/ImportMaterials", "1") == 1 && %matCount > 0) { %materialItem = %assetItem.shapeInfo.getChild(%matItem); @@ -119,7 +119,7 @@ function AssetBrowser::prepareImportShapeAsset(%this, %assetItem) if(%filePath !$= "" && isFile(%filePath)) AssetBrowser.addImportingAsset("Material", %filePath, %assetItem); else - AssetBrowser.addImportingAsset("Material", %matName, %assetItem); + AssetBrowser.addImportingAsset("Material", filePath(%assetItem.filePath) @ "/" @ %matName, %assetItem); } %materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem); @@ -138,7 +138,7 @@ function AssetBrowser::prepareImportShapeAsset(%this, %assetItem) if(%filePath !$= "" && isFile(%filePath)) AssetBrowser.addImportingAsset("Material", %filePath, %assetItem); else - AssetBrowser.addImportingAsset("Material", %matName, %assetItem); + AssetBrowser.addImportingAsset("Material", filePath(%assetItem.filePath) @ "/" @ %matName, %assetItem); } %materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem); @@ -212,15 +212,16 @@ function AssetBrowser::importShapeAsset(%this, %assetItem) //We'll update any relevent bits to the ShapeConstructor here $TSShapeConstructor::neverImportMat = ""; - if(ImportAssetWindow.activeImportConfig.IgnoreMaterials !$= "") + if(getAssetImportConfigValue("Materials/IgnoreMaterials", "") !$= "") { - %ignoredMatNamesCount = getTokenCount(ImportAssetWindow.activeImportConfig.IgnoreMaterials, ",;"); + %ignoreMaterialList = getAssetImportConfigValue("Materials/IgnoreMaterials", ""); + %ignoredMatNamesCount = getTokenCount(%ignoreMaterialList, ",;"); for(%i=0; %i < %ignoredMatNamesCount; %i++) { if(%i==0) - $TSShapeConstructor::neverImportMat = getToken(ImportAssetWindow.activeImportConfig.IgnoreMaterials, ",;", %i); + $TSShapeConstructor::neverImportMat = getToken(%ignoreMaterialList, ",;", %i); else - $TSShapeConstructor::neverImportMat = $TSShapeConstructor::neverImportMat TAB getToken(ImportAssetWindow.activeImportConfig.IgnoreMaterials, ",;", %i); + $TSShapeConstructor::neverImportMat = $TSShapeConstructor::neverImportMat TAB getToken(%ignoreMaterialList, ",;", %i); } } diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/fieldTypes.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/fieldTypes.cs index 6dd6a2368..0417e4c66 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/fieldTypes.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/fieldTypes.cs @@ -3,14 +3,15 @@ function GuiVariableInspector::onInspectorFieldModified(%this, %targetObj, %fiel echo("FIELD CHANGED: " @ %fieldName @ " from " @ %oldValue @ " to " @ %newValue); } -function GuiInspectorVariableGroup::onConstructField(%this, %fieldName, %fieldLabel, %fieldTypeName, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %ownerObj) +function GuiInspectorVariableGroup::onConstructField(%this, %fieldName, %fieldLabel, %fieldTypeName, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj) { + %inspector = %this.getParent(); %makeCommand = %this @ ".build" @ %fieldTypeName @ "Field(\""@ %fieldName @ "\",\"" @ %fieldLabel @ "\",\"" @ %fieldDesc @ "\",\"" @ - %fieldDefaultVal @ "\",\"" @ %fieldDataVals @ "\",\"" @ %ownerObj @"\");"; + %fieldDefaultVal @ "\",\"" @ %fieldDataVals @ "\",\"" @ %inspector @ "." @ %callbackName @ "\",\"" @ %ownerObj @"\");"; eval(%makeCommand); } -function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %ownerObj) +function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj) { %extent = 200; @@ -82,6 +83,7 @@ function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabe hovertime = "1000"; ownerObject = %ownerObj; fieldName = %fieldName; + callbackName = %callbackName; }; //set the field value @@ -107,6 +109,8 @@ function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabe %fieldCtrl.setCaption(%fieldLabel); %fieldCtrl.setEditControl(%editControl); + + echo("GuiInspectorListField - " @ %editControl.getID() @ " - " @ %fieldName); %this.addInspectorField(%fieldCtrl); } @@ -118,10 +122,15 @@ function guiInspectorListField::onSelect( %this, %id, %text ) //ah, a global var, just do it straight, then %setCommand = %this.fieldName @ " = \"" @ %text @ "\";"; } - else + else if(isObject(%this.ownerObj)) { //regular variable %setCommand = %this.ownerObject @ "." @ %this.fieldName @ " = \"" @ %text @ "\";"; } + else if(%this.callbackName !$= "") + { + %setCommand = %this.callbackName @ "(\"" @ %this.fieldName @ "\",\"" @ %text @"\");"; + } + eval(%setCommand); } \ No newline at end of file