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

GUI2K4.UT2K4SPTab_ProfileNew


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
//==============================================================================
// Create a new single player profile
//
// Written by Michiel Hendriks
// (c) 2003, Epic Games, Inc. All Rights Reserved
//==============================================================================

class UT2K4SPTab_ProfileNew extends UT2K4SPTab_Base;

var automated GUISectionBackground sbEditBg, sbPortraitBack, sbSponsorBack;
var automated GUIButton btnPrevSkin, btnNextSkin, btnPrevSponsor, btnNextSponsor;
var automated moEditBox edName, edTeam;
var automated moComboBox cbDifficulty;
var automated GUICharacterListTeam clPlayerSkins;
var automated GUIImageList ilSponsor;

var	localized string DefaultTeamName;
var string DefaultCharacter, TeamSponsorPrefix;
var int DefaultDifficulty, DefaultTeamSponsor;

/** more agents to add to the free agent pool */
var array<string> InitialFreeAgents;

/**
	The URL to visit after a profile has been created, the profile name will be appended to the end
*/
var string GameIntroURL;

var localized string ErrorProfileExists, ErrorCantCreateProfile;
var() localized string    DifficultyLevels[8];

function InitComponent(GUIController pMyController, GUIComponent MyOwner)
{
	local int i;
	Super.Initcomponent(pMyController, MyOwner);
	edName.MyEditBox.MaxWidth=16;  // as per polge, check UT2K4Tab_PlayerSettings if you change this
	edName.MyEditBox.AllowedCharSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_";

	clPlayerSkins.InitListInclusive("SP");

	for(i = 0; i < 8; i++)
		cbDifficulty.AddItem(DifficultyLevels[i]);

	LoadSponsorSymbols();
	ResetValues();
}

function ShowPanel(bool bShow)
{
	Super.ShowPanel(bShow);
	if (bShow)
	{
		MainWindow.btnPlay.Caption = CaptionCreate;
		MainWindow.btnBack.Caption = CaptionCancel;

		btnPlayEnabled(true);
	}
	else {
		MainWindow.btnPlay.Caption = CaptionPlay;
		MainWindow.btnBack.Caption = CaptionBack;
	}
}

/**
	Create the profile and load it
*/
function bool onPlayClick()
{
	local array<string> ExistingProfiles;
	local string ProfileName;
	local int i;
	local GUIQuestionPage QPage;

	ProfileName = MainWindow.ProfilePrefix$edName.GetText();
	// test for existing record
	Controller.GetProfileList(MainWindow.ProfilePrefix, ExistingProfiles);
	for (i = 0; i < ExistingProfiles.length; i++)
	{
		if (ExistingProfiles[i] ~= ProfileName)
		{
			if (Controller.OpenMenu(Controller.QuestionMenuClass))
			{
				QPage = GUIQuestionPage(Controller.ActivePage);
				QPage.SetupQuestion(QPage.Replace(ErrorProfileExists, "profile", edName.GetText()), QBTN_Ok, QBTN_Ok); // no prefix
			}
			SetFocus(edName);
			return true;
		}
	}
	GP = PlayerOwner().Level.Game.CreateDataObject(ProfileClass, "GameProfile", ProfileName);
	if ( GP != none )
	{
		GP.CreateProfile(PlayerOwner());
		GP.PlayerName = edName.GetText();
		GP.TeamName = edTeam.GetText();
		GP.TeamSymbolName = String(ilSponsor.Image);
		GP.PlayerCharacter = clPlayerSkins.GetName();
		AddDefaultBots(GP);
		AddDefaultTeams(GP);
		GP.BaseDifficulty = cbDifficulty.GetIndex();
		// set difficulty variables
		GP.InjuryChance = GP.InjuryChance+(GP.BaseDifficulty/30);
		GP.ChallengeChance = GP.ChallengeChance+(GP.BaseDifficulty/30);
		GP.FeeIncrease = GP.FeeIncrease+(GP.BaseDifficulty/300);
		GP.TeamPercentage = GP.TeamPercentage+(GP.BaseDifficulty/30);
		GP.MatchBonus = GP.MatchBonus+(GP.TeamPercentage/10);
		GP.InjuryTreatment = GP.InjuryTreatment+(GP.BaseDifficulty / 50);
		GP.MapChallengeCost = GP.MapChallengeCost+(GP.BaseDifficulty / 100);
		GP.AltPath = rand(MaxInt);
		PlayerOwner().Level.Game.CurrentGameProfile = GP;
		GP.Initialize(PlayerOwner().Level.Game, ProfileName);
		GP.SpecialEvent = "WELCOME";
		PlayerOwner().Level.Game.CurrentGameProfile.bInLadderGame = true;  // so it'll reload into SP menus
		if (!PlayerOwner().Level.Game.SavePackage(ProfileName))
		{
			Warn("Couldn't save profile package");
		}

		// launch the game introduction
		PlayerOwner().ConsoleCommand("START"@GameIntroUrl$profilename);
		if (MainWindow != none) MainWindow.bAllowedAsLast = true; // workaround, or else the main window will pop up
		Controller.CloseAll(false,true);
	}
	else
	{
		Warn("Error creating profile");
		if (Controller.OpenMenu(Controller.QuestionMenuClass))
		{
			QPage = GUIQuestionPage(Controller.ActivePage);
			QPage.SetupQuestion(ErrorCantCreateProfile, QBTN_Ok, QBTN_Ok);
		}
		// restore old tab
		MainWindow.c_Tabs.ReplaceTab(MyButton, MainWindow.PanelCaption[0], MainWindow.PanelClass[0], , MainWindow.PanelHint[0], true);
		MainWindow.UpdateTabs();
		return true;
	}

	return true;
}

/**
	Go back to the main menu when there are not proflies
*/
function bool onBackClick()
{
	local array<string> profilenames;
	MainWindow.btnBack.Caption = CaptionBack;
	Controller.GetProfileList(MainWindow.ProfilePrefix, profilenames);
	if ( profilenames.Length == 0 )	Controller.CloseMenu();
	else MainWindow.c_Tabs.ReplaceTab(MyButton, MainWindow.PanelCaption[0], MainWindow.PanelClass[0], , MainWindow.PanelHint[0], true);
	return true;
}

/**
	Clear the input box when it has the default name
*/
function OnNameActivate()
{
	if (edName.GetText() == clPlayerSkins.GetName()) edName.SetText("");
}

/**
	Clear the input box when it has the default team name
*/
function OnTeamActivate()
{
	if (edTeam.GetText() == DefaultTeamName) edTeam.SetText("");
}

/**
	Check to see if we have an empty name
*/
function OnNameDeActivate()
{
	if ( edName.GetText() == "") edName.SetText(repl(clPlayerSkins.GetName(), ".", "_"));
	if ( edTeam.GetText() == "") edTeam.SetText(DefaultTeamName);
}

/**
	Disable "create" button when names are empty
*/
function onNameChange( GUIComponent Sender)
{
	btnPlayEnabled((edName.GetText() != "") && (edTeam.GetText() != ""));
}

/**
	Change the selected skin
*/
function bool onSelectSkin(GUIComponent Sender)
{
	local string prev;
	prev = repl(clPlayerSkins.GetName(), ".", "_");
	if ( Sender == btnPrevSkin )
	{
		clPlayerSkins.ScrollLeft();
	}
	else if ( Sender == btnNextSkin )
	{
		clPlayerSkins.ScrollRight();
	}
	if (edName.GetText() == prev) edName.SetText(repl(clPlayerSkins.GetName(), ".", "_"));
	return Super.OnClick(Sender);
}

/**
	Change the selected sponsor
*/
function bool onSelectSponsor(GUIComponent Sender)
{
	if ( Sender == btnPrevSponsor )
	{
		ilSponsor.PrevImage();
	}
	else if ( Sender == btnNextSponsor )
	{
		ilSponsor.NextImage();
	}
	return Super.OnClick(Sender);
}

/**
	Will reset all the settings to their initial value
*/
function ResetValues()
{
	local int i;
	edTeam.SetText(DefaultTeamName);
	cbDifficulty.SetIndex(DefaultDifficulty);
	clPlayerSkins.Find(DefaultCharacter);
	edName.SetText(clPlayerSkins.GetName());
	for (i = 0; i < ilSponsor.MatNames.Length; i++)
	{
		if (ilSponsor.MatNames[i] ~= "TeamSymbols_UT2004.Design1")
		{
			ilSponsor.SetIndex(i);
			break;
		}
	}
}

/**
	Add the default bots to the free agent list
*/
function AddDefaultBots(UT2K4GameProfile GP)
{
	local array<xUtil.PlayerRecord> FreeAgents;
	local int i;

	GP.BotStats.length = 0;
	class'xUtil'.static.GetPlayerList(FreeAgents);
	for (i = 0; i < FreeAgents.Length; i++)
	{
		if ((FreeAgents[i].Menu ~= "SP") &&
				((FreeAgents[i].species == class'xGame.SPECIES_Egypt') || (FreeAgents[i].species == class'xGame.SPECIES_Merc')))
		{
			if (FreeAgents[i].DefaultName ~= GP.PlayerCharacter) continue;
			GP.GetBotPosition(FreeAgents[i].DefaultName, true);
		}
	}
	for (i = 0; i < InitialFreeAgents.length; i++)
	{
		GP.GetBotPosition(InitialFreeAgents[i], true);
	}
}

/**
	Add the default teams to the list (the Phantom teams)
*/
function AddDefaultTeams(UT2K4GameProfile GP)
{
	local class<UT2K4RosterGroup> RGclass;
	local int i;

	RGclass = class<UT2K4RosterGroup>(DynamicLoadObject("xGame.UT2K4TeamRosterPhantom", class'Class'));
	for (i = 0; i < RGclass.default.Rosters.length; i++)
	{
		GP.GetTeamPosition(RGclass.default.Rosters[i], true);
	}
}

/**
	Loads all Sponsor symbols
*/
function LoadSponsorSymbols()
{
	local int i;
	local Material M;
	local array<string> SymbolNames;

	Controller.GetTeamSymbolList(SymbolNames, true);  // get all usable team symbols

	for (i = 0; i < SymbolNames.Length; i++)
	{
		M = Material(DynamicLoadObject(SymbolNames[i], class'Material'));
		ilSponsor.AddMaterial(SymbolNames[i], M);
	}
}


defaultproperties
{
	Begin Object class=GUICharacterListTeam Name=SPNclPlayerSkins
		Hint="Your character's appearance, use arrow keys to change"
		WinWidth=0.199566
		WinHeight=0.500000
		WinLeft=0.048207
		WinTop=0.191921
		bCenterInBounds=true
		FixedItemsPerPage=1
		StyleName="CharButton"
		TabOrder=0
		bBoundToParent=true
	End Object
	clPlayerSkins=SPNclPlayerSkins

	Begin Object class=GUISectionBackground Name=SPNimgEditBg
		WinWidth=0.425171
		WinHeight=0.770000
		WinLeft=0.536263
		WinTop=0.101463
		Caption="Profile"
		bBoundToParent=true
    End Object
    sbEditBg=SPNimgEditBg

	Begin Object class=moEditBox Name=SPNmeName
		Caption="Player Name: "
		Hint="Your character's name"
		LabelJustification=TXTA_Left
		WinHeight=0.122500
		WinWidth=0.345000
		WinLeft=0.572258
		WinTop=0.286087
		bVerticalLayout=true
		OnChange=onNameChange
		OnActivate=OnNameActivate
		OnDeActivate=OnNameDeActivate
		TabOrder=1
		bBoundToParent=true
	End Object
	edName=SPNmeName

	Begin Object class=moEditBox Name=SPNmeTeam
		Caption="Team Name: "
		Hint="The name of your team"
		LabelJustification=TXTA_Left
		WinHeight=0.122500
		WinWidth=0.345000
		WinLeft=0.572258
		WinTop=0.428007
		bVerticalLayout=true
		OnChange=onNameChange
		OnActivate=OnTeamActivate
		OnDeActivate=OnNameDeActivate
		TabOrder=2
		bBoundToParent=true
	End Object
	edTeam=SPNmeTeam

	Begin Object class=moComboBox Name=SPNmcDifficulty
		Caption="Difficulty: "
		Hint="Customize your challenge"
		LabelJustification=TXTA_Left
		WinWidth=0.345000
		WinHeight=0.068311
		WinLeft=0.572258
		WinTop=0.568803
		bVerticalLayout=true
		bReadOnly=true
		TabOrder=3
		bBoundToParent=true
	End Object
	cbDifficulty=SPNmcDifficulty

	Begin Object class=GUIImageList Name=SPNilSponsor
		Hint="Your team's sponsor, use arrow keys to change"
		WinWidth=0.185561
		WinHeight=0.506378
		WinLeft=0.304401
		WinTop=0.189296
		ImageRenderStyle=MSTY_Normal
		ImageStyle=ISTY_Justified
		ImageAlign=IMGA_Center
		bWrap=true
		TabOrder=7
		bBoundToParent=true
	End Object
	ilSponsor=SPNilSponsor

	Begin Object class=GUISectionBackground Name=SPNimgPortraitBack
		WinWidth=0.234133
		WinHeight=0.770000
		WinLeft=0.030428
		WinTop=0.101463
		Caption="Portrait"
		bBoundToParent=true
    End Object
    sbPortraitBack=SPNimgPortraitBack

	Begin Object Class=GUIButton Name=SPNbtnPrevSkin
		Hint="Selects a new appearance for your character"
		StyleName="ArrowLeft"
		WinWidth=0.048750
		WinHeight=0.080000
		WinLeft=0.060867
		WinTop=0.733722
		bNeverFocus=true
		bRepeatClick=true
		OnClickSound=CS_Down
		OnClick=onSelectSkin
		TabOrder=5
		bBoundToParent=true
	End Object
	btnPrevSkin=SPNbtnPrevSkin

	Begin Object Class=GUIButton Name=SPNbtnNextSkin
		Hint="Selects a new appearance for your character"
		StyleName="ArrowRight"
		WinWidth=0.048750
		WinHeight=0.080000
		WinLeft=0.178054
		WinTop=0.733722
		bNeverFocus=true
		bRepeatClick=true
		OnClickSound=CS_Up
		OnClick=onSelectSkin
		TabOrder=6
		bBoundToParent=true
	End Object
	btnNextSkin=SPNbtnNextSkin

	Begin Object class=GUISectionBackground Name=SPNimgSponsorBack
		WinWidth=0.253265
		WinHeight=0.770000
		WinLeft=0.273865
		WinTop=0.101463
		Caption="Team symbol"
		bBoundToParent=true
    End Object
    sbSponsorBack=SPNimgSponsorBack

	Begin Object Class=GUIButton Name=SPNbtnPrevSponsor
		Hint="Selects a new symbol for your team"
		StyleName="ArrowLeft"
		WinWidth=0.048750
		WinHeight=0.080000
		WinLeft=0.311505
		WinTop=0.733722
		bNeverFocus=true
		bRepeatClick=true
		OnClickSound=CS_Down
		OnClick=onSelectSponsor
		TabOrder=8
		bBoundToParent=true
	End Object
	btnPrevSponsor=SPNbtnPrevSponsor

	Begin Object Class=GUIButton Name=SPNbtnNextSponsor
		Hint="Selects a new symbol for your team"
		StyleName="ArrowRight"
		WinWidth=0.055000
		WinHeight=0.080000
		WinLeft=0.433380
		WinTop=0.733722
		bNeverFocus=true
		bRepeatClick=true
		OnClickSound=CS_Up
		OnClick=onSelectSponsor
		TabOrder=9
		bBoundToParent=true
	End Object
	btnNextSponsor=SPNbtnNextSponsor

	PanelCaption="New profile"

	DefaultTeamName="Team"
	DefaultTeamSponsor=1
	DefaultDifficulty=2
	TeamSponsorPrefix="TeamSymbols_UT2003.sym"
	DefaultCharacter="Jakob"
	ErrorProfileExists="Profile with name '%profile%' already exists!"
	ErrorCantCreateProfile="Profile creation failed."
	GameIntroURL="MOV-UT2004-Intro?quickstart=true?TeamScreen=False?savegame="

    DifficultyLevels(0)="Novice"
    DifficultyLevels(1)="Average"
    DifficultyLevels(2)="Experienced"
    DifficultyLevels(3)="Skilled"
    DifficultyLevels(4)="Adept"
    DifficultyLevels(5)="Masterful"
    DifficultyLevels(6)="Inhuman"
    DifficultyLevels(7)="Godlike"

	InitialFreeAgents(0)="Hathor"
	InitialFreeAgents(1)="Huntress"
	InitialFreeAgents(2)="Sunspear"
	InitialFreeAgents(3)="Cipher"
	InitialFreeAgents(4)="Medusa"
	InitialFreeAgents(5)="Jackhammer"
	InitialFreeAgents(6)="Avarice"
	InitialFreeAgents(7)="Darkling"
}

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:53.912 - Created with UnCodeX