mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Updated TSStatic to utilize the getShapeAsset utility functions, and shifted the loader logic to utilize ShapeAssets exclusively, having straight file names go through the utility function to find/process a relevent asset.
This commit is contained in:
parent
6ade6f08ce
commit
7029024b8e
5 changed files with 127 additions and 141 deletions
|
|
@ -135,6 +135,29 @@ function findImageFile(%path, %materialName, %type)
|
|||
return %path @ "/" @ %materialName @ ".tif";
|
||||
}
|
||||
|
||||
function getAssetTypeByFilename(%filePath)
|
||||
{
|
||||
%fileExt = fileExt( %filePath );
|
||||
|
||||
//add it to our array!
|
||||
if(isImageFormat(%fileExt))
|
||||
return "ImageAsset";
|
||||
else if( isShapeFormat(%fileExt))
|
||||
return "ShapeAsset";
|
||||
else if( isSoundFormat(%fileExt))
|
||||
return "SoundAsset";
|
||||
else if( %fileExt $= ".cs" || %fileExt $= ".cs.dso" )
|
||||
return "ScriptAsset";
|
||||
else if( %fileExt $= ".gui" || %fileExt $= ".gui.dso" )
|
||||
return "GUIAsset";
|
||||
else if (%fileExt $= ".zip")
|
||||
return "zip";
|
||||
else if( %fileExt $= "")
|
||||
return "folder";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function AssetBrowser::onBeginDropFiles( %this )
|
||||
{
|
||||
if(!AssetBrowser.isAwake())
|
||||
|
|
@ -405,20 +428,43 @@ function ImportAssetWindow::reloadImportOptionConfigs(%this)
|
|||
//
|
||||
function importLooseFile(%filePath, %forceAutoImport)
|
||||
{
|
||||
%assetType = getAssetTypeByFilename(%filePath);
|
||||
|
||||
if(%forceAutoImport)
|
||||
{
|
||||
//If we're attempting to fast-track the import, check that that's even an option
|
||||
if(ImportAssetWindow.importConfigsList.count() == 0 ||
|
||||
EditorSettings.value("Assets/AssetImporDefaultConfig") $= "" ||
|
||||
EditorSettings.value("Assets/AutoImport", false) == false)
|
||||
{
|
||||
MessageBoxOK("Unable to AutoImport", "Attempted to import a loose file " @ %filePath @ " with AutoImport but was unable to either due to lacking a valid import config, or the editor settings are not set to auto import.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(%assetType $= "folder" || %assetType $= "zip")
|
||||
{
|
||||
MessageBoxOK("Unable to AutoImport", "Unable to auto import folders or zips at this time");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(%assetType $= "")
|
||||
{
|
||||
MessageBoxOK("Unable to AutoImport", "Unable to auto import unknown file type for file " @ %filePath);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
%assetItem = AssetBrowser.addImportingAsset("ImageAsset", %filePath, "", "");
|
||||
|
||||
%assetItem = AssetBrowser.addImportingAsset(%assetType, %filePath, "", "");
|
||||
ImportAssetItems.add(%assetItem);
|
||||
|
||||
if(%forceAutoImport)
|
||||
{
|
||||
AssetImportTargetModule.text = AssetBrowser.dirHandler.getModuleFromAddress(filePath(%filePath)).ModuleId;
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(filePath(%filePath)).ModuleId;
|
||||
AssetImportTargetModule.text = %targetModule;
|
||||
|
||||
%assetItem.moduleName = %targetModule;
|
||||
|
||||
AssetBrowser.dirHandler.currentAddress = filePath(%filePath);
|
||||
|
||||
//skip the refresh delay, we'll force it here
|
||||
ImportAssetWindow.doRefresh();
|
||||
|
|
|
|||
|
|
@ -158,10 +158,13 @@ function AssetBrowser::importShapeAsset(%this, %assetItem)
|
|||
%assetImportSuccessful = TAMLWrite(%newAsset, %assetPath @ %assetName @ ".asset.taml");
|
||||
|
||||
//and copy the file into the relevent directory
|
||||
%doOverwrite = !AssetBrowser.isAssetReImport;
|
||||
if(!pathCopy(%filePath, %assetFullPath, %doOverwrite))
|
||||
if(filePath(%filePath) !$= filePath(%assetFullPath))
|
||||
{
|
||||
error("Unable to import asset: " @ %filePath);
|
||||
%doOverwrite = !AssetBrowser.isAssetReImport;
|
||||
if(!pathCopy(%filePath, %assetFullPath, %doOverwrite))
|
||||
{
|
||||
error("Unable to import asset: " @ %filePath);
|
||||
}
|
||||
}
|
||||
|
||||
%constructor = ShapeEditor.findConstructor( %assetFullPath );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue