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

UTV2004c.utvInteraction


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
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
//-----------------------------------------------------------
//
//-----------------------------------------------------------
class utvInteraction extends Interaction;

//P should always be set.. up is not set for the primary spectator
var PlayerController p;
var utvReplication UtvRep;
//var utvPlayer up;

var bool shownWelcome;
var float WelcomeWidth;
var float WelcomeMargin;
var float WelcomePos;
var int WelcomeStart[2];
var int WelcomeEnd[2];
var string WelcomeMsg[12];

var string WarnMsg;
var int Clients;
var int Delay;
var int RestartIn;

//primary only
var string ServerAddress;
var int ServerPort;
var int ListenPort;
var string JoinPassword;
var string PrimaryPassword;
var string VipPassword;
var string NormalPassword;
//var float Delay;
var int MaxClients;


//Remove ourselves if the level changes
event NotifyLevelChange()
{
	Log ("utv: Removed interaction");
	Master.RemoveInteraction (self);
}

simulated function SetState (bool primary)
{
	if (primary)
		GotoState ('Primary');
	else
		GotoState ('Secondary');
}

simulated function SetWarning (string msg)
{
	WarnMsg = msg;
}

function bool globalKeyEvent( out EInputKey Key, out EInputAction Action, FLOAT Delta )
{
	local string tmp;

	if ((!shownWelcome) && (Action == IST_Press)) {
		shownWelcome = true;
		return true;
	}

	//Is it the key that would invoke say?
	if (Action == IST_Press) {
		tmp = Viewportowner.Actor.ConsoleCommand ("KEYNAME " $ key);
		if (tmp ~= "F8") {
			ShowMenu ();
			return true;
		}
	}

	return false;
}

//stub, overriden in states
function DrawWelcome (Canvas canvas)
{
}

function DrawTextBox (Canvas canvas, string text, bool sizing, float X, out float Y, float XW)
{
	local float LineSpace;
	local float WordSpace;
	local string cur;
	local float xl, yl;
	local int i;
	local float curx;

	Canvas.TextSize("A", XL, YL);
	LineSpace = (YL * 1.1) / Canvas.ClipY;
	Canvas.TextSize(" ", XL, YL);
	WordSpace = XL * 1.1;

    //Replace color tags with the codes that DrawText recognizes
    text = Repl(text, "<1>", chr(27) $ chr(255) $ chr(255) $ chr(255));
    text = Repl(text, "<2>", chr(27) $ "àà`");
    text = Repl(text, "<3>", chr(27) $ "à@@");

	curx = 0;

	while (len (text) > 0) {
		i = InStr (text, " ");
		if (i == -1) {
			cur = text;
			text = "";
		} else {
			cur = Mid (text, 0, i);
			text = Mid (text, i + 1);
		}

		Canvas.TextSize (cur, xl, yl);
		if (curx + xl > xw * Canvas.ClipX) {
			Y+=LineSpace;
			Curx = 0;
		}

		if (!sizing) {
			Canvas.SetPos ((Canvas.ClipX * x) + curx, Canvas.ClipY * y);
			Canvas.DrawText (cur, false);
		}

		curx += xl + wordspace;
	}
	Y+=LineSpace;
}

function DrawWelcomeText (Canvas canvas, int index)
{
	local float x, y, xw, yw;
	local int i;

	Canvas.Font = class'UT2MidGameFont'.static.GetMidGameFont(Canvas.ClipX); // Update which font to use.

	yw = 0;
	xw = WelcomeWidth - WelcomeMargin*2;

	//Check sizing
	for (i = WelcomeStart[index]; i <= WelcomeEnd[index]; ++i) {
		DrawTextBox (canvas, WelcomeMsg[i], true, 0, yw, xw);
	}

	//Now draw it
	x = (1 - WelcomeWidth) / 2;
	y = ((1 - yw) / 2) - 0.1;		//kind of looks better with - 0.1

	Canvas.SetDrawColor(255,255,255,255);
	Canvas.SetPos(Canvas.ClipX * x, Canvas.ClipY * y);
	//Canvas.DrawTileStretched(texture 'InterfaceContent.Menu.BorderBoxD', Canvas.ClipX * WelcomeWidth, Canvas.ClipY * (yw + WelcomeMargin * 2));
	Canvas.DrawTileStretched(texture 'InterfaceContent.Menu.EditBoxDown', Canvas.ClipX * WelcomeWidth, Canvas.ClipY * (yw + WelcomeMargin * 2));

    //cPlayerHightlight ScoreBoxB/C      ButtonFocus
	y += WelcomeMargin;
	x += WelcomeMargin;

	for (i = WelcomeStart[index]; i <= WelcomeEnd[index]; ++i) {
		DrawTextBox (canvas, WelcomeMsg[i], false, x, y, xw);
	}
}

function DrawWarnMsg (Canvas canvas, string m)
{
	local float xl, yl;

    //Canvas.Font = class'HUD'.static.GetMediumFontFor (Canvas); //hm funka inte.. noo
    Canvas.Font = class'UT2MidGameFont'.static.GetMidGameFont(Canvas.ClipX);

	Canvas.StrLen(m,XL,YL);
	Canvas.DrawColor = class'HUD'.default.GoldColor;

	Canvas.SetPos(0.5*(Canvas.ClipX-XL), Canvas.ClipY * 0.15);
	Canvas.DrawText(m, true);
}

function DrawStats (Canvas canvas)
{
/*
	local float xl, yl;

    Canvas.Font = class'HUD'.static.GetConsoleFont (Canvas);
	Canvas.DrawColor = class'HUD'.default.WhiteColor;
	Canvas.StrLen("o_O", xl, yl);
	Canvas.SetPos(0.01 * (Canvas.ClipX), Canvas.ClipY * 0.25);
	Canvas.DrawText("UTV Clients: " $ Clients, true);
	Canvas.SetPos(0.01 * (Canvas.ClipX), Canvas.ClipY * 0.25 + yl * 1.1);
	Canvas.DrawText("UTV Delay: " $ Delay $ " seconds", true);
*/
}

function PostRender( canvas Canvas )
{
	if (p == none) {
		Log ("utv: Interaction setting playercontroller to " $ viewportowner.actor);
		p = ViewPortOwner.Actor;
	}

	Canvas.Style = p.ERenderStyle.STY_Alpha;

	if (!shownWelcome) {
		DrawWelcome (canvas);
	}

	//Anything important to tell the client?
	if (RestartIn > 0) {
		DrawWarnMsg (Canvas, "The UTV Proxy will restart in about " $ RestartIn $ " seconds");
	}
	else {
		if (WarnMsg != "") {
			DrawWarnMsg (Canvas, WarnMsg);
		}
	}

	DrawStats (Canvas);
}

function ShowChat (string msg)
{
	Viewportowner.Actor.ClientMessage (msg);
}

function ShowMenu ()
{
}

simulated function GotStatus (string s)
{
 	local string tmps;
 	local int i;

 	//Parse out the values
 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	clients = int (tmps);
 	s = Mid (s, i + 1);

 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	delay = int (tmps);
 	s = Mid (s, i + 1);

 	restartin = int (s);

 	Log ("utv: Got status - " $ clients $ " - " $ delay $ " - " $ restartin);
}

simulated function GotBigStatus (string s)
{
 	local string tmps;
 	local int i;

 	//Parse out the values
 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	ServerAddress = tmps;
 	s = Mid (s, i + 1);

 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	ServerPort = int (tmps);
 	s = Mid (s, i + 1);

 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	ListenPort = int (tmps);
 	s = Mid (s, i + 1);

 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	JoinPassword = tmps;
 	s = Mid (s, i + 1);

 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	PrimaryPassword = tmps;
 	s = Mid (s, i + 1);

 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	VipPassword = tmps;
 	s = Mid (s, i + 1);

 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	NormalPassword = tmps;
 	s = Mid (s, i + 1);

 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	Delay = float (tmps);
 	s = Mid (s, i + 1);

 	i = InStr (s, " ");
 	tmps = Mid (s, 0, i);
 	MaxClients = int (tmps);
 	s = Mid (s, i + 1);
}

state Primary
{
 	function bool KeyEvent( out EInputKey Key, out EInputAction Action, FLOAT Delta )
	{
		local string tmp;

		if (GlobalKeyEvent (Key, Action, Delta))
			return true;

		//Check stuff
		if (Action == IST_Press) {
			//teamsay key?
			tmp = Viewportowner.Actor.ConsoleCommand ("KEYNAME " $ key);
			tmp = Viewportowner.Actor.ConsoleCommand ("KEYBINDING " $ tmp);

			if (tmp ~= "TeamTalk") {
				p.ClientOpenMenu (class'utvReplication'.default.UtvPackage $ ".utvInputPage");
			    return true;
			}
		}
	}

   	function ShowMenu ()
	{
		if(ListenPort!=0){
			//StopForceFeedback();
			p.ClientMessage ("Opening menu");
			p.ClientOpenMenu(class'utvReplication'.default.UtvPackage $ ".utvPrimaryMenu");
		} else {
			p.ClientMessage ("Waiting for info from proxy");
		}
	}

	function DrawWelcome (canvas canvas)
	{
		DrawWelcomeText (canvas, 0);
	}

}

state Secondary
{
	function ShowMenu ()
	{
		//StopForceFeedback();
		p.ClientMessage ("Opening menu");
		p.ClientOpenMenu(class'utvReplication'.default.UtvPackage $ ".utvWatcherMenu");
	}

	function bool KeyEvent( out EInputKey Key, out EInputAction Action, FLOAT Delta )
	{
		local string tmp;

		if (GlobalKeyEvent (Key, Action, Delta))
			return true;

		//Check stuff
		if (Action == IST_Press) {

			//Right mouse pressed?
			if (Key == IK_RightMouse) {
				if(utvRep.FollowPrimary){
					if(utvRep.SeeAll){
						utvRep.FollowPrimary=false;
						utvRep.FreeFlight=true;
						p.ClientMessage ("Free flight mode");
					} else {
						if (class'utvReplication'.default.wantBehindview)
							class'utvReplication'.default.wantBehindview = false;
						else
							class'utvReplication'.default.wantBehindview = true;
					}
				} else {
					if(utvRep.FreeFlight || class'utvReplication'.default.wantBehindview){
						utvRep.FreeFlight=false;
						if(utvRep.LastTargetName=="")
							utvRep.GetNextPlayer();
						if(class'utvReplication'.default.wantBehindview){
							p.ClientMessage ("Following player in 1st person view");
							class'utvReplication'.default.wantBehindview = false;
						} else {
							p.ClientMessage ("Following player with behindview");
							class'utvReplication'.default.wantBehindview = true;
						}
					} else {
						if(utvRep.NoPrimary){
							utvRep.FollowPrimary=false;
							utvRep.FreeFlight=true;
							p.ClientMessage ("Free flight mode");
						} else {
							class'utvReplication'.default.wantBehindview = false;
							utvRep.FollowPrimary=true;
							p.ClientMessage ("Following primary");
						}
					}
				}
				return true;
			}
			if (Key == IK_LeftMouse) {
				if(!utvRep.FollowPrimary){
					utvRep.GetNextPlayer();
					utvRep.FreeFlight=false;
					return true;
				}
			}

			//Or the say key?
			tmp = Viewportowner.Actor.ConsoleCommand ("KEYNAME " $ key);
			tmp = Viewportowner.Actor.ConsoleCommand ("KEYBINDING " $ tmp);

			if (tmp ~= "Talk") {
				p.ClientOpenMenu (class'utvReplication'.default.UtvPackage $ ".utvInputPage");
			    return true;
			}
			if (tmp ~= "MoveForward") {
				utvRep.MoveForward=true;
			}
			if (tmp ~= "MoveBackward") {
				utvRep.MoveBackward=true;
			}
			if (tmp ~= "StrafeLeft") {
				utvRep.MoveLeft=true;
			}
			if (tmp ~= "StrafeRight") {
				utvRep.MoveRight=true;
			}
			if (tmp ~= "Jump") {
				utvRep.MoveUp=true;
			}
			if (tmp ~= "Duck") {
				utvRep.MoveDown=true;
			}
		}
		if (Action == IST_Release) {
			tmp = Viewportowner.Actor.ConsoleCommand ("KEYNAME " $ key);
			tmp = Viewportowner.Actor.ConsoleCommand ("KEYBINDING " $ tmp);

			if (tmp ~= "MoveForward") {
				utvRep.MoveForward=false;
			}
			if (tmp ~= "MoveBackward") {
				utvRep.MoveBackward=false;
			}
			if (tmp ~= "StrafeLeft") {
				utvRep.MoveLeft=false;
			}
			if (tmp ~= "StrafeRight") {
				utvRep.MoveRight=false;
			}
			if (tmp ~= "Jump") {
				utvRep.MoveUp=false;
			}
			if (tmp ~= "Duck") {
				utvRep.MoveDown=false;
			}
		}

		return false;
	}

	function DrawWelcome (canvas canvas)
	{
		DrawWelcomeText (canvas, 1);
	}

}

DefaultProperties
{
	bActive=true
	bVisible=true
	WelcomeWidth=0.4
	WelcomeMargin=0.02
	WelcomePos=0.2
	WelcomeStart[0]=0
	WelcomeEnd[0]=4
	WelcomeMsg[0]="Welcome to <2>UTV2004<1> Primary Client!"
	WelcomeMsg[1]=""
	WelcomeMsg[2]="You are now broadcasting a game to people over the net! To configure settings and control the UTV server, press <2>F8<1> to bring up the configuration menu."
	WelcomeMsg[3]=""
	WelcomeMsg[4]="Press any key to close this window.."
	WelcomeStart[1]=5
	WelcomeEnd[1]=11
	WelcomeMsg[5]="Welcome to <2>UTV2004<1> Watcher Client!"
	WelcomeMsg[6]=""
	WelcomeMsg[7]="You are watching a live broadcast of a game! To configure watcher settings press <2>F8<1> to bring up the configuration menu."
	WelcomeMsg[8]=""
	WelcomeMsg[9]="To toggle between first and third person view, press the <2>right<1> mouse button."
	WelcomeMsg[10]=""
	WelcomeMsg[11]="Press any key to close this window.."
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 5.9.2006 22:36:14.000 - Creation time: Do 14.8.2014 09:58:54.863 - Created with UnCodeX