mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Helper scripts for making font & physical properties from enums
This commit is contained in:
parent
6d76df7524
commit
e57abbe5d9
4 changed files with 55 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -22,3 +22,5 @@ luneTypes.d.luau
|
||||||
|
|
||||||
# Files generated by runtime or build scripts
|
# Files generated by runtime or build scripts
|
||||||
packages/lib-roblox/scripts/brick_color.rs
|
packages/lib-roblox/scripts/brick_color.rs
|
||||||
|
packages/lib-roblox/scripts/font_enum_map.rs
|
||||||
|
packages/lib-roblox/scripts/physical_properties_enum_map.rs
|
||||||
|
|
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
|
@ -5,8 +5,11 @@
|
||||||
"luau-lsp.types.definitionFiles": ["luneTypes.d.luau"],
|
"luau-lsp.types.definitionFiles": ["luneTypes.d.luau"],
|
||||||
"luau-lsp.types.documentationFiles": ["luneDocs.json"],
|
"luau-lsp.types.documentationFiles": ["luneDocs.json"],
|
||||||
"luau-lsp.require.mode": "relativeToFile",
|
"luau-lsp.require.mode": "relativeToFile",
|
||||||
// Luau - ignore type defs file in docs dir
|
// Luau - ignore type defs file in docs dir and dev scripts we use
|
||||||
"luau-lsp.ignoreGlobs": ["docs/*.d.luau"],
|
"luau-lsp.ignoreGlobs": [
|
||||||
|
"docs/*.d.luau",
|
||||||
|
"packages/lib-roblox/scripts/*.luau"
|
||||||
|
],
|
||||||
// Rust
|
// Rust
|
||||||
"rust-analyzer.check.command": "clippy",
|
"rust-analyzer.check.command": "clippy",
|
||||||
// Formatting
|
// Formatting
|
||||||
|
|
22
packages/lib-roblox/scripts/font_enum_map.luau
Normal file
22
packages/lib-roblox/scripts/font_enum_map.luau
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
-- NOTE: This must be ran in Roblox Studio to get up-to-date font values
|
||||||
|
|
||||||
|
local contents = ""
|
||||||
|
|
||||||
|
contents ..= "\nconst FONT_ENUM_MAP: &[(&str, Option<(&str, RbxFontWeight, RbxFontStyle)>)] = &[\n"
|
||||||
|
for _, enum in Enum.Font:GetEnumItems() do
|
||||||
|
if enum == Enum.Font.Unknown then
|
||||||
|
contents ..= ' ("Unknown", None),\n'
|
||||||
|
else
|
||||||
|
local font = Font.fromEnum(enum)
|
||||||
|
contents ..= string.format(
|
||||||
|
' ("%s", Some(("%s", RbxFontWeight::%s, RbxFontStyle::%s))),\n',
|
||||||
|
enum.Name,
|
||||||
|
font.Family,
|
||||||
|
font.Weight.Name,
|
||||||
|
font.Style.Name
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
contents ..= "];\n"
|
||||||
|
|
||||||
|
print(contents)
|
|
@ -0,0 +1,26 @@
|
||||||
|
-- NOTE: This must be ran in Roblox Studio to get up-to-date enum values
|
||||||
|
|
||||||
|
local contents = ""
|
||||||
|
|
||||||
|
local longestNameLen = 0
|
||||||
|
for _, enum in Enum.Material:GetEnumItems() do
|
||||||
|
longestNameLen = math.max(longestNameLen, #enum.Name)
|
||||||
|
end
|
||||||
|
|
||||||
|
contents ..= "\n#[rustfmt::skip]\nconst MATERIAL_ENUM_MAP: &[(&str, f32, f32, f32, f32, f32)] = &[\n"
|
||||||
|
for _, enum in Enum.Material:GetEnumItems() do
|
||||||
|
local props = PhysicalProperties.new(enum)
|
||||||
|
contents ..= string.format(
|
||||||
|
' ("%s",%s %.2f, %.2f, %.2f, %.2f, %.2f),\n',
|
||||||
|
enum.Name,
|
||||||
|
string.rep(" ", longestNameLen - #enum.Name),
|
||||||
|
props.Density,
|
||||||
|
props.Friction,
|
||||||
|
props.Elasticity,
|
||||||
|
props.FrictionWeight,
|
||||||
|
props.ElasticityWeight
|
||||||
|
)
|
||||||
|
end
|
||||||
|
contents ..= "];\n"
|
||||||
|
|
||||||
|
print(contents)
|
Loading…
Reference in a new issue