2f107db...5202af9
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user