mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-21 04:15:36 +00:00
- Reimplements autosave logic to handle levels, subscenes and terrains in a more consistent, reliable way.
- Adds entry to RMB menu in Asset Browser to restore an asset to a backup copy taken from autosaves - Adds reparent out-of-bounds objects button to SceneGroup inspector - Adds ability to have SubScene have a different loading bounds from the actual subscene bounds, allowing load triggering to happen ahead of the bounds of the subscene itself - Fixes asset importer handling of animFPS field to be the correct type - Adds onInspect handling to GameBase allowing better handling for any game class type with editor integration - Add getAssetLooseFileCount and getAssetLooseFile to AssetManager to be able to iterate over all loose files associated to an asset - Add standard/default preload function def to forestItem - Fixes handling of text placement on GuiIconButtonCtrl when text is set to the right - Adds setGlobalCenter utility function - Adds ability to set guiInputCtrl active state - Matched util functions for tracking if left and right mouse buttons are down to EditTSCtrl alongside the existing middle mouse - Add empty element sanity check to appMesh loader - Add callback for GameBase when game is created - Add default graphics options config for steamdeck - Fix typo in assetImportConfig default - Filters SceneGroup utility buttons in inspector to only show for relevent class types
This commit is contained in:
parent
70502d1b0f
commit
bb7ee38bf4
33 changed files with 978 additions and 237 deletions
|
|
@ -99,6 +99,52 @@ function LevelAsset::onEdit(%this)
|
|||
schedule( 1, 0, "EditorOpenMission", %this);
|
||||
}
|
||||
|
||||
function LevelAsset::onShowActionMenu(%this)
|
||||
{
|
||||
if( !isObject( EditLevelAssetPopup ) )
|
||||
{
|
||||
new PopupMenu( EditLevelAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditLevelAssetPopup.clearItems();
|
||||
|
||||
EditLevelAssetPopup.appendItem("Edit Asset" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();");
|
||||
EditLevelAssetPopup.appendItem("Rename Asset" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();");
|
||||
EditLevelAssetPopup.appendItem("Reload Asset" TAB "" TAB $CurrentAssetBrowser @ ".refreshAsset();");
|
||||
EditLevelAssetPopup.appendItem("Asset Properties" TAB "" TAB $CurrentAssetBrowser @ ".editAssetInfo();");
|
||||
EditLevelAssetPopup.appendItem("-");
|
||||
EditLevelAssetPopup.appendItem("Duplicate Asset" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();");
|
||||
EditLevelAssetPopup.appendItem("-");
|
||||
EditLevelAssetPopup.appendItem("Regenerate Preview Image" TAB "" TAB $CurrentAssetBrowser @ ".regeneratePreviewImage();");
|
||||
EditLevelAssetPopup.appendItem("-");
|
||||
EditLevelAssetPopup.appendItem("Restore Backup" TAB RestoreBackupListPopup);
|
||||
EditLevelAssetPopup.appendItem("-");
|
||||
EditLevelAssetPopup.appendItem("Open File Location" TAB "" TAB $CurrentAssetBrowser @ ".openFileLocation();");
|
||||
EditLevelAssetPopup.appendItem("-");
|
||||
EditLevelAssetPopup.appendItem("Delete Asset" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();");
|
||||
|
||||
%assetId = %this.getAssetId();
|
||||
%assetType = AssetDatabase.getAssetType(%assetId);
|
||||
|
||||
EditLevelAssetPopup.objectData = %assetId;
|
||||
EditLevelAssetPopup.objectType = %assetType;
|
||||
|
||||
RestoreBackupListPopup.populateList(%assetId);
|
||||
EditLevelAssetPopup.reloadItems();
|
||||
|
||||
EditLevelAssetPopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditLevelAssetPopup;
|
||||
}
|
||||
|
||||
function LevelAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%previewData.assetName = %this.assetName;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,52 @@ function SubSceneAsset::onCreateNew(%this)
|
|||
return %tamlpath;
|
||||
}
|
||||
|
||||
function SubSceneAsset::onShowActionMenu(%this)
|
||||
{
|
||||
if( !isObject( EditSubSceneAssetPopup ) )
|
||||
{
|
||||
new PopupMenu( EditSubSceneAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditSubSceneAssetPopup.clearItems();
|
||||
|
||||
EditSubSceneAssetPopup.appendItem("Edit Asset" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();");
|
||||
EditSubSceneAssetPopup.appendItem("Rename Asset" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();");
|
||||
EditSubSceneAssetPopup.appendItem("Reload Asset" TAB "" TAB $CurrentAssetBrowser @ ".refreshAsset();");
|
||||
EditSubSceneAssetPopup.appendItem("Asset Properties" TAB "" TAB $CurrentAssetBrowser @ ".editAssetInfo();");
|
||||
EditSubSceneAssetPopup.appendItem("-");
|
||||
EditSubSceneAssetPopup.appendItem("Duplicate Asset" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();");
|
||||
EditSubSceneAssetPopup.appendItem("-");
|
||||
EditSubSceneAssetPopup.appendItem("Regenerate Preview Image" TAB "" TAB $CurrentAssetBrowser @ ".regeneratePreviewImage();");
|
||||
EditSubSceneAssetPopup.appendItem("-");
|
||||
EditSubSceneAssetPopup.appendItem("Restore Backup" TAB RestoreBackupListPopup);
|
||||
EditSubSceneAssetPopup.appendItem("-");
|
||||
EditSubSceneAssetPopup.appendItem("Open File Location" TAB "" TAB $CurrentAssetBrowser @ ".openFileLocation();");
|
||||
EditSubSceneAssetPopup.appendItem("-");
|
||||
EditSubSceneAssetPopup.appendItem("Delete Asset" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();");
|
||||
|
||||
%assetId = %this.getAssetId();
|
||||
%assetType = AssetDatabase.getAssetType(%assetId);
|
||||
|
||||
EditSubSceneAssetPopup.objectData = %assetId;
|
||||
EditSubSceneAssetPopup.objectType = %assetType;
|
||||
|
||||
RestoreBackupListPopup.populateList(%assetId);
|
||||
EditSubSceneAssetPopup.reloadItems();
|
||||
|
||||
EditSubSceneAssetPopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditSubSceneAssetPopup;
|
||||
}
|
||||
|
||||
function SubSceneAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%previewData.assetName = %this.assetName;
|
||||
|
|
|
|||
|
|
@ -132,6 +132,49 @@ function createTerrainBlock(%assetId)
|
|||
//
|
||||
}
|
||||
|
||||
function TerrainAsset::onShowActionMenu(%this)
|
||||
{
|
||||
if( !isObject( EditTerrainAssetPopup ) )
|
||||
{
|
||||
new PopupMenu( EditTerrainAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditTerrainAssetPopup.clearItems();
|
||||
|
||||
EditTerrainAssetPopup.appendItem("Edit Asset" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();");
|
||||
EditTerrainAssetPopup.appendItem("Rename Asset" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();");
|
||||
EditTerrainAssetPopup.appendItem("Reload Asset" TAB "" TAB $CurrentAssetBrowser @ ".refreshAsset();");
|
||||
EditTerrainAssetPopup.appendItem("Asset Properties" TAB "" TAB $CurrentAssetBrowser @ ".editAssetInfo();");
|
||||
EditTerrainAssetPopup.appendItem("-");
|
||||
EditTerrainAssetPopup.appendItem("Duplicate Asset" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();");
|
||||
EditTerrainAssetPopup.appendItem("-");
|
||||
EditTerrainAssetPopup.appendItem("Restore Backup" TAB RestoreBackupListPopup);
|
||||
EditTerrainAssetPopup.appendItem("-");
|
||||
EditTerrainAssetPopup.appendItem("Open File Location" TAB "" TAB $CurrentAssetBrowser @ ".openFileLocation();");
|
||||
EditTerrainAssetPopup.appendItem("-");
|
||||
EditTerrainAssetPopup.appendItem("Delete Asset" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();");
|
||||
|
||||
%assetId = %this.getAssetId();
|
||||
%assetType = AssetDatabase.getAssetType(%assetId);
|
||||
|
||||
EditTerrainAssetPopup.objectData = %assetId;
|
||||
EditTerrainAssetPopup.objectType = %assetType;
|
||||
|
||||
RestoreBackupListPopup.populateList(%assetId);
|
||||
EditTerrainAssetPopup.reloadItems();
|
||||
|
||||
EditTerrainAssetPopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditTerrainAssetPopup;
|
||||
}
|
||||
|
||||
function TerrainAsset::onWorldEditorDropped(%this, %position)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -520,4 +520,87 @@ function AssetBrowser::openFolderLocation(%this, %folderPath)
|
|||
systemCommand(%cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
function AssetBrowser::getAssetBackupCount(%this, %assetId)
|
||||
{
|
||||
//process it and then check if we have any autosave backups
|
||||
%processedId = strReplace(EditAssetPopup.assetId, ":", "_");
|
||||
%autosavePath = "tools/autosave/" @ %processedId @ "/";
|
||||
|
||||
RestoreBackupListPopup.clearItems();
|
||||
|
||||
if(isDirectory(%autosavePath))
|
||||
{
|
||||
%dirs = getDirectoryList(%autosavePath);
|
||||
%count = getFieldCount(%dirs);
|
||||
|
||||
return %count;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function AssetBrowser::restoreAssetBackup(%this, %assetId, %index)
|
||||
{
|
||||
if(!AssetDatabase.isDeclaredAsset(%assetId))
|
||||
{
|
||||
error("AssetBrowser::restoreAssetBackup() - Attempted to restore backed up version of asset: " @ %assetId @ " but asset is not validly declared!");
|
||||
return;
|
||||
}
|
||||
|
||||
//process it and then check if we have any autosave backups
|
||||
%processedId = strReplace(%assetId, ":", "_");
|
||||
%autosavePath = "tools/autosave/" @ %processedId @ "/";
|
||||
|
||||
if(isDirectory(%autosavePath))
|
||||
{
|
||||
%dirs = getDirectoryList(%autosavePath);
|
||||
%count = getFieldCount(%dirs);
|
||||
if(%count > 0)
|
||||
{
|
||||
%saveArray = new ArrayObject(){};
|
||||
//loop over the entries and find the oldest one
|
||||
for(%f=0; %f < %count; %f++)
|
||||
{
|
||||
%saveArray.add(getField(%dirs, %f));
|
||||
}
|
||||
|
||||
%saveArray.sortk();
|
||||
|
||||
%folderName = %saveArray.getKey(%index);
|
||||
|
||||
//now we just copy the contents of the folder into our assetId path and refresh
|
||||
%assetPath = AssetDatabase.getAssetPath(%assetId);
|
||||
|
||||
%autosaveFullPath = %autosavePath @ "/" @ %folderName @ "/";
|
||||
%autosaveFullPath = strReplace(%autosaveFullPath, "//", "/");
|
||||
|
||||
%file = findFirstFile( %autosaveFullPath @ "*.*" );
|
||||
while( %file !$= "" )
|
||||
{
|
||||
%fileName = fileName(%file);
|
||||
%assetFileName = %assetPath @ "/" @ %fileName;
|
||||
|
||||
warn("| Copying file from: " @ %file @ " to: " @ %assetFileName);
|
||||
if(!pathCopy(%file, %assetFileName, false))
|
||||
{
|
||||
error("AssetBrowser::restoreAssetBackup() - Something went wrong when copying the file: " @ %file @ " to " @ %assetFileName);
|
||||
}
|
||||
|
||||
%file = findNextFile( %autosaveFullPath @ "*.*" );
|
||||
}
|
||||
|
||||
AssetBrowser.reloadAsset(%assetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("AssetBrowser::restoreAssetBackup() - Attempted to restore backed up version of asset: " @ %assetId @ " but no autosaves were found!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error("AssetBrowser::restoreAssetBackup() - Attempted to restore backed up version of asset: " @ %assetId @ " but autosave directory doesn't exist!");
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,18 @@ function AssetBrowser::buildPopupMenus(%this)
|
|||
};
|
||||
}
|
||||
|
||||
if( !isObject( RestoreBackupListPopup ) )
|
||||
{
|
||||
new PopupMenu( RestoreBackupListPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
//isPopup = true;
|
||||
|
||||
radioSelection = false;
|
||||
};
|
||||
}
|
||||
|
||||
if( !isObject( EditLevelAssetPopup ) )
|
||||
{
|
||||
new PopupMenu( EditLevelAssetPopup )
|
||||
|
|
@ -59,9 +71,11 @@ function AssetBrowser::buildPopupMenus(%this)
|
|||
item[ 5 ] = "-";
|
||||
Item[ 6 ] = "Duplicate Asset" TAB "" TAB "AssetBrowser.duplicateAsset();";
|
||||
item[ 7 ] = "-";
|
||||
item[ 8 ] = "Open File Location" TAB "" TAB "AssetBrowser.openFileLocation();";
|
||||
Item[ 8 ] = "Restore Backup" TAB RestoreBackupListPopup;
|
||||
item[ 9 ] = "-";
|
||||
item[ 10 ] = "Delete Asset" TAB "" TAB "AssetBrowser.deleteAsset();";
|
||||
item[ 10 ] = "Open File Location" TAB "" TAB "AssetBrowser.openFileLocation();";
|
||||
item[ 11 ] = "-";
|
||||
item[ 12 ] = "Delete Asset" TAB "" TAB "AssetBrowser.deleteAsset();";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
|
|
@ -82,9 +96,11 @@ function AssetBrowser::buildPopupMenus(%this)
|
|||
item[ 3 ] = "-";
|
||||
Item[ 4 ] = "Duplicate Asset" TAB "" TAB "AssetBrowser.duplicateAsset();";
|
||||
item[ 5 ] = "-";
|
||||
item[ 6 ] = "Open File Location" TAB "" TAB "AssetBrowser.openFileLocation();";
|
||||
Item[ 6 ] = "Restore Backup" TAB RestoreBackupListPopup;
|
||||
item[ 7 ] = "-";
|
||||
item[ 8 ] = "Delete Asset" TAB "" TAB "AssetBrowser.deleteAsset();";
|
||||
item[ 8 ] = "Open File Location" TAB "" TAB "AssetBrowser.openFileLocation();";
|
||||
item[ 9 ] = "-";
|
||||
item[ 10 ] = "Delete Asset" TAB "" TAB "AssetBrowser.deleteAsset();";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
|
|
@ -398,3 +414,41 @@ function AddNewScriptAssetPopupMenu::setupDefaultState(%this)
|
|||
function AddNewScriptAssetPopupMenu::setupGuiControls(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function RestoreBackupListPopup::populateList(%this, %assetId)
|
||||
{
|
||||
//process it and then check if we have any autosave backups
|
||||
%processedId = strReplace(%assetId, ":", "_");
|
||||
%autosavePath = "tools/autosave/" @ %processedId @ "/";
|
||||
|
||||
RestoreBackupListPopup.clearItems();
|
||||
|
||||
if(isDirectory(%autosavePath))
|
||||
{
|
||||
%dirs = getDirectoryList(%autosavePath);
|
||||
%count = getFieldCount(%dirs);
|
||||
|
||||
if(%count > 0)
|
||||
{
|
||||
%saveArray = new ArrayObject(){};
|
||||
//loop over the entries and find the oldest one
|
||||
for(%f=0; %f < %count; %f++)
|
||||
{
|
||||
%saveArray.add(getField(%dirs, %f));
|
||||
}
|
||||
|
||||
%saveArray.sortk();
|
||||
|
||||
for(%i=0; %i < %count; %i++)
|
||||
{
|
||||
%folderName = %saveArray.getKey(%i);
|
||||
%labelText = %folderName @ " (" @ fileModifiedTime(%autosavePath @ %folderName) @ ")";
|
||||
RestoreBackupListPopup.addItem(%i, %labelText TAB "" TAB "AssetBrowser.restoreAssetBackup(\"" @ %assetId @ "\"," @ %i @ ");");
|
||||
|
||||
echo("Added restore item: " @ %labelText TAB "" TAB "AssetBrowser.restoreAssetBackup(\"" @ %assetId @ "\"," @ %i @ ");");
|
||||
}
|
||||
|
||||
%saveArray.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue