mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
Merge pull request #1493 from Areloch/MakeSelectedAMeshFix
Corrects handling for creating new folders via asset/AB workflow
This commit is contained in:
commit
b4ca6c6e88
2 changed files with 90 additions and 0 deletions
|
|
@ -1,5 +1,62 @@
|
||||||
AssetBrowser::registerFileType("FolderObjectType", "Folder", "/", false);
|
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()
|
function FolderObjectType::setupCreateNew()
|
||||||
{
|
{
|
||||||
AssetBrowser_newFolderNameTxt.text = "NewFolder";
|
AssetBrowser_newFolderNameTxt.text = "NewFolder";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,38 @@
|
||||||
AssetBrowser::registerAssetType("ShapeAsset", "Shapes");
|
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)
|
function ShapeAsset::onEdit(%this)
|
||||||
{
|
{
|
||||||
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
|
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue