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

UTGame.UTUIScene_COptions


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
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */

class UTUIScene_COptions extends UTUIFrontEnd
	config(Game);

var transient UILabel MenuLabel;
var transient UILabel SkillDesc;
var transient UIPanel LanGamePanel;
var transient UICheckBox SkillLevels[4];
var transient UICheckBox LanPlay;


var transient bool bNetworkOk;
var transient bool bNewGame;

/** Reference to the settings datastore that we will use to create the game. */
var transient UIDataStore_OnlineGameSettings	SettingsDataStore;

var localized string SkillDescriptions[4];

var transient string LaunchURL;

var transient bool bWasPublic;

var transient int ChapterToLoad;

var transient bool bIgnoreChange;

var string ChapterURLs[5];


event PostInitialize( )
{
	local int i;

    bNetworkOk = HasLinkConnection();

	LogInternal("[Network]"@bNetworkOK ? "Network Is Available" : "Network is not Available");

	Super.PostInitialize();

	for (i=0;i<4;i++)
	{
		SkillLevels[i] = UICheckBox( FindChild( name("Check"$i), true));
		SkillLevels[i].OnValueChanged = SkillLevelChanged;
	}

	SettingsDataStore = UIDataStore_OnlineGameSettings(FindDataStore('UTGameSettings'));
	SkillDesc = UILabel(FindChild('Description',true));
	LanGamePanel = UIPanel(FindChild('LanGamePanel',true));
	LanPlay = UICheckBox( FindChild('LanPlay',true));

	MenuLabel = UILabel(FindChild('Title',true));

	// this used to be set here, so we'll need to clear it in case it got serialized
	OnPreRenderCallback=None;
}

/**
 * Handler for the 'show' animation completed.
 */
function OnMainRegion_Show_UIAnimEnd( UIObject AnimTarget, int AnimIndex, UIAnimationSeq AnimSeq )
{
	Super.OnMainRegion_Show_UIAnimEnd(AnimTarget, AnimIndex, AnimSeq);

	if ( AnimTarget.AnimStack[AnimIndex].SeqRef.SeqName == 'SceneShowInitial' )
	{
		// make sure we can't choose "internet" if we aren't signed in online
		ValidateServerType();
	}
}

/**
 * Enables / disables the "server type" control based on whether we are signed in online.
 */
function ValidateServerType()
{
	local int PlayerIndex, PlayerControllerID;
	local string OnlineProfileRequiredMessage;

	OnlineProfileRequiredMessage = "<Strings:UTGameUI.Errors.OnlineRequiredForInternet_Message>";

	// find the "MatchType" control (contains the "LAN" and "Internet" options);  if we aren't signed in online,
	// don't have a link connection, or not allowed to play online, don't allow them to select one.
	PlayerIndex = GetPlayerIndex();
	PlayerControllerID = GetPlayerControllerId( PlayerIndex );

	if (!CheckLoginAndError(PlayerControllerID,true,,OnlineProfileRequiredMessage) || !CheckOnlinePrivilegeAndError( PlayerControllerID ) )
	{
		if ( LanPlay != None )
		{
			// check the lan checkbox
			LanPlay.SetValue(true, PlayerIndex);

			// now disable it
			LanPlay.DisableWidget(PlayerIndex);
		}

		if ( LanGamePanel != None )
		{
			LanGamePanel.DisableWidget(PlayerIndex);
		}
	}
	else
	{
		CheckNatTypeAndDisplayError(PlayerControllerID);
	}
}

/** Callback for when the login changes after showing the login UI. */
function OnLoginUI_LoginChange()
{
	local int PlayerIndex, PlayerControllerId;
	local bool bCanPlayOnline;
	local UIPanel SkillContainerPanel;

	PlayerIndex = GetPlayerIndex();
	PlayerControllerID = GetPlayerControllerId( PlayerIndex );

	if ( IsLoggedIn(PlayerControllerId, true) )
	{
		// we just connected to the online service
		// check online parental restrictions and NAT settings
		bCanPlayOnline = CanPlayOnline(PlayerControllerId) && GetNATType() < NAT_Strict;
		if ( bCanPlayOnline )
		{
			if ( LanPlay != None )
			{
				LanPlay.EnableWidget(PlayerIndex);
			}

			if ( LanGamePanel != None )
			{
				LanGamePanel.EnableWidget(PlayerIndex);
			}
		}
	}

	if ( !bCanPlayOnline )
	{
		if ( LanPlay != None )
		{
			if ( LanPlay.IsFocused(PlayerIndex) )
			{
				SkillContainerPanel = UIPanel(FindChild('OptionPanel', true));
				SkillContainerPanel.SetFocus(None, PlayerIndex);
			}

			// check the lan checkbox
			LanPlay.SetValue(true, PlayerIndex);

			// now disable it
			LanPlay.DisableWidget(PlayerIndex);
		}

		if ( LanGamePanel != None )
		{
			LanGamePanel.DisableWidget(PlayerIndex);
		}
	}

	Super.OnLoginUI_LoginChange();
}

function SkillLevelChanged( UIObject Sender, int PlayerIndex )
{
	local int i;
	local UTProfileSettings Profile;

	Profile = GetPlayerProfile();

	if (!bIgnoreChange)
	{
		bIgnoreChange = true;
		for (i=0;i<4;i++)
		{
			if ( SkillLevels[i] == Sender )
			{
				SkillLevels[i].SetValue(true);
				SkillDesc.SetValue(SkillDescriptions[i]);
				Profile.SetCampaignSkillLevel(i);
			}
			else
			{
				SkillLevels[i].SetValue(false);
			}
		}
		bIgnoreChange = false;
	}
}

function bool AllowInternetPlay()
{
//	local OnlineSubsystem OnlineSub;
	local LocalPlayer LP;

	// Check NAT.  If we are behind a strict nat, disable internet play
/*
	OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
	if ( OnlineSub != None && OnlineSub.SystemInterface.GetNATType() >= NAT_Strict )
	{
    	return false;
    }
*/
	LP = GetPlayerOwner();

	if ( LP == None )
	{
		return false;
	}
	if ( !IsLoggedIn(LP.ControllerID,true) )
	{
		LogInternal("[Network] Not Logged in!");
		return false;
	}

	if (!CanPlayOnline(LP.ControllerID) )
	{
		LogInternal("[Netowrk] User Is Restricted from Online");
		return false;
	}

	return true;
}


/** Sets up the button bar for the scene. */
function SetupButtonBar()
{

	if(ButtonBar != None)
	{
		ButtonBar.Clear();
		ButtonBar.AppendButton("<Strings:UTGameUI.ButtonCallouts.Back>", OnButtonBar_Back);

		if ( bNetworkOk )
		{
			ButtonBar.AppendButton("<Strings:UTGameUI.ButtonCallouts.StartPrivateGame>", OnButtonBar_Start);
			ButtonBar.AppendButton("<Strings:UTGameUI.ButtonCallouts.StartPublicGame>", OnButtonBar_StartPublic);
		}
		else
		{
			ButtonBar.AppendButton("<Strings:UTGameUI.ButtonCallouts.StartGame>", OnButtonBar_Start);
		}

		if (!IsConsole())
		{
			ButtonBar.Buttons[1].SetFocus(none);
		}


		// Setup mouse boundaries, based upon the first button bar button
		// NOTE: This is done through code instead of the UIEditor, to avoid patching the campaign packages
		if (ButtonBar.Buttons[0] != none)
		{
			MouseBounds.bFullscreenOnly = False;
			SetMouseBounds(UIFACE_Right,,, ButtonBar.Buttons[0]);
			SetMouseBounds(UIFACE_Bottom,,, ButtonBar.Buttons[0]);
		}
	}
}

function Configure(bool bIsNewGame, int InChapterToLoad)
{
	local UTProfileSettings Profile;
	local int Skill;
	local string s;

	bNewGame = bIsNewGame;

	s = "[<Strings:UTGameUI.Campaign.CampaignOptionsPrefix>" @ (bIsNewGame ? "<Strings:UTGameUI.Campaign.CampaignTitleA>]" : "<Strings:UTGameUI.Campaign.CampaignTitleB>]");
    GetTitleLabel().SetDataStoreBinding(Caps(s));

	Profile = GetPlayerProfile();
	if ( bIsNewGame )
	{
		if ( Profile != none )
		{
			Profile.NewGame();
		}
	}

	Skill = Profile.GetCampaignSkillLevel();
	SkillLevels[Skill].SetValue( true );

	ChapterToLoad = InChapterToLoad;
}

function bool OnButtonBar_Start(UIScreenObject InButton, int InPlayerIndex)
{
	StartGame(InPlayerIndex, false);
	return true;
}

function bool OnButtonBar_StartPublic(UIScreenObject InButton, int InPlayerIndex)
{
	StartGame(InPlayerIndex, true);
	return true;
}



function StartGame(int InPlayerIndex, bool bPublic)
{
	local UTProfileSettings Profile;
	local int Skill;
	local bool bInternetAllowed;

	Profile = GetPlayerProfile();
	if ( Profile != none )
	{
		Skill = Profile.GetCampaignSkillLevel();
		SavePlayerProfile(0);
	}

	Skill *= 2;

	if (ChapterToLoad != INDEX_None)
	{
		LaunchURL = "open "$ChapterURLs[ChapterToLoad]$"?Difficulty="$Skill$"?MaxPlayers=" $ 4;
	}
	else
	{
		if ( bNewGame )
		{
			LaunchURL = "open UTM-MissionSelection?SPI=0?SPResult=1?Difficulty="$Skill$"?MaxPlayers=" $ 4;
		}
		else
		{
			LaunchURL = "open UTM-MissionSelection?Difficulty="$Skill$"?MaxPlayers=" $ 4;
		}
	}

	bWasPublic = bPublic;

	if ( bNetworkOk )
	{
		LaunchURL $= "?Listen";

		// We have a profile, see if we can play on the net....
		bInternetAllowed = AllowInternetPlay();
		if ( LanPlay.IsChecked() || bInternetAllowed )
		{
			CreateOnlineGame(InPlayerIndex, bPublic, LanPlay.IsChecked() || !bInternetAllowed);
		}
		else
		{
			ShowOnlinePrivilegeError();
		}
	}
	else
	{
		ConsoleCommand(LaunchURL);
	}
}

function ShowOnlinePrivilegeError()
{
	DisplayMessageBox("<Strings:UTGameUI.Errors.CampaignOnlineFailure>","<Strings:UTGameUI.Errors.CampaignOnlineFailure_Title>");
	GetMessageBoxScene().OnClosed = MessageBoxClosed;
}

function MessageBoxClosed()
{
	CreateOnlineGame(0, bWasPublic, true);
}


/************************ Online Game Interface **************************/

/** Creates the online game and travels to the map we are hosting a server on. */
function CreateOnlineGame(int PlayerIndex, bool bPublic, bool bIsLanMatch)
{
	local OnlineSubsystem OnlineSub;
	local OnlineGameInterface GameInterface;
	local OnlineGameSettings GameSettings;

	// Figure out if we have an online subsystem registered
	OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
	if (OnlineSub != None)
	{
		// Grab the game interface to verify the subsystem supports it
		GameInterface = OnlineSub.GameInterface;
		if (GameInterface != None)
		{
			// Play the startgame sound
			PlayUISound('StartGame');

			// Setup server options based on server type.
			SettingsDataStore.SetCurrentByName('UTGameSettingsCampaign');
			GameSettings = SettingsDataStore.GetCurrentGameSettings();

			LogInternal("Starting a Campaign --- ");

			GameSettings.bUsesArbitration=false;				LogInternal("   bUseArbitration:"@GameSettings.bUsesArbitration);
			GameSettings.bAllowJoinInProgress = true;			LogInternal("   bAllowJoinInProgress:"@GameSettings.bAllowJoinInProgress);
			GameSettings.bAllowInvites = true;					LogInternal("   bAllowInvites:"@GameSettings.bAllowInvites);
			GameSettings.bIsLanMatch=bIsLanMatch;				LogInternal("   bIsLanMatch:"@GameSettings.bIsLanMatch);

			if (bPublic)
			{
				GameSettings.NumPrivateConnections = 0;
				GameSettings.NumPublicConnections = 4;
				GameSettings.bShouldAdvertise = true;
			}
			else
			{
				GameSettings.NumPrivateConnections = 4;
				GameSettings.NumPublicConnections = 0;
				GameSettings.bShouldAdvertise = false;
			}

			LogInternal("   bShouldAdvertise:"@GameSettings.bShouldAdvertise);
			LogInternal("   NumPrivateConnections"@GameSettings.NumPrivateConnections);
			LogInternal("   NumPublicConnections"@GameSettings.NumPublicConnections);

			// Create the online game
			GameInterface.AddCreateOnlineGameCompleteDelegate(OnGameCreated);

			if(SettingsDataStore.CreateGame(GetPlayerControllerId(PlayerIndex))==false)
			{
				GameInterface.ClearCreateOnlineGameCompleteDelegate(OnGameCreated);
				LogInternal("UTUIScene_COption::CreateOnlineGame - Failed to create online game.");
			}
		}
		else
		{
			LogInternal("UTUIScene_COption::CreateOnlineGame - No GameInterface found.");
		}
	}
	else
	{
		LogInternal("UTUIScene_COption::CreateOnlineGame - No OnlineSubSystem found.");
	}
}

/** Callback for when the game is finish being created. */
function OnGameCreated(bool bWasSuccessful)
{
	local OnlineSubsystem OnlineSub;
	local OnlineGameInterface GameInterface;

	// Figure out if we have an online subsystem registered
	OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
	if (OnlineSub != None)
	{
		// Grab the game interface to verify the subsystem supports it
		GameInterface = OnlineSub.GameInterface;
		if (GameInterface != None)
		{
			// Clear the delegate we set.
			GameInterface.ClearCreateOnlineGameCompleteDelegate(OnGameCreated);

			// If we were successful, then travel.
			if(bWasSuccessful)
			{
				ConsoleCommand(LaunchURL);
			}
			else
			{
				LogInternal("UTUIScene_COption::OnGameCreated - Game Creation Failed.");
			}
		}
		else
		{
			LogInternal("UTUIScene_COption::OnGameCreated - No GameInterface found.");
		}
	}
	else
	{
		LogInternal("UTUIScene_COption::OnGameCreated - No OnlineSubSystem found.");
	}
}



/**
 * Provides a hook for unrealscript to respond to input using actual input key names (i.e. Left, Tab, etc.)
 *
 * Called when an input key event is received which this widget responds to and is in the correct state to process.  The
 * keys and states widgets receive input for is managed through the UI editor's key binding dialog (F8).
 *
 * This delegate is called BEFORE kismet is given a chance to process the input.
 *
 * @param	EventParms	information about the input event.
 *
 * @return	TRUE to indicate that this input key was processed; no further processing will occur on this input key event.
 */
function bool HandleInputKey( const out InputEventParameters EventParms )
{
	if(EventParms.InputKeyName=='XboxTypeS_Y')
	{
		if (EventParms.EventType==IE_Released)
		{
			StartGame(EventParms.PlayerIndex,false);
		}
		return true;
	}

	if( EventParms.InputKeyName=='XboxTypeS_X' && bNetworkOk )
	{
		if (EventParms.EventType==IE_Released)
		{
			StartGame(EventParms.PlayerIndex,true);
		}
		return true;
	}

	if(EventParms.InputKeyName=='XboxTypeS_B' || EventParms.InputKeyName=='Escape')
	{
		if (EventParms.EventType==IE_Released)
		{
			OnBack();
		}
		return true;
	}

	return Super.HandleInputKey(EventParms);
}


/** Buttonbar Callbacks. */
function bool OnButtonBar_Back(UIScreenObject InButton, int PlayerIndex)
{
	OnBack();

	return true;
}

/** Callback for when the user wants to exit the scene. */
function OnBack()
{
	CloseScene(self);
}

defaultproperties
{
   SkillDescriptions(0)="Don't feel bad playing on casual.  At least you might live long enough to make a difference."
   SkillDescriptions(1)="So, you feel average today.  That's fine.  Get some practice, then try something more difficult."
   SkillDescriptions(2)="That's more like it.  Now get in there and do some damage!"
   SkillDescriptions(3)="ARE YOU INSANE? GIVE UP NOW!"
   ChapterURLs(0)="UTM-MissionSelection?SPI=0?SPResult=1"
   ChapterURLs(1)="UTM-MissionSelection?SPI=1?SPResult=1"
   ChapterURLs(2)="UTM-MissionSelection?SPI=15?SPResult=1"
   ChapterURLs(3)="UTM-MissionSelection?SPI=24?SPResult=1"
   ChapterURLs(4)="UTM-MissionSelection?SPI=33?SPResult=1"
   Begin Object Class=UIComp_Event Name=SceneEventComponent ObjName=SceneEventComponent Archetype=UIComp_Event'UTGame.Default__UTUIFrontEnd:SceneEventComponent'
      ObjectArchetype=UIComp_Event'UTGame.Default__UTUIFrontEnd:SceneEventComponent'
   End Object
   EventProvider=SceneEventComponent
   Name="Default__UTUIScene_COptions"
   ObjectArchetype=UTUIFrontEnd'UTGame.Default__UTUIFrontEnd'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:50.000 - Creation time: sk 18-3-2018 10:01:27.323 - Created with UnCodeX