diff --git a/Barotrauma/BarotraumaClient/ClientCode.projitems b/Barotrauma/BarotraumaClient/ClientCode.projitems index 991ce2d39..96e169d05 100644 --- a/Barotrauma/BarotraumaClient/ClientCode.projitems +++ b/Barotrauma/BarotraumaClient/ClientCode.projitems @@ -223,6 +223,7 @@ Never + diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index c3c50da75..c96a76c05 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -80,8 +80,8 @@ - - ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.1.1.12\lib\net45\GameAnalytics.Mono.dll + + ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\lib\net45\GameAnalytics.Mono.dll ..\..\Libraries\NuGet\MonoGame.Framework.DesktopGL.3.7.1.189\lib\net45\MonoGame.Framework.dll @@ -101,7 +101,7 @@ - ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.1.1.12\lib\net45\System.Data.SQLite.dll + ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\lib\net45\System.Data.SQLite.dll @@ -247,6 +247,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -268,6 +271,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -341,13 +350,13 @@ - - + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj index 797f42a80..b57d6b7cc 100644 --- a/Barotrauma/BarotraumaClient/MacClient.csproj +++ b/Barotrauma/BarotraumaClient/MacClient.csproj @@ -79,8 +79,8 @@ - - ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.1.1.12\lib\net45\GameAnalytics.Mono.dll + + ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\lib\net45\GameAnalytics.Mono.dll ..\..\Libraries\NuGet\MonoGame.Framework.DesktopGL.3.7.1.189\lib\net45\MonoGame.Framework.dll @@ -100,7 +100,7 @@ - ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.1.1.12\lib\net45\System.Data.SQLite.dll + ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\lib\net45\System.Data.SQLite.dll @@ -271,13 +271,12 @@ - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + - + + + \ No newline at end of file diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs index 0ee4b4bdf..aaf8d1e3b 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs @@ -43,7 +43,7 @@ namespace Barotrauma { return text; } - text = TextManager.Get(textTag).Replace("[key]", keyBind); + text = TextManager.GetWithVariable(textTag, "[key]", keyBind); cachedHudTexts.Add(textTag + keyBind, text); return text; } diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterInfo.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterInfo.cs index 9896272dd..f678e8b3a 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterInfo.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterInfo.cs @@ -119,11 +119,9 @@ namespace Barotrauma if ((int)newLevel > (int)prevLevel) { GUI.AddMessage( - TextManager.Get("SkillIncreased") - .Replace("[name]", Name) - .Replace("[skillname]", TextManager.Get("SkillName." + skillIdentifier)) - .Replace("[newlevel]", ((int)newLevel).ToString()), - Color.Green); + TextManager.GetWithVariables("SkillIncreased", new string[3] { "[name]", "[skillname]", "[newlevel]" }, + new string[3] { Name, TextManager.Get("SkillName." + skillIdentifier), ((int)newLevel).ToString() }, + new bool[3] { false, true, false }), Color.Green); } } diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/AfflictionHusk.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/AfflictionHusk.cs index 727aea035..802016b71 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Health/AfflictionHusk.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/AfflictionHusk.cs @@ -26,7 +26,7 @@ namespace Barotrauma } else if (state != InfectionState.Active && Character.Controlled == character) { - GUI.AddMessage(TextManager.Get("HuskActivate").Replace("[Attack]", GameMain.Config.KeyBind(InputType.Attack).ToString()), + GUI.AddMessage(TextManager.GetWithVariable("HuskActivate", "[Attack]", GameMain.Config.KeyBind(InputType.Attack).ToString()), Color.Red); } } diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs index afa1d3daf..90748c3f2 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs @@ -606,7 +606,7 @@ namespace Barotrauma .ThenByDescending(a => a.Strength).FirstOrDefault(); if (affliction.DamagePerSecond > 0 || affliction.Strength > 0) { - var limbHealth = GetMathingLimbHealth(affliction); + var limbHealth = GetMatchingLimbHealth(affliction); if (limbHealth != null) { selectedLimbIndex = limbHealths.IndexOf(limbHealth); diff --git a/Barotrauma/BarotraumaClient/Source/EventInput/EventInput.cs b/Barotrauma/BarotraumaClient/Source/EventInput/EventInput.cs index e156dd669..ee3619634 100644 --- a/Barotrauma/BarotraumaClient/Source/EventInput/EventInput.cs +++ b/Barotrauma/BarotraumaClient/Source/EventInput/EventInput.cs @@ -256,4 +256,4 @@ namespace EventInput } #endif } -} +} \ No newline at end of file diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs index 9a02dd655..e93f22c76 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs @@ -118,27 +118,21 @@ namespace Barotrauma switch (subElement.Name.ToString().ToLowerInvariant()) { case "font": - if (Font == null) { continue; } Font.Size = GetFontSize(subElement); break; case "smallfont": - if (SmallFont == null) { continue; } SmallFont.Size = GetFontSize(subElement); break; case "largefont": - if (LargeFont == null) { continue; } LargeFont.Size = GetFontSize(subElement); break; case "objectivetitle": - if (ObjectiveTitleFont == null) { continue; } ObjectiveTitleFont.Size = GetFontSize(subElement); break; case "objectivename": - if (ObjectiveNameFont == null) { continue; } ObjectiveNameFont.Size = GetFontSize(subElement); break; case "videotitle": - if (VideoTitleFont == null) { continue; } VideoTitleFont.Size = GetFontSize(subElement); break; } diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index fe28df09d..a055efc07 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -226,7 +226,11 @@ namespace Barotrauma GraphicsWidth = Config.GraphicsWidth; GraphicsHeight = Config.GraphicsHeight; - + if (Config.WindowMode == WindowMode.BorderlessWindowed) + { + GraphicsWidth = GraphicsDevice.DisplayMode.Width; + GraphicsHeight = GraphicsDevice.DisplayMode.Height; + } GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.Reach; GraphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Color; GraphicsDeviceManager.PreferMultiSampling = false; @@ -250,6 +254,8 @@ namespace Barotrauma GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsWidth; GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight; + + GraphicsDeviceManager.ApplyChanges(); } public void ResetViewPort() @@ -267,10 +273,7 @@ namespace Barotrauma { base.Initialize(); - DisplayWidth = GraphicsDevice.DisplayMode.Width; - DisplayHeight = GraphicsDevice.DisplayMode.Height; - - RequestGraphicsSettings(); + ApplyGraphicsSettings(); ScissorTestEnable = new RasterizerState() { ScissorTestEnable = true }; @@ -309,45 +312,8 @@ namespace Barotrauma #endif loadingCoroutine = CoroutineManager.StartCoroutine(Load(canLoadInSeparateThread), "", canLoadInSeparateThread); - -#if WINDOWS - var gameForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(Window.Handle); - gameForm.Activated += new EventHandler(HandleFocus); - gameForm.Deactivate += new EventHandler(HandleDefocus); - if (WindowActive) { HandleFocus(null, null); } -#endif } - -#if WINDOWS - private void HandleFocus(object sender, EventArgs e) - { - CoroutineManager.StopCoroutines("FocusCoroutine"); - CoroutineManager.StartCoroutine(FocusCoroutine(),"FocusCoroutine"); - } - - private IEnumerable FocusCoroutine() - { - yield return new WaitForSeconds(0.01f); - ApplyGraphicsSettings(); - yield return CoroutineStatus.Success; - } -#endif - - private void HandleDefocus(object sender, EventArgs e) - { - CoroutineManager.StopCoroutines("FocusCoroutine"); - if (GraphicsDeviceManager.IsFullScreen && !GraphicsDeviceManager.HardwareModeSwitch) - { - DisplayMode minMode = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.First(m => m.Format == SurfaceFormat.Color); - GraphicsDeviceManager.PreferredBackBufferWidth = minMode.Width; - GraphicsDeviceManager.PreferredBackBufferHeight = minMode.Height; - GraphicsDeviceManager.IsFullScreen = false; - GraphicsDeviceManager.ApplyChanges(); - Thread.Sleep(100); - } - } -#endif - + private void InitUserStats() { if (GameSettings.ShowUserStatisticsPrompt) @@ -584,10 +550,8 @@ namespace Barotrauma var exePaths = contentPackage.GetFilesOfType(ContentType.Executable); if (exePaths.Any() && AppDomain.CurrentDomain.FriendlyName != exePaths.First()) { - var msgBox = new GUIMessageBox(TextManager.Get("Error"), - TextManager.Get("IncorrectExe") - .Replace("[selectedpackage]", contentPackage.Name) - .Replace("[exename]", 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) => { @@ -927,7 +891,7 @@ namespace Barotrauma { if (NetworkMember != null) NetworkMember.Disconnect(); SteamManager.ShutDown(); - if (GameSettings.SendUserStatistics) GameAnalytics.OnStop(); + if (GameSettings.SendUserStatistics) GameAnalytics.OnQuit(); base.OnExiting(sender, args); } } diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index bf758c5ea..c2e36d361 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -505,7 +505,10 @@ namespace Barotrauma btn.OnClicked += (GUIButton button, object userData) => { - if (Character.Controlled == null || Character.Controlled.SpeechImpediment >= 100.0f) return false; +#if CLIENT + if (GameMain.Client != null && Character.Controlled == null) { return false; } +#endif + if (Character.Controlled != null && Character.Controlled.SpeechImpediment >= 100.0f) { return false; } if (btn.GetChildByUserData("selected").Visible) { @@ -919,7 +922,9 @@ namespace Barotrauma Font = GUI.SmallFont, OnClicked = (btn, userData) => { - if (Character.Controlled == null) return false; +#if CLIENT + if (GameMain.Client != null && Character.Controlled == null) { return false; } +#endif SetCharacterOrder(character, userData as Order, option, Character.Controlled); orderTargetFrame = null; OrderOptionButtons.Clear(); @@ -957,7 +962,9 @@ namespace Barotrauma UserData = item == null ? order : new Order(order, item, item.Components.FirstOrDefault(ic => ic.GetType() == order.ItemComponentType)), OnClicked = (btn, userData) => { - if (Character.Controlled == null) return false; +#if CLIENT + if (GameMain.Client != null && Character.Controlled == null) { return false; } +#endif SetCharacterOrder(character, userData as Order, option, Character.Controlled); orderTargetFrame = null; OrderOptionButtons.Clear(); diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/MultiPlayerCampaign.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/MultiPlayerCampaign.cs index bb18197ea..6be3bacb1 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/MultiPlayerCampaign.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/MultiPlayerCampaign.cs @@ -113,8 +113,8 @@ namespace Barotrauma if (GameMain.Client != null && interactor == Character.Controlled) { - var msgBox = new GUIMessageBox("", TextManager.Get("CampaignEnterOutpostPrompt") - .Replace("[locationname]", Submarine.MainSub.AtStartPosition ? Map.CurrentLocation.Name : Map.SelectedLocation.Name), + 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" diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs index b0463872e..0bb370465 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs @@ -125,12 +125,12 @@ namespace Barotrauma } else if (leavingSub.AtEndPosition) { - endRoundButton.Text = ToolBox.LimitString(TextManager.Get("EnterLocation").Replace("[locationname]", Map.SelectedLocation.Name), endRoundButton.Font, endRoundButton.Rect.Width - 5); + endRoundButton.Text = ToolBox.LimitString(TextManager.GetWithVariable("EnterLocation", "[locationname]", Map.SelectedLocation.Name), endRoundButton.Font, endRoundButton.Rect.Width - 5); endRoundButton.Visible = true; } else if (leavingSub.AtStartPosition) { - endRoundButton.Text = ToolBox.LimitString(TextManager.Get("EnterLocation").Replace("[locationname]", Map.CurrentLocation.Name), endRoundButton.Font, endRoundButton.Rect.Width - 5); + endRoundButton.Text = ToolBox.LimitString(TextManager.GetWithVariable("EnterLocation", "[locationname]", Map.CurrentLocation.Name), endRoundButton.Font, endRoundButton.Rect.Width - 5); endRoundButton.Visible = true; } else @@ -189,8 +189,8 @@ namespace Barotrauma { return; } - var msgBox = new GUIMessageBox("", TextManager.Get("CampaignEnterOutpostPrompt") - .Replace("[locationname]", leavingSub.AtStartPosition ? Map.CurrentLocation.Name : Map.SelectedLocation.Name), + 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" diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs index 1427c742c..f45ec0fc9 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs @@ -230,7 +230,7 @@ namespace Barotrauma.Tutorials } while (!Submarine.MainSub.AtEndPosition || Submarine.MainSub.DockedTo.Count == 0); RemoveCompletedObjective(segments[6]); yield return new WaitForSeconds(3f, false); - GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Captain.Radio.Complete").Replace("[OUTPOSTNAME]", GameMain.GameSession.EndLocation.Name), ChatMessageType.Radio, null); + GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.GetWithVariable("Captain.Radio.Complete", "[OUTPOSTNAME]", GameMain.GameSession.EndLocation.Name), ChatMessageType.Radio, null); SetHighlight(captain_navConsole.Item, false); SetHighlight(captain_sonar.Item, false); SetHighlight(captain_statusMonitor, false); diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameSession.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameSession.cs index 016cd1d1c..b9d2f5b69 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameSession.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameSession.cs @@ -123,7 +123,7 @@ namespace Barotrauma new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedFrame.RectTransform), Mission.Name, font: GUI.LargeFont); - new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedFrame.RectTransform), TextManager.Get("MissionReward").Replace("[reward]", Mission.Reward.ToString())); + new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedFrame.RectTransform), TextManager.GetWithVariable("MissionReward", "[reward]", Mission.Reward.ToString())); new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform), Mission.Description, wrap: true); } diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/RoundSummary.cs b/Barotrauma/BarotraumaClient/Source/GameSession/RoundSummary.cs index e3e2992c6..e4e0bb2a6 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/RoundSummary.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/RoundSummary.cs @@ -44,16 +44,9 @@ namespace Barotrauma GUIListBox infoTextBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.7f), paddedFrame.RectTransform)); - string summaryText = TextManager.Get(gameOver ? "RoundSummaryGameOver" : - (progress ? "RoundSummaryProgress" : "RoundSummaryReturn")); - - int width = 760, height = 500; - GUIFrame innerFrame = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.5f), frame.RectTransform, Anchor.Center, minSize: new Point(width, height))); - var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), innerFrame.RectTransform, Anchor.Center)) - { - Stretch = true, - RelativeSpacing = 0.03f - }; + string summaryText = TextManager.GetWithVariables(gameOver ? "RoundSummaryGameOver" : + (progress ? "RoundSummaryProgress" : "RoundSummaryReturn"), new string[2] { "[sub]", "[location]" }, + new string[2] { Submarine.MainSub.Name, progress ? GameMain.GameSession.EndLocation.Name : GameMain.GameSession.StartLocation.Name }); var infoText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoTextBox.Content.RectTransform), summaryText, wrap: true); @@ -83,7 +76,7 @@ namespace Barotrauma if (GameMain.GameSession.Mission.Completed && singleplayer) { var missionReward = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoTextBox.Content.RectTransform), - TextManager.Get("MissionReward").Replace("[reward]", GameMain.GameSession.Mission.Reward.ToString())); + TextManager.GetWithVariable("MissionReward", "[reward]", GameMain.GameSession.Mission.Reward.ToString())); } } } diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs index 7ca6d5a85..8fb57e2f1 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs @@ -106,18 +106,15 @@ namespace Barotrauma { tickBox.TextColor = Color.Red; tickBox.Enabled = false; - tickBox.ToolTip = TextManager.Get(contentPackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage") - .Replace("[packagename]", contentPackage.Name) - .Replace("[packageversion]", contentPackage.GameVersion.ToString()) - .Replace("[gameversion]", GameMain.Version.ToString()); + tickBox.ToolTip = TextManager.GetWithVariables(contentPackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage", + new string[3] { "[packagename]", "[packageversion]", "[gameversion]" }, new string[3] { contentPackage.Name, contentPackage.GameVersion.ToString(), GameMain.Version.ToString() }); } else if (contentPackage.CorePackage && !contentPackage.ContainsRequiredCorePackageFiles(out List missingContentTypes)) { tickBox.TextColor = Color.Red; tickBox.Enabled = false; - tickBox.ToolTip = TextManager.Get("ContentPackageMissingCoreFiles") - .Replace("[packagename]", contentPackage.Name) - .Replace("[missingfiletypes]", string.Join(", ", missingContentTypes)); + tickBox.ToolTip = TextManager.GetWithVariables("ContentPackageMissingCoreFiles", new string[2] { "[packagename]", "[missingfiletypes]" }, + new string[2] { contentPackage.Name, string.Join(", ", missingContentTypes) }, new bool[2] { false, true }); } } @@ -192,14 +189,13 @@ namespace Barotrauma foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) { if (supportedDisplayModes.Any(m => m.Width == mode.Width && m.Height == mode.Height)) { continue; } - if (mode.Width < MinSupportedResolution.X || mode.Height < MinSupportedResolution.Y) { continue; } #if OSX // Monogame currently doesn't support retina displays // so we need to disable resolutions above the viewport size. // In a bundled .app you just disable HiDPI in the info.plist // but that's probably not gonna happen. - if (mode.Width > GameMain.DisplayWidth || mode.Height > GameMain.DisplayHeight) { continue; } + if (mode.Width > GameMain.Instance.GraphicsDevice.DisplayMode.Width || mode.Height > GameMain.Instance.GraphicsDevice.DisplayMode.Height) { continue; } #endif supportedDisplayModes.Add(mode); } @@ -207,11 +203,15 @@ namespace Barotrauma new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform), TextManager.Get("Resolution")); var resolutionDD = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform), elementCount: supportedDisplayModes.Count) { - OnSelected = SelectResolution - }; + OnSelected = SelectResolution, +#if !LINUX + ButtonEnabled = GameMain.Config.WindowMode == WindowMode.Windowed +#endif + }; foreach (DisplayMode mode in supportedDisplayModes) { + if (mode.Width < MinSupportedResolution.X || mode.Height < MinSupportedResolution.Y) { continue; } resolutionDD.AddItem(mode.Width + "x" + mode.Height, mode); if (GraphicsWidth == mode.Width && GraphicsHeight == mode.Height) resolutionDD.SelectItem(mode); } @@ -224,25 +224,6 @@ namespace Barotrauma new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform), TextManager.Get("DisplayMode")); var displayModeDD = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform)); - displayModeDD.OnSelected = (guiComponent, obj) => - { - UnsavedSettings = true; - GameMain.Config.WindowMode = (WindowMode)guiComponent.UserData; - if (GameMain.Config.WindowMode == WindowMode.BorderlessWindowed) - { - resolutionDD.SelectItem(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.First( - m => m.Width == GameMain.DisplayWidth && - m.Height == GameMain.DisplayHeight)); - resolutionDD.ButtonEnabled = false; - } - else - { - resolutionDD.ButtonEnabled = true; - } - return true; - }; - - displayModeDD.AddItem(TextManager.Get("Fullscreen"), WindowMode.Fullscreen); displayModeDD.AddItem(TextManager.Get("Windowed"), WindowMode.Windowed); #if (!OSX) @@ -259,6 +240,36 @@ namespace Barotrauma displayModeDD.SelectItem(GameMain.Config.WindowMode); } #endif + displayModeDD.OnSelected = (guiComponent, obj) => + { + ToolTip = TextManager.Get("EnableVSyncToolTip"), + OnSelected = (GUITickBox box) => + { + VSyncEnabled = box.Selected; + GameMain.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = VSyncEnabled; + GameMain.GraphicsDeviceManager.ApplyChanges(); + UnsavedSettings = true; + + return true; + }, + Selected = VSyncEnabled + }; + + //TODO: remove hardcoded texts after the texts have been added to localization + GUITickBox pauseOnFocusLostBox = new GUITickBox(new RectTransform(new Point(32, 32), leftColumn.RectTransform), + TextManager.Get("PauseOnFocusLost", returnNull: true) ?? "Pause on focus lost"); + pauseOnFocusLostBox.Selected = PauseOnFocusLost; + pauseOnFocusLostBox.ToolTip = TextManager.Get("PauseOnFocusLostToolTip", returnNull: true) ?? "Pauses the game when its window is not in focus. Note that the game won't be paused when a multiplayer session is active."; + pauseOnFocusLostBox.OnSelected = (tickBox) => + { + PauseOnFocusLost = tickBox.Selected; + UnsavedSettings = true; + GameMain.Config.WindowMode = (WindowMode)guiComponent.UserData; +#if !LINUX + resolutionDD.ButtonEnabled = GameMain.Config.WindowMode == WindowMode.Windowed; +#endif + return true; + }; GUITickBox vsyncTickBox = new GUITickBox(new RectTransform(new Point(32, 32), leftColumn.RectTransform), TextManager.Get("EnableVSync")) { @@ -848,7 +859,7 @@ namespace Barotrauma GraphicsWidth = mode.Width; GraphicsHeight = mode.Height; - GameMain.Instance.RequestGraphicsSettings(); + GameMain.Instance.ApplyGraphicsSettings(); UnsavedSettings = true; return true; @@ -987,7 +998,7 @@ namespace Barotrauma if (GameMain.WindowMode != GameMain.Config.WindowMode) { - GameMain.Instance.RequestGraphicsSettings(); + GameMain.Instance.ApplyGraphicsSettings(); } if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight) diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs index 467bbbb77..0e058bbd9 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs @@ -110,7 +110,7 @@ namespace Barotrauma.Items.Components if (child.UserData is Hull hull) { if (hull.Submarine == null || !hull.Submarine.IsOutpost) { continue; } - string text = TextManager.Get("MiniMapOutpostDockingInfo").Replace("[outpost]", hull.Submarine.Name); + string text = TextManager.GetWithVariable("MiniMapOutpostDockingInfo", "[outpost]", hull.Submarine.Name); Vector2 textSize = GUI.Font.MeasureString(text); Vector2 textPos = child.Center; if (textPos.X + textSize.X / 2 > submarineContainer.Rect.Right) diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Steering.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Steering.cs index 404829e26..a6fc8d8e2 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Steering.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Steering.cs @@ -290,9 +290,9 @@ namespace Barotrauma.Items.Components noPowerTip = TextManager.Get("SteeringNoPowerTip"); autoPilotMaintainPosTip = TextManager.Get("SteeringAutoPilotMaintainPosTip"); - autoPilotLevelStartTip = TextManager.Get("SteeringAutoPilotLocationTip").Replace("[locationname]", + autoPilotLevelStartTip = TextManager.GetWithVariable("SteeringAutoPilotLocationTip", "[locationname]", GameMain.GameSession?.StartLocation == null ? "Start" : GameMain.GameSession.StartLocation.Name); - autoPilotLevelEndTip = TextManager.Get("SteeringAutoPilotLocationTip").Replace("[locationname]", + autoPilotLevelEndTip = TextManager.GetWithVariable("SteeringAutoPilotLocationTip", "[locationname]", GameMain.GameSession?.EndLocation == null ? "End" : GameMain.GameSession.EndLocation.Name); steerArea = new GUICustomComponent(new RectTransform(new Point(viewSize), GuiFrame.RectTransform, Anchor.CenterLeft), diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/CustomInterface.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/CustomInterface.cs index a116d7603..004286d00 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/CustomInterface.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/CustomInterface.cs @@ -120,13 +120,13 @@ namespace Barotrauma.Items.Components if (uiElements[i] is GUIButton button) { button.Text = string.IsNullOrWhiteSpace(customInterfaceElementList[i].Label) ? - TextManager.Get("connection.signaloutx").Replace("[num]", (i + 1).ToString()) : + TextManager.GetWithVariable("connection.signaloutx", "[num]", (i + 1).ToString()) : customInterfaceElementList[i].Label; } else if (uiElements[i] is GUITickBox tickBox) { tickBox.Text = string.IsNullOrWhiteSpace(customInterfaceElementList[i].Label) ? - TextManager.Get("connection.signaloutx").Replace("[num]", (i + 1).ToString()) : + TextManager.GetWithVariable("connection.signaloutx", "[num]", (i + 1).ToString()) : customInterfaceElementList[i].Label; } } diff --git a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs index 3f8633f0c..53994493b 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs @@ -721,7 +721,7 @@ namespace Barotrauma var shadowSprite = GUI.Style.GetComponentStyle("OuterGlow").Sprites[GUIComponent.ComponentState.None][0]; string toolTip = mouseOnHealthInterface ? TextManager.Get("QuickUseAction.UseTreatment") : Character.Controlled.FocusedItem != null ? - TextManager.Get("PutItemIn").Replace("[itemname]", Character.Controlled.FocusedItem.Name) : + TextManager.GetWithVariable("PutItemIn", "[itemname]", Character.Controlled.FocusedItem.Name, true) : TextManager.Get("DropItem"); int textWidth = (int)Math.Max(GUI.Font.MeasureString(draggingItem.Name).X, GUI.SmallFont.MeasureString(toolTip).X); int textSpacing = (int)(15 * GUI.Scale); @@ -771,11 +771,11 @@ namespace Barotrauma { if (idJob == null) { - description = TextManager.Get("IDCardName").Replace("[name]", idName); + description = TextManager.GetWithVariable("IDCardName", "[name]", idName); } else { - description = TextManager.Get("IDCardNameJob").Replace("[name]", idName).Replace("[job]", idJob); + description = TextManager.GetWithVariables("IDCardNameJob", new string[2] { "[name]", "[job]" }, new string[2] { idName, idJob }, new bool[2] { false, true }); } if (!string.IsNullOrEmpty(item.Description)) { diff --git a/Barotrauma/BarotraumaClient/Source/Items/Item.cs b/Barotrauma/BarotraumaClient/Source/Items/Item.cs index bd3248c1a..71260001a 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Item.cs @@ -754,7 +754,7 @@ namespace Barotrauma itemInUseWarning.RectTransform.NonScaledSize = new Point(mergedHUDRect.Width, (int)(50 * GUI.Scale)); if (itemInUseWarning.UserData != otherCharacter) { - itemInUseWarning.Text = TextManager.Get("ItemInUse").Replace("[character]", otherCharacter.Name); + itemInUseWarning.Text = TextManager.GetWithVariable("ItemInUse", "[character]", otherCharacter.Name); itemInUseWarning.UserData = otherCharacter; } break; diff --git a/Barotrauma/BarotraumaClient/Source/Map/Submarine.cs b/Barotrauma/BarotraumaClient/Source/Map/Submarine.cs index 7e9d2051b..3063a925b 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Submarine.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Submarine.cs @@ -310,7 +310,7 @@ namespace Barotrauma Vector2 realWorldDimensions = Dimensions * Physics.DisplayToRealWorldRatio; if (realWorldDimensions != Vector2.Zero) { - string dimensionsStr = TextManager.Get("DimensionsFormat").Replace("[width]", ((int)(realWorldDimensions.X)).ToString()).Replace("[height]", ((int)(realWorldDimensions.Y)).ToString()); + string dimensionsStr = TextManager.GetWithVariables("DimensionsFormat", new string[2] { "[width]", "[height]" }, new string[2] { ((int)realWorldDimensions.X).ToString(), ((int)realWorldDimensions.Y).ToString() }); var dimensionsText = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), TextManager.Get("Dimensions"), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/BanList.cs b/Barotrauma/BarotraumaClient/Source/Networking/BanList.cs index 5077cef2c..962e8f436 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/BanList.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/BanList.cs @@ -81,7 +81,7 @@ namespace Barotrauma.Networking new GUITextBlock(new RectTransform(new Vector2(0.6f, 0.0f), paddedPlayerFrame.RectTransform), bannedPlayer.ExpirationTime == null ? - TextManager.Get("BanPermanent") : TextManager.Get("BanExpires").Replace("[time]", bannedPlayer.ExpirationTime.Value.ToString()), + TextManager.Get("BanPermanent") : TextManager.GetWithVariable("BanExpires", "[time]", bannedPlayer.ExpirationTime.Value.ToString()), font: GUI.SmallFont); var reasonText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 0.0f), paddedPlayerFrame.RectTransform), diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index b303caea6..26e9bdf38 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -269,7 +269,7 @@ namespace Barotrauma.Networking catch { new GUIMessageBox(TextManager.Get("CouldNotConnectToServer"), - TextManager.Get("InvalidIPAddress").Replace("[serverip]", serverIP).Replace("[port]", Port.ToString())); + TextManager.GetWithVariables("InvalidIPAddress", new string[2] { "[serverip]", "[port]" }, new string[2] { serverIP, Port.ToString() })); return; } @@ -347,7 +347,7 @@ namespace Barotrauma.Networking { if (reconnectBox == null) { - reconnectBox = new GUIMessageBox(connectingText, TextManager.Get("ConnectingTo").Replace("[serverip]", serverIP), new string[] { TextManager.Get("Cancel") }); + reconnectBox = new GUIMessageBox(connectingText, TextManager.GetWithVariable("ConnectingTo", "[serverip]", serverIP), new string[] { TextManager.Get("Cancel") }); reconnectBox.Buttons[0].OnClicked += (btn, userdata) => { CancelConnect(); return true; }; reconnectBox.Buttons[0].OnClicked += reconnectBox.Close; } @@ -667,7 +667,7 @@ namespace Barotrauma.Networking string errorMsg = "Error while reading a message from server. {" + e + "}\n" + e.StackTrace; GameAnalyticsManager.AddErrorEventOnce("GameClient.Update:CheckServerMessagesException" + e.TargetSite.ToString(), GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg); DebugConsole.ThrowError("Error while reading a message from server.", e); - new GUIMessageBox(TextManager.Get("Error"), TextManager.Get("MessageReadError").Replace("[message]", e.Message).Replace("[targetsite]", e.TargetSite.ToString())); + new GUIMessageBox(TextManager.Get("Error"), TextManager.GetWithVariables("MessageReadError", new string[2] { "[message]", "[targetsite]" }, new string[2] { e.Message, e.TargetSite.ToString() })); Disconnect(); GameMain.MainMenuScreen.Select(); return; @@ -1686,7 +1686,7 @@ namespace Barotrauma.Networking switch (transfer.FileType) { case FileTransferType.Submarine: - new GUIMessageBox(TextManager.Get("ServerDownloadFinished"), TextManager.Get("FileDownloadedNotification").Replace("[filename]", transfer.FileName)); + new GUIMessageBox(TextManager.Get("ServerDownloadFinished"), TextManager.GetWithVariable("FileDownloadedNotification", "[filename]", transfer.FileName)); var newSub = new Submarine(transfer.FilePath); var existingSubs = Submarine.SavedSubmarines.Where(s => s.Name == newSub.Name && s.MD5Hash.Hash == newSub.MD5Hash.Hash).ToList(); foreach (Submarine existingSub in existingSubs) @@ -2264,7 +2264,7 @@ namespace Barotrauma.Networking GUI.DrawString(spriteBatch, pos, - ToolBox.LimitString(TextManager.Get("DownloadingFile").Replace("[filename]", transfer.FileName), GUI.SmallFont, (int)downloadBarSize.X), + ToolBox.LimitString(TextManager.GetWithVariable("DownloadingFile", "[filename]", transfer.FileName), GUI.SmallFont, (int)downloadBarSize.X), Color.White, null, 0, GUI.SmallFont); GUI.DrawProgressBar(spriteBatch, new Vector2(pos.X, -pos.Y - downloadBarSize.Y / 2), new Vector2(downloadBarSize.X * 0.7f, downloadBarSize.Y / 2), transfer.Progress, Color.Green); GUI.DrawString(spriteBatch, pos + new Vector2(5, downloadBarSize.Y / 2), @@ -2297,9 +2297,7 @@ namespace Barotrauma.Networking } else { - string endVoteText = TextManager.Get("EndRoundVotes") - .Replace("[votes]", EndVoteCount.ToString()) - .Replace("[max]", EndVoteMax.ToString()); + string endVoteText = TextManager.GetWithVariables("EndRoundVotes", new string[2] { "[votes]", "[max]" }, new string[2] { EndVoteCount.ToString(), EndVoteMax.ToString() }); GUI.DrawString(spriteBatch, EndVoteTickBox.Rect.Center.ToVector2() - GUI.SmallFont.MeasureString(endVoteText) / 2, endVoteText, Color.White, @@ -2317,14 +2315,13 @@ namespace Barotrauma.Networking if (respawnManager.CurrentState == RespawnManager.State.Waiting && respawnManager.CountdownStarted) { - respawnInfo = TextManager.Get(respawnManager.UsingShuttle ? "RespawnShuttleDispatching" : "RespawningIn"); - respawnInfo = respawnInfo.Replace("[time]", ToolBox.SecondsToReadableTime(respawnManager.RespawnTimer)); + respawnInfo = TextManager.GetWithVariable(respawnManager.UsingShuttle ? "RespawnShuttleDispatching" : "RespawningIn", "[time]", ToolBox.SecondsToReadableTime(respawnManager.RespawnTimer)); } else if (respawnManager.CurrentState == RespawnManager.State.Transporting) { respawnInfo = respawnManager.TransportTimer <= 0.0f ? "" : - TextManager.Get("RespawnShuttleLeavingIn").Replace("[time]", ToolBox.SecondsToReadableTime(respawnManager.TransportTimer)); + TextManager.GetWithVariable("RespawnShuttleLeavingIn", "[time]", ToolBox.SecondsToReadableTime(respawnManager.TransportTimer)); } if (respawnManager != null) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/ServerInfo.cs b/Barotrauma/BarotraumaClient/Source/Networking/ServerInfo.cs index d896575f9..68356b34d 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/ServerInfo.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/ServerInfo.cs @@ -203,23 +203,20 @@ namespace Barotrauma.Networking if (ContentPackage.List.Any(cp => cp.MD5hash.Hash == ContentPackageHashes[i])) { packageText.TextColor = Color.Orange; - packageText.ToolTip = TextManager.Get("ServerListContentPackageNotEnabled") - .Replace("[contentpackage]", ContentPackageNames[i]); + packageText.ToolTip = TextManager.GetWithVariable("ServerListContentPackageNotEnabled", "[contentpackage]", ContentPackageNames[i]); } //workshop download link found else if (i < ContentPackageWorkshopUrls.Count && !string.IsNullOrEmpty(ContentPackageWorkshopUrls[i])) { availableWorkshopUrls.Add(ContentPackageWorkshopUrls[i]); packageText.TextColor = Color.Yellow; - packageText.ToolTip = TextManager.Get("ServerListIncompatibleContentPackageWorkshopAvailable") - .Replace("[contentpackage]", ContentPackageNames[i]); + packageText.ToolTip = TextManager.GetWithVariable("ServerListIncompatibleContentPackageWorkshopAvailable", "[contentpackage]", ContentPackageNames[i]); } else //no package or workshop download link found, tough luck { packageText.TextColor = Color.Red; - packageText.ToolTip = TextManager.Get("ServerListIncompatibleContentPackage") - .Replace("[contentpackage]", ContentPackageNames[i]) - .Replace("[hash]", ContentPackageHashes[i]); + packageText.ToolTip = TextManager.GetWithVariables("ServerListIncompatibleContentPackage", + new string[2] { "[contentpackage]", "[hash]" }, new string[2] { ContentPackageNames[i], ContentPackageHashes[i] }); } } } diff --git a/Barotrauma/BarotraumaClient/Source/Networking/ServerSettings.cs b/Barotrauma/BarotraumaClient/Source/Networking/ServerSettings.cs index a4e27b2e1..2af9e3428 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/ServerSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/ServerSettings.cs @@ -464,7 +464,8 @@ namespace Barotrauma.Networking ((GUIComponent)obj).Visible = !((GUIComponent)obj).Visible; return true; }; - + + InitMonstersEnabled(); List monsterNames = MonsterEnabled.Keys.ToList(); tempMonsterEnabled = new Dictionary(MonsterEnabled); foreach (string s in monsterNames) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/SteamManager.cs b/Barotrauma/BarotraumaClient/Source/Networking/SteamManager.cs index ceca903d2..38b56ce3e 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/SteamManager.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/SteamManager.cs @@ -596,7 +596,7 @@ namespace Barotrauma.Steam { if (!item.Installed) { - errorMsg = TextManager.Get("WorkshopErrorInstallRequiredToEnable").Replace("[itemname]", item.Title); + errorMsg = TextManager.GetWithVariable("WorkshopErrorInstallRequiredToEnable", "[itemname]", item.Title); DebugConsole.NewMessage(errorMsg, Microsoft.Xna.Framework.Color.Red); return false; } @@ -607,18 +607,15 @@ namespace Barotrauma.Steam if (!contentPackage.IsCompatible()) { - errorMsg = TextManager.Get(contentPackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage") - .Replace("[packagename]", contentPackage.Name) - .Replace("[packageversion]", contentPackage.GameVersion.ToString()) - .Replace("[gameversion]", GameMain.Version.ToString()); + errorMsg = TextManager.GetWithVariables(contentPackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage", + new string[3] { "[packagename]", "[packageversion]", "[gameversion]" }, new string[3] { contentPackage.Name, contentPackage.GameVersion.ToString(), GameMain.Version.ToString() }); return false; } if (contentPackage.CorePackage && !contentPackage.ContainsRequiredCorePackageFiles(out List missingContentTypes)) { - errorMsg = TextManager.Get("ContentPackageMissingCoreFiles") - .Replace("[packagename]", contentPackage.Name) - .Replace("[missingfiletypes]", string.Join(", ", missingContentTypes)); + errorMsg = TextManager.GetWithVariables("ContentPackageMissingCoreFiles", new string[2] { "[packagename]", "[missingfiletypes]" }, + new string[2] { contentPackage.Name, string.Join(", ", missingContentTypes) }, new bool[2] { false, true }); return false; } @@ -640,9 +637,7 @@ namespace Barotrauma.Steam { if (File.Exists(newContentPackagePath) && !CheckFileEquality(newContentPackagePath, metaDataFilePath)) { - errorMsg = TextManager.Get("WorkshopErrorOverwriteOnEnable") - .Replace("[itemname]", item.Title) - .Replace("[filename]", newContentPackagePath); + errorMsg = TextManager.GetWithVariables("WorkshopErrorOverwriteOnEnable", new string[2] { "[itemname]", "[filename]" }, new string[2] { item.Title, newContentPackagePath }); DebugConsole.NewMessage(errorMsg, Microsoft.Xna.Framework.Color.Red); return false; } @@ -652,9 +647,7 @@ namespace Barotrauma.Steam string sourceFile = Path.Combine(item.Directory.FullName, contentFile.Path); if (File.Exists(sourceFile) && File.Exists(contentFile.Path) && !CheckFileEquality(sourceFile, contentFile.Path)) { - errorMsg = TextManager.Get("WorkshopErrorOverwriteOnEnable") - .Replace("[itemname]", item.Title) - .Replace("[filename]", contentFile.Path); + errorMsg = TextManager.GetWithVariables("WorkshopErrorOverwriteOnEnable", new string[2] { "[itemname]", "[filename]" }, new string[2] { item.Title, contentFile.Path }); DebugConsole.NewMessage(errorMsg, Microsoft.Xna.Framework.Color.Red); return false; } @@ -673,15 +666,14 @@ namespace Barotrauma.Steam //the content package is trying to copy a file to a prohibited path, which is not allowed if (File.Exists(sourceFile)) { - errorMsg = TextManager.Get("WorkshopErrorIllegalPathOnEnable").Replace("[filename]", contentFile.Path); + errorMsg = TextManager.GetWithVariable("WorkshopErrorIllegalPathOnEnable", "[filename]", contentFile.Path); return false; } //not trying to copy anything, so this is a reference to an external file //if the external file doesn't exist, we cannot enable the package else if (!File.Exists(contentFile.Path)) { - //TODO: add the error message to localization - errorMsg = TextManager.Get("WorkshopErrorEnableFailed").Replace("[itemname]", item.Title) + " {File \"" + contentFile.Path + "\" not found.}"; + errorMsg = TextManager.GetWithVariable("WorkshopErrorEnableFailed", "[itemname]", item.Title) + " " + TextManager.GetWithVariable("WorkshopFileNotFound", "[path]", "\"" + contentFile.Path + "\""); return false; } continue; @@ -696,8 +688,7 @@ namespace Barotrauma.Steam else { //file not present in either the mod or the game folder -> cannot enable the package - //TODO: add the error message to localization - errorMsg = TextManager.Get("WorkshopErrorEnableFailed").Replace("[itemname]", item.Title) + " {File \"" + contentFile.Path + "\" not found.}"; + errorMsg = TextManager.GetWithVariable("WorkshopErrorEnableFailed", "[itemname]", item.Title) + " " + TextManager.GetWithVariable("WorkshopFileNotFound", "[path]", "\"" + contentFile.Path + "\""); return false; } } @@ -713,7 +704,7 @@ namespace Barotrauma.Steam if (!File.Exists(sourceFile)) { continue; } if (!ContentPackage.IsModFilePathAllowed(nonContentFile)) { - DebugConsole.ThrowError(TextManager.Get("WorkshopErrorIllegalPathOnEnable").Replace("[filename]", nonContentFile)); + DebugConsole.ThrowError(TextManager.GetWithVariable("WorkshopErrorIllegalPathOnEnable", "[filename]", nonContentFile)); continue; } Directory.CreateDirectory(Path.GetDirectoryName(nonContentFile)); @@ -722,7 +713,7 @@ namespace Barotrauma.Steam } catch (Exception e) { - errorMsg = TextManager.Get("WorkshopErrorEnableFailed").Replace("[itemname]", item.Title) + " {" + e.Message + "}"; + errorMsg = TextManager.GetWithVariable("WorkshopErrorEnableFailed", "[itemname]", item.Title) + " {" + e.Message + "}"; DebugConsole.NewMessage(errorMsg, Microsoft.Xna.Framework.Color.Red); return false; } @@ -937,11 +928,11 @@ namespace Barotrauma.Steam DebugConsole.ThrowError(errorMsg); new GUIMessageBox( TextManager.Get("Error"), - TextManager.Get("WorkshopItemUpdateFailed").Replace("[itemname]", item.Title).Replace("[errormessage]", errorMsg)); + TextManager.GetWithVariables("WorkshopItemUpdateFailed", new string[2] { "[itemname]", "[errormessage]" }, new string[2] { item.Title, errorMsg })); } else { - new GUIMessageBox("", TextManager.Get("WorkshopItemUpdated").Replace("[itemname]", item.Title)); + new GUIMessageBox("", TextManager.GetWithVariable("WorkshopItemUpdated", "[itemname]", item.Title)); itemsUpdated = true; } } diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs b/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs index aab141dd7..d3b3cde22 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs @@ -121,8 +121,7 @@ namespace Barotrauma if (!hasRequiredContentPackages) { var msgBox = new GUIMessageBox(TextManager.Get("ContentPackageMismatch"), - TextManager.Get("ContentPackageMismatchWarning") - .Replace("[requiredcontentpackages]", string.Join(", ", selectedSub.RequiredContentPackages)), + TextManager.GetWithVariable("ContentPackageMismatchWarning", "[requiredcontentpackages]", string.Join(", ", selectedSub.RequiredContentPackages)), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked = msgBox.Close; diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs b/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs index e622bc1ca..a393d601a 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs @@ -636,7 +636,7 @@ namespace Barotrauma CanBeFocused = false }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), - TextManager.Get("Reward").Replace("[reward]", selectedMission.Reward.ToString())) + TextManager.GetWithVariable("Reward", "[reward]", selectedMission.Reward.ToString())) { CanBeFocused = false }; @@ -860,8 +860,7 @@ namespace Barotrauma public string GetMoney() { - return TextManager.Get("PlayerCredits").Replace("[credits]", - ((GameMain.GameSession == null) ? "0" : string.Format(CultureInfo.InvariantCulture, "{0:N0}", Campaign.Money))); + return TextManager.GetWithVariable("PlayerCredits", "[credits]", (GameMain.GameSession == null) ? "0" : string.Format(CultureInfo.InvariantCulture, "{0:N0}", Campaign.Money)); } private bool SelectCharacter(GUIComponent component, object selection) @@ -902,7 +901,7 @@ namespace Barotrauma { var confirmDialog = new GUIMessageBox( TextManager.Get("FireWarningHeader"), - TextManager.Get("FireWarningText").Replace("[charactername]", ((CharacterInfo)obj).Name), + TextManager.GetWithVariable("FireWarningText", "[charactername]", ((CharacterInfo)obj).Name), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); confirmDialog.Buttons[0].UserData = (CharacterInfo)obj; confirmDialog.Buttons[0].OnClicked = FireCharacter; diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs b/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs index 718c7c116..594fac1ca 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CreditsPlayer.cs @@ -8,19 +8,31 @@ namespace Barotrauma { private GUIListBox listBox; - private readonly float scrollSpeed; + private XElement configElement; + + private float scrollSpeed; + public CreditsPlayer(RectTransform rectT, string configFile) : base(null, rectT) { - var doc = XMLExtensions.TryLoadXml(configFile); - scrollSpeed = doc.Root.GetAttributeFloat("scrollspeed", 100.0f); - int spacing = doc.Root.GetAttributeInt("spacing", 0); + GameMain.Instance.OnResolutionChanged += () => { ClearChildren(); Load(); }; - listBox = new GUIListBox(new RectTransform(Vector2.One, rectT), style: null) + var doc = XMLExtensions.TryLoadXml(configFile); + configElement = doc.Root; + + Load(); + } + + private void Load() + { + scrollSpeed = configElement.GetAttributeFloat("scrollspeed", 100.0f); + int spacing = configElement.GetAttributeInt("spacing", 0); + + listBox = new GUIListBox(new RectTransform(Vector2.One, RectTransform), style: null) { Spacing = spacing }; - foreach (XElement subElement in doc.Root.Elements()) + foreach (XElement subElement in configElement.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { diff --git a/Barotrauma/BarotraumaClient/Source/Screens/LevelEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/LevelEditorScreen.cs index 14dd89537..cf8126a46 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/LevelEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/LevelEditorScreen.cs @@ -277,7 +277,7 @@ namespace Barotrauma Stretch = true }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), commonnessContainer.RectTransform), - TextManager.Get("LevelEditorLevelObjCommonness").Replace("[leveltype]", selectedParams.Name), textAlignment: Alignment.Center); + TextManager.GetWithVariable("LevelEditorLevelObjCommonness", "[leveltype]", selectedParams.Name), textAlignment: Alignment.Center); new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), GUINumberInput.NumberType.Float) { MinValueFloat = 0, diff --git a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs index 9bcc3deed..a431c7354 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs @@ -199,12 +199,6 @@ namespace Barotrauma UserData = "noresults" }; } - else - { - joinButton.Enabled = false; - } - - return true; } private bool RefreshJoinButtonState(GUIComponent component, object obj) @@ -475,16 +469,15 @@ namespace Barotrauma { string toolTip = ""; if (serverInfo.GameVersion != GameMain.Version.ToString()) - toolTip = TextManager.Get("ServerListIncompatibleVersion").Replace("[version]", serverInfo.GameVersion); + toolTip = TextManager.GetWithVariable("ServerListIncompatibleVersion", "[version]", serverInfo.GameVersion); for (int i = 0; i < serverInfo.ContentPackageNames.Count; i++) { if (!GameMain.SelectedPackages.Any(cp => cp.MD5hash.Hash == serverInfo.ContentPackageHashes[i])) { if (toolTip != "") toolTip += "\n"; - toolTip += TextManager.Get("ServerListIncompatibleContentPackage") - .Replace("[contentpackage]", serverInfo.ContentPackageNames[i]) - .Replace("[hash]", Md5Hash.GetShortHash(serverInfo.ContentPackageHashes[i])); + toolTip += TextManager.GetWithVariables("ServerListIncompatibleContentPackage", new string[2] { "[contentpackage]", "[hash]" }, + new string[2] { serverInfo.ContentPackageNames[i], Md5Hash.GetShortHash(serverInfo.ContentPackageHashes[i]) }); } } @@ -558,17 +551,11 @@ namespace Barotrauma { case System.Net.HttpStatusCode.NotFound: new GUIMessageBox(TextManager.Get("MasterServerErrorLabel"), - TextManager.Get("MasterServerError404") - .Replace("[masterserverurl]", NetConfig.MasterServerUrl) - .Replace("[statuscode]", masterServerResponse.StatusCode.ToString()) - .Replace("[statusdescription]", masterServerResponse.StatusDescription)); + TextManager.GetWithVariable("MasterServerError404", "[masterserverurl]", NetConfig.MasterServerUrl)); break; case System.Net.HttpStatusCode.ServiceUnavailable: new GUIMessageBox(TextManager.Get("MasterServerErrorLabel"), - TextManager.Get("MasterServerErrorUnavailable") - .Replace("[masterserverurl]", NetConfig.MasterServerUrl) - .Replace("[statuscode]", masterServerResponse.StatusCode.ToString()) - .Replace("[statusdescription]", masterServerResponse.StatusDescription)); + TextManager.Get("MasterServerErrorUnavailable")); break; case System.Net.HttpStatusCode.ServiceUnavailable: new GUIMessageBox(TextManager.Get("MasterServerErrorLabel"), diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs index a1799b683..ce5b54c2d 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs @@ -415,14 +415,14 @@ namespace Barotrauma { if (SteamManager.UpdateWorkshopItem(item, out string errorMsg)) { - new GUIMessageBox("", TextManager.Get("WorkshopItemUpdated").Replace("[itemname]", TextManager.EnsureUTF8(item.Title))); + new GUIMessageBox("", TextManager.GetWithVariable("WorkshopItemUpdated", "[itemname]", TextManager.EnsureUTF8(item.Title))); } else { DebugConsole.ThrowError(errorMsg); new GUIMessageBox( TextManager.Get("Error"), - TextManager.Get("WorkshopItemUpdateFailed").Replace("[itemname]", TextManager.EnsureUTF8(item.Title)).Replace("[errormessage]", errorMsg)); + TextManager.GetWithVariables("WorkshopItemUpdateFailed", new string[2] { "[itemname]", "[errormessage]" }, new string[2] { TextManager.EnsureUTF8(item.Title), errorMsg })); } btn.Enabled = false; btn.Visible = false; @@ -733,7 +733,7 @@ namespace Barotrauma new GUIImage(new RectTransform(new Point(scoreContainer.Rect.Height), scoreContainer.RectTransform), i < starCount ? "GUIStarIconBright" : "GUIStarIconDark"); } - new GUITextBlock(new RectTransform(new Vector2(0.2f, 0.0f), scoreContainer.RectTransform), TextManager.Get("WorkshopItemVotes").Replace("[votecount]", (item.VotesUp + item.VotesDown).ToString())); + new GUITextBlock(new RectTransform(new Vector2(0.2f, 0.0f), scoreContainer.RectTransform), TextManager.GetWithVariable("WorkshopItemVotes", "[votecount]", (item.VotesUp + item.VotesDown).ToString())); //tags ------------------------------------ var tagContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) @@ -857,7 +857,7 @@ namespace Barotrauma if (!item.Installed) { new GUIMessageBox(TextManager.Get("Error"), - TextManager.Get("WorkshopErrorInstallRequiredToEdit").Replace("[itemname]", TextManager.EnsureUTF8(item.Title))); + TextManager.GetWithVariable("WorkshopErrorInstallRequiredToEdit", "[itemname]", TextManager.EnsureUTF8(item.Title))); return; } SteamManager.CreateWorkshopItemStaging(item, out itemEditor, out itemContentPackage); @@ -967,7 +967,7 @@ namespace Barotrauma { try { - OpenFileDialog ofd = new OpenFileDialog() + Barotrauma.OpenFileDialog ofd = new Barotrauma.OpenFileDialog() { Multiselect = true, InitialDirectory = Path.GetFullPath(SteamManager.WorkshopItemStagingFolder), @@ -1025,9 +1025,8 @@ namespace Barotrauma { new GUIMessageBox( TextManager.Get("Error"), - TextManager.Get("ContentPackageCantMakeCorePackage") - .Replace("[packagename]", itemContentPackage.Name) - .Replace("[missingfiletypes]", string.Join(", ", missingContentTypes))); + TextManager.GetWithVariables("ContentPackageCantMakeCorePackage", new string[2] { "[packagename]", "[missingfiletypes]" }, + new string[2] { itemContentPackage.Name, string.Join(", ", missingContentTypes) }, new bool[2] { false, true })); tickbox.Selected = false; } else @@ -1078,7 +1077,7 @@ namespace Barotrauma { try { - OpenFileDialog ofd = new OpenFileDialog() + Barotrauma.OpenFileDialog ofd = new Barotrauma.OpenFileDialog() { InitialDirectory = Path.GetFullPath(SteamManager.WorkshopItemStagingFolder), Title = TextManager.Get("workshopitemaddfiles"), @@ -1154,7 +1153,7 @@ namespace Barotrauma OnClicked = (btn, userData) => { if (itemEditor == null) { return false; } - var deleteVerification = new GUIMessageBox("", TextManager.Get("WorkshopItemDeleteVerification").Replace("[itemname]", itemEditor.Title), + var deleteVerification = new GUIMessageBox("", TextManager.GetWithVariable("WorkshopItemDeleteVerification", "[itemname]", itemEditor.Title), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); deleteVerification.Buttons[0].OnClicked = (yesBtn, userdata) => { @@ -1356,7 +1355,7 @@ namespace Barotrauma string pleaseWaitText = TextManager.Get("WorkshopPublishPleaseWait"); var msgBox = new GUIMessageBox( pleaseWaitText, - TextManager.Get("WorkshopPublishInProgress").Replace("[itemname]", TextManager.EnsureUTF8(item.Title)), + TextManager.GetWithVariable("WorkshopPublishInProgress", "[itemname]", TextManager.EnsureUTF8(item.Title)), new string[] { TextManager.Get("Cancel") }); msgBox.Buttons[0].OnClicked = (btn, userdata) => @@ -1378,13 +1377,13 @@ namespace Barotrauma if (string.IsNullOrEmpty(item.Error)) { - new GUIMessageBox("", TextManager.Get("WorkshopItemPublished").Replace("[itemname]", TextManager.EnsureUTF8(item.Title))); + new GUIMessageBox("", TextManager.GetWithVariable("WorkshopItemPublished", "[itemname]", TextManager.EnsureUTF8(item.Title))); } else { new GUIMessageBox( TextManager.Get("Error"), - TextManager.Get("WorkshopItemPublishFailed").Replace("[itemname]", TextManager.EnsureUTF8(item.Title)) + item.Error); + TextManager.GetWithVariable("WorkshopItemPublishFailed", "[itemname]", TextManager.EnsureUTF8(item.Title)) + item.Error); } createItemFrame.ClearChildren(); diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs index 15e319cb8..ec29f34d8 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs @@ -115,7 +115,7 @@ namespace Barotrauma { if (buoyancyVol / selectedVol < 1.0f) { - retVal += " (" + TextManager.Get("OptimalBallastLevel").Replace("[value]", (buoyancyVol / selectedVol).ToString("0.000")) + ")"; + retVal += " (" + TextManager.GetWithVariable("OptimalBallastLevel", "[value]", (buoyancyVol / selectedVol).ToString("0.000")) + ")"; } else { @@ -572,7 +572,7 @@ namespace Barotrauma ItemAssemblyPrefab assemblyPrefab = userData as ItemAssemblyPrefab; var msgBox = new GUIMessageBox( TextManager.Get("DeleteDialogLabel"), - TextManager.Get("DeleteDialogQuestion").Replace("[file]", assemblyPrefab.Name), + TextManager.GetWithVariable("DeleteDialogQuestion", "[file]", assemblyPrefab.Name), new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") }); msgBox.Buttons[0].OnClicked += (deleteBtn, userData2) => { @@ -584,7 +584,7 @@ namespace Barotrauma } catch (Exception e) { - DebugConsole.ThrowError(TextManager.Get("DeleteFileError").Replace("[file]", assemblyPrefab.Name), e); + DebugConsole.ThrowError(TextManager.GetWithVariable("DeleteFileError", "[file]", assemblyPrefab.Name), e); } return true; }; @@ -861,7 +861,7 @@ namespace Barotrauma { if (nameBox.Text.Contains(illegalChar)) { - GUI.AddMessage(TextManager.Get("SubNameIllegalCharsWarning").Replace("[illegalchar]", illegalChar.ToString()), Color.Red); + GUI.AddMessage(TextManager.GetWithVariable("SubNameIllegalCharsWarning", "[illegalchar]", illegalChar.ToString()), Color.Red); nameBox.Flash(); return false; } @@ -907,7 +907,7 @@ namespace Barotrauma } Submarine.MainSub.CheckForErrors(); - GUI.AddMessage(TextManager.Get("SubSavedNotification").Replace("[filepath]", Submarine.MainSub.FilePath), Color.Green); + GUI.AddMessage(TextManager.GetWithVariable("SubSavedNotification", "[filepath]", Submarine.MainSub.FilePath), Color.Green); Submarine.RefreshSavedSub(savePath); if (prevSavePath != null && prevSavePath != savePath) @@ -1074,7 +1074,7 @@ namespace Barotrauma { OnClicked = (btn, userdata) => { - OpenFileDialog ofd = new OpenFileDialog() + Barotrauma.OpenFileDialog ofd = new Barotrauma.OpenFileDialog() { InitialDirectory = Path.GetFullPath(Submarine.SavePath), Filter = "PNG file|*.png", @@ -1259,7 +1259,7 @@ namespace Barotrauma { if (nameBox.Text.Contains(illegalChar)) { - GUI.AddMessage(TextManager.Get("ItemAssemblyNameIllegalCharsWarning").Replace("[illegalchar]", illegalChar.ToString()), Color.Red); + GUI.AddMessage(TextManager.GetWithVariable("ItemAssemblyNameIllegalCharsWarning", "[illegalchar]", illegalChar.ToString()), Color.Red); nameBox.Flash(); return false; } diff --git a/Barotrauma/BarotraumaClient/Source/Serialization/SerializableEntityEditor.cs b/Barotrauma/BarotraumaClient/Source/Serialization/SerializableEntityEditor.cs index 2ce6ff0d7..e7bac5c7c 100644 --- a/Barotrauma/BarotraumaClient/Source/Serialization/SerializableEntityEditor.cs +++ b/Barotrauma/BarotraumaClient/Source/Serialization/SerializableEntityEditor.cs @@ -536,12 +536,12 @@ namespace Barotrauma if (translatedText == null) { propertyBox.TextColor = Color.Gray; - propertyBox.ToolTip = TextManager.Get("StringPropertyCannotTranslate").Replace("[tag]", text ?? ""); + propertyBox.ToolTip = TextManager.GetWithVariable("StringPropertyCannotTranslate", "[tag]", text ?? string.Empty); } else { propertyBox.TextColor = Color.LightGreen; - propertyBox.ToolTip = TextManager.Get("StringPropertyTranslate").Replace("[translation]", translatedText); + propertyBox.ToolTip = TextManager.GetWithVariable("StringPropertyTranslate", "[translation]", translatedText); } return true; }; diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index 3466d3dd7..dc6b33c63 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -80,8 +80,8 @@ - - ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.1.1.12\lib\net45\GameAnalytics.Mono.dll + + ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\lib\net45\GameAnalytics.Mono.dll ..\..\Libraries\NuGet\MonoGame.Framework.WindowsDX.3.7.1.189\lib\net45\MonoGame.Framework.dll @@ -132,7 +132,7 @@ - ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.1.1.12\lib\net45\System.Data.SQLite.dll + ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\lib\net45\System.Data.SQLite.dll @@ -306,13 +306,13 @@ - - + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/Barotrauma/BarotraumaClient/packages.config b/Barotrauma/BarotraumaClient/packages.config index d637bffbb..e593ce09a 100644 --- a/Barotrauma/BarotraumaClient/packages.config +++ b/Barotrauma/BarotraumaClient/packages.config @@ -1,6 +1,6 @@  - + diff --git a/Barotrauma/BarotraumaServer/Server.csproj b/Barotrauma/BarotraumaServer/Server.csproj index 99289cacd..6b66b1b69 100644 --- a/Barotrauma/BarotraumaServer/Server.csproj +++ b/Barotrauma/BarotraumaServer/Server.csproj @@ -149,7 +149,13 @@ true + + ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\lib\net45\GameAnalytics.Mono.dll + + + ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\lib\net45\System.Data.SQLite.dll + @@ -163,12 +169,6 @@ ..\..\Libraries\NuGet\NLog.4.3.8\lib\net45\NLog.dll - - ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.1.1.12\lib\net45\GameAnalytics.Mono.dll - - - ..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.1.1.12\lib\net45\System.Data.SQLite.dll - ..\..\Libraries\NuGet\RestSharp.105.2.3\lib\net45\RestSharp.dll @@ -293,5 +293,11 @@ - + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/Barotrauma/BarotraumaServer/Source/GameMain.cs b/Barotrauma/BarotraumaServer/Source/GameMain.cs index 6515b87c6..f97944a3e 100644 --- a/Barotrauma/BarotraumaServer/Source/GameMain.cs +++ b/Barotrauma/BarotraumaServer/Source/GameMain.cs @@ -128,9 +128,7 @@ namespace Barotrauma var exePaths = contentPackage.GetFilesOfType(ContentType.ServerExecutable); if (exePaths.Count() > 0 && AppDomain.CurrentDomain.FriendlyName != exePaths.First()) { - DebugConsole.ShowQuestionPrompt(TextManager.Get("IncorrectExe") - .Replace("[selectedpackage]", contentPackage.Name) - .Replace("[exename]", exePaths.First()), + DebugConsole.ShowQuestionPrompt(TextManager.GetWithVariables("IncorrectExe", new string[2] { "[selectedpackage]", "[exename]" }, new string[2] { contentPackage.Name, exePaths.First() }), (option) => { if (option.ToLower() == "y" || option.ToLower() == "yes") @@ -298,7 +296,7 @@ namespace Barotrauma CloseServer(); SteamManager.ShutDown(); - if (GameSettings.SendUserStatistics) GameAnalytics.OnStop(); + if (GameSettings.SendUserStatistics) GameAnalytics.OnQuit(); } public static void ResetFrameTime() diff --git a/Barotrauma/BarotraumaServer/Source/GameSession/GameModes/TraitorManager.cs b/Barotrauma/BarotraumaServer/Source/GameSession/GameModes/TraitorManager.cs index c275b4a36..3c05f2ef0 100644 --- a/Barotrauma/BarotraumaServer/Source/GameSession/GameModes/TraitorManager.cs +++ b/Barotrauma/BarotraumaServer/Source/GameSession/GameModes/TraitorManager.cs @@ -16,10 +16,9 @@ namespace Barotrauma public void Greet(GameServer server, string codeWords, string codeResponse) { - string greetingMessage = TextManager.Get("TraitorStartMessage").Replace("[targetname]", TargetCharacter.Name); - string moreAgentsMessage = TextManager.Get("TraitorMoreAgentsMessage") - .Replace("[codewords]", codeWords) - .Replace("[coderesponse]", codeResponse); + string greetingMessage = TextManager.GetWithVariable("TraitorStartMessage", "[targetname]", TargetCharacter.Name); + string moreAgentsMessage = TextManager.GetWithVariables("TraitorMoreAgentsMessage", + new string[2] { "[codewords]", "[coderesponse]" }, new string[2] { codeWords, codeResponse }); var greetingChatMsg = ChatMessage.Create(null, greetingMessage, ChatMessageType.Server, null); var moreAgentsChatMsg = ChatMessage.Create(null, moreAgentsMessage, ChatMessageType.Server, null); @@ -38,7 +37,7 @@ namespace Barotrauma { var ownerMsg = ChatMessage.Create( null,//TextManager.Get("NewTraitor"), - TextManager.Get("TraitorStartMessageServer").Replace("[targetname]", TargetCharacter.Name).Replace("[traitorname]", Character.Name), + TextManager.GetWithVariables("TraitorStartMessageServer", new string[2] { "[targetname]", "[traitorname]" }, new string[2] { TargetCharacter.Name, Character.Name }), ChatMessageType.MessageBox, null ); diff --git a/Barotrauma/BarotraumaServer/Source/Items/Item.cs b/Barotrauma/BarotraumaServer/Source/Items/Item.cs index beb831abf..8e29b0a21 100644 --- a/Barotrauma/BarotraumaServer/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaServer/Source/Items/Item.cs @@ -193,7 +193,7 @@ namespace Barotrauma { if (GameMain.Server == null) return; - msg.Write(Prefab.Name); + msg.Write(Prefab.OriginalName); msg.Write(Prefab.Identifier); msg.Write(Description != prefab.Description); if (Description != prefab.Description) diff --git a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs index 48dfceef2..1dbc815cb 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs @@ -415,7 +415,7 @@ namespace Barotrauma.Networking { if (endRoundTimer <= 0.0f) { - SendChatMessage(TextManager.Get("CrewDeadNoRespawns").Replace("[time]", "60"), ChatMessageType.Server); + SendChatMessage(TextManager.GetWithVariable("CrewDeadNoRespawns", "[time]", "60"), ChatMessageType.Server); } endRoundTimer += deltaTime; } @@ -728,7 +728,7 @@ namespace Barotrauma.Networking if (matchingSub == null) { SendDirectChatMessage( - TextManager.Get("CampaignStartFailedSubNotFound").Replace("[subname]", subName), + TextManager.GetWithVariable("CampaignStartFailedSubNotFound", "[subname]", subName), connectedClient, ChatMessageType.MessageBox); } else diff --git a/Barotrauma/BarotraumaServer/Source/Networking/RespawnManager.cs b/Barotrauma/BarotraumaServer/Source/Networking/RespawnManager.cs index 593bec08f..a27e15083 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/RespawnManager.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/RespawnManager.cs @@ -232,7 +232,7 @@ namespace Barotrauma.Networking //add the ID card tags they should've gotten when spawning in the shuttle foreach (Item item in character.Inventory.Items) { - if (item == null || item.Prefab.Name != "ID Card") continue; + if (item == null || item.Prefab.Identifier != "idcard") continue; foreach (string s in shuttleSpawnPoints[i].IdCardTags) { item.AddTag(s); diff --git a/Barotrauma/BarotraumaServer/Source/Networking/SteamManager.cs b/Barotrauma/BarotraumaServer/Source/Networking/SteamManager.cs index c0bbd0c9d..1bc7105a6 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/SteamManager.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/SteamManager.cs @@ -37,7 +37,7 @@ namespace Barotrauma.Steam public static bool RefreshServerDetails(Networking.GameServer server) { - if (instance == null || !instance.isInitialized) + if (instance?.server == null || !instance.isInitialized) { return false; } diff --git a/Barotrauma/BarotraumaServer/Source/Program.cs b/Barotrauma/BarotraumaServer/Source/Program.cs index f58204d7a..01070636e 100644 --- a/Barotrauma/BarotraumaServer/Source/Program.cs +++ b/Barotrauma/BarotraumaServer/Source/Program.cs @@ -35,7 +35,7 @@ namespace Barotrauma inputThread.Start(); game.Run(); inputThread.Abort(); inputThread.Join(); - if (GameSettings.SendUserStatistics) GameAnalytics.OnStop(); + if (GameSettings.SendUserStatistics) GameAnalytics.OnQuit(); SteamManager.ShutDown(); #if !DEBUG } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index e1587cdfc..2f176e100 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -202,22 +202,18 @@ namespace Barotrauma if (run || speedMultiplier <= 0.0f) targetMovement *= speedMultiplier; Character.ResetSpeedMultiplier(); // Reset, items will set the value before the next update Character.AnimController.TargetMovement = targetMovement; - if (!NeedsDivingGear(Character.CurrentHull)) { bool oxygenLow = Character.OxygenAvailable < CharacterHealth.LowOxygenThreshold; bool highPressure = Character.CurrentHull == null || Character.CurrentHull.LethalPressure > 0 && Character.PressureProtection <= 0; bool shouldKeepTheGearOn = !ObjectiveManager.IsCurrentObjective(); - - // Don't allow to drop the diving suit in water or while climbing or if the current path has stairs - bool removeDivingSuit = - (oxygenLow && !highPressure) || - (!shouldKeepTheGearOn && - Character.CurrentHull.WaterPercentage < 1 && - !Character.IsClimbing && - steeringManager == insideSteering && - !PathSteering.InStairs); - + bool removeDivingSuit = oxygenLow && !highPressure; + if (!removeDivingSuit) + { + bool targetHasNoSuit = objectiveManager.CurrentOrder is AIObjectiveGoTo gtObj && gtObj.mimic && !HasDivingSuit(gtObj.Target as Character); + bool canDropTheSuit = Character.CurrentHull.WaterPercentage < 1 && !Character.IsClimbing && steeringManager == insideSteering && !PathSteering.InStairs; + removeDivingSuit = (!shouldKeepTheGearOn || targetHasNoSuit) && canDropTheSuit; + } if (removeDivingSuit) { var divingSuit = Character.Inventory.FindItemByIdentifier("divingsuit") ?? Character.Inventory.FindItemByTag("divingsuit"); @@ -227,7 +223,8 @@ namespace Barotrauma divingSuit.Drop(Character); } } - bool takeMaskOff = oxygenLow || (!shouldKeepTheGearOn && Character.CurrentHull.WaterPercentage < 20); + bool targetHasNoMask = objectiveManager.CurrentOrder is AIObjectiveGoTo gotoObjective && gotoObjective.mimic && !HasDivingMask(gotoObjective.Target as Character); + bool takeMaskOff = oxygenLow || (!shouldKeepTheGearOn && Character.CurrentHull.WaterPercentage < 20) || targetHasNoMask; if (takeMaskOff) { var mask = Character.Inventory.FindItemByIdentifier("divingmask"); @@ -336,7 +333,7 @@ namespace Barotrauma if (AIObjectiveFixLeaks.IsValidTarget(gap, Character)) { AddTargets(Character, gap); - if (newOrder == null) + if (newOrder == null && !gap.IsRoomToRoom) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportbreach"); newOrder = new Order(orderPrefab, hull, null, orderGiver: Character); @@ -384,8 +381,8 @@ namespace Barotrauma } if (Character.PressureTimer > 50.0f && Character.CurrentHull != null) - { - Character.Speak(TextManager.Get("DialogPressure").Replace("[roomname]", Character.CurrentHull.DisplayName), null, 0, "pressure", 30.0f); + { + Character.Speak(TextManager.GetWithVariable("DialogPressure", "[roomname]", Character.CurrentHull.DisplayName, true), null, 0, "pressure", 30.0f); } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs index d60f7926b..b2bccbe4d 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs @@ -110,8 +110,8 @@ namespace Barotrauma move = false; extinguisher.Use(deltaTime, character); if (!targetHull.FireSources.Contains(fs)) - { - character.Speak(TextManager.Get("DialogPutOutFire").Replace("[roomname]", targetHull.Name), null, 0, "putoutfire", 10.0f); + { + character.Speak(TextManager.GetWithVariable("DialogPutOutFire", "[roomname]", targetHull.Name, true), null, 0, "putoutfire", 10.0f); } } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs index 851a0cd01..3cdc8780b 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs @@ -122,9 +122,8 @@ namespace Barotrauma goToObjective = null; } TryAddSubObjective(ref goToObjective, - constructor: () => new AIObjectiveGoTo(currentSafeHull, character, objectiveManager, getDivingGearIfNeeded: false) + constructor: () => new AIObjectiveGoTo(currentSafeHull, character, objectiveManager, getDivingGearIfNeeded: true) { - // If we need diving gear, we should already have it, if possible. AllowGoingOutside = HumanAIController.HasDivingSuit(character) }, onAbandon: () => unreachable.Add(goToObjective.Target as Hull)); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs index 19a21b7ff..ec1e63d2c 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs @@ -234,6 +234,7 @@ namespace Barotrauma switch (order.AITag.ToLowerInvariant()) { case "follow": + if (orderGiver == null) { return null; } newObjective = new AIObjectiveGoTo(orderGiver, character, this, repeat: true, priorityModifier: priorityModifier) { CloseEnough = 150, diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs index d77c798c3..3da532975 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs @@ -60,7 +60,7 @@ namespace Barotrauma ItemComponent target = useController ? controller : component; if (useController && controller == null) { - character.Speak(TextManager.Get("DialogCantFindController").Replace("[item]", component.Item.Name), null, 2.0f, "cantfindcontroller", 30.0f); + character.Speak(TextManager.GetWithVariable("DialogCantFindController", "[item]", component.Item.Name, true), null, 2.0f, "cantfindcontroller", 30.0f); abandon = true; return; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs index a3574b29d..8ddb26d26 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs @@ -44,8 +44,8 @@ namespace Barotrauma { bool isCompleted = Item.IsFullCondition; if (isCompleted) - { - character?.Speak(TextManager.Get("DialogItemRepaired").Replace("[itemname]", Item.Name), null, 0.0f, "itemrepaired", 10.0f); + { + character?.Speak(TextManager.GetWithVariable("DialogItemRepaired", "[itemname]", Item.Name, true), null, 0.0f, "itemrepaired", 10.0f); } return isCompleted; } @@ -140,7 +140,7 @@ namespace Barotrauma { // If the current condition is less than the previous condition, we can't complete the task, so let's abandon it. The item is probably deteriorating at a greater speed than we can repair it. abandon = true; - character?.Speak(TextManager.Get("DialogCannotRepair").Replace("[itemname]", Item.Name), null, 0.0f, "cannotrepair", 10.0f); + character?.Speak(TextManager.GetWithVariable("DialogCannotRepair", "[itemname]", Item.Name, true), null, 0.0f, "cannotrepair", 10.0f); } } repairable.CurrentFixer = abandon && repairable.CurrentFixer == character ? null : character; @@ -161,8 +161,8 @@ namespace Barotrauma objective.CloseEnough = repairTool.Range * 0.75f; } return objective; - }, - onAbandon: () => character.Speak(TextManager.Get("DialogCannotRepair").Replace("[itemname]", Item.Name), null, 0.0f, "cannotrepair", 10.0f)); + }, + onAbandon: () => character.Speak(TextManager.GetWithVariable("DialogCannotRepair", "[itemname]", Item.Name, true), null, 0.0f, "cannotrepair", 10.0f)); } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs index 65c43a1d9..3eff46f3a 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs @@ -57,11 +57,10 @@ namespace Barotrauma if (targetCharacter.IsUnconscious && HumanAIController.GetHullSafety(targetCharacter.CurrentHull, targetCharacter) < HumanAIController.HULL_SAFETY_THRESHOLD) { if (character.SelectedCharacter != targetCharacter) - { - character.Speak(TextManager.Get("DialogFoundUnconsciousTarget") - .Replace("[targetname]", targetCharacter.Name).Replace("[roomname]", targetCharacter.CurrentHull.DisplayName), - null, 1.0f, - "foundunconscioustarget" + targetCharacter.Name, 60.0f); + { + character.Speak(TextManager.GetWithVariables("DialogFoundUnconsciousTarget", new string[2] { "[targetname]", "[roomname]" }, + new string[2] { targetCharacter.Name, targetCharacter.CurrentHull.DisplayName }, new bool[2] { false, true }), + null, 1.0f, "foundunconscioustarget" + targetCharacter.Name, 60.0f); // Go to the target and select it if (!character.CanInteractWith(targetCharacter)) @@ -113,11 +112,10 @@ namespace Barotrauma { // We can start applying treatment if (character.SelectedCharacter != targetCharacter) - { - character.Speak(TextManager.Get("DialogFoundWoundedTarget") - .Replace("[targetname]", targetCharacter.Name).Replace("[roomname]", targetCharacter.CurrentHull.DisplayName), - null, 1.0f, - "foundwoundedtarget" + targetCharacter.Name, 60.0f); + { + character.Speak(TextManager.GetWithVariables("DialogFoundWoundedTarget", new string[2] { "[targetname]", "[roomname]" }, + new string[2] { targetCharacter.Name, targetCharacter.CurrentHull.DisplayName }, new bool[2] { false, true }), + null, 1.0f, "foundwoundedtarget" + targetCharacter.Name, 60.0f); character.SelectCharacter(targetCharacter); } @@ -191,9 +189,10 @@ namespace Barotrauma { itemListStr = string.Join(" or ", string.Join(", ", itemNameList.Take(itemNameList.Count - 1)), itemNameList.Last()); } - character.Speak(TextManager.Get("DialogListRequiredTreatments") - .Replace("[targetname]", targetCharacter.Name) - .Replace("[treatmentlist]", itemListStr), + + + character.Speak(TextManager.GetWithVariables("DialogListRequiredTreatments", new string[2] { "[targetname]", "[treatmentlist]" }, + new string[2] { targetCharacter.Name, itemListStr }, new bool[2] { false, true }), null, 2.0f, "listrequiredtreatments" + targetCharacter.Name, 60.0f); } character.DeselectCharacter(); @@ -235,8 +234,8 @@ namespace Barotrauma bool isCompleted = targetCharacter.Bleeding <= 0 && targetCharacter.Vitality / targetCharacter.MaxVitality > AIObjectiveRescueAll.GetVitalityThreshold(objectiveManager); if (isCompleted) - { - character.Speak(TextManager.Get("DialogTargetHealed").Replace("[targetname]", targetCharacter.Name), + { + character.Speak(TextManager.GetWithVariable("DialogTargetHealed", "[targetname]", targetCharacter.Name), null, 1.0f, "targethealed" + targetCharacter.Name, 60.0f); } return isCompleted || targetCharacter.IsDead; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs index 6391147f5..202310ced 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs @@ -171,12 +171,12 @@ namespace Barotrauma string messageTag = (givingOrderToSelf && !TargetAllCharacters ? "OrderDialogSelf." : "OrderDialog.") + AITag; if (!string.IsNullOrEmpty(orderOption)) messageTag += "." + orderOption; - string msg = TextManager.Get(messageTag, true); + if (targetCharacterName == null) targetCharacterName = ""; + if (targetRoomName == null) targetRoomName = ""; + string msg = TextManager.GetWithVariables(messageTag, new string[2] { "[name]", "[roomname]" }, new string[2] { targetCharacterName, targetRoomName }, new bool[2] { false, true }); if (msg == null) return ""; - if (targetCharacterName == null) targetCharacterName = ""; - if (targetRoomName == null) targetRoomName = ""; - return msg.Replace("[name]", targetCharacterName).Replace("[roomname]", targetRoomName); + return msg; } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Params/Ragdoll/RagdollParams.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Params/Ragdoll/RagdollParams.cs index 0ca685008..cec8bfc44 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Params/Ragdoll/RagdollParams.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Params/Ragdoll/RagdollParams.cs @@ -36,7 +36,8 @@ namespace Barotrauma [Serialize(1.0f, true), Editable(MIN_SCALE, MAX_SCALE, DecimalCount = 3)] public float JointScale { get; set; } - [Serialize(1f, true), Editable(DecimalCount = 2)] + // Don't show in the editor, because shouldn't be edited in runtime. Requires that the limb scale and the collider sizes are adjusted. TODO: automatize. + [Serialize(1f, false)] public float TextureScale { get; set; } [Serialize(45f, true), Editable(0f, 1000f)] diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs index a33207b92..52d84e829 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs @@ -17,6 +17,12 @@ namespace Barotrauma { public abstract RagdollParams RagdollParams { get; protected set; } + const float ImpactDamageMultiplayer = 10.0f; + /// + /// Maximum damage per impact (0.1 = 10% of the character's maximum health) + /// + const float MaxImpactDamage = 0.1f; + private static List list = new List(); protected Hull currentHull; @@ -688,8 +694,10 @@ namespace Barotrauma Vector2 impactPos = ConvertUnits.ToDisplayUnits(points[0]); if (character.Submarine != null) impactPos += character.Submarine.Position; + float impactDamage = Math.Min((impact - ImpactTolerance) * ImpactDamageMultiplayer, character.MaxVitality * MaxImpactDamage); + character.LastDamageSource = null; - character.AddDamage(impactPos, new List() { AfflictionPrefab.InternalDamage.Instantiate((impact - ImpactTolerance) * 10.0f) }, 0.0f, true); + character.AddDamage(impactPos, new List() { AfflictionPrefab.InternalDamage.Instantiate(impactDamage) }, 0.0f, true); strongestImpact = Math.Max(strongestImpact, impact - ImpactTolerance); character.ApplyStatusEffects(ActionType.OnImpact, 1.0f); //briefly disable impact damage @@ -1303,13 +1311,6 @@ namespace Barotrauma } } } - foreach (Limb limb in Limbs) - { - limb.body.SetTransform(Collider.SimPosition, 0.0f); - limb.body.ResetDynamics(); - } - SetInitialLimbPositions(); - return false; } UpdateProjSpecific(deltaTime); } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Health/Afflictions/AfflictionHusk.cs b/Barotrauma/BarotraumaShared/Source/Characters/Health/Afflictions/AfflictionHusk.cs index db7d465b2..234203834 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Health/Afflictions/AfflictionHusk.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Health/Afflictions/AfflictionHusk.cs @@ -217,7 +217,16 @@ namespace Barotrauma limb.body.AngularVelocity = matchingLimb.body.AngularVelocity; } } - for (int i = 0; i < character.Inventory.Items.Length; i++) + + if (character.Inventory.Items.Length != husk.Inventory.Items.Length) + { + string errorMsg = "Failed to move items from a human's inventory into a humanhusk's inventory (inventory sizes don't match)"; + DebugConsole.ThrowError(errorMsg); + GameAnalyticsManager.AddErrorEventOnce("AfflictionHusk.CreateAIHusk:InventoryMismatch", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg); + yield return CoroutineStatus.Success; + } + + for (int i = 0; i < character.Inventory.Items.Length && i < husk.Inventory.Items.Length; i++) { if (character.Inventory.Items[i] == null) continue; husk.Inventory.TryPutItem(character.Inventory.Items[i], i, true, false, null); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs index 4f5769f34..6425a776e 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs @@ -232,13 +232,13 @@ namespace Barotrauma } private LimbHealth GetMatchingLimbHealth(Limb limb) => limbHealths[limb.HealthIndex]; - private LimbHealth GetMathingLimbHealth(Affliction affliction) => GetMatchingLimbHealth(Character.AnimController.GetLimb(affliction.Prefab.IndicatorLimb)); + private LimbHealth GetMatchingLimbHealth(Affliction affliction) => GetMatchingLimbHealth(Character.AnimController.GetLimb(affliction.Prefab.IndicatorLimb)); /// /// Returns the limb afflictions and non-limbspecific afflictions that are set to be displayed on this limb. /// private IEnumerable GetMatchingAfflictions(LimbHealth limb, Func predicate) - => limb.Afflictions.Where(predicate).Union(afflictions.Where(a => predicate(a) && GetMathingLimbHealth(a) == limb)); + => limb.Afflictions.Where(predicate).Union(afflictions.Where(a => predicate(a) && GetMatchingLimbHealth(a) == limb)); public Affliction GetAffliction(string afflictionType, bool allowLimbAfflictions = true) { diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs b/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs index 271dd6dc1..03c92e52e 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs @@ -108,7 +108,7 @@ namespace Barotrauma } #if CLIENT - new GUIMessageBox("", TextManager.Get("CargoSpawnNotification").Replace("[roomname]", cargoRoom.DisplayName)); + new GUIMessageBox("", TextManager.GetWithVariable("CargoSpawnNotification", "[roomname]", cargoRoom.DisplayName, true)); #endif Dictionary availableContainers = new Dictionary(); diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/CampaignMode.cs b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/CampaignMode.cs index d0cd28725..3ddd11311 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/CampaignMode.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/CampaignMode.cs @@ -193,7 +193,7 @@ namespace Barotrauma character.TeamID = Character.TeamType.FriendlyNPC; character.SetCustomInteract( WatchmanInteract, - hudText: TextManager.Get("TalkHint").Replace("[key]", GameMain.Config.KeyBind(InputType.Select).ToString())); + hudText: TextManager.GetWithVariable("TalkHint", "[key]", GameMain.Config.KeyBind(InputType.Select).ToString())); } protected abstract void WatchmanInteract(Character watchman, Character interactor); diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index 0b3f91c9a..26313251a 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -569,14 +569,12 @@ namespace Barotrauma //to make sure the package that contains text files has been loaded before we attempt to use TextManager foreach (string missingPackagePath in missingPackagePaths) { - DebugConsole.ThrowError(TextManager.Get("ContentPackageNotFound").Replace("[packagepath]", missingPackagePath)); + DebugConsole.ThrowError(TextManager.GetWithVariable("ContentPackageNotFound", "[packagepath]", missingPackagePath)); } foreach (ContentPackage incompatiblePackage in incompatiblePackages) { - DebugConsole.ThrowError(TextManager.Get(incompatiblePackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage") - .Replace("[packagename]", incompatiblePackage.Name) - .Replace("[packageversion]", incompatiblePackage.GameVersion.ToString()) - .Replace("[gameversion]", GameMain.Version.ToString())); + DebugConsole.ThrowError(TextManager.GetWithVariables(incompatiblePackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage", + new string[3] { "[packagename]", "[packageversion]", "[gameversion]" }, new string[3] { incompatiblePackage.Name, incompatiblePackage.GameVersion.ToString(), GameMain.Version.ToString() })); } foreach (ContentPackage contentPackage in SelectedContentPackages) { @@ -955,14 +953,12 @@ namespace Barotrauma //to make sure the package that contains text files has been loaded before we attempt to use TextManager foreach (string missingPackagePath in missingPackagePaths) { - DebugConsole.ThrowError(TextManager.Get("ContentPackageNotFound").Replace("[packagepath]", missingPackagePath)); + DebugConsole.ThrowError(TextManager.GetWithVariable("ContentPackageNotFound", "[packagepath]", missingPackagePath)); } foreach (ContentPackage incompatiblePackage in incompatiblePackages) { - DebugConsole.ThrowError(TextManager.Get(incompatiblePackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage") - .Replace("[packagename]", incompatiblePackage.Name) - .Replace("[packageversion]", incompatiblePackage.GameVersion.ToString()) - .Replace("[gameversion]", GameMain.Version.ToString())); + DebugConsole.ThrowError(TextManager.GetWithVariables(incompatiblePackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage", + new string[3] { "[packagename]", "[packageversion]", "[gameversion]" }, new string[3] { incompatiblePackage.Name, incompatiblePackage.GameVersion.ToString(), GameMain.Version.ToString() })); } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs index e39877bdb..681f74534 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs @@ -40,6 +40,9 @@ namespace Barotrauma.Items.Components [Serialize(false, false)] public bool RepairThroughWalls { get; set; } + [Serialize(false, false)] + public bool RepairMultiple { get; set; } + public Vector2 TransformedBarrelPos { get @@ -158,12 +161,22 @@ namespace Barotrauma.Items.Components private void Repair(Vector2 rayStart, Vector2 rayEnd, float deltaTime, Character user, float degreeOfSuccess, List ignoredBodies) { var collisionCategories = Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel | Physics.CollisionRepair; - if (RepairThroughWalls) + if (RepairMultiple) { var bodies = Submarine.PickBodies(rayStart, rayEnd, ignoredBodies, collisionCategories, ignoreSensors: false, allowInsideFixture: true); + Type lastHitType = null; foreach (Body body in bodies) { - FixBody(user, deltaTime, degreeOfSuccess, body); + Type bodyType = body.UserData?.GetType(); + if (!RepairThroughWalls && bodyType != null && bodyType != lastHitType) + { + //stop the ray if it already hit a door/wall and is now about to hit some other type of entity + if (lastHitType == typeof(Item) || lastHitType == typeof(Structure)) { break; } + } + if (FixBody(user, deltaTime, degreeOfSuccess, body)) + { + if (bodyType != null) { lastHitType = bodyType; } + } } } else @@ -202,19 +215,19 @@ namespace Barotrauma.Items.Components } } - private void FixBody(Character user, float deltaTime, float degreeOfSuccess, Body targetBody) + private bool FixBody(Character user, float deltaTime, float degreeOfSuccess, Body targetBody) { - if (targetBody?.UserData == null) { return; } + if (targetBody?.UserData == null) { return false; } pickedPosition = Submarine.LastPickedPosition; if (targetBody.UserData is Structure targetStructure) { - if (!fixableEntities.Contains("structure") && !fixableEntities.Contains(targetStructure.Prefab.Identifier)) return; - if (targetStructure.IsPlatform) return; + if (!fixableEntities.Contains("structure") && !fixableEntities.Contains(targetStructure.Prefab.Identifier)) { return false; } + if (targetStructure.IsPlatform) { return false; } int sectionIndex = targetStructure.FindSectionIndex(ConvertUnits.ToDisplayUnits(pickedPosition)); - if (sectionIndex < 0) return; + if (sectionIndex < 0) { return false; } FixStructureProjSpecific(user, deltaTime, targetStructure, sectionIndex); targetStructure.AddDamage(sectionIndex, -StructureFixAmount * degreeOfSuccess, user); @@ -239,12 +252,14 @@ namespace Barotrauma.Items.Components targetCharacter.LastDamageSource = item; ApplyStatusEffectsOnTarget(user, deltaTime, ActionType.OnUse, new List() { targetCharacter }); FixCharacterProjSpecific(user, deltaTime, targetCharacter); + return true; } else if (targetBody.UserData is Limb targetLimb) { targetLimb.character.LastDamageSource = item; ApplyStatusEffectsOnTarget(user, deltaTime, ActionType.OnUse, new List() { targetLimb.character, targetLimb }); FixCharacterProjSpecific(user, deltaTime, targetLimb.character); + return true; } else if (targetBody.UserData is Item targetItem) { @@ -269,6 +284,7 @@ namespace Barotrauma.Items.Components #endif } FixItemProjSpecific(user, deltaTime, targetItem, prevCondition); + return true; } return false; } @@ -380,11 +396,12 @@ namespace Barotrauma.Items.Components sinTime = 0; if (!leak.FlowTargetHull.ConnectedGaps.Any(g => !g.IsRoomToRoom && g.Open > 0.0f)) { - character.Speak(TextManager.Get("DialogLeaksFixed").Replace("[roomname]", leak.FlowTargetHull.DisplayName), null, 0.0f, "leaksfixed", 10.0f); + + character.Speak(TextManager.GetWithVariable("DialogLeaksFixed", "[roomname]", leak.FlowTargetHull.DisplayName, true), null, 0.0f, "leaksfixed", 10.0f); } else { - character.Speak(TextManager.Get("DialogLeakFixed").Replace("[roomname]", leak.FlowTargetHull.DisplayName), null, 0.0f, "leakfixed", 10.0f); + character.Speak(TextManager.GetWithVariable("DialogLeakFixed", "[roomname]", leak.FlowTargetHull.DisplayName, true), null, 0.0f, "leakfixed", 10.0f); } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Sonar.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Sonar.cs index c18e1ad02..539ba0aac 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Sonar.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Sonar.cs @@ -219,8 +219,10 @@ namespace Barotrauma.Items.Components { dialogTag = "DialogSonarTargetLarge"; } - character.Speak(TextManager.Get(dialogTag).Replace("[direction]", targetGroup.Key).Replace("[count]", targetGroup.Value.Count.ToString()), - null, 0, "sonartarget" + targetGroup.Value[0].ID, 30); + + character.Speak(TextManager.GetWithVariables(dialogTag, new string[2] { "[direction]", "[count]" }, + new string[2] { targetGroup.Key.ToString(), targetGroup.Value.Count.ToString() }, + new bool[2] { true, false }), null, 0, "sonartarget" + targetGroup.Value[0].ID, 30); //prevent the character from reporting other targets in the group for (int i = 1; i < targetGroup.Value.Count; i++) @@ -239,7 +241,7 @@ namespace Barotrauma.Items.Components int clockDir = (int)Math.Round((angle / MathHelper.TwoPi) * 12); if (clockDir == 0) clockDir = 12; - return TextManager.Get("roomname.subdiroclock").Replace("[dir]", clockDir.ToString()); + return TextManager.GetWithVariable("roomname.subdiroclock", "[dir]", clockDir.ToString()); } private Vector2 GetTransducerPos() diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerContainer.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerContainer.cs index f411cf341..f74e81242 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerContainer.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerContainer.cs @@ -244,9 +244,10 @@ namespace Barotrauma.Items.Components #if CLIENT rechargeSpeedSlider.BarScroll = RechargeSpeed / Math.Max(maxRechargeSpeed, 1.0f); #endif - character.Speak(TextManager.Get("DialogChargeBatteries") - .Replace("[itemname]", item.Name) - .Replace("[rate]", ((int)(rechargeSpeed / maxRechargeSpeed * 100.0f)).ToString()), null, 1.0f, "chargebattery", 10.0f); + + character.Speak(TextManager.GetWithVariables("DialogChargeBatteries", new string[2] { "[itemname]", "[rate]" }, + new string[2] { item.Name, ((int)(rechargeSpeed / maxRechargeSpeed * 100.0f)).ToString() }, + new bool[2] { true, false }), null, 1.0f, "chargebattery", 10.0f); } } else @@ -260,9 +261,9 @@ namespace Barotrauma.Items.Components #if CLIENT rechargeSpeedSlider.BarScroll = RechargeSpeed / Math.Max(maxRechargeSpeed, 1.0f); #endif - character.Speak(TextManager.Get("DialogStopChargingBatteries") - .Replace("[itemname]", item.Name) - .Replace("[rate]", ((int)(rechargeSpeed / maxRechargeSpeed * 100.0f)).ToString()), null, 1.0f, "chargebattery", 10.0f); + character.Speak(TextManager.GetWithVariables("DialogStopChargingBatteries", new string[2] { "[itemname]", "[rate]" }, + new string[2] { item.Name, ((int)(rechargeSpeed / maxRechargeSpeed * 100.0f)).ToString() }, + new bool[2] { true, false }), null, 1.0f, "chargebattery", 10.0f); } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Turret.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Turret.cs index b8b1ce152..e839e8c8b 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Turret.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Turret.cs @@ -459,7 +459,7 @@ namespace Barotrauma.Items.Components } var containShellObjective = new AIObjectiveContainItem(character, container.ContainableItems[0].Identifiers[0], container, objective.objectiveManager); - character?.Speak(TextManager.Get("DialogLoadTurret").Replace("[itemname]", item.Name), null, 0.0f, "loadturret", 30.0f); + character?.Speak(TextManager.GetWithVariable("DialogLoadTurret", "[itemname]", item.Name, true), null, 0.0f, "loadturret", 30.0f); containShellObjective.targetItemCount = usableProjectileCount + 1; containShellObjective.ignoredContainerIdentifiers = new string[] { containerItem.prefab.Identifier }; objective.AddSubObjective(containShellObjective); @@ -506,7 +506,7 @@ namespace Barotrauma.Items.Components if (objective.Option.ToLowerInvariant() == "fireatwill") { - character?.Speak(TextManager.Get("DialogFireTurret").Replace("[itemname]", item.Name), null, 0.0f, "fireturret", 5.0f); + character?.Speak(TextManager.GetWithVariable("DialogFireTurret", "[itemname]", item.Name, true), null, 0.0f, "fireturret", 5.0f); character.SetInput(InputType.Shoot, true, true); } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index da2ae77e2..752d3df85 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1539,9 +1539,8 @@ namespace Barotrauma { if (requiredSkill != null) { - GUI.AddMessage(TextManager.Get("InsufficientSkills") - .Replace("[requiredskill]", TextManager.Get("SkillName." + requiredSkill.Identifier)) - .Replace("[requiredlevel]", ((int)requiredSkill.Level).ToString()), Color.Red); + GUI.AddMessage(TextManager.GetWithVariables("InsufficientSkills", new string[2] { "[requiredskill]", "[requiredlevel]" }, + new string[2] { TextManager.Get("SkillName." + requiredSkill.Identifier), ((int)requiredSkill.Level).ToString() }, new bool[2] { true, false }), Color.Red); } } #endif @@ -2033,8 +2032,8 @@ namespace Barotrauma XElement element = new XElement("Item"); element.Add( - new XAttribute("name", prefab.Name), - new XAttribute("identifier", prefab.Identifier), + new XAttribute("name", Prefab.OriginalName), + new XAttribute("identifier", Prefab.Identifier), new XAttribute("ID", ID)); if (FlippedX) element.Add(new XAttribute("flippedx", true)); diff --git a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs index 15f3074a6..39c924710 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs @@ -145,6 +145,11 @@ namespace Barotrauma private List fabricationRecipeElements = new List(); + /// + /// Original, non-translated name as defined in the xml + /// + public readonly string OriginalName; + public string ConfigFile { get { return configFile; } @@ -440,7 +445,7 @@ namespace Barotrauma configFile = filePath; ConfigElement = element; - string nonTranslatedName = element.GetAttributeString("name", ""); + OriginalName = element.GetAttributeString("name", ""); identifier = element.GetAttributeString("identifier", ""); //nameidentifier can be used to make multiple items use the same names and descriptions @@ -448,11 +453,11 @@ namespace Barotrauma if (string.IsNullOrEmpty(nameIdentifier)) { - name = TextManager.Get("EntityName." + identifier, true) ?? nonTranslatedName; + name = TextManager.Get("EntityName." + identifier, true) ?? OriginalName; } else { - name = TextManager.Get("EntityName." + nameIdentifier, true) ?? nonTranslatedName; + name = TextManager.Get("EntityName." + nameIdentifier, true) ?? OriginalName; } if (name == "") { DebugConsole.ThrowError("Unnamed item in " + filePath + "!"); } @@ -462,7 +467,7 @@ namespace Barotrauma Aliases = new HashSet (element.GetAttributeStringArray("aliases", null, convertToLowerInvariant: true) ?? element.GetAttributeStringArray("Aliases", new string[0], convertToLowerInvariant: true)); - Aliases.Add(nonTranslatedName.ToLowerInvariant()); + Aliases.Add(OriginalName.ToLowerInvariant()); if (!Enum.TryParse(element.GetAttributeString("category", "Misc"), true, out MapEntityCategory category)) { diff --git a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs index f9620770f..2cb8f3192 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs @@ -730,7 +730,15 @@ namespace Barotrauma return closestBody; } - public static List PickBodies(Vector2 rayStart, Vector2 rayEnd, IEnumerable ignoredBodies = null, Category? collisionCategory = null, bool ignoreSensors = true, Predicate customPredicate = null, bool allowInsideFixture = false) + private static readonly Dictionary bodyDist = new Dictionary(); + private static readonly List bodies = new List(); + + /// + /// Returns a list of physics bodies the ray intersects with, sorted according to distance (the closest body is at the beginning of the list). + /// + /// Can be used to filter the bodies based on some condition. If the predicate returns false, the body isignored. + /// Should fixtures that the start of the ray is inside be returned + public static IEnumerable PickBodies(Vector2 rayStart, Vector2 rayEnd, IEnumerable ignoredBodies = null, Category? collisionCategory = null, bool ignoreSensors = true, Predicate customPredicate = null, bool allowInsideFixture = false) { if (Vector2.DistanceSquared(rayStart, rayEnd) < 0.00001f) { @@ -738,20 +746,25 @@ namespace Barotrauma } float closestFraction = 1.0f; - List bodies = new List(); + bodies.Clear(); + bodyDist.Clear(); GameMain.World.RayCast((fixture, point, normal, fraction) => { if (!CheckFixtureCollision(fixture, ignoredBodies, collisionCategory, ignoreSensors, customPredicate)) { return -1; } - if (fixture.Body != null) { bodies.Add(fixture.Body); } + if (fixture.Body != null) + { + bodies.Add(fixture.Body); + bodyDist[fixture.Body] = fraction; + } if (fraction < closestFraction) { lastPickedPosition = rayStart + (rayEnd - rayStart) * fraction; lastPickedFraction = fraction; lastPickedNormal = normal; } - - return fraction; + //continue + return -1; }, rayStart, rayEnd); if (allowInsideFixture) @@ -770,10 +783,12 @@ namespace Barotrauma lastPickedFraction = 0.0f; lastPickedNormal = Vector2.Normalize(rayEnd - rayStart); bodies.Add(fixture.Body); + bodyDist[fixture.Body] = 0.0f; return false; }, ref aabb); } + bodies.Sort((b1, b2) => { return bodyDist[b1].CompareTo(bodyDist[b2]); }); return bodies; } diff --git a/Barotrauma/BarotraumaShared/Source/Networking/ServerSettings.cs b/Barotrauma/BarotraumaShared/Source/Networking/ServerSettings.cs index 5dd5f1546..01ccc1c0e 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/ServerSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/ServerSettings.cs @@ -656,7 +656,7 @@ namespace Barotrauma.Networking private set; } = new List>(); - public void ReadMonsterEnabled(NetBuffer inc) + private void InitMonstersEnabled() { //monster spawn settings if (MonsterEnabled == null) @@ -673,7 +673,11 @@ namespace Barotrauma.Networking if (!MonsterEnabled.ContainsKey(s)) MonsterEnabled.Add(s, true); } } + } + public void ReadMonsterEnabled(NetBuffer inc) + { + InitMonstersEnabled(); List monsterNames = MonsterEnabled.Keys.ToList(); foreach (string s in monsterNames) { @@ -681,7 +685,7 @@ namespace Barotrauma.Networking } inc.ReadPadBits(); } - + public void WriteMonsterEnabled(NetBuffer msg, Dictionary monsterEnabled = null) { //monster spawn settings @@ -703,13 +707,17 @@ namespace Barotrauma.Networking Dictionary extraCargo = new Dictionary(); for (int i = 0; i < count; i++) { + string prefabIdentifier = msg.ReadString(); string prefabName = msg.ReadString(); byte amount = msg.ReadByte(); - ItemPrefab ip = MapEntityPrefab.List.Find(p => p is ItemPrefab && p.Name.Equals(prefabName, StringComparison.InvariantCulture)) as ItemPrefab; - if (ip != null && amount > 0) + + var itemPrefab = string.IsNullOrEmpty(prefabIdentifier) ? + MapEntityPrefab.Find(prefabName, null, showErrorMessages: false) as ItemPrefab : + MapEntityPrefab.Find(prefabName, prefabIdentifier, showErrorMessages: false) as ItemPrefab; + if (itemPrefab != null && amount > 0) { - if (changed || !ExtraCargo.ContainsKey(ip) || ExtraCargo[ip] != amount) changed = true; - extraCargo.Add(ip, amount); + if (changed || !ExtraCargo.ContainsKey(itemPrefab) || ExtraCargo[itemPrefab] != amount) changed = true; + extraCargo.Add(itemPrefab, amount); } } if (changed) ExtraCargo = extraCargo; @@ -727,7 +735,9 @@ namespace Barotrauma.Networking msg.Write((UInt32)ExtraCargo.Count); foreach (KeyValuePair kvp in ExtraCargo) { - msg.Write(kvp.Key.Name); msg.Write((byte)kvp.Value); + msg.Write(kvp.Key.Identifier ?? ""); + msg.Write(kvp.Key.OriginalName ?? ""); + msg.Write((byte)kvp.Value); } } } diff --git a/Barotrauma/BarotraumaShared/Source/TextManager.cs b/Barotrauma/BarotraumaShared/Source/TextManager.cs index 60ff00a43..5091040a0 100644 --- a/Barotrauma/BarotraumaShared/Source/TextManager.cs +++ b/Barotrauma/BarotraumaShared/Source/TextManager.cs @@ -176,6 +176,107 @@ namespace Barotrauma } } + public static string GetWithVariables(string textTag, string[] variableTags, string[] variableValues, bool[] formatCapitals = null, bool returnNull = false, string fallBackTag = null) + { + string text = Get(textTag, returnNull, fallBackTag); + + if (text == null || text.Length == 0 || variableTags.Length != variableValues.Length) + { +#if DEBUG + if (variableTags.Length != variableValues.Length) + { + DebugConsole.ThrowError("variableTags.Length and variableValues.Length do not match for \"" + textTag + "\"."); + } + + if (formatCapitals != null && formatCapitals.Length != variableTags.Length) + { + DebugConsole.ThrowError("variableTags.Length and formatCapitals.Length do not match for \"" + textTag + "\"."); + } +#endif + if (returnNull) + { + return null; + } + else + { + return textTag; + } + } + + if (formatCapitals != null && !GameMain.Config.Language.Contains("Chinese")) + { + for (int i = 0; i < variableTags.Length; i++) + { + if (formatCapitals[i]) + { + variableValues[i] = HandleVariableCapitalization(text, variableTags[i], variableValues[i]); + } + } + } + + for (int i = 0; i < variableTags.Length; i++) + { + text = text.Replace(variableTags[i], variableValues[i]); + } + + return text; + } + + public static string GetWithVariable(string textTag, string variableTag, string variableValue, bool formatCapitals = false, bool returnNull = false, string fallBackTag = null) + { + string text = Get(textTag, returnNull, fallBackTag); + + if (text == null || text.Length == 0) + { + if (returnNull) + { + return null; + } + else + { + return textTag; + } + } + + if (formatCapitals && !GameMain.Config.Language.Contains("Chinese")) + { + variableValue = HandleVariableCapitalization(text, variableTag, variableValue); + } + + return text.Replace(variableTag, variableValue); + } + + private static string HandleVariableCapitalization(string text, string variableTag, string variableValue) + { + int index = text.IndexOf(variableTag) - 1; + if (index == -1) + { + return variableValue; + } + + for (int i = index; i >= 0; i--) + { + if (text[i] == ' ') + { + continue; + } + else + { + if (text[i] != '.') + { + variableValue = variableValue.ToLower(); + } + else + { + variableValue = Capitalize(variableValue); + break; + } + } + } + + return variableValue; + } + public static string ParseInputTypes(string text) { foreach (InputType inputType in Enum.GetValues(typeof(InputType))) diff --git a/Barotrauma/BarotraumaShared/Submarines/Remora.sub b/Barotrauma/BarotraumaShared/Submarines/Remora.sub index 6e3afa65c..26d37bd22 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Remora.sub and b/Barotrauma/BarotraumaShared/Submarines/Remora.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/RemoraDrone.sub b/Barotrauma/BarotraumaShared/Submarines/RemoraDrone.sub index ec48ad330..49ade4d29 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/RemoraDrone.sub and b/Barotrauma/BarotraumaShared/Submarines/RemoraDrone.sub differ