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

280 lines
10 KiB
Plaintext
Raw Normal View History

//
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 AssetBrowser::ConvertFolderIntoModule(%this, %folderName)
{
if(!isDirectory("data/" @ %folderName))
return;
AssetBrowser_AddModule-->moduleName.text = %folderName;
AssetBrowser_addModuleWindow.callbackFunction = "AssetBrowser.loadDirectories();";
AssetBrowser_addModuleWindow.CreateNewModule();
}
function AssetBrowser::CreateNewModule(%this)
{
Canvas.pushDialog(AssetBrowser_AddModule);
AssetBrowser_addModuleWindow.selectWindow();
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
AssetBrowser_addModuleWindow.callbackFunction = "AssetBrowser.promptNewModuleFolders();";
}
function AssetBrowser::promptNewModuleFolders(%this)
{
toolsMessageBoxYesNo("Create Folders?",
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
"Do you want to create some common folders for organization of your new Module?",
"AssetBrowser.makeModuleFolders();", //if yes, make the foldesr
"AssetBrowser.loadDirectories();"); //if no, just refresh
}
function AssetBrowser::makeModuleFolders(%this)
{
%moduleId = AssetBrowser.newModuleId;
%moduleDef = ModuleDatabase.findModule(%moduleId);
%modulePath = %moduleDef.ModulePath;
%count = 0;
%defaultModuleFolders[%count++] = "datablocks";
%defaultModuleFolders[%count++] = "terrains";
%defaultModuleFolders[%count++] = "postFXs";
%defaultModuleFolders[%count++] = "levels";
%defaultModuleFolders[%count++] = "shapes";
%defaultModuleFolders[%count++] = "guis";
%defaultModuleFolders[%count++] = "scripts";
%defaultModuleFolders[%count++] = "scripts/client";
%defaultModuleFolders[%count++] = "scripts/server";
for(%i=0; %i <= %count; %i++)
{
%this.dirHandler.createFolder(%modulePath @ "/" @ %defaultModuleFolders[%i]);
}
AssetBrowser.loadDirectories();
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 AssetBrowser::createNewEditorTool(%this)
{
Canvas.pushDialog(AssetBrowser_AddModule);
AssetBrowser_addModuleWindow.selectWindow();
AssetBrowser_addModuleWindow.callbackFunction = "AssetBrowser.loadDirectories();";
AssetBrowser_addModuleWindow.CreateNewModule();
}
function AssetBrowser_editModule::saveModule(%this)
{
//Check what special actions we may need to do, such as renames
%moduleDef = ModuleDatabase.findModule(AssetBrowser.selectedModule, 1);
%oldModuleName = %moduleDef.ModuleID;
if(%oldModuleName !$= AssetBrowser.tempModule.ModuleID)
{
//rename the script file and script namespaces
%oldScriptFilePath = "data/" @ %oldModuleName @ "/" @ %moduleDef.scriptFile;
%newscriptFilePath = "data/" @ AssetBrowser.tempModule.ModuleID @ "/";
%scriptExt = fileExt(%moduleDef.scriptFile);
%newScriptFileName = %newscriptFilePath @ "/" @ AssetBrowser.tempModule.ModuleID @ %scriptExt;
%newScriptFileOldName = %newscriptFilePath @ "/" @ %oldModuleName @ %scriptExt;
%moduleDef.ModuleId = AssetBrowser.tempModule.ModuleID;
%moduleDef.scriptFile = AssetBrowser.tempModule.ModuleID @ %scriptExt;
ModuleDatabase.copyModule(%moduleDef, AssetBrowser.tempModule.ModuleID, "data/" @ AssetBrowser.tempModule.ModuleID);
//Go through our scriptfile and replace the old namespace with the new
%editedFileContents = "";
%file = new FileObject();
if ( %file.openForRead( %newScriptFileOldName ) )
{
while ( !%file.isEOF() )
{
%line = %file.readLine();
%line = trim( %line );
%editedFileContents = %editedFileContents @ strreplace(%line, %oldModuleName, AssetBrowser.tempModule.ModuleID) @ "\n";
}
%file.close();
}
if(%editedFileContents !$= "")
{
%file.openForWrite(%newScriptFileName);
%file.writeline(%editedFileContents);
%file.close();
}
%success = fileDelete(%newScriptFileOldName);
ModuleDatabase.unloadExplicit(%oldModuleName);
%success = fileDelete("data/" @ %oldModuleName);
ModuleDatabase.loadExplicit(AssetBrowser.tempModule.ModuleID);
}
//Now, update the module file itself
//%file = ModuleDatabase.getAssetFilePath(%moduleDef.ModuleID);
//%success = TamlWrite(AssetBrowser_editAsset.editedAsset, %file);
AssetBrowser.loadFilters();
Canvas.popDialog(AssetBrowser_editModule);
}
function AssetBrowser::editModuleInfo(%this)
{
Canvas.pushDialog(AssetBrowser_editModule);
%moduleDef = ModuleDatabase.findModule(AssetBrowser.selectedModule, 1);
AssetBrowser.tempModule = new ModuleDefinition();
AssetBrowser.tempModule.assignFieldsFrom(%moduleDef);
AssetBrowser_editModule.editedModuleId = AssetBrowser.selectedModule;
AssetBrowser_editModule.editedModule = AssetBrowser.tempModule;
Moved unneeded modules to Templates/Modules Added templated getObjectsByClass to Scene for easier engine-side polling of objects, including nested checks for subscenes Proper init'ing of mGamemodeName in LevelAsset, as well as proper fieldType for mIsSubLevel D3D11 added logic to handle scaling down of textures in cubemap arrays for lower texture resolution preferences Added ability to collapse groups programmatically to GuiVariableInspector Upped PSSM shadowmap max size to 4096 Caught GL deferred lighting/probes up to D3D11 Temporarily disabled forward lighting/probes on GL materials until conversion finished Upped smMaxInstancingVerts to 2000 from 200 to support slightly more detailed meshes being instanced Reordered project settings so they load ahead of core modules, so that core modules can actually use project settings Established current preset file for PostFXManager to use for reverting WIP logic for forcing probes to update as part of level lighting load step in loading process Streamlined PostFXManager code, removing unnecessary/redundant files Coverted HDR, Lightrays and SSAO and ExamplePostEffect to use new PostFX Manager/Editor paradigm PostFX manager now enacts callbacks so that postFXs' can process their own settings as well as provide editor fields Changed PostFX editor to work with new callbacks via using VariableInspector Updated PostEffectAsset's template file so new PostFX's will now automatically register with the PostFXManager and have the needed new callbacks for integration Made HDR on by default, removed enable field from editing Made probe bake resolution a project setting Updated many GL postFX shaders to have proper case for PostFx.glsl Example module now loads ExampleGUI and ExamplePostEffect during init'ing Removed unneeded autoload definitions from ExampleModule's module file Fixed Graphics Adapter settings field to properly display as well as apply setting Updated many referenced profiles in tools folder to use the Tools specific gui profiles to make theming more consistent Fixed coloration of tools button bitmap to make theming more consistent Updated a few theme settings for improved visibility with theme, particularly selected/highlighted text Moved AssetBrowser field types to separated folder/files Updated new module creation to properly utilize template file instead of overriding it with a programmatic script generation. Removed unneded default autoload definitions from new modules Added WIP for editing Module/Asset dependencies Updated the PostEffectAsset to properly generate glsl and hlsl files from templates Updated module editor window to display only necessary fields Added WIP of TerrainAsset Added shaderCache gitignore file so folder isn't lost
2019-09-29 11:44:43 +00:00
/// Module configuration.
ModuleEditInspector.startGroup("General");
ModuleEditInspector.addField("ModuleId", "ModuleId", "string", "", AssetBrowser.tempModule.ModuleId, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("VersionId", "VersionId", "string", "", AssetBrowser.tempModule.VersionId, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("BuildId", "BuildId", "string", "", AssetBrowser.tempModule.BuildId, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("enabled", "enabled", "bool", "", AssetBrowser.tempModule.enabled, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("Description", "Description", "command", "", AssetBrowser.tempModule.Description, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("Group", "Group", "string", "", AssetBrowser.tempModule.Group, "", AssetBrowser.tempModule);
ModuleEditInspector.endGroup();
ModuleEditInspector.startGroup("Management");
ModuleEditInspector.addField("Synchronized", "Synchronized", "bool", "", AssetBrowser.tempModule.Synchronized, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("Deprecated", "Deprecated", "bool", "", AssetBrowser.tempModule.Deprecated, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("CriticalMerge", "CriticalMerge", "bool", "", AssetBrowser.tempModule.CriticalMerge, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("OverrideExistingObjects", "OverrideExistingObjects", "bool", "", AssetBrowser.tempModule.OverrideExistingObjects, "", AssetBrowser.tempModule);
ModuleEditInspector.endGroup();
ModuleEditInspector.startGroup("Meta");
ModuleEditInspector.addField("Author", "Author", "string", "", AssetBrowser.tempModule.Author, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("Type", "Type", "string", "", AssetBrowser.tempModule.Type, "", AssetBrowser.tempModule);
ModuleEditInspector.endGroup();
ModuleEditInspector.startGroup("Script");
ModuleEditInspector.addField("ScriptFile", "ScriptFile", "string", "", AssetBrowser.tempModule.ScriptFile, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("CreateFunction", "CreateFunction", "string", "", AssetBrowser.tempModule.CreateFunction, "", AssetBrowser.tempModule);
ModuleEditInspector.addField("DestroyFunction", "DestroyFunction", "string", "", AssetBrowser.tempModule.DestroyFunction, "", AssetBrowser.tempModule);
ModuleEditInspector.endGroup();
ModuleEditInspector.startGroup("Dependencies");
ModuleEditInspector.addField("ModuleDependencies", "Module Dependencies", "ModuleDependenciesButton", "", "", "", AssetBrowser.tempModule);
ModuleEditInspector.endGroup();
}
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
function AssetBrowser::editModuleScript(%this)
{
%moduleDef = ModuleDatabase.findModule(AssetBrowser.selectedModule, 1);
%scriptFile = %moduleDef.ModuleScriptFilePath;
EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);
}
function AssetBrowser::renameModule(%this)
{
}
function AssetBrowser::reloadModule(%this)
{
ModuleDatabase.unregisterModule(AssetBrowser.SelectedModule, 1);
ModuleDatabase.loadExplicit(AssetBrowser.SelectedModule);
}
function AssetBrowser::deleteModule(%this)
{
2020-12-03 06:15:24 +00:00
%moduleDef = ModuleDatabase.findModule(AssetBrowser.selectedModule, 1);
toolsMessageBoxYesNo("Delete Module?",
"This will permanently delete the module " @ %moduleDef.moduleId @ " and all it's contents. <br><br> Do you wish to continue?",
"AssetBrowser.doDeleteModule();",
"");
}
function AssetBrowser::doDeleteModule(%this)
{
//First, get the module path
%moduleDef = ModuleDatabase.findModule(AssetBrowser.selectedModule, 1);
%modulePath = %moduleDef.ModulePath;
//Next, unregister the module
ModuleDatabase.unregisterModule(AssetBrowser.SelectedModule, 1);
//Then, delete it
%this.deleteFolder(%modulePath);
//Remove the module def
%moduleDef.delete();
2020-12-03 06:15:24 +00:00
//And refresh the browser
%this.loadDirectories();
}
function AssetBrowser::RefreshModuleDependencies(%this, %moduleDef)
{
//Iterate through all our modules
//then, iterate through the module's assets
//if an asset has a module that isn't us, queue that into the dependencies list
//AssetBrowser.RefreshModuleDependencies(16823);
%modulePath = filePath(%moduleDef.ModuleFilePath);
%filePattern = "*.tscript" TAB "*.taml" TAB "*.mis";
//First, wipe out any files inside the folder first
%file = makeFullPath(findFirstFileMultiExpr( %filePattern, true));
%fileObj = new FileObject();
%modulesList = ModuleDatabase.findModules(false);
new ArrayObject(moduleDepList);
while( %file !$= "" )
{
if(startsWith(%file, %modulePath))
{
if(%fileObj.openForRead(%file))
{
while( !%fileObj.isEOF() )
{
%line = %fileObj.readLine();
if(%line $= "")
continue;
for(%i=0; %i < getWordCount(%modulesList); %i++)
{
%moduleName = getWord(%modulesList, %i).moduleID;
//if(%moduleName $= %moduleDef.moduleID)
// continue;
%hasMatch = strIsMatchExpr( "*"@%moduleName@":*", %line );
if(%hasMatch)
{
moduleDepList.add(%moduleName);
}
}
}
}
}
%file = makeFullPath(findNextFileMultiExpr( %filePattern ));
}
%fileObj.delete();
}