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

GUI2K4.UT2K4SP_TeamRoles


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
00491
00492
00493
//==============================================================================
// Set the team roles for the next match
//
// Written by Michiel Hendriks
// (c) 2003, Epic Games, Inc.  All Rights Reserved
//==============================================================================

class UT2K4SP_TeamRoles extends LargeWindow;

#exec OBJ LOAD FILE=2K4Menus.utx

var UT2K4GameProfile GP;
var material PortraitBGMat;

var array<GUIImage> imgFaces;
var array<GUIComboBox> cbRoles;

var automated GUIButton btnOk, btnCancel;
var automated GUILabel lblTitle, lblInfo, lblNoMoney, lblBalance;
var automated GUIScrollTextBox sbCharInfo;

var localized string InactiveMsg, MinimalFeeCaption, InjuredCaption;
var localized string AggressionCaption, AccuracyCaption, AgilityCaption, TacticsCaption;

/** Used to check the number of roles assigned */
var int MaxTeamMates;
/** Currently assigned roles */
var int AssignedRoles;
/** used to check if the current team can be payed */
var array<int> TeamFee;
/** the fee for the currently selected team */
var int CurrentFee;
/** if true no balance check is done */
var bool bNoBalanceCheck;

/**	Will be called when the user clicks the "ok" button */
delegate OnOkClick();

function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
	local MatchInfo mi;
	local CacheManager.MapRecord MR;
	bInit = true;

	Super.Initcomponent(MyController, MyOwner);
	GP = UT2K4GameProfile(PlayerOwner().Level.Game.CurrentGameProfile);
	if (GP == none)
	{
		Log("GP == none");
		Controller.CloseMenu(false);
		return;
	}

	MaxTeamMates = GP.GetNumTeammatesForMatch();
	lblInfo.Caption = repl(lblInfo.Caption, "%teammates%", string(MaxTeamMates));
	lblInfo.Caption = repl(lblInfo.Caption, "%gametype%", GP.GetMatchDescription());
	lblBalance.Caption = repl(lblBalance.Caption, "%balance%", GP.MoneyToString(GP.Balance));

	mi = GP.GetMatchInfo(GP.CurrentLadder, GP.CurrentMenuRung);
	if ( mi.MenuName != "" ) lblInfo.Caption = repl("%map%", mi.MenuName, lblInfo.Caption);
	else {
		MR = class'CacheManager'.static.GetMapRecord(mi.LevelName);
		if (MR.FriendlyName != "") lblInfo.Caption = repl(lblInfo.Caption, "%map%", MR.FriendlyName);
		else lblInfo.Caption = repl(lblInfo.Caption, "%map%", MR.MapName);
	}

}

event HandleParameters(string Param1, string Param2)
{
	bNoBalanceCheck = (Param1 != "");
	drawButtons();
	bInit = false;
}

/** draw team member faces and role selection controlls */
function drawButtons()
{
	local int i, j, health;
	local GUIImage img, img2;
	local GUIComboBox cb;
	local GUILabel lbl;
	local GUIButton btn;
	local float X, Y, BaseWidth, Spacing;
	local xUtil.PlayerRecord PR;

	BaseWidth = i_FrameBG.WinWidth/(1+GP.GetMaxTeamSize());
	Spacing = BaseWidth/(1+GP.GetMaxTeamSize());
	X = i_FrameBG.WinLeft+Spacing;
	Y = lblInfo.WinTop+lblInfo.WinHeight;
	AssignedRoles = 0;
	CurrentFee = 0;

	for (i = 0; i < GP.GetMaxTeamSize(); i++)
	{
		PR = class'xGame.xUtil'.static.FindPlayerRecord(GP.PlayerTeam[i]);
		j = GP.GetBotPosition(PR.DefaultName);
		if (j == -1)
		{
			TeamFee[i] = 0;
			health = 100;
		}
		else {
			TeamFee[i] = GP.BotStats[j].Price;
			health = GP.BotStats[j].Health;
		}

		img = new class'GUIImage';
		img.WinLeft = X;
		img.WinTop = Y;
		img.WinWidth = BaseWidth;
		img.WinHeight = img.WinWidth*2.7;
		img.Image = PortraitBGMat;
		img.ImageStyle = ISTY_Scaled;
		img.RenderWeight = 0.11;
		img.Hint = PR.DefaultName;
		img.bBoundToParent = true;
		AppendComponent(img, true);

		btn = new class'GUIButton';
		btn.WinLeft = img.WinLeft;
		btn.WinTop = img.WinTop;
		btn.WinWidth = img.WinWidth;
		btn.WinHeight = img.WinHeight;
		btn.RenderWeight = 0.5;
		btn.OnHover = ShowPlayerDetails;
		btn.StyleName = "NoBackground";
		btn.Tag = i;
		btn.bBoundToParent = true;
		AppendComponent(btn, true);

		img2 = new class'GUIImage';
		img2.WinLeft = img.WinLeft+0.00125;
		img2.WinTop = img.WinTop+0.008;
		img2.WinWidth = img.WinWidth-0.0025;
		img2.WinHeight = img.WinHeight-0.015;
		img2.Image = PR.Portrait;
		img2.ImageStyle = ISTY_Scaled;
		img2.RenderWeight = 0.12;
		img2.Hint = PR.DefaultName;
		img2.ImageRenderStyle = MSTY_Alpha;
		img2.ImageColor.A = 255;
		img2.bBoundToParent = true;
		if (Health < 100)
		{
			img2.ImageColor.G = Health*1.5;
			img2.ImageColor.B = Health*1.5;
		}
		AppendComponent(img2, true);
		imgFaces[i] = img2;

		lbl = new class'GUILabel';
		lbl.WinLeft = img.WinLeft;
		lbl.WinWidth = img.WinWidth;
		lbl.WinHeight = 0.09;
		lbl.WinTop = img.WinTop+0.01;
		lbl.RenderWeight = 0.13;
		lbl.StyleName = "TextLabel";
		lbl.bMultiLine = true;
		if (j > -1) lbl.Caption = GP.BotStats[j].Name;
		lbl.TextALign = TXTA_Center;
		lbl.ShadowOffsetX = 1.5;
		lbl.ShadowOffsetY = 1.5;
		lbl.bBoundToParent = true;
		AppendComponent(lbl, true);

		if (!bNoBalanceCheck)
		{
			lbl = new class'GUILabel';
			lbl.WinLeft = img.WinLeft-0.01;
			lbl.WinWidth = img.WinWidth;
			lbl.WinHeight = 0.09;
			lbl.WinTop = img.WinTop+(img.WinHeight*(WinWidth/WinHeight))-lbl.WinHeight;
			lbl.RenderWeight = 0.13;
			lbl.StyleName = "TextLabel";
			lbl.bMultiLine = true;
			lbl.Caption = repl(MinimalFeeCaption, "%fee%", GP.MoneyToString(round(float(TeamFee[i])*GP.LoserFee)));
			lbl.TextALign=TXTA_Right;
			lbl.ShadowOffsetX = 1.5;
			lbl.ShadowOffsetY = 1.5;
			lbl.bBoundToParent = true;
			AppendComponent(lbl, true);
		}

		if (Health < 100)
		{
			lbl = new class'GUILabel';
			lbl.WinLeft = img.WinLeft;
			lbl.WinWidth = img.WinWidth;
			lbl.WinHeight = 0.05;
			lbl.WinTop = img.WinTop+(img.WinHeight/3);
			lbl.RenderWeight = 0.13;
			lbl.TextColor.R = 255;
			lbl.TextColor.G = 0;
			lbl.TextColor.B = 0;
			lbl.Caption = InjuredCaption;
			lbl.TextALign=TXTA_Center;
			lbl.bBoundToParent = true;
			AppendComponent(lbl, true);
		}

		cb = new class'GUIComboBox';
		cb.WinLeft = X-0.005;
		cb.WinTop = img.WinTop+(img.WinHeight*(WinWidth/WinHeight));
		cb.WinWidth = BaseWidth+0.01;
		cb.WinHeight = 0.036;
		cb.bReadOnly = true;
		cb.bShowListOnFocus = true;
		cb.OnChange = onRoleChange;
		cb.tag = i;
		cb.TabOrder = 3+i;
		cb.bBoundToParent = true;
		cb.Edit.FontScale = FNS_Small;
		AppendComponent(cb);
		cbRoles[i] = cb;

		for (j = 0; j < GP.GetNumPositions(); j++)
		{
			cb.AddItem(GP.PositionName[j]);
		}
		cb.AddItem(InactiveMsg);
		cb.Find(InactiveMsg);
		// only set assigned role when there's still room
		if ((AssignedRoles < MaxTeamMates) && (img2.Image != none) && (Health >= 100))
		{
			for (j = 0; j < GP.LINEUP_SIZE; j++)
			{
				if (GP.PlayerLineup[j] == i)
				{
					cb.Find(GP.TextPositionDescription(GP.PlayerPositions[i]));
					if(!bNoBalanceCheck) CurrentFee += TeamFee[i];
					AssignedRoles++;
					break;
				}
			}
		}
		if ((cb.Get() ~= InactiveMsg) || (img2.Image == none) || (Health < 100))
		{
			// no free spot, so disable
			cb.DisableMe();
			img2.ImageColor.A = 128;
		}

		X += BaseWidth+Spacing;
	}
	// check to see if we need more team mates
	for (i = 0; i < GP.GetMaxTeamSize(); i++)
	{
		if ((cbRoles[i].Get() ~= InactiveMsg) && (imgFaces[i].Image != none)
			&& (imgFaces[i].ImageColor.G >= 255) && (AssignedRoles < MaxTeamMates)) // activate player
		{
			cbRoles[i].SetIndex(0);	// auto assign
			cbRoles[i].EnableMe();
			imgFaces[i].ImageColor.A = 255;
			AssignedRoles++;
			if(!bNoBalanceCheck) CurrentFee += TeamFee[i];
		}
	}
	setOkButtonState();
}

function bool InternalOnClick(GUIComponent Sender)
{
	local int i, cpos;
	local bool res;

	res = Controller.CloseMenu(Sender != btnOk);
	if (Sender == btnOk)
	{
		// reset old data
		for (i = 0; i < GP.LINEUP_SIZE; i++)
		{
			GP.PlayerLineup[i] = -1;
		}
		// set new data
		cpos = 0;
		for (i = 0; i < cbRoles.length; i++)
		{
			if (cbRoles[i].Get() != InactiveMsg)
			{
				GP.SetLineup(cpos, i);
				GP.SetPosition(cpos, cbRoles[i].Get());
				cpos++;
			}
		}
		OnOkClick();
	}
	return res;
}

/**
	A role has changed, check the constraints
*/
function onRoleChange(GUIComponent Sender)
{
	local int i;
	if (bInit) return;

	AssignedRoles = 0;
	CurrentFee = 0;
	if (cbRoles[Sender.Tag].Get() ~= InactiveMsg)	imgFaces[Sender.Tag].ImageColor.A = 128;
		else imgFaces[Sender.Tag].ImageColor.A = 255;
	for (i = 0; i < cbRoles.length; i++)
	{
		if (cbRoles[i].Get() != InactiveMsg)
		{
			AssignedRoles++;
			if(!bNoBalanceCheck) CurrentFee += TeamFee[i];
		}
	}
	// enable/disable assigned roles
	for (i = 0; i < cbRoles.length; i++)
	{
		if ((cbRoles[i].Get() ~= InactiveMsg) && (imgFaces[i].Image != none)
			&& (imgFaces[i].ImageColor.G >= 255))
		{
			if (AssignedRoles < MaxTeamMates)
			{
				cbRoles[i].EnableMe();
			}
			else {
				cbRoles[i].DisableMe();
			}
		}
	}
	// enable ok if all is assigned
	setOkButtonState();
}

function setOkButtonState()
{
	local bool enable;
	enable = (AssignedRoles == MaxTeamMates);
	if(!bNoBalanceCheck)
	{
		if ((float(CurrentFee)*GP.LoserFee) < GP.Balance)
		{ // has enough cache to pay out
			enable = enable && true;
			lblNoMoney.bVisible = false;
		}
		else {
			enable = false;
			lblNoMoney.bVisible = true;
		}
	}
	else lblNoMoney.bVisible = false;
	if (enable) btnOk.EnableMe();
		else btnOk.DisableMe();
}

function bool ShowPlayerDetails( GUIComponent Sender )
{
	local string PlayerDetails;
	local XUtil.PlayerRecord ActivePR;

	if (Sender.Tag < 0) return false;

	ActivePR = class'XUtil'.static.FindPlayerRecord(GP.PlayerTeam[Sender.Tag]);
	PlayerDetails = ActivePR.DefaultName;
	PlayerDetails $= "|"$AccuracyCaption@class'XUtil'.static.AccuracyRating(ActivePR)$"%";
	PlayerDetails $= "|"$AggressionCaption@class'XUtil'.static.AggressivenessRating(ActivePR)$"%";
	PlayerDetails $= "|"$AgilityCaption@class'XUtil'.static.AgilityRating(ActivePR)$"%";
	PlayerDetails $= "|"$TacticsCaption@class'XUtil'.static.TacticsRating(ActivePR)$"%";
	PlayerDetails $= "|"$class'xUtil'.static.GetFavoriteWeaponFor(ActivePR);
	sbCharInfo.SetContent(PlayerDetails);
	return true;
}

defaultproperties
{
	Begin Object Class=GUIButton Name=SPMbtnOk
		Caption="OK"
		WinWidth=0.200000
		WinHeight=0.040000
		WinLeft=0.764064
		WinTop=0.912292
		OnClick=InternalOnClick
		RenderWeight=0.2
		FontScale=FNS_Small
		TabOrder=1
		bBoundToParent=True
	End Object
	btnOk=SPMbtnOk

	Begin Object Class=GUIButton Name=SPTbtnCancel
		Caption="CANCEL"
		WinWidth=0.200000
		WinHeight=0.040000
		WinLeft=0.532813
		WinTop=0.912292
		OnClick=InternalOnClick
		RenderWeight=0.2
		FontScale=FNS_Small
		TabOrder=2
		bBoundToParent=True
	End Object
	btnCancel=SPTbtnCancel

	Begin Object Class=GUILabel Name=SPTlblTitle
		Caption="Team roster"
		WinWidth=0.806251
		WinHeight=0.065000
		WinLeft=0.089063
		WinTop=0.041666
		RenderWeight=0.2
		StyleName="TextLabel"
		FontScale=FNS_Large
		TextALign=TXTA_Center
		bBoundToParent=True
	End Object
	lblTitle=SPTlblTitle

	Begin Object Class=GUILabel Name=SPTlblInfo
		Caption="%gametype% in %map% with %teammates% team mates"
		WinWidth=0.931251
		WinHeight=0.058750
		WinLeft=0.032813
		WinTop=0.100000
		RenderWeight=0.2
		StyleName="TextLabel"
		bMultiLine=true
		TextALign=TXTA_Center
		bBoundToParent=True
	End Object
	lblInfo=SPTlblInfo

	Begin Object Class=GUILabel Name=SPTlblNoMoney
		Caption="You do not have enough money to pay this team's minimal fee"
		WinWidth=0.431250
		WinHeight=0.102500
		WinLeft=0.532813
		WinTop=0.758334
		RenderWeight=0.2
		TextColor=(R=228,G=0,B=0,A=255)
		bMultiLine=true
		TextALign=TXTA_Center
		//bVisible=false
		ShadowOffsetX=1
		ShadowOffsetY=1
		bBoundToParent=True
	End Object
	lblNoMoney=SPTlblNoMoney

	Begin Object Class=GUILabel Name=SPTlblBalance
		Caption="Balance: %balance%"
		WinWidth=0.415000
		WinHeight=0.040000
		WinLeft=0.556563
		WinTop=0.049999
		RenderWeight=0.2
		StyleName="TextLabel"
		bMultiLine=true
		TextALign=TXTA_Right
		bBoundToParent=True
	End Object
	lblBalance=SPTlblBalance

	Begin Object Class=GUIScrollTextBox Name=SPTsbCharInfo
		WinWidth=0.468750
		WinHeight=0.212500
		WinLeft=0.032500
		WinTop=0.726666
		bNoTeletype=true
		RenderWeight=0.2
		bVisibleWhenEmpty=true
		FontScale=FNS_Medium
		TabOrder=3
		bBoundToParent=True
	End Object
	sbCharInfo=SPTsbCharInfo

	PortraitBGMat=material'2K4Menus.Controls.sectionback'

	DefaultWidth=1
	DefaultHeight=0.88
	DefaultLeft=0.00
	DefaultTop=0.06

	WinWidth=1
	WinHeight=0.88
	WinLeft=0.00
	WinTop=0.06

	InactiveMsg="INACTIVE"
	MinimalFeeCaption="Minimal fee:|%fee%"
	InjuredCaption="INJURED"

	AggressionCaption="Aggressiveness:"
	AgilityCaption="Agility:"
	AccuracyCaption="Accuracy:"
	TacticsCaption="Tactics:"
}

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