2018-01-28 15:30:17 -06:00
|
|
|
new SimGroup(AssetBrowserPreviewCache);
|
|
|
|
|
|
|
|
|
|
//AssetBrowser.addToolbarButton
|
|
|
|
|
function AssetBrowser::addToolbarButton(%this)
|
|
|
|
|
{
|
|
|
|
|
%filename = expandFilename("tools/gui/images/iconOpen");
|
|
|
|
|
%button = new GuiBitmapButtonCtrl() {
|
|
|
|
|
canSaveDynamicFields = "0";
|
|
|
|
|
internalName = AssetBrowserBtn;
|
|
|
|
|
Enabled = "1";
|
|
|
|
|
isContainer = "0";
|
|
|
|
|
Profile = "ToolsGuiButtonProfile";
|
|
|
|
|
HorizSizing = "right";
|
|
|
|
|
VertSizing = "bottom";
|
|
|
|
|
position = "180 0";
|
|
|
|
|
Extent = "25 19";
|
|
|
|
|
MinExtent = "8 2";
|
|
|
|
|
canSave = "1";
|
|
|
|
|
Visible = "1";
|
|
|
|
|
Command = "AssetBrowser.ShowDialog();";
|
|
|
|
|
tooltipprofile = "ToolsGuiToolTipProfile";
|
|
|
|
|
ToolTip = "Asset Browser";
|
|
|
|
|
hovertime = "750";
|
|
|
|
|
bitmap = %filename;
|
|
|
|
|
bitmapMode = "Centered";
|
|
|
|
|
buttonType = "PushButton";
|
|
|
|
|
groupNum = "0";
|
|
|
|
|
useMouseEvents = "0";
|
|
|
|
|
};
|
|
|
|
|
ToolsToolbarArray.add(%button);
|
|
|
|
|
EWToolsToolbar.setExtent((25 + 8) * (ToolsToolbarArray.getCount()) + 12 SPC "33");
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
function AssetBrowser::onAdd(%this)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::onWake(%this)
|
|
|
|
|
{
|
2019-05-04 11:49:42 -05:00
|
|
|
// manage preview array
|
|
|
|
|
if(!isObject(AssetPreviewArray))
|
|
|
|
|
new ArrayObject(AssetPreviewArray);
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
if(!isObject(%this.dirHandler))
|
|
|
|
|
%this.dirHandler = makedirectoryHandler(AssetBrowser-->filterTree, "cache,shaderCache", "");
|
2019-05-04 11:49:42 -05:00
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser-->filterTree.buildIconTable( ":tools/classIcons/Prefab:tools/classIcons/Prefab" @
|
|
|
|
|
":tools/classIcons/SimSet:tools/classIcons/SimSet");
|
2019-10-20 02:47:15 -05:00
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
%this.isReImportingAsset = false;
|
2019-12-03 00:09:18 -06:00
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
%this.coreModulesFilter = false;
|
2019-10-20 02:47:15 -05:00
|
|
|
%this.toolsModulesFilter = false;
|
2019-05-04 11:49:42 -05:00
|
|
|
%this.onlyShowModulesWithAssets = false;
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
%this.folderPanelState = true;
|
|
|
|
|
%this.folderPanelSplit = 0;
|
|
|
|
|
|
2019-07-15 00:34:18 -05:00
|
|
|
%this.templateFilesPath = "tools/assetBrowser/scripts/templateFiles/";
|
|
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
//First, build our our list of active modules
|
|
|
|
|
%modulesList = ModuleDatabase.findModules(true);
|
|
|
|
|
|
|
|
|
|
%nonDefaultModuleCount = 0;
|
|
|
|
|
|
|
|
|
|
for(%i=0; %i < getWordCount(%modulesList); %i++)
|
|
|
|
|
{
|
|
|
|
|
%moduleName = getWord(%modulesList, %i).ModuleId;
|
|
|
|
|
|
|
|
|
|
%moduleGroup = getWord(%modulesList, %i).Group;
|
|
|
|
|
if((%moduleGroup $= "Core" || %moduleGroup $= "Tools") && !%this.coreModulesFilter)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
%nonDefaultModuleCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(%nonDefaultModuleCount == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBoxYesNo( "Import Template Content?",
|
|
|
|
|
"You have no modules or content. Do you want to import a module from the template content?",
|
|
|
|
|
"AssetBrowser.ImportTemplateModules();", "" );
|
|
|
|
|
}
|
2019-10-20 02:47:15 -05:00
|
|
|
|
|
|
|
|
%this.setPreviewSize(EditorSettings.value("Assets/Browser/previewTileSize", "small"));
|
2019-05-04 11:49:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Filters
|
|
|
|
|
function AssetBrowser::showFilterPopup(%this)
|
|
|
|
|
{
|
|
|
|
|
BrowserVisibilityPopup.showPopup(Canvas);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::viewCoreModulesFilter(%this)
|
|
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
%oldVal = EditorSettings.value("Assets/Browser/showCoreModule", false);
|
|
|
|
|
%newVal = !%oldVal;
|
|
|
|
|
|
|
|
|
|
BrowserVisibilityPopup.checkItem(0,%newVal);
|
|
|
|
|
|
|
|
|
|
EditorSettings.setValue("Assets/Browser/showCoreModule", %newVal);
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser.refresh();
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::viewToolsModulesFilter(%this)
|
|
|
|
|
{
|
|
|
|
|
%oldVal = EditorSettings.value("Assets/Browser/showToolsModule", false);
|
|
|
|
|
%newVal = !%oldVal;
|
|
|
|
|
|
|
|
|
|
BrowserVisibilityPopup.checkItem(1,%newVal);
|
2019-05-04 11:49:42 -05:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
EditorSettings.setValue("Assets/Browser/showToolsModule", %newVal);
|
2019-05-04 11:49:42 -05:00
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser.refresh();
|
2019-05-04 11:49:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::viewPopulatedModulesFilter(%this)
|
|
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
%oldVal = EditorSettings.value("Assets/Browser/showOnlyPopulatedModule", false);
|
|
|
|
|
%newVal = !%oldVal;
|
2019-05-04 11:49:42 -05:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
BrowserVisibilityPopup.checkItem(2,%newVal);
|
|
|
|
|
|
|
|
|
|
EditorSettings.setValue("Assets/Browser/showOnlyPopulatedModule", %newVal);
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser.refresh();
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::toggleShowingFolders(%this)
|
|
|
|
|
{
|
|
|
|
|
%oldVal = EditorSettings.value("Assets/Browser/showFolders", false);
|
|
|
|
|
%newVal = !%oldVal;
|
|
|
|
|
|
|
|
|
|
BrowserVisibilityPopup.checkItem(4,%newVal);
|
|
|
|
|
|
|
|
|
|
EditorSettings.setValue("Assets/Browser/showFolders", %newVal);
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser.refresh();
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::toggleShowingEmptyFolders(%this)
|
|
|
|
|
{
|
|
|
|
|
%oldVal = EditorSettings.value("Assets/Browser/showEmptyFolders", false);
|
|
|
|
|
%newVal = !%oldVal;
|
|
|
|
|
|
|
|
|
|
BrowserVisibilityPopup.checkItem(5,%newVal);
|
|
|
|
|
|
|
|
|
|
EditorSettings.setValue("Assets/Browser/showEmptyFolders", %newVal);
|
2019-05-04 11:49:42 -05:00
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser.refresh();
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
function AssetBrowser::toggleAssetTypeFilter(%this, %assetTypeIdx)
|
2019-10-20 02:47:15 -05:00
|
|
|
{
|
|
|
|
|
%isChecked = AssetTypeListPopup.isItemChecked(%assetTypeIdx);
|
2019-11-24 06:52:34 -06:00
|
|
|
|
|
|
|
|
//Clear existing filters
|
|
|
|
|
if(%assetTypeIdx == 0)
|
|
|
|
|
{
|
|
|
|
|
for(%i=0; %i < AssetFilterTypeList.Count() + 1; %i++)
|
|
|
|
|
{
|
|
|
|
|
AssetTypeListPopup.checkItem(%i, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssetTypeListPopup.checkItem(0, true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(%isChecked)
|
|
|
|
|
{
|
|
|
|
|
%anyOtherFilters = false;
|
|
|
|
|
for(%i=1; %i < AssetFilterTypeList.Count() + 1; %i++)
|
|
|
|
|
{
|
|
|
|
|
if(%assetTypeIdx == %i)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if(AssetTypeListPopup.isItemChecked(%i))
|
|
|
|
|
{
|
|
|
|
|
%anyOtherFilters = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(%isChecked && !%anyOtherFilters)
|
|
|
|
|
{
|
|
|
|
|
for(%i=0; %i < AssetFilterTypeList.Count() + 1; %i++)
|
|
|
|
|
{
|
|
|
|
|
AssetTypeListPopup.checkItem(%i, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssetTypeListPopup.checkItem(0, true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AssetTypeListPopup.checkItem(0, false);
|
|
|
|
|
AssetTypeListPopup.checkItem(%assetTypeIdx, !%isChecked);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%this.rebuildAssetArray();
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
//
|
2018-01-28 15:30:17 -06:00
|
|
|
function AssetBrowser::selectAsset( %this, %asset )
|
|
|
|
|
{
|
|
|
|
|
if(AssetBrowser.selectCallback !$= "")
|
|
|
|
|
{
|
|
|
|
|
// The callback function should be ready to intake the returned material
|
|
|
|
|
//eval("materialEd_previewMaterial." @ %propertyField @ " = " @ %value @ ";");
|
|
|
|
|
if( AssetBrowser.returnType $= "name" )
|
|
|
|
|
{
|
|
|
|
|
eval( "" @ AssetBrowser.selectCallback @ "(" @ %name @ ");");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
%command = "" @ AssetBrowser.selectCallback @ "(\"" @ %asset @ "\");";
|
|
|
|
|
eval(%command);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//try just setting the asset
|
|
|
|
|
%this.changeAsset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Inspector.refresh();
|
|
|
|
|
|
|
|
|
|
AssetBrowser.hideDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::showDialog( %this, %AssetTypeFilter, %selectCallback, %targetObj, %fieldName, %returnType)
|
|
|
|
|
{
|
|
|
|
|
// Set the select callback
|
|
|
|
|
AssetBrowser.selectCallback = %selectCallback;
|
|
|
|
|
AssetBrowser.returnType = %returnType;
|
|
|
|
|
AssetBrowser.assetTypeFilter = %AssetTypeFilter;
|
|
|
|
|
AssetBrowser.fieldTargetObject = %targetObj;
|
|
|
|
|
AssetBrowser.fieldTargetName = %fieldName;
|
|
|
|
|
|
2019-06-13 00:37:12 -05:00
|
|
|
Canvas.pushDialog(AssetBrowser);
|
2018-01-28 15:30:17 -06:00
|
|
|
AssetBrowser.setVisible(1);
|
|
|
|
|
AssetBrowserWindow.setVisible(1);
|
|
|
|
|
AssetBrowserWindow.selectWindow();
|
|
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
//If we're special-case filtering(like for selecting a given type), then ignore our normal
|
|
|
|
|
//visibility filter
|
|
|
|
|
if(%AssetTypeFilter !$= "")
|
|
|
|
|
{
|
|
|
|
|
AssetBrowser.toggleAssetTypeFilter(0);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
if(%selectCallback $= "")
|
|
|
|
|
{
|
|
|
|
|
//we're not in selection mode, so just hide the select button
|
|
|
|
|
%this-->SelectButton.setHidden(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
%this-->SelectButton.setHidden(false);
|
|
|
|
|
}
|
2019-12-03 00:09:18 -06:00
|
|
|
|
|
|
|
|
AssetBrowser.loadDirectories();
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::hideDialog( %this )
|
|
|
|
|
{
|
|
|
|
|
AssetBrowser.setVisible(1);
|
|
|
|
|
AssetBrowserWindow.setVisible(1);
|
|
|
|
|
Canvas.popDialog(AssetBrowser_addModule);
|
|
|
|
|
Canvas.popDialog(ImportAssetWindow);
|
|
|
|
|
|
|
|
|
|
Canvas.popDialog(AssetBrowser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::buildPreviewArray( %this, %asset, %moduleName )
|
|
|
|
|
{
|
2019-05-04 11:49:42 -05:00
|
|
|
if(!isObject(%this.previewData))
|
|
|
|
|
{
|
|
|
|
|
%this.previewData = new ScriptObject();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
AssetPreviewArray.empty();
|
|
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
%previewImage = "core/art/warnmat";
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
if(ModuleDatabase.findModule(%moduleName, 1) !$= "")
|
|
|
|
|
{
|
|
|
|
|
%assetDesc = AssetDatabase.acquireAsset(%asset);
|
|
|
|
|
%assetName = AssetDatabase.getAssetName(%asset);
|
|
|
|
|
%assetType = AssetDatabase.getAssetType(%asset);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
%fullPath = %moduleName !$= "" ? %moduleName @ "/" @ %asset : %asset;
|
|
|
|
|
%fullPath = strreplace(%fullPath, "/", "_");
|
|
|
|
|
|
|
|
|
|
if(isObject(%fullPath))
|
2019-11-24 06:52:34 -06:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
%assetDesc = %fullPath;
|
|
|
|
|
else
|
|
|
|
|
%assetDesc = new ScriptObject(%fullPath);
|
|
|
|
|
|
|
|
|
|
%assetDesc.dirPath = %moduleName;
|
|
|
|
|
%assetDesc.assetName = %asset;
|
|
|
|
|
%assetDesc.description = %moduleName @ "/" @ %asset;
|
|
|
|
|
%assetDesc.assetType = "Folder";
|
|
|
|
|
|
|
|
|
|
%assetName = %asset;
|
|
|
|
|
%assetType = "Folder";
|
|
|
|
|
}
|
2019-11-24 06:52:34 -06:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
%previewSize = %this.previewSize SPC %this.previewSize;
|
|
|
|
|
%previewBounds = 20;
|
2018-01-28 15:30:17 -06:00
|
|
|
|
|
|
|
|
%tooltip = %assetName;
|
|
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
%doubleClickCommand = "AssetBrowser.editAsset( "@%assetDesc@" );";
|
|
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
if(%assetType $= "ShapeAsset")
|
|
|
|
|
{
|
2019-11-24 06:52:34 -06:00
|
|
|
%previewButton = AssetPreviewButtonsTemplate-->ShapeAssetPreviewButton.deepClone();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
%previewButton = AssetPreviewButtonsTemplate-->GeneralAssetPreviewButton.deepClone();
|
|
|
|
|
}
|
2019-05-04 11:49:42 -05:00
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
%previewButton.extent = %previewSize.x + %previewBounds SPC %previewSize.y + %previewBounds + 24;
|
|
|
|
|
%previewButton.assetName = %assetName;
|
|
|
|
|
%previewButton.moduleName = %moduleName;
|
|
|
|
|
%previewButton.assetType = %assetType;
|
|
|
|
|
|
|
|
|
|
//Build out the preview
|
|
|
|
|
%buildCommand = %this @ ".build" @ %assetType @ "Preview(" @ %assetDesc @ "," @ %this.previewData @ ");";
|
|
|
|
|
eval(%buildCommand);
|
|
|
|
|
|
|
|
|
|
//debug dump
|
|
|
|
|
%tooltip = %this.previewData.tooltip;
|
|
|
|
|
%assetName = %this.previewData.assetName;
|
|
|
|
|
%previewImage = %this.previewData.previewImage;
|
|
|
|
|
%doubleClickCommand = %this.previewData.doubleClickCommand;
|
|
|
|
|
|
2019-12-23 12:37:55 -06:00
|
|
|
%previewButton-->button.assetName = %assetName;
|
|
|
|
|
%previewButton-->button.moduleName = %moduleName;
|
|
|
|
|
%previewButton-->button.assetType = %assetType;
|
|
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
if(%assetType $= "ShapeAsset")
|
|
|
|
|
{
|
|
|
|
|
%previewButton-->shapeAssetView.setModel(%previewImage);
|
|
|
|
|
%previewButton-->shapeAssetView.extent = %previewSize;
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-11-24 06:52:34 -06:00
|
|
|
%previewButton-->assetPreviewImage.bitmap = %this.previewData.previewImage;
|
|
|
|
|
%previewButton-->assetPreviewImage.extent = %previewSize;
|
|
|
|
|
}
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
%previewButton-->AssetPreviewBorderButton.extent = %previewSize;
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
//%previewButton-->AssetPreviewButton.internalName = %this.previewData.assetName@"Border";
|
|
|
|
|
%previewButton-->AssetPreviewButton.extent = %previewSize.x + %previewBounds SPC %previewSize.y + 24;
|
|
|
|
|
%previewButton-->AssetPreviewButton.tooltip = %this.previewData.tooltip;
|
|
|
|
|
%previewButton-->AssetPreviewButton.Command = "AssetBrowser.updateSelection( $ThisControl.getParent().assetName, $ThisControl.getParent().moduleName );";
|
|
|
|
|
%previewButton-->AssetPreviewButton.altCommand = %this.previewData.doubleClickCommand;
|
|
|
|
|
//%previewButton-->AssetPreviewButton.icon = %this.previewData.previewImage;
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
%previewButton-->AssetNameLabel.position = 0 SPC %previewSize.y + %previewBounds - 16;
|
|
|
|
|
%previewButton-->AssetNameLabel.extent = %previewSize.x + %previewBounds SPC 16;
|
|
|
|
|
%previewButton-->AssetNameLabel.text = %this.previewData.assetName;
|
|
|
|
|
%previewButton-->AssetNameLabel.originalAssetName = %this.previewData.assetName;
|
|
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
// add to the gui control array
|
2019-11-24 06:52:34 -06:00
|
|
|
AssetBrowser-->assetList.add(%previewButton);
|
2018-01-28 15:30:17 -06:00
|
|
|
|
|
|
|
|
// add to the array object for reference later
|
2019-05-04 11:49:42 -05:00
|
|
|
AssetPreviewArray.add( %previewButton, %this.previewData.previewImage );
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
function AssetBrowser::refresh(%this)
|
|
|
|
|
{
|
|
|
|
|
%this.navigateTo(%this.dirHandler.currentAddress);
|
|
|
|
|
}
|
2019-10-20 02:47:15 -05:00
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
function AssetPreviewButton::onClick(%this)
|
|
|
|
|
{
|
|
|
|
|
echo("CLICKED AN ASSET PREVIEW BUTTON");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetPreviewButton::onDoubleClick(%this)
|
|
|
|
|
{
|
|
|
|
|
echo("DOUBLE CLICKED AN ASSET PREVIEW BUTTON");
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
function AssetBrowser::loadDirectories( %this )
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
|
|
|
|
AssetBrowser-->filterTree.clear();
|
2019-10-20 02:47:15 -05:00
|
|
|
|
|
|
|
|
%dataItem = AssetBrowser-->filterTree.insertItem(0, "Data");
|
2019-12-03 00:09:18 -06:00
|
|
|
%this.dirHandler.loadFolders("Data", %dataItem);
|
2019-10-20 02:47:15 -05:00
|
|
|
|
|
|
|
|
//If set to, show core
|
|
|
|
|
if(%this.coreModulesFilter)
|
|
|
|
|
{
|
|
|
|
|
%coreItem = AssetBrowser-->filterTree.insertItem(0, "Core");
|
2019-12-03 00:09:18 -06:00
|
|
|
%this.dirHandler.loadFolders("Core", %coreItem);
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//If set to, show tools
|
|
|
|
|
if(%this.toolsModulesFilter)
|
|
|
|
|
{
|
|
|
|
|
%toolsItem = AssetBrowser-->filterTree.insertItem(0, "Tools");
|
2019-12-03 00:09:18 -06:00
|
|
|
%this.dirHandler.loadFolders("Tools", %toolsItem);
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
AssetPreviewArray.empty();
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
AssetBrowser-->filterTree.buildVisibleTree(true);
|
|
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
//Remove any modules that have no assets if we have that filter on
|
|
|
|
|
if(%this.onlyShowModulesWithAssets)
|
|
|
|
|
{
|
|
|
|
|
for(%i=0; %i < getWordCount(%modulesList); %i++)
|
|
|
|
|
{
|
|
|
|
|
%moduleName = getWord(%modulesList, %i).ModuleId;
|
|
|
|
|
|
|
|
|
|
%moduleItemId = AssetBrowser-->filterTree.findItemByName(%moduleName);
|
|
|
|
|
|
|
|
|
|
if(AssetBrowser-->filterTree.isParentItem(%moduleItemId) == false)
|
|
|
|
|
AssetBrowser-->filterTree.removeItem(%moduleItemId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
//special handling for selections
|
|
|
|
|
if(AssetBrowser.newModuleId !$= "")
|
|
|
|
|
{
|
|
|
|
|
AssetBrowser-->filterTree.clearSelection();
|
|
|
|
|
%newModuleItem = AssetBrowser-->filterTree.findItemByName(AssetBrowser.newModuleId);
|
|
|
|
|
AssetBrowser-->filterTree.selectItem(%newModuleItem);
|
|
|
|
|
AssetBrowser.newModuleId = "";
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
%dataItem = AssetBrowser-->filterTree.findItemByName("Data");
|
|
|
|
|
AssetBrowser-->filterTree.expandItem(%dataItem);
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser.dirHandler.expandTreeToAddress(AssetBrowser.dirHandler.currentAddress);
|
2019-10-20 02:47:15 -05:00
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
%selectedItem = AssetBrowser.dirHandler.getFolderTreeItemFromAddress(AssetBrowser.dirHandler.currentAddress);
|
2018-01-28 15:30:17 -06:00
|
|
|
AssetBrowser-->filterTree.scrollVisibleByObjectId(%selectedItem);
|
2019-05-04 11:49:42 -05:00
|
|
|
|
|
|
|
|
AssetBrowser-->filterTree.buildVisibleTree();
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser.refresh();
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::updateSelection( %this, %asset, %moduleName )
|
|
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
//If we're navigating a folder, just nav to it and be done
|
|
|
|
|
/*if(isDirectory(%moduleName))
|
|
|
|
|
{
|
|
|
|
|
AssetBrowser.navigateTo(%moduleName @ "/" @ %asset);
|
|
|
|
|
return;
|
|
|
|
|
}*/
|
2018-01-28 15:30:17 -06:00
|
|
|
|
|
|
|
|
%isAssetBorder = 0;
|
|
|
|
|
eval("%isAssetBorder = isObject(AssetBrowser-->"@%asset@"Border);");
|
|
|
|
|
if( %isAssetBorder )
|
|
|
|
|
{
|
|
|
|
|
eval( "AssetBrowser-->"@%asset@"Border.setStateOn(1);");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%isAssetBorderPrevious = 0;
|
|
|
|
|
eval("%isAssetBorderPrevious = isObject(AssetBrowser-->"@%this.prevSelectedMaterialHL@"Border);");
|
|
|
|
|
if( %isAssetBorderPrevious )
|
|
|
|
|
{
|
|
|
|
|
eval( "AssetBrowser-->"@%this.prevSelectedMaterialHL@"Border.setStateOn(0);");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssetBrowser.selectedMaterial = %asset;
|
|
|
|
|
AssetBrowser.selectedAsset = %moduleName@":"@%asset;
|
|
|
|
|
AssetBrowser.selectedAssetDef = AssetDatabase.acquireAsset(AssetBrowser.selectedAsset);
|
|
|
|
|
//AssetBrowser.selectedPreviewImagePath = %previewImagePath;
|
|
|
|
|
|
|
|
|
|
%this.prevSelectedMaterialHL = %asset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//needs to be deleted with the persistence manager and needs to be blanked out of the matmanager
|
|
|
|
|
//also need to update instances... i guess which is the tricky part....
|
|
|
|
|
function AssetBrowser::showDeleteDialog( %this )
|
|
|
|
|
{
|
|
|
|
|
%material = AssetBrowser.selectedMaterial;
|
|
|
|
|
%secondFilter = "MaterialFilterMappedArray";
|
|
|
|
|
%secondFilterName = "Mapped";
|
|
|
|
|
|
|
|
|
|
for( %i = 0; %i < MaterialFilterUnmappedArray.count(); %i++ )
|
|
|
|
|
{
|
|
|
|
|
if( MaterialFilterUnmappedArray.getValue(%i) $= %material )
|
|
|
|
|
{
|
|
|
|
|
%secondFilter = "MaterialFilterUnmappedArray";
|
|
|
|
|
%secondFilterName = "Unmapped";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( isObject( %material ) )
|
|
|
|
|
{
|
|
|
|
|
MessageBoxYesNoCancel("Delete Material?",
|
|
|
|
|
"Are you sure you want to delete<br><br>" @ %material.getName() @ "<br><br> Material deletion won't take affect until the engine is quit.",
|
|
|
|
|
"AssetBrowser.deleteMaterial( " @ %material @ ", " @ %secondFilter @ ", " @ %secondFilterName @" );",
|
|
|
|
|
"",
|
|
|
|
|
"" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::deleteMaterial( %this, %materialName, %secondFilter, %secondFilterName )
|
|
|
|
|
{
|
|
|
|
|
if( !isObject( %materialName ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for( %i = 0; %i <= MaterialFilterAllArray.countValue( %materialName ); %i++)
|
|
|
|
|
{
|
|
|
|
|
%index = MaterialFilterAllArray.getIndexFromValue( %materialName );
|
|
|
|
|
MaterialFilterAllArray.erase( %index );
|
|
|
|
|
}
|
|
|
|
|
MaterialFilterAllArrayCheckbox.setText("All ( " @ MaterialFilterAllArray.count() - 1 @ " ) ");
|
|
|
|
|
|
|
|
|
|
%checkbox = %secondFilter @ "Checkbox";
|
|
|
|
|
for( %k = 0; %k <= %secondFilter.countValue( %materialName ); %k++)
|
|
|
|
|
{
|
|
|
|
|
%index = %secondFilter.getIndexFromValue( %materialName );
|
|
|
|
|
%secondFilter.erase( %index );
|
|
|
|
|
}
|
|
|
|
|
%checkbox.setText( %secondFilterName @ " ( " @ %secondFilter.count() - 1 @ " ) ");
|
|
|
|
|
|
|
|
|
|
for( %i = 0; %materialName.getFieldValue("materialTag" @ %i) !$= ""; %i++ )
|
|
|
|
|
{
|
|
|
|
|
%materialTag = %materialName.getFieldValue("materialTag" @ %i);
|
|
|
|
|
|
|
|
|
|
for( %j = AssetBrowser.staticFilterObjects; %j < AssetBrowser-->filterArray.getCount() ; %j++ )
|
|
|
|
|
{
|
|
|
|
|
if( %materialTag $= AssetBrowser-->filterArray.getObject(%j).getObject(0).filter )
|
|
|
|
|
{
|
|
|
|
|
%count = getWord( AssetBrowser-->filterArray.getObject(%j).getObject(0).getText(), 2 );
|
|
|
|
|
%count--;
|
|
|
|
|
AssetBrowser-->filterArray.getObject(%j).getObject(0).setText( %materialTag @ " ( "@ %count @ " )");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnlistedMaterials.add( "unlistedMaterials", %materialName );
|
|
|
|
|
|
|
|
|
|
if( %materialName.getFilename() !$= "" &&
|
|
|
|
|
%materialName.getFilename() !$= "tools/gui/AssetBrowser.ed.gui" &&
|
|
|
|
|
%materialName.getFilename() !$= "tools/materialEditor/scripts/materialEditor.ed.cs" )
|
|
|
|
|
{
|
|
|
|
|
AssetBrowserPerMan.removeObjectFromFile(%materialName);
|
|
|
|
|
AssetBrowserPerMan.saveDirty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssetBrowser.preloadFilter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::thumbnailCountUpdate(%this)
|
|
|
|
|
{
|
|
|
|
|
$Pref::AssetBrowser::ThumbnailCountIndex = AssetBrowser-->materialPreviewCountPopup.getSelected();
|
|
|
|
|
AssetBrowser.LoadFilter( AssetBrowser.currentFilter, AssetBrowser.currentStaticFilter );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::toggleTagFilterPopup(%this)
|
|
|
|
|
{
|
|
|
|
|
if(TagFilterWindow.visible)
|
|
|
|
|
TagFilterWindow.visible = false;
|
|
|
|
|
else
|
|
|
|
|
TagFilterWindow.visible = true;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
%assetQuery = new AssetQuery();
|
|
|
|
|
%numAssetsFound = AssetDatabase.findAllAssets(%assetQuery);
|
|
|
|
|
|
|
|
|
|
for( %i=0; %i < %numAssetsFound; %i++)
|
|
|
|
|
{
|
|
|
|
|
%assetId = %assetQuery.getAsset(%i);
|
|
|
|
|
|
|
|
|
|
//first, get the asset's module, as our major categories
|
|
|
|
|
%module = AssetDatabase.getAssetModule(%assetId);
|
|
|
|
|
|
|
|
|
|
%moduleName = %module.moduleId;
|
|
|
|
|
|
|
|
|
|
//check that we don't re-add it
|
|
|
|
|
%moduleItemId = AssetBrowser-->filterTree.findItemByName(%moduleName);
|
|
|
|
|
|
|
|
|
|
if(%moduleItemId == -1 || %moduleItemId == 0)
|
2019-12-03 00:09:18 -06:00
|
|
|
%moduleItemId = AssetBrowser-->filterTree.insertItem(1, %module.moduleId, "", "", 1, 2);
|
2018-01-28 15:30:17 -06:00
|
|
|
|
|
|
|
|
//now, add the asset's category
|
|
|
|
|
%assetType = AssetDatabase.getAssetCategory(%assetId);
|
|
|
|
|
|
|
|
|
|
%checkBox = new GuiCheckBoxCtrl()
|
|
|
|
|
{
|
|
|
|
|
canSaveDynamicFields = "0";
|
|
|
|
|
isContainer = "0";
|
|
|
|
|
Profile = "ToolsGuiCheckBoxListProfile";
|
|
|
|
|
HorizSizing = "right";
|
|
|
|
|
VertSizing = "bottom";
|
|
|
|
|
Position = "0 0";
|
|
|
|
|
Extent = (%textLength * 4) @ " 18";
|
|
|
|
|
MinExtent = "8 2";
|
|
|
|
|
canSave = "1";
|
|
|
|
|
Visible = "1";
|
|
|
|
|
Variable = %var;
|
|
|
|
|
tooltipprofile = "ToolsGuiToolTipProfile";
|
|
|
|
|
hovertime = "1000";
|
|
|
|
|
text = %text;
|
|
|
|
|
groupNum = "-1";
|
|
|
|
|
buttonType = "ToggleButton";
|
|
|
|
|
useMouseEvents = "0";
|
|
|
|
|
useInactiveState = "0";
|
|
|
|
|
Command = %cmd;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TagFilterList.add(%checkBox);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::changeAsset(%this)
|
|
|
|
|
{
|
|
|
|
|
//alright, we've selectd an asset for a field, so time to set it!
|
|
|
|
|
%cmd = %this.fieldTargetObject @ "." @ %this.fieldTargetName @ "=\"" @ %this.selectedAsset @ "\";";
|
|
|
|
|
echo("Changing asset via the " @ %cmd @ " command");
|
|
|
|
|
eval(%cmd);
|
2019-05-04 11:49:42 -05:00
|
|
|
|
|
|
|
|
//Flag us as dirty for editing purposes
|
|
|
|
|
EWorldEditor.setSceneAsDirty();
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::reImportAsset(%this)
|
|
|
|
|
{
|
|
|
|
|
//Find out what type it is
|
|
|
|
|
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
|
|
|
|
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
|
|
|
|
|
|
|
|
|
|
if(%assetType $= "ShapeAsset" || %assetType $= "ImageAsset" || %assetType $= "SoundAsset")
|
|
|
|
|
{
|
|
|
|
|
AssetBrowser.isAssetReImport = true;
|
|
|
|
|
AssetBrowser.reImportingAssetId = EditAssetPopup.assetId;
|
|
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
%reimportingPath = %assetDef.originalFilePath;
|
|
|
|
|
|
|
|
|
|
//first, double-check we have an originating file. if we don't then we need to basically go out looking for it
|
|
|
|
|
if(!isFile(%assetDef.originalFilePath))
|
|
|
|
|
{
|
|
|
|
|
//if(%assetType $= "ImageAsset")
|
|
|
|
|
// %filters = "";
|
|
|
|
|
|
|
|
|
|
%dlg = new OpenFileDialog()
|
|
|
|
|
{
|
|
|
|
|
Filters = "(All Files (*.*)|*.*|";
|
|
|
|
|
DefaultFile = %currentFile;
|
|
|
|
|
ChangePath = false;
|
|
|
|
|
MustExist = true;
|
|
|
|
|
MultipleFiles = false;
|
|
|
|
|
forceRelativePath = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if ( %dlg.Execute() )
|
|
|
|
|
{
|
|
|
|
|
%reimportingPath = %dlg.FileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%dlg.delete();
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
AssetBrowser.onBeginDropFiles();
|
2019-05-04 11:49:42 -05:00
|
|
|
AssetBrowser.onDropFile(%reimportingPath);
|
2018-01-28 15:30:17 -06:00
|
|
|
AssetBrowser.onEndDropFiles();
|
|
|
|
|
|
|
|
|
|
%module = AssetDatabase.getAssetModule(EditAssetPopup.assetId);
|
|
|
|
|
|
|
|
|
|
//get the selected module data
|
|
|
|
|
ImportAssetModuleList.setText(%module.ModuleId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// RMB context popups
|
2018-01-28 15:30:17 -06:00
|
|
|
function AssetPreviewButton::onRightClick(%this)
|
|
|
|
|
{
|
|
|
|
|
AssetBrowser.selectedAssetPreview = %this.getParent();
|
|
|
|
|
EditAssetPopup.assetId = %this.getParent().moduleName @ ":" @ %this.getParent().assetName;
|
2019-10-20 02:47:15 -05:00
|
|
|
EditAssetPopup.assetType = %this.getParent().assetType;
|
2018-01-28 15:30:17 -06:00
|
|
|
%assetType = %this.getParent().assetType;
|
|
|
|
|
|
|
|
|
|
//Do some enabling/disabling of options depending on asset type
|
|
|
|
|
EditAssetPopup.enableItem(0, true);
|
|
|
|
|
EditAssetPopup.enableItem(7, true);
|
|
|
|
|
|
|
|
|
|
//Is it an editable type?
|
2019-05-04 11:49:42 -05:00
|
|
|
if(%assetType $= "ImageAsset" /*|| %assetType $= "GameObjectAsset"*/ || %assetType $= "CppAsset" || %assetType $= "SoundAsset")
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
|
|
|
|
EditAssetPopup.enableItem(0, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Is it an importable type?
|
|
|
|
|
if(%assetType $= "GameObjectAsset" || %assetType $= "ComponentAsset" || %assetType $= "GUIAsset" || %assetType $= "LevelAsset"
|
|
|
|
|
|| %assetType $= "MaterialAsset" || %assetType $= "ParticleAsset" || %assetType $= "PostEffectAsset" || %assetType $= "ScriptAsset"
|
|
|
|
|
|| %assetType $= "StateMachineAsset")
|
|
|
|
|
{
|
|
|
|
|
EditAssetPopup.enableItem(7, false);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
if(%assetType $= "LevelAsset")
|
|
|
|
|
EditLevelAssetPopup.showPopup(Canvas);
|
2019-10-20 02:47:15 -05:00
|
|
|
else if(%assetType $= "Folder")
|
2019-12-03 00:09:18 -06:00
|
|
|
{
|
2019-12-23 12:37:55 -06:00
|
|
|
EditFolderPopup.dirPath = %this.getParent().moduleName @ "/" @ %this.getParent().assetName;
|
2019-10-20 02:47:15 -05:00
|
|
|
EditFolderPopup.showPopup(Canvas);
|
2019-12-03 00:09:18 -06:00
|
|
|
}
|
2019-05-04 11:49:42 -05:00
|
|
|
else
|
|
|
|
|
EditAssetPopup.showPopup(Canvas);
|
2019-10-20 02:47:15 -05:00
|
|
|
|
|
|
|
|
if(%assetType $= "Folder")
|
|
|
|
|
{
|
|
|
|
|
EditAssetPopup.assetId = %this.getParent().moduleName @ "/" @ %this.getParent().assetName;
|
|
|
|
|
}
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
//function AssetListPanel::onRightMouseDown(%this)
|
|
|
|
|
function AssetListPanelInputs::onRightMouseDown(%this)
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
|
|
|
|
AddNewAssetPopup.showPopup(Canvas);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
function AssetBrowserFilterTree::onRightMouseDown(%this, %itemId)
|
|
|
|
|
{
|
2019-11-18 03:30:04 -06:00
|
|
|
%count = %this.getSelectedItemsCount();
|
2019-10-20 02:47:15 -05:00
|
|
|
if( %this.getSelectedItemsCount() > 0 && %itemId != 1)
|
|
|
|
|
{
|
|
|
|
|
//AddNewAssetPopup.showPopup(Canvas);
|
|
|
|
|
|
|
|
|
|
//We have something clicked, so figure out if it's a sub-filter or a module filter, then push the correct
|
|
|
|
|
//popup menu
|
|
|
|
|
if(%this.getParentItem(%itemId) == 1)
|
|
|
|
|
{
|
|
|
|
|
//yep, module, push the all-inclusive popup
|
|
|
|
|
EditModulePopup.showPopup(Canvas);
|
|
|
|
|
//also set the module value for creation info
|
|
|
|
|
AssetBrowser.selectedModule = %this.getItemText(%itemId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-11-06 00:23:07 -06:00
|
|
|
EditFolderPopup.showPopup(Canvas);
|
2019-12-03 00:09:18 -06:00
|
|
|
EditFolderPopup.assetType = "Folder";
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
|
|
|
|
}
|
2019-11-18 03:30:04 -06:00
|
|
|
else if(%itemId == 1)
|
|
|
|
|
{
|
|
|
|
|
AddNewModulePopup.showPopup(Canvas);
|
|
|
|
|
}
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
function AssetBrowser::showVisibiltyOptions(%this)
|
|
|
|
|
{
|
|
|
|
|
BrowserVisibilityPopup.showPopup(Canvas);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::showFilterOptions(%this)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// Preview tile handling
|
|
|
|
|
function AssetBrowser::setPreviewSize(%this, %size)
|
|
|
|
|
{
|
|
|
|
|
AssetPreviewSizePopup.checkItem(0, false);
|
|
|
|
|
AssetPreviewSizePopup.checkItem(1, false);
|
|
|
|
|
AssetPreviewSizePopup.checkItem(2, false);
|
|
|
|
|
|
|
|
|
|
%this.previewSize = 80; //default to small
|
|
|
|
|
|
|
|
|
|
if(%size $= "Small")
|
|
|
|
|
{
|
|
|
|
|
%this.previewSize = 80;
|
|
|
|
|
AssetPreviewSizePopup.checkItem(0, true);
|
|
|
|
|
}
|
|
|
|
|
else if(%size $= "Medium")
|
|
|
|
|
{
|
|
|
|
|
%this.previewSize = 120;
|
|
|
|
|
AssetPreviewSizePopup.checkItem(1, true);
|
|
|
|
|
}
|
|
|
|
|
else if(%size $= "Large")
|
|
|
|
|
{
|
|
|
|
|
%this.previewSize = 160;
|
2019-11-24 06:52:34 -06:00
|
|
|
AssetPreviewSizePopup.checkItem(2, true);
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EditorSettings.setValue("Assets/Browser/previewTileSize", %size);
|
|
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
%this.rebuildAssetArray();
|
2019-10-20 02:47:15 -05:00
|
|
|
}
|
|
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
function AssetBrowser::refreshPreviews(%this)
|
|
|
|
|
{
|
|
|
|
|
AssetBrowserFilterTree.onSelect(AssetBrowser.selectedItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowserFilterTree::onSelect(%this, %itemId)
|
|
|
|
|
{
|
|
|
|
|
if(%itemId == 1)
|
|
|
|
|
//can't select root
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
//Make sure we have an actual module selected!
|
|
|
|
|
%parentId = %this.getParentItem(%itemId);
|
2019-10-20 02:47:15 -05:00
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
%name = %this.getItemText(%itemId);
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
%breadcrumbPath = %this.getItemValue(%itemId);
|
|
|
|
|
if(%breadcrumbPath !$= "")
|
|
|
|
|
%breadcrumbPath = %breadcrumbPath @ "/" @ %this.getItemText(%itemId);
|
2018-01-28 15:30:17 -06:00
|
|
|
else
|
2019-10-20 02:47:15 -05:00
|
|
|
%breadcrumbPath = %this.getItemText(%itemId);
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
if(%breadcrumbPath $= "")
|
2019-12-03 00:09:18 -06:00
|
|
|
%breadcrumbPath = AssetBrowser.dirHandler.currentAddress;
|
2019-11-24 06:52:34 -06:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
AssetBrowser.navigateTo(%breadcrumbPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::rebuildAssetArray(%this)
|
|
|
|
|
{
|
2019-12-03 00:09:18 -06:00
|
|
|
%breadcrumbPath = AssetBrowser.dirHandler.currentAddress;
|
2019-10-20 02:47:15 -05:00
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
// we have to empty out the list; so when we create new guicontrols, these dont linger
|
2019-10-20 02:47:15 -05:00
|
|
|
AssetBrowser-->assetList.deleteAllObjects();
|
2018-01-28 15:30:17 -06:00
|
|
|
AssetPreviewArray.empty();
|
|
|
|
|
|
|
|
|
|
%assetArray = new ArrayObject();
|
2019-10-20 02:47:15 -05:00
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
//First, Query for our assets
|
|
|
|
|
%assetQuery = new AssetQuery();
|
|
|
|
|
%numAssetsFound = AssetDatabase.findAllAssets(%assetQuery);
|
2019-11-24 06:52:34 -06:00
|
|
|
|
|
|
|
|
%finalAssetCount = 0;
|
2019-10-20 02:47:15 -05:00
|
|
|
|
2018-01-28 15:30:17 -06:00
|
|
|
//now, we'll iterate through, and find the assets that are in this module, and this category
|
|
|
|
|
for( %i=0; %i < %numAssetsFound; %i++)
|
|
|
|
|
{
|
|
|
|
|
%assetId = %assetQuery.getAsset(%i);
|
2019-10-20 02:47:15 -05:00
|
|
|
|
|
|
|
|
%assetPath = makeRelativePath(AssetDatabase.getAssetFilePath(%assetId));
|
|
|
|
|
%assetBasePath = filePath(%assetPath);
|
|
|
|
|
|
|
|
|
|
//clean up the path
|
|
|
|
|
%assetBasePath = strreplace(%assetBasePath, "//", "/");
|
|
|
|
|
|
|
|
|
|
if(%assetBasePath $= %breadcrumbPath)
|
|
|
|
|
{
|
|
|
|
|
//first, get the asset's module, as our major categories
|
|
|
|
|
%module = AssetDatabase.getAssetModule(%assetId);
|
|
|
|
|
%moduleName = %module.moduleId;
|
|
|
|
|
|
|
|
|
|
//it's good, so test that the category is right!
|
2018-01-28 15:30:17 -06:00
|
|
|
%assetType = AssetDatabase.getAssetCategory(%assetId);
|
|
|
|
|
if(%assetType $= "")
|
|
|
|
|
{
|
|
|
|
|
%assetType = AssetDatabase.getAssetType(%assetId);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
%validType = false;
|
|
|
|
|
|
|
|
|
|
if(AssetBrowser.assetTypeFilter $= "")
|
|
|
|
|
{
|
|
|
|
|
if(AssetTypeListPopup.isItemChecked(0))
|
|
|
|
|
{
|
|
|
|
|
%validType = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for(%f=1; %f < AssetFilterTypeList.Count(); %f++)
|
|
|
|
|
{
|
|
|
|
|
%isChecked = AssetTypeListPopup.isItemChecked(%f+1);
|
|
|
|
|
|
|
|
|
|
if(%isChecked)
|
|
|
|
|
{
|
|
|
|
|
%filterTypeName = AssetFilterTypeList.getKey(%f);
|
|
|
|
|
|
|
|
|
|
if(%activeTypeFilterList $= "")
|
|
|
|
|
%activeTypeFilterList = %filterTypeName;
|
|
|
|
|
else
|
|
|
|
|
%activeTypeFilterList = %activeTypeFilterList @ ", " @ %filterTypeName;
|
|
|
|
|
|
|
|
|
|
if(%filterTypeName @ "Asset" $= %assetType)
|
|
|
|
|
{
|
|
|
|
|
%validType = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!%validType)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(%assetType !$= AssetBrowser.assetTypeFilter)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-11-06 00:23:07 -06:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
/*if(%this.getItemText(%itemId) $= %assetType || (%assetType $= "" && %this.getItemText(%itemId) $= "Misc")
|
2018-01-28 15:30:17 -06:00
|
|
|
|| %moduleItemId == 1)
|
2019-10-20 02:47:15 -05:00
|
|
|
{*/
|
2018-01-28 15:30:17 -06:00
|
|
|
//stop adding after previewsPerPage is hit
|
|
|
|
|
%assetName = AssetDatabase.getAssetName(%assetId);
|
|
|
|
|
|
|
|
|
|
%searchText = AssetBrowserSearchFilter.getText();
|
2019-10-20 02:47:15 -05:00
|
|
|
if(%searchText !$= "Search Assets...")
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
|
|
|
|
if(strstr(strlwr(%assetName), strlwr(%searchText)) != -1)
|
2019-11-24 06:52:34 -06:00
|
|
|
{
|
2018-01-28 15:30:17 -06:00
|
|
|
%assetArray.add( %moduleName, %assetId);
|
2019-11-24 06:52:34 -06:00
|
|
|
|
|
|
|
|
if(%assetType !$= "Folder")
|
|
|
|
|
%finalAssetCount++;
|
|
|
|
|
}
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//got it.
|
|
|
|
|
%assetArray.add( %moduleName, %assetId );
|
2019-11-24 06:52:34 -06:00
|
|
|
|
|
|
|
|
if(%assetType !$= "Folder")
|
|
|
|
|
%finalAssetCount++;
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
2019-10-20 02:47:15 -05:00
|
|
|
//}
|
|
|
|
|
}
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
2019-10-20 02:47:15 -05:00
|
|
|
|
|
|
|
|
//Add folders
|
|
|
|
|
if(EditorSettings.value("Assets/Browser/showFolders", true) == true)
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
%folders = getDirectoryList(%breadcrumbPath);
|
|
|
|
|
for(%f=0; %f < getFieldCount(%folders); %f++)
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
%folderName = getField(%folders, %f);
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
%searchText = AssetBrowserSearchFilter.getText();
|
|
|
|
|
if(%searchText !$= "Search Assets...")
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
if(strstr(strlwr(%folderName), strlwr(%searchText)) != -1)
|
|
|
|
|
%assetArray.add( %breadcrumbPath, %folderName );
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
2019-10-20 02:47:15 -05:00
|
|
|
else
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
//got it.
|
|
|
|
|
%assetArray.add( %breadcrumbPath, %folderName );
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-20 02:47:15 -05:00
|
|
|
|
|
|
|
|
AssetBrowser.currentPreviewPage = 0;
|
|
|
|
|
AssetBrowser.totalPages = 1;
|
|
|
|
|
|
|
|
|
|
for(%i=0; %i < %assetArray.count(); %i++)
|
|
|
|
|
AssetBrowser.buildPreviewArray( %assetArray.getValue(%i), %assetArray.getKey(%i) );
|
|
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
AssetBrowser_FooterText.text = %finalAssetCount @ " Assets";
|
|
|
|
|
|
|
|
|
|
%activeTypeFilterList = "";
|
|
|
|
|
if(AssetBrowser.assetTypeFilter $= "")
|
|
|
|
|
{
|
|
|
|
|
if(!AssetTypeListPopup.isItemChecked(0))
|
|
|
|
|
{
|
|
|
|
|
for(%f=1; %f < AssetFilterTypeList.Count(); %f++)
|
|
|
|
|
{
|
|
|
|
|
%isChecked = AssetTypeListPopup.isItemChecked(%f+1);
|
|
|
|
|
|
|
|
|
|
if(%isChecked)
|
|
|
|
|
{
|
|
|
|
|
%filterTypeName = AssetFilterTypeList.getKey(%f);
|
|
|
|
|
|
|
|
|
|
if(%activeTypeFilterList $= "")
|
|
|
|
|
%activeTypeFilterList = %filterTypeName;
|
|
|
|
|
else
|
|
|
|
|
%activeTypeFilterList = %activeTypeFilterList @ ", " @ %filterTypeName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!%validType)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
%activeTypeFilterList = AssetBrowser.assetTypeFilter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(%activeTypeFilterList !$= "")
|
|
|
|
|
AssetBrowser_FooterText.text = AssetBrowser_FooterText.text @ " | Active Type Filters: " @ %activeTypeFilterList;
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//
|
2019-10-20 02:47:15 -05:00
|
|
|
// Search Filters
|
|
|
|
|
function AssetBrowserSearchFilterTxt::onWake( %this )
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
|
|
|
|
/*%filter = %this.treeView.getFilterText();
|
|
|
|
|
if( %filter $= "" )
|
|
|
|
|
%this.setText( "\c2Filter..." );
|
|
|
|
|
else
|
|
|
|
|
%this.setText( %filter );*/
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
function AssetBrowserSearchFilterTxt::onGainFirstResponder( %this )
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
|
|
|
|
%this.selectAllText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// When Enter is pressed in the filter text control, pass along the text of the control
|
|
|
|
|
// as the treeview's filter.
|
2019-10-20 02:47:15 -05:00
|
|
|
function AssetBrowserFolderSearchFilter::onReturn( %this )
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
|
|
|
|
%text = %this.getText();
|
|
|
|
|
if( %text $= "" )
|
|
|
|
|
%this.reset();
|
2019-10-20 02:47:15 -05:00
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser.refresh();
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
function AssetBrowserSearchFilter::onReturn( %this )
|
|
|
|
|
{
|
|
|
|
|
%text = %this.getText();
|
|
|
|
|
if( %text $= "" )
|
|
|
|
|
%this.reset();
|
|
|
|
|
|
|
|
|
|
AssetBrowser.rebuildAssetArray();
|
|
|
|
|
}
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
function AssetBrowserFolderSearchFilter::reset( %this )
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
%this.setText( "Search Folders..." );
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
AssetBrowser.refresh();
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
function AssetBrowserSearchFilter::reset( %this )
|
|
|
|
|
{
|
|
|
|
|
%this.setText( "Search Assets..." );
|
|
|
|
|
|
|
|
|
|
AssetBrowser.rebuildAssetArray();
|
|
|
|
|
}
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
function AssetBrowser_ClearFolderFilterBtn::onClick( %this )
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
AssetBrowserFolderSearchFilter.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser_ClearAssetFilterBtn::onClick( %this )
|
|
|
|
|
{
|
|
|
|
|
AssetBrowserSearchFilter.reset();
|
|
|
|
|
}
|
2019-12-03 00:09:18 -06:00
|
|
|
|
2019-10-20 02:47:15 -05:00
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// Navigation
|
|
|
|
|
function AssetBrowser::navigateTo(%this, %address, %historyNav)
|
|
|
|
|
{
|
|
|
|
|
//Don't bother navigating if it's to the place we already are
|
2019-12-03 00:09:18 -06:00
|
|
|
if(AssetBrowser.dirHandler.currentAddress !$= %address)
|
|
|
|
|
{
|
|
|
|
|
AssetBrowser.dirHandler.navigateTo(%address, %historyNav);
|
|
|
|
|
|
|
|
|
|
%this.updateNavigationBreadcrumb(%address);
|
|
|
|
|
|
|
|
|
|
%module = AssetBrowser.dirHandler.getModuleFromAddress(%address);
|
|
|
|
|
if(%module !$= "")
|
|
|
|
|
{
|
|
|
|
|
//legit module, so set it as current target
|
|
|
|
|
AssetBrowser.SelectedModule = %module.moduleId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%this.rebuildAssetArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::navigateHistoryForward(%this)
|
|
|
|
|
{
|
|
|
|
|
%this.dirHandler.navigateHistoryForward();
|
|
|
|
|
|
|
|
|
|
%this.updateNavigationBreadcrumb();
|
|
|
|
|
|
|
|
|
|
%module = AssetBrowser.dirHandler.getModuleFromAddress(%address);
|
|
|
|
|
if(%module !$= "")
|
|
|
|
|
{
|
|
|
|
|
//legit module, so set it as current target
|
|
|
|
|
AssetBrowser.SelectedModule = %module.moduleId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%this.rebuildAssetArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::navigateHistoryBack(%this)
|
|
|
|
|
{
|
|
|
|
|
%this.dirHandler.navigateHistoryBack();
|
2019-10-20 02:47:15 -05:00
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
%this.updateNavigationBreadcrumb();
|
|
|
|
|
|
|
|
|
|
%module = AssetBrowser.dirHandler.getModuleFromAddress(%address);
|
|
|
|
|
if(%module !$= "")
|
|
|
|
|
{
|
|
|
|
|
//legit module, so set it as current target
|
|
|
|
|
AssetBrowser.SelectedModule = %module.moduleId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%this.rebuildAssetArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowser::updateNavigationBreadcrumb(%this, %address)
|
|
|
|
|
{
|
2019-10-20 02:47:15 -05:00
|
|
|
//clear the breadcrumb bar
|
|
|
|
|
AssetBrowser_BreadcrumbBar.clear();
|
|
|
|
|
|
|
|
|
|
//break down the address
|
|
|
|
|
%folderCount = getTokenCount(%address, "/");
|
|
|
|
|
|
|
|
|
|
%rebuiltPath = "";
|
|
|
|
|
for(%f=0; %f < %folderCount; %f++)
|
|
|
|
|
{
|
|
|
|
|
%folderName = getToken(%address, "/", %f);
|
|
|
|
|
|
|
|
|
|
%rebuiltPath = %f == 0 ? %folderName : %rebuiltPath @ "/" @ %folderName;
|
|
|
|
|
|
|
|
|
|
%folderNavButton = new GuiButtonCtrl()
|
|
|
|
|
{
|
|
|
|
|
profile = ToolsGuiButtonProfile;
|
|
|
|
|
text = %folderName;
|
|
|
|
|
command = "AssetBrowser.navigateTo(\"" @ %rebuiltPath @ "\");";
|
|
|
|
|
extent = "100" SPC AssetBrowser_BreadcrumbBar.extent.y;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AssetBrowser_BreadcrumbBar.add(%folderNavButton);
|
|
|
|
|
|
|
|
|
|
if(%f != %folderCount-1)
|
|
|
|
|
{
|
|
|
|
|
%folderSpacerButton = new GuiBitmapButtonCtrl()
|
|
|
|
|
{
|
|
|
|
|
profile = ToolsGuiButtonProfile;
|
|
|
|
|
bitmap = "tools/gui/images/rightArrowWhite";
|
|
|
|
|
bitmapMode = "Centered";
|
|
|
|
|
extent = "25" SPC AssetBrowser_BreadcrumbBar.extent.y;
|
|
|
|
|
//command = "AssetBrowser.navigateTo(\"" @ %rebuiltPath @ "\");";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AssetBrowser_BreadcrumbBar.add(%folderSpacerButton);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//refresh the nav buttons to display the history
|
|
|
|
|
%backButtonHistory = "";
|
2019-12-03 00:09:18 -06:00
|
|
|
for(%i=0; %i < AssetBrowser.dirHandler.prevHistoryList.Count(); %i++)
|
2019-10-20 02:47:15 -05:00
|
|
|
{
|
2019-12-03 00:09:18 -06:00
|
|
|
%prevAddress = AssetBrowser.dirHandler.prevHistoryList.getKey(%i);
|
2019-10-20 02:47:15 -05:00
|
|
|
%backButtonHistory = %i==0 ? %prevAddress @ "\n" : %backButtonHistory @ %prevAddress @ "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssetBrowser_NavigateBackBtn.tooltip = %backButtonHistory;
|
|
|
|
|
|
|
|
|
|
%foreButtonHistory = "";
|
2019-12-03 00:09:18 -06:00
|
|
|
for(%i=0; %i < AssetBrowser.dirHandler.foreHistoryList.Count(); %i++)
|
2019-10-20 02:47:15 -05:00
|
|
|
{
|
2019-12-03 00:09:18 -06:00
|
|
|
%prevAddress = AssetBrowser.dirHandler.foreHistoryList.getKey(%i);
|
2019-10-20 02:47:15 -05:00
|
|
|
%foreButtonHistory = %i==0 ? %prevAddress @ "\n" : %foreButtonHistory @ %prevAddress @ "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssetBrowser_NavigateForwardBtn.tooltip = %foreButtonHistory;
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
function AssetBrowser::reloadModules(%this)
|
|
|
|
|
{
|
|
|
|
|
ModuleDatabase.unloadGroup("Game");
|
|
|
|
|
|
|
|
|
|
%modulesList = ModuleDatabase.findModules();
|
|
|
|
|
|
|
|
|
|
%count = getWordCount(%modulesList);
|
|
|
|
|
|
|
|
|
|
for(%i=0; %i < %count; %i++)
|
|
|
|
|
{
|
|
|
|
|
%moduleId = getWord(%modulesList, %i).ModuleId;
|
|
|
|
|
ModuleDatabase.unloadExplicit(%moduleId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ModuleDatabase.scanModules();
|
|
|
|
|
|
|
|
|
|
%modulesList = ModuleDatabase.findModules();
|
|
|
|
|
|
|
|
|
|
%count = getWordCount(%modulesList);
|
|
|
|
|
|
|
|
|
|
for(%i=0; %i < %count; %i++)
|
|
|
|
|
{
|
|
|
|
|
%moduleId = getWord(%modulesList, %i).ModuleId;
|
|
|
|
|
ModuleDatabase.loadExplicit(%moduleId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ModuleDatabase.loadGroup("Game");
|
|
|
|
|
}
|
2019-10-20 02:47:15 -05:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
function AssetBrowser::toggleFolderCollapseButton(%this)
|
|
|
|
|
{
|
|
|
|
|
%this.folderPanelState = !%this.folderPanelState;
|
|
|
|
|
|
|
|
|
|
//If we're collapsing
|
|
|
|
|
if(!%this.folderPanelState)
|
|
|
|
|
{
|
|
|
|
|
//Store the original
|
|
|
|
|
%this.folderPanelSplit = AssetBrowser_MainSplit.splitPoint.x;
|
|
|
|
|
|
|
|
|
|
//collapse it
|
|
|
|
|
AssetBrowser_MainSplit.setSplitPoint(AssetBrowser_MainSplit.splitterSize SPC AssetBrowser_MainSplit.splitPoint.y);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//restore the original
|
|
|
|
|
AssetBrowser_MainSplit.setSplitPoint(%this.folderPanelSplit SPC AssetBrowser_MainSplit.splitPoint.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// Drag n drop
|
2018-01-28 15:30:17 -06:00
|
|
|
function AssetPreviewButton::onMouseDragged(%this)
|
|
|
|
|
{
|
|
|
|
|
%payload = new GuiBitmapButtonCtrl();
|
2019-12-23 12:37:55 -06:00
|
|
|
//%payload.assignFieldsFrom( %this );
|
|
|
|
|
%payload.assetName = %this.assetName;
|
|
|
|
|
%payload.assetType = %this.assetType ;
|
|
|
|
|
%payload.moduleName = %this.moduleName;
|
|
|
|
|
%payload.class = "AssetPreviewControl";
|
2018-01-28 15:30:17 -06:00
|
|
|
%payload.position = "0 0";
|
|
|
|
|
%payload.dragSourceControl = %this;
|
|
|
|
|
%payload.bitmap = %this.icon;
|
|
|
|
|
%payload.extent.x /= 2;
|
|
|
|
|
%payload.extent.y /= 2;
|
|
|
|
|
|
|
|
|
|
%xOffset = getWord( %payload.extent, 0 ) / 2;
|
|
|
|
|
%yOffset = getWord( %payload.extent, 1 ) / 2;
|
|
|
|
|
|
|
|
|
|
// Compute the initial position of the GuiDragAndDrop control on the cavas based on the current
|
|
|
|
|
// mouse cursor position.
|
|
|
|
|
|
|
|
|
|
%cursorpos = Canvas.getCursorPos();
|
|
|
|
|
%xPos = getWord( %cursorpos, 0 ) - %xOffset;
|
|
|
|
|
%yPos = getWord( %cursorpos, 1 ) - %yOffset;
|
|
|
|
|
|
|
|
|
|
if(!isObject(EditorDragAndDropLayer))
|
|
|
|
|
{
|
|
|
|
|
new GuiControl(EditorDragAndDropLayer)
|
|
|
|
|
{
|
|
|
|
|
position = "0 0";
|
|
|
|
|
extent = Canvas.extent;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the drag control.
|
|
|
|
|
%ctrl = new GuiDragAndDropControl()
|
|
|
|
|
{
|
|
|
|
|
canSaveDynamicFields = "0";
|
|
|
|
|
Profile = "GuiSolidDefaultProfile";
|
|
|
|
|
HorizSizing = "right";
|
|
|
|
|
VertSizing = "bottom";
|
|
|
|
|
Position = %xPos SPC %yPos;
|
|
|
|
|
extent = %payload.extent;
|
|
|
|
|
MinExtent = "4 4";
|
|
|
|
|
canSave = "1";
|
|
|
|
|
Visible = "1";
|
|
|
|
|
hovertime = "1000";
|
|
|
|
|
|
|
|
|
|
// Let the GuiDragAndDropControl delete itself on mouse-up. When the drag is aborted,
|
|
|
|
|
// this not only deletes the drag control but also our payload.
|
|
|
|
|
deleteOnMouseUp = true;
|
|
|
|
|
|
|
|
|
|
useWholeCanvas = true;
|
|
|
|
|
|
|
|
|
|
// To differentiate drags, use the namespace hierarchy to classify them.
|
|
|
|
|
// This will allow a color swatch drag to tell itself apart from a file drag, for example.
|
|
|
|
|
class = "AssetPreviewControlType_AssetDrop";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Add the temporary color swatch to the drag control as the payload.
|
|
|
|
|
%ctrl.add( %payload );
|
|
|
|
|
|
|
|
|
|
// Start drag by adding the drag control to the canvas and then calling startDragging().
|
|
|
|
|
//Canvas.getContent().add( %ctrl );
|
|
|
|
|
EditorDragAndDropLayer.add(%ctrl);
|
|
|
|
|
Canvas.pushDialog(EditorDragAndDropLayer);
|
|
|
|
|
|
|
|
|
|
%ctrl.startDragging( %xOffset, %yOffset );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetPreviewButton::onControlDragCancelled(%this)
|
|
|
|
|
{
|
|
|
|
|
Canvas.popDialog(EditorDragAndDropLayer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetPreviewButton::onControlDropped( %this, %payload, %position )
|
|
|
|
|
{
|
|
|
|
|
Canvas.popDialog(EditorDragAndDropLayer);
|
|
|
|
|
|
|
|
|
|
if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// If dropped on same button whence we came from,
|
|
|
|
|
// do nothing.
|
|
|
|
|
|
|
|
|
|
if( %payload.dragSourceControl == %this )
|
|
|
|
|
return;
|
2019-12-23 12:37:55 -06:00
|
|
|
|
|
|
|
|
%assetType = %payload.dragSourceControl.parentGroup.assetType;
|
|
|
|
|
%assetName = %payload.dragSourceControl.parentGroup.assetName;
|
|
|
|
|
%moduleName = %payload.dragSourceControl.parentGroup.moduleName;
|
|
|
|
|
|
|
|
|
|
%targetAssetName = %this.assetName;
|
|
|
|
|
%targetAssetType = %this.assetType;
|
|
|
|
|
%targetModuleName = %this.moduleName;
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-12-23 12:37:55 -06:00
|
|
|
if( %payload.dragSourceControl.class $= "AssetPreviewButton" && %targetAssetType $= "Folder")
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
2019-12-23 12:37:55 -06:00
|
|
|
%destination = %targetModuleName @ "/" @ %targetAssetName;
|
|
|
|
|
|
|
|
|
|
if(%assetType $= "Folder")
|
|
|
|
|
{
|
|
|
|
|
%originFolder = %moduleName @ "/" @ %assetName;
|
|
|
|
|
%destination = %destination @ "/" @ %assetName;
|
|
|
|
|
|
|
|
|
|
//Do any cleanup required given the type
|
|
|
|
|
if(AssetBrowser.isMethod("moveFolder"))
|
|
|
|
|
eval(AssetBrowser @ ".moveFolder(\""@%originFolder@"\",\""@%destination@"\");");
|
|
|
|
|
}
|
2018-01-28 15:30:17 -06:00
|
|
|
else
|
2019-12-23 12:37:55 -06:00
|
|
|
{
|
|
|
|
|
%assetId = %moduleName @ ":" @ %assetName;
|
|
|
|
|
%assetDef = AssetDatabase.acquireAsset(%assetId);
|
|
|
|
|
%assetType = AssetDatabase.getAssetType(%assetId);
|
|
|
|
|
|
|
|
|
|
//Do any cleanup required given the type
|
|
|
|
|
if(AssetBrowser.isMethod("move"@%assetType))
|
|
|
|
|
{
|
|
|
|
|
%command = AssetBrowser @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %destination @ "\");";
|
|
|
|
|
eval(AssetBrowser @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %destination @ "\");");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssetBrowser.refresh();
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function EWorldEditor::onControlDropped( %this, %payload, %position )
|
|
|
|
|
{
|
|
|
|
|
Canvas.popDialog(EditorDragAndDropLayer);
|
|
|
|
|
|
|
|
|
|
// Make sure this is a color swatch drag operation.
|
|
|
|
|
if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// If dropped on same button whence we came from,
|
|
|
|
|
// do nothing.
|
|
|
|
|
|
|
|
|
|
if( %payload.dragSourceControl == %this )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
%assetType = %payload.dragSourceControl.parentGroup.assetType;
|
|
|
|
|
|
|
|
|
|
%pos = EWCreatorWindow.getCreateObjectPosition(); //LocalClientConnection.camera.position;
|
|
|
|
|
%module = %payload.dragSourceControl.parentGroup.moduleName;
|
|
|
|
|
%asset = %payload.dragSourceControl.parentGroup.assetName;
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
if(AssetBrowser.isMethod("on" @ %assetType @ "EditorDropped"))
|
|
|
|
|
{
|
|
|
|
|
%assetDef = AssetDatabase.acquireAsset(%module @ ":" @ %asset);
|
|
|
|
|
%buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %assetDef @ ",\"" @ %position @ "\");";
|
|
|
|
|
eval(%buildCommand);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*if(%assetType $= "ImageAsset")
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
2019-05-04 11:49:42 -05:00
|
|
|
echo("WorldEditor::onControlDropped - dropped an ImageAsset onto the editor window. Todo: Implement dropping image/material into scene");
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
else if(%assetType $= "ShapeAsset")
|
|
|
|
|
{
|
|
|
|
|
echo("DROPPED A SHAPE ON THE EDITOR WINDOW!");
|
|
|
|
|
|
2019-11-18 03:30:04 -06:00
|
|
|
/*%staticShapeObjDef = AssetDatabase.acquireAsset("Core_GameObjects:StaticShapeObject");
|
2019-05-04 11:49:42 -05:00
|
|
|
|
|
|
|
|
%newEntity = %staticShapeObjDef.createObject();
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
%newEntity.position = %pos;
|
|
|
|
|
%newEntity-->MeshComponent.MeshAsset = %module @ ":" @ %asset;
|
|
|
|
|
|
2019-11-18 03:30:04 -06:00
|
|
|
%newEntity.dirtyGameObject = true; //because if we're specifically setting the mesh asset, it's dirty*/
|
|
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
/*%newEntity = new TSStatic()
|
2019-11-18 03:30:04 -06:00
|
|
|
{
|
|
|
|
|
position = %pos;
|
|
|
|
|
shapeAsset = %module @ ":" @ %asset;
|
|
|
|
|
};
|
2019-08-19 01:14:34 -05:00
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
getScene(0).add(%newEntity);
|
2018-01-28 15:30:17 -06:00
|
|
|
|
|
|
|
|
EWorldEditor.clearSelection();
|
|
|
|
|
EWorldEditor.selectObject(%newEntity);
|
|
|
|
|
}
|
|
|
|
|
else if(%assetType $= "MaterialAsset")
|
|
|
|
|
{
|
2019-05-04 11:49:42 -05:00
|
|
|
echo("WorldEditor::onControlDropped - dropped an MaterialAsset onto the editor window. Todo: Implement dropping image/material into scene");
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
else if(%assetType $= "GameObjectAsset")
|
|
|
|
|
{
|
2019-05-04 11:49:42 -05:00
|
|
|
echo("WorldEditor::onControlDropped - dropped an GameObjectAsset onto the editor window.");
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
%goAssetDef = AssetDatabase.acquireAsset(%module @ ":" @%asset);
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
AssetBrowser.dragAndDropGameObjectAsset(%goAssetDef, EWorldEditor);
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
else if(%assetType $= "ComponentAsset")
|
|
|
|
|
{
|
|
|
|
|
%newEntity = new Entity()
|
|
|
|
|
{
|
|
|
|
|
position = %pos;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%assetDef = AssetDatabase.acquireAsset(%module @ ":" @ %asset);
|
|
|
|
|
|
|
|
|
|
if(%assetDef.componentClass $= "Component")
|
|
|
|
|
eval("$tmpVar = new " @ %assetDef.componentClass @ "() { class = " @ %assetDef.componentName @ "; }; %newEntity.add($tmpVar);");
|
|
|
|
|
else
|
|
|
|
|
eval("$tmpVar = new " @ %assetDef.componentClass @ "() {}; %newEntity.add($tmpVar);");
|
|
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
getScene(0).add(%newEntity);
|
2018-01-28 15:30:17 -06:00
|
|
|
|
|
|
|
|
EWorldEditor.clearSelection();
|
|
|
|
|
EWorldEditor.selectObject(%newEntity);
|
|
|
|
|
}
|
|
|
|
|
else if(%assetType $= "ScriptAsset") //do we want to do it this way?
|
|
|
|
|
{
|
|
|
|
|
%newEntity = new Entity()
|
|
|
|
|
{
|
|
|
|
|
position = %pos;
|
|
|
|
|
class = %asset;
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
getScene(0).add(%newEntity);
|
2018-01-28 15:30:17 -06:00
|
|
|
|
|
|
|
|
EWorldEditor.clearSelection();
|
|
|
|
|
EWorldEditor.selectObject(%newEntity);
|
2019-12-03 00:09:18 -06:00
|
|
|
}*/
|
2018-01-28 15:30:17 -06:00
|
|
|
|
|
|
|
|
EWorldEditor.isDirty = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowserFilterTree::onControlDropped( %this, %payload, %position )
|
|
|
|
|
{
|
|
|
|
|
Canvas.popDialog(EditorDragAndDropLayer);
|
|
|
|
|
|
|
|
|
|
if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
%assetType = %payload.dragSourceControl.parentGroup.assetType;
|
|
|
|
|
%assetName = %payload.dragSourceControl.parentGroup.assetName;
|
|
|
|
|
%moduleName = %payload.dragSourceControl.parentGroup.moduleName;
|
|
|
|
|
|
|
|
|
|
echo("DROPPED A " @ %assetType @ " ON THE ASSET BROWSER NAVIGATION TREE!");
|
|
|
|
|
|
|
|
|
|
%item = %this.getItemAtPosition(%position);
|
|
|
|
|
|
|
|
|
|
echo("DROPPED IT ON ITEM " @ %item);
|
|
|
|
|
|
|
|
|
|
%parent = %this.getParentItem(%item);
|
|
|
|
|
|
2019-11-24 06:52:34 -06:00
|
|
|
if(%item != 1)
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
2019-11-24 06:52:34 -06:00
|
|
|
//we're a folder entry, cool
|
|
|
|
|
%path = %this.getItemValue(%item) @ "/" @ %this.getItemText(%item);
|
|
|
|
|
echo("DROPPED IT ON PATH " @ %path);
|
2018-01-28 15:30:17 -06:00
|
|
|
|
2019-12-03 00:09:18 -06:00
|
|
|
if(%path !$= AssetBrowser.dirHandler.CurrentAddress)
|
2018-01-28 15:30:17 -06:00
|
|
|
{
|
|
|
|
|
//we're trying to move the asset to a different module!
|
2019-12-23 12:37:55 -06:00
|
|
|
//MessageBoxYesNo( "Move Asset", "Do you wish to move asset " @ %assetName @ " to " @ %path @ "?",
|
|
|
|
|
// "AssetBrowser.moveAsset(\""@ %moduleName @ ":" @ %assetName @"\", \""@%path@"\");", "");
|
|
|
|
|
|
|
|
|
|
if(%assetType $= "Folder")
|
|
|
|
|
{
|
|
|
|
|
%originFolder = %moduleName @ "/" @ %assetName;
|
|
|
|
|
%path = %path @ "/" @ %assetName;
|
|
|
|
|
|
|
|
|
|
//Do any cleanup required given the type
|
|
|
|
|
if(AssetBrowser.isMethod("moveFolder"))
|
|
|
|
|
eval(AssetBrowser @ ".moveFolder(\""@%originFolder@"\",\""@%path@"\");");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
%assetId = %moduleName @ ":" @ %assetName;
|
|
|
|
|
%assetDef = AssetDatabase.acquireAsset(%assetId);
|
|
|
|
|
%assetType = AssetDatabase.getAssetType(%assetId);
|
|
|
|
|
|
|
|
|
|
//Do any cleanup required given the type
|
|
|
|
|
if(AssetBrowser.isMethod("move"@%assetType))
|
|
|
|
|
{
|
|
|
|
|
%command = AssetBrowser @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %path @ "\");";
|
|
|
|
|
eval(AssetBrowser @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %path @ "\");");
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-28 15:30:17 -06:00
|
|
|
}
|
|
|
|
|
}
|
2019-11-24 06:52:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AssetBrowserFilterTree::onDragDropped( %this )
|
|
|
|
|
{
|
|
|
|
|
%asdgadfhg =true;
|
|
|
|
|
}
|