mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-21 20:21:38 +00:00
Merge 8f8c19b845 into 7e60406373
This commit is contained in:
commit
f5f0b65c6d
1 changed files with 40 additions and 4 deletions
|
|
@ -8,9 +8,49 @@ local Theme = require(Plugin.App.Theme)
|
||||||
|
|
||||||
local e = Roact.createElement
|
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)
|
local function DisplayValue(props)
|
||||||
return Theme.with(function(theme)
|
return Theme.with(function(theme)
|
||||||
local t = typeof(props.value)
|
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
|
if t == "Color3" then
|
||||||
-- Colors get a blot that shows the color
|
-- Colors get a blot that shows the color
|
||||||
return Roact.createFragment({
|
return Roact.createFragment({
|
||||||
|
|
@ -100,10 +140,6 @@ local function DisplayValue(props)
|
||||||
})
|
})
|
||||||
end
|
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", " ")
|
local textRepresentation = string.gsub(tostring(props.value), "%s", " ")
|
||||||
if t == "string" then
|
if t == "string" then
|
||||||
textRepresentation = '"' .. textRepresentation .. '"'
|
textRepresentation = '"' .. textRepresentation .. '"'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue