mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Corrects handling for creating new folders via asset/AB workflow
Also fixes issue where Make Selected a Mesh action wasn't working properly because it lacked a ShapeAsset createNew method
This commit is contained in:
parent
6f92701330
commit
970394c42d
|
|
@ -1,5 +1,62 @@
|
|||
AssetBrowser::registerFileType("FolderObjectType", "Folder", "/", false);
|
||||
|
||||
function AssetBrowser::createNewFolder(%this)
|
||||
{
|
||||
AssetBrowser_newFolderNameTxt.text = "NewFolder";
|
||||
Canvas.pushDialog(AssetBrowser_newFolder, 99, true);
|
||||
|
||||
AssetBrowser_newFolderNameTxt.selectAllText();
|
||||
}
|
||||
|
||||
function AssetBrowser::doCreateNewFolder(%this)
|
||||
{
|
||||
%newFolderName = AssetBrowser_newFolderNameTxt.getText();
|
||||
|
||||
if(%newFolderName $= "")
|
||||
%newFolderName = "NewFolder";
|
||||
|
||||
if(SelectAssetPath.isAwake())
|
||||
{
|
||||
%currentAddressPath = SelectAssetPath-->folderTree.getItemValue(SelectAssetPath.selectedTreeItem) @ "/" @ SelectAssetPath-->folderTree.getItemText(SelectAssetPath.selectedTreeItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
%currentAddressPath = AssetBrowser.dirHandler.currentAddress;
|
||||
}
|
||||
|
||||
%newFolderIdx = "";
|
||||
%matched = true;
|
||||
%newFolderPath = "";
|
||||
while(%matched == true)
|
||||
{
|
||||
%newFolderPath = %currentAddressPath @ "/" @ %newFolderName @ %newFolderIdx;
|
||||
if(!isDirectory(%newFolderPath))
|
||||
{
|
||||
%matched = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
%newFolderIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
//make a dummy file
|
||||
%file = new FileObject();
|
||||
%file.openForWrite(%newFolderPath @ "/test");
|
||||
%file.close();
|
||||
|
||||
fileDelete(%newFolderPath @ "/test");
|
||||
|
||||
//refresh the directory
|
||||
AssetBrowser.loadDirectories();
|
||||
|
||||
%this.navigateTo(%newFolderPath);
|
||||
|
||||
//On the off chance we're trying to select a path, we'll update the select path window too
|
||||
if(SelectAssetPath.isAwake())
|
||||
SelectAssetPath.showDialog(%newFolderPath, SelectAssetPath.callback);
|
||||
}
|
||||
|
||||
function FolderObjectType::setupCreateNew()
|
||||
{
|
||||
AssetBrowser_newFolderNameTxt.text = "NewFolder";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,38 @@
|
|||
AssetBrowser::registerAssetType("ShapeAsset", "Shapes");
|
||||
|
||||
function ShapeAsset::onCreateNew()
|
||||
{
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%shapeFilePath = %assetPath @ %assetName @ ".dae";
|
||||
|
||||
%asset = new ShapeAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
friendlyName = $CurrentAssetBrowser.newAssetSettings.friendlyName;
|
||||
description = $CurrentAssetBrowser.newAssetSettings.description;
|
||||
fileName = %assetName @ ".dae";
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
Canvas.popDialog(AssetBrowser_newComponentAsset);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
$CurrentAssetBrowser.refresh();
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function ShapeAsset::onEdit(%this)
|
||||
{
|
||||
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
|
||||
|
|
|
|||
Loading…
Reference in a new issue