Adds handling for drag-and-drop import of files even if asset browser is not open. If world or gui editor are the active controls, then it will injest the incoming files and prompt what their destination module and path will be via a new popup window. After clicking OK, import continues into that destination.

Cleaned up commented lines from drag-and-drop functions.
Fixed issue where material icon on buttons in the object creator windows wouldn't display.
Fixed issue where it wasn't correctly binding cloud textures for BasicClouds object or ripple/foam/depth textures for water objects when newly created
Fixed issue where when double-clicking on a datablock type in the datablock editor, wasn't correctly going through the module selection process, making an invalid destination.
Added handling for Trigger object creation via TriggerData class
Standardized double-click handling of datablock entries in AB to respect double click action mode, and properly either open the datablock editor to the given datablock, or spawn it.
Made Create New Datablock prompt window indicate the destination module to be clearer where it's going if force-prompt of module setting is off.
This commit is contained in:
Areloch 2021-09-12 05:32:30 -05:00
parent a30f64506f
commit 5892ff7428
15 changed files with 469 additions and 90 deletions

View file

@ -95,7 +95,7 @@ function AssetBrowser_addModuleWindow::CreateNewModule(%this)
//force a refresh of our modules list
ModuleDatabase.ignoreLoadedGroups(true);
ModuleDatabase.scanModules();
ModuleDatabase.registerModule(%moduleFilePath, %newModuleName @ ".module");
%success = ModuleDatabase.loadExplicit(%newModuleName, 1);
ModuleDatabase.ignoreLoadedGroups(false);
@ -123,8 +123,9 @@ function AssetBrowserModuleList::refresh(%this)
%count = getWordCount(%moduleList);
for(%i=0; %i < %count; %i++)
{
%moduleName = getWord(%moduleList, %i);
%this.add(%moduleName.ModuleId, %i);
%moduleDef = getWord(%moduleList, %i);
%moduleName = %moduleDef.ModuleId;
%this.add(%moduleName, %i);
}
}

View file

@ -165,8 +165,14 @@ function getAssetTypeByFilename(%filePath)
function AssetBrowser::onBeginDropFiles( %this )
{
if(!AssetBrowser.isAwake())
if(!AssetBrowser.isAwake() || !AssetBrowser.isVisible())
{
if(GuiEditorIsActive())
GuiEditor.onBeginDropFiles();
else if(EditorIsActive())
EWorldEditor.onBeginDropFiles();
return;
}
error("% DragDrop - Beginning files dropping.");
if(!ImportAssetWindow.isAwake())
@ -175,45 +181,28 @@ function AssetBrowser::onBeginDropFiles( %this )
function AssetBrowser::onDropFile( %this, %filePath )
{
if(!%this.isVisible())
if(!AssetBrowser.isAwake() || !AssetBrowser.isVisible())
{
if(GuiEditorIsActive())
GuiEditor.onDropFile(%filePath);
else if(EditorIsActive())
EWorldEditor.onDropFile(%filePath);
return;
}
ImportAssetWindow.importer.addImportingFile(%filePath);
/*%fileExt = fileExt( %filePath );
//add it to our array!
if(isImageFormat(%fileExt))
%assetItem = %this.addImportingAsset("ImageAsset", %filePath);
else if( isShapeFormat(%fileExt))
%assetItem = %this.addImportingAsset("ShapeAsset", %filePath);
else if( isSoundFormat(%fileExt))
%assetItem = %this.addImportingAsset("SoundAsset", %filePath);
else if( %fileExt $= "." @ $TorqueScriptFileExtension || %fileExt $= "." @ $TorqueScriptFileExtension @ ".dso" )
%assetItem = %this.addImportingAsset("ScriptAsset", %filePath);
else if( %fileExt $= ".gui" || %fileExt $= ".gui.dso" )
%assetItem = %this.addImportingAsset("GUIAsset", %filePath);
else if (%fileExt $= ".zip")
%this.onDropZipFile(%filePath);
else if( %fileExt $= "")
%this.onDropFolder(%filePath);
if(%assetItem !$= "")
{
SessionImportAssetItems.add(%assetItem);
ImportAssetItems.add(%assetItem);
}*/
//Used to keep tabs on what files we were trying to import, used mainly in the event of
//adjusting configs and needing to completely reprocess the import
//ensure we're not doubling-up on files by accident
//if(ImportAssetWindow.importingFilesArray.getIndexFromKey(%filePath) == -1)
// ImportAssetWindow.importingFilesArray.add(%filePath);
}
function AssetBrowser::onDropZipFile(%this, %filePath)
{
if(!%this.isVisible())
if(!AssetBrowser.isAwake() || !AssetBrowser.isVisible())
{
if(GuiEditorIsActive())
GuiEditor.onDropZipFile(%filePath);
else if(EditorIsActive())
EWorldEditor.onDropZipFile(%filePath);
return;
}
%zip = new ZipObject();
%zip.openArchive(%filePath);
@ -226,27 +215,6 @@ function AssetBrowser::onDropZipFile(%this, %filePath)
%fileEntry = %zip.getFileEntry(%i);
%fileFrom = getField(%fileEntry, 0);
//First, we wanna scan to see if we have modules to contend with. If we do, we'll just plunk them in wholesale
//and not process their contents.
//If not modules, it's likely an art pack or other mixed files, so we'll import them as normal
/*if( (%fileExt $= ".png") || (%fileExt $= ".jpg") || (%fileExt $= ".bmp") || (%fileExt $= ".dds") )
%this.importAssetListArray.add("ImageAsset", %filePath);
else if( (%fileExt $= ".dae") || (%fileExt $= ".dts"))
%this.importAssetListArray.add("ShapeAsset", %filePath);
else if( (%fileExt $= ".ogg") || (%fileExt $= ".wav") || (%fileExt $= ".mp3"))
%this.importAssetListArray.add("SoundAsset", %filePath);
else if( (%fileExt $= ".gui") || (%fileExt $= ".gui.dso"))
%this.importAssetListArray.add("GUIAsset", %filePath);
//else if( (%fileExt $= "." @ $TorqueScriptFileExtension) || (%fileExt $= ".dso"))
// %this.importAssetListArray.add("Script", %filePath);
else if( (%fileExt $= ".mis"))
%this.importAssetListArray.add("LevelAsset", %filePath);*/
// For now, if it's a .tscript file, we'll assume it's a behavior.
//if (fileExt(%fileFrom) !$= "." @ $TorqueScriptFileExtension)
// continue;
%fileTo = expandFilename("^tools/assetBrowser/importTemp/") @ %fileFrom;
%zip.extractFile(%fileFrom, %fileTo);
//exec(%fileTo);
@ -259,8 +227,14 @@ function AssetBrowser::onDropZipFile(%this, %filePath)
function AssetBrowser::onDropFolder(%this, %filePath)
{
if(!%this.isVisible())
if(!AssetBrowser.isAwake() || !AssetBrowser.isVisible())
{
if(GuiEditorIsActive())
GuiEditor.onDropFolder(%filePath);
else if(EditorIsActive())
EWorldEditor.onDropFolder(%filePath);
return;
}
%zip = new ZipObject();
%zip.openArchive(%filePath);
@ -306,8 +280,14 @@ function AssetBrowser::onDropFolder(%this, %filePath)
function AssetBrowser::onEndDropFiles( %this )
{
if(!%this.isVisible())
if(!AssetBrowser.isAwake() || !AssetBrowser.isVisible())
{
if(GuiEditorIsActive())
GuiEditor.onEndDropFiles();
else if(EditorIsActive())
EWorldEditor.onEndDropFiles();
return;
}
ImportAssetWindow.refresh();
}

View file

@ -63,7 +63,22 @@ function AssetBrowser::buildDatablockPreview(%this, %assetDef, %previewData)
"\nDatablock Type: " @ %assetDef.getClassName() @
"\nDefinition Path: " @ %assetDef.getFilename();
%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"spawnDatablockObject\",\""@ %assetDef @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
if(%this.selectMode)
{
%previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
}
else
{
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
{
%previewData.doubleClickCommand = "DatablockEditorPlugin.openDatablock( "@%assetDef@" );";
}
else
{
%previewData.doubleClickCommand = "AssetBrowser.onDatablockEditorDropped( "@%assetDef@" );";
}
}
}
function spawnDatablockObject(%datablock)

View file

@ -106,8 +106,6 @@ function AssetBrowser::loadCreatorClasses(%this)
%guiClasses.sortk(true);
%guiClasses.echo();
%currentCat = "";
for(%i=0; %i < %guiClasses.count(); %i++)
{

View file

@ -0,0 +1,43 @@
function AssetBrowser_setAssetTarget::showDialog(%this, %callback)
{
AssetBrowser_setAssetTarget.callback = %callback;
Canvas.pushDialog(AssetBrowser_setAssetTarget);
}
function AssetBrowser_setAssetTarget::onWake(%this)
{
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress).ModuleId;
if(%targetModule $= "")
%targetModule = EditorSettings.value("Assets/New/defaultModule", "");
AssetBrowser_setAssetTarget-->moduleList.setText(%targetModule);
%moduleDef = ModuleDatabase.findModule(%targetModule);
%targetPath = AssetBrowser.dirHandler.currentAddress;
if(!startsWith(%targetPath, %moduleDef.ModulePath))
{
%targetPath = %moduleDef.ModulePath;
}
AssetBrowser_setAssetTarget-->targetPath.text = %targetPath;
}
function AssetBrowser_setAssetTargetWindow::onClose(%this)
{
Canvas.popDialog(AssetBrowser_setAssetTarget);
}
function setAssetTargetUpdatePath(%targetPath)
{
AssetBrowser_setAssetTarget-->targetPath.text = %targetPath;
}
function setAssetTarget()
{
AssetBrowser.dirHandler.currentAddress = AssetBrowser_setAssetTarget-->targetPath.text;
eval(AssetBrowser_setAssetTarget.callback);
Canvas.popDialog(AssetBrowser_setAssetTarget);
}