mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-19 14:43:47 +00:00
Added ability to override radio button behavior when selecting items in popup menus Added ability to turn on rotation snapping as a setting, with SHIFT just inverting the rot snap mode Implemented proper asset type filtering, complete with multiple type selection, and listing of active filters in AB footer. Selectable via visibility popup Menu Moved asset preview button generation from code to template GUI file added ability to move asset with drag-n-drop(Image asset only so far) New AB folder icon Properly link image asset fields to material asset if 'AlwaysPresentImageMaps' config setting is active
241 lines
8.2 KiB
C#
241 lines
8.2 KiB
C#
function AssetBrowser_editAsset::saveAsset(%this)
|
|
{
|
|
%file = AssetDatabase.getAssetFilePath(%this.editedAssetId);
|
|
%success = TamlWrite(AssetBrowser_editAsset.editedAsset, %file);
|
|
|
|
AssetBrowser.loadFilters();
|
|
|
|
Canvas.popDialog(AssetBrowser_editAsset);
|
|
}
|
|
|
|
function AssetBrowser::editAsset(%this, %assetDef)
|
|
{
|
|
//Find out what type it is
|
|
//If the passed-in definition param is blank, then we're likely called via a popup
|
|
if(%assetDef $= "")
|
|
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
|
|
|
%assetType = %assetDef.getClassName();
|
|
|
|
//Build out the edit command
|
|
%buildCommand = %this @ ".edit" @ %assetType @ "(" @ %assetDef @ ");";
|
|
eval(%buildCommand);
|
|
}
|
|
|
|
function AssetBrowser::appendSubLevel(%this)
|
|
{
|
|
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
|
%assetType = %assetDef.getClassName();
|
|
|
|
schedule( 1, 0, "EditorOpenSceneAppend", %assetDef);
|
|
}
|
|
|
|
function AssetBrowser::editAssetInfo(%this)
|
|
{
|
|
Canvas.pushDialog(AssetBrowser_editAsset);
|
|
|
|
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
|
|
|
eval("AssetBrowser.tempAsset = new " @ %assetDef.getClassName() @ "();");
|
|
AssetBrowser.tempAsset.assignFieldsFrom(%assetDef);
|
|
|
|
AssetEditInspector.inspect(AssetBrowser.tempAsset);
|
|
AssetBrowser_editAsset.editedAssetId = EditAssetPopup.assetId;
|
|
AssetBrowser_editAsset.editedAsset = AssetBrowser.tempAsset;
|
|
|
|
//remove some of the groups we don't need:
|
|
for(%i=0; %i < AssetEditInspector.getCount(); %i++)
|
|
{
|
|
%caption = AssetEditInspector.getObject(%i).caption;
|
|
|
|
if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing"
|
|
|| %caption $= "Persistence" || %caption $= "Dynamic Fields")
|
|
{
|
|
AssetEditInspector.remove(AssetEditInspector.getObject(%i));
|
|
%i--;
|
|
}
|
|
}
|
|
}
|
|
|
|
//------------------------------------------------------------
|
|
|
|
function AssetBrowser::refreshAsset(%this, %assetId)
|
|
{
|
|
if(%assetId $= "")
|
|
{
|
|
//if we have no passed-in asset ID, we're probably going through the popup menu, so get our edit popup id
|
|
%assetId = EditAssetPopup.assetId;
|
|
}
|
|
|
|
AssetDatabase.refreshAsset(%assetId);
|
|
AssetBrowser.refreshPreviews();
|
|
}
|
|
|
|
//------------------------------------------------------------
|
|
|
|
function AssetBrowser::renameAsset(%this)
|
|
{
|
|
//Find out what type it is
|
|
//%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
|
|
|
%curFirstResponder = AssetBrowser.getFirstResponder();
|
|
|
|
if(%curFirstResponder != 0)
|
|
%curFirstResponder.clearFirstResponder();
|
|
|
|
AssetBrowser.selectedAssetPreview-->AssetNameLabel.setActive(true);
|
|
AssetBrowser.selectedAssetPreview-->AssetNameLabel.setFirstResponder();
|
|
}
|
|
|
|
function AssetBrowser::performRenameAsset(%this, %originalAssetName, %newName)
|
|
{
|
|
//if the name is different to the asset's original name, rename it!
|
|
if(%originalAssetName !$= %newName)
|
|
{
|
|
if(EditAssetPopup.assetType !$= "Folder")
|
|
{
|
|
%moduleName = AssetBrowser.selectedModule;
|
|
|
|
//do a rename!
|
|
%success = AssetDatabase.renameDeclaredAsset(%moduleName @ ":" @ %originalAssetName, %moduleName @ ":" @ %newName);
|
|
|
|
if(%success)
|
|
echo("AssetBrowser - renaming of asset " @ %moduleName @ ":" @ %originalAssetName @ " to " @ %moduleName @ ":" @ %newName @ " was a success.");
|
|
else
|
|
echo("AssetBrowser - renaming of asset " @ %moduleName @ ":" @ %originalAssetName @ " to " @ %moduleName @ ":" @ %newName @ " was a failure.");
|
|
|
|
if(%success)
|
|
{
|
|
%newAssetId = %moduleName @ ":" @ %newName;
|
|
%assetPath = AssetDatabase.getAssetFilePath(%newAssetId);
|
|
|
|
//Rename any associated files as well
|
|
%assetDef = AssetDatabase.acquireAsset(%newAssetId);
|
|
%assetType = %assetDef.getClassName();
|
|
|
|
//rename the file to match
|
|
%path = filePath(%assetPath);
|
|
|
|
//Do the rename command
|
|
%buildCommand = %this @ ".rename" @ %assetType @ "(" @ %assetDef @ "," @ %newAssetId @ ");";
|
|
eval(%buildCommand);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
%buildCommand = %this @ ".renameFolder(\"" @ EditAssetPopup.assetId @ "\",\"" @ %newName @ "\");";
|
|
eval(%buildCommand);
|
|
}
|
|
}
|
|
|
|
//Make sure everything is refreshed
|
|
AssetBrowser.loadFilters();
|
|
|
|
//Update the selection to immediately jump to the new asset
|
|
AssetBrowser-->filterTree.clearSelection();
|
|
%ModuleItem = AssetBrowser-->filterTree.findItemByName(%moduleName);
|
|
%assetTypeId = AssetBrowser-->filterTree.findChildItemByName(%ModuleItem, %assetType);
|
|
|
|
AssetBrowser-->filterTree.selectItem(%assetTypeId);
|
|
|
|
%selectedItem = AssetBrowser-->filterTree.getSelectedItem();
|
|
AssetBrowser-->filterTree.scrollVisibleByObjectId(%selectedItem);
|
|
|
|
AssetBrowser-->filterTree.buildVisibleTree();
|
|
}
|
|
|
|
function AssetNameField::onReturn(%this)
|
|
{
|
|
%this.clearFirstResponder();
|
|
%this.setActive(false);
|
|
|
|
AssetBrowser.performRenameAsset(%this.originalAssetName, %this.getText());
|
|
}
|
|
|
|
//------------------------------------------------------------
|
|
function AssetBrowser::moveAsset(%this, %assetId, %destination)
|
|
{
|
|
if(EditAssetPopup.assetType $= "Folder")
|
|
{
|
|
//Do any cleanup required given the type
|
|
if(%this.isMethod("moveFolder"))
|
|
eval(%this @ ".moveFolder("@EditAssetPopup.assetId@",\""@%destination@"\");");
|
|
}
|
|
else
|
|
{
|
|
%assetDef = AssetDatabase.acquireAsset(%assetId);
|
|
%assetType = AssetDatabase.getAssetType(%assetId);
|
|
|
|
//Do any cleanup required given the type
|
|
if(%this.isMethod("move"@%assetType))
|
|
{
|
|
%command = %this @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %destination @ "\");";
|
|
eval(%this @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %destination @ "\");");
|
|
}
|
|
}
|
|
}
|
|
|
|
//------------------------------------------------------------
|
|
|
|
function AssetBrowser::duplicateAsset(%this, %targetModule)
|
|
{
|
|
if(%targetModule $= "")
|
|
{
|
|
//we need a module to duplicate to first
|
|
Canvas.pushDialog(AssetBrowser_selectModule);
|
|
AssetBrowser_selectModule.callback = "AssetBrowser.duplicateAsset";
|
|
return;
|
|
}
|
|
|
|
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
|
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
|
|
|
|
//this acts as a redirect based on asset type and will enact the appropriate function
|
|
//so for a GameObjectAsset, it'll become %this.duplicateGameObjectAsset(%assetDef, %targetModule);
|
|
//and call to the tools/assetBrowser/scripts/assetTypes/gameObject.cs file for implementation
|
|
if(%this.isMethod("duplicate"@%assetType))
|
|
eval(%this @ ".duplicate"@%assetType@"("@%assetDef@","@%targetModule@");");
|
|
}
|
|
|
|
function AssetBrowser::deleteAsset(%this)
|
|
{
|
|
//Find out what type it is
|
|
//%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
|
//%assetType = %assetDef.getClassName();
|
|
|
|
MessageBoxOKCancel("Warning!", "This will delete the selected content and the files associated to it, do you wish to continue?",
|
|
"AssetBrowser.confirmDeleteAsset();", "");
|
|
}
|
|
|
|
function AssetBrowser::confirmDeleteAsset(%this)
|
|
{
|
|
%currentSelectedItem = AssetBrowserFilterTree.getSelectedItem();
|
|
%currentItemParent = AssetBrowserFilterTree.getParentItem(%currentSelectedItem);
|
|
|
|
if(EditAssetPopup.assetType $= "Folder")
|
|
{
|
|
//Do any cleanup required given the type
|
|
if(%this.isMethod("deleteFolder"))
|
|
eval(%this @ ".deleteFolder(\""@EditAssetPopup.assetId@"\");");
|
|
}
|
|
else
|
|
{
|
|
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
|
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetType);
|
|
|
|
//Do any cleanup required given the type
|
|
if(%this.isMethod("delete"@%assetType))
|
|
eval(%this @ ".delete"@%assetType@"("@%assetDef@");");
|
|
|
|
AssetDatabase.deleteAsset(EditAssetPopup.assetId, false);
|
|
}
|
|
|
|
%this.loadFilters();
|
|
|
|
if(!AssetBrowserFilterTree.selectItem(%currentSelectedItem))
|
|
{
|
|
//if it failed, that means we deleted the last item in that category, and we need to do the parent
|
|
AssetBrowserFilterTree.selectItem(%currentItemParent);
|
|
AssetBrowserFilterTree.expandItem(%currentItemParent);
|
|
}
|
|
}
|