mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-09 07:20:40 +00:00
Initial implementation of the new Base Game Template and some starting modules.
This makes some tweaks to the engine to support this, specifically, it tweaks the hardcoded shaderpaths to defer to a pref variable, so none of the shader paths are hardcoded. Also tweaks how post effects read in texture files, removing a bizzare filepath interpretation choice, where if the file path didn't start with "/" it forcefully appended the script's file path. This made it impossible to have images not in the same dir as the script file defining the post effect. This was changed and the existing template's post effects tweaked for now to just add "./" to those few paths impacted, as well as the perf vars to support the non-hardcoded shader paths in the engine.
This commit is contained in:
parent
5c8a82180b
commit
d680dc9934
2321 changed files with 296541 additions and 85 deletions
323
Templates/Modules/FPSGameplay/scripts/client/chatHud.cs
Normal file
323
Templates/Modules/FPSGameplay/scripts/client/chatHud.cs
Normal file
|
|
@ -0,0 +1,323 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Message Hud
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// chat hud sizes in lines
|
||||
$outerChatLenY[1] = 4;
|
||||
$outerChatLenY[2] = 9;
|
||||
$outerChatLenY[3] = 13;
|
||||
|
||||
// Only play sound files that are <= 5000ms in length.
|
||||
$MaxMessageWavLength = 5000;
|
||||
|
||||
// Helper function to play a sound file if the message indicates.
|
||||
// Returns starting position of wave file indicator.
|
||||
function playMessageSound(%message, %voice, %pitch)
|
||||
{
|
||||
// Search for wav tag marker.
|
||||
%wavStart = strstr(%message, "~w");
|
||||
if (%wavStart == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
%wav = getSubStr(%message, %wavStart + 2, 1000);
|
||||
|
||||
if (%voice !$= "")
|
||||
{
|
||||
%wavFile = "data/FPSGameplay/sound/voice/" @ %voice @ "/" @ %wav;
|
||||
}
|
||||
else
|
||||
%wavFile = "data/FPSGameplay/sound/" @ %wav;
|
||||
|
||||
if (strstr(%wavFile, ".wav") != (strlen(%wavFile) - 4))
|
||||
%wavFile = %wavFile @ ".wav";
|
||||
|
||||
// XXX This only expands to a single filepath, of course; it
|
||||
// would be nice to support checking in each mod path if we
|
||||
// have multiple mods active.
|
||||
%wavFile = ExpandFilename(%wavFile);
|
||||
|
||||
%wavSource = sfxCreateSource(AudioMessage, %wavFile);
|
||||
|
||||
if (isObject(%wavSource))
|
||||
{
|
||||
%wavLengthMS = %wavSource.getDuration() * %pitch;
|
||||
|
||||
if (%wavLengthMS == 0)
|
||||
error("** WAV file \"" @ %wavFile @ "\" is nonexistent or sound is zero-length **");
|
||||
else if (%wavLengthMS <= $MaxMessageWavLength)
|
||||
{
|
||||
if (isObject($ClientChatHandle[%sender]))
|
||||
$ClientChatHandle[%sender].delete();
|
||||
|
||||
$ClientChatHandle[%sender] = %wavSource;
|
||||
|
||||
if (%pitch != 1.0)
|
||||
$ClientChatHandle[%sender].setPitch(%pitch);
|
||||
|
||||
$ClientChatHandle[%sender].play();
|
||||
}
|
||||
else
|
||||
error("** WAV file \"" @ %wavFile @ "\" is too long **");
|
||||
}
|
||||
else
|
||||
error("** Unable to load WAV file : \"" @ %wavFile @ "\" **");
|
||||
|
||||
return %wavStart;
|
||||
}
|
||||
|
||||
|
||||
// All messages are stored in this HudMessageVector, the actual
|
||||
// MainChatHud only displays the contents of this vector.
|
||||
|
||||
new MessageVector(HudMessageVector);
|
||||
$LastHudTarget = 0;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
function onChatMessage(%message, %voice, %pitch)
|
||||
{
|
||||
// XXX Client objects on the server must have voiceTag and voicePitch
|
||||
// fields for values to be passed in for %voice and %pitch... in
|
||||
// this example mod, they don't have those fields.
|
||||
|
||||
// Clients are not allowed to trigger general game sounds with their
|
||||
// chat messages... a voice directory MUST be specified.
|
||||
if (%voice $= "") {
|
||||
%voice = "default";
|
||||
}
|
||||
|
||||
// See if there's a sound at the end of the message, and play it.
|
||||
if ((%wavStart = playMessageSound(%message, %voice, %pitch)) != -1) {
|
||||
// Remove the sound marker from the end of the message.
|
||||
%message = getSubStr(%message, 0, %wavStart);
|
||||
}
|
||||
|
||||
// Chat goes to the chat HUD.
|
||||
if (getWordCount(%message)) {
|
||||
ChatHud.addLine(%message);
|
||||
}
|
||||
}
|
||||
|
||||
function onServerMessage(%message)
|
||||
{
|
||||
// See if there's a sound at the end of the message, and play it.
|
||||
if ((%wavStart = playMessageSound(%message)) != -1) {
|
||||
// Remove the sound marker from the end of the message.
|
||||
%message = getSubStr(%message, 0, %wavStart);
|
||||
}
|
||||
|
||||
// Server messages go to the chat HUD too.
|
||||
if (getWordCount(%message)) {
|
||||
ChatHud.addLine(%message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MainChatHud methods
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function MainChatHud::onWake( %this )
|
||||
{
|
||||
// set the chat hud to the users pref
|
||||
%this.setChatHudLength( $Pref::ChatHudLength );
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function MainChatHud::setChatHudLength( %this, %length )
|
||||
{
|
||||
%textHeight = ChatHud.Profile.fontSize + ChatHud.lineSpacing;
|
||||
if (%textHeight <= 0)
|
||||
%textHeight = 12;
|
||||
%lengthInPixels = $outerChatLenY[%length] * %textHeight;
|
||||
%chatMargin = getWord(OuterChatHud.extent, 1) - getWord(ChatScrollHud.Extent, 1)
|
||||
+ 2 * ChatScrollHud.profile.borderThickness;
|
||||
OuterChatHud.setExtent(firstWord(OuterChatHud.extent), %lengthInPixels + %chatMargin);
|
||||
ChatScrollHud.scrollToBottom();
|
||||
ChatPageDown.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function MainChatHud::nextChatHudLen( %this )
|
||||
{
|
||||
%len = $pref::ChatHudLength++;
|
||||
if ($pref::ChatHudLength == 4)
|
||||
$pref::ChatHudLength = 1;
|
||||
%this.setChatHudLength($pref::ChatHudLength);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ChatHud methods
|
||||
// This is the actual message vector/text control which is part of
|
||||
// the MainChatHud dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function ChatHud::addLine(%this,%text)
|
||||
{
|
||||
//first, see if we're "scrolled up"...
|
||||
%textHeight = %this.profile.fontSize + %this.lineSpacing;
|
||||
if (%textHeight <= 0)
|
||||
%textHeight = 12;
|
||||
|
||||
%scrollBox = %this.getGroup();
|
||||
%chatScrollHeight = getWord(%scrollBox.extent, 1) - 2 * %scrollBox.profile.borderThickness;
|
||||
%chatPosition = getWord(%this.extent, 1) - %chatScrollHeight + getWord(%this.position, 1) - %scrollBox.profile.borderThickness;
|
||||
%linesToScroll = mFloor((%chatPosition / %textHeight) + 0.5);
|
||||
if (%linesToScroll > 0)
|
||||
%origPosition = %this.position;
|
||||
|
||||
//remove old messages from the top only if scrolled down all the way
|
||||
while( !chatPageDown.isVisible() && HudMessageVector.getNumLines() && (HudMessageVector.getNumLines() >= $pref::HudMessageLogSize))
|
||||
{
|
||||
%tag = HudMessageVector.getLineTag(0);
|
||||
if(%tag != 0)
|
||||
%tag.delete();
|
||||
HudMessageVector.popFrontLine();
|
||||
}
|
||||
|
||||
//add the message...
|
||||
HudMessageVector.pushBackLine(%text, $LastHudTarget);
|
||||
$LastHudTarget = 0;
|
||||
|
||||
//now that we've added the message, see if we need to reset the position
|
||||
if (%linesToScroll > 0)
|
||||
{
|
||||
chatPageDown.setVisible(true);
|
||||
%this.position = %origPosition;
|
||||
}
|
||||
else
|
||||
chatPageDown.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function ChatHud::pageUp(%this)
|
||||
{
|
||||
// Find out the text line height
|
||||
%textHeight = %this.profile.fontSize + %this.lineSpacing;
|
||||
if (%textHeight <= 0)
|
||||
%textHeight = 12;
|
||||
|
||||
%scrollBox = %this.getGroup();
|
||||
|
||||
// Find out how many lines per page are visible
|
||||
%chatScrollHeight = getWord(%scrollBox.extent, 1) - 2 * %scrollBox.profile.borderThickness;
|
||||
if (%chatScrollHeight <= 0)
|
||||
return;
|
||||
|
||||
%pageLines = mFloor(%chatScrollHeight / %textHeight) - 1; // have a 1 line overlap on pages
|
||||
if (%pageLines <= 0)
|
||||
%pageLines = 1;
|
||||
|
||||
// See how many lines we actually can scroll up:
|
||||
%chatPosition = -1 * (getWord(%this.position, 1) - %scrollBox.profile.borderThickness);
|
||||
%linesToScroll = mFloor((%chatPosition / %textHeight) + 0.5);
|
||||
if (%linesToScroll <= 0)
|
||||
return;
|
||||
|
||||
if (%linesToScroll > %pageLines)
|
||||
%scrollLines = %pageLines;
|
||||
else
|
||||
%scrollLines = %linesToScroll;
|
||||
|
||||
// Now set the position
|
||||
%this.position = firstWord(%this.position) SPC (getWord(%this.position, 1) + (%scrollLines * %textHeight));
|
||||
|
||||
// Display the pageup icon
|
||||
chatPageDown.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function ChatHud::pageDown(%this)
|
||||
{
|
||||
// Find out the text line height
|
||||
%textHeight = %this.profile.fontSize + %this.lineSpacing;
|
||||
if (%textHeight <= 0)
|
||||
%textHeight = 12;
|
||||
|
||||
%scrollBox = %this.getGroup();
|
||||
|
||||
// Find out how many lines per page are visible
|
||||
%chatScrollHeight = getWord(%scrollBox.extent, 1) - 2 * %scrollBox.profile.borderThickness;
|
||||
if (%chatScrollHeight <= 0)
|
||||
return;
|
||||
|
||||
%pageLines = mFloor(%chatScrollHeight / %textHeight) - 1;
|
||||
if (%pageLines <= 0)
|
||||
%pageLines = 1;
|
||||
|
||||
// See how many lines we actually can scroll down:
|
||||
%chatPosition = getWord(%this.extent, 1) - %chatScrollHeight + getWord(%this.position, 1) - %scrollBox.profile.borderThickness;
|
||||
%linesToScroll = mFloor((%chatPosition / %textHeight) + 0.5);
|
||||
if (%linesToScroll <= 0)
|
||||
return;
|
||||
|
||||
if (%linesToScroll > %pageLines)
|
||||
%scrollLines = %pageLines;
|
||||
else
|
||||
%scrollLines = %linesToScroll;
|
||||
|
||||
// Now set the position
|
||||
%this.position = firstWord(%this.position) SPC (getWord(%this.position, 1) - (%scrollLines * %textHeight));
|
||||
|
||||
// See if we have should (still) display the pagedown icon
|
||||
if (%scrollLines < %linesToScroll)
|
||||
chatPageDown.setVisible(true);
|
||||
else
|
||||
chatPageDown.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Support functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function pageUpMessageHud()
|
||||
{
|
||||
ChatHud.pageUp();
|
||||
}
|
||||
|
||||
function pageDownMessageHud()
|
||||
{
|
||||
ChatHud.pageDown();
|
||||
}
|
||||
|
||||
function cycleMessageHudSize()
|
||||
{
|
||||
MainChatHud.nextChatHudLen();
|
||||
}
|
||||
180
Templates/Modules/FPSGameplay/scripts/client/clientCommands.cs
Normal file
180
Templates/Modules/FPSGameplay/scripts/client/clientCommands.cs
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Server Admin Commands
|
||||
//-----------------------------------------------------------------------------
|
||||
function SAD(%password)
|
||||
{
|
||||
if (%password !$= "")
|
||||
commandToServer('SAD', %password);
|
||||
}
|
||||
|
||||
function SADSetPassword(%password)
|
||||
{
|
||||
commandToServer('SADSetPassword', %password);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Misc server commands
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function clientCmdSyncClock(%time)
|
||||
{
|
||||
// Time update from the server, this is only sent at the start of a mission
|
||||
// or when a client joins a game in progress.
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// WeaponHUD
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Update the Ammo Counter with current ammo, if not any then hide the counter.
|
||||
function clientCmdSetAmmoAmountHud(%amount, %amountInClips)
|
||||
{
|
||||
if (!%amount)
|
||||
AmmoAmount.setVisible(false);
|
||||
else
|
||||
{
|
||||
AmmoAmount.setVisible(true);
|
||||
AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips);
|
||||
}
|
||||
}
|
||||
|
||||
// Here we update the Weapon Preview image & reticle for each weapon. We also
|
||||
// update the Ammo Counter (just so we don't have to call it separately).
|
||||
// Passing an empty parameter ("") hides the HUD component.
|
||||
|
||||
function clientCmdRefreshWeaponHUD(%amount, %preview, %ret, %zoomRet, %amountInClips)
|
||||
{
|
||||
if (!%amount)
|
||||
AmmoAmount.setVisible(false);
|
||||
else
|
||||
{
|
||||
AmmoAmount.setVisible(true);
|
||||
AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips);
|
||||
}
|
||||
|
||||
if (%preview $= "")
|
||||
WeaponHUD.setVisible(false);//PreviewImage.setVisible(false);
|
||||
else
|
||||
{
|
||||
WeaponHUD.setVisible(true);//PreviewImage.setVisible(true);
|
||||
PreviewImage.setbitmap("data/FPSGameplay/art/gui/weaponHud/"@ detag(%preview));
|
||||
}
|
||||
|
||||
if (%ret $= "")
|
||||
Reticle.setVisible(false);
|
||||
else
|
||||
{
|
||||
Reticle.setVisible(true);
|
||||
Reticle.setbitmap("data/FPSGameplay/art/gui/weaponHud/"@ detag(%ret));
|
||||
}
|
||||
|
||||
if (isObject(ZoomReticle))
|
||||
{
|
||||
if (%zoomRet $= "")
|
||||
{
|
||||
ZoomReticle.setBitmap("");
|
||||
}
|
||||
else
|
||||
{
|
||||
ZoomReticle.setBitmap("data/FPSGameplay/art/gui/weaponHud/"@ detag(%zoomRet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Damage Direction Indicator
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function clientCmdSetDamageDirection(%direction)
|
||||
{
|
||||
eval("%ctrl = DamageHUD-->damage_" @ %direction @ ";");
|
||||
if (isObject(%ctrl))
|
||||
{
|
||||
// Show the indicator, and schedule an event to hide it again
|
||||
cancelAll(%ctrl);
|
||||
%ctrl.setVisible(true);
|
||||
%ctrl.schedule(500, setVisible, false);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Teleporter visual effect
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function clientCmdPlayTeleportEffect(%position, %effectDataBlock)
|
||||
{
|
||||
if (isObject(%effectDataBlock))
|
||||
{
|
||||
new Explosion()
|
||||
{
|
||||
position = %position;
|
||||
dataBlock = %effectDataBlock;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Vehicle Support
|
||||
// ----------------------------------------------------------------------------
|
||||
function clientCmdtoggleVehicleMap(%toggle)
|
||||
{
|
||||
if(%toggle)
|
||||
{
|
||||
moveMap.pop();
|
||||
// clear movement
|
||||
$mvForwardAction = 0;
|
||||
$mvBackwardAction = 0;
|
||||
vehicleMap.push();
|
||||
}
|
||||
else
|
||||
{
|
||||
vehicleMap.pop();
|
||||
moveMap.push();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Turret Support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Call by the Turret class when a player mounts or unmounts it.
|
||||
// %turret = The turret that was mounted
|
||||
// %player = The player doing the mounting
|
||||
// %mounted = True if the turret was mounted, false if it was unmounted
|
||||
function turretMountCallback(%turret, %player, %mounted)
|
||||
{
|
||||
//echo ( "\c4turretMountCallback -> " @ %mounted );
|
||||
|
||||
if (%mounted)
|
||||
{
|
||||
// Push the action map
|
||||
turretMap.push();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pop the action map
|
||||
turretMap.pop();
|
||||
}
|
||||
}
|
||||
224
Templates/Modules/FPSGameplay/scripts/client/default.keybinds.cs
Normal file
224
Templates/Modules/FPSGameplay/scripts/client/default.keybinds.cs
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
if ( isObject( moveMap ) )
|
||||
moveMap.delete();
|
||||
new ActionMap(moveMap);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Non-remapable binds
|
||||
//------------------------------------------------------------------------------
|
||||
moveMap.bind( keyboard, F2, showPlayerList );
|
||||
|
||||
moveMap.bind(keyboard, "ctrl h", hideHUDs);
|
||||
|
||||
moveMap.bind(keyboard, "alt p", doScreenShotHudless);
|
||||
|
||||
moveMap.bindCmd(keyboard, "escape", "", "Canvas.pushDialog(PauseMenu);");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Movement Keys
|
||||
//------------------------------------------------------------------------------
|
||||
moveMap.bind( keyboard, a, moveleft );
|
||||
moveMap.bind( keyboard, d, moveright );
|
||||
moveMap.bind( keyboard, left, moveleft );
|
||||
moveMap.bind( keyboard, right, moveright );
|
||||
|
||||
moveMap.bind( keyboard, w, moveforward );
|
||||
moveMap.bind( keyboard, s, movebackward );
|
||||
moveMap.bind( keyboard, up, moveforward );
|
||||
moveMap.bind( keyboard, down, movebackward );
|
||||
|
||||
moveMap.bind( keyboard, e, moveup );
|
||||
moveMap.bind( keyboard, c, movedown );
|
||||
|
||||
moveMap.bind( keyboard, space, jump );
|
||||
moveMap.bind( mouse, xaxis, yaw );
|
||||
moveMap.bind( mouse, yaxis, pitch );
|
||||
|
||||
moveMap.bind( gamepad, thumbrx, "D", "-0.23 0.23", gamepadYaw );
|
||||
moveMap.bind( gamepad, thumbry, "D", "-0.23 0.23", gamepadPitch );
|
||||
moveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX );
|
||||
moveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY );
|
||||
|
||||
moveMap.bind( gamepad, btn_a, jump );
|
||||
moveMap.bindCmd( gamepad, btn_back, "disconnect();", "" );
|
||||
|
||||
moveMap.bindCmd(gamepad, dpadl, "toggleLightColorViz();", "");
|
||||
moveMap.bindCmd(gamepad, dpadu, "toggleDepthViz();", "");
|
||||
moveMap.bindCmd(gamepad, dpadd, "toggleNormalsViz();", "");
|
||||
moveMap.bindCmd(gamepad, dpadr, "toggleLightSpecularViz();", "");
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Stance/pose
|
||||
// ----------------------------------------------------------------------------
|
||||
moveMap.bind(keyboard, lcontrol, doCrouch);
|
||||
moveMap.bind(gamepad, btn_b, doCrouch);
|
||||
|
||||
moveMap.bind(keyboard, lshift, doSprint);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Mouse Trigger
|
||||
//------------------------------------------------------------------------------
|
||||
//function altTrigger(%val)
|
||||
//{
|
||||
//$mvTriggerCount1++;
|
||||
//}
|
||||
|
||||
moveMap.bind( mouse, button0, mouseFire );
|
||||
//moveMap.bind( mouse, button1, altTrigger );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Gamepad Trigger
|
||||
//------------------------------------------------------------------------------
|
||||
moveMap.bind(gamepad, triggerr, gamepadFire);
|
||||
moveMap.bind(gamepad, triggerl, gamepadAltTrigger);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Zoom and FOV functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if($Player::CurrentFOV $= "")
|
||||
$Player::CurrentFOV = $pref::Player::DefaultFOV / 2;
|
||||
|
||||
// toggleZoomFOV() works by dividing the CurrentFOV by 2. Each time that this
|
||||
// toggle is hit it simply divides the CurrentFOV by 2 once again. If the
|
||||
// FOV is reduced below a certain threshold then it resets to equal half of the
|
||||
// DefaultFOV value. This gives us 4 zoom levels to cycle through.
|
||||
moveMap.bind(keyboard, f, setZoomFOV); // f for field of view
|
||||
moveMap.bind(keyboard, z, toggleZoom); // z for zoom
|
||||
moveMap.bind( mouse, button1, mouseButtonZoom );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Camera & View functions
|
||||
//------------------------------------------------------------------------------
|
||||
moveMap.bind( keyboard, v, toggleFreeLook ); // v for vanity
|
||||
moveMap.bind(keyboard, tab, toggleFirstPerson );
|
||||
|
||||
moveMap.bind( gamepad, btn_x, toggleFirstPerson );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Misc. Player stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Gideon does not have these animations, so the player does not need access to
|
||||
// them. Commenting instead of removing so as to retain an example for those
|
||||
// who will want to use a player model that has these animations and wishes to
|
||||
// use them.
|
||||
|
||||
//moveMap.bindCmd(keyboard, "ctrl w", "commandToServer('playCel',\"wave\");", "");
|
||||
//moveMap.bindCmd(keyboard, "ctrl s", "commandToServer('playCel',\"salute\");", "");
|
||||
|
||||
moveMap.bindCmd(keyboard, "ctrl k", "commandToServer('suicide');", "");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Item manipulation
|
||||
//------------------------------------------------------------------------------
|
||||
moveMap.bindCmd(keyboard, "1", "commandToServer('use',\"Ryder\");", "");
|
||||
moveMap.bindCmd(keyboard, "2", "commandToServer('use',\"Lurker\");", "");
|
||||
moveMap.bindCmd(keyboard, "3", "commandToServer('use',\"LurkerGrenadeLauncher\");", "");
|
||||
moveMap.bindCmd(keyboard, "4", "commandToServer('use',\"ProxMine\");", "");
|
||||
moveMap.bindCmd(keyboard, "5", "commandToServer('use',\"DeployableTurret\");", "");
|
||||
|
||||
moveMap.bindCmd(keyboard, "r", "commandToServer('reloadWeapon');", "");
|
||||
|
||||
moveMap.bind(keyboard, 0, unmountWeapon);
|
||||
|
||||
moveMap.bind(keyboard, "alt w", throwWeapon);
|
||||
moveMap.bind(keyboard, "alt a", tossAmmo);
|
||||
|
||||
moveMap.bind(keyboard, q, nextWeapon);
|
||||
moveMap.bind(keyboard, "ctrl q", prevWeapon);
|
||||
moveMap.bind(mouse, "zaxis", mouseWheelWeaponCycle);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Message HUD functions
|
||||
//------------------------------------------------------------------------------
|
||||
moveMap.bind(keyboard, u, toggleMessageHud );
|
||||
//moveMap.bind(keyboard, y, teamMessageHud );
|
||||
moveMap.bind(keyboard, "pageUp", pageMessageHudUp );
|
||||
moveMap.bind(keyboard, "pageDown", pageMessageHudDown );
|
||||
moveMap.bind(keyboard, "p", resizeMessageHud );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Demo recording functions
|
||||
//------------------------------------------------------------------------------
|
||||
moveMap.bind( keyboard, F3, startRecordingDemo );
|
||||
moveMap.bind( keyboard, F4, stopRecordingDemo );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helper Functions
|
||||
//------------------------------------------------------------------------------
|
||||
moveMap.bind(keyboard, "F8", dropCameraAtPlayer);
|
||||
moveMap.bind(keyboard, "F7", dropPlayerAtCamera);
|
||||
|
||||
GlobalActionMap.bind(keyboard, "ctrl F3", doProfile);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Misc.
|
||||
//------------------------------------------------------------------------------
|
||||
GlobalActionMap.bind(keyboard, "tilde", toggleConsole);
|
||||
GlobalActionMap.bindCmd(keyboard, "alt k", "cls();","");
|
||||
GlobalActionMap.bindCmd(keyboard, "alt enter", "", "Canvas.attemptFullscreenToggle();");
|
||||
GlobalActionMap.bindCmd(keyboard, "F1", "", "contextHelp();");
|
||||
moveMap.bindCmd(keyboard, "n", "toggleNetGraph();", "");
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Useful vehicle stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
// Bind the keys to the carjack command
|
||||
moveMap.bindCmd(keyboard, "ctrl z", "carjack();", "");
|
||||
|
||||
// Starting vehicle action map code
|
||||
if ( isObject( vehicleMap ) )
|
||||
vehicleMap.delete();
|
||||
new ActionMap(vehicleMap);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Non-remapable binds
|
||||
//------------------------------------------------------------------------------
|
||||
vehicleMap.bindCmd(keyboard, "escape", "", "Canvas.pushDialog(PauseMenu);");
|
||||
|
||||
// The key command for flipping the car
|
||||
vehicleMap.bindCmd(keyboard, "ctrl x", "commandToServer(\'flipCar\');", "");
|
||||
|
||||
vehicleMap.bind( keyboard, w, moveforward );
|
||||
vehicleMap.bind( keyboard, s, movebackward );
|
||||
vehicleMap.bind( keyboard, up, moveforward );
|
||||
vehicleMap.bind( keyboard, down, movebackward );
|
||||
vehicleMap.bind( mouse, xaxis, yaw );
|
||||
vehicleMap.bind( mouse, yaxis, pitch );
|
||||
vehicleMap.bind( mouse, button0, mouseFire );
|
||||
vehicleMap.bind( mouse, button1, altTrigger );
|
||||
vehicleMap.bindCmd(keyboard, "f","getout();","");
|
||||
vehicleMap.bind(keyboard, space, brake);
|
||||
vehicleMap.bindCmd(keyboard, "l", "brakeLights();", "");
|
||||
vehicleMap.bind( keyboard, v, toggleFreeLook ); // v for vanity
|
||||
//vehicleMap.bind(keyboard, tab, toggleFirstPerson );
|
||||
// bind the left thumbstick for steering
|
||||
vehicleMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamepadYaw );
|
||||
// bind the gas, break, and reverse buttons
|
||||
vehicleMap.bind( gamepad, btn_a, moveforward );
|
||||
vehicleMap.bind( gamepad, btn_b, brake );
|
||||
vehicleMap.bind( gamepad, btn_x, movebackward );
|
||||
// bind exiting the vehicle to a button
|
||||
vehicleMap.bindCmd(gamepad, btn_y,"getout();","");
|
||||
175
Templates/Modules/FPSGameplay/scripts/client/gameProfiles.cs
Normal file
175
Templates/Modules/FPSGameplay/scripts/client/gameProfiles.cs
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Override base controls
|
||||
//GuiMenuButtonProfile.soundButtonOver = "AudioButtonOver";
|
||||
//GuiMenuButtonProfile.soundButtonDown = "AudioButtonDown";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Chat Hud profiles
|
||||
|
||||
|
||||
singleton GuiControlProfile (ChatHudEditProfile)
|
||||
{
|
||||
opaque = false;
|
||||
fillColor = "255 255 255";
|
||||
fillColorHL = "128 128 128";
|
||||
border = false;
|
||||
borderThickness = 0;
|
||||
borderColor = "40 231 240";
|
||||
fontColor = "40 231 240";
|
||||
fontColorHL = "40 231 240";
|
||||
fontColorNA = "128 128 128";
|
||||
textOffset = "0 2";
|
||||
autoSizeWidth = false;
|
||||
autoSizeHeight = true;
|
||||
tab = true;
|
||||
canKeyFocus = true;
|
||||
};
|
||||
|
||||
singleton GuiControlProfile (ChatHudTextProfile)
|
||||
{
|
||||
opaque = false;
|
||||
fillColor = "255 255 255";
|
||||
fillColorHL = "128 128 128";
|
||||
border = false;
|
||||
borderThickness = 0;
|
||||
borderColor = "40 231 240";
|
||||
fontColor = "40 231 240";
|
||||
fontColorHL = "40 231 240";
|
||||
fontColorNA = "128 128 128";
|
||||
textOffset = "0 0";
|
||||
autoSizeWidth = true;
|
||||
autoSizeHeight = true;
|
||||
tab = true;
|
||||
canKeyFocus = true;
|
||||
};
|
||||
|
||||
singleton GuiControlProfile ("ChatHudMessageProfile")
|
||||
{
|
||||
fontType = "Arial";
|
||||
fontSize = 16;
|
||||
fontColor = "44 172 181"; // default color (death msgs, scoring, inventory)
|
||||
fontColors[1] = "4 235 105"; // client join/drop, tournament mode
|
||||
fontColors[2] = "219 200 128"; // gameplay, admin/voting, pack/deployable
|
||||
fontColors[3] = "77 253 95"; // team chat, spam protection message, client tasks
|
||||
fontColors[4] = "40 231 240"; // global chat
|
||||
fontColors[5] = "200 200 50 200"; // used in single player game
|
||||
// WARNING! Colors 6-9 are reserved for name coloring
|
||||
autoSizeWidth = true;
|
||||
autoSizeHeight = true;
|
||||
};
|
||||
|
||||
singleton GuiControlProfile ("ChatHudScrollProfile")
|
||||
{
|
||||
opaque = false;
|
||||
borderThickness = 0;
|
||||
borderColor = "0 255 0";
|
||||
bitmap = "data/UI/art/scrollBar";
|
||||
hasBitmapArray = true;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Core Hud profiles
|
||||
|
||||
singleton GuiControlProfile ("HudScrollProfile")
|
||||
{
|
||||
opaque = false;
|
||||
border = true;
|
||||
borderColor = "0 255 0";
|
||||
bitmap = "data/UI/art/scrollBar";
|
||||
hasBitmapArray = true;
|
||||
};
|
||||
|
||||
singleton GuiControlProfile ("HudTextProfile")
|
||||
{
|
||||
opaque = false;
|
||||
fillColor = "128 128 128";
|
||||
fontColor = "0 255 0";
|
||||
border = true;
|
||||
borderColor = "0 255 0";
|
||||
};
|
||||
|
||||
singleton GuiControlProfile ("ChatHudBorderProfile")
|
||||
{
|
||||
bitmap = "data/UI/art/chatHudBorderArray";
|
||||
hasBitmapArray = true;
|
||||
opaque = false;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Center and bottom print
|
||||
|
||||
singleton GuiControlProfile ("CenterPrintProfile")
|
||||
{
|
||||
opaque = false;
|
||||
fillColor = "128 128 128";
|
||||
fontColor = "0 255 0";
|
||||
border = true;
|
||||
borderColor = "0 255 0";
|
||||
};
|
||||
|
||||
singleton GuiControlProfile ("CenterPrintTextProfile")
|
||||
{
|
||||
opaque = false;
|
||||
fontType = "Arial";
|
||||
fontSize = 12;
|
||||
fontColor = "0 255 0";
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// HUD text
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
singleton GuiControlProfile (HudTextNormalProfile)
|
||||
{
|
||||
opaque = false;
|
||||
fontType = "Arial";
|
||||
fontSize = 14;
|
||||
fontColor = "255 255 255";
|
||||
};
|
||||
|
||||
singleton GuiControlProfile (HudTextItalicProfile : HudTextNormalProfile)
|
||||
{
|
||||
fontType = "ArialItalic";
|
||||
};
|
||||
|
||||
singleton GuiControlProfile (HudTextBoldProfile : HudTextNormalProfile)
|
||||
{
|
||||
fontType = "ArialBold";
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Numerical health text
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
singleton GuiControlProfile (NumericHealthProfile)
|
||||
{
|
||||
opaque = true;
|
||||
justify = "center";
|
||||
fontType = "ArialBold";
|
||||
fontSize = 32;
|
||||
fontColor = "255 255 255";
|
||||
};
|
||||
533
Templates/Modules/FPSGameplay/scripts/client/inputCommands.cs
Normal file
533
Templates/Modules/FPSGameplay/scripts/client/inputCommands.cs
Normal file
|
|
@ -0,0 +1,533 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 escapeFromGame()
|
||||
{
|
||||
disconnect();
|
||||
}
|
||||
|
||||
function showPlayerList(%val)
|
||||
{
|
||||
if (%val)
|
||||
PlayerListGui.toggle();
|
||||
}
|
||||
|
||||
function hideHUDs(%val)
|
||||
{
|
||||
if (%val)
|
||||
HudlessPlayGui.toggle();
|
||||
}
|
||||
|
||||
function doScreenShotHudless(%val)
|
||||
{
|
||||
if(%val)
|
||||
{
|
||||
canvas.setContent(HudlessPlayGui);
|
||||
//doScreenshot(%val);
|
||||
schedule(10, 0, "doScreenShot", %val);
|
||||
}
|
||||
else
|
||||
canvas.setContent(PlayGui);
|
||||
}
|
||||
|
||||
$movementSpeed = 1; // m/s
|
||||
|
||||
function setSpeed(%speed)
|
||||
{
|
||||
if(%speed)
|
||||
$movementSpeed = %speed;
|
||||
}
|
||||
|
||||
function moveleft(%val)
|
||||
{
|
||||
$mvLeftAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function moveright(%val)
|
||||
{
|
||||
$mvRightAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function moveforward(%val)
|
||||
{
|
||||
$mvForwardAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function movebackward(%val)
|
||||
{
|
||||
$mvBackwardAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function moveup(%val)
|
||||
{
|
||||
%object = ServerConnection.getControlObject();
|
||||
|
||||
if(%object.isInNamespaceHierarchy("Camera"))
|
||||
$mvUpAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function movedown(%val)
|
||||
{
|
||||
%object = ServerConnection.getControlObject();
|
||||
|
||||
if(%object.isInNamespaceHierarchy("Camera"))
|
||||
$mvDownAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function turnLeft( %val )
|
||||
{
|
||||
$mvYawRightSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
|
||||
}
|
||||
|
||||
function turnRight( %val )
|
||||
{
|
||||
$mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
|
||||
}
|
||||
|
||||
function panUp( %val )
|
||||
{
|
||||
$mvPitchDownSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
|
||||
}
|
||||
|
||||
function panDown( %val )
|
||||
{
|
||||
$mvPitchUpSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
|
||||
}
|
||||
|
||||
function getMouseAdjustAmount(%val)
|
||||
{
|
||||
// based on a default camera FOV of 90'
|
||||
return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity;
|
||||
}
|
||||
|
||||
function getGamepadAdjustAmount(%val)
|
||||
{
|
||||
// based on a default camera FOV of 90'
|
||||
return(%val * ($cameraFov / 90) * 0.01) * 10.0;
|
||||
}
|
||||
|
||||
function yaw(%val)
|
||||
{
|
||||
%yawAdj = getMouseAdjustAmount(%val);
|
||||
if(ServerConnection.isControlObjectRotDampedCamera())
|
||||
{
|
||||
// Clamp and scale
|
||||
%yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
|
||||
%yawAdj *= 0.5;
|
||||
}
|
||||
|
||||
$mvYaw += %yawAdj;
|
||||
}
|
||||
|
||||
function pitch(%val)
|
||||
{
|
||||
%pitchAdj = getMouseAdjustAmount(%val);
|
||||
if(ServerConnection.isControlObjectRotDampedCamera())
|
||||
{
|
||||
// Clamp and scale
|
||||
%pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
|
||||
%pitchAdj *= 0.5;
|
||||
}
|
||||
|
||||
$mvPitch += %pitchAdj;
|
||||
}
|
||||
|
||||
function jump(%val)
|
||||
{
|
||||
$mvTriggerCount2++;
|
||||
}
|
||||
|
||||
function gamePadMoveX( %val )
|
||||
{
|
||||
if(%val > 0)
|
||||
{
|
||||
$mvRightAction = %val * $movementSpeed;
|
||||
$mvLeftAction = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mvRightAction = 0;
|
||||
$mvLeftAction = -%val * $movementSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
function gamePadMoveY( %val )
|
||||
{
|
||||
if(%val > 0)
|
||||
{
|
||||
$mvForwardAction = %val * $movementSpeed;
|
||||
$mvBackwardAction = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mvForwardAction = 0;
|
||||
$mvBackwardAction = -%val * $movementSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
function gamepadYaw(%val)
|
||||
{
|
||||
%yawAdj = getGamepadAdjustAmount(%val);
|
||||
if(ServerConnection.isControlObjectRotDampedCamera())
|
||||
{
|
||||
// Clamp and scale
|
||||
%yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
|
||||
%yawAdj *= 0.5;
|
||||
}
|
||||
|
||||
if(%yawAdj > 0)
|
||||
{
|
||||
$mvYawLeftSpeed = %yawAdj;
|
||||
$mvYawRightSpeed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mvYawLeftSpeed = 0;
|
||||
$mvYawRightSpeed = -%yawAdj;
|
||||
}
|
||||
}
|
||||
|
||||
function gamepadPitch(%val)
|
||||
{
|
||||
%pitchAdj = getGamepadAdjustAmount(%val);
|
||||
if(ServerConnection.isControlObjectRotDampedCamera())
|
||||
{
|
||||
// Clamp and scale
|
||||
%pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
|
||||
%pitchAdj *= 0.5;
|
||||
}
|
||||
|
||||
if(%pitchAdj > 0)
|
||||
{
|
||||
$mvPitchDownSpeed = %pitchAdj;
|
||||
$mvPitchUpSpeed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mvPitchDownSpeed = 0;
|
||||
$mvPitchUpSpeed = -%pitchAdj;
|
||||
}
|
||||
}
|
||||
|
||||
function doCrouch(%val)
|
||||
{
|
||||
$mvTriggerCount3++;
|
||||
}
|
||||
|
||||
function doSprint(%val)
|
||||
{
|
||||
$mvTriggerCount5++;
|
||||
}
|
||||
|
||||
function mouseFire(%val)
|
||||
{
|
||||
$mvTriggerCount0++;
|
||||
}
|
||||
|
||||
function gamepadFire(%val)
|
||||
{
|
||||
if(%val > 0.1 && !$gamepadFireTriggered)
|
||||
{
|
||||
$gamepadFireTriggered = true;
|
||||
$mvTriggerCount0++;
|
||||
}
|
||||
else if(%val <= 0.1 && $gamepadFireTriggered)
|
||||
{
|
||||
$gamepadFireTriggered = false;
|
||||
$mvTriggerCount0++;
|
||||
}
|
||||
}
|
||||
|
||||
function gamepadAltTrigger(%val)
|
||||
{
|
||||
if(%val > 0.1 && !$gamepadAltTriggerTriggered)
|
||||
{
|
||||
$gamepadAltTriggerTriggered = true;
|
||||
$mvTriggerCount1++;
|
||||
}
|
||||
else if(%val <= 0.1 && $gamepadAltTriggerTriggered)
|
||||
{
|
||||
$gamepadAltTriggerTriggered = false;
|
||||
$mvTriggerCount1++;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleZoomFOV()
|
||||
{
|
||||
$Player::CurrentFOV = $Player::CurrentFOV / 2;
|
||||
|
||||
if($Player::CurrentFOV < 5)
|
||||
resetCurrentFOV();
|
||||
|
||||
if(ServerConnection.zoomed)
|
||||
setFOV($Player::CurrentFOV);
|
||||
else
|
||||
{
|
||||
setFov(ServerConnection.getControlCameraDefaultFov());
|
||||
}
|
||||
}
|
||||
|
||||
function resetCurrentFOV()
|
||||
{
|
||||
$Player::CurrentFOV = ServerConnection.getControlCameraDefaultFov() / 2;
|
||||
}
|
||||
|
||||
function turnOffZoom()
|
||||
{
|
||||
ServerConnection.zoomed = false;
|
||||
setFov(ServerConnection.getControlCameraDefaultFov());
|
||||
Reticle.setVisible(true);
|
||||
zoomReticle.setVisible(false);
|
||||
|
||||
// Rather than just disable the DOF effect, we want to set it to the level's
|
||||
// preset values.
|
||||
//DOFPostEffect.disable();
|
||||
ppOptionsUpdateDOFSettings();
|
||||
}
|
||||
|
||||
function setZoomFOV(%val)
|
||||
{
|
||||
if(%val)
|
||||
toggleZoomFOV();
|
||||
}
|
||||
|
||||
function toggleZoom(%val)
|
||||
{
|
||||
if (%val)
|
||||
{
|
||||
ServerConnection.zoomed = true;
|
||||
setFov($Player::CurrentFOV);
|
||||
Reticle.setVisible(false);
|
||||
zoomReticle.setVisible(true);
|
||||
|
||||
DOFPostEffect.setAutoFocus( true );
|
||||
DOFPostEffect.setFocusParams( 0.5, 0.5, 50, 500, -5, 5 );
|
||||
DOFPostEffect.enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
turnOffZoom();
|
||||
}
|
||||
}
|
||||
|
||||
function mouseButtonZoom(%val)
|
||||
{
|
||||
toggleZoom(%val);
|
||||
}
|
||||
|
||||
function toggleFreeLook( %val )
|
||||
{
|
||||
if ( %val )
|
||||
$mvFreeLook = true;
|
||||
else
|
||||
$mvFreeLook = false;
|
||||
}
|
||||
|
||||
function toggleFirstPerson(%val)
|
||||
{
|
||||
if (%val)
|
||||
{
|
||||
ServerConnection.setFirstPerson(!ServerConnection.isFirstPerson());
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCamera(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('ToggleCamera');
|
||||
}
|
||||
|
||||
function unmountWeapon(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('unmountWeapon');
|
||||
}
|
||||
|
||||
function throwWeapon(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('Throw', "Weapon");
|
||||
}
|
||||
function tossAmmo(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('Throw', "Ammo");
|
||||
}
|
||||
|
||||
function nextWeapon(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('cycleWeapon', "next");
|
||||
}
|
||||
|
||||
function prevWeapon(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('cycleWeapon', "prev");
|
||||
}
|
||||
|
||||
function mouseWheelWeaponCycle(%val)
|
||||
{
|
||||
if (%val < 0)
|
||||
commandToServer('cycleWeapon', "next");
|
||||
else if (%val > 0)
|
||||
commandToServer('cycleWeapon', "prev");
|
||||
}
|
||||
|
||||
function pageMessageHudUp( %val )
|
||||
{
|
||||
if ( %val )
|
||||
pageUpMessageHud();
|
||||
}
|
||||
|
||||
function pageMessageHudDown( %val )
|
||||
{
|
||||
if ( %val )
|
||||
pageDownMessageHud();
|
||||
}
|
||||
|
||||
function resizeMessageHud( %val )
|
||||
{
|
||||
if ( %val )
|
||||
cycleMessageHudSize();
|
||||
}
|
||||
|
||||
function startRecordingDemo( %val )
|
||||
{
|
||||
if ( %val )
|
||||
startDemoRecord();
|
||||
}
|
||||
|
||||
function stopRecordingDemo( %val )
|
||||
{
|
||||
if ( %val )
|
||||
stopDemoRecord();
|
||||
}
|
||||
|
||||
function dropCameraAtPlayer(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('dropCameraAtPlayer');
|
||||
}
|
||||
|
||||
function dropPlayerAtCamera(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('DropPlayerAtCamera');
|
||||
}
|
||||
|
||||
function bringUpOptions(%val)
|
||||
{
|
||||
if (%val)
|
||||
Canvas.pushDialog(OptionsDlg);
|
||||
}
|
||||
|
||||
GlobalActionMap.bind(keyboard, "ctrl o", bringUpOptions);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Debugging Functions
|
||||
//------------------------------------------------------------------------------
|
||||
function showMetrics(%val)
|
||||
{
|
||||
if(%val)
|
||||
{
|
||||
if(!Canvas.isMember(FrameOverlayGui))
|
||||
metrics("fps gfx shadow sfx terrain groundcover forest net");
|
||||
else
|
||||
metrics("");
|
||||
}
|
||||
}
|
||||
GlobalActionMap.bind(keyboard, "ctrl F2", showMetrics);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Start profiler by pressing ctrl f3
|
||||
// ctrl f3 - starts profile that will dump to console and file
|
||||
//
|
||||
function doProfile(%val)
|
||||
{
|
||||
if (%val)
|
||||
{
|
||||
// key down -- start profile
|
||||
echo("Starting profile session...");
|
||||
profilerReset();
|
||||
profilerEnable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// key up -- finish off profile
|
||||
echo("Ending profile session...");
|
||||
|
||||
profilerDumpToFile("profilerDumpToFile" @ getSimTime() @ ".txt");
|
||||
profilerEnable(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Trace a line along the direction the crosshair is pointing
|
||||
// If you find a car with a player in it...eject them
|
||||
function carjack()
|
||||
{
|
||||
%player = LocalClientConnection.getControlObject();
|
||||
|
||||
if (%player.getClassName() $= "Player")
|
||||
{
|
||||
%eyeVec = %player.getEyeVector();
|
||||
|
||||
%startPos = %player.getEyePoint();
|
||||
%endPos = VectorAdd(%startPos, VectorScale(%eyeVec, 1000));
|
||||
|
||||
%target = ContainerRayCast(%startPos, %endPos, $TypeMasks::VehicleObjectType);
|
||||
|
||||
if (%target)
|
||||
{
|
||||
// See if anyone is mounted in the car's driver seat
|
||||
%mount = %target.getMountNodeObject(0);
|
||||
|
||||
// Can only carjack bots
|
||||
// remove '&& %mount.getClassName() $= "AIPlayer"' to allow you
|
||||
// to carjack anyone/anything
|
||||
if (%mount && %mount.getClassName() $= "AIPlayer")
|
||||
{
|
||||
commandToServer('carUnmountObj', %mount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getOut()
|
||||
{
|
||||
vehicleMap.pop();
|
||||
moveMap.push();
|
||||
commandToServer('dismountVehicle');
|
||||
}
|
||||
|
||||
function brakeLights()
|
||||
{
|
||||
// Turn on/off the Cheetah's head lights.
|
||||
commandToServer('toggleBrakeLights');
|
||||
}
|
||||
|
||||
function brake(%val)
|
||||
{
|
||||
commandToServer('toggleBrakeLights');
|
||||
$mvTriggerCount2++;
|
||||
}
|
||||
109
Templates/Modules/FPSGameplay/scripts/client/message.cs
Normal file
109
Templates/Modules/FPSGameplay/scripts/client/message.cs
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Functions that process commands sent from the server.
|
||||
|
||||
|
||||
// This function is for chat messages only; it is invoked on the client when
|
||||
// the server does a commandToClient with the tag ChatMessage. (Cf. the
|
||||
// functions chatMessage* in core/scripts/server/message.cs.)
|
||||
|
||||
// This just invokes onChatMessage, which the mod code must define.
|
||||
|
||||
function clientCmdChatMessage(%sender, %voice, %pitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10)
|
||||
{
|
||||
onChatMessage(detag(%msgString), %voice, %pitch);
|
||||
}
|
||||
|
||||
|
||||
// Game event descriptions, which may or may not include text messages, can be
|
||||
// sent using the message* functions in core/scripts/server/message.cs. Those
|
||||
// functions do commandToClient with the tag ServerMessage, which invokes the
|
||||
// function below.
|
||||
|
||||
// For ServerMessage messages, the client can install callbacks that will be
|
||||
// run, according to the "type" of the message.
|
||||
|
||||
function clientCmdServerMessage(%msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10)
|
||||
{
|
||||
// Get the message type; terminates at any whitespace.
|
||||
%tag = getWord(%msgType, 0);
|
||||
|
||||
// First see if there is a callback installed that doesn't have a type;
|
||||
// if so, that callback is always executed when a message arrives.
|
||||
for (%i = 0; (%func = $MSGCB["", %i]) !$= ""; %i++) {
|
||||
call(%func, %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
|
||||
}
|
||||
|
||||
// Next look for a callback for this particular type of ServerMessage.
|
||||
if (%tag !$= "") {
|
||||
for (%i = 0; (%func = $MSGCB[%tag, %i]) !$= ""; %i++) {
|
||||
call(%func, %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called by the client to install a callback for a particular type of
|
||||
// ServerMessage.
|
||||
function addMessageCallback(%msgType, %func)
|
||||
{
|
||||
for (%i = 0; (%afunc = $MSGCB[%msgType, %i]) !$= ""; %i++) {
|
||||
// If it already exists as a callback for this type,
|
||||
// nothing to do.
|
||||
if (%afunc $= %func) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Set it up.
|
||||
$MSGCB[%msgType, %i] = %func;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// The following is the callback that will be executed for every ServerMessage,
|
||||
// because we're going to install it without a specified type. Any type-
|
||||
// specific callbacks will be executed afterward.
|
||||
|
||||
// This just invokes onServerMessage, which can be overridden by the game
|
||||
function onServerMessage(%a, %b, %c, %d, %e, %f, %g, %h, %i)
|
||||
{
|
||||
echo("onServerMessage: ");
|
||||
if(%a !$= "") echo(" +- a: " @ %a);
|
||||
if(%b !$= "") echo(" +- b: " @ %b);
|
||||
if(%c !$= "") echo(" +- c: " @ %c);
|
||||
if(%d !$= "") echo(" +- d: " @ %d);
|
||||
if(%e !$= "") echo(" +- e: " @ %e);
|
||||
if(%f !$= "") echo(" +- f: " @ %f);
|
||||
if(%g !$= "") echo(" +- g: " @ %g);
|
||||
if(%h !$= "") echo(" +- h: " @ %h);
|
||||
if(%i !$= "") echo(" +- i: " @ %i);
|
||||
}
|
||||
|
||||
function defaultMessageCallback(%msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10)
|
||||
{
|
||||
onServerMessage(detag(%msgString));
|
||||
}
|
||||
|
||||
// Register that default message handler now.
|
||||
addMessageCallback("", defaultMessageCallback);
|
||||
121
Templates/Modules/FPSGameplay/scripts/client/messageHud.cs
Normal file
121
Templates/Modules/FPSGameplay/scripts/client/messageHud.cs
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Enter Chat Message Hud
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function MessageHud::open(%this)
|
||||
{
|
||||
%offset = 6;
|
||||
|
||||
if(%this.isVisible())
|
||||
return;
|
||||
|
||||
if(%this.isTeamMsg)
|
||||
%text = "TEAM:";
|
||||
else
|
||||
%text = "GLOBAL:";
|
||||
|
||||
MessageHud_Text.setValue(%text);
|
||||
|
||||
%windowPos = "0 " @ ( getWord( outerChatHud.position, 1 ) + getWord( outerChatHud.extent, 1 ) + 1 );
|
||||
%windowExt = getWord( OuterChatHud.extent, 0 ) @ " " @ getWord( MessageHud_Frame.extent, 1 );
|
||||
|
||||
%textExtent = getWord(MessageHud_Text.extent, 0) + 14;
|
||||
%ctrlExtent = getWord(MessageHud_Frame.extent, 0);
|
||||
|
||||
Canvas.pushDialog(%this);
|
||||
|
||||
messageHud_Frame.position = %windowPos;
|
||||
messageHud_Frame.extent = %windowExt;
|
||||
MessageHud_Edit.position = setWord(MessageHud_Edit.position, 0, %textExtent + %offset);
|
||||
MessageHud_Edit.extent = setWord(MessageHud_Edit.extent, 0, %ctrlExtent - %textExtent - (2 * %offset));
|
||||
|
||||
%this.setVisible(true);
|
||||
MessageHud_Edit.makeFirstResponder(true);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function MessageHud::close(%this)
|
||||
{
|
||||
if(!%this.isVisible())
|
||||
return;
|
||||
|
||||
Canvas.popDialog(%this);
|
||||
%this.setVisible(false);
|
||||
MessageHud_Edit.setValue("");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function MessageHud::toggleState(%this)
|
||||
{
|
||||
if(%this.isVisible())
|
||||
%this.close();
|
||||
else
|
||||
%this.open();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function MessageHud_Edit::onEscape(%this)
|
||||
{
|
||||
MessageHud.close();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function MessageHud_Edit::eval(%this)
|
||||
{
|
||||
%text = collapseEscape(trim(%this.getValue()));
|
||||
|
||||
if(%text !$= "")
|
||||
{
|
||||
if(MessageHud.isTeamMsg)
|
||||
commandToServer('teamMessageSent', %text);
|
||||
else
|
||||
commandToServer('messageSent', %text);
|
||||
}
|
||||
|
||||
MessageHud.close();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// MessageHud key handlers
|
||||
|
||||
function toggleMessageHud(%make)
|
||||
{
|
||||
if(%make)
|
||||
{
|
||||
MessageHud.isTeamMsg = false;
|
||||
MessageHud.toggleState();
|
||||
}
|
||||
}
|
||||
|
||||
function teamMessageHud(%make)
|
||||
{
|
||||
if(%make)
|
||||
{
|
||||
MessageHud.isTeamMsg = true;
|
||||
MessageHud.toggleState();
|
||||
}
|
||||
}
|
||||
116
Templates/Modules/FPSGameplay/scripts/client/playerList.cs
Normal file
116
Templates/Modules/FPSGameplay/scripts/client/playerList.cs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Hook into the client update messages to maintain our player list and scores.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
addMessageCallback('MsgClientJoin', handleClientJoin);
|
||||
addMessageCallback('MsgClientDrop', handleClientDrop);
|
||||
addMessageCallback('MsgClientScoreChanged', handleClientScoreChanged);
|
||||
|
||||
function handleClientJoin(%msgType, %msgString, %clientName, %clientId, %guid,
|
||||
%score, %kills, %deaths, %isAI, %isAdmin, %isSuperAdmin)
|
||||
{
|
||||
PlayerListGui.update(%clientId, detag(%clientName), %isSuperAdmin, %isAdmin,
|
||||
%isAI, %score, %kills, %deaths);
|
||||
}
|
||||
|
||||
function handleClientDrop(%msgType, %msgString, %clientName, %clientId)
|
||||
{
|
||||
PlayerListGui.remove(%clientId);
|
||||
}
|
||||
|
||||
function handleClientScoreChanged(%msgType, %msgString, %score, %kills, %deaths, %clientId)
|
||||
{
|
||||
PlayerListGui.updateScore(%clientId, %score, %kills, %deaths);
|
||||
echo(" score:"@%score@" kills:"@%kills@" deaths:"@%deaths);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// GUI methods
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function PlayerListGui::update(%this, %clientId, %name, %isSuperAdmin, %isAdmin, %isAI, %score, %kills, %deaths)
|
||||
{
|
||||
// Build the row to display. The name can have ML control tags, including
|
||||
// color and font. Since we're not using an ML control here, we need to
|
||||
// strip them off.
|
||||
%tag = %isSuperAdmin ? "[Super]" :
|
||||
(%isAdmin ? "[Admin]" :
|
||||
(%isAI ? "[Bot]" :
|
||||
""));
|
||||
%text = StripMLControlChars(%name) SPC %tag TAB %score TAB %kills TAB %deaths;
|
||||
|
||||
// Update or add the player to the control
|
||||
if (PlayerListGuiList.getRowNumById(%clientId) == -1)
|
||||
PlayerListGuiList.addRow(%clientId, %text);
|
||||
else
|
||||
PlayerListGuiList.setRowById(%clientId, %text);
|
||||
|
||||
// Sorts by score
|
||||
PlayerListGuiList.sortNumerical(1, false);
|
||||
PlayerListGuiList.clearSelection();
|
||||
}
|
||||
|
||||
function PlayerListGui::updateScore(%this, %clientId, %score, %kills, %deaths)
|
||||
{
|
||||
%text = PlayerListGuiList.getRowTextById(%clientId);
|
||||
%text = setField(%text, 1, %score);
|
||||
%text = setField(%text, 2, %kills);
|
||||
%text = setField(%text, 3, %deaths);
|
||||
PlayerListGuiList.setRowById(%clientId, %text);
|
||||
PlayerListGuiList.sortNumerical(1, false);
|
||||
PlayerListGuiList.clearSelection();
|
||||
}
|
||||
|
||||
function PlayerListGui::remove(%this, %clientId)
|
||||
{
|
||||
PlayerListGuiList.removeRowById(%clientId);
|
||||
}
|
||||
|
||||
function PlayerListGui::toggle(%this)
|
||||
{
|
||||
if (%this.isAwake())
|
||||
Canvas.popDialog(%this);
|
||||
else
|
||||
Canvas.pushDialog(%this);
|
||||
}
|
||||
|
||||
function PlayerListGui::clear(%this)
|
||||
{
|
||||
// Override to clear the list.
|
||||
PlayerListGuiList.clear();
|
||||
}
|
||||
|
||||
function PlayerListGui::zeroScores(%this)
|
||||
{
|
||||
for (%i = 0; %i < PlayerListGuiList.rowCount(); %i++)
|
||||
{
|
||||
%text = PlayerListGuiList.getRowText(%i);
|
||||
%text = setField(%text, 1, "0");
|
||||
%text = setField(%text, 2, "0");
|
||||
%text = setField(%text, 3, "0");
|
||||
PlayerListGuiList.setRowById(PlayerListGuiList.getRowId(%i), %text);
|
||||
}
|
||||
PlayerListGuiList.clearSelection();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue