Changes to settings/contentpackage exception handling

This commit is contained in:
Regalis11
2015-08-12 19:35:43 +03:00
parent 5771bc7e02
commit b2d6548fce
3 changed files with 21 additions and 31 deletions
+18 -12
View File
@@ -45,23 +45,30 @@ namespace Subsurface
public void Load(string filePath)
{
XDocument doc = ToolBox.TryLoadXml(filePath);
try
{
XElement graphicsMode = doc.Root.Element("graphicsmode");
GraphicsWidth = int.Parse(graphicsMode.Attribute("width").Value);
GraphicsHeight = int.Parse(graphicsMode.Attribute("height").Value);
FullScreenEnabled = graphicsMode.Attribute("fullscreen").Value == "true";
}
catch
if (doc == null)
{
DebugConsole.ThrowError("No config file found");
GraphicsWidth = 1024;
GraphicsHeight = 768;
GraphicsHeight = 678;
MasterServerUrl = "";
SelectedContentPackage = new ContentPackage("");
return;
}
XElement graphicsMode = doc.Root.Element("graphicsmode");
GraphicsWidth = int.Parse(graphicsMode.Attribute("width").Value);
GraphicsHeight = int.Parse(graphicsMode.Attribute("height").Value);
FullScreenEnabled = graphicsMode.Attribute("fullscreen").Value == "true";
MasterServerUrl = ToolBox.GetAttributeString(doc.Root, "masterserverurl", "");
foreach (XElement subElement in doc.Root.Elements())
{
switch (subElement.Name.ToString().ToLower())
@@ -73,8 +80,7 @@ namespace Subsurface
if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path);
break;
}
}
}
}
public void Save(string filePath)