diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs index 105f3f32f..cc32e819a 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs @@ -12,6 +12,10 @@ namespace Barotrauma private XElement configElement; + private GraphicsDevice graphicsDevice; + + private ScalableFont defaultFont; + public ScalableFont Font { get; private set; } public ScalableFont SmallFont { get; private set; } public ScalableFont LargeFont { get; private set; } @@ -27,6 +31,7 @@ namespace Barotrauma public GUIStyle(string file, GraphicsDevice graphicsDevice) { + this.graphicsDevice = graphicsDevice; componentStyles = new Dictionary(); GameMain.Instance.OnResolutionChanged += () => { RescaleFonts(); }; @@ -82,6 +87,26 @@ namespace Barotrauma } } + /// + /// Returns the default font of the currently selected language + /// + public ScalableFont LoadCurrentDefaultFont() + { + defaultFont?.Dispose(); + defaultFont = null; + foreach (XElement subElement in configElement.Elements()) + { + switch (subElement.Name.ToString().ToLowerInvariant()) + { + case "font": + defaultFont = LoadFont(subElement, graphicsDevice); + break; + } + } + return defaultFont; + } + + private void RescaleFonts() { foreach (XElement subElement in configElement.Elements()) diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs index 017a3e7e9..8658a7ba1 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs @@ -139,12 +139,16 @@ namespace Barotrauma { string newLanguage = obj as string; if (newLanguage == Language) return true; - - UnsavedSettings = true; + Language = newLanguage; ApplySettings(); - new GUIMessageBox(TextManager.Get("RestartRequiredLabel"), TextManager.Get("RestartRequiredLanguage")); + var msgBox = new GUIMessageBox(TextManager.Get("RestartRequiredLabel"), TextManager.Get("RestartRequiredLanguage")); + //change fonts to the default font of the new language to make sure + //they can be displayed when for example changing from English to Chinese + var defaultFont = GUI.Style.LoadCurrentDefaultFont(); + msgBox.Header.Font = defaultFont; + msgBox.Text.Font = defaultFont; return true; };