mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Merge pull request #760 from Areloch/ForestBrushGroupToolingFixes
Fixes tooling of Forest Editor to be module-friendly
This commit is contained in:
commit
be3be2eb7d
11 changed files with 177 additions and 88 deletions
|
|
@ -21,6 +21,8 @@ function @@::onCreateGameServer(%this)
|
|||
%this.registerDatablock("./scripts/managedData/managedDatablocks");
|
||||
if(isFile("./scripts/managedData/managedForestItemData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedForestItemData");
|
||||
if(isFile("./scripts/managedData/managedForestBrushData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedForestBrushData");
|
||||
if(isFile("./scripts/managedData/managedParticleEmitterData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedParticleEmitterData");
|
||||
if(isFile("./scripts/managedData/managedParticleData." @ $TorqueScriptFileExtension))
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$forestBrushesGroup = new SimGroup( ForestBrushGroup )
|
||||
{
|
||||
};
|
||||
//--- OBJECT WRITE END ---
|
||||
|
|
@ -110,17 +110,45 @@ function ForestEditorGui::createForest( %this )
|
|||
|
||||
function ForestEditorGui::newBrush( %this )
|
||||
{
|
||||
%internalName = getUniqueInternalName( "Brush", ForestBrushGroup, true );
|
||||
AssetBrowser_SelectModule.showDialog("ForestEditorGui.pickedNewBrushTargetModule");
|
||||
AssetBrowser_SelectModuleWindow.selectWindow();
|
||||
}
|
||||
|
||||
function ForestEditorGui::pickedNewBrushTargetModule(%this, %module)
|
||||
{
|
||||
%moduleDef = ModuleDatabase.findModule(%module);
|
||||
|
||||
ForestEditorGui.forestBrushPath = %moduleDef.ModulePath @ "/scripts/managedData/managedForestBrushData." @ $TorqueScriptFileExtension;
|
||||
|
||||
if(!isDirectory(filePath(ForestEditorGui.forestItemDataPath)))
|
||||
{
|
||||
AssetBrowser.dirHandler.createFolder(filePath(ForestEditorGui.forestItemDataPath));
|
||||
}
|
||||
|
||||
%group = ForestBrushSet.findObjectByInternalName(%module @ "ForestBrushGroup");
|
||||
if(!isObject(%group))
|
||||
{
|
||||
%group = new ForestBrushGroup() {
|
||||
internalName = %module @ "ForestBrushGroup";
|
||||
};
|
||||
|
||||
%group.setFilename(ForestEditorGui.forestBrushPath);
|
||||
}
|
||||
|
||||
%internalName = getUniqueInternalName( "Brush", ForestBrushSet, true );
|
||||
|
||||
%brush = new ForestBrush()
|
||||
{
|
||||
class = "ForestBrushGroup";
|
||||
internalName = %internalName;
|
||||
parentGroup = ForestBrushGroup;
|
||||
parentGroup = ForestBrushSet;
|
||||
};
|
||||
|
||||
%group.add(%brush);
|
||||
|
||||
MECreateUndoAction::submit( %brush );
|
||||
|
||||
ForestEditBrushTree.open( ForestBrushGroup );
|
||||
ForestEditBrushTree.open( ForestBrushSet );
|
||||
ForestEditBrushTree.buildVisibleTree(true);
|
||||
%item = ForestEditBrushTree.findItemByObjectId( %brush );
|
||||
ForestEditBrushTree.clearSelection();
|
||||
|
|
@ -135,7 +163,7 @@ function ForestEditorGui::newElement( %this )
|
|||
%sel = ForestEditBrushTree.getSelectedObject();
|
||||
|
||||
if ( !isObject( %sel ) )
|
||||
%parentGroup = ForestBrushGroup;
|
||||
%parentGroup = ForestBrushSet;
|
||||
else
|
||||
{
|
||||
if ( %sel.getClassName() $= "ForestBrushElement" )
|
||||
|
|
@ -144,7 +172,7 @@ function ForestEditorGui::newElement( %this )
|
|||
%parentGroup = %sel;
|
||||
}
|
||||
|
||||
%internalName = getUniqueInternalName( "Element", ForestBrushGroup, true );
|
||||
%internalName = getUniqueInternalName( "Element", ForestBrushSet, true );
|
||||
|
||||
%element = new ForestBrushElement()
|
||||
{
|
||||
|
|
@ -191,37 +219,11 @@ function ForestEditorGui::pickedNewMeshTargetModule(%this, %module)
|
|||
|
||||
function selectNewForestMesh(%selectedShapeAssetId)
|
||||
{
|
||||
/*%spec = "All Mesh Files|*.dts;*.dae|DTS|*.dts|DAE|*.dae";
|
||||
|
||||
%dlg = new OpenFileDialog()
|
||||
{
|
||||
Filters = %spec;
|
||||
DefaultPath = $Pref::WorldEditor::LastPath;
|
||||
DefaultFile = "";
|
||||
ChangePath = true;
|
||||
};
|
||||
|
||||
%ret = %dlg.Execute();
|
||||
|
||||
if ( %ret )
|
||||
{
|
||||
$Pref::WorldEditor::LastPath = filePath( %dlg.FileName );
|
||||
%fullPath = makeRelativePath( %dlg.FileName, getMainDotCSDir() );
|
||||
%file = fileBase( %fullPath );
|
||||
}
|
||||
|
||||
%dlg.delete();*/
|
||||
|
||||
if ( %selectedShapeAssetId $= "")
|
||||
return;
|
||||
|
||||
%name = getUniqueName( AssetDatabase.getAssetName(%selectedShapeAssetId) );
|
||||
|
||||
//%str = "datablock TSForestItemData( " @ %name @ " ) { shapeFile = \"" @ %fullPath @ "\"; };";
|
||||
//eval( %str );
|
||||
|
||||
//%fullPath = AssetDatabase.acquireAsset(%selectedShapeAssetId).getShapePath();
|
||||
|
||||
new TSForestItemData(%name) {
|
||||
shapeAsset = %selectedShapeAssetId;
|
||||
};
|
||||
|
|
@ -418,7 +420,7 @@ function ForestEditBrushTree::handleRenameObject( %this, %name, %obj )
|
|||
{
|
||||
if ( %name !$= "" )
|
||||
{
|
||||
%found = ForestBrushGroup.findObjectByInternalName( %name );
|
||||
%found = ForestBrushSet.findObjectByInternalName( %name );
|
||||
if ( isObject( %found ) && %found.getId() != %obj.getId() )
|
||||
{
|
||||
toolsMessageBoxOK( "Error", "Brush or Element with that name already exists.", "" );
|
||||
|
|
|
|||
|
|
@ -91,25 +91,7 @@ function ForestEditorPlugin::onWorldEditorStartup( %this )
|
|||
{
|
||||
new PersistenceManager( ForestDataManager );
|
||||
|
||||
%brushPath = "tools/forestEditor/brushes." @ $TorqueScriptFileExtension;
|
||||
|
||||
if ( !isFile( %brushPath ) )
|
||||
%successfulFile = createPath( %brushPath );
|
||||
|
||||
// This creates the ForestBrushGroup, all brushes, and elements.
|
||||
exec( %brushpath );
|
||||
|
||||
if ( !isObject( ForestBrushGroup ) )
|
||||
{
|
||||
new SimGroup( ForestBrushGroup );
|
||||
%this.showError = true;
|
||||
}
|
||||
|
||||
ForestEditBrushTree.open( ForestBrushGroup );
|
||||
|
||||
if ( !isObject( ForestItemDataSet ) )
|
||||
new SimSet( ForestItemDataSet );
|
||||
|
||||
ForestEditBrushTree.open( ForestBrushSet );
|
||||
ForestEditMeshTree.open( ForestItemDataSet );
|
||||
|
||||
// Add ourselves to the window menu.
|
||||
|
|
@ -126,8 +108,8 @@ function ForestEditorPlugin::onWorldEditorStartup( %this )
|
|||
|
||||
function ForestEditorPlugin::onWorldEditorShutdown( %this )
|
||||
{
|
||||
if ( isObject( ForestBrushGroup ) )
|
||||
ForestBrushGroup.delete();
|
||||
if ( isObject( ForestBrushSet ) )
|
||||
ForestBrushSet.delete();
|
||||
if ( isObject( ForestDataManager ) )
|
||||
ForestDataManager.delete();
|
||||
}
|
||||
|
|
@ -153,7 +135,7 @@ function ForestEditorPlugin::onActivated( %this )
|
|||
%this.map.push();
|
||||
Parent::onActivated(%this);
|
||||
|
||||
ForestEditBrushTree.open( ForestBrushGroup );
|
||||
ForestEditBrushTree.open( ForestBrushSet );
|
||||
ForestEditMeshTree.open( ForestItemDataSet );
|
||||
|
||||
// Open the Brush tab.
|
||||
|
|
@ -224,12 +206,26 @@ function ForestEditorPlugin::onDeactivated( %this )
|
|||
|
||||
// Also take this opportunity to save.
|
||||
ForestDataManager.saveDirty();
|
||||
%this.saveBrushSet();
|
||||
|
||||
%this.map.pop();
|
||||
|
||||
Parent::onDeactivated(%this);
|
||||
}
|
||||
|
||||
function ForestEditorPlugin::saveBrushSet(%this)
|
||||
{
|
||||
for(%i=0; %i < ForestBrushSet.getCount(); %i++)
|
||||
{
|
||||
%group = ForestBrushSet.getObject(%i);
|
||||
if(%group.isMemberOfClass("ForestBrushGroup"))
|
||||
{
|
||||
%fileName = %group.getFileName();
|
||||
%group.save(%group.getFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ForestEditorPlugin::isDirty( %this )
|
||||
{
|
||||
%dirty = %this.dirty || ForestEditorGui.isDirty();
|
||||
|
|
@ -266,7 +262,8 @@ function ForestEditorPlugin::onSaveMission( %this, %missionFile )
|
|||
}
|
||||
}
|
||||
|
||||
ForestBrushGroup.save( "tools/forestEditor/brushes." @ $TorqueScriptFileExtension );
|
||||
//Make sure our data is up to date too
|
||||
%this.saveBrushSet();
|
||||
}
|
||||
|
||||
function ForestEditorPlugin::onEditorSleep( %this )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue