This commit is contained in:
Andy Vu 2026-10-06 01:20:58 -04:00 • committed by GitHub
commit f5f0b65c6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,9 +8,49 @@ local Theme = require(Plugin.App.Theme)
local e = Roact.createElement
local function fmtNum(n)
if math.abs(n - math.round(n)) < 0.0001 then
return tostring(math.round(n))
end
return (string.format("%.3f", n):gsub("0+$", ""):gsub("%.$", ""))
end
local function DisplayValue(props)
return Theme.with(function(theme)
local t = typeof(props.value)
local text
if t == "Vector3" then
text = string.format("(%s, %s, %s)", fmtNum(props.value.X), fmtNum(props.value.Y), fmtNum(props.value.Z))
elseif t == "Vector2" then
text = string.format("(%s, %s)", fmtNum(props.value.X), fmtNum(props.value.Y))
elseif t == "UDim2" then
local x, y = props.value.X, props.value.Y
text = string.format("{%s, %s}, {%s, %s}", fmtNum(x.Scale), fmtNum(x.Offset), fmtNum(y.Scale), fmtNum(y.Offset))
elseif t == "CFrame" then
local p = props.value.Position
local rx, ry, rz = props.value:ToOrientation()
text = string.format("(%s, %s, %s), (%s°, %s°, %s°)",
fmtNum(p.X), fmtNum(p.Y), fmtNum(p.Z),
fmtNum(math.deg(rx)), fmtNum(math.deg(ry)), fmtNum(math.deg(rz)))
elseif t == "NumberRange" then
text = string.format("[%s, %s]", fmtNum(props.value.Min), fmtNum(props.value.Max))
end
if text then
return e("TextLabel", {
Text = text,
BackgroundTransparency = 1,
FontFace = theme.Font.Main,
TextSize = theme.TextSize.Body,
TextColor3 = props.textColor,
TextXAlignment = Enum.TextXAlignment.Left,
TextTransparency = props.transparency,
TextTruncate = Enum.TextTruncate.AtEnd,
Size = UDim2.new(1, 0, 1, 0),
})
end
if t == "Color3" then
-- Colors get a blot that shows the color
return Roact.createFragment({
@ -100,10 +140,6 @@ local function DisplayValue(props)
})
end
-- TODO: Maybe add visualizations to other datatypes?
-- Or special text handling tostring for some?
-- Will add as needed, let's see what cases arise.
local textRepresentation = string.gsub(tostring(props.value), "%s", " ")
if t == "string" then
textRepresentation = '"' .. textRepresentation .. '"'