private void CheckDx11AndStart() { bool needsDx11 = (m_scenarioTypesGroup.SelectedButton as MyGuiControlScenarioButton).Scenario.HasPlanets; if (!needsDx11) { StartNewSandbox(); } else if (MySandboxGame.IsDirectX11) { StartNewSandbox(); } else if (MyDirectXHelper.IsDx11Supported()) { // Has DX11, ask for switch or selecting different scenario MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( callback: OnSwitchAnswer, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.QuickstartDX11SwitchQuestion), buttonType: MyMessageBoxButtonsType.YES_NO)); } else { // No DX11, ask for selecting another scenario var text = MyTexts.Get(MySpaceTexts.QuickstartNoDx9SelectDifferent); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); } }
void EntityIDInput(ScreenResult result, string resultText) { if (result == ScreenResult.Ok) { uint entityID; if (uint.TryParse(resultText, out entityID)) { var entity = MyEntities.GetEntityByIdOrNull(new MyEntityIdentifier(entityID)); if (entity != null) { var position = entity.GetPosition() - entity.WorldVolume.Radius * entity.GetForward(); MySpectator.SetViewMatrix(Matrix.CreateLookAt(position, entity.GetPosition(), entity.GetUp())); MyEditorGizmo.AddEntityToSelection(entity); } else { MyGuiScreenMessageBox.Show(MyTextsWrapperEnum.EntityIsNotExist, type: MyMessageBoxType.ERROR); } } else { MyGuiScreenMessageBox.Show(MyTextsWrapperEnum.WrongNumberFormat, type: MyMessageBoxType.ERROR); } } }
private void OnExitToMainMenuClick(MyGuiControlButton sender) { base.CanBeHidden = false; MyGuiScreenMessageBox myGuiScreenMessageBox = ((!Sync.IsServer) ? MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Info, MyMessageBoxButtonsType.YES_NO, MyTexts.Get(MyCommonTexts.MessageBoxTextAnyWorldBeforeExit), MyTexts.Get(MyCommonTexts.MessageBoxCaptionExit), null, null, null, null, OnExitToMainMenuFromCampaignMessageBoxCallback) : ((MySession.Static.Settings.EnableSaving && Sync.IsServer) ? MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.YES_NO_CANCEL, MyTexts.Get(MyCommonTexts.MessageBoxTextSaveChangesBeforeExit), MyTexts.Get(MyCommonTexts.MessageBoxCaptionExit), null, null, null, null, OnExitToMainMenuMessageBoxCallback) : MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Info, MyMessageBoxButtonsType.YES_NO, MyTexts.Get(MyCommonTexts.MessageBoxTextCampaignBeforeExit), MyTexts.Get(MyCommonTexts.MessageBoxCaptionExit), null, null, null, null, OnExitToMainMenuFromCampaignMessageBoxCallback))); myGuiScreenMessageBox.SkipTransition = true; myGuiScreenMessageBox.InstantClose = false; MyGuiSandbox.AddScreen(myGuiScreenMessageBox); }
private void OnClickSaveWorld(MyGuiControlButton sender) { base.CanBeHidden = false; MyGuiScreenMessageBox myGuiScreenMessageBox = ((!MyAsyncSaving.InProgress) ? MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.YES_NO, MyTexts.Get(MyCommonTexts.MessageBoxTextDoYouWantToSaveYourProgress), MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm), null, null, null, null, OnSaveWorldMessageBoxCallback) : MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MessageBoxTextSavingInProgress), MyTexts.Get(MyCommonTexts.MessageBoxCaptionError))); myGuiScreenMessageBox.SkipTransition = true; myGuiScreenMessageBox.InstantClose = false; MyGuiSandbox.AddScreen(myGuiScreenMessageBox); }
public static MyGuiScreenMessageBox CreateMessageBox( MyMessageBoxStyleEnum styleEnum = MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType buttonType = MyMessageBoxButtonsType.OK, StringBuilder messageText = null, StringBuilder messageCaption = null, MyStringId?okButtonText = null, MyStringId?cancelButtonText = null, MyStringId?yesButtonText = null, MyStringId?noButtonText = null, Action <MyGuiScreenMessageBox.ResultEnum> callback = null, int timeoutInMiliseconds = 0, MyGuiScreenMessageBox.ResultEnum focusedResult = MyGuiScreenMessageBox.ResultEnum.YES, bool canHideOthers = true, Vector2?size = null, bool useOpacity = true, Vector2?position = null, bool focusable = true, bool canBeHidden = false, Action onClosing = null) { int num1 = (int)styleEnum; int num2 = (int)buttonType; StringBuilder messageText1 = messageText; StringBuilder messageCaption1 = messageCaption; MyStringId? nullable = okButtonText; MyStringId okButtonText1 = nullable ?? MyCommonTexts.Ok; nullable = cancelButtonText; MyStringId cancelButtonText1 = nullable ?? MyCommonTexts.Cancel; nullable = yesButtonText; MyStringId yesButtonText1 = nullable ?? MyCommonTexts.Yes; nullable = noButtonText; MyStringId noButtonText1 = nullable ?? MyCommonTexts.No; Action <MyGuiScreenMessageBox.ResultEnum> callback1 = callback; int timeoutInMiliseconds1 = timeoutInMiliseconds; int num3 = (int)focusedResult; int num4 = canHideOthers ? 1 : 0; Vector2?size1 = size; double num5 = useOpacity ? (double)MySandboxGame.Config.UIBkOpacity : 1.0; double num6 = useOpacity ? (double)MySandboxGame.Config.UIOpacity : 1.0; Vector2?position1 = position; int num7 = focusable ? 1 : 0; int num8 = canBeHidden ? 1 : 0; Action onClosing1 = onClosing; var dlg = new MyGuiScreenMessageBox((MyMessageBoxStyleEnum)num1, (MyMessageBoxButtonsType)num2, messageText1, messageCaption1, okButtonText1, cancelButtonText1, yesButtonText1, noButtonText1, callback1, timeoutInMiliseconds1, (MyGuiScreenMessageBox.ResultEnum)num3, num4 != 0, size1, (float)num5, (float)num6, position1, num7 != 0, num8 != 0, onClosing1); if (dlg.Controls.GetControlByName("MyGuiControlMultilineText") is MyGuiControlMultilineText text) { text.TextAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; } return(dlg); }
private static void OnJoinBattleFailed(MyGuiScreenProgress progress, MyMultiplayerBase multiplayer, string status) { MyGuiScreenMainMenu.UnloadAndExitToMenu(); progress.Cancel(); StringBuilder error = new StringBuilder(); //error.AppendFormat(MySpaceTexts.DialogTextJoinBattleLobbyFailed, status); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: error, messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); }
private static void OnJoinBattleFailed(MyGuiScreenProgress progress, MyMultiplayerBase multiplayer, string status) { if (multiplayer != null) { multiplayer.Dispose(); } progress.Cancel(); StringBuilder error = new StringBuilder(); error.AppendFormat(MySpaceTexts.DialogTextJoinBattleLobbyFailed, status); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: error, messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); }
public MyGuiScreenServerSave() { m_currentServerSaveScreen = new MyGuiScreenMessageBox( timeoutInMiliseconds: m_timeoutInSeconds, styleEnum: MyMessageBoxStyleEnum.BLUE, buttonType: MyMessageBoxButtonsType.NONE_TIMEOUT, messageText: new StringBuilder(MyTextsWrapper.GetString(MyTextsWrapperEnum.SavingPleaseWait)), callback: (result) => { CloseWindow = true; }); m_currentServerSaveScreen.InstantClose = false; MyGuiSandbox.AddScreen(m_currentServerSaveScreen); CloseWindow = false; SkipTransition = true; }
void MessageBoxSwitchCallback(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MySandboxGame.Config.GraphicsRenderer = MySandboxGame.DirectX11RendererKey; MySandboxGame.Config.Save(); var text = MyTexts.Get(MySpaceTexts.QuickstartDX11PleaseRestartGame); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), callback: OnPleaseRestart); MyGuiSandbox.AddScreen(mb); } else { var text = MyTexts.Get(MySpaceTexts.QuickstartNoPlanets); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), callback: StartNoPlanetsOK); MyGuiSandbox.AddScreen(mb); } }
void OnSwitchAnswer(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MySandboxGame.Config.GraphicsRenderer = MySandboxGame.DirectX11RendererKey; MySandboxGame.Config.Save(); MyGuiSandbox.BackToMainMenu(); var text = MyTexts.Get(MySpaceTexts.QuickstartDX11PleaseRestartGame); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); } else { var text = MyTexts.Get(MySpaceTexts.QuickstartSelectDifferent); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); } }
private static void OnJoinBattleFailed(MyGuiScreenProgress progress, MyMultiplayerBase multiplayer, string status, bool statusFullMessage = false) { MySessionLoader.UnloadAndExitToMenu(); progress.Cancel(); StringBuilder error = new StringBuilder(); if (statusFullMessage) { error.Append(status); } else { error.AppendFormat(MySpaceTexts.DialogTextJoinBattleFailed, status); } MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: error, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); }
public static void HandleDx11Needed() { MySessionLoader.UnloadAndExitToMenu(); if (MyDirectXHelper.IsDx11Supported()) { // Has DX11, ask for switch or selecting different scenario MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( callback: OnDX11SwitchRequestAnswer, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.QuickstartDX11SwitchQuestion), buttonType: MyMessageBoxButtonsType.YES_NO)); } else { // No DX11, ask for selecting another scenario var text = MyTexts.Get(MySpaceTexts.QuickstartNoDx9SelectDifferent); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); } }
protected virtual void StartQuickstart() { // TODO: Move to derived screen in SpaceEngineers.Game if (MySandboxGame.IsDirectX11) // Running DirectX11, start planet quickstart { QuickstartSandbox(GetQuickstartSettings(), CreatePlanetQuickstartArgs()); } else if (MyDirectXHelper.IsDx11Supported()) // DirectX11 not enabled, messagebox { MyScreenManager.RemoveAllScreensExcept(null); var text = MyTexts.Get(MySpaceTexts.QuickstartDX11SwitchQuestion); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), buttonType: MyMessageBoxButtonsType.YES_NO, callback: MessageBoxSwitchCallback); MyGuiSandbox.AddScreen(mb); } else // DirectX11 not supported, show message, start easy start 1 { MyScreenManager.RemoveAllScreensExcept(null); var text = MyTexts.Get(MySpaceTexts.QuickstartDX11NotAvailable); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), callback: StartNoPlanetsOK); MyGuiSandbox.AddScreen(mb); } }
/// <summary> /// Initialized new single player session and loads load checkpoint /// </summary> public static MyServerAction StartLastCheckpoint() { if (MyClientServer.LoggedPlayer.IsDemoUser()) { return(MySession.StartNewGame(MyGameplayConstants.GameplayDifficultyProfile.GameplayDifficulty)); } else { // Difficulty doesn't matter, will be rewritten by checkpoint MySession.Static = new MySinglePlayerSession(MyGameplayDifficultyEnum.NORMAL); MySession.Static.Init(); try { return(MySession.Static.LoadLastCheckpoint()); } catch (MyDataCorruptedException) { var screen = new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.SaveCorruptedText, MyTextsWrapperEnum.SaveCorruptedCaption, MyTextsWrapperEnum.Ok, OnErrorClick); MyGuiManager.AddScreen(screen); return(null); } } }
private void OnUserJoined(ref JoinResultMsg msg) { if (msg.JoinResult == JoinResult.OK) { base.IsServerExperimental = msg.ServerExperimental; if (this.OnJoin != null) { this.OnJoin(); this.OnJoin = null; } } else { StringBuilder builder; MyStringId? nullable; Vector2? nullable2; if (msg.JoinResult == JoinResult.NotInGroup) { MySessionLoader.UnloadAndExitToMenu(); this.Dispose(); ulong groupId = this.Server.GetGameTagByPrefixUlong("groupId"); string clanName = MyGameService.GetClanName(groupId); builder = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError); nullable = null; nullable = null; nullable = null; nullable = null; nullable2 = null; MyGuiScreenMessageBox screen = MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.YES_NO, new StringBuilder(string.Format(MyTexts.GetString(MyCommonTexts.MultiplayerErrorNotInGroup), clanName)), builder, nullable, nullable, nullable, nullable, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, nullable2); screen.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MyGameService.OpenOverlayUser(groupId); } }; MyGuiSandbox.AddScreen(screen); } else if (msg.JoinResult == JoinResult.BannedByAdmins) { MySessionLoader.UnloadAndExitToMenu(); this.Dispose(); ulong admin = msg.Admin; if (admin == 0) { builder = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError); nullable = null; nullable = null; nullable = null; nullable = null; nullable2 = null; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdmins), builder, nullable, nullable, nullable, nullable, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, nullable2)); } else { builder = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError); nullable = null; nullable = null; nullable = null; nullable = null; nullable2 = null; MyGuiScreenMessageBox screen = MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.YES_NO, MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdminsWithDialog), builder, nullable, nullable, nullable, nullable, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, nullable2); screen.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MyGameService.OpenOverlayUser(admin); } }; MyGuiSandbox.AddScreen(screen); } } else { StringBuilder messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorConnectionFailed); switch (msg.JoinResult) { case JoinResult.AlreadyJoined: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorAlreadyJoined); break; case JoinResult.TicketInvalid: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorTicketInvalid); break; case JoinResult.SteamServersOffline: messageText = new StringBuilder().AppendFormat(MyTexts.GetString(MyCommonTexts.MultiplayerErrorSteamServersOffline), MySession.Platform); break; case JoinResult.GroupIdInvalid: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorGroupIdInvalid); break; case JoinResult.ServerFull: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorServerFull); break; case JoinResult.KickedRecently: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorKickedByAdmins); break; case JoinResult.TicketCanceled: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorTicketCanceled); break; case JoinResult.TicketAlreadyUsed: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorTicketAlreadyUsed); break; case JoinResult.LoggedInElseWhere: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorLoggedInElseWhere); break; case JoinResult.NoLicenseOrExpired: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorNoLicenseOrExpired); break; case JoinResult.UserNotConnected: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorUserNotConnected); break; case JoinResult.VACBanned: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorVACBanned); break; case JoinResult.VACCheckTimedOut: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorVACCheckTimedOut); break; case JoinResult.PasswordRequired: MyGuiSandbox.AddScreen(new MyGuiScreenServerPassword(password => this.SendPasswordHash(password))); return; case JoinResult.WrongPassword: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorWrongPassword); break; case JoinResult.ExperimentalMode: messageText = !MySandboxGame.Config.ExperimentalMode ? MyTexts.Get(MyCommonTexts.MultiplayerErrorExperimental) : MyTexts.Get(MyCommonTexts.MultiplayerErrorNotExperimental); break; default: break; } this.Dispose(); MySessionLoader.UnloadAndExitToMenu(); nullable = null; nullable = null; nullable = null; nullable = null; nullable2 = null; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageText, MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), nullable, nullable, nullable, nullable, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, nullable2)); } } }
//loads next mission, SP only //id can be workshop ID or save name (in that case official scenarios are searched first, if not found, then user's saves) public static void LoadNextScenario(string id) { if (MySession.Static.OnlineMode != MyOnlineModeEnum.OFFLINE) { return; } MyAPIGateway.Utilities.ShowNotification(MyTexts.GetString(MySpaceTexts.NotificationNextScenarioWillLoad), 10000); ulong workshopID; if (ulong.TryParse(id, out workshopID)) { //scenario from steam, without the user needing to subscribe it first: if (!MySteam.IsOnline) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed), messageCaption: MyTexts.Get(MyCommonTexts.ScreenCaptionWorkshop))); } else { MySandboxGame.Log.WriteLine(string.Format("Querying details of file " + workshopID)); Action <bool, RemoteStorageGetPublishedFileDetailsResult> onGetDetailsCallResult = delegate(bool ioFailure, RemoteStorageGetPublishedFileDetailsResult data) { MySandboxGame.Log.WriteLine(string.Format("Obtained details: Id={4}; Result={0}; ugcHandle={1}; title='{2}'; tags='{3}'", data.Result, data.FileHandle, data.Title, data.Tags, data.PublishedFileId)); if (!ioFailure && data.Result == Result.OK && data.Tags.Length != 0) { m_newWorkshopMap.Title = data.Title; m_newWorkshopMap.PublishedFileId = data.PublishedFileId; m_newWorkshopMap.Description = data.Description; m_newWorkshopMap.UGCHandle = data.FileHandle; m_newWorkshopMap.SteamIDOwner = data.SteamIDOwner; m_newWorkshopMap.TimeUpdated = data.TimeUpdated; m_newWorkshopMap.Tags = data.Tags.Split(','); Static.EndAction += EndActionLoadWorkshop; } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed), messageCaption: MyTexts.Get(MyCommonTexts.ScreenCaptionWorkshop))); } }; MySteam.API.RemoteStorage.GetPublishedFileDetails(workshopID, 0, onGetDetailsCallResult); } } else { var contentDir = Path.Combine(MyFileSystem.ContentPath, "Missions", id); if (Directory.Exists(contentDir)) { m_newPath = contentDir; Static.EndAction += EndActionLoadLocal; return; } var saveDir = Path.Combine(MyFileSystem.SavesPath, id); if (Directory.Exists(saveDir)) { m_newPath = saveDir; Static.EndAction += EndActionLoadLocal; return; } //fail msg: StringBuilder error = new StringBuilder(); error.AppendFormat(MyTexts.GetString(MySpaceTexts.MessageBoxTextScenarioNotFound), contentDir, saveDir); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: error, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); } }
private void CreateInGameMenuControls() { 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; 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.ScreenMenuButtonSave), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { base.CanBeHidden = false; MyGuiScreenMessageBox myGuiScreenMessageBox = ((!MyAsyncSaving.InProgress) ? MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.YES_NO, MyTexts.Get(MyCommonTexts.MessageBoxTextDoYouWantToSaveYourProgress), MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm), null, null, null, null, OnSaveWorldMessageBoxCallback) : MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MessageBoxTextSavingInProgress), MyTexts.Get(MyCommonTexts.MessageBoxCaptionError))); myGuiScreenMessageBox.SkipTransition = true; myGuiScreenMessageBox.InstantClose = false; MyGuiSandbox.AddScreen(myGuiScreenMessageBox); }); myGuiControlButton.GamepadHelpTextId = optionsScreen_Help_Menu; 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.LoadScreenButtonSaveAs), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { MyGuiSandbox.AddScreen(new MyGuiScreenSaveAs(MySession.Static.Name)); }); myGuiControlButton2.GamepadHelpTextId = optionsScreen_Help_Menu; if (!Sync.IsServer || (MySession.Static != null && !MySession.Static.Settings.EnableSaving)) { MyStringId toolTip = ((!Sync.IsServer) ? MyCommonTexts.NotificationClientCannotSave : MyCommonTexts.NotificationSavingDisabled); myGuiControlButton.Enabled = false; myGuiControlButton.ShowTooltipWhenDisabled = true; myGuiControlButton.SetToolTip(toolTip); myGuiControlButton2.Enabled = false; myGuiControlButton2.ShowTooltipWhenDisabled = true; myGuiControlButton2.SetToolTip(toolTip); } Controls.Add(myGuiControlButton); m_elementGroup.Add(myGuiControlButton); Controls.Add(myGuiControlButton2); m_elementGroup.Add(myGuiControlButton2); MyGuiControlButton myGuiControlButton3; if (Sync.MultiplayerActive) { myGuiControlButton3 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonPlayers), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyGuiScreenPlayers>(Array.Empty <object>())); }); myGuiControlButton3.GamepadHelpTextId = optionsScreen_Help_Menu; Controls.Add(myGuiControlButton3); m_elementGroup.Add(myGuiControlButton3); } 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.ScreenMenuButtonOptions), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { MyGuiSandbox.AddScreen(new MyGuiScreenOptionsAudio(m_isLimitedMenu)); }); 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.ScreenMenuButtonExitToMainMenu), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate { base.CanBeHidden = false; MyGuiScreenMessageBox myGuiScreenMessageBox = ((!Sync.IsServer) ? MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Info, MyMessageBoxButtonsType.YES_NO, MyTexts.Get(MyCommonTexts.MessageBoxTextAnyWorldBeforeExit), MyTexts.Get(MyCommonTexts.MessageBoxCaptionExit), null, null, null, null, OnExitToMainMenuFromCampaignMessageBoxCallback) : ((MySession.Static.Settings.EnableSaving && Sync.IsServer) ? MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.YES_NO_CANCEL, MyTexts.Get(MyCommonTexts.MessageBoxTextSaveChangesBeforeExit), MyTexts.Get(MyCommonTexts.MessageBoxCaptionExit), null, null, null, null, OnExitToMainMenuMessageBoxCallback) : MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Info, MyMessageBoxButtonsType.YES_NO, MyTexts.Get(MyCommonTexts.MessageBoxTextCampaignBeforeExit), MyTexts.Get(MyCommonTexts.MessageBoxCaptionExit), null, null, null, null, OnExitToMainMenuFromCampaignMessageBoxCallback))); myGuiScreenMessageBox.SkipTransition = true; myGuiScreenMessageBox.InstantClose = false; MyGuiSandbox.AddScreen(myGuiScreenMessageBox); }); myGuiControlButton4.GamepadHelpTextId = optionsScreen_Help_Menu; Controls.Add(myGuiControlButton5); m_elementGroup.Add(myGuiControlButton5); }
/// <summary> /// Displays a message box to the user and calls the given callback, when it is closed. /// </summary> /// <param name="message">The message</param> /// <param name="caption">The caption of the box</param> /// <param name="callback">Callback to call when closed</param> public static void DisplayMessage(string message, string caption, Action callback = null) { MyGuiScreenMessageBox msg = new MyGuiScreenMessageBox(MyMessageBoxStyleEnum.Info, MyMessageBoxButtonsType.OK, new StringBuilder(message), new StringBuilder(caption), MyCommonTexts.Ok, MyCommonTexts.Cancel, MyCommonTexts.Yes, MyCommonTexts.No, null, 10000, MyGuiScreenMessageBox.ResultEnum.CANCEL, true, null, onClosing: callback);; MyGuiSandbox.AddScreen(msg); }