Full Template for ticket #1

This commit is contained in:
DavidWyand-GG 2012-09-19 11:54:25 -04:00
parent 74f265b3b3
commit f439dc8dcd
2150 changed files with 286240 additions and 0 deletions

View file

@ -0,0 +1,55 @@
//-----------------------------------------------------------------------------
// 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 BaseEditorCanvas::onAdd( %this )
{
%this.createMenuBar();
%panel = new GuiPanel() { internalName = "DocumentContainer"; };
%this.setContent( %panel );
%xOffset = 20;
%yOffset = 20;
for( %i =0; %i<10; %i++ )
{
%window = new GuiWindowCtrl()
{
extent = "200 100";
position = %xOffset SPC %yOffset;
};
%panel.add( %window );
%xOffset += 30;
%yOffset += 30;
}
}
function BaseEditorCanvas::onRemove( %this )
{
%this.destroyMenuBar();
}
function testBaseEditor()
{
%baseEd = new GuiCanvas() { class="BaseEditorCanvas"; };
}

View file

@ -0,0 +1,35 @@
//-----------------------------------------------------------------------------
// 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 initializeBase()
{
echo(" % - Initializing Base Editor");
// Load Custom Editors
loadDirectory( expandFilename( "./canvas" ) );
loadDirectory( expandFilename( "./menuBar" ) );
loadDirectory( expandFilename( "./utils" ) );
}
function destroyBase()
{
}

View file

@ -0,0 +1,81 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
// onAdd creates the base menu's and document controller
function BaseEditorCanvas::createMenuBar( %this )
{
if(isObject(%this.menuBar))
return;
// Menu bar
%this.menuBar = new MenuBar()
{
dynamicItemInsertPos = 3;
// File Menu
new PopupMenu()
{
superClass = "MenuBuilder";
class = "BaseEditorFileMenu";
internalName = "FileMenu";
barTitle = "File";
item[0] = "New..." TAB "Ctrl N" TAB "[this].onNew();";
item[1] = "Open..." TAB "Ctrl O" TAB "[this].onOpen();";
item[2] = "-";
item[3] = "Save" TAB "Ctrl S" TAB "[this].onSave();";
item[4] = "Save As" TAB "Ctrl-Alt S" TAB "[this].onSaveAs();";
item[5] = "Save All" TAB "Ctrl-Shift S" TAB "[this].onSaveAll();";
item[6] = "-";
item[7] = "Import..." TAB "Ctrl-Shift I" TAB "[this].onImport();";
item[8] = "Export..." TAB "Ctrl-Shift E" TAB "[this].onExport();";
item[9] = "-";
item[10] = "Revert" TAB "Ctrl R" TAB "[this].onRevert();";
item[11] = "-";
item[12] = "Close" TAB "Ctrl W" TAB "[this].onClose();";
};
};
}
function BaseEditorCanvas::destroyMenuBar( %this )
{
if( isObject( %this.menuBar ) )
%this.menuBar.delete();
}
function BaseEditorCanvas::onCreateMenu(%this)
{
if( !isObject( %this.menuBar ) )
%this.createMenuBar();
%this.menuBar.attachToCanvas( %this, 0 );
}
function BaseEditorCanvas::onDestroyMenu(%this)
{
if( isObject( %this.menuBar ) )
{
%this.destroyMenuBar();
%this.menuBar.removeFromCanvas( %this );
}
}

View file

@ -0,0 +1,52 @@
//-----------------------------------------------------------------------------
// 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 BaseEditorFileMenu::onNew( %this )
{
}
function BaseEditorFileMenu::onOpen( %this )
{
}
function BaseEditorFileMenu::onSave( %this )
{
}
function BaseEditorFileMenu::onSaveAs( %this )
{
}
function BaseEditorFileMenu::onSaveAll( %this )
{
}
function BaseEditorFileMenu::onRevert( %this )
{
}
function BaseEditorFileMenu::onClose( %this )
{
}
function BaseEditorFileMenu::onImport( %this )
{
}
function BaseEditorFileMenu::onExport( %this )
{
}

View file

@ -0,0 +1,248 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Menu Builder Helper Class
//-----------------------------------------------------------------------------
/// @class MenuBuilder
/// @brief Create Dynamic Context and MenuBar Menus
///
///
/// Summary : The MenuBuilder script class exists merely as a helper for creating
/// popup menu's for use in torque editors. It is setup as a single
/// object with dynamic fields starting with item[0]..[n] that describe
/// how to create the menu in question. An example is below.
///
/// isPopup : isPopup is a persistent field on PopupMenu console class which
/// when specified to true will allow you to perform .showPopup(x,y)
/// commands which allow popupmenu's to be used/reused as menubar menus
/// as well as context menus.
///
/// barPosition : barPosition indicates which index on the menu bar (0 = leftmost)
/// to place this menu if it is attached. Use the attachToMenuBar() command
/// to attach a menu.
///
/// barName : barName specifies the visible name of a menu item that is attached
/// to the global menubar.
///
/// canvas : The GuiCanvas object the menu should be attached to. This defaults to
/// the global Canvas object if unspecified.
///
/// Remarks : If you wish to use a menu as a context popup menu, isPopup must be
/// specified as true at the creation time of the menu.
///
///
/// @li @b item[n] (String) TAB (String) TAB (String) : <c>A Menu Item Definition.</c>
/// @code item[0] = "Open File..." TAB "Ctrl O" TAB "Something::OpenFile"; @endcode
///
/// @li @b isPopup (bool) : <c>If Specified the menu will be considered a popup menu and should be used via .showPopup()</c>
/// @code isPopup = true; @endcode
///
///
/// Example : Creating a @b MenuBar Menu
/// @code
/// %%editMenu = new PopupMenu()
/// {
/// barPosition = 3;
/// barName = "View";
/// superClass = "MenuBuilder";
/// item[0] = "Undo" TAB "Ctrl Z" TAB "levelBuilderUndo(1);";
/// item[1] = "Redo" TAB "Ctrl Y" TAB "levelBuilderRedo(1);";
/// item[2] = "-";
/// };
///
/// %%editMenu.attachToMenuBar( 1, "Edit" );
///
/// @endcode
///
///
/// Example : Creating a @b Context (Popup) Menu
/// @code
/// %%contextMenu = new PopupMenu()
/// {
/// superClass = MenuBuilder;
/// isPopup = true;
/// item[0] = "My Super Cool Item" TAB "Ctrl 2" TAB "echo(\"Clicked Super Cool Item\");";
/// item[1] = "-";
/// };
///
/// %%contextMenu.showPopup();
/// @endcode
///
///
/// Example : Modifying a Menu
/// @code
/// %%editMenu = new PopupMenu()
/// {
/// item[0] = "Foo" TAB "Ctrl F" TAB "echo(\"clicked Foo\")";
/// item[1] = "-";
/// };
/// %%editMenu.addItem( 2, "Bar" TAB "Ctrl B" TAB "echo(\"clicked Bar\")" );
/// %%editMenu.removeItem( 0 );
/// %%editMenu.addItem( 0, "Modified Foo" TAB "Ctrl F" TAB "echo(\"clicked modified Foo\")" );
/// @endcode
///
///
/// @see PopupMenu
///
//-----------------------------------------------------------------------------
// Adds one item to the menu.
// if %item is skipped or "", we will use %item[#], which was set when the menu was created.
// if %item is provided, then we update %item[#].
function MenuBuilder::addItem(%this, %pos, %item)
{
if(%item $= "")
%item = %this.item[%pos];
if(%item !$= %this.item[%pos])
%this.item[%pos] = %item;
%name = getField(%item, 0);
%accel = getField(%item, 1);
%cmd = getField(%item, 2);
// We replace the [this] token with our object ID
%cmd = strreplace( %cmd, "[this]", %this );
%this.item[%pos] = setField( %item, 2, %cmd );
if(isObject(%accel))
{
// If %accel is an object, we want to add a sub menu
%this.insertSubmenu(%pos, %name, %accel);
}
else
{
%this.insertItem(%pos, %name !$= "-" ? %name : "", %accel);
}
}
function MenuBuilder::appendItem(%this, %item)
{
%this.addItem(%this.getItemCount(), %item);
}
function MenuBuilder::onAdd(%this)
{
if(! isObject(%this.canvas))
%this.canvas = Canvas;
for(%i = 0;%this.item[%i] !$= "";%i++)
{
%this.addItem(%i);
}
}
function MenuBuilder::onRemove(%this)
{
%this.removeFromMenuBar();
}
//////////////////////////////////////////////////////////////////////////
function MenuBuilder::onSelectItem(%this, %id, %text)
{
%cmd = getField(%this.item[%id], 2);
if(%cmd !$= "")
{
eval( %cmd );
return true;
}
return false;
}
/// Sets a new name on an existing menu item.
function MenuBuilder::setItemName( %this, %id, %name )
{
%item = %this.item[%id];
%accel = getField(%item, 1);
%this.setItem( %id, %name, %accel );
}
/// Sets a new command on an existing menu item.
function MenuBuilder::setItemCommand( %this, %id, %command )
{
%this.item[%id] = setField( %this.item[%id], 2, %command );
}
/// (SimID this)
/// Wraps the attachToMenuBar call so that it does not require knowledge of
/// barName or barIndex to be removed/attached. This makes the individual
/// MenuBuilder items very easy to add and remove dynamically from a bar.
///
function MenuBuilder::attachToMenuBar( %this )
{
if( %this.barName $= "" )
{
error("MenuBuilder::attachToMenuBar - Menu property 'barName' not specified.");
return false;
}
if( %this.barPosition < 0 )
{
error("MenuBuilder::attachToMenuBar - Menu " SPC %this.barName SPC "property 'barPosition' is invalid, must be zero or greater.");
return false;
}
Parent::attachToMenuBar( %this, %this.canvas, %this.barPosition, %this.barName );
}
//////////////////////////////////////////////////////////////////////////
// Callbacks from PopupMenu. These callbacks are now passed on to submenus
// in C++, which was previously not the case. Thus, no longer anything to
// do in these. I am keeping the callbacks in case they are needed later.
function MenuBuilder::onAttachToMenuBar(%this, %canvas, %pos, %title)
{
}
function MenuBuilder::onRemoveFromMenuBar(%this, %canvas)
{
}
//////////////////////////////////////////////////////////////////////////
/// Method called to setup default state for the menu. Expected to be overriden
/// on an individual menu basis. See the mission editor for an example.
function MenuBuilder::setupDefaultState(%this)
{
for(%i = 0;%this.item[%i] !$= "";%i++)
{
%name = getField(%this.item[%i], 0);
%accel = getField(%this.item[%i], 1);
%cmd = getField(%this.item[%i], 2);
// Pass on to sub menus
if(isObject(%accel))
%accel.setupDefaultState();
}
}
/// Method called to easily enable or disable all items in a menu.
function MenuBuilder::enableAllItems(%this, %enable)
{
for(%i = 0; %this.item[%i] !$= ""; %i++)
{
%this.enableItem(%i, %enable);
}
}

View file

@ -0,0 +1,289 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
// Functionality that allows all editor inspectors to share certain functionality.
//---------------------------------------------------------------------------------------------
function EditorInspectorBase::onAdd( %this )
{
if( !isObject( EditorInspectorBaseDatablockFieldPopup ) )
new PopupMenu( EditorInspectorBaseDatablockFieldPopup )
{
superClass = "MenuBuilder";
isPopup = true;
item[ 0 ] = "Edit Datablock" TAB "" TAB "DatablockEditorPlugin.openDatablock( %this.inspectorField.getData() );";
Item[ 1 ] = "Jump to Definition in Torsion" TAB "" TAB "EditorOpenDeclarationInTorsion( %this.inspectorField.getData() );";
item[ 2 ] = "Inspect Object" TAB "" TAB "inspectObject( %this.inspectorField.getData() );";
item[ 3 ] = "-";
item[ 4 ] = "Copy Value" TAB "" TAB "setClipboard( %this.inspectorField.getData() );";
item[ 5 ] = "Paste Value" TAB "" TAB "%this.inspectorField.apply( getClipboard() );";
item[ 6 ] = "Reset to Default" TAB "" TAB "%this.inspectorField.reset();";
inspectorField = -1;
};
if( !isObject( EditorInspectorBaseFieldPopup ) )
new PopupMenu( EditorInspectorBaseFieldPopup )
{
superClass = "MenuBuilder";
isPopup = true;
item[ 0 ] = "Inspect Object" TAB "" TAB "inspectObject( %this.inspectorField.getData() );";
Item[ 1 ] = "Jump to Definition in Torsion" TAB "" TAB "EditorOpenDeclarationInTorsion( %this.inspectorField.getData() );";
item[ 2 ] = "-";
item[ 3 ] = "Copy Value" TAB "" TAB "setClipboard( %this.inspectorField.getData() );";
item[ 4 ] = "Paste Value" TAB "" TAB "%this.inspectorField.apply( getClipboard() );";
item[ 5 ] = "Reset to Default" TAB "" TAB "%this.inspectorField.reset();";
inspectorField = -1;
};
if( !isObject( EditorInspectorBaseFileFieldPopup ) )
new PopupMenu( EditorInspectorBaseFileFieldPopup )
{
superClass = "MenuBuilder";
isPopup = true;
item[ 0 ] = "Open File" TAB "" TAB "openFile( %this.filePath );";
item[ 1 ] = "Open Folder" TAB "" TAB "openFolder( %this.folderPath );";
item[ 2 ] = "-";
item[ 3 ] = "Copy Value" TAB "" TAB "setClipboard( %this.inspectorField.getData() );";
item[ 4 ] = "Paste Value" TAB "" TAB "%this.inspectorField.apply( getClipboard() );";
item[ 5 ] = "Reset to Default" TAB "" TAB "%this.inspectorField.reset();";
inspectorField = -1;
folderPath = "";
filePath = "";
};
if( !isObject( EditorInspectorBaseShapeFieldPopup ) )
new PopupMenu( EditorInspectorBaseShapeFieldPopup )
{
superClass = "MenuBuilder";
isPopup = true;
item[ 0 ] = "Edit Shape" TAB "" TAB "ShapeEditorPlugin.openShape( %this.inspectorField.getData() );";
item[ 1 ] = "-";
item[ 2 ] = "Open File" TAB "" TAB "openFile( %this.filePath );";
item[ 3 ] = "Open Folder" TAB "" TAB "openFolder( %this.folderPath );";
item[ 4 ] = "-";
item[ 5 ] = "Copy Value" TAB "" TAB "setClipboard( %this.inspectorField.getData() );";
item[ 6 ] = "Paste Value" TAB "" TAB "%this.inspectorField.apply( getClipboard() );";
item[ 7 ] = "Reset to Default" TAB "" TAB "%this.inspectorField.reset();";
inspectorField = -1;
folderPath = "";
filePath = "";
};
if( !isObject( EditorInspectorBaseProfileFieldPopup ) )
new PopupMenu( EditorInspectorBaseProfileFieldPopup )
{
superClass = "MenuBuilder";
isPopup = true;
item[ 0 ] = "Edit Profile" TAB "" TAB "if( !$InGuiEditor ) toggleGuiEditor( true ); GuiEditor.editProfile( %this.inspectorField.getData() );";
item[ 1 ] = "Jump to Definition in Torsion" TAB "" TAB "EditorOpenDeclarationInTorsion( %this.inspectorField.getData() );";
item[ 2 ] = "Inspect Object" TAB "" TAB "inspectObject( %this.inspectorField.getData() );";
item[ 3 ] = "-";
item[ 4 ] = "Copy Value" TAB "" TAB "setClipboard( %this.inspectorField.getData() );";
item[ 5 ] = "Paste Value" TAB "" TAB "%this.inspectorField.apply( getClipboard() );";
item[ 6 ] = "Reset to Default" TAB "" TAB "%this.inspectorField.reset();";
inspectorField = -1;
folderPath = "";
filePath = "";
};
}
//---------------------------------------------------------------------------------------------
function EditorInspectorBase::onFieldRightClick( %this, %field )
{
%obj = %this.getInspectObject();
%fieldValue = %field.getData();
%inspectIndex = -1;
%openFileIndex = -1;
%openFolderIndex = -1;
// Find out if this is a TypeFilename field referring to a shape file.
%isShapeFilenameField = false;
if( %field.getInspectedFieldName() $= "shapeName" )
{
%isShapeFilenameField =
%obj.isMemberOfClass( "PhysicsShape" ) ||
%obj.isMemberOfClass( "TSStatic" );
}
else if( %field.getInspectedFieldName() $= "shapeFile" )
{
%isShapeFilenameField =
%obj.isMemberOfClass( "ShapeBaseData" ) ||
%obj.isMemberOfClass( "ShapeBaseImageData" ) ||
%obj.isMemberOfClass( "ForestItemData" ) ||
%obj.isMemberOfClass( "WheeledVehicleTire" ) ||
%obj.isMemberOfClass( "fxShapeReplicator" ) ||
%obj.isMemberOfClass( "RenderShapeExample" ) ||
%obj.isMemberOfClass( "DebrisData" );
}
// Select the popup.
if( %isShapeFilenameField )
{
%popup = EditorInspectorBaseShapeFieldPopup;
%openFileIndex = 2;
%openFolderIndex = 3;
}
else if( EditorInspectorBase::isFileTypeField( %field ) )
{
%popup = EditorInspectorBaseFileFieldPopup;
%openFileIndex = 0;
%openFolderIndex = 1;
}
else
{
switch$( %field.getClassName() )
{
case "GuiInspectorCustomField":
if( %field.getInspectedFieldName() !$= "parentGroup" )
return;
case "GuiInspectorTypeGuiProfile":
%popup = EditorInspectorBaseProfileFieldPopup;
%popup.enableItem( 0, isObject( %fieldValue ) );
%inspectIndex = 2;
%jumpToIndex = 1;
case "GuiInspectorDatablockField" or
"GuiInspectorTypeSFXDescriptionName" or
"GuiInspectorTypeSFXEnvironmentName" or
"GuiInspectorTypeSFXTrackName" or
"GuiInspectorTypeSFXAmbienceName" or
"GuiInspectorTypeSFXSourceName":
%popup = EditorInspectorBaseDatablockFieldPopup;
%popup.enableItem( 0, isObject( %fieldValue ) );
%inspectIndex = 2;
%jumpToIndex = 1;
default:
%popup = EditorInspectorBaseFieldPopup;
%inspectIndex = 0;
%jumpToIndex = 1;
}
}
if( %inspectIndex != -1 )
{
%isObject = false;
if( EditorInspectorBase::isObjectTypeField( %field ) )
%isObject = isObject( %fieldValue );
%popup.enableItem( %inspectIndex, %isObject );
%popup.enableItem( %jumpToIndex, %isObject );
}
if( %openFileIndex != -1 || %openFolderIndex != -1 )
{
%fullPath = EditorInspectorBase::getFullFilePath( %field );
%popup.filePath = %fullPath;
%popup.folderPath = filePath( %fullPath );
if( %openFileIndex != -1 )
%popup.enableItem( 0, isFile( %fullPath ) );
if( %openFolderIndex != -1 )
%popup.enableItem( 1, isDirectory( %popup.folderPath ) );
}
%popup.inspectorField = %field;
%popup.showPopup( Canvas );
}
//---------------------------------------------------------------------------------------------
function EditorInspectorBase::isObjectTypeField( %field )
{
// Inspector field types that refer to objects.
switch$( %field.getClassName() )
{
case "GuiInspectorDatablockField" or
"GuiInspectorTypeSFXDescriptionName" or
"GuiInspectorTypeSFXEnvironmentName" or
"GuiInspectorTypeSFXTrackName" or
"GuiInspectorTypeSFXAmbienceName" or
"GuiInspectorTypeSFXSourceName" or
"GuiInspectorTypeGuiProfile":
return true;
}
// Other console types that refer to objects.
switch$( %field.getInspectedFieldType() )
{
case "TypeSimObject" or
"TypeSimObjectName" or
"TypeMaterialName" or
"TypeCubemapName" or
"TypeGuiProfile":
return true;
}
return false;
}
//---------------------------------------------------------------------------------------------
function EditorInspectorBase::isFileTypeField( %field )
{
return %field.isMemberOfClass( "GuiInspectorTypeFileName" );
}
//---------------------------------------------------------------------------------------------
function EditorInspectorBase::getFullFilePath( %field )
{
%fileName = %field.getData();
%inspector = %field.getInspector();
%object = %inspector.getInspectObject();
if( %object.isMemberOfClass( "Material" ) )
{
// Image filenames in materials are relative to the material's file.
%objectPath = filePath( makeFullPath( %object.getFilename(), getMainDotCsDir() ) );
return makeFullPath( %fileName, %objectPath );
}
else
return makeFullPath( %fileName, getMainDotCsDir() );
}

View file

@ -0,0 +1,59 @@
//-----------------------------------------------------------------------------
// 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 Editor::validateObjectName( %name, %mustHaveName )
{
if( %mustHaveName && %name $= "" )
{
MessageBoxOK( "Missing Object Name", "No name given for object. Please enter a valid object name." );
return false;
}
if( !isValidObjectName( %name ) )
{
MessageBoxOK( "Invalid Object Name", "'" @ %name @ "' is not a valid object name." NL
"" NL
"Please choose a name that begins with a letter or underscore and is otherwise comprised " @
"exclusively of letters, digits, and/or underscores."
);
return false;
}
if( isObject( %name ) )
{
%filename = %name.getFilename();
if ( %filename $= "" )
%filename = "an unknown file";
MessageBoxOK( "Invalid Object Name", "Object names must be unique, and there is an " @
"existing " @ %name.getClassName() @ " object with the name '" @ %name @ "' (defined " @
"in " @ %filename @ "). Please choose another name." );
return false;
}
if( isClass( %name ) )
{
MessageBoxOK( "Invalid Object Name", "'" @ %name @ "' is the name of an existing TorqueScript " @
"class. Please choose another name." );
return false;
}
return true;
}

View file

@ -0,0 +1,99 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
// Common functionality for GuiSwatchButtonCtrls.
//
// Note that for the mouse-event related functionality, "useMouseEvents" must be set
// to true.
//---------------------------------------------------------------------------------------------
function GuiSwatchButtonCtrl::onMouseDragged( %this )
{
%payload = new GuiSwatchButtonCtrl();
%payload.assignFieldsFrom( %this );
%payload.position = "0 0 ";
%payload.dragSourceControl = %this;
%xOffset = getWord( %payload.extent, 0 ) / 2;
%yOffset = getWord( %payload.extent, 1 ) / 2;
%cursorpos = Canvas.getCursorPos();
%xPos = getWord( %cursorpos, 0 ) - %xOffset;
%yPos = getWord( %cursorpos, 1 ) - %yOffset;
// Create the drag control.
%ctrl = new GuiDragAndDropControl()
{
canSaveDynamicFields = "0";
Profile = "GuiSolidDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = %xPos SPC %yPos;
extent = %payload.extent;
MinExtent = "4 4";
canSave = "1";
Visible = "1";
hovertime = "1000";
deleteOnMouseUp = true;
class = "GuiDragAndDropControlType_ColorSwatch";
};
%ctrl.add( %payload );
// Start drag.
Canvas.getContent().add( %ctrl );
%ctrl.startDragging( %xOffset, %yOffset );
}
//---------------------------------------------------------------------------------------------
function GuiSwatchButtonCtrl::onControlDropped( %this, %payload, %position )
{
if( !%payload.parentGroup.isInNamespaceHierarchy( "GuiDragAndDropControlType_ColorSwatch" ) )
return;
// If dropped on same button whence we came from,
// do nothing.
if( %payload.dragSourceControl == %this )
return;
// If a swatch button control is dropped onto this control,
// copy it's color.
if( %payload.isMemberOfClass( "GuiSwatchButtonCtrl" ) )
{
// If the swatch button is part of a color-type inspector field,
// remember the inspector field so we can later set the color
// through it.
if( %this.parentGroup.isMemberOfClass( "GuiInspectorTypeColorI" ) )
%this.parentGroup.apply( ColorFloatToInt( %payload.color ) );
else if( %this.parentGroup.isMemberOfClass( "GuiInspectorTypeColorF" ) )
%this.parentGroup.apply( %payload.color );
else
%this.setColor( %payload.color );
}
}

View file

@ -0,0 +1,74 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
// Common functions for filter text and clear button controls on tree views.
// The GuiTextEditCtrl having the filter text must have "treeView" dynamic field
// that has the ID of the associated GuiTreeViewCtrl.
// The button ctrl used to clear the text field must have a "textCtrl" dynamic field
// that has the ID of the associated filter GuiTextEditCtrl.
//---------------------------------------------------------------------------------------------
function GuiTreeViewFilterText::onWake( %this )
{
%filter = %this.treeView.getFilterText();
if( %filter $= "" )
%this.setText( "\c2Filter..." );
else
%this.setText( %filter );
}
//---------------------------------------------------------------------------------------------
function GuiTreeViewFilterText::onGainFirstResponder( %this )
{
%this.selectAllText();
}
//---------------------------------------------------------------------------------------------
// When Enter is pressed in the filter text control, pass along the text of the control
// as the treeview's filter.
function GuiTreeViewFilterText::onReturn( %this )
{
%text = %this.getText();
if( %text $= "" )
%this.reset();
else
%this.treeView.setFilterText( %text );
}
//---------------------------------------------------------------------------------------------
function GuiTreeViewFilterText::reset( %this )
{
%this.setText( "\c2Filter..." );
%this.treeView.clearFilterText();
}
//---------------------------------------------------------------------------------------------
function GuiTreeViewFilterClearButton::onClick( %this )
{
%this.textCtrl.reset();
}

View file

@ -0,0 +1,93 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
// Undo actions that are useful in multiple editors.
//=============================================================================================
// Undo reparenting.
//=============================================================================================
//---------------------------------------------------------------------------------------------
function UndoActionReparentObjects::create( %treeView )
{
pushInstantGroup();
%action = new UndoScriptAction()
{
class = "UndoActionReparentObjects";
numObjects = 0;
treeView = %treeView;
};
popInstantGroup();
return %action;
}
//---------------------------------------------------------------------------------------------
function UndoActionReparentObjects::add( %this, %object, %oldParent, %newParent )
{
%index = %this.numObjects;
%this.objects[ %index ] = %object;
%this.oldParents[ %index ] = %oldParent;
%this.newParents[ %index ] = %newParent;
%this.numObjects = %this.numObjects + 1;
}
//---------------------------------------------------------------------------------------------
function UndoActionReparentObjects::undo( %this )
{
%numObjects = %this.numObjects;
for( %i = 0; %i < %numObjects; %i ++ )
{
%obj = %this.objects[ %i ];
%group = %this.oldParents[ %i ];
if( isObject( %obj ) && isObject( %group ) )
%obj.parentGroup = %group;
}
if( isObject( %this.treeView ) )
%this.treeView.update();
}
//---------------------------------------------------------------------------------------------
function UndoActionReparentObjects::redo( %this )
{
%numObjects = %this.numObjects;
for( %i = 0; %i < %numObjects; %i ++ )
{
%obj = %this.objects[ %i ];
%group = %this.newParents[ %i ];
if( isObject( %obj ) && isObject( %group ) )
%obj.parentGroup = %group;
}
if( isObject( %this.treeView ) )
%this.treeView.update();
}