From cf4cf829d7fc4fb67b3fab0d466f7489013c47e0 Mon Sep 17 00:00:00 2001 From: CloneTrooper1019 Date: Thu, 4 Jul 2019 18:26:53 -0500 Subject: [PATCH] Minor fixes and tweaks. --- DataTypes/Content.cs | 15 ++++---- DataTypes/ProtectedString.cs | 8 ++-- DataTypes/Quaternion.cs | 5 +++ Generated/Classes.cs | 1 + Plugins/GenerateApiDump.rbxm | Bin 13301 -> 13330 bytes Plugins/GenerateApiDump/PropertyPatches.lua | 6 +++ Tree/Instance.cs | 13 +++++-- Tree/Property.cs | 40 ++++++++++++-------- XmlFormat/Tokens/BinaryString.cs | 6 +-- 9 files changed, 60 insertions(+), 34 deletions(-) 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 1c77ae3b9a063254cecf8012edc3a6d3bffcb0c9..3c57b8aa347f9118000451c1c3bd1d301d7f03a2 100644 GIT binary patch delta 1163 zcmW-hZERC@6vm(Pzi;hryL;R9_MPsoOxai%Epr%{!FB5-ECVZ@Fy+Iz+wQiqwkx-t zLWUwQF(L5-dLu~0Xf!TL6d4%x0|+LVX!xW?Awe;s_=ZtINcbe)c#@OnIiF6>^GnX{ z$rq+hM47NQ2E2VL$~CiU}54hSsk z5v44$%QD^WJP8+MY*k!;s$!ASyY)GJ5%hJrogf+E@#kGQz_3MD9wbm4+t*d{RhieoD{`J6tNDwrj6tZt4Eo%Lv`-@vXx zIw7D%$kwKes$Zo#kHzR5+F9M>bIpwe@0-&LOF^Ar=LL2cSc${Mv69(eF4pS>CJhjO zl=zJe`9jq)jlICI4;`E^s<9ZhXDgE>vtxJ*FDwM5IM5Uqc7*~f-e1Buw6QKgPuQ1( z(ZyDfO zBqWIHkedmg+9O)aBqxTx~^PkT$sW%*tCh?#^50glSpkcnY*n7Sb%g z(X5P{SKHG=X6>Ah{lxiR6y;+<-^E6p1bC!mcdJ0dEV(0(UI#@gg`QfjSnC(<>smbj zv=^=z+-{#Rgog^%DRYgYY{v3l>j~4k0C=GcgvHLm8RM6z@_|?EFO+Adj{t*`;E71P z71u#;dZuc;6F^=;nUikVn?gzLuA*!O(Q@#QL)uLIJX4rz9|+y6ebPW@IHVc%knlP8 zsB>Jdc+)-~8er)LTMe&X>TA^X)Cg~l8e`Lis`*chyb2buM|KyghBaN9_pqZRo&$Yp z*Tc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3u9QQ@5hM$J%LH*8mUHucBh-`m*t2OkL#>S7wXl@uR?PQ8=basw(TA zRJme26~tX1ik!61o`@zRhg5Yth}yw#gS3_SIi?;_?NibDkxf3j#399K1qq*VTbz`A z`5F70=sI@AYqx4$i{1(9dh_$VHEfKGXDj9_ahmnvee84MR19mpu*}V7NxT9Ywhw82 z&x|F=;9a5mV0R4Z^~Ug9n(6?|^i0-jS;<}RJOlhzIYe*3x1SyEEjR#7Yqhn&&!19g zPH<@J&vx{a+5o|Bs2iqN?U(Cbh)hJJ?@2ho1*T>^femX~_~QxMY5!ZdQ0WQMQLqWO zGuRPJYaK}zgjh;K2mKRZMUWrdiKM+dwv^`EXJb(sx39*UgxL^(B4qy@YoVv@V0^iE zeVm0E%{e;|*g<a@Gk+*>fJ)vgN~5@7cL z1&!$^;Kebe9Mj-WCyBX1TkXH%eYD@sB)WU8u)liIk5-~DnWBL<1Aps! zA)iZZT5XjlE4xJbq;z2ARHcv~$=AApji67$bda!sGTEACK1|pjB}(jS#BQ(uurUVb Zx*h#r4`k+a-qA**Xp-odb8>^C{Ra@060-mR 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; }