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

136 lines
4.2 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.
//-----------------------------------------------------------------------------
Added/Improved some asset type icons Renamed current default import config to DefaultConfig Updated Asset Browser UI layout. Fixed sizing behavior for Edit Asset window Fixed sizing behavior for Edit Module window Implemented Collection Sets system Implemented handling of non-asset loose files for AB Initial handling logic for prefabs for AB Updated Asset Importer to hook into C++ AssetImporter Made Add Module window properly reset module name field when opened Overhauled entire AB search system so it can use phrases and compound search logic Overhauled asset previews to utilize single guiIconButtonCtrl for efficiency and stability Updated Asset Preview Drag-n-drop to work with new previews Begun initial work with Tags integration into AB - currently only works with datablock categories Bugin initial work with Creator classes - currently only populates category lists, no items Added logic for scanning current AB directory for non-asset loose files, and activating an Auto-Import button if any are found Added ability to drag-n-drop datablocks from AB and spawn requisite object Stabilized drag-n-drop behavior of ShapeAssets, so when spawned, it'll find a much more sane drop position Fixed shapeAsset fields for drag-n-drop behavior so it correctly sets field now Adjusted folder and asset search fields in AB to utilize placeholder text Added logic when creating new module to prompt auto-populating common default folders Shifted preview size to slider Added logic to MenuBuilder so popup menus can utilize bitmap arrays Added editor setting for if to display loose files in AB Minor theme color corrections for some profiles
2020-07-11 21:49:06 +00:00
function AssetBrowser_addModuleWindow::onWake(%this)
{
%this-->ModuleName.setText("");
}
function AssetBrowser_addModuleWindow::onGainFirstResponder(%this)
{
%this-->moduleName.setFirstResponder();
}
function AssetBrowser_addModuleWindow::close()
{
Canvas.popDialog(AssetBrowser_addModule);
}
function AssetBrowser_addModuleWindow::CreateNewModule(%this)
{
%newModuleName = %this-->moduleName.getText();
if(%newModuleName $= "")
return;
echo("Creating a new Module named: " @ %newModuleName);
%moduleFilePath = "data/" @ %newModuleName;
%moduleDefinitionFilePath = %moduleFilePath @ "/" @ %newModuleName @ ".module";
%moduleScriptFilePath = %moduleFilePath @ "/" @ %newModuleName @ "." @ $TorqueScriptFileExtension;
%newModule = new ModuleDefinition()
{
ModuleId = %newModuleName;
versionId = 1;
ScriptFile = %newModuleName;
CreateFunction="onCreate";
DestroyFunction="onDestroy";
Group = "Game";
new DeclaredAssets()
{
Extension = "asset.taml";
Recurse = true;
};
};
TAMLWrite(%newModule, %moduleDefinitionFilePath);
//Now generate the script file for it
%file = new FileObject();
%templateFile = new FileObject();
%moduleTemplateCodeFilePath = AssetBrowser.templateFilesPath @ "module." @ $TorqueScriptFileExtension @ ".template";
if(%file.openForWrite(%moduleScriptFilePath) && %templateFile.openForRead(%moduleTemplateCodeFilePath))
{
while( !%templateFile.isEOF() )
{
%line = %templateFile.readline();
%line = strreplace( %line, "@@", %newModuleName );
%file.writeline(%line);
}
%file.close();
%templateFile.close();
}
else
{
%file.close();
%templateFile.close();
warnf("CreateNewModule - Something went wrong and we couldn't write the script file!");
}
//force a refresh of our modules list
ModuleDatabase.ignoreLoadedGroups(true);
ModuleDatabase.registerModule(%moduleFilePath, %newModuleName @ ".module");
%success = ModuleDatabase.loadExplicit(%newModuleName, 1);
ModuleDatabase.ignoreLoadedGroups(false);
//force a reload of the Module lists
AssetBrowser.refresh();
AssetBrowser.newModuleId = %newModuleName;
Canvas.popDialog(AssetBrowser_addModule);
eval(AssetBrowser_addModuleWindow.callbackFunction);
}
function AssetBrowserModuleList::onWake(%this)
{
%this.refresh();
}
function AssetBrowserModuleList::refresh(%this)
{
%this.clear();
//First, get our list of modules
%moduleList = ModuleDatabase.findModules();
%count = getWordCount(%moduleList);
for(%i=0; %i < %count; %i++)
{
%moduleDef = getWord(%moduleList, %i);
%moduleName = %moduleDef.ModuleId;
%this.add(%moduleName, %i);
}
Adjusted handling for the bitmap and bitmapAsset fields for guiBitmapButtonCtrl to forcefully update the button states when changed, ensuring that the bitmaps refresh when changed via the field Added callback for onResize to guiWindowCtrl so controls - such as the EditorTree - can be properly resized in certain circumstances when the window is changed Added getIncrement() and getRange() to GuiGameSettingsCtrl to better facilitate options manipulation on the script side Corrected some of the console method documentation strings in GuiGameSettingsCtrl Removed some unneeded, extraneous files and their asset definitions that came from odd import conversions. Where applicable, created cleaned up versions to make naming conventions and references stable Fixed canvas mode update text typo: FSAA -> FXAA Added logic to DOF, Light Rays, SSAO and Vignette postFX's to check both the preset setting AND the user preference before enabling. Shifted initialization order so PostFX's are loaded before we configure the canvas, to ensure stuff like the FXAAPostFX exists and can be toggled on on load Fixed multiple issues with options menu: When using gamepad, unable to navigate from categories to options. Fixed so can now traverse as normal Input limitations on gamepad necessitated changing of how setting applying happens, is now done as a 'apply or discard' prompt when leaving the options menu Added proper handling for adjusting settings with gamepad with left/right inputs Fixed issue where the unapplied change for an option was sometimes being processed as an object name rather than an implicit string. Now made to be explicit strings to avoid issue. Made the menu button input for "Select" to go from categories to options gamepad only, and hidden when in the options list Fixed issue where changing window mode didn't correctly affect resolution option. Now set up so changing this field correctly refreshes the resolution option. Specifically, when on borderless, the resolution field does not show, preventing confusion as it is always full resolution Generally have the options list refresh when changes happen to allow any and all fields to be able to dynamically respond to other options having changed improving flexibility. Cleaned up old, unused, commented out functions Added ability on OKCancel message boxes to override the button text if needed Fixed issue with AssetBrowser where the shrink/grow icons next to the preview size slider were not anchored correctly. Adjusted callback logic so if preview slider is clicked on, rather than dragged, it will correctly update the zoom values Added sorting to Modules List dropdown for the AssetBrowser Improved standardization of double-clicking in AssetBrowser. Now defaults to editing action if regularly browsing and selecting if in select mode. Still allows regular per-type overrides as normal Moved definition of GuiDisabledTextEditProfile to gui profiles.ed.tscript file, removed duplicates to stop error spam Adjusted default settings value for double-click action in AB to be edit to prevent unstable behavior Removed old file refs from Load Recent list in the default settings
2022-03-27 03:36:37 +00:00
%this.sort();
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
}
function AssetBrowserSelModuleAddBtn::onClick(%this)
{
AssetBrowser.CreateNewModule("AssetBrowser_selectModule.newModuleAdded();");
}