TribesReplay/base/scripts/recordings.cs
Robert MacGregor 669c607190 v24834 - skipped v24763 and v24822 due to not being available (09/13/01):
Map Editor
===================================
Several editor crashes have been resolved and this tool should be more stable for the MOD community now.

VCR Mode
===================================
The VCR Mode has been implemented.

F3 starts recording.  F4 stops the current recording.  Multiple recordings can be made from the same mission.

Other controls can be used while playing back a recording. They include:

   -- ESCAPE will stop the playback
   -- TAB will pop up the playback controls window in the upper part of the screen
   -- SPACEBAR will pause/unpause the playback
   -- Numpad + will increase the time step so that the playback accelerates (maximum of 16X speed)
   -- Numpad - will decrease the time step so that the playback slows down (minimum of 1/16X speed)

***If you Alt-Tab to windows to rename a demo file and then return to Tribes instead of using the rename file feature of the demo recorder you will crash after you exit the recorder. It is a windows issue and so we can't fix it.

Satchel Charge Icon Glow
===================================
When the satchel charge is deployed and ready to explode, the icon now glows. The icon disappears completely when the satchel is destroyed (either through activation or destruction). This allows players to more readily keep track of satchel charge status.

"Visibility" option for Server Admins
=====================================
Allows an Advanced Server option to indicate whether the server will use the "Speed" or "Distance" versions of the maps when hosting games. The "Distance" setting will use world versions with much less fog and more visible distance. The "Speed" setting will use the current foggier map settings. These settings will be displayed as a new column on the Master Server List titled "VISIBILITY" and the settings will be "Speed" or "Distance".

NOTE: This visibility change won't be apparent on all maps. A map you can use as a test to show the differences is "Dessicator".

World Skins Default to Main Tribes
==========================================
The missions are now set up so they have default skins other than "Storm" vs. "Inferno". This occurs whenever a player has "Show Individual Skins" toggled OFF. In otherwords, some maps will have "Diamond Skin" vs. "StarWolf", while others will have different combinations. (NOTE: If a player has "Show Individual Skins" toggled ON, then he will see the regular individual skins for players.) New voice samples have been added to allow Victory messages indicate these new team skins. Also note: Bioderms are bioderms, regardless of the team they are on...we're not changing models or voice packages.

Teams now use skins for CTF games relative to the planet - as follows:
Terrain 	Team 1 		Team 2
Ice  		Starwolf 	Blood Eagle
Lush  		Blood Eagle 	Diamond Sword
Badlands 	Starwolf 	Diamond Sword
Desert  	Phoenix 	Blood Eagle
Lava  		Diamond Sword 	Phoenix

If the server admin wishes to specify team skins, set the variable
$host:: useCustomSkins = true;  in serverPrefs.cs

if this variable is set true the skins and names used are
$Host::TeamName1 and $Host::TeamName2  and
$Host::TeamSkin1 and $Host::TeamSkin2  also set in serverPrefs.cs.
These team and skin names are always used for non-CTF games.

NOTE: In "Tournament" mode games, the skins will always default to Storm and Inferno rather than world-specific skins. This is to make it easier for League and Ladder players to assign teams to sides.

Cheat Fixes
===================================
Significant cheat prevention code has been implemented to eliminate known cheats, as well as to make it much more difficult for future cheating of a similar nature to occur.

NOTE: If you have any troubles running a server now, you may have altered or removed something from the build on your server. The code is checking almost everything now (shapes, textures, etc.), so you should ensure that you have all files present from a normal build on your server. (Additional files, like MODs and extra art files won't be a problem...but all original files must be there as well.)

Siege Halftime Improved
===================================
The Siege halftime now gets a screen listing the winning team instead of simply "Switching Sides".

CTF Individual Scoring
===================================
No change was made whatsoever to the team CTF scoring. But the individual scoring now takes into account vehicle kills, more repair/destroy stuff, and makes it nice and robust for statistical tracking later. NOTE: The scores are dramatically inflated compared to previous individual scores so that we had more "granularity" in the system and didn't have to use decimal points. Thus, you will appear to be racking up a huge amount of points, but it's all relative when compared to other players in the game.
Scoring Details
----------------------
Kill: 10 pts
Flag Capture: 30 pts
Flag Grab (if subsequently captured): 20  [A one player grab-and-cap you get both for a total of 50]
Carrier Escort: 3
Sniper Headshot: 1
Turret kill:  manned: 10  automated: 3
Flag Defend: 5
Flag Carrier Kill: 5
Flag Return: 0 - 10 pts [Points are scaled by distance: no points for a short return. 10 pts if the flag carrier gets all the way to the flag. 1 point per 10% (Halfway is 5 pts.)]  15 points if the return breaks a stalemate (both teams have had each others flags for 60 seconds or longer.)
Generator Defend: 5 pts
Object			Destroy				Repair
Generator		10				8
Sensor			4				1
Base Turret		5				4
Inv Station		2				2
Vehicle Station		5				4
Solar Panel		5				4
Sentry Turret		4				2
Deployed sensor		1				0
Deployed inv station	2				0
Deployed turret		3				3
Shrike			5
Bomber			8
Havoc			5
Wildcat			5
Tank			8
MPB			12
*vehicles destroyed by mines are double points, vehicles destroyed by the Shrike are triple points
**vehicles destroyed also score 2 points per passenger (after any multiplier)
***points accumulated in a vehicle are earned by everyone in the vehicle

Heat Lock vs. Target Laser Lock
===================================
Heat Locking now supercedes Targeting Laser Locking so that heat locks can be attained on objects that are being lazed by friends. Keep in mind that when the target is out of range for the ML, it will still lock onto the targeting laser giving the appearance that its locking onto the laser first. If the target is in range the ML will always look for heated targets first.

Objective HUD Visible on Vehicles
===================================
The objective HUD is now visible while flying/driving vehicles.

Client-Side Toggle on Vehicle Tport
===================================
The player now has the ability to toggle Vehicle Tport ability on/off (defaults to ON) as a client-side option in SETTINGS/GAME.

EAX Sound Improvements
===================================
EAX environmental sound reverbs have been included for underwater and interiors. Those sounds will only be heard when using EAX or EAX2 drivers. (We recommend EAX for best results.)

IFeel Force Feedback Mouse
===================================
The IFeel force feedback mouse vibrations should now work correctly again. They have also been enhanced beyond what was previously available.

Vehicles Parking on Flags
===================================
"Anti-Parking" code has been added to flags similar to the "anti-camping" code around a Nexus in Hunters. This results in vehicles taking damage over time when they are parked near a flag, eventually resulting in their destruction if left there too long.

Aiming Up and Down
===================================
The restrictions on aiming up and down have been virtually removed for all armors. NOTE: This will result in situations where your weapon can clip through the leg of your armor when looking straight down. If this bothers you, then change your graphics setting to "Items Only" so that your body is not drawn when in first-person perspective.

Jetpower for Suits
===================================
Scout jetpower (power of thrust) was reduced to previous levels, but their maximum speed velocity was increased somewhat. This removes the "butterfly" effect, but allows slightly faster skiing than previously allowed. Additionally, air resistance was reduced by 33% on all armors to further reduce the "floaty" feel. This also allows slightly faster speeds across the board.

Splash Damage
===================================
Splash damage on shots was reduced slightly. It is still much more powerful than when the game was released, but this change makes mortars and grenades more playable.

Shrike Speed
===================================
The Shrike thrust was returned to normal, making the Shrike very responsive again. A new maximum speed cap has been added to prevent it from going too fast, but the performance improvement on this vehicle is significant.

Mine Damage
===================================
Mine damage was reduced slightly to prevent Lights from being one-shotted by stepping on a mine. They will still be severely harmed, but won't go from 100% health to dead in one shot.

Missile Launcher
===================================
The Missile Launcher range had been inadvertently reduced during the reticule improvements a few patches back. It has now been increased back to its original design. Range is now 400m.

Heat Signature Fall Off
===================================
Heat reduces *very slightly* slower than it did previously. Players can still easily manage their heat signatures, but must be a bit more paranoid of missile launchers now (thus making it a bit easier for high-ping players to use this weapon).

Suit Mortars vs. Tanks
===================================
The strength of hand-held mortars versus Tanks was incorrectly weak. It has now been increased so that it is much more useful.

Shrike Gun Changes
===================================
The Shrike blasters have been moved out to the wing joints to allow easier strafing of objects. Additionally, there is some (very minor...one degree of spread) projectile spread on the blasters now to make strafing easier. (For comparison purposes, the chaingun has eight degrees of spread.)The range of the blasters was incorrectly enormous and has been reduced to a balanced distance (slightly outside the range of hand-held missile launchers).

Water Movement
===================================
Speeds in water have been greatly increased so as to make water a more viable playing environment.

Whiteout Grenades
===================================
A maximum saturation has been defined for the Whiteout grenades to keep your "whiteout" time to no more than two seconds.

OOB Grid
===================================
The mission boundary is now visually defined. As you approach a mission boundary, and "out of bounds grid" will fade into existence. If you go past the boundary, the grid will not fade out until you return inside the mission area. This is done to make it easier to avoid getting a flag stripped or getting damaged due to OOB damage. This visual option can be toggled OFF in your Game Settings area (option button is called "Show Out of Bounds Grid").

Wildcat Grav Bike
===================================
"Suspension" has been added to the Wildcat making it easier to control over rough terrain.

Air Drag
===================================
Air Drag has been reduced making the game feel "faster".

Panther XL Support Added
===================================
Players will now be able to satisfactorily map the roller ball of the Panther XL. The Z axis or throttle is not configurable with T2 because of a Panther XL driver issue.

Flight Ceiling limited for Shrike
===================================
If you fly past the flight ceiling then you will lose your jetting and thrusting ability. Angle your nose down (when you are above the flight ceiling) and thrust will function normally.

"Unassigned" Team
===================================
This bug allowed a person to join as "unassigned" and view all friend/foe triangles as grey. It has been fixed.

<Null> and random string issues
===================================
There is a finite number of network strings available, the single quote strings. This problem occurs when all strings have been allocated. This is particularly common with mod servers, which appear to be allocating too many net strings. Mod and script developers need to be cautious when creating new strings. Don't create dynamic net strings unless you have a firm understanding of the implications. If a string is added using "AddTaggedString" make sure that there is a corresponding "RemoveTaggedSting" call when the string is no longer needed. Also be sure to limit the number of imbedded strings in your scripts.
2017-07-17 23:27:34 -04:00

735 lines
21 KiB
C#

function RecordingsDlg::onWake(%gui)
{
%gui.fillRecordingsList();
updateRecordingButtons();
}
function msToMinSec(%time)
{
%sec = mFloor(%time / 1000);
%min = mFloor(%sec / 60);
%sec -= %min * 60;
// pad it
if(%min < 10)
%min = "0" @ %min;
if(%sec < 10)
%sec = "0" @ %sec;
return(%min @ ":" @ %sec);
}
function RecordingsDlg::fillRecordingsList(%gui)
{
// setup the ctrl
if(!%gui.initialized)
{
RecordingsDlgList.setSortColumn(0);
RecordingsDlgList.setSortIncreasing(true);
RecordingsDlgList.addStyle(1, $ShellFont, $ShellFontSize, "80 220 200", "30 255 225", "10 60 40" );
RecordingsDlgList.addStyle(2, $ShellFont, $ShellFontSize, "120 120 120", "120 120 120", "120 120 120" );
// add the columns
RecordingsDlgList.addColumn(0, "Recording", 200, 100, 300);
RecordingsDlgList.addColumn(1, "Time", 140, 60, 180, "filetime center");
RecordingsDlgList.addColumn(2, "Length (min:sec)", 40, 40, 80, "center");
%gui.initialized = true;
}
RecordingsDlgList.clear();
RecordingsDlgList.clearList();
// process all the recordings
%search = "recordings/*.rec";
%ct = 0;
%demoVersion = getDemoVersion();
for(%file = findFirstFile(%search); %file !$= ""; %file = findNextFile(%search))
{
%fileName = fileBase(%file);
// query the version/length of the recording
%val = getDemoVersionLength(%file);
%version = getField(%val, 0);
// unknown version
if(%version == -1)
{
%version = "???";
%length = "???";
}
else
%length = msToMinSec(getField(%val, 1));
%fileTime = getFileModifyTime(%file);
RecordingsDlgList.addRow(%ct, %fileName TAB %fileTime TAB %length);
RecordingsDlgList.setRowStyle(%ct, (%version == %demoVersion) ? 1 : 2);
%ct++;
}
RecordingsDlgList.sort(0, true);
RecordingsDlgList.setSelectedRow(0);
}
function updateRecordingButtons()
{
%active = RecordingsDlgList.rowCount() != 0;
PR_StartDemoBtn.setActive(%active);
PR_DeleteDemoBtn.setActive(%active);
PR_RenameDemoBtn.setActive(%active);
if(%active)
PR_StartDemoBtn.makeFirstResponder(1);
else
PR_CancelBtn.makeFirstResponder(1);
}
//-------------------------------------------------------------------------
// functions to handle the progress bar for loading demo
function DemoLoadProgressDlg::onWake(%this)
{
DemoLoadProgressCtrl.setValue(0.0);
}
function demoUpdateDatablockProgress(%count, %total)
{
DemoLoadProgressCtrl.setValue(%count / %total);
}
//-------------------------------------------------------------------------
// sequential variables named $DemoValue[?] will be stored in the demo stream
// and accessable right after the demo has been loaded
function saveDemoSettings()
{
$DemoValueIdx = 0;
getState(MISC);
// store the playergroup
getState(PLAYERLIST);
// get the states for all the gui's of interest
getState(RETICLE);
getState(BACKPACK);
getState(WEAPON);
getState(INVENTORY);
getState(SCORE);
getState(CLOCK);
getState(CHAT);
}
function resetGameState()
{
$timeScale = 1;
// reset some state
HudMessageVector.clear();
if(isObject(PlayerListGroup))
PlayerListGroup.delete();
// stop all sound
alxStopAll();
// clean up voting
voteHud.voting = false;
mainVoteHud.setvisible(0);
// clear all print messages
clientCmdclearBottomPrint();
clientCmdClearCenterPrint();
clientCmdResetCommandMap();
// clear the inventory and weapons hud
weaponsHud.reset();
inventoryHud.reset();
// reset the objective hud
objectiveHud.setSeparators("");
objectiveHud.disableHorzSeparator();
while(objectiveHud.getCount() > 0)
objectiveHud.getObject(0).delete();
}
function loadDemoSettings()
{
$DemoValueIdx = 0;
setState(MISC);
// restore the playergroup
setState(PLAYERLIST);
// set the states for all the gui's of interest
setState(RETICLE);
setState(BACKPACK);
setState(WEAPON);
setState(INVENTORY);
setState(SCORE);
setState(CLOCK);
setState(CHAT);
}
function addDemoValue(%val)
{
// make sure variables get saved
if(%val $= "")
%val = "<BLANK>";
$DemoValue[$DemoValueIdx] = %val;
$DemoValueIdx++;
}
function getDemoValue()
{
%val = $DemoValue[$DemoValueIdx];
$DemoValueIdx++;
if(%val $= "<BLANK>")
%val = "";
return(%val);
}
//-------------------------------------------------------------------------
// get/setState
// - strings max of 255 chars
function getState(%type)
{
switch$(%type)
{
case MISC:
addDemoValue( $HudMode TAB $HudModeType TAB $HudModeNode TAB voteHud.voting TAB isObject(passengerKeys) TAB musicPlayer.currentTrack );
case PLAYERLIST:
%count = PlayerListGroup.getCount();
addDemoValue(%count);
for(%i = 0; %i < %count; %i++)
{
%obj = PlayerListGroup.getObject(%i);
addDemoValue( %obj.name TAB
%obj.guid TAB
%obj.clientId TAB
%obj.targetId TAB
%obj.teamId TAB
%obj.score TAB
%obj.ping TAB
%obj.packetLoss TAB
%obj.chatMuted TAB
%obj.canListen TAB
%obj.voiceEnabled TAB
%obj.isListening TAB
%obj.isBot TAB
%obj.isAdmin TAB
%obj.isSuperAdmin TAB
%obj.isSmurf );
}
case RETICLE:
addDemoValue( reticleHud.bitmap TAB
reticleHud.isVisible() TAB
retCenterHud.isVisible() TAB
ammoHud.isVisible() TAB
ammoHud.getValue() TAB
deploySensor.isVisible() TAB
reticleFrameHud.isVisible() );
case BACKPACK:
addDemoValue( backpackIcon.bitmap TAB backpackFrame.isVisible() TAB backpackText.getValue() TAB backpackText.isVisible TAB backpackFrame.pack );
case WEAPON:
%count = weaponsHud.getNumItems();
%slotCount = weaponsHud.getNumSlots();
%active = weaponsHud.getActiveItem();
// visible/bitmaps(3)/count/slotcount/active
addDemoValue( weaponsHud.isVisible() TAB weaponsHud.getBackgroundBitmap() TAB weaponsHud.getHighLightBitmap() TAB weaponsHud.getInfiniteBitmap() TAB %count TAB %slotCount TAB %active );
// images
for(%i = 0; %i < %count; %i++)
addDemoValue( $WeaponNames[%i] TAB weaponsHud.getItemBitmap(%i) );
// items
for(%i = 0; %i < %slotCount; %i++)
addDemoValue( weaponsHud.getSlotId(%i) TAB weaponsHud.getSlotCount(%i) );
case INVENTORY:
// count/active
%count = inventoryHud.getNumItems();
%slotCount = inventoryHud.getNumSlots();
%active = inventoryHud.getActiveItem();
// visible/bitmaps(3)/count/slotCount/active
addDemoValue( inventoryHud.isVisible() TAB inventoryHud.getBackgroundBitmap() TAB inventoryHud.getHighLightBitmap() TAB inventoryHud.getInfiniteBitmap() TAB %count TAB %slotCount TAB %active );
// images
for(%i = 0; %i < %count; %i++)
addDemoValue( inventoryHud.getItemBitmap(%i) );
// items
for(%i = 0; %i < %slotCount; %i++)
addDemoValue( inventoryHud.getSlotId(%i) TAB inventoryHud.getSlotCount(%i) );
case SCORE:
%objCount = objectiveHud.getCount();
// visible/gametype/numobjects
addDemoValue( objectiveHud.isVisible() TAB objectiveHud.gameType TAB %objCount );
// only text ctrls exist in this thing.. so just dump the strings
for(%i = 0; %i < %objCount; %i++)
addDemoValue(objectiveHud.getObject(%i).getValue());
case CLOCK:
addDemoValue( clockHud.isVisible() TAB clockHud.getTime() );
case CHAT:
// store last 10 messages
%numLines = HudMessageVector.getNumLines();
for(%i = (%numLines - 10); %i < %numLines; %i++)
{
if(%i < 0)
addDemoValue("");
else
addDemoValue(HudMessageVector.getLineText(%i));
}
}
}
function setState(%type)
{
switch$(%type)
{
case MISC:
%val = getDemoValue();
$HudMode = getField(%val, 0);
$HudModeType = getField(%val, 1);
$HudModeNode = getField(%val, 2);
voteHud.voting = getField(%val, 3);
clientCmdSetDefaultVehicleKeys(getField(%val, 4));
clientCmdPlayMusic(getField(%val, 5));
ClientCmdDisplayHuds();
case PLAYERLIST:
new SimGroup("PlayerListGroup");
%count = getDemoValue();
for(%i = 0; %i < %count; %i++)
{
%val = getDemoValue();
%player = new ScriptObject()
{
className = "PlayerRep";
name = getField(%val, 0);
guid = getField(%val, 1);
clientId = getField(%val, 2);
targetId = getField(%val, 3);
teamId = getField(%val, 4);
score = getField(%val, 5);
ping = getField(%val, 6);
packetLoss = getField(%val, 7);
chatMuted = getField(%val, 8);
canListen = getField(%val, 9);
voiceEnabled = getField(%val, 10);
isListening = getField(%val, 11);
isBot = getField(%val, 12);
isAdmin = getField(%val, 13);
isSuperAdmin = getField(%val, 14);
isSmurf = getField(%val, 15);
};
PlayerListGroup.add(%player);
$PlayerList[%player.clientId] = %player;
lobbyUpdatePlayer(%player.clientId);
}
case RETICLE:
%val = getDemoValue();
reticleHud.setBitmap(getField(%val, 0));
reticleHud.setVisible(getField(%val, 1));
retCenterHud.setVisible(getField(%val, 2));
ammoHud.setVisible(getField(%val, 3));
ammoHud.setValue(getField(%val, 4));
deploySensor.setVisible(getField(%val, 5));
reticleFrameHud.setVisible(getField(%val, 6));
case BACKPACK:
%val = getDemoValue();
backpackIcon.setBitmap(getField(%val, 0));
backpackFrame.setVisible(getField(%val, 1));
backpackText.setValue(getField(%val, 2));
backpackText.setVisible(getField(%val, 3));
backpackFrame.pack = getField(%val, 4);
case WEAPON:
%val = getDemoValue();
// visible
weaponsHud.reset();
weaponsHud.setVisible(getField(%val, 0));
// bitmaps
weaponsHud.setBackgroundBitmap(getField(%val, 1));
weaponsHud.setHighLightBitmap(getField(%val, 2));
weaponsHud.setInfiniteAmmoBitmap(getField(%val, 3));
// count/slotCount/active
%count = getField(%val, 4);
%slotCount = getField(%val, 5);
%active = getField(%val, 6);
// bitmaps
for(%i = 0; %i < %count; %i++)
{
%val = getDemoValue();
$WeaponNames[%i] = getField(%val, 0);
weaponsHud.setWeaponBitmap(%i, getField(%val, 1));
}
// items
for(%i = 0; %i < %slotCount; %i++)
{
%val = getDemoValue();
weaponsHud.addWeapon(getField(%val, 0), getField(%val, 1));
}
// active
weaponsHud.setActiveWeapon(%active);
case INVENTORY:
%val = getDemoValue();
// visible
inventoryHud.reset();
inventoryHud.setVisible(getField(%val, 0));
// bitmaps
inventoryHud.setBackgroundBitmap(getField(%val, 1));
inventoryHud.setHighLightBitmap(getField(%val, 2));
inventoryHud.setInfiniteAmountBitmap(getField(%val, 3));
// count/slotCount/active
%count = getField(%val, 4);
%slotCount = getField(%val, 5);
%active = getField(%val, 6);
// images
for(%i = 0; %i < %count; %i++)
{
%val = getDemoValue();
inventoryHud.setInventoryBitmap(%i, %val);
}
// items
for(%i = 0; %i < %slotCount; %i++)
{
%val = getDemoValue();
inventoryHud.addInventory(getField(%val, 0), getField(%val, 1));
}
// active
inventoryHud.setActiveInventory(%active);
case SCORE:
%val = getDemoValue();
objectiveHud.setVisible(getField(%val, 0));
setupObjHud(getField(%val, 1));
%objCount = getField(%val, 2);
// must read in all values even if not used
for(%i = 0; %i < %objCount; %i++)
{
%val = getDemoValue();
if(%i < objectiveHud.getCount())
objectiveHud.getObject(%i).setValue(%val);
}
case CLOCK:
%val = getDemoValue();
clockHud.setVisible(getField(%val, 0));
clockHud.setTime(getField(%val, 1));
case CHAT:
HudMessageVector.clear();
for(%i = 0; %i < 10; %i++)
{
%val = getDemoValue();
if(%val !$= "")
HudMessageVector.pushBackLine(%val);
}
}
}
//-------------------------------------------------------------------------
function doRecordingDelete(%file)
{
// delete it
if(deleteFile("recordings/" @ %file @ ".rec"))
{
%sel = RecordingsDlgList.getSelectedId();
RecordingsDlgList.removeRowById(%sel);
RecordingsDlgList.setSelectedRow(0);
updateRecordingButtons();
}
else
messageBoxOK("Failed", "Failed to remove file '" @ %file @ "'.");
}
function DeleteSelectedDemo()
{
%sel = RecordingsDlgList.getSelectedId();
%file = getField(RecordingsDlgList.getRowTextById(%sel), 0);
messageBoxOkCancel("Delete Recording?", "Are you sure you wish to delete recording file '" @ %file @ "'?", "doRecordingDelete(\"" @ %file @ "\");");
}
function StartSelectedDemo()
{
// first unit is filename
%sel = RecordingsDlgList.getSelectedId();
%rowText = RecordingsDlgList.getRowTextById(%sel);
%file = "recordings/" @ getField(%rowText, 0) @ ".rec";
%verLen = getDemoVersionLength(%file);
Canvas.pushDialog(DemoLoadProgressDlg);
if(playDemo(%file))
{
// do not allow new sources to have a force feedback effect
alxEnableForceFeedback(false);
resetGameState();
Canvas.popDialog(DemoLoadProgressDlg);
Canvas.popDialog(RecordingsDlg);
Canvas.setContent(PlayGui);
loadDemoSettings();
$DemoPlaybackIndex = 5;
$DemoPlaybackLastIndex = 5;
// setup the global action map
GlobalActionMap.bindCmd(keyboard, "escape", "", "stopDemoPlayback();");
GlobalActionMap.bindCmd(keyboard, "tab", "", "toggleDemoPlaybackHud();");
GlobalActionMap.bindCmd(keyboard, "space", "", "toggleDemoPause();");
GlobalActionMap.bindCmd(keyboard, "numpadadd", "", "stepDemoPlaybackSpeed(1);");
GlobalActionMap.bindCmd(keyboard, "numpadminus", "", "stepDemoPlaybackSpeed(-1);");
$globalActionMapOnly = true;
$DemoPlaybackProgress = 0;
$DemoPlaybackLength = getField(%verLen, 1);
// playback length may be 0 if recording was not clean (just set to 1min)
if($DemoPlaybackLength == 0)
$DemoPlaybackLength = 60000;
DemoPlayback_EndTime.setValue(msToMinSec($DemoPlaybackLength));
$DemoPlaybackIndex = 5;
$DemoPlaybackLastIndex = 5;
$DemoPlaybackProgress = 0;
demoPlaybackUpdate(0);
updateDemoPlaybackStatus();
}
else
MessageBoxOK("Playback Failed", "Demo playback failed for file '" @ %file @ "'.");
Canvas.popDialog(DemoLoadProgressDlg);
}
function demoPlaybackComplete()
{
alxStopAll();
// allow new sources to have a force feedback effect
alxEnableForceFeedback(true);
// remove the playback dialog
if(DemoPlaybackDlg.isAwake())
Canvas.popDialog(DemoPlaybackDlg);
Canvas.setContent("LaunchGui");
Canvas.pushDialog(RecordingsDlg);
// cleanup
resetGameState();
purgeResources();
// clean the globalActionMap
GlobalActionMap.unbind(keyboard, escape);
GlobalActionMap.unbind(keyboard, tab);
GlobalActionMap.unbind(keyboard, space);
GlobalActionMap.unbind(keyboard, numpadadd);
GlobalActionMap.unbind(keyboard, numpadminus);
$globalActionMapOnly = false;
}
//-------------------------------------------------------------------------
function doDemoFileRename()
{
// first unit is filename
%sel = RecordingsDlgList.getSelectedId();
%file = getField(RecordingsDlgList.getRowTextById(%sel), 0);
%newFile = DemoRenameFile_Edit.getValue();
if(%file $= %newFile)
return;
if(%newFile !$= "")
{
if(renameFile("recordings/" @ %file @ ".rec", "recordings/" @ %newFile @ ".rec"))
{
rebuildModPaths();
RecordingsDlg.fillRecordingsList();
return;
}
}
MessageBoxOK("Rename Failed", "Failed to rename file '" @ %file @ "' to '" @ %newFile @ "'.");
}
function RenameSelectedDemo()
{
// first unit is filename
%sel = RecordingsDlgList.getSelectedId();
%file = getField(RecordingsDlgList.getRowTextById(%sel), 0);
DemoRenameFile_Edit.setValue(%file);
Canvas.pushDialog(DemoRenameFileDlg);
}
//--------------------------------------------------------------------------
function beginDemoRecord()
{
if(isDemo())
return;
// make sure that current recording stream is stopped
stopDemoRecord();
for(%i = 0; %i < 1000; %i++)
{
%num = %i;
if(%num < 10)
%num = "0" @ %num;
if(%num < 100)
%num = "0" @ %num;
%file = "recordings/demo" @ %num @ ".rec";
if(!isfile(%file))
break;
}
if(%i == 1000)
return;
$DemoFile = %file;
addMessageHudLine( "\c4Recording to file [\c2" @ $DemoFile @ "\cr].");
saveDemoSettings();
startRecord(%file);
// make sure start worked
if(!isRecordingDemo())
{
deleteFile("recordings/" @ $DemoFile @ ".rec");
addMessageHudLine( "\c3 *** Failed to record to file [\c2" @ $DemoFile @ "\cr].");
$DemoFile = "";
}
}
function stopDemoRecord()
{
if(isDemo())
return;
// make sure we are recording (and have a valid file)
if(isRecordingDemo())
stopRecord();
}
function demoRecordComplete()
{
// tell the user
if($DemoFile !$= "")
{
addMessageHudLine( "\c4Stopped recording to file [\c2" @ $DemoFile @ "\cr].");
$DemoFile = "";
}
}
//-------------------------------------------------------------------------
function toggleDemoPlaybackHud()
{
if(DemoPlaybackDlg.isAwake())
Canvas.popDialog(DemoPlaybackDlg);
else
Canvas.pushDialog(DemoPlaybackDlg, 99);
}
$DemoPlaybackText[0] = "Paused"; $DemoPlaybackSpeed[0] = 0;
$DemoPlaybackText[1] = "Play 1/16X"; $DemoPlaybackSpeed[1] = 0.0625;
$DemoPlaybackText[2] = "Play 1/8X"; $DemoPlaybackSpeed[2] = 0.125;
$DemoPlaybackText[3] = "Play 1/4X"; $DemoPlaybackSpeed[3] = 0.25;
$DemoPlaybackText[4] = "Play 1/2X"; $DemoPlaybackSpeed[4] = 0.5;
$DemoPlaybackText[5] = "Play 1X"; $DemoPlaybackSpeed[5] = 1;
$DemoPlaybackText[6] = "Play 2X"; $DemoPlaybackSpeed[6] = 2;
$DemoPlaybackText[7] = "Play 4X"; $DemoPlaybackSpeed[7] = 4;
$DemoPlaybackText[8] = "Play 8X"; $DemoPlaybackSpeed[8] = 8;
$DemoPlaybackText[9] = "Play 16X"; $DemoPlaybackSpeed[9] = 16;
// called after each processTime
function demoPlaybackUpdate(%curTime)
{
DemoPlayback_CurTime.setValue(msToMinSec(%curTime));
$DemoPlaybackProgress = %curTime / $DemoPlaybackLength;
}
function updateDemoPlaybackStatus()
{
// clamp the speed
if($DemoPlaybackIndex < 0)
$DemoPlaybackIndex = 0;
if($DemoPlaybackIndex > 9)
$DemoPlaybackIndex = 9;
DemoPlayback_StatusText.setValue($DemoPlaybackText[$DemoPlaybackIndex]);
$timeScale = $DemoPlaybackSpeed[$DemoPlaybackIndex];
}
function toggleDemoPause()
{
// save the current index for unpause
if($DemoPlaybackIndex == 0)
$DemoPlaybackIndex = $DemoPlaybackLastIndex;
else
{
$DemoPlaybackLastIndex = $DemoPlaybackIndex;
$DemoPlaybackIndex = 0;
}
updateDemoPlaybackStatus();
}
function stepDemoPlaybackSpeed(%step)
{
$DemoPlaybackIndex += %step;
updateDemoPlaybackStatus();
}
function DemoPlaybackDlg::onWake(%this)
{
updateDemoPlaybackStatus();
}