mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-31 10:05:13 +00:00
commit
eb0351139e
8 changed files with 148 additions and 15 deletions
|
|
@ -97,7 +97,6 @@ void ForestEditorCtrl::onSleep()
|
|||
|
||||
bool ForestEditorCtrl::updateActiveForest( bool createNew )
|
||||
{
|
||||
mForest = dynamic_cast<Forest*>( Sim::findObject( "theForest" ) );
|
||||
Con::executef( this, "onActiveForestUpdated", mForest ? mForest->getIdString() : "", createNew ? "1" : "0" );
|
||||
|
||||
if ( mTool )
|
||||
|
|
@ -400,4 +399,13 @@ DefineConsoleMethod( ForestEditorCtrl, deleteMeshSafe, void, ( const char * obj
|
|||
DefineConsoleMethod( ForestEditorCtrl, isDirty, bool, (), , "" )
|
||||
{
|
||||
return object->isDirty();
|
||||
}
|
||||
|
||||
DefineConsoleMethod(ForestEditorCtrl, setActiveForest, void, (const char * obj), , "( Forest obj )")
|
||||
{
|
||||
Forest *forestObject;
|
||||
if (!Sim::findObject(obj, forestObject))
|
||||
return;
|
||||
|
||||
object->setActiveForest(forestObject);
|
||||
}
|
||||
|
|
@ -86,6 +86,9 @@ class ForestEditorCtrl : public EditTSCtrl
|
|||
/// Causes the editor to reselect the active forest.
|
||||
bool updateActiveForest( bool createNew );
|
||||
|
||||
/// Sets the active Forest
|
||||
void setActiveForest(Forest* forestObject) { mForest = forestObject; }
|
||||
|
||||
/// Returns the active Forest.
|
||||
Forest *getActiveForest() const { return mForest; }
|
||||
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ function parseMissionGroupForIds( %className, %childGroup )
|
|||
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
|
||||
%classIds = %classIds @ parseMissionGroupForIds( %className, (%currentGroup).getObject(%i).getId());
|
||||
}
|
||||
return %classIds;
|
||||
return trim( %classIds );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ function ForestEditorGui::onActiveForestUpdated( %this, %forest, %createNew )
|
|||
/// Called from a message box when a forest is not found.
|
||||
function ForestEditorGui::createForest( %this )
|
||||
{
|
||||
if ( isObject( theForest ) )
|
||||
%forestObject = parseMissionGroupForIds("Forest", "");
|
||||
|
||||
if ( isObject( %forestObject ) )
|
||||
{
|
||||
error( "Cannot create a second 'theForest' Forest!" );
|
||||
return;
|
||||
|
|
@ -64,8 +66,42 @@ function ForestEditorGui::createForest( %this )
|
|||
};
|
||||
|
||||
MECreateUndoAction::submit( theForest );
|
||||
|
||||
ForestEditorInspector.inspect( theForest );
|
||||
|
||||
ForestEditorGui.setActiveForest( theForest );
|
||||
|
||||
//Re-initialize the editor settings so we can start using it immediately.
|
||||
%tool = ForestEditorGui.getActiveTool();
|
||||
if ( isObject( %tool ) )
|
||||
%tool.onActivated();
|
||||
|
||||
if ( %tool == ForestTools->SelectionTool )
|
||||
{
|
||||
%mode = GlobalGizmoProfile.mode;
|
||||
switch$ (%mode)
|
||||
{
|
||||
case "None":
|
||||
ForestEditorSelectModeBtn.performClick();
|
||||
case "Move":
|
||||
ForestEditorMoveModeBtn.performClick();
|
||||
case "Rotate":
|
||||
ForestEditorRotateModeBtn.performClick();
|
||||
case "Scale":
|
||||
ForestEditorScaleModeBtn.performClick();
|
||||
}
|
||||
}
|
||||
else if ( %tool == ForestTools->BrushTool )
|
||||
{
|
||||
%mode = ForestTools->BrushTool.mode;
|
||||
switch$ (%mode)
|
||||
{
|
||||
case "Paint":
|
||||
ForestEditorPaintModeBtn.performClick();
|
||||
case "Erase":
|
||||
ForestEditorEraseModeBtn.performClick();
|
||||
case "EraseSelected":
|
||||
ForestEditorEraseSelectedModeBtn.performClick();
|
||||
}
|
||||
}
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,6 +141,13 @@ function ForestEditorPlugin::onActivated( %this )
|
|||
ForestEditorPropertiesWindow.setVisible( true );
|
||||
ForestEditorGui.makeFirstResponder( true );
|
||||
//ForestEditToolbar.setVisible( true );
|
||||
|
||||
//Get our existing forest object in our current mission if we have one
|
||||
%forestObject = parseMissionGroupForIds("Forest", "");
|
||||
if(isObject(%forestObject))
|
||||
{
|
||||
ForestEditorGui.setActiveForest(%forestObject.getName());
|
||||
}
|
||||
|
||||
%this.map.push();
|
||||
Parent::onActivated(%this);
|
||||
|
|
@ -232,9 +239,27 @@ function ForestEditorPlugin::clearDirty( %this )
|
|||
function ForestEditorPlugin::onSaveMission( %this, %missionFile )
|
||||
{
|
||||
ForestDataManager.saveDirty();
|
||||
|
||||
if ( isObject( theForest ) )
|
||||
theForest.saveDataFile();
|
||||
|
||||
//First, find out if we have an existing forest object
|
||||
%forestObject = parseMissionGroupForIds("Forest", "");
|
||||
|
||||
if ( isObject( %forestObject ) )
|
||||
{
|
||||
//We do. Next, see if we have a file already by polling the datafield.
|
||||
if(%forestObject.dataFile !$= "")
|
||||
{
|
||||
//If we do, just save to the provided file.
|
||||
%forestObject.saveDataFile(%forestObject.dataFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
//We don't, so we'll save in the same place as the mission file and give it the missionpath\missionName.forest
|
||||
//naming convention.
|
||||
%path = filePath(%missionFile);
|
||||
%missionName = fileBase(%missionFile);
|
||||
%forestObject.saveDataFile(%path @ "/" @ %missionName @ ".forest");
|
||||
}
|
||||
}
|
||||
|
||||
ForestBrushGroup.save( "art/forest/brushes.cs" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ function parseMissionGroupForIds( %className, %childGroup )
|
|||
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
|
||||
%classIds = %classIds @ parseMissionGroupForIds( %className, (%currentGroup).getObject(%i).getId());
|
||||
}
|
||||
return %classIds;
|
||||
return trim( %classIds );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ function ForestEditorGui::onActiveForestUpdated( %this, %forest, %createNew )
|
|||
/// Called from a message box when a forest is not found.
|
||||
function ForestEditorGui::createForest( %this )
|
||||
{
|
||||
if ( isObject( theForest ) )
|
||||
%forestObject = parseMissionGroupForIds("Forest", "");
|
||||
|
||||
if ( isObject( %forestObject ) )
|
||||
{
|
||||
error( "Cannot create a second 'theForest' Forest!" );
|
||||
return;
|
||||
|
|
@ -64,8 +66,42 @@ function ForestEditorGui::createForest( %this )
|
|||
};
|
||||
|
||||
MECreateUndoAction::submit( theForest );
|
||||
|
||||
ForestEditorInspector.inspect( theForest );
|
||||
|
||||
ForestEditorGui.setActiveForest( theForest );
|
||||
|
||||
//Re-initialize the editor settings so we can start using it immediately.
|
||||
%tool = ForestEditorGui.getActiveTool();
|
||||
if ( isObject( %tool ) )
|
||||
%tool.onActivated();
|
||||
|
||||
if ( %tool == ForestTools->SelectionTool )
|
||||
{
|
||||
%mode = GlobalGizmoProfile.mode;
|
||||
switch$ (%mode)
|
||||
{
|
||||
case "None":
|
||||
ForestEditorSelectModeBtn.performClick();
|
||||
case "Move":
|
||||
ForestEditorMoveModeBtn.performClick();
|
||||
case "Rotate":
|
||||
ForestEditorRotateModeBtn.performClick();
|
||||
case "Scale":
|
||||
ForestEditorScaleModeBtn.performClick();
|
||||
}
|
||||
}
|
||||
else if ( %tool == ForestTools->BrushTool )
|
||||
{
|
||||
%mode = ForestTools->BrushTool.mode;
|
||||
switch$ (%mode)
|
||||
{
|
||||
case "Paint":
|
||||
ForestEditorPaintModeBtn.performClick();
|
||||
case "Erase":
|
||||
ForestEditorEraseModeBtn.performClick();
|
||||
case "EraseSelected":
|
||||
ForestEditorEraseSelectedModeBtn.performClick();
|
||||
}
|
||||
}
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,6 +141,13 @@ function ForestEditorPlugin::onActivated( %this )
|
|||
ForestEditorPropertiesWindow.setVisible( true );
|
||||
ForestEditorGui.makeFirstResponder( true );
|
||||
//ForestEditToolbar.setVisible( true );
|
||||
|
||||
//Get our existing forest object in our current mission if we have one
|
||||
%forestObject = parseMissionGroupForIds("Forest", "");
|
||||
if(isObject(%forestObject))
|
||||
{
|
||||
ForestEditorGui.setActiveForest(%forestObject.getName());
|
||||
}
|
||||
|
||||
%this.map.push();
|
||||
Parent::onActivated(%this);
|
||||
|
|
@ -232,9 +239,27 @@ function ForestEditorPlugin::clearDirty( %this )
|
|||
function ForestEditorPlugin::onSaveMission( %this, %missionFile )
|
||||
{
|
||||
ForestDataManager.saveDirty();
|
||||
|
||||
if ( isObject( theForest ) )
|
||||
theForest.saveDataFile();
|
||||
|
||||
//First, find out if we have an existing forest object
|
||||
%forestObject = parseMissionGroupForIds("Forest", "");
|
||||
|
||||
if ( isObject( %forestObject ) )
|
||||
{
|
||||
//We do. Next, see if we have a file already by polling the datafield.
|
||||
if(%forestObject.dataFile !$= "")
|
||||
{
|
||||
//If we do, just save to the provided file.
|
||||
%forestObject.saveDataFile(%forestObject.dataFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
//We don't, so we'll save in the same place as the mission file and give it the missionpath\missionName.forest
|
||||
//naming convention.
|
||||
%path = filePath(%missionFile);
|
||||
%missionName = fileBase(%missionFile);
|
||||
%forestObject.saveDataFile(%path @ "/" @ %missionName @ ".forest");
|
||||
}
|
||||
}
|
||||
|
||||
ForestBrushGroup.save( "art/forest/brushes.cs" );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue