mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
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
336 lines
11 KiB
Plaintext
336 lines
11 KiB
Plaintext
//-----------------------------------------------------------------------------
|
|
// 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)
|
|
{
|
|
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress).ModuleId;
|
|
|
|
if(%targetModule $= "")
|
|
%targetModule = EditorSettings.value("Assets/New/defaultModule", "");
|
|
|
|
NewAssetTargetModule.setText(%targetModule);
|
|
|
|
%moduleDef = ModuleDatabase.findModule(%targetModule);
|
|
|
|
%targetPath = AssetBrowser.dirHandler.currentAddress;
|
|
if(!startsWith(%targetPath, %moduleDef.ModulePath))
|
|
{
|
|
%targetPath = %moduleDef.ModulePath;
|
|
}
|
|
|
|
NewAssetTargetAddress.text = %targetPath;
|
|
}
|
|
|
|
function AssetBrowser_newAssetWindow::onClose(%this)
|
|
{
|
|
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();
|
|
}
|
|
|
|
function AssetBrowser::setupCreateNewAsset(%this, %assetType, %moduleName, %callback, %nameOverride)
|
|
{
|
|
Canvas.pushDialog(AssetBrowser_newAsset);
|
|
|
|
%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;
|
|
|
|
%newAssetName = "New" @ %shortAssetTypeName;
|
|
if(%nameOverride !$= "")
|
|
%newAssetName = %nameOverride;
|
|
|
|
NewAssetPropertiesInspector.startGroup("General");
|
|
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);
|
|
|
|
NewAssetPropertiesInspector.addCallbackField("description", "Description", "Command", "Description of the new asset", "", "", "updateNewAssetField", %this.newAssetSettings);
|
|
NewAssetPropertiesInspector.endGroup();
|
|
|
|
if(%this.isMethod("setupCreateNew"@%assetType))
|
|
{
|
|
%command = %this @ ".setupCreateNew"@%assetType @"();";
|
|
eval(%command);
|
|
}
|
|
}
|
|
|
|
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 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
|
|
%moduleName = NewAssetTargetModule.getText();
|
|
|
|
if(%moduleName $= "")
|
|
{
|
|
toolsMessageBoxOK( "Error", "Attempted to make a new asset with no module!");
|
|
return;
|
|
}
|
|
|
|
//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
|
|
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();
|
|
} |