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

@ -470,51 +470,9 @@ function AggregateControl::callMethod(%this, %method, %args)
}
// A function used in order to easily parse the MissionGroup for classes . I'm pretty
// sure at this point the function can be easily modified to search the any group as well.
function parseMissionGroup( %className, %childGroup )
{
if( getWordCount( %childGroup ) == 0)
%currentGroup = "MissionGroup";
else
%currentGroup = %childGroup;
for(%i = 0; %i < (%currentGroup).getCount(); %i++)
{
if( (%currentGroup).getObject(%i).getClassName() $= %className )
return true;
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
{
if( parseMissionGroup( %className, (%currentGroup).getObject(%i).getId() ) )
return true;
}
}
}
// A variation of the above used to grab ids from the mission group based on classnames
function parseMissionGroupForIds( %className, %childGroup )
{
if( getWordCount( %childGroup ) == 0)
%currentGroup = "MissionGroup";
else
%currentGroup = %childGroup;
for(%i = 0; %i < (%currentGroup).getCount(); %i++)
{
if( (%currentGroup).getObject(%i).getClassName() $= %className )
%classIds = %classIds @ (%currentGroup).getObject(%i).getId() @ " ";
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
%classIds = %classIds @ parseMissionGroupForIds( %className, (%currentGroup).getObject(%i).getId());
}
return trim( %classIds );
}
//------------------------------------------------------------------------------
// Altered Version of TGB's QuickEditDropDownTextEditCtrl
//------------------------------------------------------------------------------
function QuickEditDropDownTextEditCtrl::onRenameItem( %this )
{
}
@ -531,4 +489,466 @@ function QuickEditDropDownTextEditCtrl::updateFromChild( %this, %ctrl )
%popup.changeTextById( %popup.getSelected(), %ctrl.getText() );
%this.onRenameItem();
}
}
}
// Writes out all script functions to a file.
function writeOutFunctions()
{
new ConsoleLogger(logger, "scriptFunctions.txt", false);
dumpConsoleFunctions();
logger.delete();
}
// Writes out all script classes to a file.
function writeOutClasses()
{
new ConsoleLogger(logger, "scriptClasses.txt", false);
dumpConsoleClasses();
logger.delete();
}
//
function compileFiles(%pattern)
{
%path = filePath(%pattern);
%saveDSO = $Scripts::OverrideDSOPath;
%saveIgnore = $Scripts::ignoreDSOs;
$Scripts::OverrideDSOPath = %path;
$Scripts::ignoreDSOs = false;
%mainCsFile = makeFullPath("main.cs");
for (%file = findFirstFileMultiExpr(%pattern); %file !$= ""; %file = findNextFileMultiExpr(%pattern))
{
// we don't want to try and compile the primary main.cs
if(%mainCsFile !$= %file)
compile(%file, true);
}
$Scripts::OverrideDSOPath = %saveDSO;
$Scripts::ignoreDSOs = %saveIgnore;
}
function displayHelp()
{
// Notes on logmode: console logging is written to console.log.
// -log 0 disables console logging.
// -log 1 appends to existing logfile; it also closes the file
// (flushing the write buffer) after every write.
// -log 2 overwrites any existing logfile; it also only closes
// the logfile when the application shuts down. (default)
error(
"Torque Demo command line options:\n"@
" -log <logmode> Logging behavior; see main.cs comments for details\n"@
" -game <game_name> Reset list of mods to only contain <game_name>\n"@
" <game_name> Works like the -game argument\n"@
" -dir <dir_name> Add <dir_name> to list of directories\n"@
" -console Open a separate console\n"@
" -jSave <file_name> Record a journal\n"@
" -jPlay <file_name> Play back a journal\n"@
" -help Display this help message\n"
);
}
// Execute startup scripts for each mod, starting at base and working up
function loadDir(%dir)
{
pushback($userDirs, %dir, ";");
if (isScriptFile(%dir @ "/main.cs"))
exec(%dir @ "/main.cs");
}
function loadDirs(%dirPath)
{
%dirPath = nextToken(%dirPath, token, ";");
if (%dirPath !$= "")
loadDirs(%dirPath);
if(exec(%token @ "/main.cs") != true)
{
error("Error: Unable to find specified directory: " @ %token );
$dirCount--;
}
}
//------------------------------------------------------------------------------
// Utility remap functions:
//------------------------------------------------------------------------------
function ActionMap::copyBind( %this, %otherMap, %command )
{
if ( !isObject( %otherMap ) )
{
error( "ActionMap::copyBind - \"" @ %otherMap @ "\" is not an object!" );
return;
}
%bind = %otherMap.getBinding( %command );
if ( %bind !$= "" )
{
%device = getField( %bind, 0 );
%action = getField( %bind, 1 );
%flags = %otherMap.isInverted( %device, %action ) ? "SDI" : "SD";
%deadZone = %otherMap.getDeadZone( %device, %action );
%scale = %otherMap.getScale( %device, %action );
%this.bind( %device, %action, %flags, %deadZone, %scale, %command );
}
}
//------------------------------------------------------------------------------
function ActionMap::blockBind( %this, %otherMap, %command )
{
if ( !isObject( %otherMap ) )
{
error( "ActionMap::blockBind - \"" @ %otherMap @ "\" is not an object!" );
return;
}
%bind = %otherMap.getBinding( %command );
if ( %bind !$= "" )
%this.bind( getField( %bind, 0 ), getField( %bind, 1 ), "" );
}
//Dev helpers
/// Shortcut for typing dbgSetParameters with the default values torsion uses.
function dbgTorsion()
{
dbgSetParameters( 6060, "password", false );
}
/// Reset the input state to a default of all-keys-up.
/// A helpful remedy for when Torque misses a button up event do to your breakpoints
/// and can't stop shooting / jumping / strafing.
function mvReset()
{
for ( %i = 0; %i < 6; %i++ )
setVariable( "mvTriggerCount" @ %i, 0 );
$mvUpAction = 0;
$mvDownAction = 0;
$mvLeftAction = 0;
$mvRightAction = 0;
// There are others.
}
//Persistance Manager tests
new PersistenceManager(TestPManager);
function runPManTest(%test)
{
if (!isObject(TestPManager))
return;
if (%test $= "")
%test = 100;
switch(%test)
{
case 0:
TestPManager.testFieldUpdates();
case 1:
TestPManager.testObjectRename();
case 2:
TestPManager.testNewObject();
case 3:
TestPManager.testNewGroup();
case 4:
TestPManager.testMoveObject();
case 5:
TestPManager.testObjectRemove();
case 100:
TestPManager.testFieldUpdates();
TestPManager.testObjectRename();
TestPManager.testNewObject();
TestPManager.testNewGroup();
TestPManager.testMoveObject();
TestPManager.testObjectRemove();
}
}
function TestPManager::testFieldUpdates(%doNotSave)
{
// Set some objects as dirty
TestPManager.setDirty(AudioGui);
TestPManager.setDirty(AudioSim);
TestPManager.setDirty(AudioMessage);
// Alter some of the existing fields
AudioEffect.isLooping = true;
AudioMessage.isLooping = true;
AudioEffect.is3D = true;
// Test removing a field
TestPManager.removeField(AudioGui, "isLooping");
// Alter some of the persistent fields
AudioGui.referenceDistance = 0.8;
AudioMessage.referenceDistance = 0.8;
// Add some new dynamic fields
AudioGui.foo = "bar";
AudioEffect.foo = "bar";
// Remove an object from the dirty list
// It shouldn't get updated in the file
TestPManager.removeDirty(AudioEffect);
// Dirty an object in another file as well
TestPManager.setDirty(WarningMaterial);
// Update a field that doesn't exist
WarningMaterial.glow[0] = true;
// Drity another object to test for crashes
// when a dirty object is deleted
TestPManager.setDirty(SFXPausedSet);
// Delete the object
SFXPausedSet.delete();
// Unless %doNotSave is set (by a batch/combo test)
// then go ahead and save now
if (!%doNotSave)
TestPManager.saveDirty();
}
function TestPManager::testObjectRename(%doNotSave)
{
// Flag an object as dirty
if (isObject(AudioGui))
TestPManager.setDirty(AudioGui);
else if (isObject(AudioGuiFoo))
TestPManager.setDirty(AudioGuiFoo);
// Rename it
if (isObject(AudioGui))
AudioGui.setName(AudioGuiFoo);
else if (isObject(AudioGuiFoo))
AudioGuiFoo.setName(AudioGui);
// Unless %doNotSave is set (by a batch/combo test)
// then go ahead and save now
if (!%doNotSave)
TestPManager.saveDirty();
}
function TestPManager::testNewObject(%doNotSave)
{
// Test adding a new named object
new SFXDescription(AudioNew)
{
volume = 0.5;
isLooping = true;
channel = $GuiAudioType;
foo = 2;
};
// Flag it as dirty
TestPManager.setDirty(AudioNew, "core/scripts/client/audio.cs");
// Test adding a new unnamed object
%obj = new SFXDescription()
{
volume = 0.75;
isLooping = true;
bar = 3;
};
// Flag it as dirty
TestPManager.setDirty(%obj, "core/scripts/client/audio.cs");
// Test adding an "empty" object
new SFXDescription(AudioEmpty);
TestPManager.setDirty(AudioEmpty, "core/scripts/client/audio.cs");
// Unless %doNotSave is set (by a batch/combo test)
// then go ahead and save now
if (!%doNotSave)
TestPManager.saveDirty();
}
function TestPManager::testNewGroup(%doNotSave)
{
// Test adding a new named SimGroup
new SimGroup(TestGroup)
{
foo = "bar";
new SFXDescription(TestObject)
{
volume = 0.5;
isLooping = true;
channel = $GuiAudioType;
foo = 1;
};
new SimGroup(SubGroup)
{
foo = 2;
new SFXDescription(SubObject)
{
volume = 0.5;
isLooping = true;
channel = $GuiAudioType;
foo = 3;
};
};
};
// Flag this as dirty
TestPManager.setDirty(TestGroup, "core/scripts/client/audio.cs");
// Test adding a new unnamed SimGroup
%group = new SimGroup()
{
foo = "bar";
new SFXDescription()
{
volume = 0.75;
channel = $GuiAudioType;
foo = 4;
};
new SimGroup()
{
foo = 5;
new SFXDescription()
{
volume = 0.75;
isLooping = true;
channel = $GuiAudioType;
foo = 6;
};
};
};
// Flag this as dirty
TestPManager.setDirty(%group, "core/scripts/client/audio.cs");
// Test adding a new unnamed SimSet
%set = new SimSet()
{
foo = "bar";
new SFXDescription()
{
volume = 0.75;
channel = $GuiAudioType;
foo = 7;
};
new SimGroup()
{
foo = 8;
new SFXDescription()
{
volume = 0.75;
isLooping = true;
channel = $GuiAudioType;
foo = 9;
};
};
};
// Flag this as dirty
TestPManager.setDirty(%set, "core/scripts/client/audio.cs");
// Unless %doNotSave is set (by a batch/combo test)
// then go ahead and save now
if (!%doNotSave)
TestPManager.saveDirty();
}
function TestPManager::testMoveObject(%doNotSave)
{
// First add a couple of groups to the file
new SimGroup(MoveGroup1)
{
foo = "bar";
new SFXDescription(MoveObject1)
{
volume = 0.5;
isLooping = true;
channel = $GuiAudioType;
foo = 1;
};
new SimSet(SubGroup1)
{
new SFXDescription(SubObject1)
{
volume = 0.75;
isLooping = true;
channel = $GuiAudioType;
foo = 2;
};
};
};
// Flag this as dirty
TestPManager.setDirty(MoveGroup1, "core/scripts/client/audio.cs");
new SimGroup(MoveGroup2)
{
foo = "bar";
new SFXDescription(MoveObject2)
{
volume = 0.5;
isLooping = true;
channel = $GuiAudioType;
foo = 3;
};
};
// Flag this as dirty
TestPManager.setDirty(MoveGroup2, "core/scripts/client/audio.cs");
// Unless %doNotSave is set (by a batch/combo test)
// then go ahead and save now
if (!%doNotSave)
TestPManager.saveDirty();
// Set them as dirty again
TestPManager.setDirty(MoveGroup1);
TestPManager.setDirty(MoveGroup2);
// Give the subobject an new value
MoveObject1.foo = 4;
// Move it into the other group
MoveGroup1.add(MoveObject2);
// Switch the other subobject
MoveGroup2.add(MoveObject1);
// Also add a new unnamed object to one of the groups
%obj = new SFXDescription()
{
volume = 0.75;
isLooping = true;
bar = 5;
};
MoveGroup1.add(%obj);
// Unless %doNotSave is set (by a batch/combo test)
// then go ahead and save now
if (!%doNotSave)
TestPManager.saveDirty();
}
function TestPManager::testObjectRemove(%doNotSave)
{
TestPManager.removeObjectFromFile(AudioSim);
}

View file

@ -83,8 +83,14 @@ exec("./gfxData/water.cs");
exec("./gfxData/scatterSky.cs");
exec("./gfxData/clouds.cs");
exec("./screenshot.cs");
// Initialize all core post effects.
exec("./postFx.cs");
//VR stuff
exec("./oculusVROverlay.gui");
exec("./oculusVR.cs");
// Seed the random number generator.
setRandomSeed();

View file

@ -0,0 +1,248 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// Only load these functions if an Oculus VR device is present
if(!isFunction(isOculusVRDeviceActive))
return;
function setupOculusActionMaps()
{
if (isObject(OculusWarningMap))
return;
new ActionMap(OculusWarningMap);
new ActionMap(OculusCanvasMap);
OculusWarningMap.bind(keyboard, space, dismissOculusVRWarnings);
OculusCanvasMap.bind( mouse, xaxis, oculusYaw );
OculusCanvasMap.bind( mouse, yaxis, oculusPitch );
OculusCanvasMap.bind( mouse, button0, oculusClick );
}
function oculusYaw(%val)
{
OculusCanvas.cursorNudge(%val * 0.10, 0);
}
function oculusPitch(%val)
{
OculusCanvas.cursorNudge(0, %val * 0.10);
}
function oculusClick(%active)
{
OculusCanvas.cursorClick(0, %active);
}
function GuiOffscreenCanvas::checkCursor(%this)
{
%count = %this.getCount();
for(%i = 0; %i < %count; %i++)
{
%control = %this.getObject(%i);
if ((%control.noCursor $= "") || !%control.noCursor)
{
%this.cursorOn();
return true;
}
}
// If we get here, every control requested a hidden cursor, so we oblige.
%this.cursorOff();
return false;
}
function GuiOffscreenCanvas::pushDialog(%this, %ctrl, %layer, %center)
{
Parent::pushDialog(%this, %ctrl, %layer, %center);
%cursorVisible = %this.checkCursor();
if (%cursorVisible)
{
echo("OffscreenCanvas visible");
OculusCanvasMap.pop();
OculusCanvasMap.push();
}
else
{
echo("OffscreenCanvas not visible");
OculusCanvasMap.pop();
}
}
function GuiOffscreenCanvas::popDialog(%this, %ctrl)
{
Parent::popDialog(%this, %ctrl);
%cursorVisible = %this.checkCursor();
if (%cursorVisible)
{
echo("OffscreenCanvas visible");
OculusCanvasMap.pop();
OculusCanvasMap.push();
}
else
{
echo("OffscreenCanvas not visible");
OculusCanvasMap.pop();
}
}
//-----------------------------------------------------------------------------
function oculusSensorMetricsCallback()
{
return ovrDumpMetrics(0);
}
//-----------------------------------------------------------------------------
function onOculusStatusUpdate(%status)
{
$LastOculusTrackingState = %status;
}
//-----------------------------------------------------------------------------
// Call this function from createCanvas() to have the Canvas attach itself
// to the Rift's display. The Canvas' window will still open on the primary
// display if that is different from the Rift, but it will move to the Rift
// when it goes full screen. If the Rift is not connected then nothing
// will happen.
function pointCanvasToOculusVRDisplay()
{
$pref::Video::displayOutputDevice = getOVRHMDDisplayDeviceName(0);
}
//-----------------------------------------------------------------------------
// Call this function from GameConnection::initialControlSet() just before
// your "Canvas.setContent(PlayGui);" call, or at any time you wish to switch
// to a side-by-side rendering and the appropriate barrel distortion. This
// will turn on side-by-side rendering and tell the GameConnection to use the
// Rift as its display device.
// Parameters:
// %gameConnection - The client GameConnection instance
// %trueStereoRendering - If true will enable stereo rendering with an eye
// offset for each viewport. This will render each frame twice. If false
// then a pseudo stereo rendering is done with only a single render per frame.
function enableOculusVRDisplay(%gameConnection, %trueStereoRendering)
{
setOVRHMDAsGameConnectionDisplayDevice(%gameConnection);
PlayGui.renderStyle = "stereo side by side";
setOptimalOVRCanvasSize(Canvas);
if (!isObject(OculusCanvas))
{
new GuiOffscreenCanvas(OculusCanvas) {
targetSize = "512 512";
targetName = "oculusCanvas";
dynamicTarget = true;
};
}
if (!isObject(OculusVROverlay))
{
exec("./oculusVROverlay.gui");
}
OculusCanvas.setContent(OculusVROverlay);
OculusCanvas.setCursor(DefaultCursor);
PlayGui.setStereoGui(OculusCanvas);
OculusCanvas.setCursorPos("128 128");
OculusCanvas.cursorOff();
$GameCanvas = OculusCanvas;
%ext = Canvas.getExtent();
$OculusMouseScaleX = 512.0 / 1920.0;
$OculusMouseScaleY = 512.0 / 1060.0;
//$gfx::wireframe = true;
// Reset all sensors
ovrResetAllSensors();
}
// Call this function when ever you wish to turn off the stereo rendering
// and barrel distortion for the Rift.
function disableOculusVRDisplay(%gameConnection)
{
OculusCanvas.popDialog();
OculusWarningMap.pop();
$GameCanvas = Canvas;
if (isObject(gameConnection))
{
%gameConnection.clearDisplayDevice();
}
PlayGui.renderStyle = "standard";
}
// Helper function to set the standard Rift control scheme. You could place
// this function in GameConnection::initialControlSet() at the same time
// you call enableOculusVRDisplay().
function setStandardOculusVRControlScheme(%gameConnection)
{
if($OculusVR::SimulateInput)
{
// We are simulating a HMD so allow the mouse and gamepad to control
// both yaw and pitch.
%gameConnection.setControlSchemeParameters(true, true, true);
}
else
{
// A HMD is connected so have the mouse and gamepad only add to yaw
%gameConnection.setControlSchemeParameters(true, true, false);
}
}
//-----------------------------------------------------------------------------
// Helper function to set the resolution for the Rift.
// Parameters:
// %fullscreen - If true then the display will be forced to full screen. If
// pointCanvasToOculusVRDisplay() was called before the Canvas was created, then
// the full screen display will appear on the Rift.
function setVideoModeForOculusVRDisplay(%fullscreen)
{
%res = getOVRHMDResolution(0);
Canvas.setVideoMode(%res.x, %res.y, %fullscreen, 32, 4);
}
//-----------------------------------------------------------------------------
// Reset all Oculus Rift sensors. This will make the Rift's current heading
// be considered the origin.
function resetOculusVRSensors()
{
ovrResetAllSensors();
}
function dismissOculusVRWarnings(%value)
{
//if (%value)
//{
ovrDismissWarnings();
OculusWarningMap.pop();
//}
}

View file

@ -0,0 +1,19 @@
//--- OBJECT WRITE BEGIN ---
%guiContent = singleton GuiControl(OculusVROverlay) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "1";
Profile = "GuiContentProfile";
HorizSizing = "width";
VertSizing = "height";
Position = "0 0";
Extent = "512 512";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
useVariable = "0";
tile = "0";
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,143 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
// formatImageNumber
// Preceeds a number with zeros to make it 6 digits long.
//---------------------------------------------------------------------------------------------
function formatImageNumber(%number)
{
if(%number < 10)
%number = "0" @ %number;
if(%number < 100)
%number = "0" @ %number;
if(%number < 1000)
%number = "0" @ %number;
if(%number < 10000)
%number = "0" @ %number;
return %number;
}
//---------------------------------------------------------------------------------------------
// formatSessionNumber
// Preceeds a number with zeros to make it 4 digits long.
//---------------------------------------------------------------------------------------------
function formatSessionNumber(%number)
{
if(%number < 10)
%number = "0" @ %number;
if(%number < 100)
%number = "0" @ %number;
return %number;
}
//---------------------------------------------------------------------------------------------
// recordMovie
// Records a movie file from the Canvas content using the specified fps.
// Possible encoder values are "PNG" and "THEORA" (default).
//---------------------------------------------------------------------------------------------
$RecordingMovie = false;
function recordMovie(%movieName, %fps, %encoder)
{
// If the canvas doesn't exist yet, setup a flag so it'll
// start capturing as soon as it's created
if (!isObject(Canvas))
return;
if (%encoder $= "")
%encoder = "THEORA";
%resolution = Canvas.getVideoMode();
// Start the movie recording
ChatHud.AddLine( "\c4Recording movie file to [\c2" @ %movieName @ "\cr].ogv.");
echo("Recording movie to: " @ %movieName);
startVideoCapture(Canvas, %movieName, %encoder, %fps);
$RecordingMovie = true;
}
function stopMovie()
{
// Stop the current recording
ChatHud.AddLine( "\c4Recording movie file finished.");
echo("Stopped movie recording");
stopVideoCapture();
$RecordingMovie = false;
}
/// This is bound in initializeCommon() to take
/// a screenshot on a keypress.
function doScreenShot( %val )
{
// This can be bound, so skip key up events.
if ( %val == 0 )
return;
_screenShot( 1 );
}
/// A counter for screen shots used by _screenShot().
$screenshotNumber = 0;
/// Internal function which generates unique filename
/// and triggers a screenshot capture.
function _screenShot( %tiles, %overlap )
{
if ( $pref::Video::screenShotSession $= "" )
$pref::Video::screenShotSession = 0;
if ( $screenshotNumber == 0 )
$pref::Video::screenShotSession++;
if ( $pref::Video::screenShotSession > 999 )
$pref::Video::screenShotSession = 1;
%name = "screenshot_" @ formatSessionNumber($pref::Video::screenShotSession) @ "-" @
formatImageNumber($screenshotNumber);
%name = expandFileName( %name );
$screenshotNumber++;
if ( ( $pref::Video::screenShotFormat $= "JPEG" ) ||
( $pref::video::screenShotFormat $= "JPG" ) )
screenShot( %name, "JPEG", %tiles, %overlap );
else
screenShot( %name, "PNG", %tiles, %overlap );
}
/// This will close the console and take a large format
/// screenshot by tiling the current backbuffer and save
/// it to the root game folder.
///
/// For instance a tile setting of 4 with a window set to
/// 800x600 will output a 3200x2400 screenshot.
function tiledScreenShot( %tiles, %overlap )
{
// Pop the console off before we take the shot.
Canvas.popDialog( ConsoleDlg );
_screenShot( %tiles, %overlap );
}