2019-01-30 06:36:56 +00:00
|
|
|
|
using System.Xml;
|
|
|
|
|
using Roblox.DataTypes;
|
|
|
|
|
|
|
|
|
|
namespace Roblox.XmlFormat.PropertyTokens
|
|
|
|
|
{
|
|
|
|
|
public class UDimToken : IXmlPropertyToken
|
|
|
|
|
{
|
|
|
|
|
public string Token => "UDim";
|
|
|
|
|
|
|
|
|
|
public static UDim? ReadUDim(XmlNode token, string prefix = "")
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
XmlElement scaleToken = token[prefix + 'S'];
|
|
|
|
|
float scale = XmlPropertyTokens.ParseFloat(scaleToken.InnerText);
|
|
|
|
|
|
|
|
|
|
XmlElement offsetToken = token[prefix + 'O'];
|
|
|
|
|
int offset = int.Parse(offsetToken.InnerText);
|
|
|
|
|
|
|
|
|
|
return new UDim(scale, offset);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ReadToken(Property property, XmlNode token)
|
|
|
|
|
{
|
|
|
|
|
UDim? result = ReadUDim(token);
|
2019-02-01 16:15:55 +00:00
|
|
|
|
bool success = result.HasValue;
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
|
{
|
|
|
|
|
property.Type = PropertyType.UDim;
|
2019-02-01 16:15:55 +00:00
|
|
|
|
property.Value = result.Value;
|
2019-01-30 06:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|