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

XInterface.Tab_SPProfileLoad


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
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
// ====================================================================
//  Single player menu for loading profile.
//  author:  capps 8/26/02
// ====================================================================

class Tab_SPProfileLoad extends Tab_SPPanelBase;

var GUIListBox		lbProfiles;
var moEditBox		ebPlayerName, ebTeamName, ebDifficulty;
var moEditBox		ebKills, ebDeaths, ebGoals, ebWins, ebMatches;
var GUIImage		imgPlayerSkin, imgTeamSymbol;
var GUIButton		butNew;

var localized string Difficulties[8];  // hardcoded for localization.  clamped 0,NumDifficulties where accessed.
var int NumDifficulties;			   // for external class access to size

var localized string DeleteMessage;

function InitComponent(GUIController pMyController, GUIComponent MyOwner)
{
local GameProfile GP;

	Super.Initcomponent(pMyController, MyOwner);

	butNew=GUIButton(Controls[0]);
	lbProfiles=GUIListBox(Controls[1]);
	lbProfiles.List.OnDblClick=DoubleClickList;
	ebPlayerName=moEditBox(Controls[2]);
	ebTeamName=moEditBox(Controls[3]);
	ebDifficulty=moEditBox(Controls[4]);
	ebKills=moEditBox(Controls[5]);
	ebDeaths=moEditBox(Controls[6]);
	ebGoals=moEditBox(Controls[7]);
	imgPlayerSkin=GUIImage(Controls[8]);
	imgTeamSymbol=GUIImage(Controls[10]);
	ebWins=moEditBox(Controls[18]);
	ebMatches=moEditBox(Controls[19]);

	// if there exists a profile currently, set it to that one by default
	GP = GetProfile();
	if ( GP != none )
	{
		lbProfiles.List.Find(GP.PackageName);
		// MC: Then tell all pages that a profile is present
		ProfileUpdated();
		// Check if a Button was stored in GP and use it to focus entry page.
		if (LadderButton(GP.NextMatchObject) != None)
		{
			if (LadderButton(GP.NextMatchObject).LadderIndex > 0)
				MyTabControl().ActivateTabByName(class'UT2SinglePlayerMain'.default.TabNameLadder, true);
			else
				MyTabControl().ActivateTabByName(class'UT2SinglePlayerMain'.default.TabNameQualification, true);
		}
	}

	UpdateList();
}

function InitPanel()
{
	Super.InitPanel();
	MyButton.Hint = class'UT2SinglePlayerMain'.default.TabHintProfileLoad;
	UT2SinglePlayerMain(MyButton.MenuOwner.MenuOwner).ResetTitleBar(MyButton);
}

function OnProfileUpdated()
{
	UpdateList();
}

// update the profile listing by rechecking disk, needed after create or delete
function UpdateList()
{
local array<string> profilenames;
local int i;
local GameProfile GP;

	Controller.GetProfileList("",profilenames);
	lbProfiles.List.Clear();

	for ( i=0; i<profilenames.Length; i++ )
	{
		lbProfiles.List.Add(profilenames[i]);
	}

	GP = GetProfile();
	if ( GP != none )
		lbProfiles.List.Find(GP.PackageName);

	UpdateStats();
}

// update all the various boxes to show the stats of this profile
function UpdateStats()
{
	local string profilename;
	local GameProfile GP;
	local xUtil.PlayerRecord PR;

	// get current profile from list
	profilename = lbProfiles.List.Get();
	if ( profilename == "" )
	{
		// reset name, team, difficulty
		ebPlayerName.SetText("");
		ebTeamName.SetText("");
		ebDifficulty.SetText(Difficulties[2]);
		// reset character portrait and team symbol   was PlayerPictures.cDefault
		imgPlayerSkin.Image = Material(DynamicLoadObject("InterfaceContent.pEmptySlot", class'Material'));
		imgTeamSymbol.Image = none;
		// reset kills, death, goals
		ebKills.SetText("");
		ebDeaths.SetText("");
		ebGoals.SetText("");
		ebWins.SetText("");
		ebMatches.SetText("");
		return;
	}

	GP = PlayerOwner().Level.Game.LoadDataObject(class'GameProfile', "GameProfile", profilename);

	if ( GP == none ) {
		return;
	}

	PR = class'xGame.xUtil'.static.FindPlayerRecord(GP.PlayerCharacter);

	ebPlayerName.SetText(GP.PlayerName);
	ebTeamName.SetText(GP.TeamName);
	ebDifficulty.SetText(Difficulties[Clamp(int(GP.BaseDifficulty), 0, NumDifficulties)]);
	// reset character portrait and team symbol
	imgPlayerSkin.Image = PR.Portrait;
	imgTeamSymbol.Image = Material(DynamicLoadObject(GP.TeamSymbolName, class'Material'));
	// reset kills, death, goals
	ebKills.SetText(String(GP.Kills));
	ebDeaths.SetText(String(GP.Deaths));
	ebGoals.SetText(String(GP.Goals));
	ebWins.SetText(String(GP.Wins));
	ebMatches.SetText(String(GP.Matches));
}

////////////////////////////////////////////
// get current profile from list, load it, and apply it
//
function bool LoadClick(GUIComponent Sender)
{
local class<GameProfile> profileclass;
local string profilename;
local GameProfile GP;

	profilename = lbProfiles.List.Get();
	profileclass = class<GameProfile>(DynamicLoadObject("xGame.UT2003GameProfile", class'Class'));
	GP = PlayerOwner().Level.Game.LoadDataObject(profileclass, "GameProfile", profilename);
	if ( GP != none )
	{
		PlayerOwner().Level.Game.CurrentGameProfile = GP;
		GP.Initialize(PlayerOwner().Level.Game, profilename);
		if (GP.LadderRung[1] >= 0) { // player has unlocked main ladder
			MyTabControl().ActivateTabByName(class'UT2SinglePlayerMain'.default.TabNameLadder, true);
		} else {
			MyTabControl().ActivateTabByName(class'UT2SinglePlayerMain'.default.TabNameQualification, true);
		}

		ProfileUpdated();
	}
	return true;
}

function DeleteConfirm(byte bButton)
{
local string profilename;

	if (bButton == QBTN_Yes)
	{
		profilename = lbProfiles.List.Get();
		if ( GetProfile() != none && GetProfile().PackageName == profilename)
		{
			PlayerOwner().Level.Game.CurrentGameProfile = none;
		}
		if (!PlayerOwner().Level.Game.DeletePackage(profilename))
		{
			Log("SINGLEPLAYER Tab_SPProfileLoad::ButtonClick() failed to delete GameProfile "$profilename);
		}
		ProfileUpdated();
		UpdateList();
	}
}

////////////////////////////////////////////
// Delete the selected profile
//
function bool DeleteClick(GUIComponent Sender)
{
local GUIQuestionPage Page;
local string profilename;

	if (Controller.OpenMenu("XInterface.GUIQuestionPage"))
	{
		profilename = lbProfiles.List.Get();
		Page=GUIQuestionPage(Controller.TopPage());
		Page.SetupQuestion(Page.Replace(DeleteMessage, "prof", Caps(profilename)), QBTN_YesNo, QBTN_No);
		Page.OnButtonClick = DeleteConfirm;
	}
	return true;
}

//////////////////////////////////////////////////
// Activate the New Profile MenuPage.
//
function bool NewProfileClick(GUIComponent Sender)
{
	GUITabControl(MyButton.MenuOwner).ReplaceTab(MyButton, class'UT2SinglePlayerMain'.default.TabNameProfileNew, "xInterface.Tab_SPProfileNew", , , true);
	return true;
}

function InternalOnChange(GUIComponent Sender)
{
	UpdateStats();
}

function bool DoubleClickList(GUIComponent Sender)
{
	return LoadClick(Sender);
}

// when expose menu, might have come from the profile-create screen, so update the list
function ShowPanel(bool bShow) {
	Super.ShowPanel(bShow);
	if ( bShow ) {
		// just started game, no profiles exist, jump to create new
		if ( lbProfiles.List.ItemCount == 0 ) {
			UpdateStats();  // sets everything to empty
			NewProfileClick(butNew);
			return;
		}
	}
}

defaultproperties
{
	// List of loadable profiles
	Begin Object class=GUIListBox Name=lboxProfile
		Hint="Select a profile"
		WinWidth=0.264609
		WinHeight=0.610624
		WinLeft=0.330562
		WinTop=0.131667
		bAcceptsInput=true
		OnChange=InternalOnChange
	End Object

	Begin Object class=moEditBox Name=moebPlayerName
		Caption="Player Name: "
		Hint="Your character's name"
		LabelJustification=TXTA_Right
		LabelFont="UT2SmallFont"
		LabelColor=(R=255,G=255,B=255,A=255)
		CaptionWidth=0.55
		WinWidth=0.493750
		WinHeight=0.060000
		WinLeft=0.495360
		WinTop=0.143847
		bReadOnly=true
	End Object

	Begin Object class=moEditBox Name=moebTeamName
		Caption="Team Name: "
		Hint="The name of your team"
		LabelJustification=TXTA_Right
		LabelFont="UT2SmallFont"
		LabelColor=(R=255,G=255,B=255,A=255)
		CaptionWidth=0.55
		WinWidth=0.493750
		WinHeight=0.060000
		WinLeft=0.495360
		WinTop=0.212590
		bReadOnly=true
	End Object

	Begin Object class=moEditBox Name=moebDifficulty
		Caption="Difficulty: "
		Hint="Difficulty rating of this tournament"
		LabelJustification=TXTA_Right
		LabelFont="UT2SmallFont"
		LabelColor=(R=255,G=255,B=255,A=255)
		CaptionWidth=0.55
		WinWidth=0.493750
		WinHeight=0.060000
		WinLeft=0.495360
		WinTop=0.280038
		bReadOnly=true
	End Object

	Begin Object class=moEditBox Name=moebKills
		Caption="Kills: "
		Hint="Number of kills by this character"
		LabelJustification=TXTA_Right
		LabelFont="UT2SmallFont"
		LabelColor=(R=255,G=255,B=255,A=255)
		CaptionWidth=0.55
		WinWidth=0.493750
		WinHeight=0.060000
		WinLeft=0.495360
		WinTop=0.391236
		bReadOnly=true
	End Object

	Begin Object class=moEditBox Name=moebDeaths
		Caption="Deaths: "
		Hint="Number of times this character has died"
		LabelJustification=TXTA_Right
		LabelFont="UT2SmallFont"
		LabelColor=(R=255,G=255,B=255,A=255)
		CaptionWidth=0.55
		WinWidth=0.493750
		WinHeight=0.060000
		WinLeft=0.495360
		WinTop=0.458684
		bReadOnly=true
	End Object

	Begin Object class=moEditBox Name=moebGoals
		Caption="Goals: "
		Hint="Number of goals scored by this character"
		LabelJustification=TXTA_Right
		LabelFont="UT2SmallFont"
		LabelColor=(R=255,G=255,B=255,A=255)
		CaptionWidth=0.55
		WinWidth=0.493750
		WinHeight=0.060000
		WinLeft=0.495360
		WinTop=0.528632
		bReadOnly=true
	End Object

	// cool border for the portrait
	Begin Object class=GUIImage Name=imageSkinBack
		WinWidth=0.138300
		WinHeight=0.510000
		WinLeft=0.171195
		WinTop=0.158646
		Image=Material'InterfaceContent.Menu.BorderBoxA1'
		ImageColor=(R=255,G=255,B=255,A=255);
		ImageRenderStyle=MSTY_Normal
		ImageStyle=ISTY_Stretched
	End Object

	// portrait of the selected character
	Begin Object class=GUIImage Name=imagePlayerSkin
		Hint="Your character's appearance"
		WinWidth=0.133300
		WinHeight=0.500000
		WinLeft=0.173148
		WinTop=0.162552
		Image=Material'InterfaceContent.Menu.BorderBoxD'
		ImageColor=(R=255,G=255,B=255,A=255);
		ImageRenderStyle=MSTY_Normal
		ImageStyle=ISTY_Scaled
	End Object

	// team symbol
	Begin Object class=GUIImage Name=imageTeamSymbol
		Hint="Your team's symbol"
		WinWidth=0.150000
		WinHeight=0.277800
		WinLeft=0.016538
		WinTop=0.262500
		Image=Material'InterfaceContent.Menu.SimpleBorder_F'
		ImageColor=(R=255,G=255,B=255,A=255);
		ImageRenderStyle=MSTY_Normal
		ImageStyle=ISTY_Scaled
	End Object

	Begin Object Class=GUIButton Name=btnDelete
		Caption="DELETE PROFILE"
		Hint="Delete the currently selected profile"
		OnClick=DeleteClick
		WinWidth=0.218750
		WinHeight=0.075000
		WinLeft=0.141250
		WinTop=0.925
	End Object

	Begin Object Class=GUIButton Name=btnLoad
		Caption="LOAD PROFILE"
		Hint="Load the selected profile"
		OnClick=LoadClick
		WinWidth=0.200000
		WinHeight=0.075000
		WinLeft=0.412500
		WinTop=0.925
	End Object

	Begin Object Class=GUIButton Name=btnNew
		Caption="NEW PROFILE"
		Hint="Go to the profile creation menu"
		OnClick=NewProfileClick
		WinWidth=0.200000
		WinHeight=0.075000
		WinLeft=0.661250
		WinTop=0.925
	End Object

	// border to go around profile data
	Begin Object class=GUIImage Name=SPPLDataBox
		WinWidth=0.393751
		WinHeight=0.613750
		WinLeft=0.601563
		WinTop=0.131250
		Image=Material'InterfaceContent.Menu.BorderBoxD'
		ImageColor=(R=255,G=255,B=255,A=160);
		ImageRenderStyle=MSTY_Alpha
		ImageStyle=ISTY_Stretched
	End Object

	// border to go around images
	Begin Object class=GUIImage Name=SPPLImageBox
		WinWidth=0.318752
		WinHeight=0.612187
		WinLeft=0.006251
		WinTop=0.131250
		Image=Material'InterfaceContent.Menu.BorderBoxD'
		ImageColor=(R=255,G=255,B=255,A=160);
		ImageRenderStyle=MSTY_Alpha
		ImageStyle=ISTY_Stretched
	End Object

	// PROFILE STATS label
	Begin Object class=GUILabel Name=SPPLLblStats
		Caption="PROFILE STATS"
		TextALign=TXTA_Center
		TextFont="UT2SmallFont"
		TextColor=(R=255,G=255,B=255,A=255)
		WinWidth=0.400000
		WinHeight=0.100000
		WinLeft=0.592186
		WinTop=0.734586
	End Object
	// PROFILE STATS label
	Begin Object class=GUILabel Name=SPPLLblProfiles
		Caption="PROFILE LISTING"
		TextALign=TXTA_Center
		TextFont="UT2SmallFont"
		TextColor=(R=255,G=255,B=255,A=255)
		WinWidth=0.400000
		WinHeight=0.100000
		WinLeft=0.264062
		WinTop=0.730417
	End Object

	// cool border for the team symbol
	Begin Object class=GUIImage Name=symbolBack
		WinWidth=0.149042
		WinHeight=0.273672
		WinLeft=0.015922
		WinTop=0.265417
		Image=Material'InterfaceContent.Menu.BorderBoxA1'
		ImageColor=(R=255,G=255,B=255,A=255);
		ImageRenderStyle=MSTY_Normal
		ImageStyle=ISTY_Stretched
	End Object

	Begin Object class=moEditBox Name=moebWins
		Caption="Wins: "
		Hint="Number of matches won by this character"
		LabelJustification=TXTA_Right
		LabelFont="UT2SmallFont"
		LabelColor=(R=255,G=255,B=255,A=255)
		CaptionWidth=0.55
		WinWidth=0.493751
		WinHeight=0.060000
		WinLeft=0.495315
		WinTop=0.597135
		bReadOnly=true
	End Object
	Begin Object class=moEditBox Name=moebMatches
		Caption="Matches: "
		Hint="Number of matches played by this character"
		LabelJustification=TXTA_Right
		LabelFont="UT2SmallFont"
		LabelColor=(R=255,G=255,B=255,A=255)
		CaptionWidth=0.55
		WinWidth=0.493750
		WinHeight=0.060000
		WinLeft=0.495360
		WinTop=0.667852
		bReadOnly=true
	End Object

	Controls(0)=btnNew
	Controls(1)=lboxProfile
	Controls(2)=moebPlayerName
	Controls(3)=moebTeamName
	Controls(4)=moebDifficulty
	Controls(5)=moebKills
	Controls(6)=moebDeaths
	Controls(7)=moebGoals

	Controls(8)=imagePlayerSkin
	Controls(9)=imageSkinBack
	Controls(10)=imageTeamSymbol

	Controls(11)=btnDelete
	Controls(12)=btnLoad

	Controls(13)=SPPLDataBox
	Controls(14)=SPPLImageBox
	Controls(15)=SPPLLblStats
	Controls(16)=SPPLLblProfiles

	Controls(17)=symbolBack
	Controls(18)=moebWins
	Controls(19)=moebMatches

	//Background=Material'InterfaceContent.Backgrounds.bg10'
	WinTop=0.15
	WinLeft=0
	WinWidth=1
	WinHeight=0.77
	bAcceptsInput=false
	//bFillHeight=true		// get it to fill vertical space from tab top

	// The Bots Skills should be stored and accessible somewhere in Engine.
	Difficulties(0)="Novice"
	Difficulties(1)="Average"
	Difficulties(2)="Experienced"
	Difficulties(3)="Skilled"
	Difficulties(4)="Adept"
	Difficulties(5)="Masterful"
	Difficulties(6)="Inhuman"
	Difficulties(7)="Godlike"
	NumDifficulties=8
	DeleteMessage="You are about to delete the profile for '%prof%'||Are you sure you want to delete this profile?"
}

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