Re-adds some bits from the old templates that were missed when doing the BaseGame template.

This commit is contained in:
Areloch 2017-03-26 17:53:01 -05:00
parent 9c7b5eec73
commit ea595143e8
25 changed files with 3278 additions and 381 deletions

View file

@ -0,0 +1,308 @@
exec("./FileDialog.gui");
function PlatformFileDialog::buildFilters(%this)
{
%str = strreplace( %this.data.filters, "|", "\t");
%this.filterCount = getFieldCount( %str ) / 2;
//echo( "Filter count: " @ %str );
for( %i = 0; %i < %this.filterCount; %i++ )
{
%this.filterName[%i] = GetField( %str, (%i*2) + 0 );
%this.filter[%i] = strreplace( GetField( %str, (%i*2) + 1 ), ";", "\t");
//echo( "Filter: " @ %this.filterName[%i] @ " - " @ %this.filter[%i]);
}
}
function PlatformFileDialog::handleFlags(%this, %flags)
{
%this.FDS_OPEN = false;
%this.FDS_SAVE = false;
%this.FDS_OVERWRITEPROMPT = false;
%this.FDS_MUSTEXIST = false;
%this.FDS_BROWSEFOLDER = false;
%flagCount = getFieldCount( %flags );
//echo( "flag count: " @ %flagCount );
for( %i = 0; %i < %flagCount; %i++ )
{
%flag = GetField( %flags, %i );
//echo(%flag);
if( %flag $= "FDS_OPEN" )
{
%this.FDS_OPEN = true;
%this-->Button.setText( "OPEN" );
%this-->Button.command = "PlatformFileDialog.tryFile();";
%this-->window.text = "Select file to OPEN";
}
else if( %flag $= "FDS_SAVE" )
{
%this.FDS_SAVE = true;
%this-->Button.setText( "SAVE" );
%this-->Button.command = "PlatformFileDialog.tryFile();";
%this-->window.text = "Select file to Save";
}
else if( %flag $= "FDS_OVERWRITEPROMPT" )
{
%this.FDS_OVERWRITEPROMPT = true;
}
else if( %flag $= "FDS_MUSTEXIST" )
{
%this.FDS_MUSTEXIST = true;
}
else if( %flag $= "FDS_BROWSEFOLDER" )
{
%this.FDS_BROWSEFOLDER = true;
%this-->window.text = "Select folder to OPEN";
}
}
}
function OpenPlatformFileDialog(%data, %flags)
{
PlatformFileDialog.searchDir = "";
PlatformFileDialog-->fileNameEdit.setText( "" );
PlatformFileDialog.data = %data;
PlatformFileDialog.data.finished = 0;
PlatformFileDialog.handleFlags( %flags );
if( !isObject(PlatformFileDialog.freeItemSet) )
{
PlatformFileDialog.freeItemSet = new SimGroup();
}
PlatformFileDialog.buildFilters();
Canvas.pushDialog(PlatformFileDialog);
}
function PlatformFileDialog::changeDir( %this, %newDir )
{
%this.searchDir = %newDir;
%this.update();
}
function PlatformFileDialog::navigateUp( %this )
{
//echo( "PlatformFileDialog::navigateUp " @ %this.searchDir );
if( %this.searchDir !$= "" )
{
%str = strreplace( %this.searchDir, "/", "\t");
%count = getFieldCount( %str );
if ( %count == 0 )
return;
if ( %count == 1 )
%address = "";
else
%address = getFields( %str, 0, %count - 2 );
%newDir = strreplace( %address, "\t", "/" );
if( %newDir !$= "" )
%newDir = %newDir @ "/";
%this.changeDir( %newDir );
}
}
function PlatformFileDialog::cancel( %this )
{
%this.data.files[0] = "";
%this.data.fileCount = 0;
%this.data.finished = 1;
Canvas.popDialog(%this);
}
function FileDialogItem::onClick( %this )
{
PlatformFileDialog-->fileNameEdit.setText( "" );
if( %this.isDir && %this.FDS_BROWSEFOLDER)
{
PlatformFileDialog-->fileNameEdit.setText( %this.text );
}
else if( !%this.isDir && !%this.FDS_BROWSEFOLDER )
{
PlatformFileDialog-->fileNameEdit.setText( %this.text );
}
}
function FileDialogItem::onDoubleClick( %this )
{
PlatformFileDialog-->fileNameEdit.setText( "" );
if( %this.isDir )
{
PlatformFileDialog.changeDir( PlatformFileDialog.searchDir @ %this.text @ "/" );
}
}
function PlatformFileDialog::tryFile( %this )
{
%file = %this-->fileNameEdit.getText();
if( %file $= "" )
return;
if( %this.FDS_OVERWRITEPROMPT )
{
%callback = "PlatformFileDialog.onFile( \"" @ %file @ "\" );";
MessageBoxOKCancel("Confirm overwrite", "Confirm overwrite", %callback, "");
return;
}
%this.onFile( %file );
}
function PlatformFileDialog::onFile( %this, %file )
{
%this.data.files[0] = "";
%this.data.fileCount = 0;
if( %file !$= "" )
{
%file = %this.searchDir @ %file;
%this.data.fileCount = 1;
}
if( %this.FDS_BROWSEFOLDER && !isDirectory( %file ) )
{
echo("Select a directory");
return;
}
else if( !%this.FDS_BROWSEFOLDER && !isFile( %file ) )
{
echo("Select a file");
return;
}
if( %this.FDS_MUSTEXIST )
{
if( !isFile( %file ) && !isDirectory( %file ) )
{
echo("Target must exist: " @ %file );
return;
}
}
%this.data.finished = 1;
%this.data.files[0] = %file;
Canvas.popDialog(%this);
%this-->fileNameEdit.setText( "" );
}
function PlatformFileDialog::clear( %this )
{
%itemArray = %this-->itemArray;
while( %itemArray.getCount() )
{
%item = %itemArray.getObject( 0 );
%this.freeItem( %item );
}
}
function PlatformFileDialog::getNewItem( %this )
{
if( %this.freeItemSet.getCount() )
%item = %this.freeItemSet.getObject( 0 );
if( isObject(%item) )
{
%this.freeItemSet.remove( %item );
}
else
{
//create new
%item = new GuiIconButtonCtrl();
%item.className = "FileDialogItem";
%item.profile = "ToolsGuiIconButtonProfile";
%item.textLocation = "left";
%item.iconLocation = "left";
%item.iconBitmap = "";
%item.text = "";
}
return %item;
}
function PlatformFileDialog::freeItem( %this, %item )
{
%this-->itemArray.remove( %item );
//clear
%item.setText( "" );
%item.iconBitmap = "";
%item.textMargin = 0;
%item.textLocation = "left";
%item.iconLocation = "left";
%item.resetState();
PlatformFileDialog.freeItemSet.add( %item );
}
function PlatformFileDialog::addDir( %this, %dir )
{
//echo( "Dir: " @ %dir );
%item = %this.getNewItem();
%item.setText( %dir );
%item.isDir = true;
%item.iconBitmap = "core/art/gui/images/folder";
%item.textLocation = "left";
%item.iconLocation = "left";
%item.textMargin = 24;
%this-->itemArray.add( %item );
}
function PlatformFileDialog::addFile( %this, %file )
{
//echo( "File: " @ %file );
%item = %this.getNewItem();
%item.text = strreplace( %file, %this.searchDir, "" );
%item.isDir = false;
%this-->itemArray.add( %item );
}
function PlatformFileDialog::onWake( %this )
{
%this.update();
}
function PlatformFileDialog::onSleep( %this )
{
%this.data.finished = 1;
}
function PlatformFileDialog::update( %this )
{
%this.clear();
%this-->popUpMenu.text = %this.searchDir;
// dirs
%dirList = getDirectoryList( %this.searchDir, 0 );
%wordCount = getFieldCount( %dirList );
for( %i = 0; %i < %wordCount; %i++ )
{
%dirItem = GetField( %dirList, %i );
%this.addDir( %dirItem );
}
//files
%pattern = %this.filter[0];
//echo( %pattern );
%file = findFirstFileMultiExpr( %this.searchDir @ %pattern, false);
while( %file !$= "" )
{
%this.addFile( %file );
%file = findNextFileMultiExpr( %pattern );
}
}

View file

@ -0,0 +1,40 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
if($platform $= "macos")
{
new GuiCursor(DefaultCursor)
{
hotSpot = "4 4";
renderOffset = "0 0";
bitmapName = "~/art/gui/images/macCursor";
};
}
else
{
new GuiCursor(DefaultCursor)
{
hotSpot = "1 1";
renderOffset = "0 0";
bitmapName = "~/art/gui/images/defaultCursor";
};
}

View file

@ -0,0 +1,244 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
// A very simple music player.
//---------------------------------------------------------------------------------------------
// Prerequisites.
if( !isObject( GuiMusicPlayer ) )
exec( "./guiMusicPlayer.gui" );
//---------------------------------------------------------------------------------------------
// Preferences.
$pref::GuiMusicPlayer::filePattern = "*.ogg\t*.wav";
$pref::GuiMusicPlayer::filePatternFMOD = "*.aiff\t*.asf\t*.flac\t*.it\t*.mid\t*.mod\t*.mp2\t*.mp3\t*.ogg\t*.s3m\t*.vag\t*.wav\t*.wma\t*.xm";
$pref::GuiMusicPlayer::fadeTime = "3.0";
//---------------------------------------------------------------------------------------------
// Datablocks.
singleton SFXDescription( GuiMusicPlayerStream : AudioMusic2D )
{
volume = 1.0;
isLooping = false;
isStreaming = true;
is3D = false;
};
singleton SFXDescription( GuiMusicPlayerLoopingStream : AudioMusic2D )
{
volume = 1.0;
isLooping = true;
isStreaming = true;
is3D = false;
};
//---------------------------------------------------------------------------------------------
// Functions.
function toggleMusicPlayer()
{
if( !GuiMusicPlayer.isAwake() )
{
GuiMusicPlayer.setExtent( Canvas.getExtent() );
GuiMusicPlayer.setPosition( 0, 0 );
Canvas.pushDialog( GuiMusicPlayer );
}
else
Canvas.popDialog( GuiMusicPlayer );
}
//---------------------------------------------------------------------------------------------
// Methods.
function GuiMusicPlayer_onSFXSourceStatusChange( %id, %status )
{
if( %status $= "Stopped" )
GuiMusicPlayer.onStop();
}
function GuiMusicPlayerClass::play( %this )
{
if( %this.status $= "Stopped"
|| %this.status $= "Paused"
|| %this.status $= "" )
{
%isPlaying = true;
if( %this.status $= "Paused" && isObject( %this.sfxSource ) )
%this.sfxSource.play();
else
{
%sel = GuiMusicPlayerMusicList.getSelectedItem();
if( %sel == -1 )
%isPlaying = false;
else
{
%desc = GuiMusicPlayerStream;
if( GuiMusicPlayerLoopCheckBox.getValue() )
%desc = GuiMusicPlayerLoopingStream;
if( GuiMusicPlayerFadeCheckBox.getValue() )
{
%desc.fadeInTime = $pref::GuiMusicPlayer::fadeTime;
%desc.fadeOutTime = $pref::GuiMusicPlayer::fadeTime;
}
else
{
%desc.fadeInTime = 0;
%desc.fadeOutTime = 0;
}
%file = GuiMusicPlayerMusicList.getItemText( %sel );
%this.sfxSource = sfxPlayOnce( %desc, %file );
if( !%this.sfxSource )
%isPlaying = false;
else
{
%this.sfxSource.statusCallback = "GuiMusicPlayer_onSFXSourceStatusChange";
GuiMusicPlayer.status = "Playing";
GuiMusicPlayerScrubber.setActive( true );
GuiMusicPlayerScrubber.setup( %this.sfxSource.getDuration() );
}
}
}
if( %isPlaying )
{
GuiMusicPlayerPlayButton.setText( "Pause" );
GuiMusicPlayerPlayButton.command = "GuiMusicPlayer.pause();";
GuiMusicPlayerLoopCheckBox.setActive( false );
GuiMusicPlayerFadeCheckBox.setActive( false );
%this.status = "Playing";
}
}
}
function GuiMusicPlayerClass::stop( %this )
{
if( %this.status $= "Playing"
|| %this.status $= "Paused" )
{
if( isObject( %this.sfxSource ) )
%this.sfxSource.stop( 0 ); // Stop immediately.
}
}
function GuiMusicPlayerClass::onStop( %this )
{
%this.sfxSource = 0;
GuiMusicPlayerLoopCheckBox.setActive( true );
GuiMusicPlayerFadeCheckBox.setActive( true );
GuiMusicPlayerScrubber.setActive( false );
GuiMusicPlayerPlayButton.setText( "Play" );
GuiMusicPlayerPlayButton.Command = "GuiMusicPlayer.play();";
%this.status = "Stopped";
GuiMusicPlayerScrubber.setValue( 0 );
}
function GuiMusicPlayerClass::pause( %this )
{
if( %this.status $= "Playing" )
{
if( isObject( %this.sfxSource ) )
%this.sfxSource.pause( 0 );
GuiMusicPlayerPlayButton.setText( "Play" );
GuiMusicPlayerPlayButton.command = "GuiMusicPlayer.play();";
%this.status = "Paused";
}
}
function GuiMusicPlayerClass::seek( %this, %playtime )
{
if( ( %this.status $= "Playing"
|| %this.status $= "Paused" )
&& isObject( %this.sfxSource ) )
%this.sfxSource.setPosition( %playtime );
}
function GuiMusicPlayer::onWake( %this )
{
GuiMusicPlayerMusicList.load();
}
function GuiMusicPlayerMusicListClass::load( %this )
{
// Remove all the files currently in the list.
%this.clearItems();
// Find the file matching pattern we should use.
%filePattern = $pref::GuiMusicPlayer::filePattern;
%sfxProvider = getWord( sfxGetDeviceInfo(), 0 );
%filePatternVarName = "$pref::GuiMusicPlayer::filePattern" @ %sfxProvider;
if( isDefined( %filePatternVarName ) )
eval( "%filePattern = " @ %filePatternVarName @ ";" );
// Find all files matching the pattern.
for( %file = findFirstFileMultiExpr( %filePattern );
%file !$= "";
%file = findNextFileMultiExpr( %filePattern ) )
%this.addItem( makeRelativePath( %file, getMainDotCsDir() ) );
}
function GuiMusicPlayerMusicList::onDoubleClick( %this )
{
GuiMusicPlayer.stop();
GuiMusicPlayer.play();
}
function GuiMusicPlayerScrubber::onMouseDragged( %this )
{
%this.isBeingDragged = true;
}
function GuiMusicPlayerScrubberClass::setup( %this, %totalPlaytime )
{
%this.range = "0 " @ %totalPlaytime;
%this.ticks = %totalPlaytime / 5; // One tick per five seconds.
%this.update();
}
function GuiMusicPlayerScrubberClass::update( %this )
{
if( GuiMusicPlayer.status $= "Playing"
&& !%this.isBeingDragged )
%this.setValue( GuiMusicPlayer.sfxSource.getPosition() );
if( GuiMusicPlayer.status $= "Playing"
|| GuiMusicPlayer.status $= "Paused" )
%this.schedule( 5, "update" );
}
function GuiMusicPlayerScrubberClass::onDragComplete( %this )
{
GuiMusicPlayer.seek( %this.getValue() );
%this.isBeingDragged = false;
}

View file

@ -0,0 +1,50 @@
//-----------------------------------------------------------------------------
// 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 GuiTreeViewCtrl::onDefineIcons( %this )
{
%icons = "core/art/gui/images/treeview/default:" @
"core/art/gui/images/treeview/simgroup:" @
"core/art/gui/images/treeview/simgroup_closed:" @
"core/art/gui/images/treeview/simgroup_selected:" @
"core/art/gui/images/treeview/simgroup_selected_closed:" @
"core/art/gui/images/treeview/hidden:" @
"core/art/gui/images/treeview/shll_icon_passworded_hi:" @
"core/art/gui/images/treeview/shll_icon_passworded:" @
"core/art/gui/images/treeview/default";
%this.buildIconTable(%icons);
}
function GuiTreeViewCtrl::handleRenameObject( %this, %name, %obj )
{
%inspector = GuiInspector::findByObject( %obj );
if( isObject( %inspector ) )
{
%field = ( %this.renameInternal ) ? "internalName" : "name";
%inspector.setObjectField( %field, %name );
return true;
}
return false;
}

View file

@ -0,0 +1,293 @@
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(PlatformFileDialog) {
position = "0 0";
extent = "1024 768";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1";
new GuiWindowCtrl() {
text = "";
resizeWidth = "1";
resizeHeight = "1";
canMove = "1";
canClose = "1";
canMinimize = "1";
canMaximize = "1";
canCollapse = "0";
closeCommand = "PlatformFileDialog.cancel();";
edgeSnap = "1";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "135 113";
extent = "727 623";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiWindowProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "window";
canSave = "1";
canSaveDynamicFields = "0";
new GuiControl() {
position = "2 16";
extent = "717 37";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "bottom";
profile = "ToolsGuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiBitmapButtonCtrl() {
bitmap = "tools/gui/images/folderUp";
bitmapMode = "Stretched";
autoFitExtents = "0";
useModifiers = "0";
useStates = "1";
groupNum = "0";
buttonType = "PushButton";
useMouseEvents = "0";
position = "9 9";
extent = "20 19";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiButtonProfile";
visible = "1";
active = "1";
command = "PlatformFileDialog.navigateUp();";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "folderUpButton";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiPopUpMenuCtrl() {
maxPopupHeight = "200";
sbUsesNAColor = "0";
reverseTextList = "0";
bitmapBounds = "16 16";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "36 9";
extent = "666 18";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "bottom";
profile = "ToolsGuiPopUpMenuProfile";
visible = "1";
active = "1";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "PopupMenu";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiScrollCtrl() {
willFirstRespond = "1";
hScrollBar = "dynamic";
vScrollBar = "alwaysOff";
lockHorizScroll = "0";
lockVertScroll = "1";
constantThumbHeight = "0";
childMargin = "0 0";
mouseWheelScrollSpeed = "-1";
docking = "None";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "0";
anchorBottom = "1";
anchorLeft = "1";
anchorRight = "0";
position = "7 64";
extent = "712 509";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "height";
profile = "GuiScrollProfile";
visible = "1";
active = "1";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiDynamicCtrlArrayControl() {
colCount = "1";
colSize = "64";
rowCount = "1";
rowSize = "258";
rowSpacing = "4";
colSpacing = "4";
frozen = "0";
autoCellSize = "1";
fillRowFirst = "0";
dynamicSize = "1";
padding = "0 0 0 0";
position = "1 1";
extent = "666 507";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "height";
profile = "ToolsGuiTransparentProfile";
visible = "1";
active = "1";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "itemArray";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiContainer() {
docking = "Bottom";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "0";
anchorBottom = "1";
anchorLeft = "1";
anchorRight = "1";
position = "1 583";
extent = "725 37";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiTextCtrl() {
text = "File Name";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "10 -1";
extent = "51 30";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextEditCtrl() {
historySize = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
password = "0";
passwordMask = "*";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "58 5";
extent = "561 18";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiTextEditProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "fileNameEdit";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiContainer() {
docking = "Right";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "0";
anchorBottom = "0";
anchorLeft = "0";
anchorRight = "0";
position = "630 0";
extent = "95 37";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiButtonCtrl() {
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "1";
position = "6 1";
extent = "81 24";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiButtonProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "Button";
canSave = "1";
canSaveDynamicFields = "0";
};
};
};
};
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,159 @@
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(IODropdownDlg) {
profile = "GuiDefaultProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
helpTag = "0";
new GuiWindowCtrl(IODropdownFrame) {
canSaveDynamicFields = "0";
Profile = "GuiWindowProfile";
horizSizing = "center";
vertSizing = "center";
position = "272 77";
extent = "256 117";
minExtent = "256 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
maxLength = "255";
resizeWidth = "1";
resizeHeight = "1";
canMove = "1";
canClose = "1";
canMinimize = "0";
canMaximize = "0";
minSize = "50 50";
text = "";
closeCommand="IOCallback(IODropdownDlg,IODropdownDlg.cancelCallback);";
new GuiMLTextCtrl(IODropdownText) {
text = "";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
isContainer = "0";
profile = "GuiMLTextProfile";
horizSizing = "center";
vertSizing = "bottom";
position = "9 26";
extent = "237 16";
minExtent = "8 8";
canSave = "1";
visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
new GuiBitmapBorderCtrl() {
isContainer = "0";
profile = "GuiGroupBorderProfile";
horizSizing = "width";
vertSizing = "bottom";
position = "7 51";
extent = "243 28";
minExtent = "0 0";
canSave = "1";
visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
new GuiTextCtrl(IOInputText) {
text = "Decal Datablock";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
isContainer = "0";
profile = "GuiTextRightProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "5 5";
extent = "105 18";
minExtent = "8 2";
canSave = "1";
visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
new GuiPopUpMenuCtrl(IODropdownMenu) {
maxPopupHeight = "200";
sbUsesNAColor = "0";
reverseTextList = "0";
bitmapBounds = "16 16";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
isContainer = "0";
profile = "GuiPopUpMenuProfile";
horizSizing = "width";
vertSizing = "bottom";
position = "115 5";
extent = "122 18";
minExtent = "8 2";
canSave = "1";
visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
};
new GuiButtonCtrl() {
text = "OK";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
isContainer = "0";
profile = "GuiButtonProfile";
horizSizing = "width";
vertSizing = "top";
position = "7 85";
extent = "156 24";
minExtent = "8 8";
canSave = "1";
visible = "1";
accelerator = "return";
command = "IOCallback(IODropdownDlg,IODropdownDlg.callback);";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
new GuiButtonCtrl() {
text = "Cancel";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
isContainer = "0";
profile = "GuiButtonProfile";
horizSizing = "left";
vertSizing = "top";
position = "170 85";
extent = "80 24";
minExtent = "8 8";
canSave = "1";
visible = "1";
accelerator = "escape";
command = "IOCallback(IODropdownDlg,IODropdownDlg.cancelCallback);";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
};
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,192 @@
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(GuiMusicPlayer) {
isContainer = "1";
Profile = "GuiWindowProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "0 0";
Extent = "1024 768";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "1";
superClass = "GuiMusicPlayerClass";
new GuiWindowCtrl() {
resizeWidth = "0";
resizeHeight = "0";
canMove = "1";
canClose = "1";
canMinimize = "1";
canMaximize = "1";
minSize = "50 50";
EdgeSnap = "1";
text = "Torque Music Player";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
isContainer = "1";
Profile = "GuiWindowProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "29 35";
Extent = "518 377";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
closeCommand = "toggleMusicPlayer();";
new GuiCheckBoxCtrl(GuiMusicPlayerFadeCheckBox) {
useInactiveState = "0";
text = "Fade";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
isContainer = "0";
Profile = "GuiCheckBoxProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "457 347";
Extent = "53 30";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl(GuiMusicPlayerLoopCheckBox) {
useInactiveState = "0";
text = "Loop";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
isContainer = "0";
Profile = "GuiCheckBoxProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "457 330";
Extent = "44 30";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
new GuiScrollCtrl() {
willFirstRespond = "1";
hScrollBar = "dynamic";
vScrollBar = "alwaysOn";
lockHorizScroll = "0";
lockVertScroll = "0";
constantThumbHeight = "0";
childMargin = "0 0";
mouseWheelScrollSpeed = "-1";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
isContainer = "1";
Profile = "GuiScrollProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "9 31";
Extent = "500 298";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
new GuiListBoxCtrl(GuiMusicPlayerMusicList) {
AllowMultipleSelections = "1";
fitParentWidth = "1";
isContainer = "0";
Profile = "GuiListBoxProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "1 1";
Extent = "485 2";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
superClass = "GuiMusicPlayerMusicListClass";
};
};
new GuiSliderCtrl(GuiMusicPlayerScrubber) {
range = "0 1";
ticks = "10";
value = "0";
snap = "false";
isContainer = "0";
Profile = "GuiSliderProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "114 343";
Extent = "331 23";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "$thisControl.onDragComplete();";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
class = "GuiMusicPlayerScrubberClass";
className = "GuiMusicPlayerScrubberClass";
};
new GuiButtonCtrl(GuiMusicPlayerStopButton) {
text = "Stop";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
isContainer = "0";
Profile = "GuiButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "57 338";
Extent = "40 30";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "GuiMusicPlayer.stop();";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
new GuiButtonCtrl(GuiMusicPlayerPlayButton) {
text = "Play";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
isContainer = "0";
Profile = "GuiButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "13 338";
Extent = "40 30";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "GuiMusicPlayer.play();";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
};
};
//--- OBJECT WRITE END ---

View file

@ -322,340 +322,3 @@
};
};
//--- OBJECT WRITE END ---
$MetricsParamArray[0] = "fps ";
$MetricsParamArray[1] = "shadow ";
$MetricsParamArray[2] = "gfx ";
$MetricsParamArray[3] = "sfx ";
$MetricsParamArray[4] = "terrain ";
$MetricsParamArray[5] = "groundcover ";
$MetricsParamArray[6] = "forest ";
$MetricsParamArray[7] = "net ";
$EnableProfiler = false;
$string = ""; //string used to collet the parameters for metrics function
function showMetrics(%var)
{
$string = "";
if(ppShowFps.getValue())
{
$string = $string @ $MetricsParamArray[0];
}
if(ppShowShadow.getValue())
{
$string = $string @ $MetricsParamArray[1];
}
if(ppShowGfx.getValue())
{
$string = $string @ $MetricsParamArray[2];
}
if(ppShowSfx.getValue())
{
$string = $string @ $MetricsParamArray[3];
}
if(ppShowTerrain.getValue())
{
$string = $string @ $MetricsParamArray[4];
}
if(ppShowForest.getValue())
{
$string = $string @ $MetricsParamArray[5];
}
if(ppShowGroundcover.getValue())
{
$string = $string @ $MetricsParamArray[6];
}
if(ppShowNet.getValue())
{
$string = $string @ $MetricsParamArray[7];
}
if(%var)
{
$EnableProfiler = !($EnableProfiler);
if($EnableProfiler)
{
metrics($string);
}
else if((false == $EnableProfiler))
{
metrics();
}
}
else if($EnableProfiler) //will enter only when the enable/disable button was pressed
{
metrics($string);
}
}
function showMetics(%var)
{
if(%var)
{
metrics($string);
}
else if(true == $EnableProfiler)
{
$EnableProfiler = false;
metrics();
}
}
GlobalActionMap.bind(keyboard, "ctrl F2", showMetics);
%guiContent = new GuiControl(FrameOverlayGui) {
profile = "GuiModelessDialogProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "True";
setFirstResponder = "True";
modal = "false";
helpTag = "0";
noCursor = true;
new GuiConsoleTextCtrl(TextOverlayControl) {
profile = "GuiConsoleTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "5 5";
extent = "130 18";
minExtent = "4 4";
visible = "True";
setFirstResponder = "True";
modal = "True";
helpTag = "0";
expression = "10";
command = "Canvas.popDialog(FrameOverlayGui);";
accelerator = "escape";
};
};
// Note: To implement your own metrics overlay
// just add a function with a name in the form
// XXXXMetricsCallback which can be enabled via
// metrics( XXXX )
function fpsMetricsCallback()
{
return " | FPS |" @
" " @ $fps::real @
" max: " @ $fps::realMax @
" min: " @ $fps::realMin @
" mspf: " @ 1000 / $fps::real;
}
function gfxMetricsCallback()
{
return " | GFX |" @
" PolyCount: " @ $GFXDeviceStatistics::polyCount @
" DrawCalls: " @ $GFXDeviceStatistics::drawCalls @
" RTChanges: " @ $GFXDeviceStatistics::renderTargetChanges;
}
function terrainMetricsCallback()
{
return " | Terrain |" @
" Cells: " @ $TerrainBlock::cellsRendered @
" Override Cells: " @ $TerrainBlock::overrideCells @
" DrawCalls: " @ $TerrainBlock::drawCalls;
}
function netMetricsCallback()
{
return " | Net |" @
" BitsSent: " @ $Stats::netBitsSent @
" BitsRcvd: " @ $Stats::netBitsReceived @
" GhostUpd: " @ $Stats::netGhostUpdates;
}
function groundCoverMetricsCallback()
{
return " | GroundCover |" @
" Cells: " @ $GroundCover::renderedCells @
" Billboards: " @ $GroundCover::renderedBillboards @
" Batches: " @ $GroundCover::renderedBatches @
" Shapes: " @ $GroundCover::renderedShapes;
}
function forestMetricsCallback()
{
return " | Forest |" @
" Cells: " @ $Forest::totalCells @
" Cells Meshed: " @ $Forest::cellsRendered @
" Cells Billboarded: " @ $Forest::cellsBatched @
" Meshes: " @ $Forest::cellItemsRendered @
" Billboards: " @ $Forest::cellItemsBatched;
}
function sfxMetricsCallback()
{
return " | SFX |" @
" Sounds: " @ $SFX::numSounds @
" Lists: " @ ( $SFX::numSources - $SFX::numSounds - $SFX::Device::fmodNumEventSource ) @
" Events: " @ $SFX::fmodNumEventSources @
" Playing: " @ $SFX::numPlaying @
" Culled: " @ $SFX::numCulled @
" Voices: " @ $SFX::numVoices @
" Buffers: " @ $SFX::Device::numBuffers @
" Memory: " @ ( $SFX::Device::numBufferBytes / 1024.0 / 1024.0 ) @ " MB" @
" Time/S: " @ $SFX::sourceUpdateTime @
" Time/P: " @ $SFX::parameterUpdateTime @
" Time/A: " @ $SFX::ambientUpdateTime;
}
function sfxSourcesMetricsCallback()
{
return sfxDumpSourcesToString();
}
function sfxStatesMetricsCallback()
{
return " | SFXStates |" @ sfxGetActiveStates();
}
function timeMetricsCallback()
{
return " | Time |" @
" Sim Time: " @ getSimTime() @
" Mod: " @ getSimTime() % 32;
}
function reflectMetricsCallback()
{
return " | REFLECT |" @
" Objects: " @ $Reflect::numObjects @
" Visible: " @ $Reflect::numVisible @
" Occluded: " @ $Reflect::numOccluded @
" Updated: " @ $Reflect::numUpdated @
" Elapsed: " @ $Reflect::elapsed NL
" Allocated: " @ $Reflect::renderTargetsAllocated @
" Pooled: " @ $Reflect::poolSize NL
" " @ getWord( $Reflect::textureStats, 1 ) TAB
" " @ getWord( $Reflect::textureStats, 2 ) @ "MB" TAB
" " @ getWord( $Reflect::textureStats, 0 );
}
function decalMetricsCallback()
{
return " | DECAL |" @
" Batches: " @ $Decal::Batches @
" Buffers: " @ $Decal::Buffers @
" DecalsRendered: " @ $Decal::DecalsRendered;
}
function renderMetricsCallback()
{
return " | Render |" @
" Mesh: " @ $RenderMetrics::RIT_Mesh @
" MeshDL: " @ $RenderMetrics::RIT_MeshDynamicLighting @
" Shadow: " @ $RenderMetrics::RIT_Shadow @
" Sky: " @ $RenderMetrics::RIT_Sky @
" Obj: " @ $RenderMetrics::RIT_Object @
" ObjT: " @ $RenderMetrics::RIT_ObjectTranslucent @
" Decal: " @ $RenderMetrics::RIT_Decal @
" Water: " @ $RenderMetrics::RIT_Water @
" Foliage: " @ $RenderMetrics::RIT_Foliage @
" Trans: " @ $RenderMetris::RIT_Translucent @
" Custom: " @ $RenderMetrics::RIT_Custom;
}
function shadowMetricsCallback()
{
return " | Shadow |" @
" Active: " @ $ShadowStats::activeMaps @
" Updated: " @ $ShadowStats::updatedMaps @
" PolyCount: " @ $ShadowStats::polyCount @
" DrawCalls: " @ $ShadowStats::drawCalls @
" RTChanges: " @ $ShadowStats::rtChanges @
" PoolTexCount: " @ $ShadowStats::poolTexCount @
" PoolTexMB: " @ $ShadowStats::poolTexMemory @ "MB";
}
function basicShadowMetricsCallback()
{
return " | Shadow |" @
" Active: " @ $BasicLightManagerStats::activePlugins @
" Updated: " @ $BasicLightManagerStats::shadowsUpdated @
" Elapsed Ms: " @ $BasicLightManagerStats::elapsedUpdateMs;
}
function lightMetricsCallback()
{
return " | Deferred Lights |" @
" Active: " @ $lightMetrics::activeLights @
" Culled: " @ $lightMetrics::culledLights;
}
function particleMetricsCallback()
{
return " | Particles |" @
" # Simulated " @ $particle::numSimulated;
}
function partMetricsCallback()
{
return particleMetricsCallback();
}
// alias
function audioMetricsCallback()
{
return sfxMetricsCallback();
}
// alias
function videoMetricsCallback()
{
return gfxMetricsCallback();
}
// Add a metrics HUD. %expr can be a vector of names where each element
// must have a corresponding '<name>MetricsCallback()' function defined
// that will be called on each update of the GUI control. The results
// of each function are stringed together.
//
// Example: metrics( "fps gfx" );
function metrics( %expr )
{
%metricsExpr = "";
if( %expr !$= "" )
{
for( %i = 0;; %i ++ )
{
%name = getWord( %expr, %i );
if( %name $= "" )
break;
else
{
%cb = %name @ "MetricsCallback";
if( !isFunction( %cb ) )
error( "metrics - undefined callback: " @ %cb );
else
{
%cb = %cb @ "()";
if( %i > 0 )
%metricsExpr = %metricsExpr @ " NL ";
%metricsExpr = %metricsExpr @ %cb;
}
}
}
if( %metricsExpr !$= "" )
%metricsExpr = %metricsExpr @ " @ \" \"";
}
if( %metricsExpr !$= "" )
{
$GameCanvas.pushDialog( FrameOverlayGui, 1000 );
TextOverlayControl.setValue( %metricsExpr );
}
else
$GameCanvas.popDialog(FrameOverlayGui);
}

View file

@ -0,0 +1,90 @@
//-----------------------------------------------------------------------------
// 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 HelpDlg::onWake(%this)
{
HelpFileList.entryCount = 0;
HelpFileList.clear();
for(%file = findFirstFile("*.hfl"); %file !$= ""; %file = findNextFile("*.hfl"))
{
HelpFileList.fileName[HelpFileList.entryCount] = %file;
HelpFileList.addRow(HelpFileList.entryCount, fileBase(%file));
HelpFileList.entryCount++;
}
HelpFileList.sortNumerical(0);
for(%i = 0; %i < HelpFileList.entryCount; %i++)
{
%rowId = HelpFileList.getRowId(%i);
%text = HelpFileList.getRowTextById(%rowId);
%text = %i + 1 @ ". " @ restWords(%text);
HelpFileList.setRowById(%rowId, %text);
}
HelpFileList.setSelectedRow(0);
}
function HelpFileList::onSelect(%this, %row)
{
%fo = new FileObject();
%fo.openForRead(%this.fileName[%row]);
%text = "";
while(!%fo.isEOF())
%text = %text @ %fo.readLine() @ "\n";
%fo.delete();
HelpText.setText(%text);
}
function getHelp(%helpName)
{
Canvas.pushDialog(HelpDlg);
if(%helpName !$= "")
{
%index = HelpFileList.findTextIndex(%helpName);
HelpFileList.setSelectedRow(%index);
}
}
function contextHelp()
{
for(%i = 0; %i < Canvas.getCount(); %i++)
{
if(Canvas.getObject(%i).getName() $= HelpDlg)
{
Canvas.popDialog(HelpDlg);
return;
}
}
%content = Canvas.getContent();
%helpPage = %content.getHelpPage();
getHelp(%helpPage);
}
function GuiControl::getHelpPage(%this)
{
return %this.helpPage;
}
function GuiMLTextCtrl::onURL(%this, %url)
{
gotoWebPage( %url );
}

View file

@ -0,0 +1,367 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
$MetricsParamArray[0] = "fps ";
$MetricsParamArray[1] = "shadow ";
$MetricsParamArray[2] = "gfx ";
$MetricsParamArray[3] = "sfx ";
$MetricsParamArray[4] = "terrain ";
$MetricsParamArray[5] = "groundcover ";
$MetricsParamArray[6] = "forest ";
$MetricsParamArray[7] = "net ";
$EnableProfiler = false;
$string = ""; //string used to collet the parameters for metrics function
function showMetrics(%var)
{
$string = "";
if(ppShowFps.getValue())
{
$string = $string @ $MetricsParamArray[0];
}
if(ppShowShadow.getValue())
{
$string = $string @ $MetricsParamArray[1];
}
if(ppShowGfx.getValue())
{
$string = $string @ $MetricsParamArray[2];
}
if(ppShowSfx.getValue())
{
$string = $string @ $MetricsParamArray[3];
}
if(ppShowTerrain.getValue())
{
$string = $string @ $MetricsParamArray[4];
}
if(ppShowForest.getValue())
{
$string = $string @ $MetricsParamArray[5];
}
if(ppShowGroundcover.getValue())
{
$string = $string @ $MetricsParamArray[6];
}
if(ppShowNet.getValue())
{
$string = $string @ $MetricsParamArray[7];
}
if(%var)
{
$EnableProfiler = !($EnableProfiler);
if($EnableProfiler)
{
metrics($string);
}
else if((false == $EnableProfiler))
{
metrics();
}
}
else if($EnableProfiler) //will enter only when the enable/disable button was pressed
{
metrics($string);
}
}
function showMetics(%var)
{
if(%var)
{
metrics($string);
}
else if(true == $EnableProfiler)
{
$EnableProfiler = false;
metrics();
}
}
GlobalActionMap.bind(keyboard, "ctrl F2", showMetics);
%guiContent = new GuiControl(FrameOverlayGui) {
profile = "GuiModelessDialogProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "True";
setFirstResponder = "True";
modal = "false";
helpTag = "0";
noCursor = true;
new GuiConsoleTextCtrl(TextOverlayControl) {
profile = "GuiConsoleTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "5 5";
extent = "130 18";
minExtent = "4 4";
visible = "True";
setFirstResponder = "True";
modal = "True";
helpTag = "0";
expression = "10";
command = "Canvas.popDialog(FrameOverlayGui);";
accelerator = "escape";
};
};
// Note: To implement your own metrics overlay
// just add a function with a name in the form
// XXXXMetricsCallback which can be enabled via
// metrics( XXXX )
function fpsMetricsCallback()
{
return " | FPS |" @
" " @ $fps::real @
" max: " @ $fps::realMax @
" min: " @ $fps::realMin @
" mspf: " @ 1000 / $fps::real;
}
function gfxMetricsCallback()
{
return " | GFX |" @
" PolyCount: " @ $GFXDeviceStatistics::polyCount @
" DrawCalls: " @ $GFXDeviceStatistics::drawCalls @
" RTChanges: " @ $GFXDeviceStatistics::renderTargetChanges;
}
function terrainMetricsCallback()
{
return " | Terrain |" @
" Cells: " @ $TerrainBlock::cellsRendered @
" Override Cells: " @ $TerrainBlock::overrideCells @
" DrawCalls: " @ $TerrainBlock::drawCalls;
}
function netMetricsCallback()
{
return " | Net |" @
" BitsSent: " @ $Stats::netBitsSent @
" BitsRcvd: " @ $Stats::netBitsReceived @
" GhostUpd: " @ $Stats::netGhostUpdates;
}
function groundCoverMetricsCallback()
{
return " | GroundCover |" @
" Cells: " @ $GroundCover::renderedCells @
" Billboards: " @ $GroundCover::renderedBillboards @
" Batches: " @ $GroundCover::renderedBatches @
" Shapes: " @ $GroundCover::renderedShapes;
}
function forestMetricsCallback()
{
return " | Forest |" @
" Cells: " @ $Forest::totalCells @
" Cells Meshed: " @ $Forest::cellsRendered @
" Cells Billboarded: " @ $Forest::cellsBatched @
" Meshes: " @ $Forest::cellItemsRendered @
" Billboards: " @ $Forest::cellItemsBatched;
}
function sfxMetricsCallback()
{
return " | SFX |" @
" Sounds: " @ $SFX::numSounds @
" Lists: " @ ( $SFX::numSources - $SFX::numSounds - $SFX::Device::fmodNumEventSource ) @
" Events: " @ $SFX::fmodNumEventSources @
" Playing: " @ $SFX::numPlaying @
" Culled: " @ $SFX::numCulled @
" Voices: " @ $SFX::numVoices @
" Buffers: " @ $SFX::Device::numBuffers @
" Memory: " @ ( $SFX::Device::numBufferBytes / 1024.0 / 1024.0 ) @ " MB" @
" Time/S: " @ $SFX::sourceUpdateTime @
" Time/P: " @ $SFX::parameterUpdateTime @
" Time/A: " @ $SFX::ambientUpdateTime;
}
function sfxSourcesMetricsCallback()
{
return sfxDumpSourcesToString();
}
function sfxStatesMetricsCallback()
{
return " | SFXStates |" @ sfxGetActiveStates();
}
function timeMetricsCallback()
{
return " | Time |" @
" Sim Time: " @ getSimTime() @
" Mod: " @ getSimTime() % 32;
}
function reflectMetricsCallback()
{
return " | REFLECT |" @
" Objects: " @ $Reflect::numObjects @
" Visible: " @ $Reflect::numVisible @
" Occluded: " @ $Reflect::numOccluded @
" Updated: " @ $Reflect::numUpdated @
" Elapsed: " @ $Reflect::elapsed NL
" Allocated: " @ $Reflect::renderTargetsAllocated @
" Pooled: " @ $Reflect::poolSize NL
" " @ getWord( $Reflect::textureStats, 1 ) TAB
" " @ getWord( $Reflect::textureStats, 2 ) @ "MB" TAB
" " @ getWord( $Reflect::textureStats, 0 );
}
function decalMetricsCallback()
{
return " | DECAL |" @
" Batches: " @ $Decal::Batches @
" Buffers: " @ $Decal::Buffers @
" DecalsRendered: " @ $Decal::DecalsRendered;
}
function renderMetricsCallback()
{
return " | Render |" @
" Mesh: " @ $RenderMetrics::RIT_Mesh @
" MeshDL: " @ $RenderMetrics::RIT_MeshDynamicLighting @
" Shadow: " @ $RenderMetrics::RIT_Shadow @
" Sky: " @ $RenderMetrics::RIT_Sky @
" Obj: " @ $RenderMetrics::RIT_Object @
" ObjT: " @ $RenderMetrics::RIT_ObjectTranslucent @
" Decal: " @ $RenderMetrics::RIT_Decal @
" Water: " @ $RenderMetrics::RIT_Water @
" Foliage: " @ $RenderMetrics::RIT_Foliage @
" Trans: " @ $RenderMetris::RIT_Translucent @
" Custom: " @ $RenderMetrics::RIT_Custom;
}
function shadowMetricsCallback()
{
return " | Shadow |" @
" Active: " @ $ShadowStats::activeMaps @
" Updated: " @ $ShadowStats::updatedMaps @
" PolyCount: " @ $ShadowStats::polyCount @
" DrawCalls: " @ $ShadowStats::drawCalls @
" RTChanges: " @ $ShadowStats::rtChanges @
" PoolTexCount: " @ $ShadowStats::poolTexCount @
" PoolTexMB: " @ $ShadowStats::poolTexMemory @ "MB";
}
function basicShadowMetricsCallback()
{
return " | Shadow |" @
" Active: " @ $BasicLightManagerStats::activePlugins @
" Updated: " @ $BasicLightManagerStats::shadowsUpdated @
" Elapsed Ms: " @ $BasicLightManagerStats::elapsedUpdateMs;
}
function lightMetricsCallback()
{
return " | Deferred Lights |" @
" Active: " @ $lightMetrics::activeLights @
" Culled: " @ $lightMetrics::culledLights;
}
function particleMetricsCallback()
{
return " | Particles |" @
" # Simulated " @ $particle::numSimulated;
}
function partMetricsCallback()
{
return particleMetricsCallback();
}
function imposterMetricsCallback()
{
return " | IMPOSTER |" @
" Rendered: " @ $ImposterStats::rendered @
" Batches: " @ $ImposterStats::batches @
" DrawCalls: " @ $ImposterStats::drawCalls @
" Polys: " @ $ImposterStats::polyCount @
" RtChanges: " @ $ImposterStats::rtChanges;
}
// alias
function audioMetricsCallback()
{
return sfxMetricsCallback();
}
// alias
function videoMetricsCallback()
{
return gfxMetricsCallback();
}
// Add a metrics HUD. %expr can be a vector of names where each element
// must have a corresponding '<name>MetricsCallback()' function defined
// that will be called on each update of the GUI control. The results
// of each function are stringed together.
//
// Example: metrics( "fps gfx" );
function metrics( %expr )
{
%metricsExpr = "";
if( %expr !$= "" )
{
for( %i = 0;; %i ++ )
{
%name = getWord( %expr, %i );
if( %name $= "" )
break;
else
{
%cb = %name @ "MetricsCallback";
if( !isFunction( %cb ) )
error( "metrics - undefined callback: " @ %cb );
else
{
%cb = %cb @ "()";
if( %i > 0 )
%metricsExpr = %metricsExpr @ " NL ";
%metricsExpr = %metricsExpr @ %cb;
}
}
}
if( %metricsExpr !$= "" )
%metricsExpr = %metricsExpr @ " @ \" \"";
}
if( %metricsExpr !$= "" )
{
$GameCanvas.pushDialog( FrameOverlayGui, 1000 );
TextOverlayControl.setValue( %metricsExpr );
}
else
$GameCanvas.popDialog(FrameOverlayGui);
}