Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

TribesGUI.TribesHUD


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
class TribesHUD extends Gameplay.TribesHUDBase
	Config(TribesHUD)
	abstract;

import enum EMessageType from Gameplay.ClientSideCharacter;

var TribesHUDScript	HUDScript;
var config string	HUDScriptType;	// config
var string			HUDScriptName;

// Interaction variables
var bool			bAllowInteractions;
var bool			bAllowChat;
var HUDAction		Response;

// mouse cursor data
var config Texture	MouseCursorTexture;
var config Color	MouseCursorDrawColor;
var int				MouseX;
var int				MouseY;

simulated event PostBeginPlay()
{
	Super.PostBeginPlay();

	SetHUDScript(HUDScriptType);
	InitActionDelegates();

	clientSideChar.RadarUnderlayMaterial = Level.GetMapTexture();
	clientSideChar.mapOrigin = Level.GetMapTextureOrigin();
	clientSideChar.mapExtent = Level.GetMapTextureExtent();
}

simulated function Cleanup()
{
	CleanupActionDelegates();
}

simulated function bool NeedsKeyInput()
{
	return (bAllowInteractions || ((clientSideChar.bTalk || clientSideChar.bTeamTalk || clientSideChar.bQuickChat) && bAllowChat) || clientSideChar.bLoadoutSelection);
}

function SetHUDScript(string NewHUDScriptType)
{
	local class NewHUDClass;

	if(NewHUDScriptType != "")
	{
		HUDScriptType = NewHUDScriptType;
		NewHUDClass = class<TribesHUDScript>(DynamicLoadObject(HUDScriptType, class'class'));
		HUDScript = TribesHUDScript(new(None, HUDScriptName) NewHUDClass);
		if (HUDScript == None)
			Log("HUD ERROR:  HUDScript was None trying to set "$NewHUDScriptType);
	}
}

function HUDShown()
{
	super.HUDShown();
	HUDScript.PreShow(ClientSideChar);
}

function DrawHUD(Canvas canvas)
{
	if(HUDScript != None && ! bHideHUD)
		HUDScript.DoUpdate(canvas, Level.TimeSeconds);
}

function PostRender(Canvas canvas)
{
	super.PostRender(canvas);

	// render the mouse cursor
	if(bShowCursor)
	{
		MouseX = Clamp(MouseX, 0, canvas.SizeX);
		MouseY = Clamp(MouseY, 0, canvas.SizeY);

		if(canvas.Viewport.bWindowsMouseAvailable)
		{
			MouseX = Canvas.Viewport.WindowsMouseX;
			MouseY = Canvas.Viewport.WindowsMouseY;
		}

		canvas.bNoSmooth = True;
		canvas.DrawColor = MouseCursorDrawColor;
		canvas.Style = 2;
		canvas.SetPos(MouseX, MouseY);
		canvas.DrawIcon(MouseCursorTexture, 1.0);
		canvas.Style = 1;
	}
}

// Key events
function bool KeyType( EInputKey Key, optional string Unicode )
{
	if(HUDscript != None)
		return HUDScript.KeyType(Key, Unicode, response);

	return false;
}

function bool KeyEvent( EInputKey Key, EInputAction Action, FLOAT Delta )
{
	//
	// Grab the mouse events if the HUD wants to render a cursor
	//
	if(bShowCursor)
	{
		switch(Key)
		{
			case EInputKey.IK_MouseX:
				MouseX += Delta;
				break;
			case EinputKey.IK_MouseY:
				MouseY -= Delta;
				break;
		}
	}

	if(HUDscript != None)
		return HUDScript.KeyEvent(Key, Action, delta, response);

	return false;
}

// messaging
simulated function Message( PlayerReplicationInfo PRI, coerce string Msg, name MsgType )
{
	local String quickChatTag, quickChatMessage;
	local ClientSideCharacter.HUDMessage NewMessage;
	local int splitIndex;
	local String PlayerNameString;
	local TribesReplicationInfo TRI;
	local class<TeamInfo> InfoClass;

	// PRI will be None if it's an announcer message
	if(PRI != None && Controller.IsMuted(PRI.PlayerName))
		return;

	if(PRI != None)
	{
		TRI = TribesReplicationInfo(PRI);
		if(TRI.team != None)
			InfoClass = TRI.team.class;
		if(HUDScript != None)
			PlayerNameString = HUDScript.EncodePlayerName(TRI.PlayerName, TRI.teamTag, clientSideChar.GetTeamAlignment(Controller, TRI), InfoClass);
		else
			PlayerNameString = TribesReplicationInfo(PRI).teamTag $ PRI.playerName;
	}

	if(MsgType == 'Subtitle')
	{
		NewMessage.Text = Msg;
		NewMessage.Type = MessageType_Subtitle;

		clientSideChar.Messages[clientSideChar.Messages.Length] = NewMessage;
	}
	else if(MsgType == 'Announcer')
	{
		Msg = ReplacePromptKeyBinds(Msg);
		clientSideChar.Announcements[clientSideChar.Announcements.Length] = Msg;
	}
	else if(! Controller.IsSinglePlayer())
	{
		// none of this stuff should be processed or displayed in sp
		if(MsgType == 'QuickChat' || MsgType == 'TeamQuickChat')
		{
			splitIndex = InStr(Msg, "?");

			quickChatTag = Left(Msg, splitIndex);
			quickChatMessage = Right(Msg, Len(Msg) - splitIndex - 1);

			if(quickChatMessage == "")
				quickChatMessage = Localize("QuickChat", quickChatTag, "Localisation\\Speech\\QuickChat");

			if(TribesReplicationInfo(PRI) != None && quickChatTag != "")
				Level.speechManager.PlayQuickChatSpeech(PRI, TribesReplicationInfo(PRI).VoiceSetPackageName, Name(quickChatTag));

			NewMessage.Text = PlayerNameString $": " $quickChatMessage;
			if(MsgType == 'TeamQuickChat')
				NewMessage.Type = MessageType_Ally;

			clientSideChar.Messages[clientSideChar.Messages.Length] = NewMessage;
		}
		else if(MsgType == 'Say' || MsgType == 'TeamSay')
		{
			// append the say message to the list of messages.
			NewMessage.Text = PlayerNameString $": " $Msg;
			if(MsgType == 'TeamSay')
				NewMessage.Type = MessageType_Ally;

			clientSideChar.Messages[clientSideChar.Messages.Length] = NewMessage;
		}
		else if(MsgType == 'System')
		{
			NewMessage.Text = Msg;
			NewMessage.Type = MessageType_System;

			clientSideChar.Messages[clientSideChar.Messages.Length] = NewMessage;
		}
		else
			Super.Message(PRI, Msg, MsgType);
	}
	else
		Super.Message(PRI, Msg, MsgType);

}

// LocalizedMessage
simulated function LocalizedMessage(class<LocalMessage> Message, optional int Switch, optional Core.Object Related1, optional Core.Object Related2, optional Core.Object OptionalObject, optional string CriticalString, optional string OptionalString)
{
	local class<MPEventMessage> SentEventMessage;
	local class<TribesGameMessage> SentGameMessage;
	local class<MPPersonalMessage> SentPersonalMessage;
	local ClientSideCharacter.EventMessage newMessage;
	local ClientSideCharacter.HUDMessage newHUDMessage;
	local EMessageType MessageType;
	local TribesReplicationInfo TRI;
	local class<TeamInfo> InfoClass;

	SentPersonalMessage = class<MPPersonalMessage>(Message);
	SentGameMessage = class<TribesGameMessage>(Message);
	SentEventMessage = class<MPEventMessage>(Message);
	
	// no localised messages in sp
	if(! Controller.IsSinglePlayer())
	{
		if(SentEventMessage != None)
		{
			newMessage.StringOne = SentEventMessage.static.GetStringOne(newMessage.StringOneType, Switch, Related1, Related2, OptionalObject, OptionalString);
			newMessage.StringTwo = SentEventMessage.static.GetStringTwo(newMessage.StringTwoType, Switch, Related1, Related2, OptionalObject, OptionalString);
			newMessage.IconMaterial = SentEventMessage.static.GetIconMaterial(Switch, Related1, Related2, OptionalObject, OptionalString);

			// hacky: Related1 is None for suicides, so on a death message where 
			// related1 is none we make it equal related2
			if(Related1 == None && class<MPDeathMessages>(Message) != None && TribesReplicationInfo(Related2) != None)
				Related1 = Related2;

			if(TribesReplicationInfo(Related1) != None && HUDScript != None)
			{
				TRI = TribesReplicationInfo(Related1);
				if(TRI.team != None)
					InfoClass = TRI.team.class;
				newMessage.StringOne = "" $ HUDScript.EncodePlayerName(TRI.PlayerName, TRI.teamTag, ClientSideChar.GetTeamAlignment(Controller, TRI), InfoClass);
			}
			if(TribesReplicationInfo(Related2) != None && (Related1 != Related2) && HUDScript != None)
			{
				TRI = TribesReplicationInfo(Related2);
				if(TRI.team != None)
					InfoClass = TRI.team.class;
				newMessage.StringTwo = "" $ HUDScript.EncodePlayerName(TRI.PlayerName, TRI.teamTag, ClientSideChar.GetTeamAlignment(Controller, TRI), InfoClass);
			}

			clientSideChar.EventMessages[clientSideChar.EventMessages.Length] = newMessage;
		}
		else if(SentGameMessage != None)
		{
			newHUDMessage.Text = SentGameMessage.static.GetString(Switch, Related1, Related2, OptionalObject, OptionalString);
			newHUDMessage.Type = MessageType_System;

			clientSideChar.Messages[clientSideChar.Messages.Length] = newHUDMessage;
		}
		else if(SentPersonalMessage != None)
		{
			MessageType = MessageType_System;

			newHUDMessage.Text = SentPersonalMessage.static.GetPersonalString(MessageType, Switch, Related1, Related2, OptionalObject, OptionalString);
			newHUDMessage.Type = MessageType;

			clientSideChar.PersonalMessages[clientSideChar.PersonalMessages.Length] = newHUDMessage;
		}
		else
			PlayerOwner.ClientMessage(Message.static.GetString(Switch, Related1, Related2, OptionalObject, OptionalString));
	}
	else
		PlayerOwner.ClientMessage(Message.static.GetString(Switch, Related1, Related2, OptionalObject, OptionalString));
}

//
// initialises any action delegates for the hud response
function InitActionDelegates()
{
	// chat delegates
	if(Response == None)
		Response = new class'HUDAction';

	Response.CancelChat = impl_CancelChat;
	Response.SendChatMessage = impl_SendChatMessage;
	Response.SendQuickChatMessage = impl_SendQuickChatMessage;
}

//
// cleans up any action delegates for the hud response
function CleanupActionDelegates()
{
	if(Response != None)
	{
		Response.CancelChat = None;
		Response.SendChatMessage = None;
		Response.SendQuickChatMessage = None;
	}
}

//
// The base functionality for this function is to add all the info
// which is required for all (or most) HUDs
//
simulated function UpdateHUDData()
{
	super.UpdateHUDData();

	// mouse pointer info
	ClientSideChar.MouseX = MouseX;
	ClientSideChar.MouseY = MouseY;

	// Game and round data
	UpdateHUDGameData();
	clientSideChar.respawnTime = Controller.respawnDelay;
	clientSideChar.livesLeft = Controller.livesLeft;
	clientSideChar.bWaitingForRoundEnd = Controller.bWaitingForRoundEnd;
	if(Controller.PlayerReplicationInfo != None)
		clientSideChar.ping = Controller.PlayerReplicationInfo.ping;

	clientSideChar.bDisplayChatWindow = clientSideChar.gameClass == None || clientSideChar.gameClass.static.showChatWindow();

	if(ClassIsChildOf(clientSideChar.gameClass, class'Gameplay.MultiPlayerGameInfo'))
		clientSideChar.bQuickChat = (Controller.bQuickChat == 1 && ! Controller.CanUseQuickInventoryLoadoutMenu());
	else
		clientSideChar.bQuickChat = false;

	clientSideChar.levelTimeSeconds = Level.TimeSeconds;

	if(Controller.IsSinglePlayer())
		clientSideChar.CurrentChatWindowSize = Controller.SPChatWindowSizes[Controller.SPChatWindowSizeIndex];
	else
		clientSideChar.CurrentChatWindowSize = Controller.ChatWindowSizes[Controller.ChatWindowSizeIndex];

	UpdateRoundInfoData();
}

function UpdateRoundInfoData()
{
	local RoundInfo RoundInfo;

	RoundInfo = Controller.RoundInfo;
	if(RoundInfo != None)
	{
		// Assume multiplayer (this variable determines whether or not the timer will be visible)
		clientSideChar.bNeedCountDownTimer = true;

		if(RoundInfo.replicatedRemainingCountdown > 0)
		{
			// If a pre-match countdown is in progress, replicate that
			clientSideChar.bRoundCountingDown = true;
			clientSideChar.countDown = RoundInfo.replicatedRemainingCountdown;
		}
		else
		{
			// Otherwise, replicate the match duration
			clientSideChar.bRoundCountingDown = false;
			clientSideChar.countDown = RoundInfo.replicatedRemainingDuration;
		}
	}
	else
	{
		clientSideChar.bNeedCountDownTimer = Controller.bCountDown;
		clientSideChar.countDown = Controller.countDown;
	}
}

//-------------------------------------------------------------
// Delegate function implementation

//
// Cancels chat message window
function impl_CancelChat()
{
	clientSideChar.bTalk = false;
	clientSideChar.bTeamTalk = false;
}

//
// Sends a chat message, and cancels the chat message window
function impl_SendChatMessage(String msg)
{
	if(clientSideChar.bTalk)
		Controller.Say(msg);
	else if(clientSideChar.bTeamTalk)
		Controller.TeamSay(msg);

	clientSideChar.bTalk = false;
	clientSideChar.bTeamTalk = false;
}

//
// Sends a quick chat message, then cancels the quick chat menu
function impl_SendQuickChatMessage(QuickChatMenu menuItem)
{
	local String MessageText;

	// dont bother sending the text if there was no override, 
	// because it will be localized at the other end anyway.
	if(menuItem.MessageOverride != "")
		MessageText = menuItem.MessageOverride;

	if(menuItem.sayType == 'Say')
		Controller.QuickChat(MessageText, String(menuItem.chatTag), menuItem.bLocal, menuItem.animationName);
	else if(menuItem.sayType == 'TeamSay')
		Controller.TeamQuickChat(MessageText, String(menuItem.chatTag), menuItem.bLocal, menuItem.animationName);
	clientSideChar.bQuickChat = false;

	// force the controller QC to false, for v-chat system
	Controller.bQuickChat = 0;
}

defaultproperties
{
	bAllowChat = true
	bAllowInteractions = false
	bShowCursor = false
	ConsoleMessagePosX = 0.00
	ConsoleMessagePosY = 0.45
    ConsoleMessageCount=5

	HUDScriptName = ""

    FontArrayNames(0)="Engine_res.SmallFont"
    FontArrayNames(1)="Engine_res.SmallFont"
    FontArrayNames(2)="Engine_res.SmallFont"
    FontArrayNames(3)="Engine_res.SmallFont"
    FontArrayNames(4)="Engine_res.SmallFont"
    FontArrayNames(5)="Engine_res.SmallFont"
    FontArrayNames(6)="Engine_res.SmallFont"
    FontArrayNames(7)="Engine_res.SmallFont"
    FontArrayNames(8)="Engine_res.SmallFont"

	MouseCursorTexture=Texture'guitribes.mousecursor'
	MouseCursorDrawColor=(R=255,G=255,B=255,A=255)
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: st 16.4.2014 10:20:46.000 - Creation time: st 23.5.2018 00:10:48.312 - Created with UnCodeX