2f107db...5202af9

This commit is contained in:
Joonas Rikkonen
2019-03-18 21:42:26 +02:00
parent 58c92888b7
commit 044fd3344b
395 changed files with 27417 additions and 19754 deletions
@@ -38,6 +38,21 @@ namespace Barotrauma
return doc;
}
public static XDocument LoadXml(string filePath)
{
XDocument doc = null;
ToolBox.IsProperFilenameCase(filePath);
if (File.Exists(filePath))
{
doc = XDocument.Load(filePath, LoadOptions.SetBaseUri);
if (doc.Root == null) return null;
}
return doc;
}
public static object GetAttributeObject(XAttribute attribute)
{
if (attribute == null) return null;
@@ -222,6 +237,24 @@ namespace Barotrauma
return val;
}
public static uint GetAttributeUInt(this XElement element, string name, uint defaultValue)
{
if (element?.Attribute(name) == null) return defaultValue;
uint val = defaultValue;
try
{
val = UInt32.Parse(element.Attribute(name).Value);
}
catch (Exception e)
{
DebugConsole.ThrowError("Error in " + element + "! ", e);
}
return val;
}
public static int[] GetAttributeIntArray(this XElement element, string name, int[] defaultValue)
{
if (element?.Attribute(name) == null) return defaultValue;