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

365 lines
11 KiB
Plaintext
Raw Normal View History

//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
function CreateAssetButton::onClick(%this)
{
AddNewAssetPopup.showPopup(Canvas);
}
function AssetBrowser_newAsset::onWake(%this)
{
Misc Quality of Life and Bug fixes Added handling for if preview images on image assets fails to generate, will fallback to using the full image Added handling for double clicking or drag-n-dropping terrain assets to create them Improved handling of field labels in variable inspector by making the stringtable be case sensitive. Added editor settings for handling of asset double click behavior. Can now select between Edit Asset and Spawn Asset. Support is asset type dependent. Added editor setting for auto-importing loose files when navigating to a folder. If on and the user has flagged to also enable auto-import generally, will auto import all unaffiliated loose files in as assets. Added editor setting for default module to use when creating new assets. Updated various tooling logic so when creating a new material, if this and the 'Always Prompt Module Target' setting is off, it will fill in the target module and target asset path info based on the default module. Fixed issue with editors that use managedData scripts where if the path didn't exist, the script file wouldn't be made. Fixed display issue in terrain editor where if you clear the detail map, the normal/macro/orm maps would disable, but not also clear. Fixed handling of cleared maps in terrain editor so it no longer fills empty maps in with the no image image. Fixed handling of creating new material where it would fill in the diffuse with a no texture image as the default. Fixed issue where canceling out of creating a module would still prompt to create the common default folders. Fixed issue where the Select Module window couldn't be closed via the cancel or x buttons. Based on feedback, reduced default size of the Text Pad window. Fixed issue where the Drop At menu list wouldn't correctly display which item was marked after it was changed. Fixed spawning shape asset handling so it uses whatever the editor's Drop At setting is. Improved themeing of regular bitmap buttons in the editor. Based on feedback, flipped layout of Target Module and Target Path in the Create New Asset window. Improved handling of setting up the Target Path for when creating new assets. If a path is not set, and the user has a Default Module, it will default the path to that module.
2021-08-28 23:51:27 +00:00
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress).ModuleId;
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
Misc Quality of Life and Bug fixes Added handling for if preview images on image assets fails to generate, will fallback to using the full image Added handling for double clicking or drag-n-dropping terrain assets to create them Improved handling of field labels in variable inspector by making the stringtable be case sensitive. Added editor settings for handling of asset double click behavior. Can now select between Edit Asset and Spawn Asset. Support is asset type dependent. Added editor setting for auto-importing loose files when navigating to a folder. If on and the user has flagged to also enable auto-import generally, will auto import all unaffiliated loose files in as assets. Added editor setting for default module to use when creating new assets. Updated various tooling logic so when creating a new material, if this and the 'Always Prompt Module Target' setting is off, it will fill in the target module and target asset path info based on the default module. Fixed issue with editors that use managedData scripts where if the path didn't exist, the script file wouldn't be made. Fixed display issue in terrain editor where if you clear the detail map, the normal/macro/orm maps would disable, but not also clear. Fixed handling of cleared maps in terrain editor so it no longer fills empty maps in with the no image image. Fixed handling of creating new material where it would fill in the diffuse with a no texture image as the default. Fixed issue where canceling out of creating a module would still prompt to create the common default folders. Fixed issue where the Select Module window couldn't be closed via the cancel or x buttons. Based on feedback, reduced default size of the Text Pad window. Fixed issue where the Drop At menu list wouldn't correctly display which item was marked after it was changed. Fixed spawning shape asset handling so it uses whatever the editor's Drop At setting is. Improved themeing of regular bitmap buttons in the editor. Based on feedback, flipped layout of Target Module and Target Path in the Create New Asset window. Improved handling of setting up the Target Path for when creating new assets. If a path is not set, and the user has a Default Module, it will default the path to that module.
2021-08-28 23:51:27 +00:00
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)
{
NewAssetPropertiesInspector.clearFields();
Canvas.popDialog(AssetBrowser_newAsset);
}
function NewAssetTypeList::onWake(%this)
{
%this.refresh();
}
function NewAssetTypeList::refresh(%this)
{
%this.clear();
//TODO: make this more automated
//%this.add("GameObject", 0);
%this.add("ComponentAsset", 0);
%this.add("ImageAsset", 1);
%this.add("MaterialAsset", 2);
%this.add("ShapeAsset", 3);
%this.add("SoundAsset", 4);
%this.add("StateMachineAsset", 5);
}
function NewAssetTypeList::onSelected(%this)
{
%assetType = %this.getText();
if(%assetType $= "ComponentAsset")
{
NewComponentAssetSettings.hidden = false;
}
}
function NewAssetModuleBtn::onClick(%this)
{
Canvas.pushDialog(AssetBrowser_AddModule);
AssetBrowser_addModuleWindow.selectWindow();
}
Fixed formatting to match the standard for TerrainMaterialAsset inspector fields Added utility functions to TerrainMaterialAsset for getting the material and fx material definitions Fixed logical flaw with the initialization code that could cause the materialDefinition to be nulled in terrainmaterialassets Fixed layer handling in GroundCover to properly work with TerrainMaterialAssets Added logic to properly exit out of the onAdd in the event no internal name is assigned or if there is a collision. This prevents duplicates from appearing in the terr mat editor when creating a new material Fixed issue where going from a creator item in the AB to selecting a particular asset type would break the filtering because select mode removed collections and creator items, changing all the item ids and breaking references. Added sanity check to prevent attempting to acquire non-assets in the AB, such as creator entries, which would cause console spam Added optional field to provide an override new asset name to the New Asset window Added logic so in the event no FX Material is found when importing a terrain material, it will create a stub entry so it always has one defined Added logic to handle situations where a terrain has a reference to an assetId, but the asset does not exist for whatever reason. Will prompt to create the missing asset, then continue on with the regular saving/editing process as normal Fixed issue where the terrain material editor would try and reference the preview images being used in the display on the editor instead of the proper assetId itself
2022-03-29 06:40:07 +00:00
function AssetBrowser::setupCreateNewAsset(%this, %assetType, %moduleName, %callback, %nameOverride)
{
Canvas.pushDialog(AssetBrowser_newAsset);
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
%shortAssetTypeName = strreplace(%assetType, "Asset", "");
AssetBrowser_newAssetWindow.text = "New" SPC %shortAssetTypeName SPC "Asset";
NewAssetPropertiesInspector.clearFields();
AssetBrowser_newAsset.callbackFunc = %callback;
//get rid of the old one if we had one.
if(isObject(%this.newAssetSettings))
%this.newAssetSettings.delete();
%this.newAssetSettings = new ScriptObject();
%this.newAssetSettings.assetType = %assetType;
%this.newAssetSettings.moduleName = %moduleName;
Fixed formatting to match the standard for TerrainMaterialAsset inspector fields Added utility functions to TerrainMaterialAsset for getting the material and fx material definitions Fixed logical flaw with the initialization code that could cause the materialDefinition to be nulled in terrainmaterialassets Fixed layer handling in GroundCover to properly work with TerrainMaterialAssets Added logic to properly exit out of the onAdd in the event no internal name is assigned or if there is a collision. This prevents duplicates from appearing in the terr mat editor when creating a new material Fixed issue where going from a creator item in the AB to selecting a particular asset type would break the filtering because select mode removed collections and creator items, changing all the item ids and breaking references. Added sanity check to prevent attempting to acquire non-assets in the AB, such as creator entries, which would cause console spam Added optional field to provide an override new asset name to the New Asset window Added logic so in the event no FX Material is found when importing a terrain material, it will create a stub entry so it always has one defined Added logic to handle situations where a terrain has a reference to an assetId, but the asset does not exist for whatever reason. Will prompt to create the missing asset, then continue on with the regular saving/editing process as normal Fixed issue where the terrain material editor would try and reference the preview images being used in the display on the editor instead of the proper assetId itself
2022-03-29 06:40:07 +00:00
%newAssetName = "New" @ %shortAssetTypeName;
if(%nameOverride !$= "")
%newAssetName = %nameOverride;
NewAssetPropertiesInspector.startGroup("General");
Fixed formatting to match the standard for TerrainMaterialAsset inspector fields Added utility functions to TerrainMaterialAsset for getting the material and fx material definitions Fixed logical flaw with the initialization code that could cause the materialDefinition to be nulled in terrainmaterialassets Fixed layer handling in GroundCover to properly work with TerrainMaterialAssets Added logic to properly exit out of the onAdd in the event no internal name is assigned or if there is a collision. This prevents duplicates from appearing in the terr mat editor when creating a new material Fixed issue where going from a creator item in the AB to selecting a particular asset type would break the filtering because select mode removed collections and creator items, changing all the item ids and breaking references. Added sanity check to prevent attempting to acquire non-assets in the AB, such as creator entries, which would cause console spam Added optional field to provide an override new asset name to the New Asset window Added logic so in the event no FX Material is found when importing a terrain material, it will create a stub entry so it always has one defined Added logic to handle situations where a terrain has a reference to an assetId, but the asset does not exist for whatever reason. Will prompt to create the missing asset, then continue on with the regular saving/editing process as normal Fixed issue where the terrain material editor would try and reference the preview images being used in the display on the editor instead of the proper assetId itself
2022-03-29 06:40:07 +00:00
NewAssetPropertiesInspector.addField("assetName", "New Asset Name", "String", "Name of the new asset", %newAssetName, "", %this.newAssetSettings);
//NewAssetPropertiesInspector.addField("AssetType", "New Asset Type", "List", "Type of the new asset", %assetType, "Component,Image,Material,Shape,Sound,State Machine", %newAssetSettings);
//NewAssetPropertiesInspector.addField("friendlyName", "Friendly Name", "String", "Human-readable name of new asset", "", "", %this.newAssetSettings);
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
NewAssetPropertiesInspector.addCallbackField("description", "Description", "Command", "Description of the new asset", "", "", "updateNewAssetField", %this.newAssetSettings);
NewAssetPropertiesInspector.endGroup();
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("setupCreateNew"@%assetType))
{
%command = %this @ ".setupCreateNew"@%assetType @"();";
eval(%command);
}
NewAssetPropertiesInspector.refresh();
}
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
function NewAssetPropertiesInspector::updateNewAssetField(%this)
{
%this.schedule(32, "update");
}
function newAssetUpdatePath(%newPath)
{
AssetBrowser.navigateTo(%newPath);
NewAssetTargetAddress.text = %newPath;
NewAssetTargetModule.text = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress).ModuleId;
}
//
function AssetBrowser::importNewFile(%this)
{
%importingPath = "";
%dlg = new OpenFileDialog()
{
Filters = "(All Files (*.*)|*.*|";
DefaultFile = "";
ChangePath = false;
MustExist = true;
MultipleFiles = false;
forceRelativePath = false;
};
if ( %dlg.Execute() )
{
%importingPath = makeFullPath(%dlg.FileName);
}
%dlg.delete();
AssetBrowser.onBeginDropFiles();
AssetBrowser.onDropFile(%importingPath);
AssetBrowser.onEndDropFiles();
}
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 NewAssetTargetModule::onSelect(%this, %idx, %idy)
{
%newModuleName = %this.getText();
%currentTargetPath = NewAssetTargetAddress.getText();
if(!startsWith(%currentTargetPath, "data/" @ %newModuleName @ "/"))
{
NewAssetTargetAddress.setText("data/" @ %newModuleName @ "/");
}
}
//
//We do a quick validation that mandatory fields are filled in before passing along to the asset-type specific function
function CreateNewAsset()
{
//To enusre that any in-progress-of-being-edited field applies it's changes
%lastEditField = AssetBrowser_newAsset.getFirstResponder();
if(isObject(%lastEditField) && %lastEditField.isMethod("forceValidateText"))
%lastEditField.forceValidateText();
%assetName = AssetBrowser.newAssetSettings.assetName;
if(%assetName $= "")
{
toolsMessageBoxOK( "Error", "Attempted to make a new asset with no name!");
return;
}
%firstChar = getSubStr(%assetName, 0, 1);
if(isInt(%firstChar))
{
toolsMessageBoxOK( "Error", "Names cannot start with a number!");
return;
}
//get the selected module data
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 = NewAssetTargetModule.getText();
if(%moduleName $= "")
{
toolsMessageBoxOK( "Error", "Attempted to make a new asset with no module!");
return;
}
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
//First, we need to make sure we're not creating a conflicting asset
if(AssetDatabase.isDeclaredAsset(%moduleName @ ":" @ %assetName))
{
toolsMessageBoxOK( "Error", "An asset with the ID: " @ %moduleName @ ":" @ %assetName
@ " already exists! Please review and rename.");
return;
}
%assetType = AssetBrowser.newAssetSettings.assetType;
if(%assetType $= "MaterialAsset" || %assetType $= "TerrainMaterialAsset" ||
%assetType $= "GUIAsset")
{
if(isObject(%assetName))
{
toolsMessageBoxOK( "Error", "Attempted to create a new asset that requires " @
"a unique name, as the object definition must be unique. " @
"Please use a new name.");
return;
}
}
%currentTargetPath = NewAssetTargetAddress.getText();
%modulePath = makeRelativePath(ModuleDatabase.findModule(%moduleName).ModulePath);
if(!startsWith(%currentTargetPath, %modulePath))
{
toolsMessageBoxOK( "Error", "Attempting to create a new asset in an invalid path. " @
"Please set the target path to be within the target module folder.");
return;
}
AssetBrowser.newAssetSettings.moduleName = %moduleName;
if(%assetType $= "")
{
toolsMessageBoxOK( "Error", "Attempted to make a new asset with no type!");
return;
}
%assetFilePath = eval(AssetBrowser @ ".create"@%assetType@"();");
Canvas.popDialog(AssetBrowser_newAsset);
//Load it
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
if(!AssetDatabase.isDeclaredAsset(%moduleName @ ":" @ %assetName))
{
%moduleDef = ModuleDatabase.findModule(%moduleName,1);
AssetDatabase.addDeclaredAsset(%moduleDef, %assetFilePath);
//For utilities' sake, we'll acquire it immediately so it can be utilized
//without delay if it's got any script/dependencies stuff
AssetDatabase.acquireAsset("\"" @ %moduleName @ ":" @ %assetName @ "\"");
}
if(AssetBrowser_newAsset.callbackFunc !$= "")
{
%callbackCommand = "" @ AssetBrowser_newAsset.callbackFunc @ "(\"" @ %moduleName @ ":" @ %assetName @ "\");";
eval(%callbackCommand);
}
//Update the selection to immediately jump to the new asset
/*AssetBrowser-->filterTree.clearSelection();
%ModuleItem = AssetBrowser-->filterTree.findItemByName(%moduleName);
%assetTypeId = AssetBrowser-->filterTree.findChildItemByName(%ModuleItem, %assetType);
AssetBrowser-->filterTree.selectItem(%assetTypeId);
%selectedItem = AssetBrowser-->filterTree.getSelectedItem();
AssetBrowser-->filterTree.scrollVisibleByObjectId(%selectedItem);
AssetBrowser-->filterTree.buildVisibleTree(); */
AssetBrowser.refresh();
}
function ParentComponentList::onWake(%this)
{
%this.refresh();
}
function ParentComponentList::refresh(%this)
{
%this.clear();
%assetQuery = new AssetQuery();
if(!AssetDatabase.findAssetType(%assetQuery, "ComponentAsset"))
return; //if we didn't find ANY, just exit
// Find all the types.
%count = %assetQuery.getCount();
/*%categories = "";
for (%i = 0; %i < %count; %i++)
{
%assetId = %assetQuery.getAsset(%i);
%componentAsset = AssetDatabase.acquireAsset(%assetId);
%componentName = %componentAsset.componentName;
if(%componentName $= "")
%componentName = %componentAsset.componentClass;
%this.add(%componentName, %i);
}*/
%categories = "";
for (%i = 0; %i < %count; %i++)
{
%assetId = %assetQuery.getAsset(%i);
%componentAsset = AssetDatabase.acquireAsset(%assetId);
%componentClass = %componentAsset.componentClass;
if (!isInList(%componentClass, %categories))
%categories = %categories TAB %componentClass;
}
%categories = trim(%categories);
%index = 0;
%categoryCount = getFieldCount(%categories);
for (%i = 0; %i < %categoryCount; %i++)
{
%category = getField(%categories, %i);
%this.addCategory(%category);
for (%j = 0; %j < %count; %j++)
{
%assetId = %assetQuery.getAsset(%j);
%componentAsset = AssetDatabase.acquireAsset(%assetId);
%componentName = %componentAsset.componentName;
%componentClass = %componentAsset.componentClass;
if (%componentClass $= %category)
{
if(%componentName !$= "")
%this.add(" "@%componentName, %i);
}
}
}
}
//----------------------------------------------------------
// Game Object creation
//----------------------------------------------------------
function EWorldEditor::createGameObject( %this )
{
AssetBrowser.createGameObjectAsset();
}