Torque3D/Templates/BaseGame/game/tools/assetBrowser/scripts/looseFileAudit.tscript

316 lines
9.3 KiB
Plaintext
Raw Permalink Normal View History

function LooseFileAuditWindow::buildPopupMenus(%this)
{
//
// Import Asset Actions
//
//done with any valid image format file
if( !isObject( ImageLooseFilePopup ) )
{
%this.ImportAssetActions = new PopupMenu( ImageLooseFilePopup )
{
superClass = "MenuBuilder";
class = "EditorWorldMenu";
item[0] = "Make an Image Asset" TAB "" TAB "LooseFileAuditWindow.importImage();";
};
}
//Done with .tscript files
if( !isObject( ScriptLooseFilePopup ) )
{
%this.ImportAssetActions = new PopupMenu( ScriptLooseFilePopup )
{
superClass = "MenuBuilder";
class = "EditorWorldMenu";
item[0] = "Make a Script Asset" TAB "" TAB "LooseFileAuditWindow.importScript();";
item[1] = "Make a PostFX Asset" TAB "" TAB "LooseFileAuditWindow.importPostFX();";
item[2] = "Make a Material Asset" TAB "" TAB "LooseFileAuditWindow.importMaterial();";
item[3] = "Make a Terrain Material Asset" TAB "" TAB "LooseFileAuditWindow.importTerrMat();";
item[4] = "Make a Particle Asset" TAB "" TAB "LooseFileAuditWindow.importParticle();";
item[5] = "Make a Explosion Asset" TAB "" TAB "LooseFileAuditWindow.importExplosion();";
item[6] = "Make a Forest Brush Asset" TAB "" TAB "LooseFileAuditWindow.importForest();";
};
}
ScriptLooseFilePopup.enableItem(4, false);
ScriptLooseFilePopup.enableItem(5, false);
ScriptLooseFilePopup.enableItem(6, false);
if( !isObject( ShapeLooseFilePopup ) )
{
%this.ImportAssetActions = new PopupMenu( ShapeLooseFilePopup )
{
superClass = "MenuBuilder";
class = "EditorWorldMenu";
item[0] = "Make a Shape Asset" TAB "" TAB "LooseFileAuditWindow.importShape();";
item[1] = "Make a Shape Animation Asset" TAB "" TAB "LooseFileAuditWindow.importShapeAnimation();";
};
}
if( !isObject( DecalLooseFilePopup ) )
{
%this.ImportAssetActions = new PopupMenu( DecalLooseFilePopup )
{
superClass = "MenuBuilder";
class = "EditorWorldMenu";
item[0] = "Make a Decal Asset" TAB "" TAB "LooseFileAuditWindow.importDecal();";
};
}
if( !isObject( TerrainLooseFilePopup ) )
{
%this.ImportAssetActions = new PopupMenu( TerrainLooseFilePopup )
{
superClass = "MenuBuilder";
class = "EditorWorldMenu";
item[0] = "Make a Terrain Data Asset" TAB "" TAB "LooseFileAuditWindow.importTerrain();";
};
}
if( !isObject(SoundLooseFilePopup ) )
{
%this.ImportAssetActions = new PopupMenu( SoundLooseFilePopup )
{
superClass = "MenuBuilder";
class = "EditorWorldMenu";
item[0] = "Make a Sound Asset" TAB "" TAB "LooseFileAuditWindow.importSound();";
};
}
if( !isObject(LevelLooseFilePopup ) )
{
%this.ImportAssetActions = new PopupMenu( LevelLooseFilePopup )
{
superClass = "MenuBuilder";
class = "EditorWorldMenu";
item[0] = "Make a Level Asset" TAB "" TAB "LooseFileAuditWindow.importLevel();";
};
}
if( !isObject(GUILooseFilePopup ) )
{
%this.ImportAssetActions = new PopupMenu( GUILooseFilePopup )
{
superClass = "MenuBuilder";
class = "EditorWorldMenu";
item[0] = "Make a GUI Asset" TAB "" TAB "LooseFileAuditWindow.importGUI();";
};
}
}
function LooseFileAuditWindow::showDialog(%this, %address)
{
LooseFileAuditWindow.buildPopupMenus();
Canvas.pushDialog(LooseFileAudit);
%this.currentAddress = %address;
%this.refresh();
}
function LooseFileAuditWindow::refresh(%this)
{
LooseFileList.clear();
LooseFileList.insertItem(0, "Loose Files");
//First, wipe out any files inside the folder first
%file = findFirstFileMultiExpr( %this.currentAddress @ "/*.*", false);
%aq = new AssetQuery();
while( %file !$= "" )
{
if(!endsWith(%file, ".cached.dts"))
{
if(!strIsMatchExpr("*.asset.taml", %file) && !strIsMatchExpr("*.taml", %file))
{
%assetsFound = AssetDatabase.findAssetLooseFile(%aq, %file);
if(%assetsFound == 0)
{
LooseFileList.insertItem(1, %file);
}
}
}
%file = findNextFileMultiExpr( %this.currentAddress @ "/*.*" );
}
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
%aq.delete();
}
function LooseFileList::onRightMouseDown(%this, %itemId)
{
LooseFileList.itemPath = %this.getItemText(%itemId);
LooseFileList.selectedItem = %itemId;
%ext = fileExt(LooseFileList.itemPath);
if(isImageFormat(%ext))
{
ImageLooseFilePopup.showPopup(Canvas);
}
else if(%ext $= "." @ $TorqueScriptFileExtension)
{
ScriptLooseFilePopup.showPopup(Canvas);
}
else if(isShapeFormat(%ext))
{
ShapeLooseFilePopup.showPopup(Canvas);
}
else if(%ext $= ".mis")
{
LevelLooseFilePopup.showPopup(Canvas);
}
else if(isSoundFormat(%ext))
{
SoundLooseFilePopup.showPopup(Canvas);
}
else if(%ext $= ".ter")
{
TerrainLooseFilePopup.showPopup(Canvas);
}
else if(%ext $= ".gui")
{
GUILooseFilePopup.showPopup(Canvas);
}
}
//
//
function LooseFileAuditWindow::importImage(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
%assetItem = AssetBrowser.addImportingAsset("ImageAsset", LooseFileList.itemPath, "", "");
ImportAssetItems.add(%assetItem);
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importScript(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
AssetBrowser.addImportingAsset("ScriptAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importGUI(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
Added/Improved some asset type icons Renamed current default import config to DefaultConfig Updated Asset Browser UI layout. Fixed sizing behavior for Edit Asset window Fixed sizing behavior for Edit Module window Implemented Collection Sets system Implemented handling of non-asset loose files for AB Initial handling logic for prefabs for AB Updated Asset Importer to hook into C++ AssetImporter Made Add Module window properly reset module name field when opened Overhauled entire AB search system so it can use phrases and compound search logic Overhauled asset previews to utilize single guiIconButtonCtrl for efficiency and stability Updated Asset Preview Drag-n-drop to work with new previews Begun initial work with Tags integration into AB - currently only works with datablock categories Bugin initial work with Creator classes - currently only populates category lists, no items Added logic for scanning current AB directory for non-asset loose files, and activating an Auto-Import button if any are found Added ability to drag-n-drop datablocks from AB and spawn requisite object Stabilized drag-n-drop behavior of ShapeAssets, so when spawned, it'll find a much more sane drop position Fixed shapeAsset fields for drag-n-drop behavior so it correctly sets field now Adjusted folder and asset search fields in AB to utilize placeholder text Added logic when creating new module to prompt auto-populating common default folders Shifted preview size to slider Added logic to MenuBuilder so popup menus can utilize bitmap arrays Added editor setting for if to display loose files in AB Minor theme color corrections for some profiles
2020-07-11 21:49:06 +00:00
ImportAssetWindow.allowAutoImport = false;
AssetBrowser.addImportingAsset("GUIAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importLevel(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
Added/Improved some asset type icons Renamed current default import config to DefaultConfig Updated Asset Browser UI layout. Fixed sizing behavior for Edit Asset window Fixed sizing behavior for Edit Module window Implemented Collection Sets system Implemented handling of non-asset loose files for AB Initial handling logic for prefabs for AB Updated Asset Importer to hook into C++ AssetImporter Made Add Module window properly reset module name field when opened Overhauled entire AB search system so it can use phrases and compound search logic Overhauled asset previews to utilize single guiIconButtonCtrl for efficiency and stability Updated Asset Preview Drag-n-drop to work with new previews Begun initial work with Tags integration into AB - currently only works with datablock categories Bugin initial work with Creator classes - currently only populates category lists, no items Added logic for scanning current AB directory for non-asset loose files, and activating an Auto-Import button if any are found Added ability to drag-n-drop datablocks from AB and spawn requisite object Stabilized drag-n-drop behavior of ShapeAssets, so when spawned, it'll find a much more sane drop position Fixed shapeAsset fields for drag-n-drop behavior so it correctly sets field now Adjusted folder and asset search fields in AB to utilize placeholder text Added logic when creating new module to prompt auto-populating common default folders Shifted preview size to slider Added logic to MenuBuilder so popup menus can utilize bitmap arrays Added editor setting for if to display loose files in AB Minor theme color corrections for some profiles
2020-07-11 21:49:06 +00:00
ImportAssetWindow.allowAutoImport = false;
AssetBrowser.addImportingAsset("LevelAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importSound(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
AssetBrowser.addImportingAsset("SoundAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importTerrain(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
AssetBrowser.addImportingAsset("TerrainAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importTerrMat(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
AssetBrowser.addImportingAsset("TerrainMaterialAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importShape(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
AssetBrowser.addImportingAsset("ShapeAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importShapeAnimation(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
AssetBrowser.addImportingAsset("ShapeAnimationAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importPostFX(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
AssetBrowser.addImportingAsset("PostEffectAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}
function LooseFileAuditWindow::importMaterial(%this)
{
if(!ImportAssetWindow.isAwake())
ImportAssetWindow.showDialog();
AssetBrowser.addImportingAsset("MaterialAsset", LooseFileList.itemPath, "", "");
LooseFileList.removeItem(LooseFileList.selectedItem, false);
LooseFileList.buildVisibleTree(true);
LooseFileList.expandItem(0);
}