From 3d57999f2df3a2e347ddb48ac7353d0c905d0c15 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 11 Jun 2019 21:47:35 +0300 Subject: [PATCH] (2246b239b) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev --- Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs index 780264181..26fe1031b 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs @@ -40,6 +40,9 @@ namespace Barotrauma { ToolBox.IsProperFilenameCase(file); doc = XDocument.Load(file, LoadOptions.SetBaseUri); + if (doc == null) { throw new Exception("doc is null"); } + if (doc.Root == null) { throw new Exception("doc.Root is null"); } + if (doc.Root.Elements() == null) { throw new Exception("doc.Root.Elements() is null"); } } catch (Exception e) { @@ -113,26 +116,34 @@ namespace Barotrauma private void RescaleFonts() { + if (configElement == null) { return; } + if (configElement.Elements() == null) { return; } foreach (XElement subElement in configElement.Elements()) { 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; }