private static bool JoinGameTest(Lobby lobby) { if (!lobby.IsValid) { return(false); } if (lobby.GetLobbyType() == LobbyTypeEnum.FriendsOnly && !MySteam.API.Friends.HasFriend(lobby.GetOwner())) { MyGuiSandbox.Show(MySpaceTexts.OnlyFriendsCanJoinThisGame); return(false); } if (!MyMultiplayerLobby.IsLobbyCorrectVersion(lobby)) { var formatString = MyTexts.GetString(MySpaceTexts.MultiplayerError_IncorrectVersion); var myVersion = MyBuildNumbers.ConvertBuildNumberFromIntToString(MyFinalBuildConstants.APP_VERSION); var serverVersion = MyBuildNumbers.ConvertBuildNumberFromIntToString(MyMultiplayerLobby.GetLobbyAppVersion(lobby)); MyGuiSandbox.Show(new StringBuilder(String.Format(formatString, myVersion, serverVersion))); return(false); } if (MyFakes.ENABLE_MP_DATA_HASHES && !MyMultiplayerLobby.HasSameData(lobby)) { MyGuiSandbox.Show(MySpaceTexts.MultiplayerError_DifferentData); MySandboxGame.Log.WriteLine("Different game data when connecting to server. Local hash: " + MyDataIntegrityChecker.GetHashBase64() + ", server hash: " + MyMultiplayerLobby.GetDataHash(lobby)); return(false); } return(true); }
private void JoinServer(MyObjectBuilder_LastSession mySession) { try { MyGuiScreenProgress prog = new MyGuiScreenProgress(MyTexts.Get(MyCommonTexts.DialogTextCheckServerStatus)); MyGuiSandbox.AddScreen(prog); MyGameService.OnPingServerResponded += OnPingSuccess; MyGameService.OnPingServerFailedToRespond += OnPingFailure; MyGameService.PingServer(mySession.GetConnectionString()); void OnPingFailure(object sender, object data) { MyGuiSandbox.RemoveScreen(prog); MySandboxGame.Static.ServerFailedToRespond(sender, data); MyGameService.OnPingServerResponded -= OnPingSuccess; MyGameService.OnPingServerFailedToRespond -= OnPingFailure; } void OnPingSuccess(object sender, MyGameServerItem item) { MyGuiSandbox.RemoveScreen(prog); MySandboxGame.Static.ServerResponded(sender, item); MyGameService.OnPingServerResponded -= OnPingSuccess; MyGameService.OnPingServerFailedToRespond -= OnPingFailure; } } catch (Exception ex) { MyLog.Default.WriteLine(ex); MyGuiSandbox.Show(MyTexts.Get(MyCommonTexts.MultiplayerJoinIPError), MyCommonTexts.MessageBoxCaptionError); } }
private static void CheckDx11AndJoin(MyObjectBuilder_World world, MyMultiplayerBase multiplayer) { bool needsDx11 = world.Checkpoint.RequiresDX >= 11; if (!needsDx11 || MySandboxGame.IsDirectX11) { if (multiplayer.Battle) { if (multiplayer.BattleCanBeJoined) { MySessionLoader.LoadMultiplayerBattleWorld(world, multiplayer); } else { MyLog.Default.WriteLine("World downloaded but battle game ended"); MySessionLoader.UnloadAndExitToMenu(); MyGuiSandbox.Show(MyCommonTexts.MultiplayerErrorSessionEnded); multiplayer.Dispose(); } } else if (multiplayer.Scenario) { MySessionLoader.LoadMultiplayerScenarioWorld(world, multiplayer); } else { MySessionLoader.LoadMultiplayerSession(world, multiplayer); } } else { HandleDx11Needed(); } }
private void OnClickSubscribedWorlds(MyGuiControlButton obj) { if (!MyFakes.XBOX_PREVIEW) MyGuiSandbox.AddScreen(new MyGuiScreenLoadSubscribedWorld()); else MyGuiSandbox.Show(MySpaceTexts.MessageBoxTextErrorFeatureNotAvailableYet, MySpaceTexts.MessageBoxCaptionError); }
public static void JoinGame(GameServerItem server) { MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Join); if (server.ServerVersion != MyFinalBuildConstants.APP_VERSION) { var sb = new StringBuilder(); sb.AppendFormat(MyTexts.GetString(MyCommonTexts.MultiplayerError_IncorrectVersion), MyFinalBuildConstants.APP_VERSION, server.ServerVersion); MyGuiSandbox.Show(sb, MyCommonTexts.MessageBoxCaptionError); return; } if (MyFakes.ENABLE_MP_DATA_HASHES) { var serverHash = server.GetGameTagByPrefix("datahash"); if (serverHash != "" && serverHash != MyDataIntegrityChecker.GetHashBase64()) { MyGuiSandbox.Show(MyCommonTexts.MultiplayerError_DifferentData); MySandboxGame.Log.WriteLine("Different game data when connecting to server. Local hash: " + MyDataIntegrityChecker.GetHashBase64() + ", server hash: " + serverHash); return; } } UInt32 unixTimestamp = (UInt32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; SteamAPI.Instance.AddFavoriteGame(server.AppID, System.Net.IPAddressExtensions.ToIPv4NetworkOrder(server.NetAdr.Address), (UInt16)server.NetAdr.Port, (UInt16)server.NetAdr.Port, FavoriteEnum.History, unixTimestamp); MyMultiplayerClient multiplayer = new MyMultiplayerClient(server, new MySyncLayer(new MyTransportLayer(MyMultiplayer.GameEventChannel))); MyMultiplayer.Static = multiplayer; MyMultiplayer.Static.SyncLayer.AutoRegisterGameEvents = false; MyMultiplayer.Static.SyncLayer.RegisterGameEvents(); multiplayer.SendPlayerData(MySteam.UserName); string gamemode = server.GetGameTagByPrefix("gamemode"); StringBuilder text = MyTexts.Get(MyCommonTexts.DialogTextJoiningWorld); MyGuiScreenProgress progress = new MyGuiScreenProgress(text, MyCommonTexts.Cancel); MyGuiSandbox.AddScreen(progress); progress.ProgressCancelled += () => { multiplayer.Dispose(); MySessionLoader.UnloadAndExitToMenu(); if (MyMultiplayer.Static != null) { MyMultiplayer.Static.Dispose(); } }; multiplayer.OnJoin += delegate { MyJoinGameHelper.OnJoin(progress, SteamSDK.Result.OK, new LobbyEnterInfo() { EnterState = LobbyEnterResponseEnum.Success }, multiplayer); }; VRage.Profiler.MyRenderProfiler.GetProfilerFromServer = MyMultiplayer.Static.DownloadProfiler; }
private void OnClickRecommend(MyGuiControlButton sender) { if (!MyFakes.XBOX_PREVIEW) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( styleEnum: MyMessageBoxStyleEnum.Info, messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionRecommend), messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextRecommend), callback: new Action <MyGuiScreenMessageBox.ResultEnum>(OnClickRecommendOK) )); } else { MyGuiSandbox.Show(MyCommonTexts.MessageBoxTextErrorFeatureNotAvailableYet, MyCommonTexts.MessageBoxCaptionError); } }
public static string Connect(List <string> args) { if (args.Count < 1) { return("Not enough arguments!"); } try { string[] array = args[0].Trim().Split(new char[] { ':' }); ushort num; if (array.Length < 2) { num = 27016; } else { num = ushort.Parse(array[1]); } IPAddress[] hostAddresses = Dns.GetHostAddresses(array[0]); StringBuilder text = MyTexts.Get(MyCommonTexts.DialogTextJoiningWorld); m_progressScreen = new MyGuiScreenProgress(text, new MyStringId?(MyCommonTexts.Cancel), false, true); MyGuiSandbox.AddScreen(m_progressScreen); m_progressScreen.ProgressCancelled += delegate { CloseHandlers(); MySessionLoader.UnloadAndExitToMenu(); }; MyGameService.OnPingServerResponded += new EventHandler <MyGameServerItem>(ServerResponded); MyGameService.OnPingServerFailedToRespond += new EventHandler(ServerFailedToRespond); MyGameService.PingServer(hostAddresses[0].ToIPv4NetworkOrder(), num); MyGameService.OnPingServerResponded += new EventHandler <MyGameServerItem>(ServerResponded); MyGameService.OnPingServerFailedToRespond += new EventHandler(ServerFailedToRespond); MyGameService.PingServer(hostAddresses[0].ToIPv4NetworkOrder(), num); } catch (Exception ex) { MyGuiSandbox.Show(MyTexts.Get(MyCommonTexts.MultiplayerJoinIPError), MyCommonTexts.MessageBoxCaptionError, MyMessageBoxStyleEnum.Error); } return("Attempting to join server: "); }
private void OnJoinWorld(MyGuiControlButton sender) { RunWithTutorialCheck(delegate { if (MyGameService.IsOnline) { MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted) { switch (granted) { case PermissionResult.Granted: MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted) { switch (ugcGranted) { case PermissionResult.Granted: MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted) { MyGuiScreenJoinGame myGuiScreenJoinGame = new MyGuiScreenJoinGame(crossGranted == PermissionResult.Granted); myGuiScreenJoinGame.Closed += joinGameScreen_Closed; MyGuiSandbox.AddScreen(myGuiScreenJoinGame); }); break; case PermissionResult.Error: MySandboxGame.Static.Invoke(delegate { MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); }, "New Game screen"); break; } }); break; case PermissionResult.Error: MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); break; } }); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: new StringBuilder().AppendFormat(MyTexts.GetString(MyGameService.IsActive ? MyCommonTexts.SteamIsOfflinePleaseRestart : MyCommonTexts.ErrorJoinSessionNoUser), MySession.GameServiceName))); } }); }
private static void OnDownloadProgressChanged(MyGuiScreenProgress progress, MyDownloadWorldResult result, MyMultiplayerBase multiplayer) { switch (result.State) { case MyDownloadWorldStateEnum.Success: progress.CloseScreen(); var world = multiplayer.ProcessWorldDownloadResult(result); if (MyFakes.ENABLE_BATTLE_SYSTEM && multiplayer.Battle) { MyGuiScreenLoadSandbox.LoadMultiplayerBattleWorld(world, multiplayer); } else { MyGuiScreenLoadSandbox.LoadMultiplayerSession(world, multiplayer); } break; case MyDownloadWorldStateEnum.InProgress: if (result.ReceivedBlockCount == 1) { MyLog.Default.WriteLine("First world part received"); } string percent = (result.Progress * 100).ToString("0."); float size = result.ReceivedDatalength; string prefix = MyUtils.FormatByteSizePrefix(ref size); string worldSize = size.ToString("0.") + " " + prefix + "B"; if (progress.Text != null) { progress.Text.Clear(); } if (float.IsNaN(result.Progress)) { MyLog.Default.WriteLine("World requested - preemble received"); if (progress.Text != null) { progress.Text.Append(MyTexts.Get(MySpaceTexts.DialogWaitingForWorldData)); } } else { if (progress.Text != null) { progress.Text.AppendFormat(MyTexts.GetString(MySpaceTexts.DialogTextDownloadingWorld), percent, worldSize); } } break; case MyDownloadWorldStateEnum.WorldNotAvailable: MyLog.Default.WriteLine("World requested - world not available"); progress.Cancel(); MyGuiSandbox.Show(MySpaceTexts.DialogDownloadWorld_WorldDoesNotExists); multiplayer.Dispose(); break; case MyDownloadWorldStateEnum.ConnectionFailed: MyLog.Default.WriteLine("World requested - connection failed"); progress.Cancel(); MyGuiSandbox.Show(MyTexts.AppendFormat(new StringBuilder(), MySpaceTexts.MultiplayerErrorConnectionFailed, result.ConnectionError)); multiplayer.Dispose(); break; case MyDownloadWorldStateEnum.DeserializationFailed: case MyDownloadWorldStateEnum.InvalidMessage: MyLog.Default.WriteLine("World requested - message invalid (wrong version?)"); progress.Cancel(); MyGuiSandbox.Show(MySpaceTexts.DialogTextDownloadWorldFailed); multiplayer.Dispose(); break; default: throw new InvalidBranchException(); } }
private static void DownloadWorld(MyGuiScreenProgress progress, MyMultiplayerBase multiplayer) { if (progress.Text != null) { progress.Text.Clear(); progress.Text.Append(MyTexts.Get(MySpaceTexts.MultiplayerStateConnectingToServer)); } MyLog.Default.WriteLine("World requested"); const float worldRequestTimeout = 40; // in seconds Stopwatch worldRequestTime = Stopwatch.StartNew(); ulong serverId = multiplayer.GetOwner(); bool connected = false; progress.Tick += () => { P2PSessionState state = default(P2PSessionState); Peer2Peer.GetSessionState(multiplayer.ServerId, ref state); if (!connected && state.ConnectionActive) { MyLog.Default.WriteLine("World requested - connection alive"); connected = true; if (progress.Text != null) { progress.Text.Clear(); progress.Text.Append(MyTexts.Get(MySpaceTexts.MultiplayerStateWaitingForServer)); } } //progress.Text.Clear(); //progress.Text.AppendLine("Connecting: " + state.Connecting); //progress.Text.AppendLine("ConnectionActive: " + state.ConnectionActive); //progress.Text.AppendLine("Relayed: " + state.UsingRelay); //progress.Text.AppendLine("Bytes queued: " + state.BytesQueuedForSend); //progress.Text.AppendLine("Packets queued: " + state.PacketsQueuedForSend); //progress.Text.AppendLine("Last session error: " + state.LastSessionError); //progress.Text.AppendLine("Original server: " + serverId); //progress.Text.AppendLine("Current server: " + multiplayer.Lobby.GetOwner()); //progress.Text.AppendLine("Game version: " + multiplayer.AppVersion); if (serverId != multiplayer.GetOwner()) { MyLog.Default.WriteLine("World requested - failed, server changed"); progress.Cancel(); MyGuiSandbox.Show(MySpaceTexts.MultiplayerErrorServerHasLeft); multiplayer.Dispose(); } if (worldRequestTime.IsRunning && worldRequestTime.Elapsed.TotalSeconds > worldRequestTimeout) { MyLog.Default.WriteLine("World requested - failed, server changed"); progress.Cancel(); MyGuiSandbox.Show(MySpaceTexts.MultiplaterJoin_ServerIsNotResponding); multiplayer.Dispose(); } }; var downloadResult = multiplayer.DownloadWorld(); downloadResult.ProgressChanged += (result) => { worldRequestTime.Stop(); OnDownloadProgressChanged(progress, result, multiplayer); }; progress.ProgressCancelled += () => { downloadResult.Cancel(); multiplayer.Dispose(); //var joinScreen = MyScreenManager.GetScreenWithFocus() as MyGuiScreenJoinGame; //if (joinScreen != null) // joinScreen.ReloadList(); }; }
void ServerFailedToRespond(object sender, object e) { //CloseHandlers(); //m_progressScreen.CloseScreen(); MyGuiSandbox.Show(MyCommonTexts.MultiplaterJoin_ServerIsNotResponding); }
public static void Publish(string sessionPath, MyWorldInfo worlInfo) { if (MyFakes.XBOX_PREVIEW) { MyGuiSandbox.Show(MyCommonTexts.MessageBoxTextErrorFeatureNotAvailableYet, MyCommonTexts.MessageBoxCaptionError); return; } MyStringId textQuestion, captionQuestion; if (worlInfo.WorkshopId.HasValue) { textQuestion = MyCommonTexts.MessageBoxTextDoYouWishToUpdateWorld; captionQuestion = MyCommonTexts.MessageBoxCaptionDoYouWishToUpdateWorld; } else { textQuestion = MyCommonTexts.MessageBoxTextDoYouWishToPublishWorld; captionQuestion = MyCommonTexts.MessageBoxCaptionDoYouWishToPublishWorld; } MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( styleEnum : MyMessageBoxStyleEnum.Info, buttonType : MyMessageBoxButtonsType.YES_NO, messageText : MyTexts.Get(textQuestion), messageCaption : MyTexts.Get(captionQuestion), callback : delegate(MyGuiScreenMessageBox.ResultEnum val) { if (val == MyGuiScreenMessageBox.ResultEnum.YES) { Action <MyGuiScreenMessageBox.ResultEnum, string[]> onTagsChosen = delegate(MyGuiScreenMessageBox.ResultEnum tagsResult, string[] outTags) { if (tagsResult == MyGuiScreenMessageBox.ResultEnum.YES) { MySteamWorkshop.PublishWorldAsync(sessionPath, worlInfo.SessionName, worlInfo.Description, worlInfo.WorkshopId, outTags, SteamSDK.PublishedFileVisibility.Public, callbackOnFinished : delegate(bool success, Result result, ulong publishedFileId) { if (success) { ulong dummy; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out dummy); worlInfo.WorkshopId = publishedFileId; checkpoint.WorkshopId = publishedFileId; MyLocalCache.SaveCheckpoint(checkpoint, sessionPath); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( styleEnum: MyMessageBoxStyleEnum.Info, messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextWorldPublished), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWorldPublished), callback: (a) => { MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId)); })); } else { MyStringId error; switch (result) { case Result.AccessDenied: error = MyCommonTexts.MessageBoxTextPublishFailed_AccessDenied; break; default: error = MyCommonTexts.MessageBoxTextWorldPublishFailed; break; } MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(error), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWorldPublishFailed))); } }); } }; if (MySteamWorkshop.WorldCategories.Length > 0) { MyGuiSandbox.AddScreen(new MyGuiScreenWorkshopTags(MySteamWorkshop.WORKSHOP_WORLD_TAG, MySteamWorkshop.WorldCategories, null, onTagsChosen)); } else { onTagsChosen(MyGuiScreenMessageBox.ResultEnum.YES, new string[] { MySteamWorkshop.WORKSHOP_WORLD_TAG }); } } })); }
private void CreateMainMenuControls() { MyStringId optionsScreen_Help_Menu = MySpaceTexts.OptionsScreen_Help_Menu; Vector2 vector = new Vector2(0.001f, (0f - m_size.Value.Y) / 2f + 0.126f); int num = 0; MyObjectBuilder_LastSession lastSession = MyLocalCache.GetLastSession(); if (lastSession != null && (lastSession.Path == null || MyPlatformGameSettings.GAME_SAVES_TO_CLOUD || Directory.Exists(lastSession.Path)) && (!lastSession.IsLobby || MyGameService.LobbyDiscovery.ContinueToLobbySupported)) { MyGuiControlButton myGuiControlButton = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonContinueGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { MyObjectBuilder_LastSession mySession = MyLocalCache.GetLastSession(); if (mySession == null) { return; } if (mySession.IsOnline) { if (mySession.IsLobby) { MyJoinGameHelper.JoinGame(ulong.Parse(mySession.ServerIP)); return; } MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted) { switch (granted) { case PermissionResult.Granted: MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted) { switch (crossGranted) { case PermissionResult.Granted: MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted) { switch (ugcGranted) { case PermissionResult.Granted: JoinServer(mySession); break; case PermissionResult.Error: MySandboxGame.Static.Invoke(delegate { MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); }, "New Game screen"); break; } }); break; case PermissionResult.Error: MySandboxGame.Static.Invoke(delegate { MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); }, "New Game screen"); break; } }); break; case PermissionResult.Error: MySandboxGame.Static.Invoke(delegate { MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); }, "New Game screen"); break; } }); } else if (!m_parallelLoadIsRunning) { m_parallelLoadIsRunning = true; MyGuiScreenProgress progressScreen = new MyGuiScreenProgress(MyTexts.Get(MySpaceTexts.ProgressScreen_LoadingWorld)); MyScreenManager.AddScreen(progressScreen); Parallel.StartBackground(delegate { MySessionLoader.LoadLastSession(); }, delegate { progressScreen.CloseScreen(); m_parallelLoadIsRunning = false; }); } }); myGuiControlButton.GamepadHelpTextId = optionsScreen_Help_Menu; Controls.Add(myGuiControlButton); m_elementGroup.Add(myGuiControlButton); } else { num--; } MyGuiControlButton myGuiControlButton2 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonCampaign), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyGuiScreenNewGame>(new object[3] { true, true, true })); }); myGuiControlButton2.GamepadHelpTextId = optionsScreen_Help_Menu; Controls.Add(myGuiControlButton2); m_elementGroup.Add(myGuiControlButton2); MyGuiControlButton myGuiControlButton3 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonLoadGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { MyGuiSandbox.AddScreen(new MyGuiScreenLoadSandbox()); }); myGuiControlButton3.GamepadHelpTextId = optionsScreen_Help_Menu; Controls.Add(myGuiControlButton3); m_elementGroup.Add(myGuiControlButton3); if (MyPerGameSettings.MultiplayerEnabled) { MyGuiControlButton myGuiControlButton4 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonJoinGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { if (MyGameService.IsOnline) { MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted) { switch (granted) { case PermissionResult.Granted: MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted) { switch (ugcGranted) { case PermissionResult.Granted: MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted) { MyGuiScreenJoinGame myGuiScreenJoinGame = new MyGuiScreenJoinGame(crossGranted == PermissionResult.Granted); myGuiScreenJoinGame.Closed += joinGameScreen_Closed; MyGuiSandbox.AddScreen(myGuiScreenJoinGame); }); break; case PermissionResult.Error: MySandboxGame.Static.Invoke(delegate { MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); }, "New Game screen"); break; } }); break; case PermissionResult.Error: MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); break; } }); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: new StringBuilder().AppendFormat(MyTexts.GetString(MyGameService.IsActive ? MyCommonTexts.SteamIsOfflinePleaseRestart : MyCommonTexts.ErrorJoinSessionNoUser), MySession.GameServiceName))); } }); myGuiControlButton4.GamepadHelpTextId = optionsScreen_Help_Menu; Controls.Add(myGuiControlButton4); m_elementGroup.Add(myGuiControlButton4); } MyGuiControlButton myGuiControlButton5 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonOptions), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { bool flag = !MyPlatformGameSettings.LIMITED_MAIN_MENU; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyOldOptionsAccessMenu>(new object[1] { !flag })); }); myGuiControlButton5.GamepadHelpTextId = optionsScreen_Help_Menu; Controls.Add(myGuiControlButton5); m_elementGroup.Add(myGuiControlButton5); if (MyFakes.ENABLE_MAIN_MENU_INVENTORY_SCENE) { MyGuiControlButton myGuiControlButton6 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonInventory), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { if (MyGameService.IsActive) { if (MyGameService.Service.GetInstallStatus(out var _)) { if (MySession.Static == null) { MyGuiScreenLoadInventory inventory = MyGuiSandbox.CreateScreen <MyGuiScreenLoadInventory>(Array.Empty <object>()); MyGuiScreenLoading screen = new MyGuiScreenLoading(inventory, null); MyGuiScreenLoadInventory myGuiScreenLoadInventory = inventory; myGuiScreenLoadInventory.OnLoadingAction = (Action)Delegate.Combine(myGuiScreenLoadInventory.OnLoadingAction, (Action) delegate { MySessionLoader.LoadInventoryScene(); MySandboxGame.IsUpdateReady = true; inventory.Initialize(inGame: false, null); }); MyGuiSandbox.AddScreen(screen); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyGuiScreenLoadInventory>(new object[2] { false, null })); } } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionInfo), messageText: MyTexts.Get(MyCommonTexts.InventoryScreen_InstallInProgress))); } } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.SteamIsOfflinePleaseRestart))); } });
private void ContinueGameInternal() { MyObjectBuilder_LastSession mySession = MyLocalCache.GetLastSession(); if (mySession == null) { return; } if (mySession.IsOnline) { if (mySession.IsLobby) { MyJoinGameHelper.JoinGame(ulong.Parse(mySession.ServerIP)); return; } MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted) { switch (granted) { case PermissionResult.Granted: MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted) { switch (crossGranted) { case PermissionResult.Granted: MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted) { switch (ugcGranted) { case PermissionResult.Granted: JoinServer(mySession); break; case PermissionResult.Error: MySandboxGame.Static.Invoke(delegate { MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); }, "New Game screen"); break; } }); break; case PermissionResult.Error: MySandboxGame.Static.Invoke(delegate { MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); }, "New Game screen"); break; } }); break; case PermissionResult.Error: MySandboxGame.Static.Invoke(delegate { MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info); }, "New Game screen"); break; } }); } else if (!m_parallelLoadIsRunning) { m_parallelLoadIsRunning = true; MyGuiScreenProgress progressScreen = new MyGuiScreenProgress(MyTexts.Get(MySpaceTexts.ProgressScreen_LoadingWorld)); MyScreenManager.AddScreen(progressScreen); Parallel.StartBackground(delegate { MySessionLoader.LoadLastSession(); }, delegate { progressScreen.CloseScreen(); m_parallelLoadIsRunning = false; }); } }
private static void ServerFailedToRespond(object sender, object e) { CloseHandlers(); m_progressScreen.CloseScreen(); MyGuiSandbox.Show(MyCommonTexts.MultiplaterJoin_ServerIsNotResponding, default(MyStringId), MyMessageBoxStyleEnum.Error); }
private void JoinFailCallback(string message) { MyStringId caption = new MyStringId(); MyGuiSandbox.Show(new StringBuilder(message), caption, MyMessageBoxStyleEnum.Error); }