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
This commit is contained in:
Areloch 2019-08-12 01:04:17 -05:00
parent cb5c71a0e2
commit 142da31156
22 changed files with 634 additions and 603 deletions

View file

@ -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();
}
//-----------------------------------------------------------------------------

View file

@ -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 = "-+*/%$&<EFBFBD>=()[].?\"#,;!~<>|<7C>^{}";
%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);
}

View file

@ -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 );
}
}
}

View file

@ -1,55 +1,59 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<AssetImportSettings>
<Group name="TestConfig">
<Group name="Collision">
<Setting name="LOSCollisionMeshPrefix">LOS</Setting>
<Setting name="GenerateCollisions">1</Setting>
<Setting name="GenLOSCollisionType">CollisionMesh</Setting>
<Setting name="GenerateLOSCollisions">1</Setting>
<Setting name="CollisionMeshPrefix">Col</Setting>
<Setting name="GenCollisionType">CollisionMesh</Setting>
</Group>
<Group name="Meshes">
<Setting name="AdjustFloor">0</Setting>
<Setting name="ScaleOverride">1</Setting>
<Setting name="LODType">TrailingNumber</Setting>
<Setting name="AdjustCenter">0</Setting>
<Setting name="UpAxisOverride">Z_AXIS</Setting>
<Setting name="CollapseSubmeshes">0</Setting>
<Setting name="IgnoreNodeScale">0</Setting>
<Setting name="DoUpAxisOverride">0</Setting>
</Group>
<Group name="Sounds">
<Setting name="VolumeAdjust">1.0</Setting>
<Setting name="Compressed">0</Setting>
<Setting name="PitchAdjust">1.0</Setting>
</Group>
<Group name="Images">
<Setting name="AOTypeSuffixes">_AO,_AMBIENT,_AMBIENTOCCLUSION</Setting>
<Setting name="NormalTypeSuffixes">_NORMAL,_NORM</Setting>
<Setting name="UseMips">1</Setting>
<Setting name="SmoothnessTypeSuffixes">_SMOOTH,_SMOOTHNESS</Setting>
<Setting name="PopulateMaterialMaps">1</Setting>
<Setting name="Scaling">1.0</Setting>
<Setting name="DiffuseTypeSuffixes">_ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL</Setting>
<Setting name="TextureFilteringMode">Bilinear</Setting>
<Setting name="GenerateMaterialOnImport">1</Setting>
<Setting name="RoughnessTypeSuffixes">_ROUGH,_ROUGHNESS</Setting>
<Setting name="CompositeTypeSuffixes">_COMP,_COMPOSITE</Setting>
<Setting name="ImageType">N/A</Setting>
<Setting name="NormalTypeSuffixes">_NORMAL,_NORM</Setting>
<Setting name="IsHDR">0</Setting>
<Setting name="MetalnessTypeSuffixes">_METAL,_MET,_METALNESS,_METALLIC</Setting>
<Setting name="SmoothnessTypeSuffixes">_SMOOTH,_SMOOTHNESS</Setting>
<Setting name="Scaling">1.0</Setting>
<Setting name="Compressed">1</Setting>
<Setting name="ImageType">N/A</Setting>
<Setting name="GenerateMaterialOnImport">1</Setting>
<Setting name="UseMips">1</Setting>
<Setting name="CompositeTypeSuffixes">_COMP,_COMPOSITE</Setting>
<Setting name="RoughnessTypeSuffixes">_ROUGH,_ROUGHNESS</Setting>
<Setting name="TextureFilteringMode">Bilinear</Setting>
<Setting name="AOTypeSuffixes">_AO,_AMBIENT,_AMBIENTOCCLUSION</Setting>
<Setting name="DiffuseTypeSuffixes">_ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL</Setting>
</Group>
<Group name="Animations">
<Setting name="SeparateAnimations">1</Setting>
<Setting name="ImportAnimations">1</Setting>
</Group>
<Group name="Collision">
<Setting name="GenLOSCollisionType">CollisionMesh</Setting>
<Setting name="CollisionMeshPrefix">Col</Setting>
<Setting name="LOSCollisionMeshPrefix">LOS</Setting>
<Setting name="GenerateCollisions">1</Setting>
<Setting name="GenerateLOSCollisions">1</Setting>
<Setting name="GenCollisionType">CollisionMesh</Setting>
</Group>
<Group name="Materials">
<Setting name="UseExistingMaterials">1</Setting>
<Setting name="UseDiffuseSuffixOnOriginImage">1</Setting>
<Setting name="CreateComposites">1</Setting>
<Setting name="ImportMaterials">1</Setting>
<Setting name="IgnoreMaterials">ColorEffect*,</Setting>
</Group>
<Group name="Animations">
<Setting name="SeparateAnimations">1</Setting>
<Setting name="ImportAnimations">1</Setting>
<Group name="Meshes">
<Setting name="AdjustFloor">0</Setting>
<Setting name="ScaleOverride">1</Setting>
<Setting name="LODType">TrailingNumber</Setting>
<Setting name="CollapseSubmeshes">0</Setting>
<Setting name="IgnoreNodeScale">0</Setting>
<Setting name="UpAxisOverride">Z_AXIS</Setting>
<Setting name="AdjustCenter">0</Setting>
<Setting name="DoUpAxisOverride">0</Setting>
</Group>
<Group name="Sounds">
<Setting name="Compressed">0</Setting>
<Setting name="PitchAdjust">1.0</Setting>
<Setting name="VolumeAdjust">1.0</Setting>
</Group>
<Group name="General">
<Setting name="DuplicatAutoResolution">AutoPrune</Setting>
</Group>
</Group>
</AssetImportSettings>

View file

@ -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";

View file

@ -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 @ " <Duplicate Asset>";
}
%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 @ " <Duplicate Asset>";
}
}
%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();
}
//
//

View file

@ -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)

View file

@ -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 "";
}

View file

@ -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);
}
}

View file

@ -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);
}