Shado
UT Name: Letylove49 / Alicia UT Since: 2005 Gender: Joined: Jul 30, 2010 Age: 41 Posts: 39
Reputation: 173.5 Status: Offline
|
Posted: Tue Mar 22, 2011 12:13 am Post subject: Re: Need help for edited Nexgen112 |
|
|
What is wrong here my hud still transparency ?
Quote: | class NexgenHUD extends Mutator;
#exec OBJ LOAD FILE=..\Textures\LadrStatic.utx PACKAGE=Botpack.LadrStatic
#exec TEXTURE IMPORT NAME=base     FILE=Resources\base.pcx     GROUP="GFX" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=grad32    FILE=Resources\grad32.pcx    GROUP="GFX" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=grad64    FILE=Resources\grad64.pcx    GROUP="GFX" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=playerIcon  FILE=Resources\PlayerIcon.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=playerIcon2  FILE=Resources\PlayerIcon2.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=serverIcon  FILE=Resources\ServerIcon.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=serverIcon2  FILE=Resources\ServerIcon2.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=offlineIcon  FILE=Resources\OfflineIcon.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=offlineIcon2 FILE=Resources\OfflineIcon2.pcx GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=waitIcon   FILE=Resources\WaitIcon.pcx   GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=waitIcon2   FILE=Resources\WaitIcon2.pcx   GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=specIcon   FILE=Resources\SpecIcon.pcx   GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=specIcon2   FILE=Resources\SpecIcon2.pcx   GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=shieldIcon  FILE=Resources\ShieldIcon.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=shieldIcon2  FILE=Resources\ShieldIcon2.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=idleIcon   FILE=Resources\IdleIcon.pcx   GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=idleIcon2   FILE=Resources\IdleIcon2.pcx   GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=mutedIcon   FILE=Resources\MutedIcon.pcx   GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=mutedIcon2  FILE=Resources\MutedIcon2.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=matchIcon   FILE=Resources\MatchIcon.pcx   GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=matchIcon2  FILE=Resources\MatchIcon2.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=loginIcon   FILE=Resources\loginIcon.pcx   GROUP="GFX" FLAGS=3 MIPS=OFF
#exec TEXTURE IMPORT NAME=loginIcon2  FILE=Resources\loginIcon2.pcx  GROUP="GFX" FLAGS=3 MIPS=OFF
var NexgenClient client; Â Â Â Â Â Â Â Â // Client owning this HUD.
var PlayerPawn player; Â Â Â Â Â Â Â Â Â // Local player (which has a viewport).
var float lastSetupTime; Â Â Â Â Â Â Â Â // Last time setup() was called.
var Font baseFont; Â Â Â Â Â Â Â Â Â Â Â // Base font to use for rendering text.
var Color blankColor; Â Â Â Â Â Â Â Â Â // White color (#FFFFFF).
var Color baseHUDColor; Â Â Â Â Â Â Â Â // Base color of the HUD (background color).
var Color baseColors[6]; Â Â Â Â Â Â Â Â // Base colors available for the HUD.
var Color colors[11]; Â Â Â Â Â Â Â Â Â // List of colors for text.
var float baseFontHeight; Â Â Â Â Â Â Â // Height of the base font.
struct MessageInfo { Â Â Â Â Â Â Â Â Â Â // Structure for storing message information.
var string text[5]; Â Â Â Â Â Â Â Â // Message text list.
var int col[5]; Â Â Â Â Â Â Â Â Â Â // Message text colors.
var float timeStamp; Â Â Â Â Â Â Â Â // Time at which the message was received.
};
struct PanelInfo { Â Â Â Â Â Â Â Â Â Â Â // Panel info container structure.
var string text; Â Â Â Â Â Â Â Â Â Â // Text displayed on the panel.
var Color textCol; Â Â Â Â Â Â Â Â Â // Color of the text to display.
var Texture icon; Â Â Â Â Â Â Â Â Â // Icon displayed in front of the text.
var Texture solidIcon; Â Â Â Â Â Â Â // Solid version of the icon.
var bool bBlink; Â Â Â Â Â Â Â Â Â Â // Indicates if the text should 'blink'.
};
var MessageInfo chatMessages[3]; Â Â Â Â // List of chat messages.
var MessageInfo messages[5]; Â Â Â Â Â Â // List of all other messages.
var int chatMsgCount; Â Â Â Â Â Â Â Â Â // Number of chat messages stored in the list.
var int msgCount; Â Â Â Â Â Â Â Â Â Â Â // Number of other messages stored.
var Texture faceImg; Â Â Â Â Â Â Â Â Â Â // Face texture to display in the chat message box.
var float msgBoxWidth; Â Â Â Â Â Â Â Â Â // Width of the message box.
var float msgBoxLineHeight; Â Â Â Â Â Â // Height of a line in the message box.
var float msgBoxHeight; Â Â Â Â Â Â Â Â // Total height of the message box.
var float minPanelWidth; Â Â Â Â Â Â Â Â // Minimum size of the panel.
var bool bFlashMessages; Â Â Â Â Â Â Â Â // Whether new messages should flash.
var float lastResX; Â Â Â Â Â Â Â Â Â Â // Horizontal resolution at last setup call.
var float lastResY; Â Â Â Â Â Â Â Â Â Â // Vertical resolution at last setup call.
var float lastLevelTimeSeconds; Â Â Â Â // Last value of level.time seconds.
var float timeSeconds; Â Â Â Â Â Â Â Â Â // Gamespeed independent timeSeconds, that keeps counting
                    // even when the game is paused.
                   Â
var bool bShowPlayerLocation; Â Â Â Â Â // Show player location name in teamsay messages?
var NexgenHUDExtension extensions[10]; Â // Registered HUD extensions.
const iconSize = 24.0; Â Â Â Â Â Â Â Â Â // Size of the status icons.
const chatMessageLifeTime = 16.0; Â Â Â // The amount of time a chat message is diplayed (in sec).
const messageLifeTime = 12.0; Â Â Â Â Â // Amount of time any other message is displayed (in sec).
const messageBlinkTime = 4.0; Â Â Â Â Â // How long a message is highlighted (in sec).
const messageBlinkRate = 4.0; Â Â Â Â Â // Message highlight blink rate (in Hz).
const panelBlinkRate = 2.0; Â Â Â Â Â Â // Panel text highlight blink rate (in Hz).
const blinkColorDamp = 0.70; Â Â Â Â Â Â // Dampening factor for blinking text.
const connectionAlertDelay = 2; Â Â Â Â // Time to wait before showing the bad connection alert.
const secPerMinute = 60; Â Â Â Â Â Â Â Â // Number of seconds per minute -- duh!
const matchInfoSwitchTime = 4; Â Â Â Â Â // Number of seconds to wait before switching between time
                    // remaining and match num.
// Alert window settings.
const hDefBarSize = 20; Â Â Â Â Â Â Â Â // Animated horizontal bar size.
const alertAnimTime = 0.5; Â Â Â Â Â Â Â // Animation cycle time.
const alertAnimDist = 64; Â Â Â Â Â Â Â // Distance the animated bar moves away from the window.
const alertBorderSize = 32; Â Â Â Â Â Â // Distance between borders and text of the window.
const newLineToken = "\
"; Â Â Â Â Â Â // Token used to break the text in multiple lines.
// Colors.
const C_RED = 0;
const C_BLUE = 1;
const C_GREEN = 2;
const C_YELLOW = 3;
const C_WHITE = 4;
const C_BLACK = 5;
const C_PINK = 6;
const C_CYAN = 7;
const C_METAL = 8;
const C_ORANGE = 9;
// Server states.
const SS_Loading = 'ssloading'; Â Â Â Â // Loading.
const SS_Offline = 'ssoffline'; Â Â Â Â // Connection with server is failing.
const SS_Waiting = 'sswaiting'; Â Â Â Â // Server is waiting for players.
const SS_Ready = 'ssready'; Â Â Â Â Â Â // Game is ready to start.
const SS_Starting = 'ssstaring'; Â Â Â Â // Game is counting down to start.
const SS_Ended = 'ssended'; Â Â Â Â Â Â // Game is ended.
const SS_Paused = 'sspaused'; Â Â Â Â Â // Game is paused.
const SS_Match = 'ssmatch'; Â Â Â Â Â Â // A match is in progress.
const SS_Normal = 'ssnormal'; Â Â Â Â Â // A normal game is in progress.
// Client states.
const CS_Login = 'cslogin'; Â Â Â Â Â Â // Client is logging in.
const CS_Idle = 'csidle'; Â Â Â Â Â Â Â // Client is idle or camping.
const CS_Protected = 'csprotected'; Â Â // Client is (damage) protected.
const CS_Muted = 'csmuted'; Â Â Â Â Â Â // Client is muted.
const CS_Dead = 'csdead'; Â Â Â Â Â Â Â // Client is dead.
const CS_Normal = 'csnormal'; Â Â Â Â Â // Client is in normal state.
/***************************************************************************************************
*
* Â $DESCRIPTION Â Initializes the extended HUD.
* Â $REQUIRE Â Â Â owner != none && owner.isA('NexgenClient')
* Â $ENSURE Â Â Â client != none
* Â $OVERRIDE
*
**************************************************************************************************/
function postBeginPlay() {
client = NexgenClient(owner);
//registerHUDMutator(); Â // doesnt always work, as the player HUD is not always valid at this point
              // call it direct from postRenderHUD to be sure
bFlashMessages = client.gc.get(client.SSTR_FlashMessages, "false") ~= "true";
bShowPlayerLocation = client.gc.get(client.SSTR_ShowPlayerLocation, "true") ~= "true";
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Renders the extended Nexgen HUD.
*  $PARAM     c  Canvas object that provides the drawing capabilities.
* Â $REQUIRE Â Â Â c != none
* Â $OVERRIDE
*
**************************************************************************************************/
function postRender(Canvas c) {
local float badConnectionTime;
local int timeRemaining;
local int index;
// Let other HUD mutators do their job first.
if (nextHUDMutator != none) {
nextHUDMutator.postRender(c);
}
// Render HUD extensions.
for (index = 0; index <arrayCount> 0 &&
  (badConnectionTime > connectionAlertDelay || client.gInf.rebootCountDown > 0)) {
// Connection lost alert.
timeRemaining = client.sConf.autoReconnectTime - badConnectionTime + 1;
if (timeRemaining > 0) {
renderAlert(c, client.lng.format(client.lng.autoReconnectAlert, timeRemaining), colors[C_RED], colors[C_RED]);
} else {
renderAlert(c, client.lng.reconnectingAlert, colors[C_RED], colors[C_RED]);
}
} else if (client.gInf != none && client.gInf.rebootCountDown > 0) {
// Reboot warning.
timeRemaining = client.gInf.rebootCountDown;
renderAlert(c, client.lng.format(client.lng.rebootAlert, timeRemaining), colors[C_WHITE], baseHUDColor);
} else if (client.idleTimeRemaining >= 0 && client.idleTimeRemaining <client> 0) {
text = left(remaining, index);
remaining = mid(remaining, index + len(newLineToken));
} else {
text = remaining;
remaining = "";
}
c.strLen(text, textWidth, textHeight);
maxTextWidth = max(maxTextWidth, textWidth);
lineCount++;
}
windowWidth = maxTextWidth + 2 * alertBorderSize;
windowHeight = lineCount * textHeight + 2 * alertBorderSize;
cx = (c.clipX - windowWidth) / 2;
cy = (c.clipY - windowHeight) / 2;
// Render frame background.
c.style = ERenderStyle.STY_Translucent;
if ( (ChallengeHUD(player.myHUD).Opacity == 16) || !Level.bHighDetailMode )
C.Style = ERenderStyle.STY_Normal;
c.drawColor = baseColor * 0.4;
c.setPos(cx, cy);
c.drawTile(Texture'grad64', windowWidth, windowHeight, 0.0, 0.0, 64.0, 64.0);
// Render borders.
c.drawColor = baseColor * 0.8;
c.setPos(cx - 3.0, cy - 1.0);
c.drawTile(Texture'base', 2.0, windowHeight + 2.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx + 1.0 + windowWidth, cy - 1.0);
c.drawTile(Texture'base', 2.0, windowHeight + 2.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx - 3.0, cy - 2.0);
c.drawTile(Texture'base', hDefBarSize, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx - 3.0, cy + 1.0 + windowHeight);
c.drawTile(Texture'base', hDefBarSize, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx + 3.0 + windowWidth - hDefBarSize, cy - 2.0);
c.drawTile(Texture'base', hDefBarSize, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx + 3.0 + windowWidth - hDefBarSize, cy + 1.0 + windowHeight);
c.drawTile(Texture'base', hDefBarSize, 1.0, 0.0, 0.0, 1.0, 1.0);
// High detail animation effect.
if (level.bHighDetailMode) {
animIndex = (client.timeSeconds % alertAnimTime) / alertAnimTime;
c.drawColor = baseColor * (1.0 - animIndex);
dist = sin(animIndex * pi * 0.5) * alertAnimDist;
hBarSize = hDefBarSize + hDefBarSize * ((windowWidth + alertAnimDist) / windowWidth) * animIndex;
c.setPos(cx - 3.0 - dist, cy - 1.0 - dist);
c.drawTile(Texture'base', 2.0, windowHeight + 2.0 + 2 * dist, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx + 1.0 + windowWidth + dist, cy - 1.0 - dist);
c.drawTile(Texture'base', 2.0, windowHeight + 2.0 + 2 * dist, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx - 3.0 - dist, cy - 2.0 - dist);
c.drawTile(Texture'base', hBarSize, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx - 3.0 - dist, cy + 1.0 + windowHeight + dist);
c.drawTile(Texture'base', hBarSize, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx + 3.0 + windowWidth - hBarSize + dist, cy - 2.0 - dist);
c.drawTile(Texture'base', hBarSize, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(cx + 3.0 + windowWidth - hBarSize + dist, cy + 1.0 + windowHeight + dist);
c.drawTile(Texture'base', hBarSize, 1.0, 0.0, 0.0, 1.0, 1.0);
}
// Render text.
remaining = msg;
lineCount = 0;
c.drawColor = textColor;
while (remaining != "") {
index = instr(remaining, newLineToken);
if (index > 0) {
text = left(remaining, index);
remaining = mid(remaining, index + len(newLineToken));
} else {
text = remaining;
remaining = "";
}
c.setPos(cx + alertBorderSize, cy + alertBorderSize + lineCount * textHeight);
c.drawText(text, false);
lineCount++;
}
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Adds a message to the message HUD.
*  $PARAM     msg    The message that is to be displayed.
*  $PARAM     msgType  Message type identifier.
* Â $PARAM Â Â Â Â pri1 Â Â Replication info of the first player involved.
* Â $PARAM Â Â Â Â pri2 Â Â Replication info of the second player involved.
*
**************************************************************************************************/
simulated function message(string msg, name msgType, PlayerReplicationInfo pri1, PlayerReplicationInfo pri2) {
local int playerColor;
local int messageColor;
local bool bIsSpecSayMsg;
local PlayerReplicationInfo specPRI;
local GameReplicationInfo gri;
local int index;
local string locationName;
// Check if the message was send by a spectator using say.
if (msgType == 'Event' && instr(msg, ":") >= 0) {
// Get shortcut to the game replication info.
gri = player.gameReplicationInfo;
// Find a player.
while (index <arrayCount> len(pri1.playerName)) {
pri1 = gri.PRIArray[index];
}
} else {
bIsSpecSayMsg = true;
pri1 = gri.PRIArray[index];
}
}
index++;
}
}
// Check message type.
if (bIsSpecSayMsg) {
// Chat message. Special case: player is spec and using say (not teamsay).
if (pri1.talkTexture != none) {
faceImg = pri1.talkTexture;
}
addChatMsg(C_METAL, pri1.playerName $ ": ", C_METAL, mid(msg, len(pri1.playerName) + 1));
} else if (pri1 != none && msg != "" && (msgType == 'Say' || msgType == 'TeamSay')) {
// Chat message.
playerColor = getPlayerColor(pri1);
if (pri1.talkTexture != none) {
faceImg = pri1.talkTexture;
}
if (msgType == 'TeamSay') {
if (pri1.bIsSpectator && !pri1.bWaitingPlayer) {
messageColor = C_WHITE;
} else {
messageColor = playerColor;
}
if (!pri1.bIsSpectator) {
  if (pri1.playerLocation != none) {
    locationName = pri1.playerLocation.locationName;
  } else if (pri1.playerZone != none) {
locationName = pri1.playerZone.zoneName;
}
}
} else {
if (pri1.bIsSpectator && !pri1.bWaitingPlayer) {
messageColor = C_METAL;
} else {
messageColor = C_ORANGE;
}
}
if (locationName != "" && bShowPlayerLocation) {
addChatMsg(playerColor, pri1.playerName, C_CYAN, " (" $ locationName $ "): ", messageColor, msg);
} else {
addChatMsg(playerColor, pri1.playerName $ ": ", messageColor, msg);
}
} else if (msg != "") {
// Other message.
addColorizedMessage(msg, pri1, pri2);
}
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Adds a message to the area just below the chatbox. Before the message is added an
* Â Â Â Â Â Â Â Â attempt will be made to highlight player names. This is done by checking if the
* Â Â Â Â Â Â Â Â messages contain the names of the given player replication info objects.
*  $PARAM     msg  Message to add.
* Â $PARAM Â Â Â Â pri1 Â Replication info of the first player involved.
* Â $PARAM Â Â Â Â pri2 Â Replication info of the second player involved.
*
**************************************************************************************************/
simulated function addColorizedMessage(string msg, PlayerReplicationInfo pri1, PlayerReplicationInfo pri2) {
local string firstPlayerName;
local string secondPlayerName;
local int firstIndex;
local int secondIndex;
local int firstPlayerColor;
local int secondPlayerColor;
local string msgPart1;
local string msgPart2;
local string msgPart3;
local int msgColor;
local string tempPlayerName;
local int tempIndex;
local int tempPlayerColor;
// Get message color.
msgColor = class'NexgenUtil'.static.getMessageColor(msg);
if (msgColor <0>= 0 && (secondIndex < firstIndex || firstIndex <0>= 0 && secondIndex >= 0) {
msgPart1 = left(msg, firstIndex);
msgPart2 = mid(msg, firstIndex + len(firstPlayerName), secondIndex - firstIndex - len(firstPlayerName));
msgPart3 = mid(msg, secondIndex + len(secondPlayerName));
} else if (firstIndex >= 0) {
msgPart1 = left(msg, firstIndex);
msgPart2 = mid(msg, firstIndex + len(firstPlayerName));
secondPlayerName = "";
} else {
firstPlayerName = "";
secondPlayerName = "";
msgPart1 = msg;
}
// Add message.
addMsg(msgColor, msgPart1, firstPlayerColor, firstPlayerName, msgColor, msgPart2,
   secondPlayerColor, secondPlayerName, msgColor, msgPart3);
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Attemps to locate the indices of player names in the given message. To speed up
* Â Â Â Â Â Â Â Â the locating process you can pass the player replication info actors of the
* Â Â Â Â Â Â Â Â players that are most likely to be included in the message.
*  $PARAM     msg   The message which may contain player names.
* Â $PARAM Â Â Â Â pri1 Â Â Replication info of the first player involved.
* Â $PARAM Â Â Â Â pri2 Â Â Replication info of the second player involved.
* Â $PARAM Â Â Â Â index1 Â The location in the string where the first player name occurs.
* Â $PARAM Â Â Â Â index2 Â The location in the string where the second player name occurs.
* Â $ENSURE Â Â Â (index1 >= 0 ? pri1 != none : true) && (index2 >= 0 ? pri2 != none : true)
*
**************************************************************************************************/
simulated function getPlayerNameIndices(string msg, out PlayerReplicationInfo pri1,
                    out PlayerReplicationInfo pri2, out int index1,
                    out int index2) {
local PlayerReplicationInfo tmpPRI;
local GameReplicationInfo gri;
local int index;
local int nameIndex;
local int tmpIndex;
// Get shortcut to the game replication info.
gri = player.gameReplicationInfo;
// Initially no indices have been found.
index1 = -1;
index2 = -1;
// Check if the first PRI is actually in the message. This appears not to be the case for some
// messages (for example with the Stranglove weapon mod).
if (pri1 != none && instr(msg, pri1.playerName) < 0) {
pri1 = none;
}
// Swap player replication info's if needed.
if (pri1 == none && pri2 != none) {
pri1 = pri2;
pri2 = none;
} else if (pri1 != none && pri2 != none && len(pri2.playerName) > len(pri1.playerName)) {
// Ensure the longest playername is located first.
tmpPRI = pri1;
pri1 = pri2;
pri2 = tmpPRI;
}
// Get the position of the first player name in the message.
if (pri1 == none) {
// No PRI found, try to find one.
index = 0;
while (index <arrayCount>= 0 && (pri1 == none || len(tmpPRI.playerName) > len(pri1.playerName))) {
// Yes, no name has been found so far or a longer player name has been found.
pri1 = tmpPRI;
index1 = nameIndex;
}
// Continue with next player name.
index++;
}
} else {
// Already got PRI, just find the index of the name.
index1 = instr(msg, pri1.playerName);
}
// Get the position of the second player name in the message.
if (pri1 != none && pri2 == none) {
// No PRI found, try to find one.
index = 0;
while (index <arrayCount>=0 && nameIndex >= 0 && index1 <= nameIndex &&
  nameIndex <index1>= 0) {
nameIndex += index1 + len(pri1.playerName);
}
}
// Select PRI?
if (nameIndex >= 0 && (pri2 == none || len(tmpPRI.playerName) > len(pri2.playerName))) {
// Yes, no name has been found so far or a longer player name has been found.
pri2 = tmpPRI;
index2 = nameIndex;
}
// Continue with next player name.
index++;
}
} else if (pri2 != none) {
// Already got PRI, just find the index of the name.
nameIndex = instr(msg, pri2.playerName);
// Check for overlap.
if (index1 >= 0 && nameIndex >= 0 && index1 <= nameIndex && nameIndex <index1>= 0) {
nameIndex += index1 + len(pri1.playerName);
}
}
// Set index.
index2 = nameIndex;
}
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Adds a message to the chatbox. The message is split in several parts, so each can
* Â Â Â Â Â Â Â Â be displayed in a specified color.
* Â $PARAM Â Â Â Â col1 Â Color of the first part of the message.
* Â $PARAM Â Â Â Â text1 Â First part of the message.
* Â $PARAM Â Â Â Â col2 Â Color of the second part of the message.
* Â $PARAM Â Â Â Â text2 Â Second part of the message.
* Â $PARAM Â Â Â Â col3 Â Color of the third part of the message.
* Â $PARAM Â Â Â Â text3 Â Third part of the message.
* Â $PARAM Â Â Â Â col4 Â Color of the fourth part of the message.
* Â $PARAM Â Â Â Â text4 Â Fourth part of the message.
* Â $PARAM Â Â Â Â col5 Â Color of the fifth part of the message.
* Â $PARAM Â Â Â Â text5 Â Fifth part of the message.
*
**************************************************************************************************/
simulated function addChatMsg(int col1, string text1,
               optional int col2, optional string text2,
               optional int col3, optional string text3,
               optional int col4, optional string text4,
               optional int col5, optional string text5) {
local int index;
// Find position in messages list.
if (chatMsgCount < arrayCount(chatMessages)) {
index = chatMsgCount;
chatMsgCount++;
} else {
// List is full, shift messages.
for (index = 1; index < chatMsgCount; index++) {
chatMessages[index - 1] = chatMessages[index];
}
index = chatMsgCount - 1;
}
// Store message.
chatMessages[index].text[0] = text1;
chatMessages[index].text[1] = text2;
chatMessages[index].text[2] = text3;
chatMessages[index].text[3] = text4;
chatMessages[index].text[4] = text5;
chatMessages[index].col[0] = col1;
chatMessages[index].col[1] = col2;
chatMessages[index].col[2] = col3;
chatMessages[index].col[3] = col4;
chatMessages[index].col[4] = col5;
chatMessages[index].timeStamp = timeSeconds;
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Adds a message to the area below the chatbox. The message is split in several
* Â Â Â Â Â Â Â Â parts, so each can be displayed in a specified color.
* Â $PARAM Â Â Â Â col1 Â Color of the first part of the message.
* Â $PARAM Â Â Â Â text1 Â First part of the message.
* Â $PARAM Â Â Â Â col2 Â Color of the second part of the message.
* Â $PARAM Â Â Â Â text2 Â Second part of the message.
* Â $PARAM Â Â Â Â col3 Â Color of the third part of the message.
* Â $PARAM Â Â Â Â text3 Â Third part of the message.
* Â $PARAM Â Â Â Â col4 Â Color of the fourth part of the message.
* Â $PARAM Â Â Â Â text4 Â Fourth part of the message.
* Â $PARAM Â Â Â Â col5 Â Color of the fifth part of the message.
* Â $PARAM Â Â Â Â text5 Â Fifth part of the message.
*
**************************************************************************************************/
simulated function addMsg(int col1, string text1,
             optional int col2, optional string text2,
             optional int col3, optional string text3,
             optional int col4, optional string text4,
             optional int col5, optional string text5) {
local int index;
// Find position in messages list.
if (msgCount < arrayCount(messages)) {
index = msgCount;
msgCount++;
} else {
// List is full, shift messages.
for (index = 1; index < msgCount; index++) {
messages[index - 1] = messages[index];
}
index = msgCount - 1;
}
// Store message.
messages[index].text[0] = text1;
messages[index].text[1] = text2;
messages[index].text[2] = text3;
messages[index].text[3] = text4;
messages[index].text[4] = text5;
messages[index].col[0] = col1;
messages[index].col[1] = col2;
messages[index].col[2] = col3;
messages[index].col[3] = col4;
messages[index].col[4] = col5;
messages[index].timeStamp = timeSeconds;
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Initializes/updates the variables used in the rendering procedure.
*  $PARAM     c  Canvas object that provides the drawing capabilities.
* Â $REQUIRE Â Â Â c != none
* Â $ENSURE Â Â Â c.font != none
*
**************************************************************************************************/
simulated function setup(Canvas c) {
local int index;
local bool bUpdateBase;
// Make sure the font ain't none.
if (baseFont == none) baseFont = getStaticSmallestFont(c.clipX);
c.font = baseFont;
// Get local PlayerPawn.
player = c.viewport.actor;
/*
// Set base hud color.
if (player == none || player.playerReplicationInfo == none || player.gameReplicationInfo == none) {
baseHUDColor = baseColors[5];
} else if (player.playerReplicationInfo.bIsSpectator &&
  !player.playerReplicationInfo.bWaitingPlayer) {
baseHUDColor = baseColors[4];
} else if (!player.gameReplicationInfo.bTeamGame &&
   ChallengeHUD(player.myHUD) != none) {
baseHUDColor = ChallengeHUD(player.myHUD).favoriteHUDColor * 15.9;
} else if (0 <= player.playerReplicationInfo.team && player.playerReplicationInfo.team <= 3) {
baseHUDColor = baseColors[player.playerReplicationInfo.team];
} else {
baseHUDColor = baseColors[5];
}
*/
// Prevent redundant setups.
if (lastSetupTime == level.timeSeconds) {
return;
}
// Timer control.
timeSeconds += (level.timeSeconds - lastLevelTimeSeconds) / level.timeDilation;
lastLevelTimeSeconds = level.timeSeconds;
// Check if the base variables need to be updated.
bUpdateBase = lastResX != c.clipX ||
       lastResY != c.clipY;
// Update HUD base variables.
if (bUpdateBase) {
// Set base hud color.
    baseHUDColor = ChallengeHUD(player.myHUD).HUDColor; // use the HUD colour set in UT prefs
// General variables.
baseFont = getStaticSmallestFont(c.clipX);
c.font = baseFont;
c.strLen("Online [00:00]", minPanelWidth, baseFontHeight);
lastResX = c.clipX;
lastResY = c.clipY;
// Message box info.
msgBoxWidth = int(c.clipX * 0.75);
msgBoxLineHeight = int(baseFontHeight + 4.0);
msgBoxHeight = msgBoxLineHeight * arrayCount(chatMessages);
}
// Remove expired messages.
if (chatMsgCount > 0 && timeSeconds - chatMessages[0].timeStamp > chatMessageLifeTime) {
for (index = 1; index < chatMsgCount; index++) {
chatMessages[index - 1] = chatMessages[index];
}
chatMsgCount--;
if (chatMsgCount == 0) {
faceImg = none;
}
}
if (msgCount > 0 && timeSeconds - messages[0].timeStamp > messageLifeTime) {
for (index = 1; index < msgCount; index++) {
messages[index - 1] = messages[index];
}
msgCount--;
}
lastSetupTime = level.timeSeconds;
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Renders the Nexgen HUD. Called before anything of the game HUD has been drawn.
*  $PARAM     c  Canvas object that provides the drawing capabilities.
* Â $REQUIRE Â Â Â c != none
*
**************************************************************************************************/
simulated function preRenderHUD(Canvas c) {
local int index;
setup(c);
for (index = 0; index < arrayCount(extensions); index++) {
if (extensions[index] != none) {
extensions[index].preRender(c);
}
}
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Renders the Nexgen HUD. Called after everything of the game HUD has been drawn.
*  $PARAM     c  Canvas object that provides the drawing capabilities.
* Â $REQUIRE Â Â Â c != none
*
**************************************************************************************************/
simulated function postRenderHUD(Canvas c) {
local int index;
// Render the message box.
if (client.bUseNexgenMessageHUD) {
renderMessageBox(c);
}
self.postRender(c);
// Render HUD extensions.
for (index = 0; index < arrayCount(extensions); index++) {
if (extensions[index] != none) {
extensions[index].postRender(c);
}
}
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Renders the chat message box.
*  $PARAM     c  Canvas object that provides the drawing capabilities.
* Â $REQUIRE Â Â Â c != none
*
**************************************************************************************************/
simulated function renderMessageBox(Canvas c) {
local float panelWidth;
local float panelHeight;
local PanelInfo serverState;
local PanelInfo clientState;
local int index;
local float cx;
local float cy;
// Initialize.
panelHeight = int((msgBoxHeight - 3.0) / 2.0);
serverState = getServerState();
clientState = getClientState();
panelWidth = fMax(getPanelWidth(serverState, c, panelHeight), getPanelWidth(clientState, c, panelHeight));
// Background.
c.style = ERenderStyle.STY_Translucent;
if ( (ChallengeHUD(player.myHUD).Opacity == 16) || !Level.bHighDetailMode )
C.Style = ERenderStyle.STY_Normal;
c.drawColor = baseHUDColor * 0.4;
c.setPos(1.0, 1.0);
c.drawTile(Texture'grad64', msgBoxWidth - 2.0, msgBoxHeight - 2.0, 0.0, 0.0, 64.0, 64.0);
// Borders.
c.drawColor = baseHUDColor * 0.8;
c.setPos(0.0, 0.0);
c.drawTile(Texture'base', msgBoxWidth, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(0.0, msgBoxHeight - 1.0);
c.drawTile(Texture'base', msgBoxWidth, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(msgBoxWidth - 1.0 - panelWidth, panelHeight + 1.0);
c.drawTile(Texture'base', panelWidth, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(0.0, 1.0);
c.drawTile(Texture'base', 1.0, msgBoxHeight - 2.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(msgBoxWidth - 1.0, 1.0);
c.drawTile(Texture'base', 1.0, msgBoxHeight - 2.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(msgBoxHeight - 1.0, 1.0);
c.drawTile(Texture'base', 1.0, msgBoxHeight - 2.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(msgBoxWidth - 2.0 - panelWidth, 1.0);
c.drawTile(Texture'base', 1.0, msgBoxHeight - 2.0, 0.0, 0.0, 1.0, 1.0);
// Panels.
renderPanel(serverState, c, panelHeight, msgBoxWidth - panelWidth - 1.0, 1.0);
renderPanel(clientState, c, panelHeight, msgBoxWidth - panelWidth - 1.0, panelHeight + 2.0);
// Face image.
if (faceImg != none) {
c.style = ERenderStyle.STY_Normal;
c.drawColor = blankColor;
c.setPos(1.0, 1.0);
c.drawTile(faceImg, msgBoxHeight - 2.0, msgBoxHeight - 2.0, 0.0, 0.0, faceImg.uSize, faceImg.vSize);
  c.style = ERenderStyle.STY_Translucent;
    c.drawColor = baseHUDColor * 0.25;
    c.setPos(1.0, 1.0);
    c.drawTile(Texture'LadrStatic.Static_a00', msgBoxHeight - 2.0, msgBoxHeight - 2.0, 0.0, 0.0,
         Texture'LadrStatic.Static_a00'.uSize, Texture'LadrStatic.Static_a00'.vSize);
}
// Typing prompt.
if (player.player.console.bTyping) {
renderTypingPromt(c, "(>" $ player.player.console.typedStr $ "_");
}
// Chat messages.
cx = msgBoxHeight + 2.0;
cy = (msgBoxLineHeight - baseFontHeight) / 2.0;
for (index = 0; index < chatMsgCount; index++) {
renderMessage(c, cx, cy, chatMessages[index]);
cy += msgBoxLineHeight;
}
// Other messages.
cx = 1.0;
cy = msgBoxHeight + 2.0;
if (player.player.console.bTyping) {
cy += msgBoxLineHeight;
}
for (index = 0; index < msgCount; index++) {
renderMessage(c, cx, cy, messages[index]);
cy += baseFontHeight;
}
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Renders the typing promt for the chat message box.
*  $PARAM     c  Canvas object that provides the drawing capabilities.
* Â $REQUIRE Â Â Â c != none
*
**************************************************************************************************/
simulated function renderTypingPromt(Canvas c, string msg) {
local float msgOffset;
// Background.
c.style = ERenderStyle.STY_Translucent;
if ( (ChallengeHUD(player.myHUD).Opacity == 16) || !Level.bHighDetailMode )
c.Style = ERenderStyle.STY_Normal;
c.drawColor = baseHUDColor * 0.4;
c.setPos(1.0, msgBoxHeight);
c.drawTile(Texture'grad32', msgBoxWidth - 2.0, msgBoxLineHeight - 1.0, 0.0, 0.0, 32.0, 32.0);
// Borders.
c.drawColor = baseHUDColor * 0.8;
c.setPos(0.0, msgBoxHeight + msgBoxLineHeight - 1.0);
c.drawTile(Texture'base', msgBoxWidth, 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(0.0, msgBoxHeight);
c.drawTile(Texture'base', 1.0, msgBoxLineHeight - 1.0, 0.0, 0.0, 1.0, 1.0);
c.setPos(msgBoxWidth - 1.0, msgBoxHeight);
c.drawTile(Texture'base', 1.0, msgBoxLineHeight - 1.0, 0.0, 0.0, 1.0, 1.0);
// Message.
msgOffset = (msgBoxLineHeight - baseFontHeight) / 2.0;
c.font = baseFont;
c.style = ERenderStyle.STY_Normal;
c.drawColor = colors[C_WHITE];
c.setPos(msgOffset, msgOffset + msgBoxHeight);
c.drawText(msg, false);
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Renders the specified message.
*  $PARAM     c   Canvas object that provides the drawing capabilities.
*  $PARAM     x   Horizontal offset.
*  $PARAM     y   Vertical offset.
*  $PARAM     msg  The message that is to be rendered.
* Â $REQUIRE Â Â Â c != none && msg != none
*
**************************************************************************************************/
simulated function renderMessage(Canvas c, float x, float y, MessageInfo msg) {
local float cx;
local int msgIndex;
local float msgWidth;
local float msgHeight;
local float lifeTime;
local float blinkFactor;
local float blinkIntensity;
// Check if the message should blink.
lifeTime = (timeSeconds - msg.timeStamp);
if (bFlashMessages && lifeTime < messageBlinkTime) {
blinkFactor = (1.0 + cos(lifeTime * 2 * pi * messageBlinkRate)) / 2.0;
blinkIntensity = (1.0 - blinkFactor) * 255.0;
}
// Render message.
cx = x;
c.font = baseFont;
c.style = ERenderStyle.STY_Normal;
for (msgIndex = 0; msgIndex < 5; msgIndex++) {
c.setPos(cx, y);
c.drawColor = colors[msg.col[msgIndex]];
if (bFlashMessages && lifeTime < messageBlinkTime) {
c.drawColor = c.drawColor * blinkColorDamp;
c.drawColor.r = int(float(c.drawColor.r) * blinkFactor + blinkIntensity);
c.drawColor.g = int(float(c.drawColor.g) * blinkFactor + blinkIntensity);
c.drawColor.b = int(float(c.drawColor.b) * blinkFactor + blinkIntensity);
}
c.drawText(msg.text[msgIndex], false);
c.strLen(msg.text[msgIndex], msgWidth, msgHeight);
cx += msgWidth;
}
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Retrieves the current state of the server. The result will be stored in a
* Â Â Â Â Â Â Â Â PanelInfo struct so it can be immediately rendered.
* Â $RETURN Â Â Â The current server state.
* Â $ENSURE Â Â Â result != none
*
**************************************************************************************************/
simulated function PanelInfo getServerState() {
local PanelInfo pInf;
local string stateInfo;
local int remainingTime;
local int minutes, seconds;
local name stateType;
local byte bBlink;
local int index;
// Check current state.
if (!client.bInitialized) {
// Loading Nexgen.
stateType = SS_Offline;
pInf.text = client.lng.loadingState;
pInf.textCol = colors[C_WHITE];
pInf.bBlink = true;
pInf.icon = Texture'offlineIcon';
pInf.solidIcon = Texture'offlineIcon2';
} else if (player.bBadConnectionAlert) {
// Server is offline.
stateType = SS_Offline;
if (client.sConf.autoReconnectTime > 0) {
stateInfo = string(max(0, 1 + client.sConf.autoReconnectTime - (client.timeSeconds - client.badConnectionSince)));
pInf.text = client.lng.format(client.lng.offlineStateRCN, stateInfo);
} else {
pInf.text = client.lng.offlineState;
}
pInf.textCol = colors[C_RED];
pInf.icon = Texture'offlineIcon';
pInf.solidIcon = Texture'offlineIcon2';
} else if (client.gInf.gameState == client.gInf.GS_Waiting) {
// Waiting for players.
stateType = SS_Waiting;
if (client.gInf.countDown <= 0 || !client.sConf.enableNexgenStartControl) {
pInf.text = client.lng.waitingStateUnknownTime;
} else {
pInf.text = client.lng.format(client.lng.waitingState, client.gInf.countDown);
}
pInf.textCol = colors[C_RED];
pInf.icon = Texture'waitIcon';
pInf.solidIcon = Texture'waitIcon2';
} else if (client.gInf.gameState == client.gInf.GS_Ready) {
// Ready to start the game.
stateType = SS_Ready;
if (client.gInf.bTournamentMode) {
pInf.text = client.lng.format(client.lng.readySignalWaitState,
               client.gInf.numReady,
               client.gInf.numRequiredReady);
} else {
pInf.text = client.lng.readyState;
}
pInf.textCol = colors[C_ORANGE];
pInf.bBlink = true;
pInf.icon = Texture'waitIcon';
pInf.solidIcon = Texture'waitIcon2';
} else if (client.gInf.gameState == client.gInf.GS_Starting) {
// Game is starting.
stateType = SS_Starting;
pInf.text = client.lng.format(client.lng.startingState, client.gInf.countDown);
pInf.textCol = colors[C_YELLOW];
pInf.bBlink = true;
pInf.icon = Texture'waitIcon';
pInf.solidIcon = Texture'waitIcon2';
} else if (client.gInf.gameState == client.gInf.GS_Ended) {
// Game has ended.
stateType = SS_Ended;
pInf.text = client.lng.endedState;
pInf.textCol = colors[C_YELLOW];
pInf.icon = Texture'serverIcon';
pInf.solidIcon = Texture'serverIcon2';
} else if (level.pauser != "") {
// Game has been paused.
stateType = SS_Paused;
pInf.text = client.lng.pausedState;
pInf.textCol = colors[C_METAL];
pInf.bBlink = true;
pInf.icon = Texture'offlineIcon';
pInf.solidIcon = Texture'offlineIcon2';
} else if (client.sConf.matchModeActivated) {
// Match in progress.
stateType = SS_Match;
remainingTime = player.gameReplicationInfo.remainingTime ;
if (remainingTime > 0 && (remainingTime / matchInfoSwitchTime) % 2 == 1) {
minutes = remainingTime / secPerMinute;
seconds = remainingTime % secPerMinute;
stateInfo = right("0" $ minutes, 2) $ ":" $ right("0" $ seconds, 2);
} else {
stateInfo = client.sConf.currentMatch $ "/" $ client.sConf.matchesToPlay;
}
pInf.text = client.lng.format(client.lng.matchState, stateInfo);
pInf.textCol = colors[C_YELLOW];
pInf.icon = Texture'matchIcon';
pInf.solidIcon = Texture'matchIcon2';
} else {
// Game in progress.
stateType = SS_Normal;
remainingTime = player.gameReplicationInfo.remainingTime ;
if (remainingTime > 0) {
minutes = remainingTime / secPerMinute;
seconds = remainingTime % secPerMinute;
stateInfo = right("0" $ minutes, 2) $ ":" $ right("0" $ seconds, 2);
} else {
stateInfo = right("0" $ level.hour, 2) $ ":" $ right("0" $ level.minute, 2);
}
pInf.text = client.lng.format(client.lng.onlineState, stateInfo);
pInf.textCol = colors[C_GREEN];
pInf.icon = Texture'serverIcon';
pInf.solidIcon = Texture'serverIcon2';
}
// Allow plugins to modify the state panel.
bBlink = byte(pInf.bBlink);
while (index < arrayCount(client.clientCtrl) && client.clientCtrl[index] != none) {
if (client.clientCtrl[index].bCanModifyHUDStatePanel) {
client.clientCtrl[index].modifyServerState(stateType, pInf.text, pInf.textCol,
                     pInf.icon, pInf.solidIcon, bBlink);
}
index++;
}
pInf.bBlink = bool(bBlink);
// Return state panel.
return pInf;
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Retrieves the current state of the client. The result will be stored in a
* Â Â Â Â Â Â Â Â PanelInfo struct so it can be immediately rendered.
* Â $RETURN Â Â Â The current client state.
* Â $ENSURE Â Â Â result != none
*
**************************************************************************************************/
simulated function PanelInfo getClientState() {
local PanelInfo pInf;
local string stateInfo;
local byte protectTime;
local name stateType;
local byte bBlink;
local int index;
pInf.icon = Texture'playerIcon';
pInf.solidIcon = Texture'playerIcon2';
// Check current state.
if (!client.loginComplete) {
// Logging in to the server.
stateType = CS_Login;
pInf.text = client.lng.loginState;
pInf.textCol = colors[C_WHITE];
pInf.icon = Texture'LoginIcon';
pInf.solidIcon = Texture'LoginIcon2';
pInf.bBlink = true;
} else if (client.idleTimeRemaining >= 0) {
// Idle / camping.
stateType = CS_Idle;
stateInfo = string(client.idleTimeRemaining);
pInf.text = client.lng.format(client.lng.idleState, stateInfo);
pInf.textCol = colors[C_CYAN];
pInf.icon = Texture'idleIcon';
pInf.solidIcon = Texture'idleIcon2';
pInf.bBlink = true;
} else if (client.spawnProtectionTime > 0 ||
     client.tkDmgProtectionTime > 0 ||
     client.tkPushProtectionTime > 0) {
// Client is damage protected.
stateType = CS_Protected;
protectTime = max(max(client.spawnProtectionTime,
           client.tkDmgProtectionTime),
           client.tkPushProtectionTime);
pInf.text = client.lng.format(client.lng.protectedState, protectTime);
if (client.tkDmgProtectionTime > 0) {
pInf.textCol = colors[C_ORANGE];
} else {
pInf.textCol = colors[C_YELLOW];
}
pInf.icon = Texture'shieldIcon';
pInf.solidIcon = Texture'shieldIcon2';
} else if (client.bMuted || client.gInf.bMuteAll) {
// Client is muted.
stateType = CS_Muted;
pInf.text = client.lng.mutedState;
pInf.textCol = colors[C_RED];
pInf.icon = Texture'mutedIcon';
pInf.solidIcon = Texture'mutedIcon2';
} else if (player.health <= 0) {
// Player is dead.
stateType = CS_Dead;
pInf.text = client.lng.deadState;
pInf.textCol = colors[C_RED];
} else {
// Normal state.
stateType = CS_Normal;
pInf.text = client.title;
if (client.bSpectator) {
pInf.textCol = colors[C_CYAN];
pInf.icon = Texture'specIcon';
pInf.solidIcon = Texture'specIcon2';
} else {
pInf.textCol = colors[C_GREEN];
}
}
// Allow plugins to modify the state panel.
bBlink = byte(pInf.bBlink);
while (index < arrayCount(client.clientCtrl) && client.clientCtrl[index] != none) {
if (client.clientCtrl[index].bCanModifyHUDStatePanel) {
client.clientCtrl[index].modifyClientState(stateType, pInf.text, pInf.textCol,
                     pInf.icon, pInf.solidIcon, bBlink);
}
index++;
}
pInf.bBlink = bool(bBlink);
// Return state panel.
return pInf;
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Returns the space necessary for the given panel if it is to be rendered.
*  $PARAM     pInf     Panel contents.
*  $PARAM     c       Canvas object that provides the drawing capabilities.
*  $PARAM     panelHeight  Vertical space available for the panel (in pixels).
* Â $REQUIRE Â Â Â pInf != none && c != none && panelHeight > 0
* Â $RETURN Â Â Â
* Â $ENSURE Â Â Â result > 0
*
**************************************************************************************************/
simulated function float getPanelWidth(PanelInfo pInf, canvas c, float panelHeight) {
local float separatorWidth;
local float width;
local float temp;
// Get text width.
separatorWidth = int(baseFontHeight * 0.4);
c.font = baseFont;
c.strLen(pInf.text, width, temp);
width = fMax(minPanelWidth, width);
// And add icon and separator width.
if (pInf.icon == none) {
width += 2.0 * separatorWidth;
} else {
if (iconSize > panelHeight) {
width += panelHeight + 3.0 * separatorWidth;
} else {
width += iconSize + 3.0 * separatorWidth;
}
}
return width;
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Renders a panel with the specified contents at the given location.
*  $PARAM     pInf     Panel contents.
*  $PARAM     c       Canvas object that provides the drawing capabilities.
*  $PARAM     panelHeight  Vertical space available for the panel (in pixels).
*  $PARAM     x       Horizontal offset.
*  $PARAM     y       Vertical offset.
* Â $REQUIRE Â Â Â pInf != none && c != none && panelHeight > 0
*
**************************************************************************************************/
simulated function renderPanel(PanelInfo pInf, canvas c, float panelHeight, float x, float y) {
local float separatorWidth;
local float cx;
local float cy;
local float iconHeight;
local float lifeTime;
local float blinkFactor;
local float blinkIntensity;
if (pInf.bBlink) {
blinkFactor = (1.0 + cos(timeSeconds * 2 * pi * panelBlinkRate)) / 2.0;
blinkIntensity = (1.0 - blinkFactor) * 255.0;
}
separatorWidth = int(baseFontHeight * 0.4);
// Draw icon.
cx = x + separatorWidth;
if (pInf.icon != none) {
if (iconSize > panelHeight) {
iconHeight = panelHeight;
cy = y;
} else {
iconHeight = iconSize;
cy = y + int((panelHeight - iconSize) / 2.0);
}
c.style = ERenderStyle.STY_Translucent;
if ( (ChallengeHUD(player.myHUD).Opacity == 16) || !Level.bHighDetailMode )
 C.Style = ERenderStyle.STY_Normal;
c.drawColor = blankColor;
c.setPos(cx, cy);
c.drawTile(pInf.icon, iconHeight, iconHeight, 0.0, 0.0, iconSize, iconSize);
if (pInf.solidIcon != none) {
c.style = ERenderStyle.STY_Normal;
c.setPos(cx, cy);
c.drawTile(pInf.solidIcon, iconHeight, iconHeight, 0.0, 0.0, iconSize, iconSize);
}
cx += separatorWidth + iconHeight;
}
// Draw the text.
cy = y + (panelHeight - baseFontHeight) / 2.0;
c.style = ERenderStyle.STY_Normal;
c.drawColor = pInf.textCol;
if (pInf.bBlink) {
c.drawColor = c.drawColor * blinkColorDamp;
c.drawColor.r = int(float(c.drawColor.r) * blinkFactor + blinkIntensity);
c.drawColor.g = int(float(c.drawColor.g) * blinkFactor + blinkIntensity);
c.drawColor.b = int(float(c.drawColor.b) * blinkFactor + blinkIntensity);
}
c.setPos(cx, cy);
c.font = baseFont;
c.drawText(pInf.text, false);
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Returns the color for the specified player.
*  $PARAM     pri  Replication info of the player whose color is to be returned.
* Â $RETURN Â Â Â The color of the player (index in the base color palette).
* Â $ENSURE Â Â Â 0 <= result && result < arrayCount(colors)
*
**************************************************************************************************/
simulated function int getPlayerColor(PlayerReplicationInfo pri) {
local int colorNum;
if (pri.bIsSpectator && !pri.bWaitingPlayer) {
colorNum = C_METAL;
} else if (0 <= pri.team && pri.team <= 3) {
colorNum = pri.team;
} else {
colorNum = C_WHITE;
}
return colorNum;
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Registers a new HUD extension so that it will receive preRender and postRender
* Â Â Â Â Â Â Â Â calls.
*  $PARAM     extension  The HUD extenstion that is to be added.
* Â $REQUIRE Â Â Â extension != none
*
**************************************************************************************************/
simulated function addHUDExtension(NexgenHUDExtension extension) {
local int index;
local bool bFound;
while (!bFound && index < arrayCount(extensions)) {
if (extensions[index] == none) {
extensions[index] = extension;
bFound = true;
} else {
index++;
}
}
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Retrieves a small font size for the specified canvas width.
*  $PARAM     width  The width of the canvas in pixels.
* Â $RETURN Â Â Â A small font.
* Â $ENSURE Â Â Â result != none
*
**************************************************************************************************/
static function Font getStaticSmallestFont(float width) {
if (width < 640) {
return Font'SmallFont';
} else if (width < 800) {
return Font(DynamicLoadObject("LadderFonts.UTLadder10", class'Font'));
} else if (width < 1024) {
return Font(DynamicLoadObject("LadderFonts.UTLadder12", class'Font'));
} else {
return Font(DynamicLoadObject("LadderFonts.UTLadder14", class'Font'));
}
}
/***************************************************************************************************
*
* Â $DESCRIPTION Â Default properties block.
*
**************************************************************************************************/
defaultproperties
{
  blankColor=(R=255,G=255,B=255)
  baseColors(0)=(R=255,G=16,B=16)
  baseColors(1)=(R=16,G=16,B=255)
  baseColors(2)=(R=16,G=250,B=16)
  baseColors(3)=(R=250,G=250,B=16)
  baseColors(4)=(R=150,G=150,B=255)
  baseColors(5)=(R=255,G=255,B=255)
  Colors(0)=(R=250,G=90,B=90)
  Colors(1)=(R=90,G=90,B=255)
  Colors(2)=(R=90,G=250,B=90)
  Colors(3)=(R=250,G=250,B=90)
  Colors(4)=(R=255,G=255,B=255)
  Colors(6)=(R=250,G=50,B=200)
  Colors(7)=(R=50,G=250,B=250)
  Colors(=(R=150,G=150,B=250)
  Colors(9)=(R=250,G=150,B=50)
  Colors(10)=(R=150,G=10)
}
|
|
|
|