Torque3D/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.tscript

529 lines
16 KiB
Plaintext
Raw Normal View History

function AssetBrowser_editAsset::saveAsset(%this)
{
%file = AssetDatabase.getAssetFilePath(%this.editedAssetId);
%success = TamlWrite(AssetBrowser_editAsset.editedAsset, %file);
AssetBrowser.reloadAsset(%this.editedAssetId);
AssetBrowser.refresh();
%assetType = AssetDatabase.getAssetType(%this.editedAssetId);
%assetDef = AssetDatabase.acquireAsset(%this.editedAssetId);
AssetBrowser.call("on" @ %assetType @ "Changed", %assetDef);
AssetDatabase.releaseAsset(%this.editedAssetId);
Canvas.popDialog(AssetBrowser_editAsset);
}
function AssetBrowser::editAsset(%this, %assetDef)
{
//Find out what type it is
//If the passed-in definition param is blank, then we're likely called via a popup
if(%assetDef $= "")
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector Adjusted expand behavior of guiTree to be more reliable Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields Removed redundant PreMult translucency type code Added setting of feature so probes work when in forward/basic lit mode Corrected indexing error in SQLiteObject class so it properly parses with the updated console API Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy Fixed var when trying to bind the camera to the client Added project setting field to dictate the default render mode between Forward or Deferred Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field Integrated DOF PostFX into updated PostFX Editor paradigm Updated setting group name for vignette postFX Shifted shaderCache to be in data/cache along with other cached files Added helper function to replace strings in a file Fixed ExampleCppObject asset to have correct loose file references Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default Fixed verve reference to root scene group Adjusted location of a nonmodal gui profile so it loads at the correct time Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful Initial work into zip and folder drag-and-drop asset importing support Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions Updated example asset type file Ensured all asset types have proper handling for move, rename and delete actions Fixed double-click behavior on folders in the AB Fixed CPP asset preview Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser Added ability to convert a non-module top-level folder in the AB into a module Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake Fixed convex editor's material handling to work with AB and reference back properly Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open Added some additional common text gui profiles Disabled calls to old editor settings logic in various editors to remove spam Added callOnModules call so tools can initialize properly when the world editor is opened Fixed logic test for visualizers Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
{
if(AssetDatabase.isDeclaredAsset(EditAssetPopup.assetId))
{
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
}
else
{
//if it's not a valid asset at all, then it's probably a folder
%folder = strreplace(EditAssetPopup.assetId, ":", "/");
if(isDirectory(%folder))
{
AssetBrowser.navigateTo(%folder);
}
}
}
else if(AssetDatabase.isDeclaredAsset(%assetDef))
{
//Turns out we were passed an assetid, not an asset definition.
//Grab the asset def from that
%assetDef = AssetDatabase.acquireAsset(%assetDef);
}
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector Adjusted expand behavior of guiTree to be more reliable Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields Removed redundant PreMult translucency type code Added setting of feature so probes work when in forward/basic lit mode Corrected indexing error in SQLiteObject class so it properly parses with the updated console API Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy Fixed var when trying to bind the camera to the client Added project setting field to dictate the default render mode between Forward or Deferred Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field Integrated DOF PostFX into updated PostFX Editor paradigm Updated setting group name for vignette postFX Shifted shaderCache to be in data/cache along with other cached files Added helper function to replace strings in a file Fixed ExampleCppObject asset to have correct loose file references Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default Fixed verve reference to root scene group Adjusted location of a nonmodal gui profile so it loads at the correct time Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful Initial work into zip and folder drag-and-drop asset importing support Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions Updated example asset type file Ensured all asset types have proper handling for move, rename and delete actions Fixed double-click behavior on folders in the AB Fixed CPP asset preview Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser Added ability to convert a non-module top-level folder in the AB into a module Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake Fixed convex editor's material handling to work with AB and reference back properly Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open Added some additional common text gui profiles Disabled calls to old editor settings logic in various editors to remove spam Added callOnModules call so tools can initialize properly when the world editor is opened Fixed logic test for visualizers Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
%assetType = %assetDef.getClassName();
//Build out the edit command
%buildCommand = %this @ ".edit" @ %assetType @ "(" @ %assetDef @ ");";
eval(%buildCommand);
}
function AssetBrowser::appendSubLevel(%this)
{
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
%assetType = %assetDef.getClassName();
schedule( 1, 0, "EditorOpenSceneAppend", %assetDef);
}
function AssetBrowser::editAssetInfo(%this)
{
Canvas.pushDialog(AssetBrowser_editAsset);
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
eval("AssetBrowser.tempAsset = new " @ %assetDef.getClassName() @ "();");
AssetBrowser.tempAsset.assignFieldsFrom(%assetDef);
AssetEditInspector.inspect(AssetBrowser.tempAsset);
AssetBrowser_editAsset.editedAssetId = EditAssetPopup.assetId;
AssetBrowser_editAsset.editedAsset = AssetBrowser.tempAsset;
//remove some of the groups we don't need:
for(%i=0; %i < AssetEditInspector.getCount(); %i++)
{
%caption = AssetEditInspector.getObject(%i).caption;
if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing"
|| %caption $= "Persistence" || %caption $= "Dynamic Fields")
{
AssetEditInspector.remove(AssetEditInspector.getObject(%i));
%i--;
}
}
}
//------------------------------------------------------------
function AssetBrowser::reloadAsset(%this, %assetId)
{
%moduleName = getToken(%assetId, ":", 0);
%moduleDef = ModuleDatabase.findModule(%moduleName);
%assetName = getToken(%assetId, ":", 1);
%assetFilePath = AssetDatabase.getAssetFilePath(%assetId);
AssetDatabase.removeDeclaredAsset(%assetId);
AssetDatabase.addDeclaredAsset(%moduleDef, %assetFilePath);
}
function AssetBrowser::refreshAsset(%this, %assetId)
{
if(%assetId $= "")
{
//if we have no passed-in asset ID, we're probably going through the popup menu, so get our edit popup id
%assetId = EditAssetPopup.assetId;
}
AssetDatabase.refreshAsset(%assetId);
%this.refresh();
}
//------------------------------------------------------------
Removed unneeded default irradiance and prefilter cubemaps, and their convars Added getGUIPath console function to guiAsset Corrected console function documentation for getScriptPath in MaterialAsset Added getter console functions to PostEffectAsset Added getAnimationPath console function to PostEffectAsset Fixes handling of mapto with the reskin usage when generating preview renders for ShapeAssets Standardizes getShapeFile to getShapePath on ShapeAsset to better match formatting of other getters on assets Adds sanity checking for getStringWidth to prevent crash if there's an issue with the font being ready at time of request(from Az) Earlies out on rendering of impostors if it's the deferred bin to prevent unneeded duplicate rendering messing up results(from Az) Fixed duplicate naming of quality levels on LightingQualityList Added check so if _makePrettyResString is handed a 'human formatted' resolution string(as in, has <width> x <height> it can handle that properly Shifted yes/no and on/off option lists to globals for ease and consistency of handling on options menu Improves check for unapplied graphics options on options menu and applies them all at once Add sanitizing of variable names so getVariable doesn't have issues when looking up array variables in optionsMenu logic Adds better tracking of what options menu category is shown so refreshes don't reset it Add better handling for changing resolution in options menu and getting it to apply properly Adds better utility functions for setting bools vs optionsLists vs quality lists and updates options fields to use the most appropriate Removes redundant setting of $pref::SFX::channelVolume vars in defaults.tscript Removed unneeded extra logging from asset browser drag-n-drop actions Adds item to RMB context menu in AB to regenerate preview images Fixes move command for asset types(needed to properly reference the full path of the associated files) and added it for shapes, animations and terrains Added logic so when the dropdown for selecting a target module on the Create New Asset window is changed, it forcefully updates the target path to point to the module to avoid erroneous paths being provided Adds proper clamping of values to Forest Editor's brush size in the editor bar. Could be set to below 1 even though it would visually clamp to 1. Temporarily disables fields and handling of 'open in Torsion'. Fixes bad pixel in gui/images/tab_border.png which was causing it to fail to generate bitmap array properly Makes the New GUI option from menubar in GUI Editor use same Create New Asset method as everything else Disables access to the CubemapDesc reflector field in the material editor as it's not nominally used now in favor of probes Adds proper loading of roughness and metalness fields in material editor Fixes the default ReflectProbePreviewMat to use a better base DiffuseMap (No Material) rather than the occluder Fixes disable display for some options in the advanced panel in the shape editor so they look more fitting to everything else Adds check to avoid spam of markItem errors in the event requested tree item is invalid Fixed remove material button and command in TerrainMaterial Editor
2022-04-04 01:00:30 +00:00
function AssetBrowser::regeneratePreviewImage(%this)
{
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
%dummyObj = new ScriptObject();
%regenCommand = "AssetBrowser.build" @ EditAssetPopup.assetType @
"Preview(" @%assetDef @ "," @ %dummyObj @ ", true);";
eval(%regenCommand);
Removed unneeded default irradiance and prefilter cubemaps, and their convars Added getGUIPath console function to guiAsset Corrected console function documentation for getScriptPath in MaterialAsset Added getter console functions to PostEffectAsset Added getAnimationPath console function to PostEffectAsset Fixes handling of mapto with the reskin usage when generating preview renders for ShapeAssets Standardizes getShapeFile to getShapePath on ShapeAsset to better match formatting of other getters on assets Adds sanity checking for getStringWidth to prevent crash if there's an issue with the font being ready at time of request(from Az) Earlies out on rendering of impostors if it's the deferred bin to prevent unneeded duplicate rendering messing up results(from Az) Fixed duplicate naming of quality levels on LightingQualityList Added check so if _makePrettyResString is handed a 'human formatted' resolution string(as in, has <width> x <height> it can handle that properly Shifted yes/no and on/off option lists to globals for ease and consistency of handling on options menu Improves check for unapplied graphics options on options menu and applies them all at once Add sanitizing of variable names so getVariable doesn't have issues when looking up array variables in optionsMenu logic Adds better tracking of what options menu category is shown so refreshes don't reset it Add better handling for changing resolution in options menu and getting it to apply properly Adds better utility functions for setting bools vs optionsLists vs quality lists and updates options fields to use the most appropriate Removes redundant setting of $pref::SFX::channelVolume vars in defaults.tscript Removed unneeded extra logging from asset browser drag-n-drop actions Adds item to RMB context menu in AB to regenerate preview images Fixes move command for asset types(needed to properly reference the full path of the associated files) and added it for shapes, animations and terrains Added logic so when the dropdown for selecting a target module on the Create New Asset window is changed, it forcefully updates the target path to point to the module to avoid erroneous paths being provided Adds proper clamping of values to Forest Editor's brush size in the editor bar. Could be set to below 1 even though it would visually clamp to 1. Temporarily disables fields and handling of 'open in Torsion'. Fixes bad pixel in gui/images/tab_border.png which was causing it to fail to generate bitmap array properly Makes the New GUI option from menubar in GUI Editor use same Create New Asset method as everything else Disables access to the CubemapDesc reflector field in the material editor as it's not nominally used now in favor of probes Adds proper loading of roughness and metalness fields in material editor Fixes the default ReflectProbePreviewMat to use a better base DiffuseMap (No Material) rather than the occluder Fixes disable display for some options in the advanced panel in the shape editor so they look more fitting to everything else Adds check to avoid spam of markItem errors in the event requested tree item is invalid Fixed remove material button and command in TerrainMaterial Editor
2022-04-04 01:00:30 +00:00
%dummyObj.delete();
AssetDatabase.releaseAsset(EditAssetPopup.assetId);
}
//------------------------------------------------------------
function AssetBrowser::renameAsset(%this)
{
//Find out what type it is
//%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
%curFirstResponder = AssetBrowser.getFirstResponder();
if(%curFirstResponder != 0)
%curFirstResponder.clearFirstResponder();
Changed default terrain paths to go into data/terrains if nothing is set Added default terrianmat definition for warning_material Corrected separator-h image path for a few GUI controls Corrected SelectAssetPathWindow reference so it focuses the window right Changed new asset window to work with new Select Path window and address system Added call to force AssetBrowser to load/initialize when the tools are initialized(ensures anything utilizing assets in other tools don't have reference issues) Standardized drag-n-drop move behavior in the Asset browser so dragging onto the folder tree and a folder in the browser both behave more predictably If import config is set to not allow importing with errors, then the Done button is disabled when errors are detected Updated the example assettype file for the AB Fixed up move/delete/rename behavior for folders in AB Begun full standardization of move/delete/rename actions for other asset types in AB Added standardized call for New Asset field fillouts by letting the asset types populate them Moved terrain block creation to the standard create call so it can accept other normal fields like resolution Updated the 'Do you want to create' terrain block prompts to generate the asset if yes, and if no it'll prompt to go find an existing terrain asset Added placeholder image for terrain material asset for preview Updated refresh behavior for terrain material assets so they properly populate on creation now Added standardized functions to the directoryHandling class for folder/file manipulation Corrected some warnMat image references
2019-12-23 18:37:55 +00:00
if(EditFolderPopup.visible == false)
{
AssetBrowser.selectedAssetPreview-->AssetNameLabel.setActive(true);
AssetBrowser.selectedAssetPreview-->AssetNameLabel.setFirstResponder();
}
}
function AssetBrowser::performRenameAsset(%this, %originalAssetName, %newName)
{
//if the name is different to the asset's original name, rename it!
if(%originalAssetName !$= %newName)
{
Changed default terrain paths to go into data/terrains if nothing is set Added default terrianmat definition for warning_material Corrected separator-h image path for a few GUI controls Corrected SelectAssetPathWindow reference so it focuses the window right Changed new asset window to work with new Select Path window and address system Added call to force AssetBrowser to load/initialize when the tools are initialized(ensures anything utilizing assets in other tools don't have reference issues) Standardized drag-n-drop move behavior in the Asset browser so dragging onto the folder tree and a folder in the browser both behave more predictably If import config is set to not allow importing with errors, then the Done button is disabled when errors are detected Updated the example assettype file for the AB Fixed up move/delete/rename behavior for folders in AB Begun full standardization of move/delete/rename actions for other asset types in AB Added standardized call for New Asset field fillouts by letting the asset types populate them Moved terrain block creation to the standard create call so it can accept other normal fields like resolution Updated the 'Do you want to create' terrain block prompts to generate the asset if yes, and if no it'll prompt to go find an existing terrain asset Added placeholder image for terrain material asset for preview Updated refresh behavior for terrain material assets so they properly populate on creation now Added standardized functions to the directoryHandling class for folder/file manipulation Corrected some warnMat image references
2019-12-23 18:37:55 +00:00
%moduleName = AssetBrowser.selectedModule;
if(EditAssetPopup.assetType !$= "Folder")
{
Changed default terrain paths to go into data/terrains if nothing is set Added default terrianmat definition for warning_material Corrected separator-h image path for a few GUI controls Corrected SelectAssetPathWindow reference so it focuses the window right Changed new asset window to work with new Select Path window and address system Added call to force AssetBrowser to load/initialize when the tools are initialized(ensures anything utilizing assets in other tools don't have reference issues) Standardized drag-n-drop move behavior in the Asset browser so dragging onto the folder tree and a folder in the browser both behave more predictably If import config is set to not allow importing with errors, then the Done button is disabled when errors are detected Updated the example assettype file for the AB Fixed up move/delete/rename behavior for folders in AB Begun full standardization of move/delete/rename actions for other asset types in AB Added standardized call for New Asset field fillouts by letting the asset types populate them Moved terrain block creation to the standard create call so it can accept other normal fields like resolution Updated the 'Do you want to create' terrain block prompts to generate the asset if yes, and if no it'll prompt to go find an existing terrain asset Added placeholder image for terrain material asset for preview Updated refresh behavior for terrain material assets so they properly populate on creation now Added standardized functions to the directoryHandling class for folder/file manipulation Corrected some warnMat image references
2019-12-23 18:37:55 +00:00
if(%this.isMethod("rename" @ EditAssetPopup.assetType))
{
Changed default terrain paths to go into data/terrains if nothing is set Added default terrianmat definition for warning_material Corrected separator-h image path for a few GUI controls Corrected SelectAssetPathWindow reference so it focuses the window right Changed new asset window to work with new Select Path window and address system Added call to force AssetBrowser to load/initialize when the tools are initialized(ensures anything utilizing assets in other tools don't have reference issues) Standardized drag-n-drop move behavior in the Asset browser so dragging onto the folder tree and a folder in the browser both behave more predictably If import config is set to not allow importing with errors, then the Done button is disabled when errors are detected Updated the example assettype file for the AB Fixed up move/delete/rename behavior for folders in AB Begun full standardization of move/delete/rename actions for other asset types in AB Added standardized call for New Asset field fillouts by letting the asset types populate them Moved terrain block creation to the standard create call so it can accept other normal fields like resolution Updated the 'Do you want to create' terrain block prompts to generate the asset if yes, and if no it'll prompt to go find an existing terrain asset Added placeholder image for terrain material asset for preview Updated refresh behavior for terrain material assets so they properly populate on creation now Added standardized functions to the directoryHandling class for folder/file manipulation Corrected some warnMat image references
2019-12-23 18:37:55 +00:00
%oldAssetId = %moduleName @ ":" @ %originalAssetName;
%assetDef = AssetDatabase.acquireAsset(%oldAssetId);
//Do the rename command
Changed default terrain paths to go into data/terrains if nothing is set Added default terrianmat definition for warning_material Corrected separator-h image path for a few GUI controls Corrected SelectAssetPathWindow reference so it focuses the window right Changed new asset window to work with new Select Path window and address system Added call to force AssetBrowser to load/initialize when the tools are initialized(ensures anything utilizing assets in other tools don't have reference issues) Standardized drag-n-drop move behavior in the Asset browser so dragging onto the folder tree and a folder in the browser both behave more predictably If import config is set to not allow importing with errors, then the Done button is disabled when errors are detected Updated the example assettype file for the AB Fixed up move/delete/rename behavior for folders in AB Begun full standardization of move/delete/rename actions for other asset types in AB Added standardized call for New Asset field fillouts by letting the asset types populate them Moved terrain block creation to the standard create call so it can accept other normal fields like resolution Updated the 'Do you want to create' terrain block prompts to generate the asset if yes, and if no it'll prompt to go find an existing terrain asset Added placeholder image for terrain material asset for preview Updated refresh behavior for terrain material assets so they properly populate on creation now Added standardized functions to the directoryHandling class for folder/file manipulation Corrected some warnMat image references
2019-12-23 18:37:55 +00:00
%buildCommand = %this @ ".rename" @ EditAssetPopup.assetType @ "(" @ %assetDef @ "," @ %newName @ ");";
eval(%buildCommand);
}
}
else
{
%buildCommand = %this @ ".renameFolder(\"" @ EditAssetPopup.assetId @ "\",\"" @ %newName @ "\");";
eval(%buildCommand);
}
}
//Make sure everything is refreshed
%this.refresh();
//Update the selection to immediately jump to the new asset
AssetBrowser-->filterTree.clearSelection();
%ModuleItem = AssetBrowser-->filterTree.findItemByName(%moduleName);
2021-05-05 02:49:19 +00:00
// TODO is this correct?
Added sanity check to ensure that the requested file to be scaled via saveScaledImage actually exists Shifts integration of other modules with the OptionsMenu so other modules can inject their own options categories to a callOnModules hook Updated ExampleModule to use new options menu integration angle to show example option Deleted unneeded dropdown_textEdit_image asset def from baseUI Fixed incorrect internal values for the terrainIcon_image asset def that made it present as a redundant terrain material asset Cleaned up old, bad loadFilters calls and replaced them with the proper refresh() calls. Removed old, bad calls for jumping through the asset browser's tree from when it was still hardcoded organization, which cuts down a lot of error spam Cleaned up some of the asset type's preview image assignment code to be more reliable Made terrain materials now use a similar preview proxy shape as regular materials Fixed erroneous duplicate GuiInspectorTypeShapeAssetPtr::onControlDropped, which was breaking drag-n-drop actions of shapeAssets into inspector fields Added proper logic for drag-n-drop actions of imageAssets into inspector fields Add sanity check after creating new asset to avoid redundant attempts at initialization of the new asset Fixed ConvexShape Editor tooling so you can now use the UI to apply the selected material to the selected surface Added tools menu to the menubar with the Project Importer entry so the PI can be launched from either tool Implemented ability to drag-n-drop imageAssets onto MaterialEditor map fields and have it work Implemented ability to drag-n-drop imageAssets onto TerrainMaterial Editor map fields and have it work Made the TerrainMaterial editor dialogue have a non-modal background so you can interact with the editor as normal while it's up Add sanity check to avoid attempting to mark EditorTree items if we couldn't find it's id renamed BaseMap references in terrain material editor to diffuseMap for consistency
2022-03-27 08:05:48 +00:00
/*%assetType = %ModuleItem.getClassName();
2021-05-05 02:49:19 +00:00
%assetTypeId = AssetBrowser-->filterTree.findChildItemByName(%ModuleItem, %assetType);
AssetBrowser-->filterTree.selectItem(%assetTypeId);
%selectedItem = AssetBrowser-->filterTree.getSelectedItem();
AssetBrowser-->filterTree.scrollVisibleByObjectId(%selectedItem);
Added sanity check to ensure that the requested file to be scaled via saveScaledImage actually exists Shifts integration of other modules with the OptionsMenu so other modules can inject their own options categories to a callOnModules hook Updated ExampleModule to use new options menu integration angle to show example option Deleted unneeded dropdown_textEdit_image asset def from baseUI Fixed incorrect internal values for the terrainIcon_image asset def that made it present as a redundant terrain material asset Cleaned up old, bad loadFilters calls and replaced them with the proper refresh() calls. Removed old, bad calls for jumping through the asset browser's tree from when it was still hardcoded organization, which cuts down a lot of error spam Cleaned up some of the asset type's preview image assignment code to be more reliable Made terrain materials now use a similar preview proxy shape as regular materials Fixed erroneous duplicate GuiInspectorTypeShapeAssetPtr::onControlDropped, which was breaking drag-n-drop actions of shapeAssets into inspector fields Added proper logic for drag-n-drop actions of imageAssets into inspector fields Add sanity check after creating new asset to avoid redundant attempts at initialization of the new asset Fixed ConvexShape Editor tooling so you can now use the UI to apply the selected material to the selected surface Added tools menu to the menubar with the Project Importer entry so the PI can be launched from either tool Implemented ability to drag-n-drop imageAssets onto MaterialEditor map fields and have it work Implemented ability to drag-n-drop imageAssets onto TerrainMaterial Editor map fields and have it work Made the TerrainMaterial editor dialogue have a non-modal background so you can interact with the editor as normal while it's up Add sanity check to avoid attempting to mark EditorTree items if we couldn't find it's id renamed BaseMap references in terrain material editor to diffuseMap for consistency
2022-03-27 08:05:48 +00:00
AssetBrowser-->filterTree.buildVisibleTree();*/
}
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector Adjusted expand behavior of guiTree to be more reliable Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields Removed redundant PreMult translucency type code Added setting of feature so probes work when in forward/basic lit mode Corrected indexing error in SQLiteObject class so it properly parses with the updated console API Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy Fixed var when trying to bind the camera to the client Added project setting field to dictate the default render mode between Forward or Deferred Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field Integrated DOF PostFX into updated PostFX Editor paradigm Updated setting group name for vignette postFX Shifted shaderCache to be in data/cache along with other cached files Added helper function to replace strings in a file Fixed ExampleCppObject asset to have correct loose file references Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default Fixed verve reference to root scene group Adjusted location of a nonmodal gui profile so it loads at the correct time Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful Initial work into zip and folder drag-and-drop asset importing support Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions Updated example asset type file Ensured all asset types have proper handling for move, rename and delete actions Fixed double-click behavior on folders in the AB Fixed CPP asset preview Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser Added ability to convert a non-module top-level folder in the AB into a module Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake Fixed convex editor's material handling to work with AB and reference back properly Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open Added some additional common text gui profiles Disabled calls to old editor settings logic in various editors to remove spam Added callOnModules call so tools can initialize properly when the world editor is opened Fixed logic test for visualizers Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
function renameAssetFile(%assetDef, %newName)
{
%assetId = %assetDef.getAssetID();
%module = AssetDatabase.getAssetModule(%assetId);
%moduleId = %module.moduleId;
%assetPath = AssetDatabase.getAssetFilePath(%assetId);
%newPath = filePath(%assetPath) @ "/" @ %newName @ ".asset.taml";
%copiedSuccess = pathCopy(%assetPath, %newPath);
if(!%copiedSuccess)
return "";
%deleteSuccess = fileDelete(%assetPath);
if(!%deleteSuccess)
return "";
//Remove the old declaration
AssetDatabase.removeDeclaredAsset(%assetId);
//Add with the new file
AssetDatabase.addDeclaredAsset(%module, %newPath);
//Perform the rename in the file/system itself
AssetDatabase.renameDeclaredAsset(%assetId, %moduleId @ ":" @ %newName);
}
function renameAssetLooseFile(%file, %newName)
{
%newPath = filePath(%file) @ "/" @ %newName @ fileExt(%file);
%copiedSuccess = pathCopy(%file, %newPath);
if(!%copiedSuccess)
return "";
%deleteSuccess = fileDelete(%file);
if(!%deleteSuccess)
return "";
return fileName(%newPath);
}
function AssetNameField::onReturn(%this)
{
%this.clearFirstResponder();
%this.setActive(false);
AssetBrowser.performRenameAsset(%this.originalAssetName, %this.getText());
}
//------------------------------------------------------------
function AssetBrowser::moveAsset(%this, %assetId, %destination)
{
if(EditAssetPopup.assetType $= "Folder")
{
//Do any cleanup required given the type
if(%this.isMethod("moveFolder"))
Changed default terrain paths to go into data/terrains if nothing is set Added default terrianmat definition for warning_material Corrected separator-h image path for a few GUI controls Corrected SelectAssetPathWindow reference so it focuses the window right Changed new asset window to work with new Select Path window and address system Added call to force AssetBrowser to load/initialize when the tools are initialized(ensures anything utilizing assets in other tools don't have reference issues) Standardized drag-n-drop move behavior in the Asset browser so dragging onto the folder tree and a folder in the browser both behave more predictably If import config is set to not allow importing with errors, then the Done button is disabled when errors are detected Updated the example assettype file for the AB Fixed up move/delete/rename behavior for folders in AB Begun full standardization of move/delete/rename actions for other asset types in AB Added standardized call for New Asset field fillouts by letting the asset types populate them Moved terrain block creation to the standard create call so it can accept other normal fields like resolution Updated the 'Do you want to create' terrain block prompts to generate the asset if yes, and if no it'll prompt to go find an existing terrain asset Added placeholder image for terrain material asset for preview Updated refresh behavior for terrain material assets so they properly populate on creation now Added standardized functions to the directoryHandling class for folder/file manipulation Corrected some warnMat image references
2019-12-23 18:37:55 +00:00
eval(%this @ ".moveFolder("@%assetId@",\""@%destination@"\");");
}
else
{
%assetDef = AssetDatabase.acquireAsset(%assetId);
%assetType = AssetDatabase.getAssetType(%assetId);
//Do any cleanup required given the type
if(%this.isMethod("move"@%assetType))
{
%command = %this @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %destination @ "\");";
eval(%this @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %destination @ "\");");
}
}
%this.refresh();
}
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector Adjusted expand behavior of guiTree to be more reliable Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields Removed redundant PreMult translucency type code Added setting of feature so probes work when in forward/basic lit mode Corrected indexing error in SQLiteObject class so it properly parses with the updated console API Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy Fixed var when trying to bind the camera to the client Added project setting field to dictate the default render mode between Forward or Deferred Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field Integrated DOF PostFX into updated PostFX Editor paradigm Updated setting group name for vignette postFX Shifted shaderCache to be in data/cache along with other cached files Added helper function to replace strings in a file Fixed ExampleCppObject asset to have correct loose file references Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default Fixed verve reference to root scene group Adjusted location of a nonmodal gui profile so it loads at the correct time Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful Initial work into zip and folder drag-and-drop asset importing support Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions Updated example asset type file Ensured all asset types have proper handling for move, rename and delete actions Fixed double-click behavior on folders in the AB Fixed CPP asset preview Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser Added ability to convert a non-module top-level folder in the AB into a module Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake Fixed convex editor's material handling to work with AB and reference back properly Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open Added some additional common text gui profiles Disabled calls to old editor settings logic in various editors to remove spam Added callOnModules call so tools can initialize properly when the world editor is opened Fixed logic test for visualizers Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
function moveAssetFile(%assetDef, %destinationPath)
{
%assetPath = makeFullPath(AssetDatabase.getAssetFilePath(%assetDef.getAssetId()));
%assetFilename = fileName(%assetPath);
2021-05-05 02:49:19 +00:00
%newAssetPath = %destinationPath @ "/" @ %assetFilename;
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector Adjusted expand behavior of guiTree to be more reliable Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields Removed redundant PreMult translucency type code Added setting of feature so probes work when in forward/basic lit mode Corrected indexing error in SQLiteObject class so it properly parses with the updated console API Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy Fixed var when trying to bind the camera to the client Added project setting field to dictate the default render mode between Forward or Deferred Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field Integrated DOF PostFX into updated PostFX Editor paradigm Updated setting group name for vignette postFX Shifted shaderCache to be in data/cache along with other cached files Added helper function to replace strings in a file Fixed ExampleCppObject asset to have correct loose file references Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default Fixed verve reference to root scene group Adjusted location of a nonmodal gui profile so it loads at the correct time Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful Initial work into zip and folder drag-and-drop asset importing support Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions Updated example asset type file Ensured all asset types have proper handling for move, rename and delete actions Fixed double-click behavior on folders in the AB Fixed CPP asset preview Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser Added ability to convert a non-module top-level folder in the AB into a module Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake Fixed convex editor's material handling to work with AB and reference back properly Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open Added some additional common text gui profiles Disabled calls to old editor settings logic in various editors to remove spam Added callOnModules call so tools can initialize properly when the world editor is opened Fixed logic test for visualizers Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
2021-05-05 02:49:19 +00:00
%copiedSuccess = pathCopy(%assetPath, %destinationPath @ "/" @ %assetFilename);
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector Adjusted expand behavior of guiTree to be more reliable Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields Removed redundant PreMult translucency type code Added setting of feature so probes work when in forward/basic lit mode Corrected indexing error in SQLiteObject class so it properly parses with the updated console API Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy Fixed var when trying to bind the camera to the client Added project setting field to dictate the default render mode between Forward or Deferred Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field Integrated DOF PostFX into updated PostFX Editor paradigm Updated setting group name for vignette postFX Shifted shaderCache to be in data/cache along with other cached files Added helper function to replace strings in a file Fixed ExampleCppObject asset to have correct loose file references Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default Fixed verve reference to root scene group Adjusted location of a nonmodal gui profile so it loads at the correct time Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful Initial work into zip and folder drag-and-drop asset importing support Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions Updated example asset type file Ensured all asset types have proper handling for move, rename and delete actions Fixed double-click behavior on folders in the AB Fixed CPP asset preview Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser Added ability to convert a non-module top-level folder in the AB into a module Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake Fixed convex editor's material handling to work with AB and reference back properly Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open Added some additional common text gui profiles Disabled calls to old editor settings logic in various editors to remove spam Added callOnModules call so tools can initialize properly when the world editor is opened Fixed logic test for visualizers Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
if(!%copiedSuccess)
return "";
%deleteSuccess = fileDelete(%assetPath);
if(!%deleteSuccess)
return "";
return %newAssetPath;
}
function moveAssetLooseFile(%file, %destinationPath)
{
%filename = fileName(%file);
%copiedSuccess = pathCopy(%file, %destinationPath @ "/" @ %filename);
if(!%copiedSuccess)
return false;
%deleteSuccess = fileDelete(%file);
return %deleteSuccess;
}
//------------------------------------------------------------
function AssetBrowser::duplicateAsset(%this)
{
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
%trailingNum = getTrailingNumber(%assetDef.assetName);
if(%trailingNum != -1)
{
%trailingNum++;
%newName = stripTrailingNumber(%assetDef.assetName) @ (%trailingNum);
}
else
{
%newName = stripTrailingNumber(%assetDef.assetName) @ "1";
}
AssetBrowser_assetNameEditTxt.text = %newName;
AssetBrowser_assetNameEdit.callback = "AssetBrowser.doDuplicateAsset();";
if(EditorSettings.value("AssetManagement/Assets/promptOnRename", "1") == 1)
Canvas.pushDialog(AssetBrowser_assetNameEdit);
else
eval(AssetBrowser_assetNameEdit.callback);
}
function AssetBrowser::doDuplicateAsset(%this)
{
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
if(AssetBrowser_assetNameEditTxt.text !$= "" && AssetBrowser_assetNameEditTxt.text !$= %assetDef.assetName)
{
//this acts as a redirect based on asset type and will enact the appropriate function
//so for a GameObjectAsset, it'll become %this.duplicateGameObjectAsset(%assetDef, %targetModule);
//and call to the tools/assetBrowser/scripts/assetTypes/gameObject.tscript file for implementation
if(%this.isMethod("duplicate"@%assetType))
eval(%this @ ".duplicate"@%assetType@"("@%assetDef@","@AssetBrowser_assetNameEditTxt.text@");");
AssetBrowser.refresh();
}
}
function duplicateAssetFile(%assetDef, %newAssetName)
{
%assetPath = makeFullPath(AssetDatabase.getAssetFilePath(%assetDef.getAssetId()));
%assetFilepath = filePath(%assetPath);
%assetFileExt = fileExt(%assetPath);
%newAssetPath = %assetFilepath @ "/" @ %newAssetName @ ".asset.taml";
%copiedSuccess = pathCopy(%assetPath, %newAssetPath);
if(!%copiedSuccess)
return "";
replaceInFile(%newAssetPath, %assetDef.assetName, %newAssetName);
%module = AssetBrowser.dirHandler.getModuleFromAddress(%newAssetPath);
//Add with the new file
AssetDatabase.addDeclaredAsset(%module, %newAssetPath);
return %newAssetPath;
}
function duplicateAssetLooseFile(%file, %newFilename)
{
%filePath = filePath(%file);
%fileExt = fileExt(%file);
%newPath = %filePath @ "/" @ %newFilename @ %fileExt;
%copiedSuccess = pathCopy(%file, %newPath);
if(!%copiedSuccess)
return "";
return %newPath;
}
//------------------------------------------------------------
function AssetBrowser::deleteAsset(%this)
{
//Find out what type it is
//%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
//%assetType = %assetDef.getClassName();
toolsMessageBoxOKCancel("Warning!", "This will delete the selected content and the files associated to it, do you wish to continue?",
"AssetBrowser.confirmDeleteAsset();", "");
}
function AssetBrowser::confirmDeleteAsset(%this)
{
%currentSelectedItem = AssetBrowserFilterTree.getSelectedItem();
%currentItemParent = AssetBrowserFilterTree.getParentItem(%currentSelectedItem);
if(EditFolderPopup.visible)
{
if(EditFolderPopup.dirPath !$= "")
%folderPath = EditFolderPopup.dirPath;
else
%folderPath = AssetBrowserFilterTree.getItemValue(%currentSelectedItem) @ "/" @ AssetBrowserFilterTree.getItemText(%currentSelectedItem);
if(%this.isMethod("deleteFolder"))
eval(%this @ ".deleteFolder(\""@%folderPath@"\");");
}
else
{
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetType);
if(!isObject(%assetDef))
return;
//Do any cleanup required given the type
if(%this.isMethod("delete"@%assetType))
eval(%this @ ".delete"@%assetType@"("@%assetDef@");");
AssetDatabase.deleteAsset(EditAssetPopup.assetId, true, false);
}
%this.refresh();
}
//------------------------------------------------------------
function AssetBrowser::updateAssetReference(%this, %targetPath, %oldAssetId, %newAssetId)
{
//assetbrowser.updateAssetReference("data/pbr/levels", "pbr:material_ball", "TreeTest:TestTree");
//this will go through every file in the game directory and swap the assetIDs to update the reference in the event something was renamed, or something was moved
//This is potentially disastrous and break a lot of things if done hapazardly, so be careful
%fullPath = makeFullPath(%targetPath);
//First, wipe out any files inside the folder first
%file = findFirstFileMultiExpr( %fullPath @ "/*.*", true);
%fileObj = new FileObject();
new ArrayObject(lineCache);
while( %file !$= "" )
{
lineCache.empty();
%fileModified = false;
if(%fileObj.openForRead(%file))
{
while( !%fileObj.isEOF() )
{
%unModLine = %fileObj.readLine();
%line = strreplace( %unModLine, %oldAssetId, %newAssetId );
if(%unModLine !$= %line)
%fileModified = true;
lineCache.add(%line);
}
}
if(%fileModified && %fileObj.openForWrite(%file))
{
for(%i=0; %i<lineCache.count(); %i++)
{
%line = lineCache.getKey(%i);
%fileObj.writeline(%line);
}
%fileObj.close();
}
%file = findNextFileMultiExpr( %fullPath @ "/*.*" );
}
lineCache.delete();
%fileObj.delete();
}
function AssetBrowser::openFileLocation(%this)
{
%filePath = "";
if(EditAssetPopup.assetId !$= "")
{
%filePath = AssetDatabase.getAssetPath(EditAssetPopup.assetId);
}
else if(EditLevelAssetPopup.assetId !$= "")
{
%filePath = AssetDatabase.getAssetPath(EditAssetPopup.assetId);
}
else if(EditTerrainAssetPopup.assetId !$= "")
{
%filePath = AssetDatabase.getAssetPath(EditAssetPopup.assetId);
}
if(%filePath !$= "")
{
if($platform $= "windows")
{
%cmd = "cd \"" @ makeFullPath(%filePath) @ "\" && start .";
systemCommand(%cmd);
}
else
{
%cmd = "open \"" @ makeFullPath(%filePath) @ "\"";
systemCommand(%cmd);
}
}
}
function AssetBrowser::openFolderLocation(%this)
{
%filePath = AssetBrowser.dirHandler.currentAddress;
if(%filePath !$= "")
{
if($platform $= "windows")
{
%cmd = "cd \"" @ makeFullPath(%filePath) @ "\" && start .";
systemCommand(%cmd);
}
else
{
%cmd = "open \"" @ makeFullPath(%filePath) @ "\"";
systemCommand(%cmd);
}
}
}