private void TryDeleteSub(Submarine sub) { if (sub == null) { return; } var msgBox = new GUIMessageBox("Delete file?", "Are you sure you want to delete \"" + sub.Name + "\"", new string[] { "OK", "Cancel" }); msgBox.Buttons[0].OnClicked += (btn, userData) => { try { sub.Remove(); File.Delete(sub.FilePath); CreateLoadScreen(); } catch (Exception e) { DebugConsole.ThrowError("Couldn't delete file \"" + sub.FilePath + "\"!", e); } return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[1].OnClicked += msgBox.Close; }
private void CheckContentPackage() { foreach (ContentPackage contentPackage in Config.SelectedContentPackages) { var exePaths = contentPackage.GetFilesOfType(ContentType.Executable); if (exePaths.Any() && AppDomain.CurrentDomain.FriendlyName != exePaths.First()) { var msgBox = new GUIMessageBox(TextManager.Get("Error"), TextManager.GetWithVariables("IncorrectExe", new string[2] { "[selectedpackage]", "[exename]" }, new string[2] { contentPackage.Name, exePaths.First() }), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked += (_, userdata) => { string fullPath = Path.GetFullPath(exePaths.First()); Process.Start(fullPath); Exit(); return(true); }; msgBox.Buttons[1].OnClicked = msgBox.Close; break; } } }
public void ShowEditorDisclaimer() { var msgBox = new GUIMessageBox(TextManager.Get("EditorDisclaimerTitle"), TextManager.Get("EditorDisclaimerText")); var linkHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), msgBox.Content.RectTransform)) { Stretch = true, RelativeSpacing = 0.025f }; linkHolder.RectTransform.MaxSize = new Point(int.MaxValue, linkHolder.Rect.Height); List <Pair <string, string> > links = new List <Pair <string, string> >() { new Pair <string, string>(TextManager.Get("EditorDisclaimerWikiLink"), TextManager.Get("EditorDisclaimerWikiUrl")), new Pair <string, string>(TextManager.Get("EditorDisclaimerDiscordLink"), TextManager.Get("EditorDisclaimerDiscordUrl")), new Pair <string, string>(TextManager.Get("EditorDisclaimerForumLink"), TextManager.Get("EditorDisclaimerForumUrl")), }; foreach (var link in links) { new GUIButton(new RectTransform(new Vector2(1.0f, 0.2f), linkHolder.RectTransform), link.First, style: "MainMenuGUIButton", textAlignment: Alignment.Left) { UserData = link.Second, OnClicked = (btn, userdata) => { ShowOpenUrlInWebBrowserPrompt(userdata as string); return(true); } }; } msgBox.InnerFrame.RectTransform.MinSize = new Point(0, msgBox.InnerFrame.Rect.Height + linkHolder.Rect.Height + msgBox.Content.AbsoluteSpacing * 2 + 10); Config.EditorDisclaimerShown = true; Config.SaveNewPlayerConfig(); }
private void ShowBuyPrompt(bool purchaseOnly) { if (GameMain.GameSession.Campaign.Money < selectedSubmarine.Price) { new GUIMessageBox(TextManager.Get("purchasesubmarineheader"), TextManager.GetWithVariables("notenoughmoneyforpurchasetext", notEnoughCreditsPurchaseTextVariables, new string[2] { currencyLongText, selectedSubmarine.DisplayName })); return; } GUIMessageBox msgBox; if (!purchaseOnly) { msgBox = new GUIMessageBox(TextManager.Get("purchaseandswitchsubmarineheader"), TextManager.GetWithVariables("purchaseandswitchsubmarinetext", PurchaseAndSwitchTextVariables, new string[4] { selectedSubmarine.DisplayName, selectedSubmarine.Price.ToString(), currencyLongText, CurrentOrPendingSubmarine().DisplayName }), messageBoxOptions); msgBox.Buttons[0].OnClicked = (applyButton, obj) => { if (GameMain.Client == null) { GameMain.GameSession.PurchaseSubmarine(selectedSubmarine); SubmarineInfo newSub = GameMain.GameSession.SwitchSubmarine(selectedSubmarine, 0); RefreshSubmarineDisplay(true); } else { GameMain.Client.InitiateSubmarineChange(selectedSubmarine, Networking.VoteType.PurchaseAndSwitchSub); } return(true); }; } else { msgBox = new GUIMessageBox(TextManager.Get("purchasesubmarineheader"), TextManager.GetWithVariables("purchasesubmarinetext", PurchaseTextVariables, new string[3] { selectedSubmarine.DisplayName, selectedSubmarine.Price.ToString(), currencyLongText }), messageBoxOptions); msgBox.Buttons[0].OnClicked = (applyButton, obj) => { if (GameMain.Client == null) { GameMain.GameSession.PurchaseSubmarine(selectedSubmarine); RefreshSubmarineDisplay(true); } else { GameMain.Client.InitiateSubmarineChange(selectedSubmarine, Networking.VoteType.PurchaseSub); } return(true); }; } msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[1].OnClicked = msgBox.Close; }
public void ShowOpenUrlInWebBrowserPrompt(string url) { if (string.IsNullOrEmpty(url)) { return; } if (GUIMessageBox.VisibleBox?.UserData as string == "verificationprompt") { return; } var msgBox = new GUIMessageBox("", TextManager.GetWithVariable("openlinkinbrowserprompt", "[link]", url), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }) { UserData = "verificationprompt" }; msgBox.Buttons[0].OnClicked = (btn, userdata) => { Process.Start(url); msgBox.Close(); return(true); }; msgBox.Buttons[1].OnClicked = msgBox.Close; }
private bool TryEndRound(GUIButton button, object obj) { leavingSub = obj as Submarine; if (leavingSub != null) { subsToLeaveBehind = GetSubsToLeaveBehind(leavingSub); } atEndPosition = leavingSub.AtEndPosition; if (subsToLeaveBehind.Any()) { string msg = TextManager.Get(subsToLeaveBehind.Count == 1 ? "LeaveSubBehind" : "LeaveSubsBehind"); var msgBox = new GUIMessageBox(TextManager.Get("Warning"), msg, new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked += EndRound; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[0].UserData = Submarine.Loaded.FindAll(s => !subsToLeaveBehind.Contains(s)); msgBox.Buttons[1].OnClicked += msgBox.Close; } else { EndRound(button, obj); } return(true); }
protected override void WatchmanInteract(Character watchman, Character interactor) { if ((watchman.Submarine == Level.Loaded.StartOutpost && !Submarine.MainSub.AtStartPosition) || (watchman.Submarine == Level.Loaded.EndOutpost && !Submarine.MainSub.AtEndPosition)) { return; } if (GUIMessageBox.MessageBoxes.Any(mbox => mbox.UserData as string == "watchmanprompt")) { return; } if (GameMain.Client != null && interactor == Character.Controlled) { var msgBox = new GUIMessageBox("", TextManager.GetWithVariable("CampaignEnterOutpostPrompt", "[locationname]", Submarine.MainSub.AtStartPosition ? Map.CurrentLocation.Name : Map.SelectedLocation.Name), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }) { UserData = "watchmanprompt" }; msgBox.Buttons[0].OnClicked = (btn, userdata) => { GameMain.Client.RequestRoundEnd(); return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[1].OnClicked += msgBox.Close; } }
private void InitUserStats() { if (GameSettings.ShowUserStatisticsPrompt) { var userStatsPrompt = new GUIMessageBox( "Do you want to help us make Barotrauma better?", "Do you allow Barotrauma to send usage statistics and error reports to the developers? The data is anonymous, " + "does not contain any personal information and is only used to help us diagnose issues and improve Barotrauma.", new string[] { "Yes", "No" }); userStatsPrompt.Buttons[0].OnClicked += (btn, userdata) => { GameSettings.ShowUserStatisticsPrompt = false; GameSettings.SendUserStatistics = true; GameAnalyticsManager.Init(); return(true); }; userStatsPrompt.Buttons[0].OnClicked += userStatsPrompt.Close; userStatsPrompt.Buttons[1].OnClicked += (btn, userdata) => { GameSettings.ShowUserStatisticsPrompt = false; GameSettings.SendUserStatistics = false; return(true); }; userStatsPrompt.Buttons[1].OnClicked += userStatsPrompt.Close; } else if (GameSettings.SendUserStatistics) { GameAnalyticsManager.Init(); } }
public void ClientRead(IReadMessage inc) { bool shouldReset = inc.ReadBoolean(); int money = inc.ReadInt32(); // uint length = inc.ReadUInt32(); // // for (int i = 0; i < length; i++) // { // string key = inc.ReadString(); // byte value = inc.ReadByte(); // Metadata.SetValue(key, value); // } Campaign.Money = money; if (shouldReset) { ResetUpgrades(); } // spentMoney is local, so this message box should only appear for those who have spent money on upgrades if (spentMoney > 0) { GUIMessageBox msgBox = new GUIMessageBox(TextManager.Get("UpgradeRefundTitle"), TextManager.Get("UpgradeRefundBody"), new [] { TextManager.Get("Ok") }); msgBox.Buttons[0].OnClicked += msgBox.Close; } spentMoney = 0; PendingUpgrades.Clear(); PurchasedUpgrades.Clear(); CanUpgrade = false; }
private bool TryEndRound(Submarine leavingSub) { if (leavingSub == null) { return(false); } this.leavingSub = leavingSub; subsToLeaveBehind = GetSubsToLeaveBehind(leavingSub); atEndPosition = leavingSub.AtEndPosition; if (subsToLeaveBehind.Any()) { string msg = TextManager.Get(subsToLeaveBehind.Count == 1 ? "LeaveSubBehind" : "LeaveSubsBehind"); var msgBox = new GUIMessageBox(TextManager.Get("Warning"), msg, new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked += (btn, userdata) => { EndRound(leavingSub); return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[0].UserData = Submarine.Loaded.FindAll(s => !subsToLeaveBehind.Contains(s)); msgBox.Buttons[1].OnClicked += msgBox.Close; } else { EndRound(leavingSub); } return(true); }
public void CheckForErrors() { List <string> errorMsgs = new List <string>(); if (!Hull.hullList.Any()) { errorMsgs.Add(TextManager.Get("NoHullsWarning")); } foreach (Item item in Item.ItemList) { if (item.GetComponent <Items.Components.Vent>() == null) { continue; } if (!item.linkedTo.Any()) { errorMsgs.Add(TextManager.Get("DisconnectedVentsWarning")); break; } } if (WayPoint.WayPointList.Find(wp => !wp.MoveWithLevel && wp.SpawnType == SpawnType.Path) == null) { errorMsgs.Add(TextManager.Get("NoWaypointsWarning")); } if (WayPoint.WayPointList.Find(wp => wp.SpawnType == SpawnType.Cargo) == null) { errorMsgs.Add(TextManager.Get("NoCargoSpawnpointWarning")); } if (errorMsgs.Any()) { new GUIMessageBox(TextManager.Get("Warning"), string.Join("\n\n", errorMsgs), 400, 0); } foreach (MapEntity e in MapEntity.mapEntityList) { if (Vector2.Distance(e.Position, HiddenSubPosition) > 20000) { var msgBox = new GUIMessageBox( TextManager.Get("Warning"), TextManager.Get("FarAwayEntitiesWarning"), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked += (btn, obj) => { GameMain.SubEditorScreen.Cam.Position = e.WorldPosition; return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[1].OnClicked += msgBox.Close; break; } } }
private void NotifyPrompt(string header, string body) { GUIMessageBox msgBox = new GUIMessageBox(header, body, new[] { TextManager.Get("Ok") }, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175)); msgBox.Buttons[0].OnClicked = delegate { msgBox.Close(); return(true); }; }
public void CreatePreviewWindow(GUIMessageBox messageBox) { var background = new GUIButton(new RectTransform(Vector2.One, messageBox.RectTransform), style: "GUIBackgroundBlocker") { OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) { messageBox.Close(); } return(true); } }; background.RectTransform.SetAsFirstChild(); new GUITextBlock(new RectTransform(new Vector2(1, 0), messageBox.Content.RectTransform, Anchor.TopCenter), Name, textAlignment: Alignment.Center, font: GUI.LargeFont, wrap: true); var upperPart = new GUIFrame(new RectTransform(new Vector2(1, 0.4f), messageBox.Content.RectTransform, Anchor.Center, Pivot.BottomCenter), color: Color.Transparent); var descriptionBox = new GUIListBox(new RectTransform(new Vector2(1, 0.35f), messageBox.Content.RectTransform, Anchor.Center, Pivot.TopCenter)); if (PreviewImage == null) { new GUITextBlock(new RectTransform(new Vector2(0.45f, 1), upperPart.RectTransform), TextManager.Get("SubPreviewImageNotFound")); } else { new GUIImage(new RectTransform(new Vector2(0.45f, 1), upperPart.RectTransform), PreviewImage); } Vector2 realWorldDimensions = Dimensions * Physics.DisplayToRealWorldRatio; string dimensionsStr = realWorldDimensions == Vector2.Zero ? TextManager.Get("Unknown") : TextManager.Get("DimensionsFormat").Replace("[width]", ((int)(realWorldDimensions.X)).ToString()).Replace("[height]", ((int)(realWorldDimensions.Y)).ToString()); var layoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 1), upperPart.RectTransform, Anchor.TopRight)); new GUITextBlock(new RectTransform(new Vector2(1, 0), layoutGroup.RectTransform), $"{TextManager.Get("Dimensions")}: {dimensionsStr}", font: GUI.SmallFont, wrap: true); new GUITextBlock(new RectTransform(new Vector2(1, 0), layoutGroup.RectTransform), $"{TextManager.Get("RecommendedCrewSize")}: {(RecommendedCrewSizeMax == 0 ? TextManager.Get("Unknown") : RecommendedCrewSizeMin + " - " + RecommendedCrewSizeMax)}", font: GUI.SmallFont, wrap: true); new GUITextBlock(new RectTransform(new Vector2(1, 0), layoutGroup.RectTransform), $"{TextManager.Get("RecommendedCrewExperience")}: {(string.IsNullOrEmpty(RecommendedCrewExperience) ? TextManager.Get("unknown") : TextManager.Get(RecommendedCrewExperience))}", font: GUI.SmallFont, wrap: true); new GUITextBlock(new RectTransform(new Vector2(1, 0), layoutGroup.RectTransform), $"{TextManager.Get("RequiredContentPackages")}: {string.Join(", ", RequiredContentPackages)}", font: GUI.SmallFont, wrap: true); new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform, Anchor.TopLeft), Description, font: GUI.SmallFont, wrap: true) { CanBeFocused = false }; }
private IEnumerable <object> WaitForMessageBoxClosed(GUIMessageBox box) { messageBoxOpen = true; while (GUIMessageBox.MessageBoxes.Contains(box)) { yield return(null); } yield return(new WaitForSeconds(.1f)); messageBoxOpen = false; }
public bool ValidatePendingHires(bool createNetworkEvent = false) { List <CharacterInfo> hires = new List <CharacterInfo>(); int total = 0; foreach (GUIComponent c in pendingList.Content.Children.ToList()) { if (c.UserData is Tuple <CharacterInfo, float> info) { hires.Add(info.Item1); total += info.Item1.Salary; } } if (hires.None() || total > campaign.Money) { return(false); } bool atLeastOneHired = false; foreach (CharacterInfo ci in hires) { if (campaign.TryHireCharacter(campaign.Map.CurrentLocation, ci)) { atLeastOneHired = true; PendingHires.Remove(ci); pendingList.Content.RemoveChild(pendingList.Content.FindChild(c => (c.UserData as Tuple <CharacterInfo, float>).Item1 == ci)); } else { break; } } if (atLeastOneHired) { UpdateLocationView(campaign.Map.CurrentLocation, true); SelectCharacter(null, null, null); var dialog = new GUIMessageBox( TextManager.Get("newcrewmembers"), TextManager.GetWithVariable("crewhiredmessage", "[location]", campaignUI?.Campaign?.Map?.CurrentLocation?.Name), new string[] { TextManager.Get("Ok") }); dialog.Buttons[0].OnClicked += dialog.Close; } if (createNetworkEvent) { SendCrewState(true, validateHires: true); } return(false); }
private void CreateCustomizeWindow() { CampaignCustomizeSettings = new GUIMessageBox("", "", new string[] { TextManager.Get("OK") }, new Vector2(0.2f, 0.2f)); CampaignCustomizeSettings.Buttons[0].OnClicked += CampaignCustomizeSettings.Close; CampaignSettingsContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), CampaignCustomizeSettings.Content.RectTransform, Anchor.TopCenter)) { RelativeSpacing = 0.1f }; if (MapGenerationParams.Instance.RadiationParams != null) { bool prevRadiationToggleEnabled = EnableRadiationToggle?.Selected ?? true; EnableRadiationToggle = new GUITickBox(new RectTransform(new Vector2(0.3f, 0.3f), CampaignSettingsContent.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUI.Style.Font) { Selected = prevRadiationToggleEnabled, ToolTip = TextManager.Get("campaignoption.enableradiation.tooltip") }; } var maxMissionCountSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.3f), CampaignSettingsContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { Stretch = true, ToolTip = TextManager.Get("maxmissioncounttooltip") }; var maxMissionCountDescription = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.0f), maxMissionCountSettingHolder.RectTransform), TextManager.Get("maxmissioncount", fallBackTag: "missions"), wrap: true); var maxMissionCountContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), maxMissionCountSettingHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { RelativeSpacing = 0.05f, Stretch = true }; var maxMissionCountButtons = new GUIButton[2]; maxMissionCountButtons[0] = new GUIButton(new RectTransform(new Vector2(0.15f, 0.8f), maxMissionCountContainer.RectTransform), style: "GUIButtonToggleLeft") { OnClicked = (button, obj) => { MaxMissionCountText.Text = Math.Clamp(Int32.Parse(MaxMissionCountText.Text) - 1, CampaignSettings.MinMissionCountLimit, CampaignSettings.MaxMissionCountLimit).ToString(); return(true); } }; string prevMaxMissionCountText = MaxMissionCountText?.Text ?? CampaignSettings.DefaultMaxMissionCount.ToString(); MaxMissionCountText = new GUITextBlock(new RectTransform(new Vector2(0.7f, 1.0f), maxMissionCountContainer.RectTransform), prevMaxMissionCountText, textAlignment: Alignment.Center, style: "GUITextBox"); maxMissionCountButtons[1] = new GUIButton(new RectTransform(new Vector2(0.15f, 0.8f), maxMissionCountContainer.RectTransform), style: "GUIButtonToggleRight") { OnClicked = (button, obj) => { MaxMissionCountText.Text = Math.Clamp(Int32.Parse(MaxMissionCountText.Text) + 1, CampaignSettings.MinMissionCountLimit, CampaignSettings.MaxMissionCountLimit).ToString(); return(true); } }; maxMissionCountContainer.Children.ForEach(c => c.ToolTip = maxMissionCountSettingHolder.ToolTip); }
private bool CreateTestSetupMenu() { var msgBox = new GUIMessageBox(TextManager.Get("EventEditor.TestPromptHeader"), "", new[] { TextManager.Get("Cancel"), TextManager.Get("OK") }, relativeSize: new Vector2(0.2f, 0.3f), minSize: new Point(300, 175)); var layout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.5f), msgBox.Content.RectTransform)); new GUITextBlock(new RectTransform(new Vector2(1, 0.25f), layout.RectTransform), TextManager.Get("EventEditor.OutpostGenParams"), font: GUI.SubHeadingFont); GUIDropDown paramInput = new GUIDropDown(new RectTransform(new Vector2(1, 0.25f), layout.RectTransform), string.Empty, OutpostGenerationParams.Params.Count); foreach (OutpostGenerationParams param in OutpostGenerationParams.Params) { paramInput.AddItem(param.Identifier, param); } paramInput.OnSelected = (_, param) => { lastTestParam = param as OutpostGenerationParams; return(true); }; paramInput.SelectItem(lastTestParam ?? OutpostGenerationParams.Params.FirstOrDefault()); new GUITextBlock(new RectTransform(new Vector2(1, 0.25f), layout.RectTransform), TextManager.Get("EventEditor.LocationType"), font: GUI.SubHeadingFont); GUIDropDown typeInput = new GUIDropDown(new RectTransform(new Vector2(1, 0.25f), layout.RectTransform), string.Empty, LocationType.List.Count); foreach (LocationType type in LocationType.List) { typeInput.AddItem(type.Identifier, type); } typeInput.OnSelected = (_, type) => { lastTestType = type as LocationType; return(true); }; typeInput.SelectItem(lastTestType ?? LocationType.List.FirstOrDefault()); // Cancel button msgBox.Buttons[0].OnClicked = (button, o) => { msgBox.Close(); return(true); }; // Ok button msgBox.Buttons[1].OnClicked = (button, o) => { TestEvent(lastTestParam, lastTestType); msgBox.Close(); return(true); }; return(true); }
public void ShowBugReporter() { if (GUIMessageBox.VisibleBox != null && GUIMessageBox.VisibleBox.UserData as string == "bugreporter") { return; } var msgBox = new GUIMessageBox(TextManager.Get("bugreportbutton"), ""); msgBox.UserData = "bugreporter"; var linkHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), msgBox.Content.RectTransform)) { Stretch = true, RelativeSpacing = 0.025f }; linkHolder.RectTransform.MaxSize = new Point(int.MaxValue, linkHolder.Rect.Height); #if !UNSTABLE new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), linkHolder.RectTransform), TextManager.Get("bugreportfeedbackform"), style: "MainMenuGUIButton", textAlignment: Alignment.Left) { UserData = "https://steamcommunity.com/app/602960/discussions/1/", OnClicked = (btn, userdata) => { if (!SteamManager.OverlayCustomURL(userdata as string)) { ShowOpenUrlInWebBrowserPrompt(userdata as string); } msgBox.Close(); return(true); } }; #endif new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), linkHolder.RectTransform), TextManager.Get("bugreportgithubform"), style: "MainMenuGUIButton", textAlignment: Alignment.Left) { #if UNSTABLE UserData = "https://barotraumagame.com/unstable-3rf3w5t4ter/", #else UserData = "https://github.com/Regalis11/Barotrauma/issues/new?template=bug_report.md", #endif OnClicked = (btn, userdata) => { ShowOpenUrlInWebBrowserPrompt(userdata as string); msgBox.Close(); return(true); } }; msgBox.InnerFrame.RectTransform.MinSize = new Point(0, msgBox.InnerFrame.Rect.Height + linkHolder.Rect.Height + msgBox.Content.AbsoluteSpacing * 2 + (int)(50 * GUI.Scale)); }
public override void MsgBox() { if (mission == null) { return; } var missionMsg = new GUIMessageBox(mission.Name, mission.Description, 400, 400); missionMsg.UserData = "missionstartmessage"; Networking.GameServer.Log("Mission: " + mission.Name, Networking.ServerLog.MessageType.ServerMessage); Networking.GameServer.Log(mission.Description, Networking.ServerLog.MessageType.ServerMessage); }
private bool SaveProjectToFile(GUIButton button, object o) { string directory = Path.GetFullPath("EventProjects"); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var msgBox = new GUIMessageBox(TextManager.Get("EventEditor.NameFilePrompt"), "", new[] { TextManager.Get("Cancel"), TextManager.Get("Save") }, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175)); var layout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), msgBox.Content.RectTransform), isHorizontal: true); GUITextBox nameInput = new GUITextBox(new RectTransform(Vector2.One, layout.RectTransform)) { Text = projectName }; // Cancel button msgBox.Buttons[0].OnClicked = delegate { msgBox.Close(); return(true); }; // Ok button msgBox.Buttons[1].OnClicked = delegate { foreach (var illegalChar in Path.GetInvalidFileNameChars()) { if (!nameInput.Text.Contains(illegalChar)) { continue; } GUI.AddMessage(TextManager.GetWithVariable("SubNameIllegalCharsWarning", "[illegalchar]", illegalChar.ToString()), GUI.Style.Red); return(false); } msgBox.Close(); projectName = nameInput.Text; XElement save = SaveEvent(projectName); string filePath = System.IO.Path.Combine(directory, $"{projectName}.sevproj"); File.WriteAllText(Path.Combine(directory, $"{projectName}.sevproj"), save.ToString()); GUI.AddMessage($"Project saved to {filePath}", GUI.Style.Green); AskForConfirmation(TextManager.Get("EventEditor.TestPromptHeader"), TextManager.Get("EventEditor.TestPromptBody"), CreateTestSetupMenu); return(true); }; return(true); }
private void RefundUpgrades() { DebugConsole.Log($"Refunded {spentMoney} marks in pending upgrades."); if (spentMoney > 0) { #if CLIENT GUIMessageBox msgBox = new GUIMessageBox(TextManager.Get("UpgradeRefundTitle"), TextManager.Get("UpgradeRefundBody"), new[] { TextManager.Get("Ok") }); msgBox.Buttons[0].OnClicked += msgBox.Close; #endif } Campaign.Money += spentMoney; spentMoney = 0; PendingUpgrades.Clear(); PurchasedUpgrades.Clear(); }
public override void MsgBox() { if (mission == null) { return; } var missionMsg = new GUIMessageBox(mission.Name, mission.Description, new Vector2(0.25f, 0.0f), new Point(400, 200)) { UserData = "missionstartmessage" }; #if SERVER Networking.GameServer.Log(TextManager.Get("Mission") + ": " + mission.Name, Networking.ServerLog.MessageType.ServerMessage); Networking.GameServer.Log(mission.Description, Networking.ServerLog.MessageType.ServerMessage); #endif }
public void CreatePreviewWindow(GUIMessageBox messageBox) { var background = new GUIButton(new RectTransform(Vector2.One, messageBox.RectTransform), style: "GUIBackgroundBlocker") { OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) { messageBox.Close(); } return(true); } }; background.RectTransform.SetAsFirstChild(); var holder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.85f), messageBox.Content.RectTransform), style: null); CreatePreviewWindow(holder); }
public static void QuitToMainMenu(bool save, bool showVerificationPrompt) { if (showVerificationPrompt) { string text = (Screen.Selected is CharacterEditor.CharacterEditorScreen || Screen.Selected is SubEditorScreen) ? "PauseMenuQuitVerificationEditor" : "PauseMenuQuitVerification"; var msgBox = new GUIMessageBox("", TextManager.Get(text), new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") }) { UserData = "verificationprompt" }; msgBox.Buttons[0].OnClicked = (yesBtn, userdata) => { QuitToMainMenu(save); return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[1].OnClicked += msgBox.Close; } }
private void InitUserStats() { return; if (GameSettings.ShowUserStatisticsPrompt) { if (TextManager.ContainsTag("statisticspromptheader") && TextManager.ContainsTag("statisticsprompttext")) { var userStatsPrompt = new GUIMessageBox( TextManager.Get("statisticspromptheader"), TextManager.Get("statisticsprompttext"), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); userStatsPrompt.Buttons[0].OnClicked += (btn, userdata) => { GameSettings.ShowUserStatisticsPrompt = false; GameSettings.SendUserStatistics = true; GameAnalyticsManager.Init(); Config.SaveNewPlayerConfig(); return(true); }; userStatsPrompt.Buttons[0].OnClicked += userStatsPrompt.Close; userStatsPrompt.Buttons[1].OnClicked += (btn, userdata) => { GameSettings.ShowUserStatisticsPrompt = false; GameSettings.SendUserStatistics = false; Config.SaveNewPlayerConfig(); return(true); }; userStatsPrompt.Buttons[1].OnClicked += userStatsPrompt.Close; } else { //user statistics enabled by default if the prompt cannot be shown in the user's language GameSettings.ShowUserStatisticsPrompt = false; GameSettings.SendUserStatistics = true; GameAnalyticsManager.Init(); Config.SaveNewPlayerConfig(); } } else if (GameSettings.SendUserStatistics) { GameAnalyticsManager.Init(); } }
protected override void WatchmanInteract(Character watchman, Character interactor) { if (interactor != null) { interactor.FocusedCharacter = null; } Submarine leavingSub = GetLeavingSub(); if (leavingSub == null) { CreateDialog(new List <Character> { watchman }, "WatchmanInteractNoLeavingSub", 5.0f); return; } CreateDialog(new List <Character> { watchman }, "WatchmanInteract", 1.0f); if (GUIMessageBox.MessageBoxes.Any(mbox => mbox.UserData as string == "watchmanprompt")) { return; } var msgBox = new GUIMessageBox("", TextManager.GetWithVariable("CampaignEnterOutpostPrompt", "[locationname]", leavingSub.AtStartPosition ? Map.CurrentLocation.Name : Map.SelectedLocation.Name), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }) { UserData = "watchmanprompt" }; msgBox.Buttons[0].OnClicked = (btn, userdata) => { if (!isRunning) { return(true); } TryEndRound(GetLeavingSub()); return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[1].OnClicked += msgBox.Close; }
private void ShowTransferPrompt() { if (GameMain.GameSession.Campaign.Money < deliveryFee && deliveryFee > 0) { new GUIMessageBox(TextManager.Get("deliveryrequestheader"), TextManager.GetWithVariables("notenoughmoneyfordeliverytext", notEnoughCreditsDeliveryTextVariables, new string[] { currencyLongText, selectedSubmarine.DisplayName, deliveryLocationName, GameMain.GameSession.Map.CurrentLocation.Name })); return; } GUIMessageBox msgBox; if (deliveryFee > 0) { msgBox = new GUIMessageBox(TextManager.Get("deliveryrequestheader"), TextManager.GetWithVariables("deliveryrequesttext", DeliveryTextVariables, new string[6] { selectedSubmarine.DisplayName, deliveryLocationName, GameMain.GameSession.Map.CurrentLocation.Name, CurrentOrPendingSubmarine().DisplayName, deliveryFee.ToString(), currencyLongText }), messageBoxOptions); } else { msgBox = new GUIMessageBox(TextManager.Get("switchsubmarineheader"), TextManager.GetWithVariables("switchsubmarinetext", SwitchTextVariables, new string[2] { CurrentOrPendingSubmarine().DisplayName, selectedSubmarine.DisplayName }), messageBoxOptions); } msgBox.Buttons[0].OnClicked = (applyButton, obj) => { if (GameMain.Client == null) { GameMain.GameSession.SwitchSubmarine(selectedSubmarine, deliveryFee); GameMain.GameSession.Campaign.UpgradeManager.RefundResetAndReload(selectedSubmarine); RefreshSubmarineDisplay(true); } else { GameMain.Client.InitiateSubmarineChange(selectedSubmarine, Networking.VoteType.SwitchSub); } return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[1].OnClicked = msgBox.Close; }
private bool TryEndRound() { var transitionType = GetAvailableTransition(out LevelData nextLevel, out Submarine leavingSub); if (leavingSub == null || transitionType == TransitionType.None) { return(false); } if (nextLevel == null) { //no level selected -> force the player to select one CampaignUI.SelectTab(InteractionType.Map); map.SelectLocation(-1); ForceMapUI = true; return(false); } else if (transitionType == TransitionType.ProgressToNextEmptyLocation) { Map.SetLocation(Map.Locations.IndexOf(Level.Loaded.EndLocation ?? Map.CurrentLocation)); } var subsToLeaveBehind = GetSubsToLeaveBehind(leavingSub); if (subsToLeaveBehind.Any()) { string msg = TextManager.Get(subsToLeaveBehind.Count == 1 ? "LeaveSubBehind" : "LeaveSubsBehind"); var msgBox = new GUIMessageBox(TextManager.Get("Warning"), msg, new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked += (btn, userdata) => { LoadNewLevel(); return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[0].UserData = Submarine.Loaded.FindAll(s => !subsToLeaveBehind.Contains(s)); msgBox.Buttons[1].OnClicked += msgBox.Close; } else { LoadNewLevel(); } return(true); }
public void UpdateSubList() { var subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)); subList.ClearChildren(); foreach (Submarine sub in subsToShow) { var textBlock = new GUITextBlock( new Rectangle(0, 0, 0, 25), ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), "ListBoxElement", Alignment.Left, Alignment.Left, subList) { Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f), ToolTip = sub.Description, UserData = sub }; if (sub.HasTag(SubmarineTag.Shuttle)) { textBlock.TextColor = textBlock.TextColor * 0.85f; var shuttleText = new GUITextBlock(new Rectangle(-20, 0, 0, 25), TextManager.Get("Shuttle"), "", Alignment.CenterRight, Alignment.CenterRight, textBlock, false, GUI.SmallFont); shuttleText.TextColor = textBlock.TextColor * 0.8f; shuttleText.ToolTip = textBlock.ToolTip; } GUIButton infoButton = new GUIButton(new Rectangle(0, 0, 20, 20), "?", Alignment.CenterRight, "", textBlock); infoButton.UserData = sub; infoButton.OnClicked += (component, userdata) => { var msgBox = new GUIMessageBox("", "", 550, 350); ((Submarine)userdata).CreatePreviewWindow(msgBox.InnerFrame); return(true); }; } if (Submarine.SavedSubmarines.Count > 0) { subList.Select(Submarine.SavedSubmarines[0]); } }
public static void CreateReadyCheck() { if (lastReadyCheck < DateTime.Now) { #if !DEBUG lastReadyCheck = DateTime.Now.AddMinutes(1); #endif IWriteMessage msg = new WriteOnlyMessage(); msg.Write((byte)ClientPacketHeader.READY_CHECK); msg.Write((byte)ReadyCheckState.Start); GameMain.Client?.ClientPeer?.Send(msg, DeliveryMethod.Reliable); return; } GUIMessageBox msgBox = new GUIMessageBox(readyCheckHeader, readyCheckPleaseWait((lastReadyCheck - DateTime.Now).Seconds), new[] { closeButton }); msgBox.Buttons[0].OnClicked = delegate { msgBox.Close(); return(true); }; }