## Engine
Class HUD

source: C:\XIII\Engine\Classes\HUD.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.HUD

Direct Known Subclasses:XIIIBaseHud

class HUD
extends Engine.Actor

    //=============================================================================
    // HUD: Superclass of the heads-up display.
    //=============================================================================

Variables
`font` | `BigFont` Big system font.
`Texture` | `BulletIconTex` Background ammo
`string` | `ConnectingMessage` To display time left with warning colors
`UpMargin,` | `DownMargin` for TV security draw, in
`Weapon` | `DrawnWeapon` Weapon to draw info on screen
`Texture` | `FondMsg` to be used by HUDMsg(s) & HUDDlg(s)
`string` | `HUDConfigWindowType` Largest system font.
`bool` | `HelpDisplay` string for drawing clips left in weapon
`color` | `HudBackGroundColor` to be used by HUDMsg(s) & HUDDlg(s)
`color` | `HudBasicColor` to be used by HUDMsg(s) & HUDDlg(s)
`Texture` | `HudIcons` one-texture for player info display
`Texture` | `HudWIcons` one-texture Icons for weapon list display
`color` | `HudWarningColor` to be used by HUDMsg(s) & HUDDlg(s)
`float` | `IconSize` Floats to track the current ScreenPosition.
`font` | `LargeFont` Largest system font.
`LifeDisplayWidth,` | `LifeDisplayHeight` used to memorize some StrLen params
`string` | `LoadingMessage` To display time left with warning colors
`font` | `MedFont` Medium system font.
`float` | `MessageLife[4]` Should the hud display itself.
`color` | `OrangeColor,BlackColor,WhiteColor,GoldColor,RedColor,BlueColor,GreenColor,` used to memorize some StrLen params
`string` | `PausedMessage` To display time left with warning colors
`Pawn` | `PawnOwner` XIIIPawn of the PlayerOwner controller
`PlayerController` | `PlayerOwner` always the actual owner
`string` | `PrecachingMessage` To display time left with warning colors
`Texture` | `RoundBackGroundTex` Icon for backGroung
`string` | `SavingMessage` To display time left with warning colors
`ScoreBoard` | `Scoring` always the actual owner
`Texture` | `SixSenseDisplayTex` texture used to show the SixSense is active
`Texture` | `SixSenseTex` texture used to 'display' sounds
`font` | `SmallFont` Small system font.
`string` | `TextMessages[4]` Should the hud display itself.
`XP,` | `YP` Floats to track the current ScreenPosition.
`bool` | `bBadConnectionAlert` display warning about bad connection
`bool` | `bDrawChrono` To display time left
`bool` | `bDrawChronoWithWarningColors` To display time left with warning colors
`bool` | `bDrawSixSense` To display SixSense SFX
`bool` | `bHideCenterMessages` don't draw centered messages (screen center being used)
`bool` | `bHideHUD` Should the hud display itself.
`bool` | `bMessageBeep` display warning about bad connection
`bool` | `bShowDebugInfo` if true, show properties of current ViewTarget
`bool` | `bShowScores` always the actual owner
`bool` | `bViewPlayer` if the viewtarget is the player (used to prevent some drawing while viewing another actor)
`float` | `fDrawChronoTimer` timer used w/ the bool above.
`float` | `fDrawSixSenseTimer[5]` timer used w/ the bool bDrawSixSense
`float` | `fDrawWeaponsTimer` timer used w/ the bool above.
`HUD` | `nextHUD` list of huds which render to the canvas
`string` | `sAmmoRef` string for drawing clips left in weapon
`string` | `sChronoString` string to display (time left)
`vector` | `vSixSensePos[5]` on-screen Position to draw SixSense SFX

Function Summary
`void` | `ClearMessage(out HUDLocalizedMessage)`
    //=============================================================================
    // Message manipulation
`void` | `CopyMessage(out HUDLocalizedMessage, HUDLocalizedMessage M2)`
`void` | `DisplayBadConnectionAlert(Canvas C)`
    /* DisplayBadConnectionAlert()
    Warn user that net connection is bad
    */
`void` | `DisplayMessages(Canvas Canvas)`
    /* DisplayMessages() - display current messages
    */
`simulated` | `DisplayProgressMessage(Canvas Canvas)`
    /* Display Progress Messages
    display progress messages in center of screen
    */
`void` | `Draw3DLine(vector Start, vector End, color LineColor)`
    /* Draw3DLine()
    draw line in world space. Should be used when engine calls RenderWorldOverlays() event.
    */
`void` | `DrawAmmo(Canvas C, String ItemText)`
`void` | `DrawHUD(Canvas Canvas)`
    /* DrawHUD() Draw HUD elements on canvas.
    */
`bool` | `DrawLevelAction(Canvas C)`
    /* Draw the Level Action
    */
`void` | `DrawPlayerInfo(Canvas C)`
`simulated` | `DrawRoute()`
`void` | `DrawStdBackground(Canvas C, float Height, float CenterWidth)`
`void` | `DrawWeaponIconsList(Canvas C)`
    //____________________________________________________________________
`void` | `DrawWeaponsList(Canvas C)`
`void` | `HideScores()`
`simulated` | `Message(PlayerReplicationInfo PRI, string Msg, name MsgType)`
    //=============================================================================
    // Messaging.
`simulated` | `PlayReceivedMessage(string S, string PName, ZoneInfo PZone)`
`void` | `PlayStartupMessage(byte Stage)`
    /* ShowUpgradeMenu()
    Event called when the engine version is less than the MinNetVer of the server you are trying
    to connect with.
    */
`simulated` | `PostBeginPlay()`
`void` | `PrintActionMessage(Canvas C, string BigMessage)`
    /*  Print a centered level action message with a drop shadow.
    */
`bool` | `ProcessKeyEvent(int Key, int Action, FLOAT Delta)`
`void` | `ShowDebug()`
    /* toggles displaying properties of player's current viewtarget
    */
`void` | `ShowScores()`
    /* toggles displaying scoreboard
    */
`void` | `UseHugeFont(Canvas Canvas)`
`void` | `UseLargeFont(Canvas Canvas)`
`void` | `UseMediumFont(Canvas Canvas)`
`void` | `UseSmallFont(Canvas Canvas)`
    //=============================================================================
    // Font Selection.

Source Code

    00001	//=============================================================================
    00002	// HUD: Superclass of the heads-up display.
    00003	//=============================================================================
    00004	class HUD extends Actor
    00005		native
    00006		config(user);
    00007
    00008	//=============================================================================
    00009	// Variables.
    00010
    00011	#exec Texture Import File=Textures\Border.pcx COMPRESS=DXT1
    00012
    00013	//#exec new TrueTypeFontFactory PACKAGE="Engine" Name=MediumFont FontName="Arial Bold" Height=16 AntiAlias=1 CharactersPerPage=128
    00014	//#exec new TrueTypeFontFactory PACKAGE="Engine" Name=SmallFont FontName="Terminal" Height=10 AntiAlias=0 CharactersPerPage=256
    00015
    00016	// Stock fonts.
    00017	var font SmallFont;             // Small system font.
    00018	var font MedFont;               // Medium system font.
    00019	var font BigFont;               // Big system font.
    00020	var font LargeFont;             // Largest system font.
    00021
    00022	var string HUDConfigWindowType;
    00023	var HUD nextHUD;                // list of huds which render to the canvas
    00024	var PlayerController PlayerOwner; // always the actual owner
    00025
    00026	var ScoreBoard Scoring;
    00027	var bool bShowScores;
    00028	var bool bShowDebugInfo;        // if true, show properties of current ViewTarget
    00029	var bool bHideCenterMessages;   // don't draw centered messages (screen center being used)
    00030	var bool bBadConnectionAlert;   // display warning about bad connection
    00031	var() config bool bMessageBeep;
    00032	var bool bViewPlayer;           // if the viewtarget is the player (used to prevent some drawing while viewing another actor)
    00033	var bool bDrawChrono; // To display time left
    00034	var bool bDrawSixSense;           // To display SixSense SFX
    00035	var bool bDrawChronoWithWarningColors; // To display time left with warning colors
    00036
    00037	var localized string LoadingMessage;
    00038	var localized string SavingMessage;
    00039	var localized string ConnectingMessage;
    00040	var localized string PausedMessage;
    00041	var localized string PrecachingMessage;
    00042
    00043	var bool bHideHUD;              // Should the hud display itself.
    00044
    00045	struct HUDLocalizedMessage
    00046	{
    00047		var Class<LocalMessage> Message;
    00048		var int Switch;
    00049		var PlayerReplicationInfo RelatedPRI;
    00050		var Object OptionalObject;
    00051		var float EndOfLife;
    00052		var float LifeTime;
    00053		var bool bDrawing;
    00054		var int numLines;
    00055		var string StringMessage;
    00056		var color DrawColor;
    00057		var font StringFont;
    00058		var float XL, YL;
    00059		var float YPos;
    00060	};
    00061	var string TextMessages[4];
    00062	var float MessageLife[4];
    00063
    00064	var Pawn PawnOwner;               // XIIIPawn of the PlayerOwner controller
    00065	var texture RoundBackGroundTex;   // Icon for backGroung
    00066	var texture FondMsg;              // to be used by HUDMsg(s) & HUDDlg(s)
    00067	var color HudWarningColor;
    00068	var color HudBasicColor;
    00069	var color HudBackGroundColor;
    00070	var float XP, YP;                 // Floats to track the current ScreenPosition.
    00071	var float IconSize;
    00072	var int LifeDisplayWidth, LifeDisplayHeight;  // used to memorize some StrLen params
    00073
    00074	var color OrangeColor,BlackColor,WhiteColor,GoldColor,RedColor,BlueColor,GreenColor,
    00075	  TurqColor,GrayColor,CyanColor,PurpleColor,LightGreenColor,LightBlueColor,LightPurpleColor;
    00076	var float fDrawSixSenseTimer[5];  // timer used w/ the bool bDrawSixSense
    00077	var vector vSixSensePos[5];       // on-screen Position to draw SixSense SFX
    00078	var texture SixSenseTex;          // texture used to 'display' sounds
    00079	var texture SixSenseDisplayTex;   // texture used to show the SixSense is active
    00080	var texture BulletIconTex;        // Background ammo
    00081
    00082	var float LeftMargin, RightMargin, UpMargin, DownMargin;  // for TV security draw, in %
    00083
    00084	var texture HudIcons;             // one-texture for player info display
    00085	var texture HudWIcons;            // one-texture Icons for weapon list display
    00086	var float fDrawChronoTimer;       // timer used w/ the bool above.
    00087	var string sChronoString;         // string to display (time left)
    00088
    00089	var Weapon DrawnWeapon;           // Weapon to draw info on screen
    00090	var float fDrawWeaponsTimer;      // timer used w/ the bool above.
    00091	var string sAmmoRef;              // string for drawing clips left in weapon
    00092	var bool HelpDisplay;
    00093
    00094	/* Draw3DLine()
    00095	draw line in world space. Should be used when engine calls RenderWorldOverlays() event.
    00096	*/
    00097	native final function Draw3DLine(vector Start, vector End, color LineColor);
    00098	native function DrawStdBackground(Canvas C, float Height, float CenterWidth);
    00099	native function DrawPlayerInfo(Canvas C);
    00100	native function DrawAmmo(Canvas C, String ItemText);
    00101	native function DrawWeaponsList(canvas C);
    00102
    00103	simulated function PostBeginPlay()
    00104	{
    00105		Super.PostBeginPlay();
    00106		PlayerOwner = PlayerController(Owner);
    00107	}
    00108
    00109	function SpawnScoreBoard(class<Scoreboard> ScoringType)
    00110	{
    00111		if ( ScoringType != None )
    00112		{
    00113			Scoring = Spawn(ScoringType, PlayerOwner);
    00114			Scoring.OwnerHUD = self;
    00115		}
    00116	}
    00117
    00118	simulated event Destroyed()
    00119	{
    00120		Super.Destroyed();
    00121		if ( Scoring != None )
    00122			Scoring.Destroy();
    00123	}
    00124
    00125	//=============================================================================
    00126	// Execs
    00127
    00128	/* toggles displaying scoreboard
    00129	*/
    00130	exec function ShowScores()
    00131	{
    00132		bShowScores = !bShowScores;
    00133		HelpDisplay = !HelpDisplay;
    00134	}
    00135
    00136	exec function HideScores()
    00137	{
    00138		bShowScores = false;
    00139		HelpDisplay = true;
    00140	}
    00141
    00142	/* toggles displaying properties of player's current viewtarget
    00143	*/
    00144	exec function ShowDebug()
    00145	{
    00146		bShowDebugInfo = !bShowDebugInfo;
    00147	}
    00148
    00149	/* ShowUpgradeMenu()
    00150	Event called when the engine version is less than the MinNetVer of the server you are trying
    00151	to connect with.
    00152	*/
    00153	event ShowUpgradeMenu();
    00154
    00155	function PlayStartupMessage(byte Stage);
    00156
    00157	//=============================================================================
    00158	// Message manipulation
    00159
    00160	function ClearMessage(out HUDLocalizedMessage M)
    00161	{
    00162		M.Message = None;
    00163		M.Switch = 0;
    00164		M.RelatedPRI = None;
    00165		M.OptionalObject = None;
    00166		M.EndOfLife = 0;
    00167		M.StringMessage = "";
    00168		M.DrawColor = class'Canvas'.Static.MakeColor(255,255,255);
    00169		M.XL = 0;
    00170		M.bDrawing = false;
    00171	}
    00172
    00173	function CopyMessage(out HUDLocalizedMessage M1, HUDLocalizedMessage M2)
    00174	{
    00175		M1.Message = M2.Message;
    00176		M1.Switch = M2.Switch;
    00177		M1.RelatedPRI = M2.RelatedPRI;
    00178		M1.OptionalObject = M2.OptionalObject;
    00179		M1.EndOfLife = M2.EndOfLife;
    00180		M1.StringMessage = M2.StringMessage;
    00181		M1.DrawColor = M2.DrawColor;
    00182		M1.XL = M2.XL;
    00183		M1.YL = M2.YL;
    00184		M1.YPos = M2.YPos;
    00185		M1.bDrawing = M2.bDrawing;
    00186		M1.LifeTime = M2.LifeTime;
    00187		M1.numLines = M2.numLines;
    00188	}
    00189
    00190	//=============================================================================
    00191	// Status drawing.
    00192
    00193	simulated event WorldSpaceOverlays()
    00194	{
    00195		if ( bShowDebugInfo && Pawn(PlayerOwner.ViewTarget) != None )
    00196			DrawRoute();
    00197	}
    00198
    00199	simulated event PostRender( canvas Canvas )
    00200	{
    00201		local HUD H;
    00202		local float YL,YPos;
    00203		local Pawn P;
    00204
    00205		if ( !PlayerOwner.bBehindView )
    00206		{
    00207			P = Pawn(PlayerOwner.ViewTarget);
    00208			if ( (P != None) && (P.Weapon != None) )
    00209				P.Weapon.RenderOverlays(Canvas);
    00210		}
    00211
    00212	//FIXMEJOE
    00213	/*
    00214		if ( PlayerConsole.bNoDrawWorld )
    00215		{
    00216			Canvas.SetPos(0,0);
    00217			Canvas.DrawPattern( Texture'Border', Canvas.ClipX, Canvas.ClipY, 1.0 );
    00218		}
    00219	*/
    00220		DisplayMessages(Canvas);
    00221		bHideCenterMessages = DrawLevelAction(Canvas);
    00222
    00223		if ( !bHideCenterMessages && (PlayerOwner.ProgressTimeOut > Level.TimeSeconds) )
    00224			DisplayProgressMessage(Canvas);
    00225
    00226		if ( bBadConnectionAlert )
    00227			DisplayBadConnectionAlert(Canvas);
    00228
    00229		if ( bShowDebugInfo )
    00230		{
    00231			YPos = 5;
    00232			UseSmallFont(Canvas);
    00233			PlayerOwner.ViewTarget.DisplayDebug(Canvas,YL,YPos);
    00234		}
    00235		else for ( H=self; H!=None; H=H.NextHUD )
    00236			H.DrawHUD(Canvas);
    00237	}
    00238
    00239	simulated function DrawRoute()
    00240	{
    00241		local int i;
    00242		local Controller C;
    00243		local vector Start, End;
    00244		local bool bPath;
    00245
00246 C = Pawn(PlayerOwner.ViewTarget).Controller; 00247 if ( C == None ) 00248 return; 00249 Start = PlayerOwner.ViewTarget.Location; 00250 00251 // show where pawn is going 00252 if ( (C == PlayerOwner) 00253 || (C.MoveTarget == C.RouteCache[0]) && (C.MoveTarget != None) ) 00254 { 00255 if ( (C == PlayerOwner) && (C.Destination != vect(0,0,0)) ) 00256 { 00257 if ( C.PointReachable(C.Destination) ) 00258 { 00259 Draw3DLine(C.Pawn.Location, C.Destination, class'Canvas'.Static.MakeColor(255,255,255)); 00260 return; 00261 } 00262 C.FindPathTo(C.Destination); 00263 } 00264 for ( i=0; i<16; i++ ) 00265 { 00266 if ( C.RouteCache[i] == None ) 00267 break; 00268 bPath = true; 00269 Draw3DLine(Start,C.RouteCache[i].Location,class'Canvas'.Static.MakeColor(0,255,0)); 00270 Start = C.RouteCache[i].Location; 00271 } 00272 if ( bPath ) 00273 Draw3DLine(Start,C.Destination,class'Canvas'.Static.MakeColor(255,255,255)); 00274 } 00275 else if ( PlayerOwner.ViewTarget.Velocity != vect(0,0,0) ) 00276 Draw3DLine(Start,C.Destination,class'Canvas'.Static.MakeColor(255,255,255)); 00277 00278 if ( C == PlayerOwner ) 00279 return; 00280 00281 // show where pawn is looking 00282 if ( C.Focus != None ) 00283 End = C.Focus.Location; 00284 else 00285 End = C.FocalPoint; 00286 Draw3DLine(PlayerOwner.ViewTarget.Location + Pawn(PlayerOwner.ViewTarget).BaseEyeHeight * vect(0,0,1),End,class'Canvas'.Static.MakeColor(255,0,0)); 00287 } 00288 00289 /* DrawHUD() Draw HUD elements on canvas. 00290 */ 00291 function DrawHUD(canvas Canvas); 00292 00293 //____________________________________________________________________ 00294 function DrawWeaponIconsList(canvas C) 00295 { 00296 DrawWeaponsList(C); 00297 /* 00298 local string ItemText; 00299 local int Loop, NbWeapon, MaxWeaponIndex,AmmoPerCharger, Ammo; 00300 local float WeaponPos; 00301 local Weapon W,TW[22]; 00302 local inventory I; 00303 00304 NbWeapon = 0; 00305 I = PawnOwner.Inventory; 00306 // Add weapons in array TW 00307 while ( I != none ) 00308 { 00309 W = Weapon(I); 00310 00311 // if ( (W != none) && !((W.default.ReLoadCount==0) && !W.HasAmmo()) && (DecoWeapon(W) == none) && !W.bIsSlave ) 00312 if ( (W != none) && !((W.default.ReLoadCount==0) && !W.HasAmmo()) && !W.IsA('DecoWeapon') && !W.bIsSlave ) 00313 { 00314 TW[W.InventoryGroup] = W; 00315 MaxWeaponIndex = Max(MaxWeaponIndex, W.InventoryGroup); 00316 NbWeapon++; 00317 } 00318 I = I.Inventory; 00319 } 00320 00321 // global pre draw init 00322 YP = C.ClipY * ( 1 - DownMargin ) - LifeDisplayHeight; 00323 WeaponPos = C.ClipX * ( 1 - RightMargin ) - (NbWeapon)*(2*LifeDisplayHeight+4) - LifeDisplayHeight; 00324 C.bUseBorder = false; 00325 C.Style = ERenderStyle.STY_Alpha; 00326 00327 for( Loop=0; Loop<MaxWeaponIndex+1; Loop++) 00328 { 00329 if ( TW[Loop] != none ) 00330 { 00331 W = TW[loop]; 00332 // Draw Weapon 00333 if ( !W.HasAmmo() && !W.HasAltAmmo() ) 00334 C.DrawColor = RedColor; 00335 else if ( ( W.WHand==WHA_2HShot ) && PawnOwner.bHaveOnlyOneHandFree ) 00336 C.DrawColor = OrangeColor; 00337 else 00338 C.DrawColor = HudBasicColor*0.1; 00339 00340 if ( W == DrawnWeapon ) 00341 C.DrawColor.A= 140 ; 00342 else 00343 C.DrawColor.A= 70 ; 00344 00345 C.SetPos( WeaponPos,YP); 00346 C.DrawRect(FondMsg, 2*LifeDisplayHeight,LifeDisplayHeight); 00347 // C.DrawTile(FondMsg, 2*LifeDisplayHeight,LifeDisplayHeight, 0, 0, FondMsg.USize, FondMsg.VSize); 00348 00349 C.DrawColor= WhiteColor; 00350 if ( W == DrawnWeapon ) 00351 { 00352 C.bUseBorder = true; 00353 C.BorderColor= HudBasicColor; 00354 C.BorderColor.A= 255; 00355 } 00356 00357 C.SetPos(WeaponPos,C.CurY); 00358 C.DrawRect(W.Icon, 2*LifeDisplayHeight,LifeDisplayHeight); 00359 // C.DrawTile(W.Icon, 2*LifeDisplayHeight,LifeDisplayHeight, 0, 0, W.Icon.USize, W.Icon.VSize); 00360 C.bUseBorder = false; 00361 00362 // Draw Ammo 00363 C.DrawColor = HudBasicColor; 00364 if ( W == DrawnWeapon ) 00365 C.DrawColor.A = 255; 00366 else 00367 C.DrawColor.A = 150; 00368 00369 if( W.default.ReLoadCount > 0 ) 00370 { 00371 Ammo = W.Ammotype.AmmoAmount; 00372 AmmoPerCharger = W.default.ReLoadCount; 00373 Ammo /= AmmoPerCharger; 00374 } 00375 else 00376 { 00377 if ( (W.WHand == WHA_Fist) || (W.WHand == WHA_Deco) ) 00378 Ammo = -1; 00379 else 00380 Ammo = W.Ammotype.AmmoAmount; 00381 } 00382 00383 if( Ammo > 0 ) 00384 { 00385 if( Ammo > 6 ) 00386 Ammo = 6 ; 00387 ItemText = Left(sAmmoRef, Ammo); 00388 C.SetPos( WeaponPos,YP-LifeDisplayHeight/2-6 ); 00389 C.DrawText(ItemText, false); 00390 } 00391 WeaponPos += 2*LifeDisplayHeight + 4; 00392 } 00393 } 00394 00395 C.DrawColor = HudBasicColor*0.1; 00396 C.DrawColor.A= 70 ; 00397 00398 C.SetPos( WeaponPos,YP); 00399 C.DrawTile(RoundBackGroundTex, LifeDisplayHeight,LifeDisplayHeight, 0, 0, -RoundBackGroundTex.USize, RoundBackGroundTex.VSize); 00400 00401 WeaponPos= C.ClipX * ( 1 - RightMargin ) - (NbWeapon)*(2*LifeDisplayHeight+4) - 2*LifeDisplayHeight - 4; 00402 00403 C.SetPos( WeaponPos,C.CurY); 00404 C.DrawTile(RoundBackGroundTex, LifeDisplayHeight,LifeDisplayHeight, 0, 0, RoundBackGroundTex.USize, RoundBackGroundTex.VSize); 00405 */ 00406 } 00407 00408 /* Print a centered level action message with a drop shadow. 00409 */ 00410 function PrintActionMessage( Canvas C, string BigMessage ) 00411 { 00412 local float XL, YL; 00413 00414 if ( Len(BigMessage) > 10 ) 00415 UseLargeFont(C); 00416 else 00417 UseHugeFont(C); 00418 C.bCenter = false; 00419 C.StrLen( BigMessage, XL, YL ); 00420 C.SetPos(0.5 * (C.ClipX - XL) + 1, 0.66 * C.ClipY - YL * 0.5 + 1); 00421 C.SetDrawColor(0,0,0); 00422 C.DrawText( BigMessage, false ); 00423 C.SetPos(0.5 * (C.ClipX - XL), 0.66 * C.ClipY - YL * 0.5); 00424 C.SetDrawColor(0,0,255);; 00425 C.DrawText( BigMessage, false ); 00426 } 00427 00428 /* Display Progress Messages 00429 display progress messages in center of screen 00430 */ 00431 simulated function DisplayProgressMessage( canvas Canvas ) 00432 { 00433 local int i; 00434 local float XL, YL, YOffset; 00435 local GameReplicationInfo GRI; 00436 00437 PlayerOwner.ProgressTimeOut = FMin(PlayerOwner.ProgressTimeOut, Level.TimeSeconds + 8); 00438 Canvas.Style = ERenderStyle.STY_Normal; 00439 UseLargeFont(Canvas); 00440 YOffset = 0.3 * Canvas.ClipY; 00441 00442 for (i=0; i<4; i++) 00443 { 00444 Canvas.DrawColor = PlayerOwner.ProgressColor[i]; 00445 Canvas.StrLen(PlayerOwner.ProgressMessage[i], XL, YL); 00446 Canvas.SetPos(0.5 * (Canvas.ClipX - XL), YOffset); 00447 Canvas.DrawText(PlayerOwner.ProgressMessage[i], false); 00448 YOffset += YL + 1; 00449 } 00450 Canvas.SetDrawColor(255,255,255); 00451 } 00452 00453 /* Draw the Level Action 00454 */ 00455 function bool DrawLevelAction( canvas C ) 00456 { 00457 local string BigMessage; 00458 00459 if (Level.LevelAction == LEVACT_None ) 00460 { 00461 if ( Level.Pauser != None ) 00462 BigMessage = PausedMessage; // Add pauser name? 00463 else 00464 { 00465 BigMessage = ""; 00466 return false; 00467 } 00468 } 00469 else if ( Level.LevelAction == LEVACT_Loading ) 00470 BigMessage = LoadingMessage; 00471 else if ( Level.LevelAction == LEVACT_Saving ) 00472 BigMessage = SavingMessage; 00473 else if ( Level.LevelAction == LEVACT_Connecting ) 00474 BigMessage = ConnectingMessage; 00475 else if ( Level.LevelAction == LEVACT_Precaching ) 00476 BigMessage = PrecachingMessage; 00477 00478 if ( BigMessage != "" ) 00479 { 00480 C.Style = ERenderStyle.STY_Normal; 00481 UseLargeFont(C); 00482 PrintActionMessage(C, BigMessage); 00483 return true; 00484 } 00485 return false; 00486 } 00487 00488 /* DisplayBadConnectionAlert() 00489 Warn user that net connection is bad 00490 */ 00491 function DisplayBadConnectionAlert(Canvas C); 00492 //============================================================================= 00493 // Messaging. 00494 00495 simulated function Message( PlayerReplicationInfo PRI, coerce string Msg, name MsgType ) 00496 { 00497 if ( bMessageBeep ) 00498 PlayerOwner.PlayBeepSound(); 00499 AddTextMessage(Msg,class'LocalMessage'); 00500 } 00501 00502 simulated function LocalizedMessage( class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject, optional string CriticalString ); 00503 00504 simulated function PlayReceivedMessage( string S, string PName, ZoneInfo PZone ) 00505 { 00506 PlayerOwner.ClientMessage(S); 00507 if ( bMessageBeep ) 00508 PlayerOwner.PlayBeepSound(); 00509 } 00510 00511 function bool ProcessKeyEvent( int Key, int Action, FLOAT Delta ) 00512 { 00513 if ( NextHud != None ) 00514 return NextHud.ProcessKeyEvent(Key,Action,Delta); 00515 return false; 00516 } 00517 00518 /* DisplayMessages() - display current messages 00519 */ 00520 function DisplayMessages(canvas Canvas) 00521 { 00522 local int i, j, YPos; 00523 local float XL, YL; 00524 00525 // first, clean up messages 00526 for ( i=0; i<4; i++ ) 00527 { 00528 if ( TextMessages[i] == "" ) 00529 break; 00530 else if ( MessageLife[i] < Level.TimeSeconds ) 00531 { 00532 TextMessages[i] = ""; 00533 if ( i < 3 ) 00534 { 00535 for ( j=i; j<3; j++ ) 00536 { 00537 TextMessages[j] = TextMessages[j+1]; 00538 MessageLife[j] = MessageLife[j+1]; 00539 } 00540 } 00541 TextMessages[3] = ""; 00542 break; 00543 } 00544 } 00545 00546 YPos = 0; 00547 UseSmallFont(Canvas); 00548 Canvas.SetDrawColor(0,255,255); 00549 for ( i=0; i<4; i++ ) 00550 { 00551 if ( TextMessages[i] == "" ) 00552 break; 00553 else 00554 { 00555 Canvas.StrLen( TextMessages[i], XL, YL ); 00556 Canvas.SetPos(4, YPos); 00557 Canvas.DrawText( TextMessages[i], false ); 00558 YPos += YL * (1 + int(XL/Canvas.ClipX)); 00559 } 00560 } 00561 } 00562 00563 function AddTextMessage(string M, class<LocalMessage> MessageClass) 00564 { 00565 local int i; 00566 00567 // look for empty spot 00568 for ( i=0; i<4; i++ ) 00569 if ( TextMessages[i] == "" ) 00570 { 00571 TextMessages[i] = M; 00572 MessageLife[i] = Level.TimeSeconds + MessageClass.Default.LifeTime; 00573 return; 00574 } 00575 00576 // force add message 00577 for ( i=0; i<3; i++ ) 00578 { 00579 TextMessages[i] = TextMessages[i+1]; 00580 MessageLife[i] = MessageLife[i+1]; 00581 } 00582 00583 TextMessages[3] = M; 00584 MessageLife[3] = Level.TimeSeconds + MessageClass.Default.LifeTime; 00585 } 00586 00587 //============================================================================= 00588 // Font Selection. 00589 00590 function UseSmallFont(Canvas Canvas) 00591 { 00592 Canvas.Font = Canvas.SmallFont; 00593 /* to prevent crash 00594 if ( Canvas.ClipX <= 640 ) 00595 Canvas.Font = SmallFont; 00596 else 00597 Canvas.Font = MedFont; 00598 */ 00599 } 00600 00601 function UseMediumFont(Canvas Canvas) 00602 { 00603 Canvas.Font = Canvas.SmallFont; 00604 /* to prevent crash 00605 if ( Canvas.ClipX <= 640 ) 00606 Canvas.Font = MedFont; 00607 else 00608 Canvas.Font = BigFont; 00609 */ 00610 } 00611 00612 function UseLargeFont(Canvas Canvas) 00613 { 00614 Canvas.Font = Canvas.SmallFont; 00615 /* to prevent crash 00616 if ( Canvas.ClipX <= 640 ) 00617 Canvas.Font = BigFont; 00618 else 00619 Canvas.Font = LargeFont; 00620 */ 00621 } 00622 00623 function UseHugeFont(Canvas Canvas) 00624 { 00625 Canvas.Font = Canvas.SmallFont; 00626 /* to prevent crash 00627 Canvas.Font = LargeFont; 00628 */ 00629 } 00630 00631 defaultproperties 00632 { 00633 bMessageBeep=True 00634 LoadingMessage="LOADING" 00635 SavingMessage="SAVING" 00636 ConnectingMessage="CONNECTING" 00637 PausedMessage="PAUSED" 00638 HudWarningColor=(B=80,G=80,R=255,A=255) 00639 HudBasicColor=(B=210,G=252,R=255,A=230) 00640 HudBackGroundColor=(B=21,G=25,R=25,A=90) 00641 WhiteColor=(B=255,G=255,R=255,A=255) 00642 HelpDisplay=True 00643 bHidden=True 00644 bInteractive=False 00645 RemoteRole=ROLE_None 00646 }

End Source Code