Merge remote-tracking branch 'devhead/Preview4_0' into tsneo

# Conflicts:
#	Engine/source/platform/types.visualc.h
#	Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript
#	Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/terrain.tscript
#	Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.tscript
#	Templates/BaseGame/game/tools/gui/scriptEditorDlg.ed.gui
This commit is contained in:
Jeff Hutchinson 2021-09-01 22:26:23 -04:00
commit 17231ca9fb
51 changed files with 736 additions and 488 deletions

View file

@ -32,7 +32,6 @@ function AssetBrowser_addModuleWindow::onGainFirstResponder(%this)
function AssetBrowser_addModuleWindow::close()
{
Canvas.popDialog(AssetBrowser_addModule);
eval(AssetBrowser_addModuleWindow.callbackFunction);
}
function AssetBrowser_addModuleWindow::CreateNewModule(%this)
@ -127,4 +126,9 @@ function AssetBrowserModuleList::refresh(%this)
%moduleName = getWord(%moduleList, %i);
%this.add(%moduleName.ModuleId, %i);
}
}
function AssetBrowserSelModuleAddBtn::onClick(%this)
{
AssetBrowser.CreateNewModule("AssetBrowser_selectModule.newModuleAdded();");
}

View file

@ -1,5 +1,3 @@
new SimGroup(AssetBrowserPreviewCache);
//AssetBrowser.addToolbarButton
function AssetBrowser::addToolbarButton(%this)
{
@ -30,18 +28,18 @@ function AssetBrowser::addToolbarButton(%this)
EWToolsToolbar.setExtent((25 + 8) * (ToolsToolbarArray.getCount()) + 12 SPC "33");
}
//
function AssetBrowser::onAdd(%this)
{
}
function AssetBrowser::onWake(%this)
function AssetBrowser::initialize(%this)
{
// manage preview array
if(!isObject(AssetPreviewArray))
new ArrayObject(AssetPreviewArray);
if(!isObject(%this.dirHandler))
{
%this.dirHandler = makedirectoryHandler(AssetBrowser-->filterTree, "cache,shaderCache", "");
%this.dirHandler.currentAddress = "data/";
}
AssetBrowser-->filterTree.buildIconTable( ":tools/classIcons/Prefab:tools/classIcons/Prefab" @
":tools/classIcons/SimSet:tools/classIcons/SimSet");
@ -65,6 +63,30 @@ function AssetBrowser::onWake(%this)
AssetBrowser-->filterAssetsButton.setActive(true);
}
function AssetBrowser::onAdd(%this)
{
}
function AssetBrowser::onWake(%this)
{
%this.initialize();
}
function AssetBrowser::onDialogPop(%this)
{
%lastPosExt = AssetBrowserWindow.position SPC AssetBrowserWindow.extent;
EditorSettings.setValue("Assets/Browser/LastPosExt", %lastPosExt);
}
function AssetBrowser::restoreLastPosExt(%this)
{
%lastPosExt = EditorSettings.value("Assets/Browser/LastPosExt", "");
if(%lastPosExt !$= "")
{
AssetBrowserWindow.resize(getWord(%lastPosExt, 0), getWord(%lastPosExt, 1), getWord(%lastPosExt, 2), getWord(%lastPosExt, 3));
}
}
function contentTreeTabBook::onTabSelected(%this, %tabText, %tabIndex)
{
if(%tabText $= "Content")
@ -273,6 +295,7 @@ function AssetBrowser::showDialog( %this, %AssetTypeFilter, %selectCallback, %ta
Canvas.popDialog(AssetBrowser);
Canvas.pushDialog(AssetBrowser);
AssetBrowser.setVisible(1);
AssetBrowserWindow.setVisible(1);
AssetBrowserWindow.selectWindow();
@ -301,6 +324,8 @@ function AssetBrowser::showDialog( %this, %AssetTypeFilter, %selectCallback, %ta
}
AssetBrowser.loadDirectories();
AssetBrowser.restoreLastPosExt();
}
function AssetBrowser::hideDialog( %this )
@ -313,6 +338,18 @@ function AssetBrowser::hideDialog( %this )
Canvas.popDialog(AssetBrowser);
}
function AssetBrowser::toggleDialog( %this )
{
if(AssetBrowser.isAwake())
{
AssetBrowser.hideDialog();
}
else
{
AssetBrowser.showDialog();
}
}
function AssetBrowser::buildAssetPreview( %this, %asset, %moduleName )
{
if(!isObject(%this.previewData))
@ -481,13 +518,12 @@ function AssetBrowser::buildAssetPreview( %this, %asset, %moduleName )
{
%previewButton.iconLocation = "Left";
%previewButton.textLocation = "Right";
%previewButton.extent = "120 20";
%previewButton.setextent(120,20);
}
else
{
%size = %previewSize.x * %previewScaleSize;
%previewButton.extent.x = %size;
%previewButton.extent.y = %size + %textBottomPad;
%previewButton.setextent(%size,%size + %textBottomPad);
}
//%previewButton.extent = %previewSize.x + %previewBounds SPC %previewSize.y + %previewBounds + 24;
@ -1417,13 +1453,10 @@ function AssetBrowser::doRebuildAssetArray(%this)
AssetBrowser-->assetList.deleteAllObjects();
AssetPreviewArray.empty();
// uhh?? I just added global schenanagins here to make this work
%assetArray = $AssetBrowser::AssetArray;
if(isObject(%assetArray))
%assetArray.delete();
if(isObject($AssetBrowser::AssetArray))
$AssetBrowser::AssetArray.delete();
%assetArray = new ArrayObject();
$AssetBrowser::AssetArray = %assetArray;
$AssetBrowser::AssetArray = new ArrayObject();
//First, Query for our assets
%assetQuery = new AssetQuery();
@ -1504,7 +1537,7 @@ function AssetBrowser::doRebuildAssetArray(%this)
{
if(matchesSearch(%assetName, %assetType))
{
%assetArray.add( %moduleName, %assetId);
$AssetBrowser::AssetArray.add( %moduleName, %assetId);
if(%assetType !$= "Folder")
%finalAssetCount++;
@ -1518,7 +1551,7 @@ function AssetBrowser::doRebuildAssetArray(%this)
{
if(AssetBrowser.assetTypeFilter $= %assetType)
{
%assetArray.add( %moduleName, %assetId );
$AssetBrowser::AssetArray.add( %moduleName, %assetId );
if(%assetType !$= "Folder")
%finalAssetCount++;
@ -1527,7 +1560,7 @@ function AssetBrowser::doRebuildAssetArray(%this)
else
{
//got it.
%assetArray.add( %moduleName, %assetId );
$AssetBrowser::AssetArray.add( %moduleName, %assetId );
if(%assetType !$= "Folder")
%finalAssetCount++;
@ -1549,7 +1582,7 @@ function AssetBrowser::doRebuildAssetArray(%this)
{
if(matchesSearch(%folderName, "Folder", ""))
{
%assetArray.add( %breadcrumbPath, "Folder" TAB %folderName );
$AssetBrowser::AssetArray.add( %breadcrumbPath, "Folder" TAB %folderName );
continue;
}
}
@ -1565,7 +1598,7 @@ function AssetBrowser::doRebuildAssetArray(%this)
if(!%this.toolsModulesFilter && %folderName $= "tools" && %breadcrumbPath $= "")
continue;
%assetArray.add( %breadcrumbPath, "Folder" TAB %folderName );
$AssetBrowser::AssetArray.add( %breadcrumbPath, "Folder" TAB %folderName );
}
}
}
@ -1595,14 +1628,14 @@ function AssetBrowser::doRebuildAssetArray(%this)
%dbName = %obj.getName();
if(matchesSearch(%dbName, "Datablock"))
{
%assetArray.add( %dbFilename, "Datablock" TAB %dbName );
$AssetBrowser::AssetArray.add( %dbFilename, "Datablock" TAB %dbName );
}
}
}
else if(%dbFilePath $= %breadcrumbPath)
{
%dbName = %obj.getName();
%assetArray.add( %dbFilename, "Datablock" TAB %dbName );
$AssetBrowser::AssetArray.add( %dbFilename, "Datablock" TAB %dbName );
/*%catItem = AssetBrowser-->filterTree.findItemByName(%obj.category);
@ -1627,7 +1660,7 @@ function AssetBrowser::doRebuildAssetArray(%this)
%looseFileName = fileName(%looseFileFullPath);
%looseFileExt = fileExt(%looseFileFullPath);
%assetArray.add( %looseFilePath, "LooseFile" TAB %looseFileName );
$AssetBrowser::AssetArray.add( %looseFilePath, "LooseFile" TAB %looseFileName );
}
//Prefabs
@ -1646,13 +1679,13 @@ function AssetBrowser::doRebuildAssetArray(%this)
{
if(matchesSearch(%prefabName, "Prefab"))
{
%assetArray.add( %prefabPath, "Prefab" TAB %prefabName );
$AssetBrowser::AssetArray.add( %prefabPath, "Prefab" TAB %prefabName );
}
}
}
else if(%prefabPath $= %breadcrumbPath)
{
%assetArray.add( %prefabPath, "Prefab" TAB %prefabName );
$AssetBrowser::AssetArray.add( %prefabPath, "Prefab" TAB %prefabName );
}
%fullPrefabPath = findNextFile( %breadcrumbPath @ "/" @ %expr );
@ -1672,13 +1705,13 @@ function AssetBrowser::doRebuildAssetArray(%this)
{
if(matchesSearch(%cppName, "Cpp"))
{
%assetArray.add( %cppPath, "Cpp" TAB %cppName );
$AssetBrowser::AssetArray.add( %cppPath, "Cpp" TAB %cppName );
}
}
}
else if(%cppPath $= %breadcrumbPath)
{
%assetArray.add( %cppPath, "Cpp" TAB %cppName );
$AssetBrowser::AssetArray.add( %cppPath, "Cpp" TAB %cppName );
}
}
@ -1696,13 +1729,13 @@ function AssetBrowser::doRebuildAssetArray(%this)
{
if(matchesSearch(%cppName, "Cpp"))
{
%assetArray.add( %cppPath, "Cpp" TAB %cppName );
$AssetBrowser::AssetArray.add( %cppPath, "Cpp" TAB %cppName );
}
}
}
else if(%cppPath $= %breadcrumbPath)
{
%assetArray.add( %cppPath, "Cpp" TAB %cppName );
$AssetBrowser::AssetArray.add( %cppPath, "Cpp" TAB %cppName );
}
}
@ -1744,13 +1777,13 @@ function AssetBrowser::doRebuildAssetArray(%this)
{
if(matchesSearch(%tscriptName, "tscript"))
{
%assetArray.add( %tscriptPath, "tscript" TAB %tscriptName );
$AssetBrowser::AssetArray.add( %tscriptPath, "tscript" TAB %tscriptName );
}
}
}
else if(%tscriptPath $= %breadcrumbPath)
{
%assetArray.add( %tscriptPath, "tscript" TAB %tscriptName );
$AssetBrowser::AssetArray.add( %tscriptPath, "tscript" TAB %tscriptName );
}
}
}
@ -1772,13 +1805,13 @@ function AssetBrowser::doRebuildAssetArray(%this)
%name = %creatorObj.val[1];
%func = %creatorObj.val[2];
%assetArray.add( %name, "Creator" TAB %creatorObj );
$AssetBrowser::AssetArray.add( %name, "Creator" TAB %creatorObj );
}
}
}
for(%i=0; %i < %assetArray.count(); %i++)
AssetBrowser.buildAssetPreview( %assetArray.getValue(%i), %assetArray.getKey(%i) );
for(%i=0; %i < $AssetBrowser::AssetArray.count(); %i++)
AssetBrowser.buildAssetPreview( $AssetBrowser::AssetArray.getValue(%i), $AssetBrowser::AssetArray.getKey(%i) );
AssetBrowser_FooterText.text = %finalAssetCount @ " Assets";
@ -2075,7 +2108,14 @@ function AssetBrowser::navigateTo(%this, %address, %historyNav)
if(%this.hasLooseFilesInDir())
{
if(EditorSettings.value("Assets/AutoImportLooseFiles", false) && EditorSettings.value("Assets/AutoImport", false))
{
AssetBrowser.autoImportSimpleLooseFiles();
}
else
{
%this-->AutoImportAssetButton.visible = true;
}
}
else
{
@ -2420,6 +2460,11 @@ function EWorldEditor::onControlDropped( %this, %payload, %position )
%buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %assetDef @ ",\"" @ %position @ "\");";
}
eval(%buildCommand);
if(EditorSettings.value("AssetManagement/Assets/closeBrowserOnDragAction", false))
{
AssetBrowser.hideDialog();
}
}
EWorldEditor.isDirty = true;

View file

@ -196,22 +196,35 @@ function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData)
%success = saveScaledImage(%assetDef.getImagePath(), %previewFilePath);
%previewAsset = new ImageAsset()
if(%success)
{
assetName = %previewAssetName;
versionId = 1;
imageFile = fileName(%previewFilePath);
};
%previewAsset = new ImageAsset()
{
assetName = %previewAssetName;
versionId = 1;
imageFile = fileName(%previewFilePath);
};
%previewImgAssetPath = %previewPath @ %previewAsset.assetName @ ".asset.taml";
%assetImportSuccessful = TAMLWrite(%previewAsset, %previewImgAssetPath);
%previewAssetName = "ToolsModule:" @ %previewAssetName;
%previewImgAssetPath = %previewPath @ %previewAsset.assetName @ ".asset.taml";
%assetImportSuccessful = TAMLWrite(%previewAsset, %previewImgAssetPath);
%toolsModuleDef = ModuleDatabase.findModule("ToolsModule",1);
%toolsModuleDef = ModuleDatabase.findModule("ToolsModule",1);
%success = AssetDatabase.addDeclaredAsset(%toolsModuleDef, %previewImgAssetPath);
%success = AssetDatabase.addDeclaredAsset(%toolsModuleDef, %previewImgAssetPath);
}
else
{
%previewFilePath = %assetDef.getImagePath();
%previewAssetName = %module.moduleId @ ":" @ %assetDef.assetName;
}
hideEditorLoadingGui();
}
else
{
%previewAssetName = "ToolsModule:" @ %previewAssetName;
}
//Revalidate. If it didn't work, just use the default placeholder one
if(!isFile(%previewFilePath))
@ -220,7 +233,7 @@ function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData)
%previewData.assetName = %assetDef.assetName;
%previewData.assetPath = %assetDef.scriptFile;
%previewData.previewImage = "ToolsModule:" @ %previewAssetName;//%assetDef.fileName;
%previewData.previewImage = %previewAssetName;
%previewData.assetFriendlyName = %assetDef.assetName;
%previewData.assetDesc = %assetDef.description;

View file

@ -318,30 +318,24 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData)
"Shape File path: " @ %assetDef.getShapeFile();
if(%this.selectMode)
{
%previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
}
else
%previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );";
{
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
{
%previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );";
}
else
{
%previewData.doubleClickCommand = "AssetBrowser.onShapeAssetEditorDropped( "@%assetDef@" );";
}
}
}
function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position)
{
//echo("DROPPED A SHAPE ON THE EDITOR WINDOW!");
%targetPosition = EWorldEditor.unproject(%position SPC 1000);
%camPos = LocalClientConnection.camera.getPosition();
%rayResult = containerRayCast(%camPos, %targetPosition, -1);
%pos = EWCreatorWindow.getCreateObjectPosition();
if(%rayResult != 0)
{
%pos = getWords(%rayResult, 1, 3);
}
else
{
%pos = "0 0 0";
}
%assetId = %assetDef.getAssetId();
%newStatic = new TSStatic()
@ -354,6 +348,8 @@ function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position)
EWorldEditor.clearSelection();
EWorldEditor.selectObject(%newStatic);
EWorldEditor.dropSelection();
EWorldEditor.isDirty = true;

View file

@ -148,6 +148,11 @@ function AssetBrowser::dragAndDropTerrainAsset(%this, %assetDef, %dropTarget)
return;
}
function AssetBrowser::onTerrainAssetEditorDropped(%this, %assetDef, %position)
{
createTerrainBlock(%assetDef.getAssetId());
}
function AssetBrowser::renameTerrainAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
{
}
@ -160,7 +165,6 @@ function AssetBrowser::buildTerrainAssetPreview(%this, %assetDef, %previewData)
{
%previewData.assetName = %assetDef.assetName;
%previewData.assetPath = "";
%previewData.doubleClickCommand = "";
%previewData.previewImage = "ToolsModule:gameObjectIcon_image";
@ -170,6 +174,18 @@ function AssetBrowser::buildTerrainAssetPreview(%this, %assetDef, %previewData)
"\nAsset Type: Terrain Asset" @
"\nAsset Definition ID: " @ %assetDef @
"\nDefinition Path: " @ %assetDef.getTerrainFilePath();
if(%this.selectMode)
{
%previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
}
else
{
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
%previewData.doubleClickCommand = "";
else
%previewData.doubleClickCommand = "createTerrainBlock(\""@%assetDef.getAssetId()@"\");";
}
}
function GuiInspectorTypeTerrainAssetPtr::onClick( %this, %fieldName )

View file

@ -10,12 +10,13 @@ function AssetBrowser::ConvertFolderIntoModule(%this, %folderName)
AssetBrowser_addModuleWindow.CreateNewModule();
}
function AssetBrowser::CreateNewModule(%this)
function AssetBrowser::CreateNewModule(%this, %callback)
{
Canvas.pushDialog(AssetBrowser_AddModule);
AssetBrowser_addModuleWindow.selectWindow();
AssetBrowser_addModuleWindow.callbackFunction = "AssetBrowser.promptNewModuleFolders();";
AssetBrowser_addModuleWindow.callbackFallthrough = %callback;
}
function AssetBrowser::promptNewModuleFolders(%this)
@ -24,6 +25,9 @@ function AssetBrowser::promptNewModuleFolders(%this)
"Do you want to create some common folders for organization of your new Module?",
"AssetBrowser.makeModuleFolders();", //if yes, make the foldesr
"AssetBrowser.loadDirectories();"); //if no, just refresh
if(AssetBrowser_addModuleWindow.callbackFallthrough !$= "")
eval(AssetBrowser_addModuleWindow.callbackFallthrough);
}
function AssetBrowser::makeModuleFolders(%this)

View file

@ -26,9 +26,22 @@ function CreateAssetButton::onClick(%this)
function AssetBrowser_newAsset::onWake(%this)
{
NewAssetTargetAddress.text = AssetBrowser.dirHandler.currentAddress;
NewAssetTargetModule.text = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress).ModuleId;
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress).ModuleId;
if(%targetModule $= "")
%targetModule = EditorSettings.value("Assets/New/defaultModule", "");
NewAssetTargetModule.setText(%targetModule);
%moduleDef = ModuleDatabase.findModule(%targetModule);
%targetPath = AssetBrowser.dirHandler.currentAddress;
if(!startsWith(%targetPath, %moduleDef.ModulePath))
{
%targetPath = %moduleDef.ModulePath;
}
NewAssetTargetAddress.text = %targetPath;
}
function AssetBrowser_newAssetWindow::onClose(%this)
@ -107,34 +120,6 @@ function AssetBrowser::setupCreateNewAsset(%this, %assetType, %moduleName, %call
%command = %this @ ".setupCreateNew"@%assetType @"();";
eval(%command);
}
/*if(%assetType $= "ComponentAsset")
{
NewAssetPropertiesInspector.startGroup("Components");
NewAssetPropertiesInspector.addField("parentClass", "New Asset Parent Class", "String", "Name of the new asset's parent class", "Component", "", %this.newAssetSettings);
NewAssetPropertiesInspector.addField("componentGroup", "Component Group", "String", "Name of the group of components this component asset belongs to", "", "", %this.newAssetSettings);
//NewAssetPropertiesInspector.addField("componentName", "Component Name", "String", "Name of the new component", "", "", %this.newAssetSettings);
NewAssetPropertiesInspector.endGroup();
}*/
//Special case, we only do this via internal means like baking
/*else if(%assetType $= "ShapeAsset")
{
NewAssetPropertiesInspector.startGroup("Shape");
NewAssetPropertiesInspector.addField("isServerScript", "Is Server Script", "bool", "Is this script used on the server?", "1", "", %this.newAssetSettings);
NewAssetPropertiesInspector.endGroup();
}*/
/*else if(%assetType $= "ShapeAnimationAsset")
{
NewAssetPropertiesInspector.startGroup("Animation");
NewAssetPropertiesInspector.addField("sourceFile", "Source File", "filename", "Source file this animation will pull from", "", "", %this.newAssetSettings);
NewAssetPropertiesInspector.addField("animationName", "Animation Name", "string", "Name of the animation clip when used in a shape", "", "", %this.newAssetSettings);
NewAssetPropertiesInspector.addField("startFrame", "Starting Frame", "int", "Source file this animation will pull from", "", "", %this.newAssetSettings);
NewAssetPropertiesInspector.addField("endFrame", "Ending Frame", "int", "Source file this animation will pull from", "", "", %this.newAssetSettings);
NewAssetPropertiesInspector.addField("padRotation", "Pad Rotations", "bool", "Source file this animation will pull from", "0", "", %this.newAssetSettings);
NewAssetPropertiesInspector.addField("padTransforms", "Pad Transforms", "bool", "Source file this animation will pull from", "0", "", %this.newAssetSettings);
NewAssetPropertiesInspector.endGroup();
}*/
}
function NewAssetPropertiesInspector::updateNewAssetField(%this)

View file

@ -7,6 +7,14 @@ function AssetBrowser_SelectModule::showDialog(%this, %callback)
function AssetBrowser_SelectModule::onWake(%this)
{
AssetBrowser_SelectModuleWindow-->ModuleList.refresh();
%defaultModule = EditorSettings.value("Assets/New/defaultModule", "");
if(%defaultModule !$= "" &&
EditorSettings.value("Assets/New/alwaysPromptModuleTarget", false) == false)
{
Canvas.popDialog(AssetBrowser_SelectModule);
eval(%this.callback @ "(" @ %defaultModule @ ");");
}
}
function AssetBrowser_SelectModule::moduleSelected(%this)
@ -24,10 +32,7 @@ function AssetBrowser_SelectModule::moduleSelected(%this)
function SelectModule_NewAssetModuleBtn::onClick(%this)
{
Canvas.pushDialog(AssetBrowser_AddModule);
AssetBrowser_addModuleWindow.selectWindow();
AssetBrowser_AddModule.callback = "AssetBrowser_selectModule.newModuleAdded();";
AssetBrowser.CreateNewModule("AssetBrowser_selectModule.newModuleAdded();");
}
function AssetBrowser_selectModule::newModuleAdded(%this)