Unstable 0.1500.5.0 (almost forgor edition 💀)
This commit is contained in:
@@ -146,6 +146,7 @@ namespace Barotrauma
|
||||
{ typeof(Vector4), "vector4" },
|
||||
{ typeof(Rectangle), "rectangle" },
|
||||
{ typeof(Color), "color" },
|
||||
{ typeof(string[]), "stringarray" }
|
||||
};
|
||||
|
||||
private static readonly Dictionary<Type, Dictionary<string, SerializableProperty>> cachedProperties =
|
||||
@@ -273,6 +274,9 @@ namespace Barotrauma
|
||||
case "rectangle":
|
||||
PropertyInfo.SetValue(parentObject, XMLExtensions.ParseRect(value, true));
|
||||
break;
|
||||
case "stringarray":
|
||||
PropertyInfo.SetValue(parentObject, XMLExtensions.ParseStringArray(value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,6 +349,9 @@ namespace Barotrauma
|
||||
case "rectangle":
|
||||
PropertyInfo.SetValue(parentObject, XMLExtensions.ParseRect((string)value, false));
|
||||
return true;
|
||||
case "stringarray":
|
||||
PropertyInfo.SetValue(parentObject, XMLExtensions.ParseStringArray((string)value));
|
||||
break;
|
||||
default:
|
||||
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + parentObject.ToString() + "\" to " + value.ToString());
|
||||
DebugConsole.ThrowError("(Cannot convert a string to a " + PropertyType.ToString() + ")");
|
||||
@@ -723,6 +730,10 @@ namespace Barotrauma
|
||||
case "rectangle":
|
||||
stringValue = XMLExtensions.RectToString((Rectangle)value);
|
||||
break;
|
||||
case "stringarray":
|
||||
string[] stringArray = (string[])value;
|
||||
stringValue = stringArray != null ? string.Join(';', stringArray) : "";
|
||||
break;
|
||||
default:
|
||||
stringValue = value.ToString();
|
||||
break;
|
||||
|
||||
@@ -520,10 +520,12 @@ namespace Barotrauma
|
||||
vector.W.ToString(format, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
[Obsolete("Prefer XMLExtensions.ToStringHex")]
|
||||
public static string ColorToString(Color color)
|
||||
{
|
||||
return color.R + "," + color.G + "," + color.B + "," + color.A;
|
||||
}
|
||||
=> $"{color.R},{color.G},{color.B},{color.A}";
|
||||
|
||||
public static string ToStringHex(this Color color)
|
||||
=> $"#{color.R:X2}{color.G:X2}{color.B:X2}{color.A:X2}";
|
||||
|
||||
public static string RectToString(Rectangle rect)
|
||||
{
|
||||
@@ -718,6 +720,11 @@ namespace Barotrauma
|
||||
return floatArray;
|
||||
}
|
||||
|
||||
public static string[] ParseStringArray(string stringArrayValues)
|
||||
{
|
||||
return string.IsNullOrEmpty(stringArrayValues) ? new string[0] : stringArrayValues.Split(';');
|
||||
}
|
||||
|
||||
public static bool IsOverride(this XElement element) => element.Name.ToString().Equals("override", StringComparison.OrdinalIgnoreCase);
|
||||
public static bool IsCharacterVariant(this XElement element) => element.Name.ToString().Equals("charactervariant", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user