2019-05-17 12:08:06 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Xml;
|
2019-02-01 17:19:20 +00:00
|
|
|
|
using RobloxFiles.DataTypes;
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
2019-02-01 17:19:20 +00:00
|
|
|
|
namespace RobloxFiles.XmlFormat.PropertyTokens
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
|
|
|
|
public class UDim2Token : IXmlPropertyToken
|
|
|
|
|
{
|
|
|
|
|
public string Token => "UDim2";
|
|
|
|
|
|
2019-05-17 12:08:06 +00:00
|
|
|
|
public bool ReadProperty(Property property, XmlNode token)
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
UDim xUDim = UDimToken.ReadUDim(token, "X");
|
|
|
|
|
UDim yUDim = UDimToken.ReadUDim(token, "Y");
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
2019-02-01 18:40:39 +00:00
|
|
|
|
if (xUDim != null && yUDim != null)
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
|
|
|
|
property.Type = PropertyType.UDim2;
|
2019-02-01 18:40:39 +00:00
|
|
|
|
property.Value = new UDim2(xUDim, yUDim);
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-05-17 12:08:06 +00:00
|
|
|
|
|
|
|
|
|
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
|
|
|
|
|
{
|
2019-06-30 22:01:19 +00:00
|
|
|
|
UDim2 value = prop.CastValue<UDim2>();
|
2019-05-17 12:08:06 +00:00
|
|
|
|
|
|
|
|
|
UDim xUDim = value.X;
|
|
|
|
|
UDimToken.WriteUDim(doc, node, xUDim, "X");
|
|
|
|
|
|
|
|
|
|
UDim yUDim = value.Y;
|
|
|
|
|
UDimToken.WriteUDim(doc, node, yUDim, "Y");
|
|
|
|
|
}
|
2019-01-30 06:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|