mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Adjusts Forest object creation and forest item data creation/management to work with asset/module workflows
This commit is contained in:
parent
bea11acc66
commit
8af6513aea
2 changed files with 40 additions and 11 deletions
|
|
@ -3,7 +3,7 @@ function SelectAssetPath::onWake(%this)
|
||||||
}
|
}
|
||||||
|
|
||||||
//SelectAssetPath.showDialog();
|
//SelectAssetPath.showDialog();
|
||||||
function SelectAssetPath::showDialog(%this, %startingPath, %callback)
|
function SelectAssetPath::showDialog(%this, %startingPath, %callback, %promptText)
|
||||||
{
|
{
|
||||||
if(!isObject(%this.dirHandler))
|
if(!isObject(%this.dirHandler))
|
||||||
%this.dirHandler = makedirectoryHandler(SelectAssetPath-->folderTree, "Core,Tools,cache,shaderCache", "");
|
%this.dirHandler = makedirectoryHandler(SelectAssetPath-->folderTree, "Core,Tools,cache,shaderCache", "");
|
||||||
|
|
@ -12,6 +12,11 @@ function SelectAssetPath::showDialog(%this, %startingPath, %callback)
|
||||||
|
|
||||||
SelectAssetPath-->folderTree.buildIconTable( ":tools/classIcons/Prefab:tools/classIcons/Prefab" @
|
SelectAssetPath-->folderTree.buildIconTable( ":tools/classIcons/Prefab:tools/classIcons/Prefab" @
|
||||||
":tools/classIcons/SimSet:tools/classIcons/SimSet");
|
":tools/classIcons/SimSet:tools/classIcons/SimSet");
|
||||||
|
|
||||||
|
if(%promptText $= "")
|
||||||
|
%promptText = "Select Path";
|
||||||
|
|
||||||
|
SelectAssetPathWindow.text = %promptText;
|
||||||
|
|
||||||
%this.dirHandler.currentPath = %startingPath;
|
%this.dirHandler.currentPath = %startingPath;
|
||||||
%this.callback = %callback;
|
%this.callback = %callback;
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,11 @@ function ForestEditorGui::createForest( %this )
|
||||||
new Forest( theForest )
|
new Forest( theForest )
|
||||||
{
|
{
|
||||||
dataFile = "";
|
dataFile = "";
|
||||||
parentGroup = "MissionGroup";
|
//parentGroup = "MissionGroup";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getRootScene().add(theForest);
|
||||||
|
|
||||||
MECreateUndoAction::submit( theForest );
|
MECreateUndoAction::submit( theForest );
|
||||||
|
|
||||||
ForestEditorGui.setActiveForest( theForest );
|
ForestEditorGui.setActiveForest( theForest );
|
||||||
|
|
@ -169,7 +171,19 @@ function ForestEditorGui::deleteBrushOrElement( %this )
|
||||||
|
|
||||||
function ForestEditorGui::newMesh( %this )
|
function ForestEditorGui::newMesh( %this )
|
||||||
{
|
{
|
||||||
%spec = "All Mesh Files|*.dts;*.dae|DTS|*.dts|DAE|*.dae";
|
SelectAssetPath.showDialog(AssetBrowser.dirHandler.currentAddress, "createNewForestMesh", "Select Forest Mesh Datablock Path");
|
||||||
|
SelectAssetPathWindow.selectWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
function createNewForestMesh(%newPath)
|
||||||
|
{
|
||||||
|
ForestEditorGui.newMeshPath = %newPath;
|
||||||
|
AssetBrowser.showDialog("ShapeAsset", "selectNewForestMesh", "", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectNewForestMesh(%selectedShapeAssetId)
|
||||||
|
{
|
||||||
|
/*%spec = "All Mesh Files|*.dts;*.dae|DTS|*.dts|DAE|*.dae";
|
||||||
|
|
||||||
%dlg = new OpenFileDialog()
|
%dlg = new OpenFileDialog()
|
||||||
{
|
{
|
||||||
|
|
@ -188,15 +202,23 @@ function ForestEditorGui::newMesh( %this )
|
||||||
%file = fileBase( %fullPath );
|
%file = fileBase( %fullPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
%dlg.delete();
|
%dlg.delete();*/
|
||||||
|
|
||||||
if ( !%ret )
|
if ( %selectedShapeAssetId $= "")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
%name = getUniqueName( %file );
|
%name = getUniqueName( AssetDatabase.getAssetName(%selectedShapeAssetId) );
|
||||||
|
|
||||||
%str = "datablock TSForestItemData( " @ %name @ " ) { shapeFile = \"" @ %fullPath @ "\"; };";
|
//%str = "datablock TSForestItemData( " @ %name @ " ) { shapeFile = \"" @ %fullPath @ "\"; };";
|
||||||
eval( %str );
|
//eval( %str );
|
||||||
|
|
||||||
|
%fullPath = AssetDatabase.acquireAsset(%selectedShapeAssetId).getShapeFile();
|
||||||
|
|
||||||
|
new TSForestItemData(%name) {
|
||||||
|
shapeFile = %fullPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
%isrl = isObject( %name );
|
||||||
|
|
||||||
if ( isObject( %name ) )
|
if ( isObject( %name ) )
|
||||||
{
|
{
|
||||||
|
|
@ -206,7 +228,7 @@ function ForestEditorGui::newMesh( %this )
|
||||||
ForestEditMeshTree.scrollVisible( %item );
|
ForestEditMeshTree.scrollVisible( %item );
|
||||||
ForestEditMeshTree.addSelection( %item );
|
ForestEditMeshTree.addSelection( %item );
|
||||||
|
|
||||||
ForestDataManager.setDirty( %name, "art/forest/managedItemData." @ $TorqueScriptFileExtension );
|
ForestDataManager.setDirty( %name, ForestEditorGui.newMeshPath @ "/managedForestItemData." @ $TorqueScriptFileExtension );
|
||||||
|
|
||||||
%element = new ForestBrushElement()
|
%element = new ForestBrushElement()
|
||||||
{
|
{
|
||||||
|
|
@ -233,7 +255,7 @@ function ForestEditorGui::newMesh( %this )
|
||||||
%action.addToManager( Editor.getUndoManager() );
|
%action.addToManager( Editor.getUndoManager() );
|
||||||
|
|
||||||
ForestEditorPlugin.dirty = true;
|
ForestEditorPlugin.dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ForestEditorGui::deleteMesh( %this )
|
function ForestEditorGui::deleteMesh( %this )
|
||||||
|
|
@ -254,8 +276,10 @@ function ForestEditorGui::deleteMesh( %this )
|
||||||
|
|
||||||
function ForestEditorGui::okDeleteMesh( %this, %mesh )
|
function ForestEditorGui::okDeleteMesh( %this, %mesh )
|
||||||
{
|
{
|
||||||
|
%originatingFile = %mesh.getFileName();
|
||||||
|
|
||||||
// Remove mesh from file
|
// Remove mesh from file
|
||||||
ForestDataManager.removeObjectFromFile( %mesh, "art/forest/managedItemData." @ $TorqueScriptFileExtension );
|
ForestDataManager.removeObjectFromFile( %mesh, %originatingFile );
|
||||||
|
|
||||||
// Submitting undo actions is handled in code.
|
// Submitting undo actions is handled in code.
|
||||||
%this.deleteMeshSafe( %mesh );
|
%this.deleteMeshSafe( %mesh );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue