Minor fixes and tweaks.
This commit is contained in:
parent
4e1fdc0a22
commit
cf4cf829d7
@ -6,27 +6,26 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Content
|
public class Content
|
||||||
{
|
{
|
||||||
// TODO: Maybe introduce constraints to the value?
|
public readonly string Url;
|
||||||
public readonly string Data;
|
|
||||||
|
|
||||||
public override string ToString()
|
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)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,21 +6,21 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProtectedString
|
public class ProtectedString
|
||||||
{
|
{
|
||||||
public readonly string Value;
|
public readonly string ProtectedValue;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Value;
|
return ProtectedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtectedString(string value)
|
public ProtectedString(string value)
|
||||||
{
|
{
|
||||||
Value = value;
|
ProtectedValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator string(ProtectedString protectedString)
|
public static implicit operator string(ProtectedString protectedString)
|
||||||
{
|
{
|
||||||
return protectedString.Value;
|
return protectedString.ProtectedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator ProtectedString(string value)
|
public static implicit operator ProtectedString(string value)
|
||||||
|
@ -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)
|
public Quaternion(float x, float y, float z, float w)
|
||||||
{
|
{
|
||||||
X = x;
|
X = x;
|
||||||
|
@ -1786,6 +1786,7 @@ namespace RobloxFiles
|
|||||||
|
|
||||||
public abstract class LuaSourceContainer : Instance
|
public abstract class LuaSourceContainer : Instance
|
||||||
{
|
{
|
||||||
|
public string ScriptGuid = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class BaseScript : LuaSourceContainer
|
public abstract class BaseScript : LuaSourceContainer
|
||||||
|
Binary file not shown.
@ -348,6 +348,12 @@ return
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LuaSourceContainer =
|
||||||
|
{
|
||||||
|
Add = { ScriptGuid = "string" };
|
||||||
|
Defaults = { ScriptGuid = "" };
|
||||||
|
};
|
||||||
|
|
||||||
ManualSurfaceJointInstance =
|
ManualSurfaceJointInstance =
|
||||||
{
|
{
|
||||||
Add =
|
Add =
|
||||||
|
@ -459,7 +459,14 @@ namespace RobloxFiles
|
|||||||
if (field.GetCustomAttribute<ObsoleteAttribute>() != null)
|
if (field.GetCustomAttribute<ObsoleteAttribute>() != null)
|
||||||
continue;
|
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("_"))
|
if (fieldName.EndsWith("_"))
|
||||||
fieldName = instType.Name;
|
fieldName = instType.Name;
|
||||||
@ -468,9 +475,9 @@ namespace RobloxFiles
|
|||||||
{
|
{
|
||||||
Property newProp = new Property()
|
Property newProp = new Property()
|
||||||
{
|
{
|
||||||
Type = Property.Types[fieldType],
|
|
||||||
Value = field.GetValue(this),
|
Value = field.GetValue(this),
|
||||||
Name = fieldName,
|
Name = fieldName,
|
||||||
|
Type = propType,
|
||||||
Instance = this
|
Instance = this
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -480,7 +487,7 @@ namespace RobloxFiles
|
|||||||
{
|
{
|
||||||
Property prop = props[fieldName];
|
Property prop = props[fieldName];
|
||||||
prop.Value = field.GetValue(this);
|
prop.Value = field.GetValue(this);
|
||||||
prop.Type = Property.Types[fieldType];
|
prop.Type = propType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,13 +43,13 @@ namespace RobloxFiles
|
|||||||
|
|
||||||
public class Property
|
public class Property
|
||||||
{
|
{
|
||||||
public string Name;
|
public string Name { get; internal set; }
|
||||||
public Instance Instance { get; internal set; }
|
public Instance Instance { get; internal set; }
|
||||||
|
|
||||||
public PropertyType Type;
|
public PropertyType Type { get; internal set; }
|
||||||
|
|
||||||
public string XmlToken = "";
|
public string XmlToken { get; internal set; }
|
||||||
public byte[] RawBuffer;
|
public byte[] RawBuffer { get; internal set; }
|
||||||
|
|
||||||
internal object RawValue;
|
internal object RawValue;
|
||||||
internal BinaryRobloxFileWriter CurrentWriter;
|
internal BinaryRobloxFileWriter CurrentWriter;
|
||||||
@ -74,16 +74,20 @@ namespace RobloxFiles
|
|||||||
{ typeof(UDim2), PropertyType.UDim2 },
|
{ typeof(UDim2), PropertyType.UDim2 },
|
||||||
{ typeof(CFrame), PropertyType.CFrame },
|
{ typeof(CFrame), PropertyType.CFrame },
|
||||||
{ typeof(Color3), PropertyType.Color3 },
|
{ typeof(Color3), PropertyType.Color3 },
|
||||||
|
{ typeof(Content), PropertyType.String },
|
||||||
{ typeof(Vector2), PropertyType.Vector2 },
|
{ typeof(Vector2), PropertyType.Vector2 },
|
||||||
{ typeof(Vector3), PropertyType.Vector3 },
|
{ typeof(Vector3), PropertyType.Vector3 },
|
||||||
|
|
||||||
|
|
||||||
{ typeof(BrickColor), PropertyType.BrickColor },
|
{ typeof(BrickColor), PropertyType.BrickColor },
|
||||||
{ typeof(Quaternion), PropertyType.Quaternion },
|
{ typeof(Quaternion), PropertyType.Quaternion },
|
||||||
|
{ typeof(Color3uint8), PropertyType.Color3uint8 },
|
||||||
{ typeof(NumberRange), PropertyType.NumberRange },
|
{ typeof(NumberRange), PropertyType.NumberRange },
|
||||||
{ typeof(SharedString), PropertyType.SharedString },
|
{ typeof(SharedString), PropertyType.SharedString },
|
||||||
{ typeof(Vector3int16), PropertyType.Vector3int16 },
|
{ typeof(Vector3int16), PropertyType.Vector3int16 },
|
||||||
{ typeof(ColorSequence), PropertyType.ColorSequence },
|
{ typeof(ColorSequence), PropertyType.ColorSequence },
|
||||||
{ typeof(NumberSequence), PropertyType.NumberSequence },
|
{ typeof(NumberSequence), PropertyType.NumberSequence },
|
||||||
|
{ typeof(ProtectedString), PropertyType.String },
|
||||||
|
|
||||||
{ typeof(PhysicalProperties), PropertyType.PhysicalProperties },
|
{ typeof(PhysicalProperties), PropertyType.PhysicalProperties },
|
||||||
};
|
};
|
||||||
@ -98,7 +102,7 @@ namespace RobloxFiles
|
|||||||
else if (RawValue is SharedString)
|
else if (RawValue is SharedString)
|
||||||
{
|
{
|
||||||
var sharedString = CastValue<SharedString>();
|
var sharedString = CastValue<SharedString>();
|
||||||
RawBuffer = Convert.FromBase64String(sharedString.MD5_Key);
|
RawBuffer = sharedString.SharedValue;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,16 +138,18 @@ namespace RobloxFiles
|
|||||||
|
|
||||||
if (typeName == Name)
|
if (typeName == Name)
|
||||||
{
|
{
|
||||||
var implicitName = Name + '_';
|
FieldInfo directField = instType.GetField(typeName, BindingFlags.DeclaredOnly);
|
||||||
return implicitName;
|
|
||||||
|
if (directField != null)
|
||||||
|
{
|
||||||
|
var implicitName = Name + '_';
|
||||||
|
return implicitName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Name.Contains(" "))
|
if (Name.Contains(" "))
|
||||||
{
|
return Name.Replace(' ', '_');
|
||||||
var implicitName = Name.Replace(' ', '_');
|
|
||||||
return implicitName;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
@ -289,14 +295,16 @@ namespace RobloxFiles
|
|||||||
|
|
||||||
public T CastValue<T>()
|
public T CastValue<T>()
|
||||||
{
|
{
|
||||||
T result;
|
object result;
|
||||||
|
|
||||||
if (Value is T)
|
if (typeof(T) == typeof(string))
|
||||||
|
result = Value?.ToString() ?? "";
|
||||||
|
else if (Value is T)
|
||||||
result = (T)Value;
|
result = (T)Value;
|
||||||
else
|
else
|
||||||
result = default(T);
|
result = default(T);
|
||||||
|
|
||||||
return result;
|
return (T)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void WriteValue<T>() where T : struct
|
internal void WriteValue<T>() where T : struct
|
||||||
|
@ -11,11 +11,11 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
{
|
{
|
||||||
// BinaryStrings are encoded in base64
|
// BinaryStrings are encoded in base64
|
||||||
string base64 = token.InnerText.Replace("\n", "");
|
string base64 = token.InnerText.Replace("\n", "");
|
||||||
prop.Value = Convert.FromBase64String(base64);
|
|
||||||
prop.Type = PropertyType.String;
|
|
||||||
|
|
||||||
byte[] buffer = Convert.FromBase64String(base64);
|
byte[] buffer = Convert.FromBase64String(base64);
|
||||||
|
|
||||||
|
prop.Value = buffer;
|
||||||
prop.RawBuffer = buffer;
|
prop.RawBuffer = buffer;
|
||||||
|
prop.Type = PropertyType.String;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user