mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
Initial implementation of the new Base Game Template and some starting modules.
This makes some tweaks to the engine to support this, specifically, it tweaks the hardcoded shaderpaths to defer to a pref variable, so none of the shader paths are hardcoded. Also tweaks how post effects read in texture files, removing a bizzare filepath interpretation choice, where if the file path didn't start with "/" it forcefully appended the script's file path. This made it impossible to have images not in the same dir as the script file defining the post effect. This was changed and the existing template's post effects tweaked for now to just add "./" to those few paths impacted, as well as the perf vars to support the non-hardcoded shader paths in the engine.
This commit is contained in:
parent
5c8a82180b
commit
1ed8b05169
1572 changed files with 146699 additions and 85 deletions
|
|
@ -0,0 +1,155 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// RSS ticker configuration:
|
||||
$RSSFeed::serverName = "feeds.garagegames.com";
|
||||
$RSSFeed::serverPort = 80;
|
||||
$RSSFeed::serverURL = "/product/tgea";
|
||||
$RSSFeed::userAgent = "TorqueGameEngineAdvances/1.1";
|
||||
$RSSFeed::maxNewHeadlines = 10;
|
||||
|
||||
// Load up the helper objects
|
||||
exec( "./RSSStructs.ed.cs" );
|
||||
|
||||
function RSSFeedObject::onConnected(%this)
|
||||
{
|
||||
//echo("RSS Feed");
|
||||
//echo(" - Requesting RSS data at URL: " @ $RSSFeed::serverURL );
|
||||
|
||||
// Reset some useful state information.
|
||||
$RSSFeed::lineCount = 0;
|
||||
$RSSFeed::requestResults = "";
|
||||
|
||||
// Load the cache here...
|
||||
$RSSFeed::rssCache = 0;
|
||||
|
||||
// Request our RSS.
|
||||
%this.send("GET " @ $RSSFeed::serverURL @ " HTTP/1.0\nHost: " @ $RSSFeed::serverName @ "\nUser-Agent: " @ $RSSFeed::userAgent @ "\n\r\n\r\n");
|
||||
}
|
||||
|
||||
function RSSFeedObject::onLine(%this, %line)
|
||||
{
|
||||
// Collate info.
|
||||
$RSSFeed::lineCount++;
|
||||
$RSSFeed::requestResults = $RSSFeed::requestResults @ %line;
|
||||
}
|
||||
|
||||
function RSSFeedObject::getTagContents(%this, %string, %tag, %startChar)
|
||||
{
|
||||
// This function occasionally makes Torque hard crash. It doesn't
|
||||
// seem to do it anymore but be careful!
|
||||
|
||||
// Ok, get thing between <%tag> and </%tag> after char #
|
||||
// %startChar in the passed string.
|
||||
|
||||
%startTag = "<" @ %tag @ ">";
|
||||
%endTag = "</" @ %tag @ ">";
|
||||
|
||||
%startTagOffset = strpos(%string, %startTag, %startChar);
|
||||
|
||||
// Compensate for presence of start tag.
|
||||
%startOffset = %startTagOffset + strlen(%startTag);
|
||||
|
||||
// Ok, now look for end tag.
|
||||
%endTagOffset = strpos(%string, %endTag, %startOffset - 1);
|
||||
|
||||
// If we didn't find it, bail.
|
||||
if(%endTagOffset < 0)
|
||||
return "";
|
||||
|
||||
// Evil hack - store last found item in a global.
|
||||
%this.lastOffset = %endTagOffset;
|
||||
|
||||
// And get & return the substring between the tags.
|
||||
%result = getSubStr(%string, %startOffset, %endTagOffset - %startOffset);
|
||||
|
||||
// Do a little mojo to deal with " and some other htmlentities.
|
||||
%result = strreplace(%result, """, "\"");
|
||||
%result = strreplace(%result, "&", "&");
|
||||
|
||||
return %result;
|
||||
}
|
||||
|
||||
function RSSFeedObject::onDisconnect(%this)
|
||||
{
|
||||
// Create collection and load cache.
|
||||
%ret = constructRSSHeadlineCollection();
|
||||
%ret.loadFromFile( "RSSCache.cs" );
|
||||
|
||||
// Ok, we have a full buffer now, hopefully. Let's process it.
|
||||
//echo(" - Got " @ $RSSFeed::lineCount @ " lines.");
|
||||
|
||||
// We want the feed title and the first three headlines + links.
|
||||
|
||||
// Feed title - get the first <title> occurence in the string.
|
||||
%title = %this.getTagContents($RSSFeed::requestResults, "title", 0);
|
||||
%titleLink = %this.getTagContents($RSSFeed::requestResults, "link", 0);
|
||||
|
||||
//echo(" - Feed title: '" @ %title @ "'");
|
||||
//echo(" - Feed link: '" @ %titleLink @ "'");
|
||||
|
||||
%newItems = "";
|
||||
|
||||
// Ok, get the first headlines, if any...
|
||||
for( %i = 0; %i < $RSSFeed::maxNewHeadlines; %i++ )
|
||||
{
|
||||
%headline[%i] = %this.getTagContents($RSSFeed::requestResults, "title", %this.lastOffset);
|
||||
%headlineLink[%i] = %this.getTagContents($RSSFeed::requestResults, "link", %this.lastOffset);
|
||||
|
||||
// Skip the content - it's not going to do anything but confuse us.
|
||||
%garbage = %this.getTagContents($RSSFeed::requestResults, "content:encoded", %this.lastOffset);
|
||||
%isNew = %ret.addHeadline( constructRSSHeadline( %headline[%i], %headlineLink[%i] ) );
|
||||
|
||||
if( %isNew )
|
||||
{
|
||||
%newItems = true;
|
||||
//echo(" - Headline #" @ %i @ " : '" @ %headline[%i] @ "'");
|
||||
//echo(" - Headline Link #" @ %i @ " : '" @ %headlineLink[%i] @ "'");
|
||||
}
|
||||
}
|
||||
|
||||
if( %this._callback !$= "" )
|
||||
{
|
||||
%params = %ret;
|
||||
|
||||
if( %newItems )
|
||||
%params = %params @ ", \"" @ %newItems @ "\"";
|
||||
|
||||
eval( %this._callback @ "(" @ %params @ ");" );
|
||||
}
|
||||
|
||||
%ret.writeToFile( "RSSCache.cs", false );
|
||||
}
|
||||
|
||||
function RSSUpdate::initialize( %callback )
|
||||
{
|
||||
new TCPObject(RSSFeedObject);
|
||||
RSSFeedObject._callback = %callback;
|
||||
|
||||
RSSFeedObject.connect( $RSSFeed::serverName @ ":" @ $RSSFeed::serverPort );
|
||||
}
|
||||
|
||||
function RSSUpdate::destroy()
|
||||
{
|
||||
if(isObject(RSSFeedObject))
|
||||
RSSFeedObject.delete();
|
||||
}
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// RSS Feed integration structures
|
||||
// I apologize in advance if this RSS reader is too restrictive with regard
|
||||
// to tags/enclosures. I may revisit it at some point to add support
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RSS Headline Item
|
||||
//------------------------------------------------------------------------------
|
||||
function constructRSSHeadline( %headline, %link )
|
||||
{
|
||||
%ret = new ScriptObject()
|
||||
{
|
||||
class = "RSSHeadline";
|
||||
_headline = %headline;
|
||||
_link = %link;
|
||||
};
|
||||
|
||||
return %ret;
|
||||
}
|
||||
|
||||
function RSSHeadline::getHeadline( %this )
|
||||
{
|
||||
return %this._headline;
|
||||
}
|
||||
|
||||
function RSSHeadline::getLink( %this )
|
||||
{
|
||||
return %this._link;
|
||||
}
|
||||
|
||||
function RSSHeadline::sameAs( %this, %headline )
|
||||
{
|
||||
return ( strcmp( %this.toString(), %headline.toString() ) == 0 );
|
||||
}
|
||||
|
||||
function RSSHeadline::toString( %this )
|
||||
{
|
||||
return %this.getHeadline() @ " ( " @ %this.getLink() @ " ) ";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function constructRSSHeadlineCollection()
|
||||
{
|
||||
%ret = new ScriptObject()
|
||||
{
|
||||
class = "RSSHeadlineCollection";
|
||||
};
|
||||
|
||||
// Create sim group for it
|
||||
%ret._simGroup = new SimGroup();
|
||||
|
||||
return %ret;
|
||||
}
|
||||
|
||||
function RSSHeadlineCollection::getObject( %this, %index )
|
||||
{
|
||||
%ret = %this._simGroup.getObject( %index );
|
||||
|
||||
if( !isObject( %ret ) )
|
||||
{
|
||||
warn( "No such index in headline collection." );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return %ret;
|
||||
}
|
||||
|
||||
function RSSHeadlineCollection::getCount( %this )
|
||||
{
|
||||
return %this._simGroup.getCount();
|
||||
}
|
||||
|
||||
function RSSHeadlineCollection::addHeadline( %this, %headline, %skipReorder )
|
||||
{
|
||||
for( %i = 0; %i < %this.getCount(); %i++ )
|
||||
{
|
||||
%obj = %this.getObject( %i );
|
||||
|
||||
if( %obj.sameAs( %headline ) )
|
||||
{
|
||||
//echo( "cache hit headline: " @ %headline.toString() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
%this._simGroup.add( %headline );
|
||||
|
||||
if( !%skipReorder )
|
||||
%this._simGroup.bringToFront( %headline );
|
||||
|
||||
//echo( "adding headline: " @ %headline.toString() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function RSSHeadlineCollection::writeToFile( %this, %file )
|
||||
{
|
||||
$rssHeadlineCollection::count = %this.getCount();
|
||||
|
||||
for( %i = 0; %i < %this.getCount(); %i++ )
|
||||
{
|
||||
%hdl = %this.getObject( %i );
|
||||
$rssHeadlineCollection::headline[%i] = %hdl.getHeadline();
|
||||
$rssHeadlineCollection::link[%i] = %hdl.getLink();
|
||||
}
|
||||
|
||||
export( "$rssHeadlineCollection::*", %file, false );
|
||||
}
|
||||
|
||||
function RSSHeadlineCollection::loadFromFile( %this, %file )
|
||||
{
|
||||
%this._simGroup.clear();
|
||||
|
||||
$rssHeadlineCollection::count = 0;
|
||||
|
||||
%file = getPrefsPath(%file);
|
||||
if (isFile(%file) || isFile(%file @ ".dso"))
|
||||
exec( %file );
|
||||
|
||||
for( %i = 0; %i < $rssHeadlineCollection::count; %i++ )
|
||||
{
|
||||
//echo( "[LD: " @ %i @ "] Headline: " @ $rssHeadlineCollection::headline[%i] );
|
||||
//echo( "[LD: " @ %i @ "] Link: " @ $rssHeadlineCollection::link[%i] );
|
||||
|
||||
%hdl = constructRSSHeadline( $rssHeadlineCollection::headline[%i],
|
||||
$rssHeadlineCollection::link[%i] );
|
||||
|
||||
// This does negate the cache check, but that is ok -pw
|
||||
%this.addHeadline( %hdl, true );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/// @class ContextPopup
|
||||
/// @brief Create a Popup Dialog that closes itself when signaled by an event.
|
||||
///
|
||||
/// ContextPopup is a support class that offers a simple way of displaying
|
||||
/// reusable context sensitive GuiControl popups. These dialogs are created
|
||||
/// and shown to the user when the <b>show</b> method is used.
|
||||
///
|
||||
/// Once a Popup is shown it will be dismissed if it meets one of a few
|
||||
/// criteria.
|
||||
///
|
||||
/// 1. A user clicks anywhere outside the bounds of the GuiControl, specified by
|
||||
/// the 'dialog' field on the object.
|
||||
/// 2. Time Passes of (n)Milliseconds, specifed by the 'timeout' field on
|
||||
/// the object.
|
||||
///
|
||||
/// For example, if you wished to create a context dialog with a dialog you held in
|
||||
/// a local variable named %myDialog you would create a new script object as such.
|
||||
///
|
||||
///
|
||||
/// @code
|
||||
/// %MyContextPopup = new ScriptObject()
|
||||
/// {
|
||||
/// class = ContextPopup;
|
||||
/// superClass= MyCallbackNamespace; // Only Necessary when you want to perform logic pre/post showing
|
||||
/// dialog = %%myDialog.getID();
|
||||
/// delay = 500; // Pop the Popup after 500 Milliseconds
|
||||
/// };
|
||||
/// @endcode
|
||||
///
|
||||
/// Now, if you wanted to show the dialog %%myDialog and have it dismissed when anything in the
|
||||
/// background is clicked, simply call the following.
|
||||
///
|
||||
///
|
||||
/// @code
|
||||
/// %MyContextPopup.show( %positionX, %positionY );
|
||||
/// @endcode
|
||||
///
|
||||
/// If you need to know more than show the dialog and hide it when clicked or time passes, ContextPopup
|
||||
/// Provides callback methods that you may override for doing intermediate processing on a dialog
|
||||
/// that is to be shown or is being hidden. For example, in the above script we created a Context Dialog Container
|
||||
/// called @%myContextDialog with a superClass of <b>MyCallbackNamespace</b>. If we wanted to hide the cursor when
|
||||
/// the dialog was shown, and show it when the dialog was hidden, we could implement the following functions.
|
||||
///
|
||||
/// @code
|
||||
/// function MyCallbackNamespace::onContextActivate( %%this )
|
||||
/// {
|
||||
/// // Hide Cursor Here
|
||||
/// }
|
||||
/// function MyCallbackNamespace::onContextDeactivate( %%this )
|
||||
/// {
|
||||
/// // Show Cursor Here
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
/// @field GuiControl Dialog The GuiControl dialog to be shown when the context dialog is activated
|
||||
|
||||
function ContextDialogContainer::onAdd(%this)
|
||||
{
|
||||
// Add to our cleanup group.
|
||||
$EditorClassesGroup.add( %this );
|
||||
|
||||
%this.base = new GuiButtonBaseCtrl()
|
||||
{
|
||||
profile = ToolsGuiTransparentProfile;
|
||||
class = ContextDialogWatcher;
|
||||
parent = %this;
|
||||
modal = true;
|
||||
};
|
||||
|
||||
// Flag not active.
|
||||
%this.isPushed = false;
|
||||
|
||||
// Add to our cleanup group.
|
||||
$EditorClassesGroup.add( %this.base );
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function ContextDialogContainer::onRemove(%this)
|
||||
{
|
||||
%this.Hide();
|
||||
|
||||
if( isObject( %this.base ) )
|
||||
%this.base.delete();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// (SimID this, int positionX, int positionY)
|
||||
/// Shows the GuiControl specified in the Dialog field at the coordinates passed
|
||||
/// to this function. If no coordinates are passed to this function, the Dialog control
|
||||
/// is shown using it's current position.
|
||||
///
|
||||
/// @param this The ContextDialogContainer object
|
||||
/// @param positionX The X Position in Global Screen Coordinates to display the dialog
|
||||
/// @param positionY The Y Position in Global Screen Coordinates to display the dialog
|
||||
/// @param delay Optional delay before this popup is hidden that overrides that specified at construction time
|
||||
///
|
||||
//-----------------------------------------------------------------------------
|
||||
function ContextDialogContainer::Show( %this, %positionX, %positionY, %delay )
|
||||
{
|
||||
if( %this.isPushed == true )
|
||||
return true;
|
||||
|
||||
if( !isObject( %this.Dialog ) )
|
||||
return false;
|
||||
|
||||
// Store old parent.
|
||||
%this.oldParent = %this.dialog.getParent();
|
||||
|
||||
// Set new parent.
|
||||
%this.base.add( %this.Dialog );
|
||||
|
||||
if( %positionX !$= "" && %positionY !$= "" )
|
||||
%this.Dialog.setPositionGlobal( %positionX, %positionY );
|
||||
|
||||
Canvas.pushDialog( %this.base, 99 );
|
||||
|
||||
// Setup Delay Schedule
|
||||
if( isEventPending( %this.popSchedule ) )
|
||||
cancel( %this.popSchedule );
|
||||
if( %delay !$= "" )
|
||||
%this.popSchedule = %this.schedule( %delay, hide );
|
||||
else if( %this.Delay !$= "" )
|
||||
%this.popSchedule = %this.schedule( %this.Delay, hide );
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// (SimID this)
|
||||
/// Hides the GuiControl specified in the Dialog field if shown. This function
|
||||
/// is provided merely for more flexibility in when your dialog is shown. If you
|
||||
/// do not call this function, it will be called when the dialog is dismissed by
|
||||
/// a background click.
|
||||
///
|
||||
/// @param this The ContextDialogContainer object
|
||||
///
|
||||
//-----------------------------------------------------------------------------
|
||||
function ContextDialogContainer::Hide( %this )
|
||||
{
|
||||
if( %this.isPushed == true )
|
||||
Canvas.popDialog( %this.base );
|
||||
|
||||
// Restore Old Parent;
|
||||
if( isObject( %this.Dialog ) && isObject( %this.oldParent ) )
|
||||
%this.oldParent.add( %this.Dialog );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ContextDialogWatcher Class - JDD
|
||||
// CDW is a namespace link for the context background button to catch
|
||||
// event information and pass it back to the main class.
|
||||
//
|
||||
// onClick it will dismiss the parent
|
||||
// onDialogPop it will cleanup and notify user of deactivation
|
||||
// onDialogPush it will initialize state information and notify user of activation
|
||||
function ContextDialogWatcher::onClick( %this )
|
||||
{
|
||||
if( isObject( %this.parent ) )
|
||||
%this.parent.hide();
|
||||
}
|
||||
|
||||
function ContextDialogWatcher::onDialogPop( %this )
|
||||
{
|
||||
if( !isObject( %this.parent ) )
|
||||
return;
|
||||
|
||||
%this.parent.isPushed = false;
|
||||
|
||||
if( %this.parent.isMethod( "onContextDeactivate" ) )
|
||||
%this.parent.onContextDeactivate();
|
||||
}
|
||||
|
||||
function ContextDialogWatcher::onDialogPush( %this )
|
||||
{
|
||||
if( !isObject( %this.parent ) )
|
||||
return;
|
||||
|
||||
%this.parent.isPushed = true;
|
||||
|
||||
if( %this.parent.isMethod( "onContextActivate" ) )
|
||||
%this.parent.onContextActivate();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 ZipObject::addPath( %this, %path, %pathInZip )
|
||||
{
|
||||
%beginPath = expandFilename( %path );
|
||||
%path = pathConcat(%path, "*");
|
||||
%file = findFirstFile( %path );
|
||||
|
||||
while(%file !$= "")
|
||||
{
|
||||
%zipRel = makeRelativePath( %file, %beginPath );
|
||||
%finalZip = pathConcat(%pathInZip, %zipRel);
|
||||
|
||||
%this.addFile( %file, %finalZip );
|
||||
|
||||
%file = findNextFile(%path);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Called to setup the base expandos
|
||||
function setupBaseExpandos()
|
||||
{
|
||||
// FIXME TGEA doesnt currently have these due to the way it's built
|
||||
return;
|
||||
|
||||
setScriptPathExpando("tools", getExecutablePath() @ "/tools", true);
|
||||
setScriptPathExpando("tool", getExecutablePath() , true);
|
||||
setScriptPathExpando("toolResources", getExecutablePath() @ "/resources", true);
|
||||
|
||||
setScriptPathExpando("core", getExecutablePath() @ "/core", true);
|
||||
|
||||
// Remove the game expando so we can use this to reset expandos
|
||||
removeScriptPathExpando("game");
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 loadDirectory(%path, %type, %dsoType)
|
||||
{
|
||||
if( %type $= "" )
|
||||
%type = "ed.cs";
|
||||
if( %dsoType $= "" )
|
||||
%dsoType = "edso";
|
||||
|
||||
%cspath = %path @ "/*." @ %type;
|
||||
|
||||
// Because in a shipping version there will be no .cs files, we can't just
|
||||
// find all the cs files and exec them.
|
||||
|
||||
// First we find all the scripts and compile them if there are any
|
||||
// In the shipping version, this wont find anything.
|
||||
if( !$Scripts::ignoreDSOs )
|
||||
{
|
||||
%dsoReloc = compileDirectory(%cspath);
|
||||
|
||||
// Finally we find all the dsos and exec them instead
|
||||
|
||||
// If the DSOs are relocated by the engine (which will be the case when
|
||||
// running the tools) then we need to look for the scripts again.
|
||||
|
||||
if(! %dsoReloc)
|
||||
%dsopath = %path @ "/*." @ %type @ "." @ %dsoType;
|
||||
else
|
||||
%dsopath = %cspath;
|
||||
}
|
||||
else
|
||||
%dsopath = %cspath;
|
||||
|
||||
//error("Execing Directory " @ %dsopath @ " ...");
|
||||
%file = findFirstFile(%dsopath);
|
||||
|
||||
while(%file !$= "")
|
||||
{
|
||||
//error(" Found File: " @ %file);
|
||||
|
||||
// As we cant exec() a .dso directly, we need to strip that part from the filename
|
||||
%pos = strstr(%file, "." @ %dsoType);
|
||||
if(%pos != -1)
|
||||
%csfile = getSubStr(%file, 0, %pos);
|
||||
else
|
||||
%csfile = %file;
|
||||
|
||||
exec(%csfile);
|
||||
%file = findNextFile(%dsopath);
|
||||
}
|
||||
}
|
||||
|
||||
function compileDirectory(%path, %dsoPath)
|
||||
{
|
||||
%saveDSOPath = $Scripts::OverrideDSOPath;
|
||||
$Scripts::OverrideDSOPath = %dsoPath;
|
||||
|
||||
%dsoReloc = false;
|
||||
|
||||
%file = findFirstFile(%path);
|
||||
|
||||
//error("Compiling Directory " @ %path @ " ...");
|
||||
while(%file !$= "")
|
||||
{
|
||||
//error(" Found File: " @ %file @ " (" @ getDSOPath(%file) @ ")");
|
||||
if(filePath(%file) !$= filePath(getDSOPath(%file)))
|
||||
%dsoReloc = true;
|
||||
|
||||
compile(%file);
|
||||
%file = findNextFile(%path);
|
||||
}
|
||||
|
||||
$Scripts::OverrideDSOPath = %saveDSOPath;
|
||||
|
||||
return %dsoReloc;
|
||||
}
|
||||
|
||||
function listDirectory(%path)
|
||||
{
|
||||
%file = findFirstFile(%path);
|
||||
|
||||
echo("Listing Directory " @ %path @ " ...");
|
||||
while(%file !$= "")
|
||||
{
|
||||
echo(" " @ %file);
|
||||
%file = findNextFile(%path);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// This file merely contains the base functionality for creating your own
|
||||
// 'subclassed' script namkespaces that define the visual appearance of
|
||||
// a thumbnail for a guiThumnailPopup list.
|
||||
//
|
||||
// All border creation and callback click functionality is also defined in
|
||||
// this file and may be overriden in your namespaces provided that you
|
||||
// properly invoke the Parent::onMethodName( %parameterList ) to all this
|
||||
// base namespace to do it's dependent processing.
|
||||
|
||||
//function GuiDefaultThumbnail::onAdd( %this )
|
||||
//{
|
||||
//// Nothing Here.
|
||||
//}
|
||||
//
|
||||
//function GuiDefaultThumbnail::onRemove( %this )
|
||||
//{
|
||||
//// Nothing Here.
|
||||
//}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Object Browser Item Default Behaviors
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiDefaultThumbnail::onClick( %this )
|
||||
{
|
||||
// Store data and hide the dialog.
|
||||
if( isObject( %this.base ) )
|
||||
{
|
||||
%this.base.item = %this;
|
||||
%this.base.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
function GuiDefaultThumbnail::onRightClick( %this )
|
||||
{
|
||||
// Nothing Here.
|
||||
}
|
||||
|
||||
function GuiDefaultThumbnail::onMouseLeave( %this )
|
||||
{
|
||||
// Nothing Here.
|
||||
}
|
||||
|
||||
function ObjectBrowserItem::onMouseEnter( %this )
|
||||
{
|
||||
// Nothing Here.
|
||||
}
|
||||
|
||||
function GuiDefaultThumbnail::onDoubleClick( %this )
|
||||
{
|
||||
// By Default if the base funcitonality is called
|
||||
// in onClick, we will never get here. However, if
|
||||
// you want to override this functionality, simply
|
||||
// override onClick and don't call the parent.
|
||||
}
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ContextDialogContainer Class - Example Use
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//%MyContextDialog = new ScriptObject()
|
||||
//{
|
||||
// class = ContextDialogContainer;
|
||||
// superClass = GuiThumbnailPopup;
|
||||
// dialog = %myContainedDialog.getID();
|
||||
// thumbType = "GuiThumbnailClass";
|
||||
// listType = "StaticSpriteThumbs";
|
||||
//};
|
||||
// %MyContextDialog.show( %positionX, %positionY );
|
||||
// %MyContextDialog.hide();
|
||||
//
|
||||
// NOTES
|
||||
//
|
||||
// - thumbType describes a script namespace that will be linked to the creation
|
||||
// of the actual thumbs in the list. This allows you to override their display
|
||||
// - listType describes a script namespace that will be linked to the creation
|
||||
// of the list and will have refresh and destroy called on it when you need
|
||||
// to add objects to the list. to add an object, call %this.AddObject on you
|
||||
// get a refresh call.
|
||||
//
|
||||
//
|
||||
//function MyCallbackNamespace::onContextActivate( %this )
|
||||
//{
|
||||
// echo("Dialog has been pushed onto canvas, clicking outside of it will pop it!");
|
||||
//}
|
||||
//function MyCallbackNamespace::onContextDeactivate( %this )
|
||||
//{
|
||||
// echo("Dialog has lost it's context and has thus been popped from the canvas!");
|
||||
//}
|
||||
//
|
||||
//
|
||||
// Object Hierarchy
|
||||
// [%scriptObject] ScriptObject (GuiThumbnailPopup)
|
||||
// .superClass (ContextDialogContainer)
|
||||
// (%scriptObject)->[%dialogCtrl]
|
||||
// | GuiScrollCtrl [%scrollCtrl] (GuiThumbnailArray)
|
||||
// | GuiDynamicCtrlArrayCtrl [%objectList] (GuiThumbnailCreator)
|
||||
// .superClass ( listType )
|
||||
// .thumbType = %thumbType
|
||||
// .base = %this
|
||||
//
|
||||
function GuiThumbnailPopup::CreateThumbPopup( %this, %parent, %thumbType, %label )
|
||||
{
|
||||
%base = new GuiWindowCtrl()
|
||||
{
|
||||
profile = "ToolsGuiWindowProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "0 0";
|
||||
extent = "260 200";
|
||||
minExtent = "140 200";
|
||||
visible = "1";
|
||||
text = %label;
|
||||
maxLength = "255";
|
||||
resizeWidth = "1";
|
||||
resizeHeight = "1";
|
||||
canMove = "1";
|
||||
canClose = "0";
|
||||
canMinimize = "0";
|
||||
canMaximize = "0";
|
||||
};
|
||||
%scroll = new GuiScrollCtrl()
|
||||
{
|
||||
canSaveDynamicFields = "0";
|
||||
Profile = "ToolsGuiScrollProfile";
|
||||
class = "GuiThumbnailArray";
|
||||
internalName = "thumbnailScroll";
|
||||
HorizSizing = "width";
|
||||
VertSizing = "height";
|
||||
Position = "5 13";
|
||||
Extent = "250 178";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
hovertime = "1000";
|
||||
hScrollBar = "alwaysOff";
|
||||
vScrollBar = "alwaysOn";
|
||||
lockHorizScroll = "true";
|
||||
lockVertScroll = "false";
|
||||
constantThumbHeight = "1";
|
||||
Margin = "6 2";
|
||||
thumbType = %thumbType; // Special Tag - Class of thumbObject
|
||||
};
|
||||
%base.add(%scroll);
|
||||
%objectList = new GuiDynamicCtrlArrayControl()
|
||||
{
|
||||
canSaveDynamicFields = "0";
|
||||
Profile = "ToolsGuiScrollProfile";
|
||||
class = %this.listType;
|
||||
superClass = "GuiThumbnailCreator";
|
||||
HorizSizing = "width";
|
||||
VertSizing = "height";
|
||||
Position = "0 0";
|
||||
Extent = "250 178";
|
||||
MinExtent = "64 64";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
internalName = "objectList";
|
||||
hovertime = "1000";
|
||||
colCount = "0";
|
||||
colSize = %this.thumbSizeX;
|
||||
rowSize = %this.thumbSizeY;
|
||||
rowSpacing = "2";
|
||||
colSpacing = "2";
|
||||
thumbType = %thumbType; // Special Tag - Class of thumbObject
|
||||
base = %this; // Special Tag - Link to base class for hiding of dlg
|
||||
};
|
||||
%scroll.add(%objectList);
|
||||
%parent.add(%base);
|
||||
|
||||
return %base;
|
||||
|
||||
}
|
||||
|
||||
function GuiThumbnailPopup::onAdd(%this)
|
||||
{
|
||||
// Call parent.
|
||||
if( !Parent::onAdd( %this ) )
|
||||
return false;
|
||||
|
||||
if( %this.thumbType $= "" )
|
||||
%this.thumbType = "GuiDefaultThumbnail";
|
||||
|
||||
%this.Dialog = %this.createThumbPopup( %this.base, %this.thumbType, %this.label );
|
||||
|
||||
if( !isObject( %this.Dialog ) )
|
||||
{
|
||||
warn("GuiThumbnailPopup::onAdd - Invalid Context Dialog Specified!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function GuiThumbnailArray::onRemove(%this)
|
||||
{
|
||||
%this.destroy();
|
||||
}
|
||||
|
||||
function GuiThumbnailArray::onWake( %this )
|
||||
{
|
||||
// Find objectList
|
||||
%objectList = %this.findObjectByInternalName("ObjectList");
|
||||
|
||||
if( !isObject( %objectList ) )
|
||||
return;
|
||||
|
||||
%objectList.refreshList();
|
||||
}
|
||||
|
||||
function GuiThumbnailArray::refreshList(%this)
|
||||
{
|
||||
// Find objectList
|
||||
%objectList = %this.findObjectByInternalName("ObjectList");
|
||||
|
||||
if( !isObject( %objectList ) )
|
||||
return;
|
||||
|
||||
// Parent will clear
|
||||
%objectList.destroy();
|
||||
|
||||
}
|
||||
|
||||
function GuiThumbnailArray::destroy(%this)
|
||||
{
|
||||
// Find objectList
|
||||
%objectList = %this.findObjectByInternalName("ObjectList");
|
||||
|
||||
if( !isObject( %objectList ) )
|
||||
return;
|
||||
|
||||
while( %objectList.getCount() > 0 )
|
||||
{
|
||||
%object = %objectList.getObject( 0 );
|
||||
if( isObject( %object ) )
|
||||
%object.delete();
|
||||
else
|
||||
%objectList.remove( %object );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Add a T2D Object to the Object List
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiThumbnailCreator::AddObject( %this, %object, %data, %tooltip )
|
||||
{
|
||||
// Add to group
|
||||
$LB::ObjectLibraryGroup.add( %object );
|
||||
|
||||
// Build Object Container
|
||||
%container = new GuiControl() { profile = ToolsGuiButtonProfile; };
|
||||
|
||||
// Add to list.
|
||||
%this.add( %container );
|
||||
|
||||
// Return Container
|
||||
return %container;
|
||||
}
|
||||
|
|
@ -0,0 +1,616 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
// This function will build out an empty frame and add it to its given parent. The newly
|
||||
// built frame control is returned
|
||||
function GuiFormClass::BuildEmptyFrame(%pos, %ext, %columns, %rows, %parentID)
|
||||
{
|
||||
%frame = new GuiFrameSetCtrl()
|
||||
{
|
||||
profile = "ToolsGuiFrameSetProfile";
|
||||
horizSizing = "width";
|
||||
vertSizing = "height";
|
||||
position = %pos;
|
||||
extent = %ext;
|
||||
columns = %columns;
|
||||
rows = %rows;
|
||||
borderWidth = "5"; //"4";
|
||||
//borderColor = "192 192 192";
|
||||
absoluteFrames = "1";
|
||||
relativeResizing = "1";
|
||||
specialHighlighting = "1";
|
||||
};
|
||||
|
||||
%parentID.add(%frame);
|
||||
|
||||
return %frame;
|
||||
}
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
// This function will build out a form control and add it to its parent. The newly built
|
||||
// form control is returned.
|
||||
function GuiFormClass::BuildFormControl( %parentID, %ContentLibrary )
|
||||
{
|
||||
// Find Default 'None' Content.
|
||||
%contentNoneObj = GuiFormManager::FindFormContent( %ContentLibrary, "Scene View" );
|
||||
if( %contentNoneObj == 0 )
|
||||
{
|
||||
error("GuiFormClass::BuildFormControl - Cannot find 'Scene View' Content Object!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
%newFormObj = new GuiFormCtrl()
|
||||
{
|
||||
class = "FormControlClass";
|
||||
profile = "ToolsGuiFormProfile";
|
||||
canSaveDynamicFields = 1;
|
||||
horizSizing = "width";
|
||||
vertSizing = "height";
|
||||
position = "0 0";
|
||||
extent = "640 455";
|
||||
minExtent = "20 20";
|
||||
visible = "1";
|
||||
caption = $FormClassNoContentCaption;
|
||||
collapsable = "1";
|
||||
barBehindText = "1";
|
||||
hasMenu = true;
|
||||
ContentLibrary = %ContentLibrary;
|
||||
ContentID = %contentNoneObj;
|
||||
Content = "Scene View";
|
||||
};
|
||||
%parentID.add( %newFormObj );
|
||||
|
||||
return %newFormObj;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
function FormControlClass::onWake( %this )
|
||||
{
|
||||
if( %this.ContentLibrary !$= "" && %this.Content !$= "" )
|
||||
{
|
||||
%contentObj = GuiFormManager::FindFormContent( %this.ContentLibrary, %this.Content );
|
||||
if( %contentObj == 0 )
|
||||
{
|
||||
error("GuiFormClass::onWake - Content Library Specified But Content Not Found!" );
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Form Content
|
||||
//if( %this.ContentID != %contentObj || !isObject( %this.ContentID ) )
|
||||
GuiFormClass::SetFormContent( %this, %contentObj );
|
||||
}
|
||||
|
||||
%parentId = %this.getParent();
|
||||
%extent = %parentID.getExtent();
|
||||
%this.setExtent( GetWord(%extent, 0), GetWord(%extent, 1) );
|
||||
|
||||
GuiFormClass::BuildFormMenu( %this );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
function GuiFormClass::BuildFormMenu( %formObj )
|
||||
{
|
||||
|
||||
if( !%formObj.hasMenu )
|
||||
return;
|
||||
|
||||
// Menu Name.
|
||||
%menuName = "FormMainMenu";
|
||||
|
||||
// Retrieve Menu ID.
|
||||
%formMenu = %formObj.getMenuID();
|
||||
|
||||
%formMenu.clearMenuItems( %menuName );
|
||||
|
||||
//*** Setup the check mark bitmap index to start at the third bitmap
|
||||
%formMenu.setCheckmarkBitmapIndex(1);
|
||||
|
||||
//*** Add a menu to the menubar
|
||||
%formMenu.addMenu( %menuName, %formObj);
|
||||
%formMenu.setMenuBitmapIndex( %menuName, 0, true, false);
|
||||
%formMenu.setMenuMargins(0, 0, 0);
|
||||
|
||||
// Build Division Control Menu Items.
|
||||
%formMenu.addMenuItem( %menuName, "Split This View Horizontally", 1);
|
||||
%formMenu.addMenuItem( %menuName, "Split This View Vertically", 2);
|
||||
%formMenu.addMenuItem( %menuName, "-", 0);
|
||||
%formMenu.addMenuItem( %menuName, "Remove This View", 3);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
function GuiFormClass::SetFormContent( %formObj, %contentObj )
|
||||
{
|
||||
|
||||
// Menu Name.
|
||||
%menuName = "FormMainMenu";
|
||||
|
||||
// Validate New Content.
|
||||
if( !isObject( %contentObj ) )
|
||||
{
|
||||
// Failure
|
||||
error("GuiFormClass::SetFormContent- No Valid Content Object!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Remove any other content from the Form
|
||||
%count = %formObj.getCount();
|
||||
if(%count > 1)
|
||||
{
|
||||
// Notify Script of Content Changing.
|
||||
if( %formObj.isMethod("onContentChanging") )
|
||||
%formObj.onContentChanging( %contentObj );
|
||||
|
||||
// Object 0 is Always The Menu.
|
||||
%currentContent = %formObj.getObject( 1 );
|
||||
if( isObject( %currentContent ) )
|
||||
{
|
||||
// Remove from Reference List.
|
||||
if( %formObj.contentID !$= "" )
|
||||
GuiFormManager::RemoveContentReference( %formObj.ContentLibrary, %formObj.contentID.Name, %currentContent );
|
||||
|
||||
// Delete the content.
|
||||
%currentContent.delete();
|
||||
|
||||
// Update form Caption
|
||||
%formObj.setCaption( $FormClassNoContentCaption );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the Form content choices by obtaining the script build command
|
||||
if( %contentObj.CreateFunction !$= "" )
|
||||
{
|
||||
//*** Set the name first
|
||||
%name = %contentObj.Name;
|
||||
%formObj.setCaption(%name);
|
||||
|
||||
// We set the content ID prior to calling the create function so
|
||||
// that it may reference it's content to retrieve information about it.
|
||||
%oldContentId = %formObj.contentID;
|
||||
%formObj.contentID = %contentObj;
|
||||
|
||||
%result = eval( %contentObj.CreateFunction @ "(" @ %formObj @ ");" );
|
||||
if(!%result)
|
||||
{
|
||||
//*** Couldn't set up the form's contents so set the name back. We need to
|
||||
//*** do it like this to allow the form's contents to change the form caption
|
||||
//*** if the above command worked.
|
||||
%formObj.setCaption($FormClassNoContentCaption);
|
||||
|
||||
// Restore Content ID.
|
||||
%formObj.contentID = %oldContentID;
|
||||
|
||||
// Notify Script of Failure.
|
||||
if( %formObj.isMethod("onContentChangeFailure") )
|
||||
%formObj.onContentChangeFailure();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add to Reference List.
|
||||
%currentContent = %formObj.getObject( 1 );
|
||||
if( isObject( %currentContent ) )
|
||||
GuiFormManager::AddContentReference( %formObj.ContentLibrary, %contentObj.Name, %currentContent );
|
||||
|
||||
%formObj.Content = %formObj.contentId.name;
|
||||
|
||||
// Notify Script of Content Change
|
||||
if( %formObj.isMethod("onContentChanged") )
|
||||
%formObj.onContentChanged( %contentObj );
|
||||
|
||||
return %result;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Create a given content library content instance on a given parent control and
|
||||
// reference count it in the ref manager.
|
||||
//
|
||||
function GuiFormClass::SetControlContent( %controlObj, %contentLibrary, %contentObj )
|
||||
{
|
||||
// Validate New Content.
|
||||
if( !isObject( %contentObj ) )
|
||||
{
|
||||
// Failure
|
||||
error("GuiFormClass::SetControlContent- No Valid Content Object!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Remove any other content from the Form
|
||||
if( isObject( %controlObj.ContentID ) )
|
||||
{
|
||||
// Find Control of current content internal name on the control.
|
||||
%currentContent = %controlObj.findObjectByInternalName( %controlObj.ContentID.Name );
|
||||
|
||||
if( isObject( %currentContent ) )
|
||||
{
|
||||
|
||||
// Notify Script of Content Changing.
|
||||
if( %controlObj.isMethod("onContentChanging") )
|
||||
%controlObj.onContentChanging( %contentObj );
|
||||
|
||||
// Remove from Reference List.
|
||||
GuiFormManager::RemoveContentReference( %contentLibrary, %controlObj.contentID.Name, %currentContent );
|
||||
|
||||
// Delete the content.
|
||||
%currentContent.delete();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the Form content choices by obtaining the script build command
|
||||
if( %contentObj.CreateFunction !$= "" )
|
||||
{
|
||||
%name = %contentObj.Name;
|
||||
|
||||
// We set the content ID prior to calling the create function so
|
||||
// that it may reference it's content to retrieve information about it.
|
||||
%oldContentId = %controlObj.contentID;
|
||||
%controlObj.contentID = %contentObj;
|
||||
|
||||
%currentContent = eval( %contentObj.CreateFunction @ "(" @ %controlObj @ ");" );
|
||||
if( !isObject( %currentContent ) )
|
||||
{
|
||||
// Restore Content ID.
|
||||
%controlObj.contentID = %oldContentID;
|
||||
|
||||
// Notify Script of Failure.
|
||||
if( %controlObj.isMethod("onContentChangeFailure") )
|
||||
%controlObj.onContentChangeFailure();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add to Reference List.
|
||||
GuiFormManager::AddContentReference( %contentLibrary, %contentObj.Name, %currentContent );
|
||||
|
||||
// Store Internal Name
|
||||
%currentContent.setInternalName( %contentObj.Name );
|
||||
|
||||
// Store Content
|
||||
%controlObj.Content = %controlObj.contentId.name;
|
||||
|
||||
// Notify Script of Content Change
|
||||
if( %controlObj.isMethod("onContentChanged") )
|
||||
%controlObj.onContentChanged( %contentObj );
|
||||
|
||||
return %currentContent;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove a given library content instance from a control that is housing it.
|
||||
//
|
||||
function GuiFormClass::ClearControlContent( %controlObj, %contentLibrary )
|
||||
{
|
||||
|
||||
// Remove any other content from the Form
|
||||
if( isObject( %controlObj.ContentID ) )
|
||||
{
|
||||
// Find Control of current content internal name on the control.
|
||||
%currentContent = %controlObj.findObjectByInternalName( %controlObj.ContentID.Name );
|
||||
|
||||
if( isObject( %currentContent ) )
|
||||
{
|
||||
|
||||
// Notify Script of Content Changing.
|
||||
if( %controlObj.isMethod("onContentClearing") )
|
||||
%controlObj.onContentClearing( %controlObj.ContentID );
|
||||
|
||||
// Remove from Reference List.
|
||||
GuiFormManager::RemoveContentReference( %contentLibrary, %controlObj.contentID.Name, %currentContent );
|
||||
|
||||
// Delete the content.
|
||||
%currentContent.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
// Turn a form into a split frame and add the form back and build a new blank
|
||||
// form in the empty slot. %horizontal==ture then make a horizontal split, otherwise
|
||||
// make a vertical one.
|
||||
function GuiFormClass::AddFrameSplitToForm(%formid, %horizontal)
|
||||
{
|
||||
%formparent = %formid.getGroup();
|
||||
|
||||
// Get form position and size
|
||||
%pos = %formid.position;
|
||||
%ext = %formid.extent;
|
||||
%rows = "0";
|
||||
%columns = "0";
|
||||
if(%horizontal)
|
||||
{
|
||||
%framesplit = getWord(%ext,1) / 2;
|
||||
%rows = "0 " @ %framesplit;
|
||||
}
|
||||
else
|
||||
{
|
||||
%framesplit = getWord(%ext,0) / 2;
|
||||
%columns = "0 " @ %framesplit;
|
||||
}
|
||||
|
||||
// If the form's parent is a frame control and this form is the first control then
|
||||
// we will need to move it to the front of the other children later on. Otherwise
|
||||
// we'll be added to the bottom of the stack and the order will get messed up.
|
||||
// This all assumes that a frame control only has two children.
|
||||
%secondctrl = -1;
|
||||
if(%formparent.getClassName() $= "GuiFrameSetCtrl")
|
||||
{
|
||||
//error("Form parent is GuiFrameSetCtrl");
|
||||
if(%formparent.getObject(0) == %formid)
|
||||
{
|
||||
// This form is the first child.
|
||||
//error("Form is at the top");
|
||||
%secondctrl = %formparent.getObject(1);
|
||||
}
|
||||
}
|
||||
|
||||
// If we're adding a frameset around the layout base, propogate the
|
||||
// layoutRef and layoutObj's to the new parent.
|
||||
if( %formID.LayoutRef !$= "" )
|
||||
%LayoutRef = %formID.LayoutRef;
|
||||
else
|
||||
%LayoutRef = 0;
|
||||
|
||||
|
||||
// Remove form from parent, put a frame control in its place, and then add this form back to the frame
|
||||
%formparent.remove(%formid);
|
||||
%frame = GuiFormClass::BuildEmptyFrame(%pos, %ext, %columns, %rows, %formparent);
|
||||
|
||||
if( %layoutRef != 0 )
|
||||
{
|
||||
%frame.LayoutRef = %LayoutRef;
|
||||
%frame.LayoutRef.layoutObj = %frame;
|
||||
%frame.setCanSave( true );
|
||||
}
|
||||
if(%secondctrl != -1)
|
||||
{
|
||||
// Move this frame to the top of its parent's children stack by removing the
|
||||
// other child and adding it back again. This will force this second child to
|
||||
// the bottom and our new frame back to the first child (the same location the
|
||||
// original form was). Whew! Maybe the frame control needs to be modified to
|
||||
// handle this.
|
||||
//error("Moving to the top");
|
||||
%formparent.remove(%secondctrl);
|
||||
%formparent.add(%secondctrl);
|
||||
}
|
||||
%frame.add(%formid);
|
||||
|
||||
// Add a blank form to the bottom frame
|
||||
GuiFormClass::BuildFormControl(%frame, %formid.ContentLibrary );
|
||||
|
||||
//error("New parent: " @ %frame SPC "(" @ %frame.getClassName() @ ")");
|
||||
}
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
//*** Remove a form's frame and any other of the frame's children and put the given
|
||||
//*** form in its place, effectively removing the split. %keepform==true then remove
|
||||
//*** all children of a parent Frame Set and keep the given Form. Otherwise, remove
|
||||
//*** the given Form and keep the other child.
|
||||
function GuiFormClass::RemoveFrameSplit(%formid, %keepform)
|
||||
{
|
||||
//*** Get the form's parent and make sure it is a frame GUI. Other wise do nothing.
|
||||
%frameID = %formid.getGroup();
|
||||
if(%frameID.getClassName() !$= "GuiFrameSetCtrl")
|
||||
return;
|
||||
|
||||
//*** Get frame's position and size
|
||||
%pos = %frameID.position;
|
||||
%ext = %frameID.extent;
|
||||
|
||||
if(%keepform)
|
||||
{
|
||||
%form = %frameID.getObject(0);
|
||||
|
||||
// Remove from Reference List.
|
||||
if(%form.getClassName() $= "GuiFormCtrl")
|
||||
GuiFormManager::RemoveContentReference( %form.ContentLibrary, %form.contentID.Name, %form.getObject(1) );
|
||||
|
||||
//*** Go through the frame's children and remove them (which includes our form)
|
||||
%frameID.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Remove from Reference List.
|
||||
if( %formId.getClassName() $= "GuiFormCtrl" )
|
||||
GuiFormManager::RemoveContentReference( %formId.ContentLibrary, %formId.contentID.Name, %formId.getObject(1) );
|
||||
|
||||
//*** Store the first child that is not the given Form
|
||||
%count = %frameID.getCount();
|
||||
for(%i=0; %i < %count; %i++)
|
||||
{
|
||||
%child = %frameID.getObject(%i);
|
||||
if(%child != %formid)
|
||||
{
|
||||
//*** This is the first child that isn't the given Form, so
|
||||
//*** swap the given %formid with this new child so we keep it
|
||||
%formid = %child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//*** Now remove all children from the frame.
|
||||
%frameID.clear();
|
||||
}
|
||||
|
||||
//*** Obtain the frame's parent
|
||||
%frameparentID = %frameID.getGroup();
|
||||
|
||||
//*** If the frame's parent is itself a frame, then track all of its children and add
|
||||
//*** our form into the correct location, and remove our frame in the process. Otherwise
|
||||
//*** just delete our frame and add our form to the parent.
|
||||
if(%frameparentID.getClassName() $= "GuiFrameSetCtrl")
|
||||
{
|
||||
//*** Store the children
|
||||
%count = %frameparentID.getCount();
|
||||
%check = -1;
|
||||
for(%i=0; %i<%count; %i++)
|
||||
{
|
||||
%obj[%i] = %frameparentID.getObject(%i);
|
||||
if(%obj[%i] == %frameID)
|
||||
%check = %i;
|
||||
}
|
||||
|
||||
//*** Clear the existing children
|
||||
%frameparentID.clear();
|
||||
|
||||
//*** Now add them back, including our form
|
||||
for(%i=0; %i<%count; %i++)
|
||||
{
|
||||
if(%i == %check)
|
||||
{
|
||||
//*** Add our form
|
||||
%frameparentID.add(%formid);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//*** Add the old child back
|
||||
%frameparentID.add(%obj[%i]);
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
// If we're about to remove a frame that has a layout ref move it to the new object (%formID)
|
||||
if( %frameID.LayoutRef !$= "" )
|
||||
{
|
||||
%formID.LayoutRef = %frameID.LayoutRef;
|
||||
// By default if a control has been added to a form it will tag itself as cannot save.
|
||||
// just to be safe, we mark it as we can since it's clearly now becoming the root of a layout.
|
||||
%formID.LayoutRef.layoutObj = %formID;
|
||||
%formID.setCanSave( true );
|
||||
}
|
||||
//*** Remove old child and add our form to the parent
|
||||
%frameparentID.remove(%frameID);
|
||||
%frameparentID.add(%formid);
|
||||
|
||||
}
|
||||
|
||||
//*** Finally resize the form to fit
|
||||
%formid.resize(getWord(%pos,0),getWord(%pos,1),getWord(%ext,0),getWord(%ext,1));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
//*** Will resize the Form's content to fit. This is usually done at the beginning when
|
||||
//*** the content is first added to the form.
|
||||
function FormControlClass::sizeContentsToFit(%this, %content, %margin)
|
||||
{
|
||||
%formext = %this.getExtent();
|
||||
%menupos = %this.getObject(0).getPosition();
|
||||
%menuext = %this.getObject(0).getExtent();
|
||||
|
||||
%ctrlposx = getWord(%menupos,0) + %this.contentID.Margin;
|
||||
%ctrlposy = getWord(%menupos,1) + getWord(%menuext,1) + %this.contentID.Margin;
|
||||
%ctrlextx = getWord(%formext,0) - %ctrlposx - %this.contentID.Margin;
|
||||
%ctrlexty = getWord(%formext,1) - %ctrlposy - %this.contentID.Margin;
|
||||
|
||||
%content.resize(%ctrlposx,%ctrlposy,%ctrlextx,%ctrlexty);
|
||||
}
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
function FormControlClass::onResize(%this)
|
||||
{
|
||||
//*** If this form has a content child, then pass along this resize notice
|
||||
//*** to allow it to do something.
|
||||
if(%this.getCount() > 1)
|
||||
{
|
||||
%child = %this.getObject(1);
|
||||
if( isObject( %child ) )
|
||||
%this.sizeContentsToFit( %child );
|
||||
|
||||
if( %child.isMethod("onResize") )
|
||||
%child.onResize(%this);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This will change to something more abstract in the near future, or will be moved into
|
||||
// the level editor if there is no concise way to abstract it.
|
||||
//
|
||||
function FormMenuBarClass::onMenuItemSelect(%this, %menuid, %menutext, %itemid, %itemtext)
|
||||
{
|
||||
%formId = %menuid; // %menuid should contain the form's ID
|
||||
|
||||
//error("FormMenuBarClass::onMenuSelect(): " @ %menuid SPC %menutext SPC %itemid SPC %itemtext SPC "parent: " @ %formparent);
|
||||
|
||||
// If the ID is less than 1000, we know it's a layout menu item
|
||||
if( %itemid < 1000 )
|
||||
{
|
||||
// Handle the standard menu choices
|
||||
switch(%itemid)
|
||||
{
|
||||
case "1": // Add horizontal split
|
||||
GuiFormClass::AddFrameSplitToForm(%formid, true);
|
||||
|
||||
case "2": // Add vertical split
|
||||
GuiFormClass::AddFrameSplitToForm(%formid, false);
|
||||
case "3": // Remove split and keep other child
|
||||
GuiFormClass::RemoveFrameSplit(%formid, false);
|
||||
}
|
||||
|
||||
// We're Done Here.
|
||||
return;
|
||||
}
|
||||
else
|
||||
GuiFormClass::SetFormContent( %formId, %itemId );
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,190 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
$FormClassNoContentCaption = "None";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Add Form Content to a Library or Update if it Already Exists
|
||||
//
|
||||
// Returns : Content ID or 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::AddFormContent( %library, %contentName, %contentCreate, %contentSave, %contentMargin )
|
||||
{
|
||||
// See if we were passed a library ID.
|
||||
if( !isObject( %library ) )
|
||||
%libraryObj = GuiFormManager::FindLibrary( %library );
|
||||
else
|
||||
%libraryObj = %library;
|
||||
|
||||
// See if we Found the Library.
|
||||
if( %libraryObj == 0 || !isObject( %libraryObj ) )
|
||||
{
|
||||
error( "GuiFormManager::AddFormContent - Unable to Find Library by Name or ID!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// See if this reference already exists.
|
||||
%contentRef = GuiFormManager::FindFormContent( %libraryObj, %contentName );
|
||||
|
||||
// If it exists, just update it's create/save functions.
|
||||
if( %contentRef != 0 )
|
||||
{
|
||||
// Echo Update.
|
||||
//echo( "GuiFormManager::AddFormContent - Found Existent Content Reference, Updating Create/Save Functions" );
|
||||
|
||||
// Apply Update.
|
||||
%contentRef.CreateFunction = %contentCreate;
|
||||
%contentRef.SaveFunction = %contentSave;
|
||||
%contentRef.Margin = %contentMargin;
|
||||
|
||||
// Return Success.
|
||||
return %contentRef;
|
||||
}
|
||||
|
||||
// Create Content Reference List.
|
||||
%refList = new SimSet();
|
||||
|
||||
// Add Reference List to Library.
|
||||
%libraryObj.getObject(0).add( %refList );
|
||||
|
||||
// Create Content Reference Object.
|
||||
%newContentRef = new ScriptObject()
|
||||
{
|
||||
Name = %contentName;
|
||||
CreateFunction = %contentCreate;
|
||||
SaveFunction = %contentSave;
|
||||
Margin = %contentMargin;
|
||||
RefList = %refList;
|
||||
};
|
||||
|
||||
// Add to library.
|
||||
%libraryObj.add( %newContentRef );
|
||||
|
||||
// Return Success.
|
||||
return %newContentRef;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Remove Form Content from a Library
|
||||
//
|
||||
// Returns : True or False.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::RemoveFormContent( %library, %contentName )
|
||||
{
|
||||
// See if we were passed a library ID.
|
||||
if( !isObject( %library ) )
|
||||
%libraryObj = GuiFormManager::FindLibrary( %library );
|
||||
else
|
||||
%libraryObj = %library;
|
||||
|
||||
// See if we Found the Library.
|
||||
if( %libraryObj == 0 || !isObject( %libraryObj ) )
|
||||
return false;
|
||||
|
||||
// See if this reference already exists.
|
||||
%contentRef = GuiFormManager::FindFormContent( %libraryObj, %contentName );
|
||||
|
||||
// If it doesn't exist, just return success.
|
||||
if( %contentRef == 0 || !isObject( %contentRef ) )
|
||||
return true;
|
||||
|
||||
// Remove From Library.
|
||||
%libraryObj.remove( %contentRef );
|
||||
|
||||
// Return Success.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Find Form Content in a Library
|
||||
//
|
||||
// Returns : Content Reference Object ID or 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::FindFormContent( %library, %contentName )
|
||||
{
|
||||
// See if we were passed a library ID.
|
||||
if( !isObject( %library ) )
|
||||
%libraryObj = GuiFormManager::FindLibrary( %library );
|
||||
else
|
||||
%libraryObj = %library;
|
||||
|
||||
// See if we Found the Library.
|
||||
if( %libraryObj == 0 || !isObject( %libraryObj ) )
|
||||
return 0;
|
||||
|
||||
// Look for the content by name in our library.
|
||||
for( %i = 0; %i < %libraryObj.getCount(); %i++ )
|
||||
{
|
||||
%object = %libraryObj.getObject( %i );
|
||||
if( %object.Name $= %contentName )
|
||||
return %object;
|
||||
}
|
||||
|
||||
// Return Failure.
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Get Form Content in a Library by Index
|
||||
//
|
||||
// Returns : Content Reference Object ID or 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::GetFormContentByIndex( %library, %index )
|
||||
{
|
||||
// See if we were passed a library ID.
|
||||
if( !isObject( %library ) )
|
||||
%libraryObj = GuiFormManager::FindLibrary( %library );
|
||||
else
|
||||
%libraryObj = %library;
|
||||
|
||||
// See if we Found the Library.
|
||||
if( %libraryObj == 0 || !isObject( %libraryObj ) )
|
||||
return 0;
|
||||
|
||||
if( %index < %libraryObj.getCount() )
|
||||
return %libraryObj.getObject( %index );
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Get Form Content Count in a Library
|
||||
//
|
||||
// Returns : Number of content objects in this library or 0
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::GetFormContentCount( %library )
|
||||
{
|
||||
// See if we were passed a library ID.
|
||||
if( !isObject( %library ) )
|
||||
%libraryObj = GuiFormManager::FindLibrary( %library );
|
||||
else
|
||||
%libraryObj = %library;
|
||||
|
||||
// See if we Found the Library.
|
||||
if( %libraryObj == 0 || !isObject( %libraryObj ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return Count.
|
||||
return %libraryObj.getCount();
|
||||
}
|
||||
|
|
@ -0,0 +1,394 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Register a Content Library Layout
|
||||
//
|
||||
// Returns : Layout Object ID or 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::InitLayouts( %libraryName, %layoutName, %layoutObj )
|
||||
{
|
||||
// Retrieve Library Object
|
||||
%libraryObj = GuiFormManager::FindLibrary( %libraryName );
|
||||
if( %libraryObj == 0 )
|
||||
{
|
||||
error("GuiFormManager::RegisterLayout - Unable to find Library" SPC %libraryName );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Load up all Layouts in the layout base path.
|
||||
loadDirectory( %libraryObj.basePath, "cs", "dso" );
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Register a Content Library Layout
|
||||
//
|
||||
// Returns : True or False.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::RegisterLayout( %libraryName, %layoutName, %layoutObj )
|
||||
{
|
||||
// Retrieve Library Object
|
||||
%libraryObj = GuiFormManager::FindLibrary( %libraryName );
|
||||
if( %libraryObj == 0 )
|
||||
{
|
||||
error("GuiFormManager::RegisterLayout - Unable to find Library" SPC %libraryName );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Retrieve Layout Group
|
||||
%layoutGroup = %libraryObj.getObject( 1 );
|
||||
if( !isObject( %layoutGroup ) )
|
||||
{
|
||||
error("GuiFormManager::RegisterLayout - Unable to locate layout group!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// See if a layout with this name already exists.
|
||||
if( GuiFormManager::FindLayout( %libraryName, %layoutName ) != 0 )
|
||||
{
|
||||
error("GuiFormManager::RegisterLayout - Layout with name" SPC %layoutName SPC "already exists!");
|
||||
return false;
|
||||
}
|
||||
|
||||
%layoutRef = new ScriptObject()
|
||||
{
|
||||
layoutGroup = %layoutGroup;
|
||||
layoutName = %layoutName;
|
||||
layoutLibrary = %libraryObj;
|
||||
layoutObj = %layoutObj;
|
||||
layoutFile = %libraryObj.basePath @ %layoutName @ ".cs";
|
||||
};
|
||||
|
||||
// Tag Layout Object Properly so it can reset itself.
|
||||
%layoutObj.layoutRef = %layoutRef;
|
||||
|
||||
// Add Layout Object to group.
|
||||
%layoutGroup.add( %layoutObj );
|
||||
|
||||
// Add Layout Object Ref to group.
|
||||
%layoutGroup.add( %layoutRef );
|
||||
|
||||
// Return Success.
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Unregister a Content Library Layout
|
||||
//
|
||||
// Returns : True or False.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::UnregisterLayout( %libraryName, %layoutName, %deleteFile )
|
||||
{
|
||||
%libraryObj = GuiFormManager::FindLibrary( %libraryName );
|
||||
if( %libraryObj == 0 )
|
||||
{
|
||||
error("GuiFormManager::UnregisterLayout - Unable to find Library" SPC %libraryName );
|
||||
return false;
|
||||
}
|
||||
|
||||
// See if the layout exists.
|
||||
%layoutObjRef = GuiFormManager::FindLayout( %libraryObj, %layoutName );
|
||||
|
||||
if( %layoutObjRef == 0 )
|
||||
return true;
|
||||
|
||||
// Remove Layout File.
|
||||
if( ( %deleteFile == true ) && isFile( %layoutObjRef.layoutFile ) )
|
||||
fileDelete( %layoutObjRef.layoutFile );
|
||||
|
||||
// Delete the Object.
|
||||
if( isObject( %layoutObjRef.layoutObj ) )
|
||||
%layoutObjRef.layoutObj.delete();
|
||||
|
||||
// Delete the Reference
|
||||
%layoutObjRef.delete();
|
||||
|
||||
// Layout Unregistered.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Find a Content Library Layout
|
||||
//
|
||||
// Returns : Layout Object ID or 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::FindLayout( %libraryName, %layoutName )
|
||||
{
|
||||
// Fetch Library Object.
|
||||
if( isObject( %libraryName ) && %libraryName.Name !$= "" )
|
||||
%libraryName = %libraryName.Name;
|
||||
|
||||
%libraryObj = GuiFormManager::FindLibrary( %libraryName );
|
||||
|
||||
if( %libraryObj == 0 )
|
||||
{
|
||||
error("GuiFormManager::FindLayout - Unable to find Library" SPC %libraryName );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Retrieve Layout Group
|
||||
%layoutGroup = %libraryObj.getObject( 1 );
|
||||
if( !isObject( %layoutGroup ) )
|
||||
{
|
||||
error("GuiFormManager::FindLayout - Unable to locate layout group!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Find Layout Object.
|
||||
for( %i = 0; %i < %layoutGroup.getCount(); %i++ )
|
||||
{
|
||||
%layoutGroupIter = %layoutGroup.getObject( %i );
|
||||
if( %layoutGroupIter.getClassName() $= "ScriptObject" && %layoutGroupIter.layoutName $= %layoutName )
|
||||
return %layoutGroupIter;
|
||||
}
|
||||
|
||||
// Not Found
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Save a Content Library Layout
|
||||
//
|
||||
// Returns : True or False
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::SaveLayout( %library, %layoutName, %newName )
|
||||
{
|
||||
%libraryObj = GuiFormManager::FindLibrary( %library );
|
||||
if( %libraryObj == 0 )
|
||||
{
|
||||
error("GuiFormManager::SaveLayout - Unable to find Library" SPC %library );
|
||||
return false;
|
||||
}
|
||||
|
||||
%layoutObjRef = GuiFormManager::FindLayout( %library, %layoutName );
|
||||
if( %layoutObjRef == 0 )
|
||||
{
|
||||
error("GuiFormManager::SaveLayout - Cannot find layout" SPC %layoutName );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do any form layout specifics saving.
|
||||
GuiFormManager::SaveLayoutContent( %layoutObjRef.layoutObj );
|
||||
|
||||
%newFile = %libraryObj.basePath @ "/" @ %newName @ ".cs";
|
||||
if( %newName $= "" )
|
||||
{
|
||||
%newName = %layoutObjRef.layoutName;
|
||||
%newFile = %layoutObjRef.layoutFile;
|
||||
}
|
||||
|
||||
// Open Layout File Object.
|
||||
%layoutFile = new FileObject();
|
||||
if( !%layoutFile.openForWrite( %newFile ) )
|
||||
{
|
||||
error("GuiFormManager::SaveLayout - Unable to open" SPC %newFile SPC "for writing!");
|
||||
%layoutFile.delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get Layout Object
|
||||
%layoutObj = %layoutObjRef.layoutObj;
|
||||
|
||||
// Write Layout Object to File
|
||||
%layoutFile.writeObject( %layoutObj, "%layoutObj = " );
|
||||
%layoutFile.writeLine("GuiFormManager::RegisterLayout(\"" @ %libraryObj.name @ "\",\"" @ %newName @ "\",%layoutObj);" );
|
||||
%layoutFile.close();
|
||||
%layoutFile.delete();
|
||||
|
||||
// Layout Saved
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Reload The Current Layout from the version last stored on disk.
|
||||
//
|
||||
// Returns : True or False
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::ReloadLayout( %libraryName, %layoutName, %parent )
|
||||
{
|
||||
%layoutObj = GuiFormManager::FindLayout( %libraryName, %layoutName );
|
||||
if( %layoutObj == 0 || !isObject( %layoutObj ) )
|
||||
{
|
||||
error("GuiFormManager::ReloadLayout - Unable to locate layout" SPC %layoutName SPC "in library" SPC %libraryName );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Store necessary layout info before the object is destroyed in UnregisterLayout.
|
||||
%layoutFile = %layoutObj.layoutFile;
|
||||
|
||||
// Unregister Layout but don't delete the layout file from disk.
|
||||
if( !GuiFormManager::UnregisterLayout( %libraryName, %layoutName, false ) )
|
||||
{
|
||||
error("GuiFormManager::ReloadLayout - Unable to unregister layout file" SPC %layoutFile );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Load the layout from disk.
|
||||
exec( %layoutFile );
|
||||
|
||||
// Set it active.
|
||||
GuiFormManager::ActivateLayout( %libraryName, %layoutName, %parent );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Activate a Layout on a Given Parent.
|
||||
//
|
||||
// Returns : True or False
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::ActivateLayout( %library, %layoutName, %parent )
|
||||
{
|
||||
%libraryObj = GuiFormManager::FindLibrary( %library );
|
||||
if( %libraryObj == 0 )
|
||||
{
|
||||
error("GuiFormManager::FindLayout - Unable to find Library" SPC %library );
|
||||
return 0;
|
||||
}
|
||||
|
||||
%layoutObjRef = GuiFormManager::FindLayout( %library, %layoutName );
|
||||
if( %layoutObjRef == 0 )
|
||||
{
|
||||
error("GuiFormManager::ActivateLayout - Cannot find layout" SPC %layoutName );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear parent for new layout.
|
||||
%parent.clear();
|
||||
|
||||
%layoutObj = %layoutObjRef.layoutObj;
|
||||
|
||||
// Size to fit parent container.
|
||||
%extent = %parent.getExtent();
|
||||
%layoutObj.setExtent( GetWord(%extent, 0), GetWord(%extent, 1) );
|
||||
|
||||
// Add to parent.
|
||||
%parent.add( %layoutObj );
|
||||
|
||||
// Not Found
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Deactivate a given layout.
|
||||
//
|
||||
// Returns : True or False
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::DeactivateLayout( %library, %layoutName )
|
||||
{
|
||||
%libraryObj = GuiFormManager::FindLibrary( %library );
|
||||
if( %libraryObj == 0 )
|
||||
{
|
||||
error("GuiFormManager::DeactivateLayout - Unable to find Library" SPC %library );
|
||||
return 0;
|
||||
}
|
||||
|
||||
%layoutObjRef = GuiFormManager::FindLayout( %library, %layoutName );
|
||||
if( %layoutObjRef == 0 )
|
||||
{
|
||||
error("GuiFormManager::DeactivateLayout - Cannot find layout" SPC %layoutName );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Retrieve Layout Group
|
||||
%layoutGroup = %libraryObj.getObject( 1 );
|
||||
if( !isObject( %layoutGroup ) )
|
||||
{
|
||||
error("GuiFormManager::RegisterLayout - Unable to locate layout group!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Fetch Layout Object
|
||||
%layoutObj = %layoutObjRef.layoutObj;
|
||||
|
||||
// Clear all forms content.
|
||||
GuiFormManager::ClearLayoutContent( %layoutObj );
|
||||
|
||||
// Return layout to it's home.
|
||||
%layoutGroup.add( %layoutObj );
|
||||
|
||||
// Not Found
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Recursively Remove Form Content
|
||||
//
|
||||
// Returns : None.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::SaveLayoutContent( %layoutObj )
|
||||
{
|
||||
for( %i = 0; %i < %layoutObj.getCount(); %i++ )
|
||||
{
|
||||
%object = %layoutObj.getObject( %i );
|
||||
if( %object.isMemberOfClass( "SimGroup" ) )
|
||||
{
|
||||
%formContent = 0;
|
||||
if (%object.getCount() > 0)
|
||||
%formContent = %object.getObject( 1 );
|
||||
|
||||
if( isObject( %formContent ) && %object.ContentLibrary !$= "" && %object.Content !$= "" )
|
||||
{
|
||||
%contentObj = GuiFormManager::FindFormContent( %object.ContentLibrary, %object.Content );
|
||||
if( %contentObj == 0 )
|
||||
{
|
||||
error("GuiFormManager::SaveLayoutContent - Content Library Specified But Content Not Found!" );
|
||||
return;
|
||||
}
|
||||
|
||||
if( %contentObj.SaveFunction !$= "" )
|
||||
eval( %contentObj.SaveFunction @ "(" @ %object @ "," @ %formContent @ ");" );
|
||||
}
|
||||
}
|
||||
else
|
||||
GuiFormManager::SaveLayoutContent( %object );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Recursively Remove Form Content
|
||||
//
|
||||
// Returns : None.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::ClearLayoutContent( %layoutObj )
|
||||
{
|
||||
for( %i = 0; %i < %layoutObj.getCount(); %i++ )
|
||||
{
|
||||
%object = %layoutObj.getObject( %i );
|
||||
if( %object.getClassName() $= "GuiFormCtrl" )
|
||||
{
|
||||
// Clear Content ID So that onWake recreates the content.
|
||||
%object.ContentID = "";
|
||||
|
||||
%formContent = %object.getObject( 1 );
|
||||
if( isObject( %formContent ) )
|
||||
%formContent.delete();
|
||||
}
|
||||
else
|
||||
GuiFormManager::ClearLayoutContent( %object );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Register a Content Library
|
||||
//
|
||||
// Returns : Library Object ID or 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::RegisterLibrary( %libraryName, %libraryBasePath )
|
||||
{
|
||||
%libraryPrepend = "GFCM";
|
||||
%newLibraryObjectName = %libraryPrepend @ %libraryName;
|
||||
|
||||
// If the library already exists, just return it's object.
|
||||
if( isObject( %newLibraryObjectName ) )
|
||||
return %newLibraryObjectName.getId();
|
||||
|
||||
// We must have the content manager to continue.
|
||||
if( !isObject( FormContentManager ) )
|
||||
{
|
||||
error("GuiFormManager::RegisterLibrary - Unable to find FormContentManager object!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create Content Library.
|
||||
%newLibrary = new SimGroup( %newLibraryObjectName )
|
||||
{
|
||||
Name = %libraryName;
|
||||
};
|
||||
|
||||
// Expand Base Path
|
||||
%libraryFullPath = getPrefsPath( %libraryBasePath );
|
||||
|
||||
// Store disk base path
|
||||
%newLibrary.basePath = %libraryFullPath;
|
||||
|
||||
// Ensure Path Exists
|
||||
createPath( %libraryFullPath );
|
||||
|
||||
// Add Library to Content Manager.
|
||||
FormContentManager.add( %newLibrary );
|
||||
|
||||
// Create Content Library Ref Group.
|
||||
%newLibraryRefGroup = new SimGroup();
|
||||
%newLibraryRefGroup.setInternalName("RefGroup");
|
||||
%newLibrary.add( %newLibraryRefGroup );
|
||||
|
||||
// Create Content Library Layout Group.
|
||||
%newLibraryLayoutGroup = new SimGroup();
|
||||
%newLibraryLayoutGroup.setInternalName("LayoutGroup");
|
||||
%newLibrary.add( %newLibraryLayoutGroup );
|
||||
|
||||
// Add Library to Content Manager.
|
||||
FormContentManager.add( %newLibrary );
|
||||
|
||||
|
||||
// Add [none] Content.
|
||||
GuiFormManager::AddFormContent( %libraryName, $FormClassNoContentCaption );
|
||||
|
||||
// Return Library Object.
|
||||
return %newLibrary;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Unregister a Content Library
|
||||
//
|
||||
// Returns : True or False.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::UnregisterLibrary( %libraryName )
|
||||
{
|
||||
// Find Library Object.
|
||||
%libraryObj = GuiFormManager::FindLibrary( %libraryName );
|
||||
|
||||
if( !isObject( FormContentManager ) || !isObject( %libraryObj ) )
|
||||
{
|
||||
error("GuiFormManager::RegisterLibrary - Unable to find GuiFormManager or Library!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove all Content Reference Objects in this Library.
|
||||
while( %libraryObj.getCount() > 0 )
|
||||
{
|
||||
if( isObject( %libraryObj.getObject( 0 ) ) )
|
||||
%libraryObj.getObject( 0 ).delete();
|
||||
%libraryObj.remove( 0 );
|
||||
}
|
||||
// Delete the library
|
||||
%libraryObj.delete();
|
||||
|
||||
// Return Success.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Find a Content Library
|
||||
//
|
||||
// Returns : Library Object ID or 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::FindLibrary( %libraryName )
|
||||
{
|
||||
// Generate Library Name.
|
||||
%libraryObjectName = "GFCM" @ %libraryName;
|
||||
|
||||
// Find Library by Name.
|
||||
if( isObject( %libraryObjectName ) )
|
||||
return %libraryObjectName.getId();
|
||||
|
||||
// Didn't find by name, see if this is already a library ID.
|
||||
if( isObject( %libraryName ) )
|
||||
return %libraryName;
|
||||
|
||||
// Couldn't Find Library
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function GuiFormManager::Init()
|
||||
{
|
||||
// Create SimGroup.
|
||||
new SimGroup( FormContentManager ){};
|
||||
}
|
||||
|
||||
|
||||
function GuiFormManager::Destroy()
|
||||
{
|
||||
while( FormContentManager.getCount() > 0 )
|
||||
{
|
||||
%object = FormContentManager.getObject( 0 );
|
||||
|
||||
if( isObject( %object ) )
|
||||
GuiFormManager::BroadcastContentMessage( %object, FormContentManager, "onLibraryDestroyed" );
|
||||
|
||||
FormContentManager.remove( %object );
|
||||
}
|
||||
|
||||
// Destroy SimGroup.
|
||||
if( isObject( FormContentManager ) )
|
||||
FormContentManager.delete();
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Send a Message to all instances of a Content.
|
||||
//
|
||||
// Returns : The Number of Objects Communicated With or (0 if None).
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::SendContentMessage( %contentObj, %sender, %message )
|
||||
{
|
||||
// See if we Found the content object.
|
||||
if( %contentObj == 0 || !isObject( %contentObj ) )
|
||||
{
|
||||
//error( "GuiFormManager::SendContentMessage - Invalid Content Specified!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Validate Ref List.
|
||||
if( !isObject( %contentObj.RefList ) )
|
||||
{
|
||||
//error( "GuiFormManager::SendContentMessage - Unable to find content RefList!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
%refListObj = %contentObj.RefList.getID();
|
||||
|
||||
%messagedObjects = 0;
|
||||
// Look for the content by name in our library.
|
||||
for( %i = 0; %i < %refListObj.getCount(); %i++ )
|
||||
{
|
||||
%object = %refListObj.getObject( %i );
|
||||
|
||||
// Check for alternate MessageControl
|
||||
if( isObject( %object.MessageControl ) && %object.MessageControl.isMethod("onContentMessage") )
|
||||
%object.MessageControl.onContentMessage( %sender, %message );
|
||||
else if( %object.isMethod("onContentMessage") ) // Check for Default
|
||||
%object.onContentMessage( %sender, %message );
|
||||
else
|
||||
continue;
|
||||
%messagedObjects++;
|
||||
}
|
||||
|
||||
// Return Success.
|
||||
return %messagedObjects;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Send a Message to all instances of all Content.
|
||||
//
|
||||
// Returns : The Number of Objects Communicated With or (0 if None).
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::BroadcastContentMessage( %libraryName, %sender, %message )
|
||||
{
|
||||
%libraryObj = GuiFormManager::FindLibrary( %libraryName );
|
||||
// See if we Found the content object.
|
||||
if( %libraryObj == 0 || !isObject( %libraryObj ) )
|
||||
{
|
||||
//error( "GuiFormManager::BroadcastContentMessage - Invalid Library Specified!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// In a library the 0 object is always the ref group.
|
||||
%contentRefGroup = %libraryObj.getObject( 0 );
|
||||
|
||||
// Validate Ref Group.
|
||||
if( !isObject( %contentRefGroup ) )
|
||||
{
|
||||
//error( "GuiFormManager::BroadcastContentMessage - Unable to find library RefGroup!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Clear messaged object count
|
||||
%messagedObjects = 0;
|
||||
|
||||
// Iterate over all contents ref lists and message everyone
|
||||
for( %refGroupIter = 0; %refGroupIter < %contentRefGroup.getCount(); %refGroupIter++ )
|
||||
{
|
||||
|
||||
// Fetch the Object Reference List Set
|
||||
%refListSet = %contentRefGroup.getObject( %refGroupIter );
|
||||
|
||||
|
||||
// Look for the content by name in our library.
|
||||
for( %i = 0; %i < %refListSet.getCount(); %i++ )
|
||||
{
|
||||
%object = %refListSet.getObject( %i );
|
||||
|
||||
// Check for alternate MessageControl
|
||||
if( isObject( %object.MessageControl ) && %object.MessageControl.isMethod("onContentMessage") )
|
||||
%object.MessageControl.onContentMessage( %sender, %message );
|
||||
else if( %object.isMethod("onContentMessage") ) // Check for Default
|
||||
%object.onContentMessage( %sender, %message );
|
||||
else
|
||||
continue;
|
||||
|
||||
// Increment Messaged Object Count.
|
||||
%messagedObjects++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return Success.
|
||||
return %messagedObjects;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Add Content Reference to RefList
|
||||
//
|
||||
// Returns : True or False.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::AddContentReference( %library, %contentName, %control )
|
||||
{
|
||||
// Fetch Content Object.
|
||||
%contentObj = GuiFormManager::FindFormContent( %library, %contentName );
|
||||
|
||||
// See if we Found the Library.
|
||||
if( %contentObj == 0 || !isObject( %contentObj ) )
|
||||
{
|
||||
error( "GuiFormManager::AddContentReference - Unable to Find Library by Name or ID!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate Ref List.
|
||||
if( !isObject( %contentObj.RefList ) )
|
||||
{
|
||||
error( "GuiFormManager::AddContentReference - Unable to find content RefList!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
//error("adding ref for object" SPC %control );
|
||||
|
||||
// Add Control Reference.
|
||||
%contentObj.RefList.add( %control );
|
||||
|
||||
// Return Success.
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Remove Content Reference from RefList
|
||||
//
|
||||
// Returns : True or False.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::RemoveContentReference( %library, %contentName, %control )
|
||||
{
|
||||
// Fetch Content Object.
|
||||
%contentObj = GuiFormManager::FindFormContent( %library, %contentName );
|
||||
|
||||
// See if we Found the Library.
|
||||
if( %contentObj == 0 || !isObject( %contentObj ) )
|
||||
{
|
||||
error( "GuiFormManager::AddContentReference - Unable to Find Library by Name or ID!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate Ref List.
|
||||
if( !isObject( %contentObj.RefList ) )
|
||||
{
|
||||
error( "GuiFormManager::AddContentReference - Unable to find content RefList!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
//error("removing ref for object" SPC %control );
|
||||
|
||||
// Add Control Reference.
|
||||
%contentObj.RefList.remove( %control );
|
||||
|
||||
if( %control.isMethod("onFormRemove") )
|
||||
%control.onFormRemove();
|
||||
|
||||
// Return Success.
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets the current number of instances of the specified content that are active
|
||||
//
|
||||
// Returns : Number of instances or 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GuiFormManager::GetContentCount( %library, %contentName )
|
||||
{
|
||||
// Fetch Content Object.
|
||||
%contentObj = GuiFormManager::FindFormContent( %library, %contentName );
|
||||
|
||||
// See if we Found the Library.
|
||||
if( %contentObj == 0 || !isObject( %contentObj ) )
|
||||
{
|
||||
error( "GuiFormManager::GetContentCount - Unable to Find Library by Name or ID!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Validate Ref List.
|
||||
if( !isObject( %contentObj.RefList ) )
|
||||
{
|
||||
error( "GuiFormManager::GetContentCount - Unable to find content RefList!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return Count.
|
||||
return %contentObj.RefList.getCount();
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
///
|
||||
/// Public Application Events
|
||||
///
|
||||
Input::GetEventManager().registerEvent( "ClosePressed" );
|
||||
Input::GetEventManager().registerEvent( "BeginShutdown" );
|
||||
Input::GetEventManager().registerEvent( "FocusChanged" );
|
||||
|
||||
function onClosePressed()
|
||||
{
|
||||
//error("% Application Close - User Pressed the X button on their window");
|
||||
Input::GetEventManager().postEvent( "ClosePressed" );
|
||||
}
|
||||
|
||||
function onPreExit()
|
||||
{
|
||||
//error("% Application Close - quit called or quit message received"");
|
||||
Input::GetEventManager().postEvent( "BeginShutdown" );
|
||||
}
|
||||
|
||||
function onWindowFocusChange( %focused )
|
||||
{
|
||||
//error("% Application Close - quit called or quit message received"");
|
||||
Input::GetEventManager().postEvent( "FocusChanged", %focused );
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
///
|
||||
/// Public DragDrop Events
|
||||
///
|
||||
Input::GetEventManager().registerEvent( "BeginDropFiles" );
|
||||
Input::GetEventManager().registerEvent( "DropFile" );
|
||||
Input::GetEventManager().registerEvent( "EndDropFiles" );
|
||||
|
||||
function onDropBegin( %fileCount )
|
||||
{
|
||||
//error("% DragDrop - Beginning file dropping of" SPC %fileCount SPC " files.");
|
||||
Input::GetEventManager().postEvent( "BeginDropFiles", %fileCount );
|
||||
}
|
||||
function onDropFile( %filePath )
|
||||
{
|
||||
//error(" % DragDrop - Got File : " SPC %filePath );
|
||||
Input::GetEventManager().postEvent( "DropFile", %filePath );
|
||||
}
|
||||
function onDropEnd( %fileCount )
|
||||
{
|
||||
|
||||
//error("% DragDrop - Completed file dropping");
|
||||
Input::GetEventManager().postEvent( "EndDropFiles" );
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
///
|
||||
/// Returns Projects API's EventManager Singleton
|
||||
///
|
||||
function Input::GetEventManager()
|
||||
{
|
||||
if( !isObject( $_Tools::InputEventManager ) )
|
||||
$_Tools::InputEventManager = new EventManager() { queue = "InputEventManager"; };
|
||||
|
||||
return $_Tools::InputEventManager;
|
||||
}
|
||||
1
Templates/BaseGame/game/tools/editorClasses/scripts/platform/.gitignore
vendored
Normal file
1
Templates/BaseGame/game/tools/editorClasses/scripts/platform/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Keep directory in git repo
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//*** Initializes the Preferences Manager
|
||||
function initPreferencesManager()
|
||||
{
|
||||
// FIXME TGEA doesnt currently have these due to the way it's built
|
||||
return;
|
||||
|
||||
//*** Create the Preferences Manager singleton
|
||||
%pm = new PreferencesManager(pref);
|
||||
registerPreferencesManager(%pm.getId());
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
///
|
||||
/// Returns Projects API's EventManager Singleton
|
||||
///
|
||||
function Projects::GetEventManager()
|
||||
{
|
||||
if( !isObject( $_Tools::ProjectEventManager ) )
|
||||
$_Tools::ProjectEventManager = new EventManager() { queue = "ProjectEventManager"; };
|
||||
|
||||
return $_Tools::ProjectEventManager;
|
||||
}
|
||||
|
||||
|
||||
function Projects::DeclareProjectTarget( %projectTargetNamespace, %objectGlobalName )
|
||||
{
|
||||
// At some point it would be nice to have a console method
|
||||
// on SimObject that supported validating that another object
|
||||
// implemented all the methods provided by a given namespace.
|
||||
// .validateInterface("myNamespace") or some such.
|
||||
%projectObject = new ScriptMsgListener( %objectGlobalName )
|
||||
{
|
||||
class = %projectTargetNamespace;
|
||||
superclass = ProjectBase;
|
||||
};
|
||||
}
|
||||
|
||||
///
|
||||
/// Public Project Events
|
||||
///
|
||||
|
||||
/// ProjectOpened
|
||||
///
|
||||
/// is fired when a project has been opened and all bootstrap
|
||||
/// processing has occured on the project object.
|
||||
/// At this point it is safe for addons to do post-load processing
|
||||
/// such as creating new create entries and other specific modifications
|
||||
/// to the editor.
|
||||
Projects::GetEventManager().registerEvent( "ProjectOpened" );
|
||||
|
||||
/// ProjectClosed
|
||||
///
|
||||
/// is fired when a project is about to be closed and it's
|
||||
/// resources destroyed by the base project class. Addons
|
||||
/// should use this event to free any project specific resources
|
||||
/// they have allocated, as well as saving of data where applicable.
|
||||
Projects::GetEventManager().registerEvent( "ProjectClosed" );
|
||||
|
||||
/// ProjectDeploy
|
||||
///
|
||||
/// is fired when a game is about to be run from the editor and on
|
||||
/// this event addons and third party's should without scheduling or
|
||||
/// other delaying calls, deploy any game data that the game will need
|
||||
/// to it's game path.
|
||||
///
|
||||
/// Example, the core package zip code intercepts this message and
|
||||
/// builds and deploys a new core.zip if is necessary
|
||||
Projects::GetEventManager().registerEvent( "ProjectDeploy" );
|
||||
|
||||
/// Currently Unused
|
||||
Projects::GetEventManager().registerEvent( "ProjectFileAdded" );
|
||||
/// Currently Unused
|
||||
Projects::GetEventManager().registerEvent( "ProjectFileRemoved" );
|
||||
|
||||
///
|
||||
/// ProjectOpen Event Handler
|
||||
/// - %data is the project object to be opened
|
||||
function ProjectBase::onProjectOpen( %this, %data )
|
||||
{
|
||||
error("onProjectOpen Handler not implemented for class -" SPC %this.class );
|
||||
}
|
||||
|
||||
///
|
||||
/// ProjectClose Event Handler
|
||||
///
|
||||
function ProjectBase::onProjectClose( %this, %data )
|
||||
{
|
||||
error("onProjectClose Handler not implemented for class -" SPC %this.class );
|
||||
}
|
||||
|
||||
///
|
||||
/// ProjectAddFile Event Handler
|
||||
///
|
||||
function ProjectBase::onProjectAddFile( %this, %data )
|
||||
{
|
||||
error("onProjectAddFile Handler not implemented for class -" SPC %this.class );
|
||||
}
|
||||
|
||||
///
|
||||
/// ProjectRemoveFile Event Handler
|
||||
///
|
||||
function ProjectBase::onProjectRemoveFile( %this, %data )
|
||||
{
|
||||
error("onProjectRemoveFile Handler not implemented for class -" SPC %this.class );
|
||||
}
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
///
|
||||
/// Internal Project Events
|
||||
///
|
||||
Projects::GetEventManager().registerEvent( "_ProjectCreate" );
|
||||
Projects::GetEventManager().registerEvent( "_ProjectOpen" );
|
||||
Projects::GetEventManager().registerEvent( "_ProjectClose" );
|
||||
Projects::GetEventManager().registerEvent( "_ProjectAddFile" );
|
||||
Projects::GetEventManager().registerEvent( "_ProjectRemoveFile" );
|
||||
|
||||
///
|
||||
/// Project Context Methods
|
||||
///
|
||||
|
||||
function ProjectBase::isActive( %this )
|
||||
{
|
||||
if( Projects::GetEventManager().activeProject == %this.getId() )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function ProjectBase::getActiveProject( %this )
|
||||
{
|
||||
return Projects::GetEventManager().activeProject;
|
||||
}
|
||||
|
||||
function ProjectBase::setActive( %this )
|
||||
{
|
||||
%activeProject = %this.getActiveProject();
|
||||
|
||||
if( isObject( %activeProject ) )
|
||||
{
|
||||
// If another is active, properly post a close event for now THEN
|
||||
// and only then should we change the .activeProject field on the evtmgr
|
||||
}
|
||||
|
||||
Projects::GetEventManager().activeProject = %this;
|
||||
}
|
||||
|
||||
function ProjectBase::onAdd( %this )
|
||||
{
|
||||
// Subscribe to base events
|
||||
Projects::GetEventManager().subscribe( %this, "_ProjectCreate", "_onProjectCreate" );
|
||||
Projects::GetEventManager().subscribe( %this, "_ProjectOpen", "_onProjectOpen" );
|
||||
Projects::GetEventManager().subscribe( %this, "_ProjectClose", "_onProjectClose" );
|
||||
Projects::GetEventManager().subscribe( %this, "_ProjectAddFile", "_onProjectAddFile" );
|
||||
Projects::GetEventManager().subscribe( %this, "_ProjectRemoveFile", "_onProjectRemoveFile" );
|
||||
|
||||
}
|
||||
|
||||
function ProjectBase::onRemove( %this )
|
||||
{
|
||||
// Remove subscriptions to base events
|
||||
Projects::GetEventManager().remove( %this, "_ProjectCreate" );
|
||||
Projects::GetEventManager().remove( %this, "_ProjectOpen" );
|
||||
Projects::GetEventManager().remove( %this, "_ProjectClose" );
|
||||
Projects::GetEventManager().remove( %this, "_ProjectAddFile" );
|
||||
Projects::GetEventManager().remove( %this, "_ProjectRemoveFile" );
|
||||
|
||||
}
|
||||
|
||||
///
|
||||
/// Internal ProjectOpen Event Handler
|
||||
/// - %data is the project file path to be opened
|
||||
function ProjectBase::_onProjectOpen( %this, %data )
|
||||
{
|
||||
// Sanity check calling of this
|
||||
if( !%this.isMethod( "onProjectOpen" ) )
|
||||
{
|
||||
error("Incomplete Project Interface - onProjectOpen method is non-existent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !%this.LoadProject( %data ) )
|
||||
{
|
||||
messageBox("Unable to Load Project", "The project file you're attempting to open was created with an incompatible version of this software\n\nConversion of 1.1.X projects will be addressed soon, we apologize for the inconvenience.","Ok","Error");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
%this.gamePath = filePath( %data );
|
||||
%this.projectFile = %data;
|
||||
|
||||
%toggle = $Scripts::ignoreDSOs;
|
||||
$Scripts::ignoreDSOs = true;
|
||||
|
||||
%this.gameResPath = %this.gamePath @ "/*";
|
||||
|
||||
// Set current dir to game
|
||||
setCurrentDirectory( %this.gamePath );
|
||||
|
||||
// Set ^game expando
|
||||
setScriptPathExpando("project", %this.gamePath );
|
||||
setScriptPathExpando("game", %this.gamePath @ "/game" );
|
||||
|
||||
%this.onProjectOpen( %data );
|
||||
%this.setActive();
|
||||
|
||||
Projects::GetEventManager().postEvent( "ProjectOpened", %this );
|
||||
|
||||
$Scripts::ignoreDSOs = %toggle;
|
||||
$pref::lastProject = %data;
|
||||
}
|
||||
|
||||
///
|
||||
/// Internal ProjectClose Event Handler
|
||||
///
|
||||
function ProjectBase::_onProjectClose( %this, %data )
|
||||
{
|
||||
|
||||
Projects::GetEventManager().postEvent( "ProjectClosed", %this );
|
||||
|
||||
// Sanity check calling of this
|
||||
if( !%this.isMethod( "onProjectClose" ) )
|
||||
error("Incomplete Project Interface - onProjectClose method is non-existent!");
|
||||
else
|
||||
%this.onProjectClose( %data );
|
||||
|
||||
// Reset to tools directory
|
||||
setCurrentDirectory( getMainDotCsDir() );
|
||||
|
||||
// Remove expandos
|
||||
removeScriptPathExpando( "game" );
|
||||
removeScriptPathExpando( "project" );
|
||||
}
|
||||
|
||||
///
|
||||
/// Internal ProjectCreate Event Handler (Optionally Inherited by public interface)
|
||||
///
|
||||
function ProjectBase::_onProjectCreate( %this, %data )
|
||||
{
|
||||
// Force a write out of the project file
|
||||
if( !%this.SaveProject( %data ) )
|
||||
return false;
|
||||
|
||||
// Sanity check calling of this
|
||||
if( %this.isMethod( "onProjectCreate" ) )
|
||||
%this.onProjectCreate( %data );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Internal ProjectAddFile Event Handler
|
||||
///
|
||||
function ProjectBase::_onProjectAddFile( %this, %data )
|
||||
{
|
||||
// Sanity check calling of this
|
||||
if( !%this.isMethod( "onProjectAddFile" ) )
|
||||
error("Incomplete Project Interface - onProjectAddFile method is non-existent!");
|
||||
else
|
||||
%this.onProjectAddFile( %data );
|
||||
|
||||
}
|
||||
|
||||
///
|
||||
/// Internal ProjectRemoveFile Event Handler
|
||||
///
|
||||
function ProjectBase::_onProjectRemoveFile( %this, %data )
|
||||
{
|
||||
// Sanity check calling of this
|
||||
if( !%this.isMethod( "onProjectRemoveFile" ) )
|
||||
error("Incomplete Project Interface - onProjectRemoveFile method is non-existent!");
|
||||
else
|
||||
%this.onProjectRemoveFile( %data );
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 isInList( %word, %list )
|
||||
{
|
||||
%count = getWordCount( %list );
|
||||
for( %i = 0; %i < %count; %i++ )
|
||||
{
|
||||
%entry = getWord( %list, %i );
|
||||
if( %word $= %entry )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isInFieldList(%word, %list)
|
||||
{
|
||||
%count = getFieldCount( %list );
|
||||
for( %i = 0; %i < %count; %i++ )
|
||||
{
|
||||
%entry = getField( %list, %i );
|
||||
if( %word $= %entry )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue