Merge remote-tracking branch 'devhead/Preview4_0' into tsneo

# Conflicts:
#	Templates/BaseGame/game/data/ui/guis/loadingGui.gui
#	Templates/BaseGame/game/data/ui/guis/mainMenu.gui
#	Templates/BaseGame/game/tools/MainEditor/guis/MainEditorWindow.gui
#	Templates/BaseGame/game/tools/assetBrowser/guis/assetPreviewButtonsTemplate.gui
#	Templates/BaseGame/game/tools/forestEditor/brushes.tscript
This commit is contained in:
Jeff Hutchinson 2021-08-13 20:14:39 -04:00
commit 717c7acca9
2266 changed files with 48780 additions and 26034 deletions

View file

@ -242,18 +242,22 @@ function ShapeEditor::findConstructor( %this, %path )
return -1;
}
function ShapeEditor::createConstructor( %this, %path )
function ShapeEditor::createConstructor( %this, %assetId )
{
%name = strcapitalise( fileBase( %path ) ) @ strcapitalise( getSubStr( fileExt( %path ), 1, 3 ) );
%name = strreplace( %name, "-", "_" );
%name = strreplace( %name, ".", "_" );
%name = AssetDatabase.getAssetName(%assetId);
//%name = strcapitalise( fileBase( %path ) ) @ strcapitalise( getSubStr( fileExt( %path ), 1, 3 ) );
//%name = strreplace( %name, "-", "_" );
//%name = strreplace( %name, ".", "_" );
%name = getUniqueName( %name );
return new TSShapeConstructor( %name ) { baseShape = %path; };
return new TSShapeConstructor( %name ) { baseShapeAsset = %assetId; };
}
function ShapeEditor::saveConstructor( %this, %constructor )
{
%savepath = filePath( %constructor.baseShape ) @ "/" @ fileBase( %constructor.baseShape ) @ "." @ $TorqueScriptFileExtension;
%assetDef = AssetDatabase.acquireAsset(%constructor.baseShapeAsset);
%savepath = %assetDef.getShapeConstructorFilePath();
AssetDatabase.releaseAsset(%constructor.baseShapeAsset);
new PersistenceManager( shapeEd_perMan );
shapeEd_perMan.setDirty( %constructor, %savepath );
shapeEd_perMan.saveDirtyObject( %constructor );
@ -266,8 +270,9 @@ function ShapeEdSelectWindow::onSelect( %this, %path )
// Prompt user to save the old shape if it is dirty
if ( ShapeEditor.isDirty() )
{
%cmd = "showImportDialog( \"" @ %path @ "\", \"ShapeEditor.selectShape( \\\"" @ %path @ "\\\", ";
toolsMessageBoxYesNoCancel( "Shape Modified", "Would you like to save your changes?", %cmd @ "true );\" );", %cmd @ "false );\" );" );
%cmdY = "showImportDialog( \"" @ %path @ "\", \"ShapeEditor.selectShape( \"" @ %path @ "\", true)\" );";
%cmdN = "showImportDialog( \"" @ %path @ "\", \"ShapeEditor.selectShape( \"" @ %path @ "\", false)\" );";
toolsMessageBoxYesNoCancel( "Shape Modified", "Would you like to save your changes?", %cmdY, %cmdN,"" );
}
else
{
@ -276,7 +281,7 @@ function ShapeEdSelectWindow::onSelect( %this, %path )
}
}
function ShapeEditor::selectShape( %this, %path, %saveOld )
function ShapeEditor::selectShape( %this, %shapeAsset, %saveOld )
{
ShapeEdShapeView.setModel( "" );
@ -288,7 +293,7 @@ function ShapeEditor::selectShape( %this, %path, %saveOld )
else if ( ShapeEditor.isDirty() )
{
// Purge all unsaved changes
%oldPath = ShapeEditor.shape.baseShape;
%oldPath = ShapeEditor.shape.baseShapeAsset;
ShapeEditor.shape.delete();
ShapeEditor.shape = 0;
@ -296,9 +301,9 @@ function ShapeEditor::selectShape( %this, %path, %saveOld )
}
// Initialise the shape preview window
if ( !ShapeEdShapeView.setModel( %path ) )
if ( !ShapeEdShapeView.setShapeAsset( %shapeAsset.getAssetId() ) )
{
toolsMessageBoxOK( "Error", "Failed to load '" @ %path @ "'. Check the console for error messages." );
toolsMessageBoxOK( "Error", "Failed to load '" @ %shapeAsset.getAssetId() @ "'. Check the console for error messages." );
return;
}
ShapeEdShapeView.fitToShape();
@ -307,13 +312,13 @@ function ShapeEditor::selectShape( %this, %path, %saveOld )
ShapeEditor.setDirty( false );
// Get ( or create ) the TSShapeConstructor object for this shape
ShapeEditor.shape = ShapeEditor.findConstructor( %path );
ShapeEditor.shape = findShapeConstructorByAssetId( %shapeAsset.getAssetId() );
if ( ShapeEditor.shape <= 0 )
{
ShapeEditor.shape = %this.createConstructor( %path );
ShapeEditor.shape = %this.createConstructor( %shapeAsset );
if ( ShapeEditor.shape <= 0 )
{
error( "ShapeEditor: Error - could not select " @ %path );
error( "ShapeEditor: Error - could not select " @ %shapeAsset.getAssetId() );
return;
}
}
@ -330,7 +335,7 @@ function ShapeEditor::selectShape( %this, %path, %saveOld )
ShapeEdSelectWindow.updateHints();
// Update editor status bar
EditorGuiStatusBar.setSelection( %path );
EditorGuiStatusBar.setSelection( %shapeAsset.getAssetId() );
}
// Handle a selection in the MissionGroup shape selector
@ -1763,7 +1768,8 @@ function ShapeEdSeqFromMenu::onSelect( %this, %id, %text )
%this.setText( %seqFrom );
// Allow the user to browse for an external source of animation data
getLoadFormatFilename( %this @ ".onBrowseSelect", %this.lastPath );
//getLoadFormatFilename( %this @ ".onBrowseSelect", %this.lastPath );
AssetBrowser.showDialog("ShapeAsset", %this @ ".onBrowseSelect");
}
else
{
@ -1771,12 +1777,17 @@ function ShapeEdSeqFromMenu::onSelect( %this, %id, %text )
}
}
function ShapeEdSeqFromMenu::onBrowseSelect( %this, %path )
function ShapeEdSeqFromMenu::onBrowseSelect( %this, %assetId )
{
%path = makeRelativePath( %path, getMainDotCSDir() );
%this.lastPath = %path;
%this.setText( %path );
ShapeEdSequences.onEditSequenceSource( %path );
//%path = makeRelativePath( %path, getMainDotCSDir() );
//%this.lastPath = %path;
%this.setText( %assetId );
%assetDef = AssetDatabase.acquireAsset(%assetId);
%shapePath = %assetDef.getShapeFile();
AssetDatabase.releaseAsset(%assetId);
ShapeEdSequences.onEditSequenceSource( %shapePath );
}
//------------------------------------------------------------------------------
@ -2170,7 +2181,7 @@ function ShapeEdTriggerList::addItem( %this, %frame, %state )
VertSizing = "bottom";
position = %pos SPC "0";
Extent = "2 12";
bitmap = "tools/shapeEditor/images/trigger_marker";
bitmapAsset = "ToolsModule:trigger_marker_image";
};
ShapeEdAnimWindow.getObject(0).addGuiControl( %ctrl );
%this.triggerId++;
@ -2344,7 +2355,7 @@ function ShapeEdMaterials::editSelectedMaterial( %this )
// materials.
pushInstantGroup();
%this.tempShape = new TSStatic() {
shapeName = ShapeEditor.shape.baseShape;
shapeAsset = ShapeEditor.shape.baseShapeAsset;
collisionType = "None";
};
popInstantGroup();
@ -2888,16 +2899,16 @@ function ShapeEdDetails::onSetObjectNode( %this )
}
}
function ShapeEdDetails::onAddMeshFromFile( %this, %path )
function ShapeEdDetails::onAddMeshFromFile( %this, %assetId )
{
if ( %path $= "" )
if ( %assetId $= "" )
{
getLoadFormatFilename( %this @ ".onAddMeshFromFile", %this.lastPath );
AssetBrowser.showDialog("ShapeAsset", %this @ ".onAddMeshFromFile", "", "", "");
return;
}
%path = makeRelativePath( %path, getMainDotCSDir() );
%this.lastPath = %path;
//%path = makeRelativePath( %path, getMainDotCSDir() );
//%this.lastPath = %path;
// Determine the detail level to use for the new geometry
if ( %this-->addGeomTo.getText() $= "current detail" )
@ -2906,8 +2917,8 @@ function ShapeEdDetails::onAddMeshFromFile( %this, %path )
}
else
{
%base = AssetDatabase.getAssetName(%assetId);
// Check if the file has an LODXXX hint at the end of it
%base = fileBase( %path );
%pos = strstr( %base, "_LOD" );
if ( %pos > 0 )
%size = getSubStr( %base, %pos + 4, strlen( %base ) ) + 0;
@ -2919,7 +2930,7 @@ function ShapeEdDetails::onAddMeshFromFile( %this, %path )
%size++;
}
ShapeEditor.doAddMeshFromFile( %path, %size );
ShapeEditor.doAddMeshFromFile( %assetId, %size );
}
function ShapeEdDetails::onDeleteMesh( %this )
@ -2998,7 +3009,11 @@ function ShapeEditor::autoAddDetails( %this, %dest )
//
// Determine the base name of the input file (MyShape_LOD in the example above)
// and use that to find any other shapes in the set.
%base = fileBase( %dest.baseShape );
%assetDef = AssetDatabase.acquireAsset(%dest.baseShapeAsset);
%shapeFile = %assetDef.getShapeFile();
AssetDatabase.releaseAsset(%dest.baseShapeAsset);
%base = fileBase( %shapeFile );
%pos = strstr( %base, "_LOD" );
if ( %pos < 0 )
{
@ -3010,7 +3025,7 @@ function ShapeEditor::autoAddDetails( %this, %dest )
echo( "Base is: " @ %base );
%filePatterns = filePath( %dest.baseShape ) @ "/" @ %base @ "*" @ fileExt( %dest.baseShape );
%filePatterns = filePath( %shapeFile ) @ "/" @ %base @ "*" @ fileExt( %shapeFile );
echo( "Pattern is: " @ %filePatterns );
@ -3019,7 +3034,7 @@ function ShapeEditor::autoAddDetails( %this, %dest )
{
%fullPath = makeRelativePath( %fullPath, getMainDotCSDir() );
if ( %fullPath !$= %dest.baseShape )
if ( %fullPath !$= %shapeFile )
{
echo( "Found LOD shape file: " @ %fullPath );
@ -3039,15 +3054,19 @@ function ShapeEditor::autoAddDetails( %this, %dest )
}
}
function ShapeEditor::addLODFromFile( %this, %dest, %filename, %size, %allowUnmatched )
function ShapeEditor::addLODFromFile( %this, %dest, %assetId, %size, %allowUnmatched )
{
%assetDef = AssetDatabase.acquireAsset(%assetId);
%csPath = %assetDef.getShapeConstructorFilePath();
%filename = %assetDef.getShapeFile();
AssetDatabase.releaseAsset(%assetId);
// Get (or create) a TSShapeConstructor object for the source shape. Need to
// exec the script manually as the resource may not have been loaded yet
%csPath = filePath( %filename ) @ "/" @ fileBase( %filename ) @ "." @ $TorqueScriptFileExtension;
if ( isFile( %csPath ) )
exec( %csPath );
%source = ShapeEditor.findConstructor( %filename );
%source = findShapeConstructorByAssetId( %assetId );
if ( %source == -1 )
%source = ShapeEditor.createConstructor( %filename );
%source.lodType = "SingleSize";
@ -3055,7 +3074,7 @@ function ShapeEditor::addLODFromFile( %this, %dest, %filename, %size, %allowUnma
// Create a temporary TSStatic to ensure the resource is loaded
%temp = new TSStatic() {
shapeName = %filename;
shapeAsset = %assetId;
collisionType = "None";
};
@ -3256,7 +3275,7 @@ function ShapeEdMountWindow::update_onMountSelectionChanged( %this )
%this-->mountSeq.clear();
%this-->mountSeq.add( "<rootpose>", 0 );
%tss = ShapeEditor.findConstructor( %shapePath );
%tss = findShapeConstructorByFilename( %shapePath );
if ( !isObject( %tss ) )
%tss = ShapeEditor.createConstructor( %shapePath );
if ( isObject( %tss ) )

View file

@ -361,7 +361,7 @@ function ActionAddSequence::doit( %this )
//We adjust due to the list "header" row as well
%idx -= 1;
%animSet = "ShapeEditorPlugin.selectedAssetDef.animationSequence"@%idx@"=\"@Asset="@%moduleName@":"@%assetDef.assetName@"\";";
%animSet = "ShapeEditorPlugin.selectedAssetDef.animationSequence"@%idx@"=\"@asset="@%moduleName@":"@%assetDef.assetName@"\";";
eval(%animSet);
%assetPath = AssetDatabase.getAssetFilePath(ShapeEditorPlugin.selectedAssetId);
@ -1007,10 +1007,10 @@ function ActionRemoveMesh::undo( %this )
//------------------------------------------------------------------------------
// Add meshes from file
function ShapeEditor::doAddMeshFromFile( %this, %filename, %size )
function ShapeEditor::doAddMeshFromFile( %this, %assetId, %size )
{
%action = %this.createAction( ActionAddMeshFromFile, "Add mesh from file" );
%action.filename = %filename;
%action.assetId = %assetId;
%action.size = %size;
%this.doAction( %action );
@ -1018,7 +1018,7 @@ function ShapeEditor::doAddMeshFromFile( %this, %filename, %size )
function ActionAddMeshFromFile::doit( %this )
{
%this.meshList = ShapeEditor.addLODFromFile( ShapeEditor.shape, %this.filename, %this.size, 1 );
%this.meshList = ShapeEditor.addLODFromFile( ShapeEditor.shape, %this.assetId, %this.size, 1 );
if ( %this.meshList !$= "" )
{
%count = getFieldCount( %this.meshList );