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

GUI2K4.UT2K4SP_LadderLoading


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
//==============================================================================
// Single Player loading screen (rewrite)
//
// Written by Michiel Hendriks
// (c) 2003, Epic Games, Inc. All Rights Reserved
//==============================================================================

class UT2K4SP_LadderLoading extends UT2K4LoadingPageBase;

var UT2K4GameProfile GP;
var UT2K4MatchInfo MI;
var UnrealTeamInfo ETI;
var array<xUtil.PlayerRecord> PlayerList;

var Material MapScreenshot;
var Material ImageFrame;

/** number of team mates, if any */
var int NumTeamMates;

/** The frame to use for the team leader */
var Material LeaderFrame;
/** The frame around all players */
var Material CharFrame;
/** the image to use for mystery players */
var Material MysteryPlayer;
var Color	White, Yellow, Blue, Red;

var localized string LoadingMessage;
var localized string StatNames[5];

/** local storage to calculate the team stats */
var array<string> TeamPlayers, EnemyPlayers;

simulated event init()
{
	local class<UnrealTeamInfo> ETIclass;

	GP = UT2K4GameProfile(Level.Game.CurrentGameProfile);
	if (GP != none) MI = UT2K4MatchInfo(GP.GetMatchInfo(GP.CurrentLadder, GP.CurrentMenuRung));
	if ((GP == none) || (MI == none))
	{
		Warn("GP =="@GP@", MI =="@MI);
		return;
	}

	MapScreenshot = Material(DynamicLoadObject(GP.ActiveMap.ScreenshotRef, class'Material', true));
	if (MaterialSequence(MapScreenshot) != none) MapScreenshot = MaterialSequence(MapScreenshot).SequenceItems[0].Material;

	AddBackground();
	AddMatchInfo();

	//Sark: The Master Control Program has chosen you to serve your system on the game grid.
	ETIclass = class<UnrealTeamInfo>(DynamicLoadObject(GP.EnemyTeam, class'Class'));
	ETI = spawn(ETIclass);

	if ( ETI == None )
	{
		Warn("ETI =="@ETI@ETIclass@GP.EnemyTeam);
		return;
	}
	NumTeamMates = GP.GetNumTeammatesForMatch();
	if (UT2K4DMRoster(ETI) != none)	UT2K4DMRoster(ETI).PreInitialize(MI.NumBots-NumTeamMates);
	else ETI.Initialize(MI.NumBots-NumTeamMates);

	class'xUtil'.static.GetPlayerList(PlayerList);

	if (NumTeamMates == 0)
	{
		AddPlayerCircle();
	}
	else {
		AddTeamInfo();
		AddEnemyInfo();
		AddTeamCompare();
	}
}

/**
	Add a backgroun image
*/
simulated function AddBackground()
{
	local Material Bg;
	Bg = MapScreenshot;
	if (Bg == none) Bg = DLOTexture("InterfaceContent.Backgrounds.bg10");
	if (Bg != None) AddImage(Bg, 0.0, 0.0, 1.0, 1.0).DrawColor=Class'Canvas'.static.MakeColor(196,196,0);
}

/**
	Add match info
*/
simulated function AddMatchInfo()
{
	local string Title;
	local DrawOpText tmp;
	AddImage(ImageFrame, 0.34, 0.299, 0.32, 0.402);
	AddImage(MapScreenshot, 0.35, 0.3, 0.3, 0.4);

	if ( MI.MenuName != "" ) Title = MI.MenuName;
	else {
		if (GP.ActiveMap.FriendlyName != "") Title = GP.ActiveMap.FriendlyName;
		else Title = GP.ActiveMap.MapName;
	}
	tmp = AddJustifiedText(Title, 1, 0.572, 0.302, 0.1, 0.4, 1);
	tmp.FontName = "GUI2K4.fntUT2k4Header";
	tmp.DrawColor = Class'Canvas'.static.MakeColor(0,0,0,196);
	tmp.bWrapText = false;
	tmp = AddJustifiedText(Title, 1, 0.57, 0.3, 0.1, 0.4, 1);
	tmp.bWrapText = false;
	tmp.FontName = "GUI2K4.fntUT2k4Header";

	tmp = AddJustifiedText(GP.GetMatchDescription(), 1, 0.332, 0.302, 0.1, 0.4, 1);
	tmp.FontName = "GUI2K4.fntUT2k4Header";
	tmp.DrawColor = Class'Canvas'.static.MakeColor(0,0,0,196);
	tmp.bWrapText = false;
	tmp = AddJustifiedText(GP.GetMatchDescription(), 1, 0.33, 0.3, 0.1, 0.4, 1);
	tmp.bWrapText = false;
	tmp.FontName = "GUI2K4.fntUT2k4Header";

	tmp = AddJustifiedText(LoadingMessage, 1, 0.452, 0.302, 0.1, 0.4, 1);
	tmp.FontName = "GUI2K4.fntUT2k4Header";
	tmp.DrawColor = Class'Canvas'.static.MakeColor(0,0,0,64);
	tmp.bWrapText = false;
	tmp = AddJustifiedText(LoadingMessage, 1, 0.452, 0.3, 0.1, 0.4, 1);
	tmp.FontName = "GUI2K4.fntUT2k4Header";
	tmp.DrawColor = Class'Canvas'.static.MakeColor(255,255,255,196);
	tmp.bWrapText = false;
}

/**
	Draw the player portaits in a circle (square)
*/
simulated function AddPlayerCircle()
{
	local int i;
	local float dist, cX, cY, cR, imgW, imgH, bX, bY;
	local float oX, oY;
	local Material Portrait;

	dist = 2 * Pi / (MI.NumBots+1);

	cX = 0.5;
	cY = 0.5;
	cR = 0.03;
	imgW = 0.11;
	imgH = 0.3;
	// border
	bX = (imgH/2)+cR;
	bY = (imgW/2)+cR*(4/3);

	// draw ourself
	Portrait = getPlayerPortrait(GP.PlayerCharacter);
	AddImage(Portrait, cR, cY-(imgW/2), imgH, imgW);
	AddImage(CharFrame, cR, cY-(imgW/2), imgH, imgW);
	// draw the rest
	for (i = 0; i < MI.NumBots; i++)
	{
		if (i > ETI.Roster.length) Portrait = MysteryPlayer;
			else Portrait = getPlayerPortrait(ETI.Roster[i].PlayerName);
		// I'm going to burn in hell
		oX = sin( -1*(i+1)*dist+(Pi/2) );
		oX = fclamp(cX-oX, 0+bX, 1-bX);
		oY = cos( -1*(i+1)*dist+(Pi/2) );
		oY = fclamp(cY-oY, 0+bY, 1-bY);
		AddImage(Portrait, oX-(imgH/2), oY-(imgW/2), imgH, imgW);
		AddImage(CharFrame, oX-(imgH/2), oY-(imgW/2), imgH, imgW);
	}
}

/**
	Add own team symbol and players
*/
simulated function AddTeamInfo()
{
	local int i, numplayers;

	TeamPlayers[0] = GP.PlayerCharacter;
	numplayers = MI.NumBots / 2;  // purposeful integer truncate on odd number of bots
	for (i = 0; i<numplayers; i++)
	{
		TeamPlayers[i+1] = GP.PlayerTeam[GP.PlayerLineup[i]];
	}

	AddTeamBar(0, GP.TeamSymbolName, TeamPlayers, 0.03, class'Canvas'.static.MakeColor(64, 64, 255));
}

/**
	Add enemy team symbol and player
*/
simulated function AddEnemyInfo()
{
	local int i, numplayers;

	numplayers = MI.NumBots /2;
	if ( MI.NumBots % 2 == 1 )
	{
		numplayers++;  // bot team get the extra player
	}
	ETI.Initialize(numplayers);
	for (i = 0; i < numplayers; i++)
	{
		EnemyPlayers[i] = ETI.Roster[i].PlayerName;
	}
	AddTeamBar(1, ETI.TeamSymbolName, EnemyPlayers, 0.7, class'Canvas'.static.MakeColor(255, 0, 0), true);
}

/** The actual drawing of the team info */
simulated function AddTeamBar(int TeamId, string TeamIconName, out array<string> Crew, float top, Color TeamColor, optional bool bNameUp)
{
	local Material TSym, Portrait;
	local float ILeft, ISpace, ImgW, ImgH, IconBoxW, IconBoxH;
	local int i;
	local DrawOpImage dop;

	// Part 1: Get The Team Symbol
	TSym = DLOTexture(TeamIconName);

	// Precompute a couple of sizes
	ImgW = 0.1;
	ImgH = 0.275;
	ISpace = 0.03 + (7-Crew.Length) * 0.01;
	IconBoxW = 0.3;
	IconBoxH = 0.4;

	// Figure out where we will start adding them
	ILeft = (1.0 - (Crew.Length * (ImgW + ISpace) - ISpace)) / 2.0;

	TeamColor.A = 70;

	if (TeamId == 0)
		dop = AddImage(TSym, 0.01, 0.01, IconBoxH, IconBoxW);
	else
		dop = AddImage(TSym, 0.99 - IconBoxH, 0.99 - IconBoxW, IconBoxH, IconBoxW);
	dop.DrawColor = TeamColor;
	dop.RenderStyle = 5; // Alpha

	TeamColor.A = 255;

	// Add Crew Portraits
	for (i=0; i<Crew.Length; i++)
	{
		//Log("Crew member "$Crew[i]$" is "$i$" of "$Crew.Length);
		Portrait = getPlayerPortrait(Crew[i]);
		AddImage(Portrait, top, ILeft, ImgH, ImgW);
		if (i == 0) AddImage(LeaderFrame, top, ILeft, ImgH, ImgW);
			else AddImage(CharFrame, top, ILeft, ImgH, ImgW);
		ILeft = ILeft + ImgW + ISpace;
	}

}

/** Team stats */
simulated function AddTeamCompare()
{
	local array<int> Team1Stat, Team2Stat;
	local string TxtFont, SmallTxtFont, tmp;
	local float TopLine, LineSpc;
	local int i;
	local DrawOpText	Op;

	Team1Stat[0] = class'xUtil'.static.TeamArrayAccuracyRating(TeamPlayers);
	Team1Stat[1] = class'xUtil'.static.TeamArrayAggressivenessRating(TeamPlayers);
	Team1Stat[2] = class'xUtil'.static.TeamArrayAgilityRating(TeamPlayers);
	Team1Stat[3] = class'xUtil'.static.TeamArrayTacticsRating(TeamPlayers);

	Team2Stat[0] = class'xUtil'.static.TeamArrayAccuracyRating(EnemyPlayers);
	Team2Stat[1] = class'xUtil'.static.TeamArrayAggressivenessRating(EnemyPlayers);
	Team2Stat[2] = class'xUtil'.static.TeamArrayAgilityRating(EnemyPlayers);
	Team2Stat[3] = class'xUtil'.static.TeamArrayTacticsRating(EnemyPlayers);

	TopLine = 0.32;
	LineSpc = 0.425/6;
	TxtFont = "XInterface.UT2HeaderFont";
	SmallTxtFont = "GUI2K4.fntUT2K4Medium"; //fntUT2k4MidGame";

	Op = AddJustifiedText(GP.TeamName, 2, TopLine, 0.05, LineSpc, 0.23, 1);
	Op.FontName = TxtFont;
	Op.DrawColor = Blue;

	Op = AddJustifiedText(ETI.TeamName, 0, TopLine, 0.72, LineSpc, 0.23, 1);
	Op.FontName = TxtFont;
	Op.DrawColor = Red;

	for (i = 1; i<5; i++)
	{
		TopLine += LineSpc;
		AddJustifiedText(StatNames[i], 1, TopLine, 0.0, LineSpc, 0.2, 1).FontName = SmallTxtFont;	// Centered
		AddJustifiedText(StatNames[i], 1, TopLine, 0.80, LineSpc, 0.2, 1).FontName = SmallTxtFont;	// Centered

		tmp = string(Team1Stat[i-1]);
		tmp $= "%";
		Op = AddJustifiedText(tmp, 2, TopLine, 0.05, LineSpc, 0.23, 1);
		Op.FontName = TxtFont;
		if (Team1Stat[i-1] >= Team2Stat[i-1])
			Op.DrawColor = Yellow;

		tmp = string(Team2Stat[i-1]);
		tmp $= "%";
		Op = AddJustifiedText(tmp, 0, TopLine, 0.72, LineSpc, 0.23, 1);
		Op.FontName = TxtFont;
		if (Team2Stat[i-1] >= Team1Stat[i-1])
			Op.DrawColor = Yellow;
	}
}

simulated function Material getPlayerPortrait(string playerName)
{
	local int i;

	for ( i=0; i < PlayerList.length; i++ ) {
		if ( PlayerList[i].DefaultName == playername ) {
			return PlayerList[i].Portrait;
		}
	}
	return none;
}

defaultproperties
{
     ImageFrame=Texture'2K4Menus.Controls.sectionback'
     LeaderFrame=FinalBlend'InterfaceContent.Menu.CharFrame_Final'
     CharFrame=FinalBlend'InterfaceContent.Menu.CharFrame_Final'
     MysteryPlayer=Texture'PlayerPictures.cDefault'
     White=(B=255,G=255,R=255,A=255)
     Yellow=(G=255,R=255,A=255)
     Blue=(B=255,G=64,R=64,A=255)
     Red=(R=255,A=255)
     LoadingMessage="loading"
     StatNames(0)="VS"
     StatNames(1)="Accuracy"
     StatNames(2)="Aggressiveness"
     StatNames(3)="Agility"
     StatNames(4)="Tactics"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: pr 5-2-2018 12:35:54.000 - Creation time: sk 18-3-2018 09:50:24.309 - Created with UnCodeX