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

UTGame.UTUIFrontEnd_Multiplayer


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
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 *
 * Multiplayer Scene for UT3.
 */

class UTUIFrontEnd_Multiplayer extends UTUIFrontEnd_BasicMenu
	dependson(UTCustomChar_Data)
	dependson(UTUIScene_MessageBox);

const MULTIPLAYER_OPTION_QUICKMATCH = 0;
const MULTIPLAYER_OPTION_JOINGAME = 1;
const MULTIPLAYER_OPTION_JOINGAMELAN = 2;
const MULTIPLAYER_OPTION_HOSTGAME = 3;

/** Reference to the quick match scene. */
var string	QuickMatchScene;

/** Reference to the host game scene. */
var string	HostScene;

/** Reference to the join game scene. */
var string	JoinScene;

/** Reference to the character selection scene. */
var string	CharacterSelectionScene;

/** Reference to the settings panels scene. */
var string	SettingsPanelsScene;

/** indicates that the player's profile should be saved */
var	transient	bool	bProfileNeedsSaving;

/** Whether or not we have already displayed the new player message box to the user. */
var transient	bool bDisplayedNewPlayerMessageBox;

/** @return bool Returns whether or not this user has saved character data. */
function bool HasSavedCharacterData()
{
	local bool bHaveLoadedCharData;
	local string CharacterDataStr;

	bHaveLoadedCharData = false;


	if( GetDataStoreStringValue("<OnlinePlayerData:ProfileData.CustomCharData>", CharacterDataStr, Self, GetPlayerOwner())
	&&	Len(CharacterDataStr) > 0 )
	{
		bHaveLoadedCharData = true;
	}

	return bHaveLoadedCharData;
}

/** Called when the screen has finished showing. */
function OnMainRegion_Show_UIAnimEnd(UIObject AnimTarget, int AnimIndex, UIAnimationSeq AnimSeq)
{
	Super.OnMainRegion_Show_UIAnimEnd(AnimTarget, AnimIndex, AnimSeq);

	if ( AnimTarget.AnimStack[AnimIndex].SeqRef.SeqName == 'SceneShowInitial' )
	{
		if ( CheckLoginAndError(GetPlayerControllerId(GetPlayerIndex()), true, ,"<Strings:UTGameUI.Errors.OnlineRequiredForInternet_Message>") )
		{
			PerformMultiplayerChecks();
		}
		else
		{
			GetSceneClient().bKillRestoreMenuProgression = true;
		}
	}
}

/**
 * Checks various conditions required to play online and displays the relevant messages to the user if any online features
 * will be disabled.
 */
function PerformMultiplayerChecks()
{
	local UTProfileSettings Profile;
	local UTUIScene_MessageBox MessageBoxReference;
	local int CurrentValue, ControllerId;
	local string ChatRestrictionValue;
	local OnlinePlayerInterface PlayerInt;

	Profile = GetPlayerProfile();
	if ( Profile != None )
	{
		if(!IsConsole()
		&&(!Profile.GetProfileSettingValueInt(class'UTProfileSettings'.const.UTPID_FirstTimeMultiplayer, CurrentValue) || CurrentValue!=1) )
		{
			CurrentValue = 1;
			Profile.SetProfileSettingValueInt(class'UTProfileSettings'.const.UTPID_FirstTimeMultiplayer, CurrentValue);
			MarkProfileDirty(true);

			MessageBoxReference = GetMessageBoxScene();
			MessageBoxReference.DisplayAcceptBox("<Strings:UTGameUI.MessageBox.FirstTimeMultiplayer_Message>",
				"<Strings:UTGameUI.MessageBox.FirstTimeMultiplayer_Title>", OnFirstTimeMultiplayer_Confirm);
		}
		else
		{
			if (!GetDataStoreStringValue("<Registry:PerformedChatRestrictionCheck>", ChatRestrictionValue, Self, GetPlayerOwner())
			||	ChatRestrictionValue != "1")
			{
				ChatRestrictionValue = "1";
				SetDataStoreStringValue("<Registry:PerformedChatRestrictionCheck>", ChatRestrictionValue, Self, GetPlayerOwner());

				ControllerId = GetPlayerOwner().ControllerId;
				PlayerInt = GetPlayerInterface();
				if ( IsLoggedIn(ControllerId, true) && PlayerInt != None && PlayerInt.CanCommunicate(ControllerId) == FPL_Disabled )
				{
					GetMessageBoxScene().DisplayAcceptBox("<Strings:UTGameUI.Errors.CommunicationRequired_Message>", "<Strings:UTGameUI.Errors.CommunicationRequired_Title>",
						OnChatRestrictionConfirm);
				}
				else
				{
					OnChatRestrictionConfirm(None, 0, GetPlayerIndex());
				}
			}
			// See if the current player hasn't setup a character yet.
			else if ( !bDisplayedNewPlayerMessageBox )
			{
				bDisplayedNewPlayerMessageBox=true;
				DisplayNewPlayerMessageBox();
			}
		}
	}
}

/** Callback for when the login changes after showing the login UI. */
function OnLoginUI_LoginChange()
{
	Super.OnLoginUI_LoginChange();

	PerformMultiplayerChecks();
}

/**
 * Delegate used in notifying the UI/game that the manual login failed after showing the login UI.
 *
 * @param LocalUserNum the controller number of the associated user
 * @param ErrorCode the async error code that occurred
 */
function OnLoginUI_LoginFailed(byte LocalUserNum,EOnlineServerConnectionStatus ErrorCode)
{
	Super.OnLoginUI_LoginFailed(LocalUserNum, ErrorCode);

	PerformMultiplayerChecks();
}

/**
 * Called when the user dismisses the "you can't chat online" message box
 */
function OnChatRestrictionConfirm(UTUIScene_MessageBox MessageBox, int SelectedOption, int PlayerIndex)
{
	if(bDisplayedNewPlayerMessageBox==false)
	{
		bDisplayedNewPlayerMessageBox=true;
		DisplayNewPlayerMessageBox();
	}
}

/**
 * Callback when the user dismisses the firsttime multiplayer message box.
 */
function OnFirstTimeMultiplayer_Confirm(UTUIScene_MessageBox MessageBox, int SelectedOption, int PlayerIndex)
{
	OpenSceneByName(SettingsPanelsScene, false, OnSettingsSceneOpened);
}

/** Callback for when the settings scene has opened. */
function OnSettingsSceneOpened(UIScene OpenedScene, bool bInitialActivation)
{
	local UTUIFrontEnd_SettingsPanels PanelSceneInst;

	PanelSceneInst = UTUIFrontEnd_SettingsPanels(OpenedScene);

	PanelSceneInst.OnMarkProfileDirty = MarkProfileDirty;
	PanelSceneInst.TabControl.ActivatePage(PanelSceneInst.NetworkTab, GetBestPlayerIndex());
	PanelSceneInst.OnSceneDeactivated = SettingsSceneClosed;
	PanelSceneInst.OnNotifyOptionChanged = OnSettingValueChanged;
}
function SettingsSceneClosed( UIScene DeactivatedScene )
{
	if ( bProfileNeedsSaving )
	{
		MarkProfileDirty(false);
		UTGameUISceneClient(GetSceneClient()).ShowSaveProfileScene(GetUTPlayerOwner());
	}

	PerformMultiplayerChecks();
}

/** Handler for the OnOptionChanged delegate of the first time settings panel; called when the user changes the value for an option */
function OnSettingValueChanged(UIScreenObject InObject, name OptionName, int PlayerIndex)
{
	local UIDataStorePublisher Publisher;
	local array<UIDataStore> Unused;

	Publisher = UIDataStorePublisher(InObject);
	if ( Publisher != None )
	{
		Publisher.SaveSubscriberValue(Unused);
	}
}

/**
 * Called when the profile has been modified and needs to be saved.
 */
function MarkProfileDirty( optional bool bDirty=true )
{
	bProfileNeedsSaving = bDirty;
}

/** Displays a messagebox if the player doesn't have a custom character set. */
function DisplayNewPlayerMessageBox()
{
	local UTUIScene_MessageBox MessageBoxReference;
	local array<string> MessageBoxOptions;
	local array<PotentialOptionKeys> PotentialOptionKeyMappings;

	if( !HasSavedCharacterData() )
	{
		if ( GetWorldInfo().IsDemoBuild() )	// In demo builds just generate a random character.
		{
			OnFirstTimeCharacter_Confirm(None,0,GetPlayerIndex());
		}
		else
		{
			// Pop up a message box asking the user if they want to edit their character or randomly generate one.
			MessageBoxReference = GetMessageBoxScene();

			if(MessageBoxReference != none)
			{
				MessageBoxOptions.AddItem("<Strings:UTGameUI.CharacterCustomization.RandomlyGenerate>");
				MessageBoxOptions.AddItem("<Strings:UTGameUI.CharacterCustomization.CreateCharacter>");
				MessageBoxOptions.AddItem("<Strings:UTGameUI.Generic.Cancel>");

				PotentialOptionKeyMappings.length = 3;
				PotentialOptionKeyMappings[0].Keys.AddItem('XboxTypeS_X');
				PotentialOptionKeyMappings[1].Keys.AddItem('XboxTypeS_A');
				PotentialOptionKeyMappings[2].Keys.AddItem('XboxTypeS_B');
				PotentialOptionKeyMappings[2].Keys.AddItem('Escape');

				MessageBoxReference.SetPotentialOptionKeyMappings(PotentialOptionKeyMappings);
				MessageBoxReference.SetPotentialOptions(MessageBoxOptions);
				MessageBoxReference.Display("<Strings:UTGameUI.MessageBox.FirstTimeCharacter_Message>", "<Strings:UTGameUI.MessageBox.FirstTimeCharacter_Title>", OnFirstTimeCharacter_Confirm);
			}
		}
	}
}

/**
 * Callback when the user dismisses the firsttime character message box.
 */

function OnFirstTimeCharacter_Confirm(UTUIScene_MessageBox MessageBox, int SelectedOption, int PlayerIndex)
{
	local CustomCharData CustomData;
	local string DataString;

	switch ( SelectedOption )
	{
	case 0:	// Randomly generate a character
		CustomData = class'UTCustomChar_Data'.static.MakeRandomCharData();
		DataString = class'UTCustomChar_Data'.static.CharDataToString(CustomData);
		if(SetDataStoreStringValue("<OnlinePlayerData:ProfileData.CustomCharData>", DataString, Self, GetPlayerOwner()))
		{
			UTGameUISceneClient(GetSceneClient()).ShowSaveProfileScene(GetUTPlayerOwner());
			MarkProfileDirty(false);
		}
		break;

	case 1:	// Open the character selection scene
		OpenSceneByName(CharacterSelectionScene);
		bDisplayedNewPlayerMessageBox=false;	// Need to recheck for a customized character after the user has closed the player customization screen.
		break;
	case 2:	// Close this scene
		CloseScene(self);
		break;
	}
}

/**
 * Executes a action based on the currently selected menu item.
 */
function OnSelectItem(int PlayerIndex=GetPlayerIndex())
{
	local int SelectedItem, ControllerId;
	local UTUIDataStore_StringList StringListDataStore;
	local DataStoreClient DSClient;

	DSClient = class'UIInteraction'.static.GetDataStoreClient();
	if ( DSClient != None )
	{
		StringListDataStore = UTUIDataStore_StringList(DSClient.FindDataStore('UTStringList'));
	}

	SelectedItem = MenuList.GetCurrentItem();
	ControllerId = class'UIInteraction'.static.GetPlayerControllerId(PlayerIndex);
	switch(SelectedItem)
	{
	case MULTIPLAYER_OPTION_QUICKMATCH:
		if ( CheckLinkConnectionAndError() && CheckLoginAndError(ControllerId, true) )
		{
			OpenSceneByName(QuickMatchScene);
		}
		break;

	case MULTIPLAYER_OPTION_HOSTGAME:
		if ( CheckLinkConnectionAndError() )
		{
			OpenSceneByName(HostScene);
		}
		break;

	case MULTIPLAYER_OPTION_JOINGAME:
		if ( CheckLinkConnectionAndError() && CheckLoginAndError(ControllerId, true) )
		{
			StringListDataStore.SetCurrentValueIndex('MatchType', 1);
			OpenSceneByName(Joinscene);
		}
		break;

	case MULTIPLAYER_OPTION_JOINGAMELAN:
		if ( CheckLinkConnectionAndError() )
		{
			StringListDataStore.SetCurrentValueIndex('MatchType', 0);
			OpenSceneByName(Joinscene, false, OnJoinLanScene_Opened);
		}
		break;
	}
}


/** Callback for when the join scene has opened for LAN. */
function OnJoinLanScene_Opened(UIScene OpenedScene, bool bInitialActivation)
{
	local UTUIFrontEnd_JoinGame JoinSceneInst;

	// Set a string value to indicate that this is a LAN client, so the
	// UI is aware of this after we disconnect from the server
	SetDataStoreStringValue("<Registry:LanClient>", "1");

	JoinSceneInst = UTUIFrontEnd_JoinGame(OpenedScene);	 
	if ( JoinSceneInst != none && bInitialActivation )
	{
		JoinSceneInst.UseLANMode();
	}
}

defaultproperties
{
   QuickMatchScene="UI_Scenes_ChrisBLayout.Scenes.QuickMatch"
   HostScene="UI_Scenes_ChrisBLayout.Scenes.HostGame"
   JoinScene="UI_Scenes_FrontEnd.Scenes.JoinGame"
   CharacterSelectionScene="UI_Scenes_ChrisBLayout.Scenes.CharacterFaction"
   SettingsPanelsScene="UI_Scenes_ChrisBLayout.Scenes.SettingsPanels"
   bRequiresNetwork=True
   bMenuLevelRestoresScene=True
   Begin Object Class=UIComp_Event Name=SceneEventComponent ObjName=SceneEventComponent Archetype=UIComp_Event'UTGame.Default__UTUIFrontEnd_BasicMenu:SceneEventComponent'
      ObjectArchetype=UIComp_Event'UTGame.Default__UTUIFrontEnd_BasicMenu:SceneEventComponent'
   End Object
   EventProvider=SceneEventComponent
   Name="Default__UTUIFrontEnd_Multiplayer"
   ObjectArchetype=UTUIFrontEnd_BasicMenu'UTGame.Default__UTUIFrontEnd_BasicMenu'
}

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