mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
153 lines
5.2 KiB
Plaintext
153 lines
5.2 KiB
Plaintext
//-----------------------------------------------------------------------------
|
|
// 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.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
function initializeMissionAreaEditor()
|
|
{
|
|
echo(" % - Initializing Mission Area Editor");
|
|
|
|
exec( "./missionAreaEditor.ed." @ $TorqueScriptFileExtension );
|
|
exec( "./missionAreaEditorGui.ed.gui" );
|
|
exec( "./missionAreaEditorGui.ed." @ $TorqueScriptFileExtension );
|
|
|
|
// Add ourselves to EditorGui, where all the other tools reside
|
|
MissionAreaEditorGui.setVisible( false );
|
|
MissionAreaEditorTerrainWindow.setVisible( false );
|
|
MissionAreaEditorPropertiesWindow.setVisible( false );
|
|
|
|
MainSceneTabPanel.add( MissionAreaEditorGui );
|
|
MainSceneTabPanel.add( MissionAreaEditorTerrainWindow );
|
|
MainSceneTabPanel.add( MissionAreaEditorPropertiesWindow );
|
|
|
|
new ScriptObject( MissionAreaEditorPlugin )
|
|
{
|
|
superClass = "EditorPlugin";
|
|
editorGui = MissionAreaEditorGui;
|
|
};
|
|
|
|
MissionAreaEditorPlugin.initSettings();
|
|
}
|
|
|
|
function destroyMissionAreaEditor()
|
|
{
|
|
}
|
|
|
|
function MissionAreaEditorPlugin::onWorldEditorStartup( %this )
|
|
{
|
|
// Add ourselves to the window menu.
|
|
%accel = EditorGui.addToEditorsMenu( "Mission Area Editor", "", MissionAreaEditorPlugin );
|
|
|
|
// Add ourselves to the ToolsToolbar
|
|
%tooltip = "Mission Area Editor (" @ %accel @ ")";
|
|
EditorGui.addToToolsToolbar( "MissionAreaEditorPlugin", "MissionAreaEditorPalette", "ToolsModule:mission_area_n_image", %tooltip );
|
|
|
|
//connect editor windows
|
|
GuiWindowCtrl::attach( MissionAreaEditorPropertiesWindow, MissionAreaEditorTerrainWindow);
|
|
}
|
|
|
|
function MissionAreaEditorPlugin::onActivated( %this )
|
|
{
|
|
%this.readSettings();
|
|
|
|
EditorGui.bringToFront( MissionAreaEditorGui );
|
|
|
|
MissionAreaEditorGui.setVisible(true);
|
|
MissionAreaEditorGui.makeFirstResponder( true );
|
|
|
|
MissionAreaEditorTerrainWindow.setVisible( true );
|
|
MissionAreaEditorPropertiesWindow.setVisible( true );
|
|
|
|
// Set the status bar here until all tool have been hooked up
|
|
EditorGuiStatusBar.setInfo("Mission Area Editor.");
|
|
EditorGuiStatusBar.setSelection("");
|
|
|
|
// Allow the Gui to setup.
|
|
MissionAreaEditorGui.onEditorActivated();
|
|
|
|
Parent::onActivated(%this);
|
|
}
|
|
|
|
function MissionAreaEditorPlugin::onDeactivated( %this )
|
|
{
|
|
%this.writeSettings();
|
|
|
|
MissionAreaEditorGui.setVisible(false);
|
|
MissionAreaEditorTerrainWindow.setVisible( false );
|
|
MissionAreaEditorPropertiesWindow.setVisible( false );
|
|
|
|
// Allow the Gui to cleanup.
|
|
MissionAreaEditorGui.onEditorDeactivated();
|
|
|
|
Parent::onDeactivated(%this);
|
|
}
|
|
|
|
function MissionAreaEditorPlugin::setEditorFunction( %this )
|
|
{
|
|
%missionAreaExists = isObject(getMissionAreaServerObject());
|
|
|
|
if( %missionAreaExists == false )
|
|
toolsMessageBoxYesNoCancel("No Mission Area","Would you like to create a New Mission Area?", "MissionAreaEditorPlugin.createNewMissionArea();");
|
|
|
|
return %missionAreaExists;
|
|
}
|
|
|
|
function MissionAreaEditorPlugin::createNewMissionArea(%this)
|
|
{
|
|
%newMissionArea = new MissionArea();
|
|
%newMissionArea.area = "-256 -256 512 512";
|
|
|
|
getScene(0).add(%newMissionArea);
|
|
|
|
EditorGui.setEditor(MissionAreaEditorPlugin);
|
|
|
|
EWorldEditor.isDirty = true;
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
// Settings
|
|
//-----------------------------------------------------------------------------
|
|
|
|
function MissionAreaEditorPlugin::initSettings( %this )
|
|
{
|
|
EditorSettings.beginGroup( "MissionAreaEditor", true );
|
|
|
|
EditorSettings.setDefaultValue( "MissionBoundsColor", "255 255 255" );
|
|
|
|
EditorSettings.endGroup();
|
|
}
|
|
|
|
function MissionAreaEditorPlugin::readSettings( %this )
|
|
{
|
|
EditorSettings.beginGroup( "MissionAreaEditor", true );
|
|
|
|
MissionAreaEditorTerrainEditor.missionBoundsColor = EditorSettings.value("MissionBoundsColor");
|
|
|
|
EditorSettings.endGroup();
|
|
}
|
|
|
|
function MissionAreaEditorPlugin::writeSettings( %this )
|
|
{
|
|
EditorSettings.beginGroup( "MissionAreaEditor", true );
|
|
|
|
EditorSettings.setValue( "MissionBoundsColor", MissionAreaEditorTerrainEditor.missionBoundsColor );
|
|
|
|
EditorSettings.endGroup();
|
|
}
|