From 50e54bf8d445d5c202a26afee41682463ccfb453 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sat, 18 May 2019 17:31:36 +0300 Subject: [PATCH] (55318b678) Credits additions, made the "community actives" section a little more readable --- .../Source/Screens/CreditsPlayer.cs | 35 ++++++++++++-- .../BarotraumaShared/Source/GameSettings.cs | 48 +++++++++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs b/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs index edd14786a..718c7c116 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs @@ -27,6 +27,9 @@ namespace Barotrauma case "text": AddTextElement(subElement, listBox.Content.RectTransform); break; + case "gridtext": + AddGridTextElement(subElement, listBox.Content.RectTransform); + break; case "spacing": AddSpacingElement(subElement, listBox.Content.RectTransform); break; @@ -38,9 +41,9 @@ namespace Barotrauma listBox.UpdateScrollBarSize(); } - private void AddTextElement(XElement element, RectTransform parent) + private GUIComponent AddTextElement(XElement element, RectTransform parent, string overrideText = null, Anchor anchor = Anchor.Center) { - var text = element.ElementInnerText().Replace(@"\n", "\n"); + var text = overrideText ?? element.ElementInnerText().Replace(@"\n", "\n"); Color color = element.GetAttributeColor("color", Color.White); float scale = element.GetAttributeFloat("scale", 1.0f); Alignment alignment = Alignment.Center; @@ -69,7 +72,7 @@ namespace Barotrauma } var textHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.0f), parent), style: null); - var textBlock = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), textHolder.RectTransform, Anchor.Center), + var textBlock = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), textHolder.RectTransform, anchor), text, color, font, @@ -81,6 +84,32 @@ namespace Barotrauma textBlock.RectTransform.IsFixedSize = textHolder.RectTransform.IsFixedSize = true; textBlock.RectTransform.NonScaledSize = new Point(textBlock.Rect.Width, textBlock.Rect.Height); textHolder.RectTransform.NonScaledSize = new Point(textHolder.Rect.Width, textBlock.Rect.Height); + return textHolder; + } + + private void AddGridTextElement(XElement element, RectTransform parent) + { + var text = element.ElementInnerText().Replace(@"\n", "\n"); + string[] elements = text.Split(','); + RectTransform lineContainer = null; + for (int i = 0; i < elements.Length; i++) + { + switch (i % 3) + { + case 0: + lineContainer = AddTextElement(element, parent, elements[i], Anchor.CenterLeft).RectTransform; + lineContainer.Anchor = Anchor.TopCenter; + lineContainer.Pivot = Pivot.TopCenter; + lineContainer.NonScaledSize = new Point((int)(parent.NonScaledSize.X * 0.7f), lineContainer.NonScaledSize.Y); + break; + case 1: + AddTextElement(element, lineContainer, elements[i], Anchor.Center).GetChild().TextAlignment = Alignment.Center; + break; + case 2: + AddTextElement(element, lineContainer, elements[i], Anchor.CenterRight).GetChild().TextAlignment = Alignment.CenterRight; + break; + } + } } private void AddSpacingElement(XElement element, RectTransform parent) diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index d6722b111..64b8a8358 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -821,6 +821,54 @@ namespace Barotrauma VoiceSetting = voiceSetting; } } + if (!SelectedContentPackages.Any()) + { + var availablePackage = ContentPackage.List.FirstOrDefault(cp => cp.IsCompatible() && cp.CorePackage); + if (availablePackage != null) + { + SelectedContentPackages.Add(availablePackage); + } + } + + //save to get rid of the invalid selected packages in the config file + if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0) { SaveNewPlayerConfig(); } + } + #endregion + + #region Save DefaultConfig + private void SaveNewDefaultConfig() + { + XDocument doc = new XDocument(); + + if (doc.Root == null) + { + doc.Add(new XElement("config")); + } + + doc.Root.Add( + new XAttribute("language", TextManager.Language), + new XAttribute("masterserverurl", MasterServerUrl), + new XAttribute("autocheckupdates", AutoCheckUpdates), + new XAttribute("musicvolume", musicVolume), + new XAttribute("soundvolume", soundVolume), + new XAttribute("voicechatvolume", voiceChatVolume), + new XAttribute("verboselogging", VerboseLogging), + new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs), + new XAttribute("enablesplashscreen", EnableSplashScreen), + new XAttribute("usesteammatchmaking", useSteamMatchmaking), + new XAttribute("quickstartsub", QuickStartSubmarineName), + new XAttribute("requiresteamauthentication", requireSteamAuthentication), + new XAttribute("aimassistamount", aimAssistAmount)); + + if (!ShowUserStatisticsPrompt) + { + doc.Root.Add(new XAttribute("senduserstatistics", sendUserStatistics)); + } + + if (WasGameUpdated) + { + doc.Root.Add(new XAttribute("wasgameupdated", true)); + } useSteamMatchmaking = doc.Root.GetAttributeBool("usesteammatchmaking", useSteamMatchmaking); requireSteamAuthentication = doc.Root.GetAttributeBool("requiresteamauthentication", requireSteamAuthentication);