0.522.0.5220281 (+ Font Type Support & Bug Fixes)

This commit is contained in:
Max
2022-04-14 20:52:05 -05:00
parent cff4b1ad5c
commit f8c914dd0b
21 changed files with 3577 additions and 2631 deletions

View File

@ -1,43 +1,67 @@
--!strict
local Format = {}
function Format.Null(value)
type IFlags = { [string]: boolean }
type IEnum = { GetEnumItems: (IEnum) -> {EnumItem} }
type IAxes =
{
X: boolean;
Y: boolean;
Z: boolean;
}
type IFaces =
{
Left: boolean;
Right: boolean;
Top: boolean;
Bottom: boolean;
Front: boolean;
Back: boolean;
}
function Format.Null(value: any): nil
return nil
end
function Format.Bytes(value)
function Format.Bytes(value: string): string
if #value > 0 then
local fmt = "Convert.FromBase64String(%q)"
return fmt:format(value)
else
return "Array.Empty<byte>()"
return string.format("Convert.FromBase64String(%q)", value)
end
return "Array.Empty<byte>()"
end
function Format.Bool(value)
function Format.Bool(value: boolean?): string?
if value then
return "true"
end
return nil
end
function Format.String(value)
function Format.String(value: string): string
return string.format("%q", value)
end
function Format.Int(value, default)
if value == 2147483647 then
function Format.Int(value: number): string
if value == 2^31-1 then
return "int.MaxValue"
elseif value == -2147483648 then
elseif value == -2^31 then
return "int.MinValue"
elseif value ~= 0 or default then
else
return string.format("%i", value)
end
end
function Format.Number(value, default)
function Format.Number(value: number): string
local int = math.floor(value)
if math.abs(value - int) < 0.001 then
return Format.Int(int, default)
return Format.Int(int)
end
local result = string.format("%.5f", value)
@ -46,12 +70,10 @@ function Format.Number(value, default)
return result
end
function Format.Double(value, default)
local result = Format.Number(value, default)
function Format.Double(value: number): string
local result = Format.Number(value)
if not result then
return nil
elseif result == "inf" then
if result == "inf" then
return "double.MaxValue"
elseif result == "-inf" then
return "double.MinValue"
@ -60,12 +82,10 @@ function Format.Double(value, default)
end
end
function Format.Float(value, default)
local result = Format.Number(value, default)
function Format.Float(value: number): string
local result = Format.Number(value)
if not result then
return nil
elseif result == "inf" then
if result == "inf" then
return "float.MaxValue"
elseif result == "-inf" then
return "float.MinValue"
@ -78,44 +98,44 @@ function Format.Float(value, default)
end
end
function Format.Flags(flag, enum)
function Format.Flags(flags: IFlags, enum: IEnum): string
local value = 0
for _,item in pairs(enum:GetEnumItems()) do
if flag[item.Name] then
if flags[item.Name] then
value += (2 ^ item.Value)
end
end
return value
return tostring(value)
end
function Format.Axes(axes)
function Format.Axes(axes: IAxes): string
return "(Axes)" .. Format.Flags(axes, Enum.Axis)
end
function Format.Faces(faces)
function Format.Faces(faces: IFaces): string
return "(Faces)" .. Format.Flags(faces, Enum.NormalId)
end
function Format.EnumItem(item)
function Format.EnumItem(item: EnumItem): string
local enum = tostring(item.EnumType)
return enum .. '.' .. item.Name
end
function Format.BrickColor(brickColor)
function Format.BrickColor(brickColor: BrickColor): string
local fmt = "BrickColor.FromNumber(%i)"
return fmt:format(brickColor.Number)
end
function Format.Color3(color)
function Format.Color3(color: Color3): string
if color == Color3.new() then
return "new Color3()"
end
local r = Format.Float(color.R, true)
local g = Format.Float(color.G, true)
local b = Format.Float(color.B, true)
local r = Format.Float(color.R)
local g = Format.Float(color.G)
local b = Format.Float(color.B)
local fmt = "%s(%s, %s, %s)";
local constructor = "new Color3";
@ -131,159 +151,176 @@ function Format.Color3(color)
return fmt:format(constructor, r, g, b)
end
function Format.UDim(udim)
function Format.UDim(udim: UDim): string
if udim == UDim.new() then
return "new UDim()"
end
local scale = Format.Float(udim.Scale, true)
local offset = Format.Int(udim.Offset, true)
local scale = Format.Float(udim.Scale)
local offset = Format.Int(udim.Offset)
local fmt = "new UDim(%s, %s)"
return fmt:format(scale, offset)
end
function Format.UDim2(udim2)
function Format.UDim2(udim2: UDim2): string
if udim2 == UDim2.new() then
return "new UDim2()"
end
local xScale = Format.Float(udim2.X.Scale, true)
local yScale = Format.Float(udim2.Y.Scale, true)
local xScale = Format.Float(udim2.X.Scale)
local yScale = Format.Float(udim2.Y.Scale)
local xOffset = Format.Int(udim2.X.Offset, true)
local yOffset = Format.Int(udim2.Y.Offset, true)
local xOffset = Format.Int(udim2.X.Offset)
local yOffset = Format.Int(udim2.Y.Offset)
local fmt = "new UDim2(%s, %s, %s, %s)"
return fmt:format(xScale, xOffset, yScale, yOffset)
end
function Format.Vector2(v2)
function Format.Vector2(v2: Vector2): string
if v2.Magnitude < 0.001 then
return "new Vector2()"
end
local x = Format.Float(v2.X, true)
local y = Format.Float(v2.Y, true)
local x = Format.Float(v2.X)
local y = Format.Float(v2.Y)
local fmt = "new Vector2(%s, %s)"
return fmt:format(x, y)
end
function Format.Vector3(v3)
function Format.Vector3(v3: Vector3): string
if v3.Magnitude < 0.001 then
return "new Vector3()"
end
local x = Format.Float(v3.X, true)
local y = Format.Float(v3.Y, true)
local z = Format.Float(v3.Z, true)
local x = Format.Float(v3.X)
local y = Format.Float(v3.Y)
local z = Format.Float(v3.Z)
local fmt = "new Vector3(%s, %s, %s)"
return fmt:format(x, y, z)
end
function Format.CFrame(cf)
local blankCF = CFrame.new()
if cf == blankCF then
function Format.CFrame(cf: CFrame): string
if cf == CFrame.identity then
return "new CFrame()"
end
local rot = cf - cf.p
if rot == blankCF then
local fmt = "new CFrame(%s, %s, %s)"
if cf.Rotation == CFrame.identity then
local x = Format.Float(cf.X)
local y = Format.Float(cf.Y)
local z = Format.Float(cf.Z)
local x = Format.Float(cf.X, true)
local y = Format.Float(cf.Y, true)
local z = Format.Float(cf.Z, true)
return fmt:format(x, y, z)
return string.format("new CFrame(%s, %s, %s)", x, y, z)
else
local comp = { cf:GetComponents() }
local matrix = ""
for i = 1,12 do
comp[i] = Format.Float(comp[i], true)
for i = 1, 12 do
local sep = (if i > 1 then ", " else "")
matrix ..= sep .. Format.Float(comp[i])
end
local fmt = "new CFrame(%s)"
local matrix = table.concat(comp, ", ")
return fmt:format(matrix)
return string.format("new CFrame(%s)", matrix)
end
end
function Format.NumberRange(nr)
function Format.NumberRange(nr: NumberRange): string
local min = nr.Min
local max = nr.Max
local fmt = "new NumberRange(%s)"
local value = Format.Float(min, true)
local value = Format.Float(min)
if min ~= max then
value = value .. ", " .. Format.Float(max, true)
value = value .. ", " .. Format.Float(max)
end
return fmt:format(value)
end
function Format.Ray(ray)
function Format.Ray(ray: Ray): string
if ray == Ray.new() then
return "new Ray()"
end
local fmt = "new Ray(%s, %s)"
local origin = Format.Vector3(ray.Origin)
local direction = Format.Vector3(ray.Direction)
local fmt = "new Ray(%s, %s)"
return fmt:format(origin, direction)
end
function Format.Rect(rect)
function Format.Rect(rect: Rect): string
local min: any = rect.Min
local max: any = rect.Max
if min == max and min == Vector2.zero then
return "new Rect()"
end
min = Format.Vector2(min)
max = Format.Vector2(max)
local fmt = "new Rect(%s, %s)"
local min = Format.Vector2(rect.Min)
local max = Format.Vector2(rect.Max)
return fmt:format(min, max)
end
function Format.ColorSequence(cs)
function Format.ColorSequence(cs: ColorSequence): string
local csKey = cs.Keypoints[1]
local fmt = "new ColorSequence(%s)"
local value = tostring(csKey.Value)
local fmt = "new ColorSequence(%s)"
return fmt:format(value)
end
function Format.NumberSequence(ns)
function Format.NumberSequence(ns: NumberSequence): string
local nsKey = ns.Keypoints[1]
local fmt = "new NumberSequence(%s)"
local value = Format.Float(nsKey.Value, true)
local value = Format.Float(nsKey.Value)
return fmt:format(value)
end
function Format.Vector3int16(v3)
function Format.Vector3int16(v3: Vector3int16): string
if v3 == Vector3int16.new() then
return "new Vector3int16()"
end
local x = Format.Int(v3.X, true)
local y = Format.Int(v3.Y, true)
local z = Format.Int(v3.Z, true)
local x = Format.Int(v3.X)
local y = Format.Int(v3.Y)
local z = Format.Int(v3.Z)
local fmt = "new Vector3int16(%s, %s, %s)"
return fmt:format(x, y, z)
end
function Format.SharedString(str)
function Format.SharedString(str: string): string
local fmt = "SharedString.FromBase64(%q)"
return fmt:format(str)
end
function Format.FontFace(font: Font): string
local family = string.format("%q", font.Family)
local args = { family }
local style = font.Style
local weight = font.Weight
if style ~= Enum.FontStyle.Normal then
table.insert(args, "FontStyle." .. style.Name)
end
if #args > 1 or weight ~= Enum.FontWeight.Regular then
table.insert(args, "FontWeight." .. weight.Name)
end
local fmt = "new FontFace(%s)"
local argStr = table.concat(args, ", ")
return fmt:format(argStr)
end
return Format

View File

@ -63,6 +63,29 @@ local GuiTextMixIn =
return
{
AnimationRigData =
{
Add =
{
label = "BinaryString";
name = "BinaryString";
parent = "BinaryString";
postTransform = "BinaryString";
preTransform = "BinaryString";
transform = "BinaryString";
};
Defaults =
{
label = "AQAAAAEAAAAAAAAA";
name = "AQAAAAEAAAAAAAAA";
parent = "AQAAAAEAAAAAAA==";
postTransform = "AQAAAAEAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAA=";
preTransform = "AQAAAAEAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAA=";
transform = "AQAAAAEAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAA=";
}
};
BallSocketConstraint =
{
-- Why does this even exist?
@ -73,13 +96,21 @@ return
{
Add =
{
MaterialVariantSerialized = "string";
MaterialVariant = "string";
Color3uint8 = "Color3uint8";
size = "Vector3";
};
Redirect =
{
Position = "CFrame.Position";
Position =
{
Get = "CFrame.Position";
Set = "CFrame = new CFrame(value) * CFrame.Rotation";
};
MaterialVariant = "MaterialVariantSerialized";
BrickColor = UseColor3("Color");
Color = "Color3uint8";
Size = "size";
@ -88,6 +119,7 @@ return
Defaults =
{
Color3uint8 = Color3.fromRGB(163, 162, 165);
MaterialVariantSerialized = "";
size = Vector3.new(4, 1.2, 2);
};
};
@ -200,6 +232,12 @@ return
Size = "size_xml";
};
};
FloatCurve =
{
Add = { ValuesAndTimes = "BinaryString" };
Defaults = { ValuesAndTimes = "AAAAAAEAAAAKAAAAAAAAFkUAAAAA" };
};
FormFactorPart =
{
@ -244,6 +282,15 @@ return
Transparency = "BackgroundTransparency";
}
};
HiddenSurfaceRemovalAsset =
{
Add =
{
HSRData = "BinaryString";
HSRMeshIdData = "BinaryString";
}
};
HttpService =
{
@ -355,6 +402,60 @@ return
Source = "ProtectedString";
};
};
MarkerCurve =
{
Add = { ValuesAndTimes = "BinaryString" };
Defaults = { ValuesAndTimes = "AAAAAAEAAAAKAAAAAAAAFkUAAAAA" };
};
MaterialService =
{
Defaults =
{
AsphaltName = "Asphalt";
BasaltName = "Basalt";
BrickName = "Brick";
CobblestoneName = "Cobblestone";
ConcreteName = "Concrete";
CorrodedMetalName = "CorrodedMetal";
CrackedLavaName = "CrackedLava";
DiamondPlateName = "DiamondPlate";
FabricName = "Fabric";
FoilName = "Foil";
GlacierName = "Glacier";
GraniteName = "Granite";
GrassName = "Grass";
GroundName = "Ground";
IceName = "Ice";
LeafyGrassName = "LeafyGrass";
LimestoneName = "Limestone";
MarbleName = "Marble";
MetalName = "Metal";
MudName = "Mud";
PavementName = "Pavement";
PebbleName = "Pebble";
PlasticName = "Plastic";
RockName = "Rock";
SaltName = "Salt";
SandName = "Sand";
SandstoneName = "Sandstone";
SlateName = "Slate";
SmoothPlasticName = "SmoothPlastic";
SnowName = "Snow";
WoodName = "Wood";
WoodPlanksName = "WoodPlanks";
}
};
MaterialVariant =
{
Add =
{
TexturePack0 = "Content";
TexturePack1 = "Content";
}
};
MeshPart =
{
@ -457,6 +558,12 @@ return
LuobuWhitelisted = TryGetEnumItem("TriStateBoolean", "Unknown");
};
};
RotationCurve =
{
Add = { ValuesAndTimes = "BinaryString" };
Defaults = { ValuesAndTimes = "AAAAAAEAAAAKAAAAAAAAFkUAAAAA" };
};
SelectionBox =
{
@ -604,6 +711,11 @@ return
MaterialColors = "AAAAAAAAan8/P39rf2Y/ilY+j35fi21PZmxvZbDqw8faiVpHOi4kHh4lZlw76JxKc3trhHtagcLgc4RKxr21zq2UlJSM";
};
};
TerrainDetail =
{
Add = { TexturePack1 = "Content"; }
};
TerrainRegion =
{

View File

@ -2,6 +2,7 @@ local Selection = game:GetService("Selection")
local HttpService = game:GetService("HttpService")
local StarterPlayer = game:GetService("StarterPlayer")
local StudioService = game:GetService("StudioService")
local TextChatService = game:GetService("TextChatService")
local classes = {}
local outStream = ""
@ -14,12 +15,16 @@ local singletons =
ParabolaAdornment = Instance.new("BoxHandleAdornment"); -- close enough
StarterPlayerScripts = StarterPlayer:WaitForChild("StarterPlayerScripts");
StarterCharacterScripts = StarterPlayer:WaitForChild("StarterCharacterScripts");
ChatWindowConfiguration = TextChatService:WaitForChild("ChatWindowConfiguration");
ChatInputBarConfiguration = TextChatService:WaitForChild("ChatInputBarConfiguration");
}
local exceptionClasses =
{
PackageLink = true;
ScriptDebugger = true;
ChatWindowConfiguration = true;
ChatInputBarConfiguration = true;
}
local numberTypes =
@ -205,7 +210,10 @@ end
-- Formatting
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local formatting = require(script.Formatting)
type FormatFunc = (any) -> string;
type Format = { [string]: FormatFunc }
local formatting: Format = require(script.Formatting)
local formatLinks =
{
@ -227,7 +235,7 @@ local formatLinks =
["ProtectedString"] = "String";
}
local function getFormatFunction(valueType)
local function getFormatFunction(valueType: string): FormatFunc?
if not formatting[valueType] then
valueType = formatLinks[valueType]
end
@ -307,6 +315,8 @@ local function generateClasses()
{
Axis = true;
FontSize = true;
FontStyle = true;
FontWeight = true;
}
for _,class in ipairs(apiDump.Classes) do
@ -323,7 +333,9 @@ local function generateClasses()
if classTags.Service then
pcall(function ()
class.Object = game:GetService(className)
if not className:find("Network") then
class.Object = game:GetService(className)
end
end)
elseif not classTags.NotCreatable then
pcall(function ()
@ -364,10 +376,6 @@ local function generateClasses()
writeLine("using RobloxFiles.Utility;")
writeLine()
-- writeLine("#pragma warning disable CA1041 // Provide ObsoleteAttribute message")
-- writeLine("#pragma warning disable CA1051 // Do not declare visible instance fields")
-- writeLine("#pragma warning disable CA1707 // Identifiers should not contain underscores")
-- writeLine("#pragma warning disable CA1716 // Identifiers should not match keywords")
writeLine("#pragma warning disable IDE1006 // Naming Styles")
writeLine()
@ -468,7 +476,10 @@ local function generateClasses()
local propTags = getTags(prop)
local serial = prop.Serialization
local valueType = prop.ValueType.Name
local typeData = prop.ValueType
local category = typeData.Category
local valueType = typeData.Name
local redirect = redirectProps[propName]
local couldSave = (serial.CanSave or propTags.Deprecated or redirect)
@ -489,6 +500,8 @@ local function generateClasses()
valueType = "long"
elseif valueType == "BinaryString" then
valueType = "byte[]"
elseif valueType == "Font" and category ~= "Enum" then
valueType = "FontFace"
end
local first = name:sub(1, 1)
@ -567,33 +580,29 @@ local function generateClasses()
end)
end
local typeData = prop.ValueType
local category = typeData.Category
if not gotValue and category ~= "Class" then
-- Fallback to implicit defaults
local typeName = typeData.Name
if numberTypes[typeName] then
if numberTypes[valueType] then
value = 0
gotValue = true
elseif stringTypes[typeName] then
elseif stringTypes[valueType] then
value = ""
gotValue = true
elseif typeName == "SharedString" then
elseif valueType == "SharedString" then
value = "yuZpQdnvvUBOTYh1jqZ2cA=="
gotValue = true
elseif category == "DataType" then
local DataType = env[typeName]
local DataType = env[valueType]
if DataType and typeof(DataType) == "table" and not rawget(env, typeName) then
if DataType and typeof(DataType) == "table" and not rawget(env, valueType) then
pcall(function ()
value = DataType.new()
gotValue = true
end)
end
elseif category == "Enum" then
local enum = Enum[typeName]
local enum = Enum[valueType]
local lowestId = math.huge
local lowest
@ -623,7 +632,8 @@ local function generateClasses()
end
if gotValue then
local formatFunc = getFormatFunction(valueType)
local formatKey = if category == "Enum" then "Enum" else valueType
local formatFunc = getFormatFunction(formatKey)
if not formatFunc then
local literal = typeof(value)
@ -636,10 +646,12 @@ local function generateClasses()
local result
if typeof(formatFunc) == "string" then
result = formatFunc
else
result = formatFunc(value)
if formatFunc then
if typeof(formatFunc) == "string" then
result = formatFunc
else
result = formatFunc(value)
end
end
if result ~= nil then