(e6b42e134) Display the "language changed, restart required" message box using the default font for the selected language
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user