diff --git a/DataTypes/Content.cs b/DataTypes/Content.cs index 4923be4..51536d2 100644 --- a/DataTypes/Content.cs +++ b/DataTypes/Content.cs @@ -6,27 +6,26 @@ /// public class Content { - // TODO: Maybe introduce constraints to the value? - public readonly string Data; + public readonly string Url; public override string ToString() { - return Data; + return Url; } - public Content(string data) + public Content(string url) { - Data = data; + Url = url; } public static implicit operator string(Content content) { - return content.Data; + return content.Url; } - public static implicit operator Content(string data) + public static implicit operator Content(string url) { - return new Content(data); + return new Content(url); } } } diff --git a/DataTypes/ProtectedString.cs b/DataTypes/ProtectedString.cs index de6e8cd..89b1197 100644 --- a/DataTypes/ProtectedString.cs +++ b/DataTypes/ProtectedString.cs @@ -6,21 +6,21 @@ /// public class ProtectedString { - public readonly string Value; + public readonly string ProtectedValue; public override string ToString() { - return Value; + return ProtectedValue; } public ProtectedString(string value) { - Value = value; + ProtectedValue = value; } public static implicit operator string(ProtectedString protectedString) { - return protectedString.Value; + return protectedString.ProtectedValue; } public static implicit operator ProtectedString(string value) diff --git a/DataTypes/Quaternion.cs b/DataTypes/Quaternion.cs index a6f9cce..722ce35 100644 --- a/DataTypes/Quaternion.cs +++ b/DataTypes/Quaternion.cs @@ -21,6 +21,11 @@ namespace RobloxFiles.DataTypes } } + public override string ToString() + { + return string.Join(", ", X, Y, Z, W); + } + public Quaternion(float x, float y, float z, float w) { X = x; diff --git a/Generated/Classes.cs b/Generated/Classes.cs index e73a65e..7bf4858 100644 --- a/Generated/Classes.cs +++ b/Generated/Classes.cs @@ -1786,6 +1786,7 @@ namespace RobloxFiles public abstract class LuaSourceContainer : Instance { + public string ScriptGuid = ""; } public abstract class BaseScript : LuaSourceContainer diff --git a/Plugins/GenerateApiDump.rbxm b/Plugins/GenerateApiDump.rbxm index 1c77ae3..3c57b8a 100644 Binary files a/Plugins/GenerateApiDump.rbxm and b/Plugins/GenerateApiDump.rbxm differ diff --git a/Plugins/GenerateApiDump/PropertyPatches.lua b/Plugins/GenerateApiDump/PropertyPatches.lua index 8448786..3fc6e8b 100644 --- a/Plugins/GenerateApiDump/PropertyPatches.lua +++ b/Plugins/GenerateApiDump/PropertyPatches.lua @@ -348,6 +348,12 @@ return } }; + LuaSourceContainer = + { + Add = { ScriptGuid = "string" }; + Defaults = { ScriptGuid = "" }; + }; + ManualSurfaceJointInstance = { Add = diff --git a/Tree/Instance.cs b/Tree/Instance.cs index 0f05af7..99389df 100644 --- a/Tree/Instance.cs +++ b/Tree/Instance.cs @@ -459,7 +459,14 @@ namespace RobloxFiles if (field.GetCustomAttribute() != null) continue; - if (Property.Types.ContainsKey(fieldType)) + PropertyType propType = PropertyType.Unknown; + + if (fieldType.IsEnum) + propType = PropertyType.Enum; + else if (Property.Types.ContainsKey(fieldType)) + propType = Property.Types[fieldType]; + + if (propType != PropertyType.Unknown) { if (fieldName.EndsWith("_")) fieldName = instType.Name; @@ -468,9 +475,9 @@ namespace RobloxFiles { Property newProp = new Property() { - Type = Property.Types[fieldType], Value = field.GetValue(this), Name = fieldName, + Type = propType, Instance = this }; @@ -480,7 +487,7 @@ namespace RobloxFiles { Property prop = props[fieldName]; prop.Value = field.GetValue(this); - prop.Type = Property.Types[fieldType]; + prop.Type = propType; } } } diff --git a/Tree/Property.cs b/Tree/Property.cs index 718ddde..2ec6a5c 100644 --- a/Tree/Property.cs +++ b/Tree/Property.cs @@ -43,13 +43,13 @@ namespace RobloxFiles public class Property { - public string Name; + public string Name { get; internal set; } public Instance Instance { get; internal set; } - public PropertyType Type; + public PropertyType Type { get; internal set; } - public string XmlToken = ""; - public byte[] RawBuffer; + public string XmlToken { get; internal set; } + public byte[] RawBuffer { get; internal set; } internal object RawValue; internal BinaryRobloxFileWriter CurrentWriter; @@ -74,16 +74,20 @@ namespace RobloxFiles { typeof(UDim2), PropertyType.UDim2 }, { typeof(CFrame), PropertyType.CFrame }, { typeof(Color3), PropertyType.Color3 }, + { typeof(Content), PropertyType.String }, { typeof(Vector2), PropertyType.Vector2 }, { typeof(Vector3), PropertyType.Vector3 }, + { typeof(BrickColor), PropertyType.BrickColor }, { typeof(Quaternion), PropertyType.Quaternion }, + { typeof(Color3uint8), PropertyType.Color3uint8 }, { typeof(NumberRange), PropertyType.NumberRange }, { typeof(SharedString), PropertyType.SharedString }, { typeof(Vector3int16), PropertyType.Vector3int16 }, { typeof(ColorSequence), PropertyType.ColorSequence }, { typeof(NumberSequence), PropertyType.NumberSequence }, + { typeof(ProtectedString), PropertyType.String }, { typeof(PhysicalProperties), PropertyType.PhysicalProperties }, }; @@ -98,7 +102,7 @@ namespace RobloxFiles else if (RawValue is SharedString) { var sharedString = CastValue(); - RawBuffer = Convert.FromBase64String(sharedString.MD5_Key); + RawBuffer = sharedString.SharedValue; return; } @@ -134,17 +138,19 @@ namespace RobloxFiles if (typeName == Name) { - var implicitName = Name + '_'; - return implicitName; + FieldInfo directField = instType.GetField(typeName, BindingFlags.DeclaredOnly); + + if (directField != null) + { + var implicitName = Name + '_'; + return implicitName; + } } } if (Name.Contains(" ")) - { - var implicitName = Name.Replace(' ', '_'); - return implicitName; - } - + return Name.Replace(' ', '_'); + return Name; } } @@ -289,14 +295,16 @@ namespace RobloxFiles public T CastValue() { - T result; + object result; - if (Value is T) + if (typeof(T) == typeof(string)) + result = Value?.ToString() ?? ""; + else if (Value is T) result = (T)Value; else result = default(T); - - return result; + + return (T)result; } internal void WriteValue() where T : struct diff --git a/XmlFormat/Tokens/BinaryString.cs b/XmlFormat/Tokens/BinaryString.cs index 7aa88a2..10194a4 100644 --- a/XmlFormat/Tokens/BinaryString.cs +++ b/XmlFormat/Tokens/BinaryString.cs @@ -11,11 +11,11 @@ namespace RobloxFiles.XmlFormat.PropertyTokens { // BinaryStrings are encoded in base64 string base64 = token.InnerText.Replace("\n", ""); - prop.Value = Convert.FromBase64String(base64); - prop.Type = PropertyType.String; - byte[] buffer = Convert.FromBase64String(base64); + + prop.Value = buffer; prop.RawBuffer = buffer; + prop.Type = PropertyType.String; return true; }