(e6b42e134) Display the "language changed, restart required" message box using the default font for the selected language

This commit is contained in:
Joonas Rikkonen
2019-05-07 16:21:15 +03:00
parent d6c05ab062
commit 02236f65c5
2 changed files with 32 additions and 3 deletions

View File

@@ -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<string, GUIComponentStyle>();
GameMain.Instance.OnResolutionChanged += () => { RescaleFonts(); };
@@ -82,6 +87,26 @@ namespace Barotrauma
}
}
/// <summary>
/// Returns the default font of the currently selected language
/// </summary>
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())

View File

@@ -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;
};