cluaupp 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +10 -5
- package/api/CHANGELOG.md +3 -0
- package/api/chat.js +74 -0
- package/api/fixtures/roblox/README.md +6 -0
- package/api/fixtures/roblox/aux/sample.d.luau +6 -0
- package/api/fixtures/roblox/mini/Mini-API-Dump.json +72 -0
- package/api/generated/bench-latest.json +39 -0
- package/api/generated/capability-profile.json +76 -0
- package/api/generated/lsp-index.json +1 -0
- package/api/generated/luau/classes.d.luau +11221 -0
- package/api/generated/luau/datatypes.d.luau +327 -0
- package/api/generated/luau/enums.d.luau +4918 -0
- package/api/generated/luau/globals.d.luau +12 -0
- package/api/manifests/roblox-target.manifest.json +22 -0
- package/api/normalized/roblox-target.profile.json +237461 -0
- package/api/overrides/classes.json +8 -0
- package/api/overrides/compatibility.json +9 -0
- package/api/overrides/datatypes.json +1579 -0
- package/api/overrides/enums.json +8 -0
- package/api/overrides/globals.json +8 -0
- package/api/overrides/type-mappings.json +9 -0
- package/api/roblox-api.lock.json +9 -0
- package/data/Mini-API-Dump.json +1 -0
- package/editors/vscode/README.md +12 -10
- package/editors/vscode/extension.js +82 -0
- package/editors/vscode/icons/axiom.svg +4 -0
- package/editors/vscode/icons/bloom.svg +5 -0
- package/editors/vscode/icons/helm.svg +4 -0
- package/editors/vscode/icons/hive.svg +5 -0
- package/editors/vscode/icons/mint.svg +4 -0
- package/editors/vscode/icons/shift.svg +6 -0
- package/editors/vscode/language-configuration-schema.json +24 -0
- package/editors/vscode/package.json +172 -12
- package/editors/vscode/snippets/axiom.json +12 -0
- package/editors/vscode/snippets/bloom.json +12 -0
- package/editors/vscode/snippets/helm.json +12 -0
- package/editors/vscode/snippets/hive.json +12 -0
- package/editors/vscode/snippets/mint.json +12 -0
- package/editors/vscode/snippets/shift.json +17 -0
- package/editors/vscode/syntaxes/axiom.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/bloom.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/helm.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/hive.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/mint.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/schema.tmLanguage.json +89 -0
- package/editors/vscode/syntaxes/shift.tmLanguage.json +5 -0
- package/examples/game/.cluaupp/compile-cache/ReplicatedStorage__Shared__Constants__Datas__TemplateData.clh.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Boot__DataBoot.server.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Configuration__ServerConfig.clp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__Guard.server.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__PlayerHandler.server.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterCharacterScripts__Character__CharacterReady.client.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterPlayerScripts__Controllers__DataController.client.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/index.json +12 -0
- package/examples/game/.cluaupp/datamodel-profile.json +94 -0
- package/examples/game/.vscode/settings.json +12 -1
- package/examples/game/include/clpp/datatypes.clh +337 -373
- package/examples/game/include/clpp/generated/datamodel.clh +25 -0
- package/examples/game/include/clpp/generated/enums.clh +1 -1
- package/examples/game/include/clpp/generated/instances.clh +41135 -41064
- package/examples/game/include/clpp/libs/axiom.clh +1 -1
- package/examples/game/include/clpp/libs/math.clh +14 -0
- package/examples/game/include/clpp/libs/spring.clh +17 -0
- package/examples/game/include/clpp/libs/ward.clh +1 -0
- package/examples/game/include/clpp/roblox.clh +3 -4
- package/examples/game/libs/ArrayIndexer/init.luau +209 -0
- package/examples/game/libs/Axiom/init.luau +608 -0
- package/examples/game/libs/Bloom/init.luau +433 -0
- package/examples/game/libs/Coil/init.luau +215 -0
- package/examples/game/libs/Crest/init.luau +426 -0
- package/examples/game/libs/Echo/init.luau +417 -0
- package/examples/game/libs/Ember/init.luau +365 -0
- package/examples/game/libs/Flare/init.luau +717 -0
- package/examples/game/libs/Gleam/init.luau +729 -0
- package/examples/game/libs/Guide/init.luau +215 -0
- package/examples/game/libs/Helm/init.luau +377 -0
- package/examples/game/libs/Hive/init.luau +241 -0
- package/examples/game/libs/Keep/Client.luau +114 -0
- package/examples/game/libs/Keep/Data.luau +883 -0
- package/examples/game/libs/Keep/Engine.luau +211 -0
- package/examples/game/libs/Keep/Enum.luau +6 -0
- package/examples/game/libs/Keep/Enums.luau +10 -0
- package/examples/game/libs/Keep/Path.luau +236 -0
- package/examples/game/libs/Keep/Replicator.luau +298 -0
- package/examples/game/libs/Keep/Server.luau +251 -0
- package/examples/game/libs/Keep/Store.luau +652 -0
- package/examples/game/libs/Keep/Trade.luau +455 -0
- package/examples/game/libs/Keep/init.luau +205 -0
- package/examples/game/libs/Lens/init.luau +609 -0
- package/examples/game/libs/Mint/init.luau +279 -0
- package/examples/game/libs/Net/init.luau +156 -0
- package/examples/game/libs/Net/src/codec.luau +224 -0
- package/examples/game/libs/Occlude/init.luau +117 -0
- package/examples/game/libs/Pin/init.luau +309 -0
- package/examples/game/libs/Promise/LICENSE +21 -0
- package/examples/game/libs/Promise/_impl/LICENSE +21 -0
- package/examples/game/libs/Promise/_impl/init.lua +1991 -0
- package/examples/game/libs/Promise/init.lua +1990 -0
- package/examples/game/libs/Promise/init.luau +13 -0
- package/examples/game/libs/Promise/types.luau +46 -0
- package/examples/game/libs/Roster/init.luau +686 -0
- package/examples/game/libs/SOURCES.md +31 -0
- package/examples/game/libs/Shift/init.luau +238 -0
- package/examples/game/libs/Spark/init.luau +487 -0
- package/examples/game/libs/Stage/init.luau +178 -0
- package/examples/game/libs/Sweep/init.luau +259 -0
- package/examples/game/libs/Trace/init.luau +213 -0
- package/examples/game/libs/Ward/init.luau +211 -0
- package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau +29 -0
- package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau.map.json +13 -0
- package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau +83 -0
- package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau +18 -0
- package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau +14 -0
- package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau +15 -0
- package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau +50 -0
- package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau.map.json +13 -0
- package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau +12 -0
- package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau.map.json +13 -0
- package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau +16 -0
- package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau.map.json +13 -0
- package/examples/game/src/ReplicatedStorage/Shared/Net/Net.clh +26 -0
- package/examples/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
- package/examples/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
- package/examples/game/stylua.toml +9 -0
- package/generated/api/build-profile.js +115 -0
- package/generated/api/cache.js +44 -0
- package/generated/api/coverage.js +32 -0
- package/generated/api/diff.js +125 -0
- package/generated/api/generators/clpp-headers.js +353 -0
- package/generated/api/generators/docs-reference.js +7 -0
- package/generated/api/generators/lsp-index.js +81 -0
- package/generated/api/generators/luau-defs.js +94 -0
- package/generated/api/ide.js +76 -0
- package/generated/api/identifier.js +47 -0
- package/generated/api/index.js +324 -0
- package/generated/api/loader.js +57 -0
- package/generated/api/merge.js +88 -0
- package/generated/api/model.js +5 -0
- package/generated/api/normalize.js +231 -0
- package/generated/api/overrides-validate.js +58 -0
- package/generated/api/perf.js +12 -0
- package/generated/api/registry.js +136 -0
- package/generated/api/release.js +44 -0
- package/generated/api/resolver.js +250 -0
- package/generated/api/sources/aux-types-diff.js +75 -0
- package/generated/api/sources/client-tracker.js +11 -0
- package/generated/api/sources/creator-docs.js +42 -0
- package/generated/api/sources/luau-types.js +34 -0
- package/generated/api/sources/mini-dump.js +17 -0
- package/generated/api/sources/studio-api.js +8 -0
- package/generated/api/sources/studio-apiv2.js +11 -0
- package/generated/api/sources/studio-full-api.js +8 -0
- package/generated/api/studio-smoke.js +80 -0
- package/generated/api/type-parse.js +49 -0
- package/generated/api/understander.js +51 -0
- package/generated/api/validate.js +135 -0
- package/generated/api-cli.js +421 -0
- package/generated/cli.js +16 -5
- package/generated/clpp/contract.js +3 -3
- package/generated/clpp/format-luau.js +236 -0
- package/generated/clpp/index.js +13 -1
- package/generated/clpp/modules.js +227 -0
- package/generated/clpp/postprocess.js +86 -5
- package/generated/clpp/rewrite-janitor.js +145 -0
- package/generated/clpp/runner.js +14 -2
- package/generated/compile.js +82 -0
- package/generated/flare/parse.js +12 -1
- package/generated/intellisense.js +57 -1
- package/generated/native/index.js +217 -16
- package/generated/target/authority-check.js +136 -0
- package/generated/target/authority-graph.js +74 -0
- package/generated/target/build-cache.js +112 -0
- package/generated/target/capabilities.js +89 -0
- package/generated/target/capability-profile.js +30 -0
- package/generated/target/component-contracts.js +60 -0
- package/generated/target/context-check.js +160 -0
- package/generated/target/datamodel-check.js +170 -0
- package/generated/target/datamodel-generate.js +74 -0
- package/generated/target/datamodel.js +233 -0
- package/generated/target/diagnostics.js +63 -0
- package/generated/target/doctor.js +152 -0
- package/generated/target/flare-version.js +58 -0
- package/generated/target/get-service.js +69 -0
- package/generated/target/lifetime-check.js +47 -0
- package/generated/target/luau-stamp.js +39 -0
- package/generated/target/optimizer-advise.js +88 -0
- package/generated/target/optimizer-apply.js +44 -0
- package/generated/target/optimizer-soa.js +254 -0
- package/generated/target/parallel-check.js +136 -0
- package/generated/target/pgo.js +148 -0
- package/generated/target/project-docs.js +69 -0
- package/generated/target/project-graph.js +71 -0
- package/generated/target/roblox.js +63 -0
- package/generated/target/security-check.js +41 -0
- package/generated/target/source-map.js +25 -0
- package/generated/target/studio-bridge.js +112 -0
- package/generated/utils/project.js +178 -8
- package/generated/utils/rojo-mapper.js +11 -3
- package/include/clpp/datatypes.clh +337 -373
- package/include/clpp/generated/enums.clh +1 -1
- package/include/clpp/generated/instances.clh +41135 -41064
- package/include/clpp/libs/axiom.clh +1 -1
- package/include/clpp/libs/hive.clh +1 -0
- package/include/clpp/libs/keep.clh +2 -0
- package/include/clpp/libs/math.clh +14 -0
- package/include/clpp/libs/spring.clh +17 -0
- package/include/clpp/libs/ward.clh +1 -0
- package/include/clpp/roblox.clh +3 -4
- package/package.json +10 -3
- package/plugins/CluauppNav/Plugin.luau +207 -0
- package/plugins/CluauppNav/ProfileLogger.luau +27 -0
- package/plugins/CluauppNav/README.md +24 -0
- package/runtime/Axiom/init.luau +10 -7
- package/runtime/Coil/init.luau +8 -2
- package/runtime/Crest/init.luau +1 -0
- package/runtime/Flare/init.luau +2 -1
- package/runtime/Gleam/init.luau +15 -4
- package/runtime/Hive/init.luau +36 -14
- package/runtime/Pin/init.luau +5 -2
- package/runtime/Roster/init.luau +2 -0
- package/runtime/Spark/init.luau +3 -0
- package/runtime/Sweep/init.luau +2 -0
- package/runtime/Trace/init.luau +3 -0
- package/runtime/Ward/init.luau +38 -5
- package/scripts/postinstall-editor.js +17 -0
- package/skills/README.md +13 -0
- package/skills/clpp-hive-flare/SKILL.md +79 -0
- package/skills/clpp-language/SKILL.md +123 -0
- package/skills/clpp-language/compiler.md +89 -0
- package/skills/clpp-style/SKILL.md +95 -0
- package/src/api/build-profile.ts +138 -0
- package/src/api/cache.ts +45 -0
- package/src/api/coverage.ts +46 -0
- package/src/api/diff.ts +143 -0
- package/src/api/generators/clpp-headers.ts +377 -0
- package/src/api/generators/docs-reference.ts +11 -0
- package/src/api/generators/lsp-index.ts +106 -0
- package/src/api/generators/luau-defs.ts +98 -0
- package/src/api/ide.ts +87 -0
- package/src/api/identifier.ts +47 -0
- package/src/api/index.ts +269 -0
- package/src/api/loader.ts +60 -0
- package/src/api/merge.ts +126 -0
- package/src/api/model.ts +283 -0
- package/src/api/normalize.ts +257 -0
- package/src/api/overrides-validate.ts +58 -0
- package/src/api/perf.ts +15 -0
- package/src/api/registry.ts +162 -0
- package/src/api/release.ts +47 -0
- package/src/api/resolver.ts +255 -0
- package/src/api/sources/aux-types-diff.ts +81 -0
- package/src/api/sources/client-tracker.ts +10 -0
- package/src/api/sources/creator-docs.ts +37 -0
- package/src/api/sources/luau-types.ts +30 -0
- package/src/api/sources/mini-dump.ts +50 -0
- package/src/api/sources/studio-api.ts +7 -0
- package/src/api/sources/studio-apiv2.ts +10 -0
- package/src/api/sources/studio-full-api.ts +7 -0
- package/src/api/studio-smoke.ts +82 -0
- package/src/api/type-parse.ts +48 -0
- package/src/api/understander.ts +72 -0
- package/src/api/validate.ts +160 -0
- package/src/api-cli.ts +493 -0
- package/src/api.generated.js +37 -22
- package/src/cli.ts +21 -6
- package/src/clpp/contract.ts +34 -3
- package/src/clpp/format-luau.ts +262 -0
- package/src/clpp/index.ts +13 -2
- package/src/clpp/modules.ts +252 -0
- package/src/clpp/postprocess.ts +100 -5
- package/src/clpp/rewrite-janitor.ts +156 -0
- package/src/clpp/runner.ts +14 -2
- package/src/compile.ts +87 -0
- package/src/flare/parse.ts +14 -1
- package/src/flare/types.ts +2 -0
- package/src/intellisense.ts +58 -1
- package/src/native/index.ts +225 -16
- package/src/target/authority-check.ts +162 -0
- package/src/target/authority-graph.ts +80 -0
- package/src/target/build-cache.ts +129 -0
- package/src/target/capabilities.ts +115 -0
- package/src/target/capability-profile.ts +25 -0
- package/src/target/component-contracts.ts +64 -0
- package/src/target/context-check.ts +177 -0
- package/src/target/datamodel-check.ts +188 -0
- package/src/target/datamodel-generate.ts +78 -0
- package/src/target/datamodel.ts +261 -0
- package/src/target/diagnostics.ts +67 -0
- package/src/target/doctor.ts +171 -0
- package/src/target/flare-version.ts +61 -0
- package/src/target/get-service.ts +85 -0
- package/src/target/lifetime-check.ts +45 -0
- package/src/target/luau-stamp.ts +33 -0
- package/src/target/optimizer-advise.ts +93 -0
- package/src/target/optimizer-apply.ts +63 -0
- package/src/target/optimizer-soa.ts +270 -0
- package/src/target/parallel-check.ts +135 -0
- package/src/target/pgo.ts +157 -0
- package/src/target/project-docs.ts +68 -0
- package/src/target/project-graph.ts +75 -0
- package/src/target/roblox.ts +78 -0
- package/src/target/security-check.ts +40 -0
- package/src/target/source-map.ts +36 -0
- package/src/target/studio-bridge.ts +140 -0
- package/src/types.ts +14 -0
- package/src/utils/project.ts +183 -9
- package/src/utils/rojo-mapper.ts +12 -3
- package/stylua.toml +9 -0
- package/templates/game/.vscode/settings.json +7 -1
- package/templates/game/include/clpp/datatypes.clh +337 -373
- package/templates/game/include/clpp/generated/enums.clh +1 -1
- package/templates/game/include/clpp/generated/instances.clh +41135 -41064
- package/templates/game/include/clpp/libs/axiom.clh +1 -1
- package/templates/game/include/clpp/libs/ward.clh +1 -0
- package/templates/game/include/clpp/roblox.clh +3 -4
- package/templates/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
- package/templates/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
- package/templates/game/stylua.toml +9 -0
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
--!optimize 2
|
|
2
|
+
--!strict
|
|
3
|
+
-- Crest — topbar icons (TopbarPlus successor), Gleam-friendly.
|
|
4
|
+
|
|
5
|
+
local GuiService = game:GetService("GuiService")
|
|
6
|
+
local Players = game:GetService("Players")
|
|
7
|
+
local RunService = game:GetService("RunService")
|
|
8
|
+
local StarterGui = game:GetService("StarterGui")
|
|
9
|
+
local Workspace = game:GetService("Workspace")
|
|
10
|
+
|
|
11
|
+
local Crest = {}
|
|
12
|
+
Crest.__index = Crest
|
|
13
|
+
|
|
14
|
+
export type Crest = typeof(setmetatable(
|
|
15
|
+
{} :: {
|
|
16
|
+
_button: ImageButton,
|
|
17
|
+
_label: TextLabel,
|
|
18
|
+
_notice: Frame,
|
|
19
|
+
_selected: boolean,
|
|
20
|
+
_items: { GuiObject },
|
|
21
|
+
_events: { [string]: { (...any) -> () } },
|
|
22
|
+
_autoDeselect: boolean,
|
|
23
|
+
_idleColor: Color3,
|
|
24
|
+
_activeColor: Color3,
|
|
25
|
+
_alive: boolean,
|
|
26
|
+
},
|
|
27
|
+
Crest
|
|
28
|
+
))
|
|
29
|
+
|
|
30
|
+
local orderCounter = 0
|
|
31
|
+
local host: ScreenGui? = nil
|
|
32
|
+
local icons: { Crest } = {}
|
|
33
|
+
local insetConn: RBXScriptConnection? = nil
|
|
34
|
+
local viewportConn: RBXScriptConnection? = nil
|
|
35
|
+
|
|
36
|
+
local ICON = 44
|
|
37
|
+
local GAP = 6
|
|
38
|
+
|
|
39
|
+
local function isClient(): boolean
|
|
40
|
+
return RunService:IsClient()
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
local function readInset(): (number, number, number)
|
|
44
|
+
local top = 8
|
|
45
|
+
local height = ICON
|
|
46
|
+
local left = 12
|
|
47
|
+
local ok, rect = pcall(function()
|
|
48
|
+
return (GuiService :: any).TopbarInset
|
|
49
|
+
end)
|
|
50
|
+
if ok and typeof(rect) == "Rect" then
|
|
51
|
+
top = rect.Min.Y
|
|
52
|
+
if rect.Height > 0 then
|
|
53
|
+
height = rect.Height
|
|
54
|
+
end
|
|
55
|
+
else
|
|
56
|
+
top = GuiService:GetGuiInset().Y
|
|
57
|
+
end
|
|
58
|
+
if height < ICON then
|
|
59
|
+
top = math.max(0, top - math.floor((ICON - height) / 2))
|
|
60
|
+
end
|
|
61
|
+
return left, top, height
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
local function layoutHost()
|
|
65
|
+
local screen = host
|
|
66
|
+
if not screen then
|
|
67
|
+
return
|
|
68
|
+
end
|
|
69
|
+
local leftPad, top, _height = readInset()
|
|
70
|
+
local left = screen:FindFirstChild("Left")
|
|
71
|
+
local mid = screen:FindFirstChild("Mid")
|
|
72
|
+
local right = screen:FindFirstChild("Right")
|
|
73
|
+
if left and left:IsA("Frame") then
|
|
74
|
+
left.Position = UDim2.fromOffset(leftPad, top)
|
|
75
|
+
left.Size = UDim2.new(0.4, 0, 0, ICON)
|
|
76
|
+
end
|
|
77
|
+
if mid and mid:IsA("Frame") then
|
|
78
|
+
mid.AnchorPoint = Vector2.new(0.5, 0)
|
|
79
|
+
mid.Position = UDim2.new(0.5, 0, 0, top)
|
|
80
|
+
mid.Size = UDim2.new(0.4, 0, 0, ICON)
|
|
81
|
+
end
|
|
82
|
+
if right and right:IsA("Frame") then
|
|
83
|
+
right.AnchorPoint = Vector2.new(1, 0)
|
|
84
|
+
right.Position = UDim2.new(1, -leftPad, 0, top)
|
|
85
|
+
right.Size = UDim2.new(0.4, 0, 0, ICON)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
local function watchInset()
|
|
90
|
+
if insetConn then
|
|
91
|
+
return
|
|
92
|
+
end
|
|
93
|
+
pcall(function()
|
|
94
|
+
insetConn = (GuiService :: any):GetPropertyChangedSignal("TopbarInset"):Connect(layoutHost)
|
|
95
|
+
end)
|
|
96
|
+
local camera = Workspace.CurrentCamera
|
|
97
|
+
if camera and not viewportConn then
|
|
98
|
+
viewportConn = camera:GetPropertyChangedSignal("ViewportSize"):Connect(layoutHost)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
local function makeStrip(name: string, align: Enum.HorizontalAlignment): Frame
|
|
103
|
+
local list = Instance.new("Frame")
|
|
104
|
+
list.Name = name
|
|
105
|
+
list.BackgroundTransparency = 1
|
|
106
|
+
list.Size = UDim2.new(0.4, 0, 0, ICON)
|
|
107
|
+
local layout = Instance.new("UIListLayout")
|
|
108
|
+
layout.FillDirection = Enum.FillDirection.Horizontal
|
|
109
|
+
layout.HorizontalAlignment = align
|
|
110
|
+
layout.VerticalAlignment = Enum.VerticalAlignment.Center
|
|
111
|
+
layout.Padding = UDim.new(0, GAP)
|
|
112
|
+
layout.SortOrder = Enum.SortOrder.LayoutOrder
|
|
113
|
+
layout.Parent = list
|
|
114
|
+
return list
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
local function ensureHost(): ScreenGui?
|
|
118
|
+
if not isClient() then
|
|
119
|
+
return nil
|
|
120
|
+
end
|
|
121
|
+
if host and host.Parent then
|
|
122
|
+
return host
|
|
123
|
+
end
|
|
124
|
+
local player = Players.LocalPlayer
|
|
125
|
+
if not player then
|
|
126
|
+
return nil
|
|
127
|
+
end
|
|
128
|
+
local gui = player:FindFirstChildOfClass("PlayerGui")
|
|
129
|
+
if not gui then
|
|
130
|
+
gui = player:WaitForChild("PlayerGui", 8) :: PlayerGui?
|
|
131
|
+
end
|
|
132
|
+
if not gui then
|
|
133
|
+
return nil
|
|
134
|
+
end
|
|
135
|
+
local screen = Instance.new("ScreenGui")
|
|
136
|
+
screen.Name = "Crest"
|
|
137
|
+
screen.IgnoreGuiInset = true
|
|
138
|
+
screen.ResetOnSpawn = false
|
|
139
|
+
screen.DisplayOrder = 1000
|
|
140
|
+
screen.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
|
141
|
+
screen.Parent = gui
|
|
142
|
+
makeStrip("Left", Enum.HorizontalAlignment.Left).Parent = screen
|
|
143
|
+
makeStrip("Mid", Enum.HorizontalAlignment.Center).Parent = screen
|
|
144
|
+
makeStrip("Right", Enum.HorizontalAlignment.Right).Parent = screen
|
|
145
|
+
host = screen
|
|
146
|
+
layoutHost()
|
|
147
|
+
watchInset()
|
|
148
|
+
return screen
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
local function fire(self: Crest, eventName: string, ...: any)
|
|
152
|
+
local list = self._events[eventName]
|
|
153
|
+
if not list then
|
|
154
|
+
return
|
|
155
|
+
end
|
|
156
|
+
for _, callback in list do
|
|
157
|
+
callback(...)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
function Crest.new(): Crest
|
|
162
|
+
orderCounter += 1
|
|
163
|
+
local screen = ensureHost()
|
|
164
|
+
local button = Instance.new("ImageButton")
|
|
165
|
+
button.Name = "CrestIcon"
|
|
166
|
+
button.Size = UDim2.fromOffset(ICON, ICON)
|
|
167
|
+
button.BackgroundColor3 = Color3.fromRGB(20, 20, 24)
|
|
168
|
+
button.AutoButtonColor = false
|
|
169
|
+
button.LayoutOrder = orderCounter
|
|
170
|
+
button.BorderSizePixel = 0
|
|
171
|
+
local corner = Instance.new("UICorner")
|
|
172
|
+
corner.CornerRadius = UDim.new(0, 8)
|
|
173
|
+
corner.Parent = button
|
|
174
|
+
local stroke = Instance.new("UIStroke")
|
|
175
|
+
stroke.Name = "Selection"
|
|
176
|
+
stroke.Color = Color3.fromRGB(80, 140, 255)
|
|
177
|
+
stroke.Thickness = 0
|
|
178
|
+
stroke.Parent = button
|
|
179
|
+
local label = Instance.new("TextLabel")
|
|
180
|
+
label.BackgroundTransparency = 1
|
|
181
|
+
label.Size = UDim2.fromScale(1, 1)
|
|
182
|
+
label.TextColor3 = Color3.new(1, 1, 1)
|
|
183
|
+
label.Font = Enum.Font.GothamBold
|
|
184
|
+
label.TextScaled = true
|
|
185
|
+
label.Text = ""
|
|
186
|
+
label.ZIndex = 2
|
|
187
|
+
label.Parent = button
|
|
188
|
+
local notice = Instance.new("Frame")
|
|
189
|
+
notice.Name = "Notice"
|
|
190
|
+
notice.Size = UDim2.fromOffset(10, 10)
|
|
191
|
+
notice.Position = UDim2.new(1, -8, 0, -2)
|
|
192
|
+
notice.BackgroundColor3 = Color3.fromRGB(255, 70, 70)
|
|
193
|
+
notice.Visible = false
|
|
194
|
+
notice.ZIndex = 3
|
|
195
|
+
notice.Parent = button
|
|
196
|
+
local noticeCorner = Instance.new("UICorner")
|
|
197
|
+
noticeCorner.CornerRadius = UDim.new(1, 0)
|
|
198
|
+
noticeCorner.Parent = notice
|
|
199
|
+
if screen then
|
|
200
|
+
button.Parent = screen:FindFirstChild("Left")
|
|
201
|
+
end
|
|
202
|
+
local icon = setmetatable({
|
|
203
|
+
_button = button,
|
|
204
|
+
_label = label,
|
|
205
|
+
_notice = notice,
|
|
206
|
+
_selected = false,
|
|
207
|
+
_items = {} :: { GuiObject },
|
|
208
|
+
_events = {} :: { [string]: { (...any) -> () } },
|
|
209
|
+
_autoDeselect = true,
|
|
210
|
+
_idleColor = Color3.fromRGB(20, 20, 24),
|
|
211
|
+
_activeColor = Color3.fromRGB(40, 90, 180),
|
|
212
|
+
_alive = true,
|
|
213
|
+
}, Crest)
|
|
214
|
+
table.insert(icons, icon)
|
|
215
|
+
button.Activated:Connect(function()
|
|
216
|
+
if not icon._alive then
|
|
217
|
+
return
|
|
218
|
+
end
|
|
219
|
+
if icon._selected then
|
|
220
|
+
icon:deselect()
|
|
221
|
+
else
|
|
222
|
+
icon:select()
|
|
223
|
+
end
|
|
224
|
+
fire(icon, "toggled", icon._selected)
|
|
225
|
+
fire(icon, "Activated")
|
|
226
|
+
end)
|
|
227
|
+
button.MouseEnter:Connect(function()
|
|
228
|
+
fire(icon, "hoverStarted")
|
|
229
|
+
end)
|
|
230
|
+
button.MouseLeave:Connect(function()
|
|
231
|
+
fire(icon, "hoverEnded")
|
|
232
|
+
end)
|
|
233
|
+
return icon
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
function Crest:setName(name: string)
|
|
237
|
+
self._button.Name = name
|
|
238
|
+
return self
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
function Crest:setLabel(text: string)
|
|
242
|
+
self._label.Text = text
|
|
243
|
+
return self
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
function Crest:setImage(image: string)
|
|
247
|
+
self._button.Image = image
|
|
248
|
+
return self
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
function Crest:setEnabled(enabled: boolean)
|
|
252
|
+
self._button.Visible = enabled
|
|
253
|
+
self._button.Active = enabled
|
|
254
|
+
return self
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
function Crest:setOrder(order: number)
|
|
258
|
+
self._button.LayoutOrder = order
|
|
259
|
+
return self
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
function Crest:setWidth(offset: number)
|
|
263
|
+
self._button.Size = UDim2.fromOffset(offset, ICON)
|
|
264
|
+
return self
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
function Crest:align(side: string)
|
|
268
|
+
local screen = host or ensureHost()
|
|
269
|
+
if not screen then
|
|
270
|
+
return self
|
|
271
|
+
end
|
|
272
|
+
local bucket = "Left"
|
|
273
|
+
local lower = string.lower(side)
|
|
274
|
+
if lower == "mid" or lower == "center" or lower == "middle" then
|
|
275
|
+
bucket = "Mid"
|
|
276
|
+
elseif lower == "right" then
|
|
277
|
+
bucket = "Right"
|
|
278
|
+
end
|
|
279
|
+
local frame = screen:FindFirstChild(bucket)
|
|
280
|
+
if frame then
|
|
281
|
+
self._button.Parent = frame
|
|
282
|
+
end
|
|
283
|
+
return self
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
function Crest:setLeft()
|
|
287
|
+
return self:align("left")
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
function Crest:setMid()
|
|
291
|
+
return self:align("mid")
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
function Crest:setRight()
|
|
295
|
+
return self:align("right")
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
function Crest:bindEvent(eventName: string, callback: (...any) -> ())
|
|
299
|
+
local list = self._events[eventName]
|
|
300
|
+
if not list then
|
|
301
|
+
list = {}
|
|
302
|
+
self._events[eventName] = list
|
|
303
|
+
end
|
|
304
|
+
table.insert(list, callback)
|
|
305
|
+
return self
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
function Crest:bindToggleItem(gui: GuiObject)
|
|
309
|
+
table.insert(self._items, gui)
|
|
310
|
+
gui.Visible = self._selected
|
|
311
|
+
return self
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
function Crest:modifyTheme(modifications: any)
|
|
315
|
+
if typeof(modifications) == "table" then
|
|
316
|
+
if modifications.background or modifications.Background then
|
|
317
|
+
self._idleColor = modifications.background or modifications.Background
|
|
318
|
+
if not self._selected then
|
|
319
|
+
self._button.BackgroundColor3 = self._idleColor
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
if modifications.selected or modifications.Selected then
|
|
323
|
+
self._activeColor = modifications.selected or modifications.Selected
|
|
324
|
+
if self._selected then
|
|
325
|
+
self._button.BackgroundColor3 = self._activeColor
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
return self
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
function Crest:setTheme(theme: any)
|
|
333
|
+
return self:modifyTheme(theme)
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
function Crest:notify()
|
|
337
|
+
self._notice.Visible = true
|
|
338
|
+
fire(self, "notified")
|
|
339
|
+
return self
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
function Crest:clearNotices()
|
|
343
|
+
self._notice.Visible = false
|
|
344
|
+
return self
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
function Crest:select()
|
|
348
|
+
if self._selected then
|
|
349
|
+
return self
|
|
350
|
+
end
|
|
351
|
+
if self._autoDeselect then
|
|
352
|
+
for _, other in icons do
|
|
353
|
+
if other ~= self and other._autoDeselect and other._selected then
|
|
354
|
+
other:deselect()
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
self._selected = true
|
|
359
|
+
self._button.BackgroundColor3 = self._activeColor
|
|
360
|
+
local stroke = self._button:FindFirstChild("Selection")
|
|
361
|
+
if stroke and stroke:IsA("UIStroke") then
|
|
362
|
+
stroke.Thickness = 1.5
|
|
363
|
+
end
|
|
364
|
+
for _, gui in self._items do
|
|
365
|
+
gui.Visible = true
|
|
366
|
+
end
|
|
367
|
+
fire(self, "selected")
|
|
368
|
+
fire(self, "viewOpened")
|
|
369
|
+
return self
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
function Crest:deselect()
|
|
373
|
+
if not self._selected then
|
|
374
|
+
return self
|
|
375
|
+
end
|
|
376
|
+
self._selected = false
|
|
377
|
+
self._button.BackgroundColor3 = self._idleColor
|
|
378
|
+
local stroke = self._button:FindFirstChild("Selection")
|
|
379
|
+
if stroke and stroke:IsA("UIStroke") then
|
|
380
|
+
stroke.Thickness = 0
|
|
381
|
+
end
|
|
382
|
+
for _, gui in self._items do
|
|
383
|
+
gui.Visible = false
|
|
384
|
+
end
|
|
385
|
+
fire(self, "deselected")
|
|
386
|
+
fire(self, "viewClosed")
|
|
387
|
+
return self
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
function Crest:autoDeselect(enabled: boolean)
|
|
391
|
+
self._autoDeselect = enabled
|
|
392
|
+
return self
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
function Crest:Destroy()
|
|
396
|
+
self._alive = false
|
|
397
|
+
for index, icon in icons do
|
|
398
|
+
if icon == self then
|
|
399
|
+
table.remove(icons, index)
|
|
400
|
+
break
|
|
401
|
+
end
|
|
402
|
+
end
|
|
403
|
+
self._button:Destroy()
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
Crest.new_ = Crest.new
|
|
407
|
+
Crest.SetLabel = Crest.setLabel
|
|
408
|
+
Crest.SetImage = Crest.setImage
|
|
409
|
+
Crest.SetEnabled = Crest.setEnabled
|
|
410
|
+
Crest.SetName = Crest.setName
|
|
411
|
+
Crest.SetOrder = Crest.setOrder
|
|
412
|
+
Crest.Notify = Crest.notify
|
|
413
|
+
Crest.Select = Crest.select
|
|
414
|
+
Crest.Deselect = Crest.deselect
|
|
415
|
+
Crest.Align = Crest.align
|
|
416
|
+
Crest.BindEvent = Crest.bindEvent
|
|
417
|
+
Crest.BindToggleItem = Crest.bindToggleItem
|
|
418
|
+
Crest.ClearNotices = Crest.clearNotices
|
|
419
|
+
|
|
420
|
+
pcall(function()
|
|
421
|
+
if RunService:IsClient() then
|
|
422
|
+
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
|
|
423
|
+
end
|
|
424
|
+
end)
|
|
425
|
+
|
|
426
|
+
return Crest
|