azul-sync 1.3.0

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.
Files changed (133) hide show
  1. package/.gitattributes +1 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +31 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. package/README.md +142 -0
  5. package/dist/build.d.ts +19 -0
  6. package/dist/build.d.ts.map +1 -0
  7. package/dist/build.js +92 -0
  8. package/dist/build.js.map +1 -0
  9. package/dist/cli.d.ts +3 -0
  10. package/dist/cli.d.ts.map +1 -0
  11. package/dist/cli.js +397 -0
  12. package/dist/cli.js.map +1 -0
  13. package/dist/config.d.ts +26 -0
  14. package/dist/config.d.ts.map +1 -0
  15. package/dist/config.js +105 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/fs/fileWriter.d.ts +100 -0
  18. package/dist/fs/fileWriter.d.ts.map +1 -0
  19. package/dist/fs/fileWriter.js +342 -0
  20. package/dist/fs/fileWriter.js.map +1 -0
  21. package/dist/fs/treeManager.d.ts +84 -0
  22. package/dist/fs/treeManager.d.ts.map +1 -0
  23. package/dist/fs/treeManager.js +365 -0
  24. package/dist/fs/treeManager.js.map +1 -0
  25. package/dist/fs/watcher.d.ts +39 -0
  26. package/dist/fs/watcher.d.ts.map +1 -0
  27. package/dist/fs/watcher.js +120 -0
  28. package/dist/fs/watcher.js.map +1 -0
  29. package/dist/index.d.ts +61 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +349 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/ipc/httpPolling.d.ts +56 -0
  34. package/dist/ipc/httpPolling.d.ts.map +1 -0
  35. package/dist/ipc/httpPolling.js +171 -0
  36. package/dist/ipc/httpPolling.js.map +1 -0
  37. package/dist/ipc/messages.d.ts +112 -0
  38. package/dist/ipc/messages.d.ts.map +1 -0
  39. package/dist/ipc/messages.js +5 -0
  40. package/dist/ipc/messages.js.map +1 -0
  41. package/dist/ipc/server.d.ts +50 -0
  42. package/dist/ipc/server.d.ts.map +1 -0
  43. package/dist/ipc/server.js +168 -0
  44. package/dist/ipc/server.js.map +1 -0
  45. package/dist/pack.d.ts +19 -0
  46. package/dist/pack.d.ts.map +1 -0
  47. package/dist/pack.js +225 -0
  48. package/dist/pack.js.map +1 -0
  49. package/dist/push.d.ts +43 -0
  50. package/dist/push.d.ts.map +1 -0
  51. package/dist/push.js +532 -0
  52. package/dist/push.js.map +1 -0
  53. package/dist/rojo.d.ts +9 -0
  54. package/dist/rojo.d.ts.map +1 -0
  55. package/dist/rojo.js +114 -0
  56. package/dist/rojo.js.map +1 -0
  57. package/dist/snapshot/rojo.d.ts +39 -0
  58. package/dist/snapshot/rojo.d.ts.map +1 -0
  59. package/dist/snapshot/rojo.js +364 -0
  60. package/dist/snapshot/rojo.js.map +1 -0
  61. package/dist/snapshot.d.ts +23 -0
  62. package/dist/snapshot.d.ts.map +1 -0
  63. package/dist/snapshot.js +132 -0
  64. package/dist/snapshot.js.map +1 -0
  65. package/dist/sourcemap/generator.d.ts +78 -0
  66. package/dist/sourcemap/generator.d.ts.map +1 -0
  67. package/dist/sourcemap/generator.js +351 -0
  68. package/dist/sourcemap/generator.js.map +1 -0
  69. package/dist/sourcemap/propertyLoader.d.ts +19 -0
  70. package/dist/sourcemap/propertyLoader.d.ts.map +1 -0
  71. package/dist/sourcemap/propertyLoader.js +131 -0
  72. package/dist/sourcemap/propertyLoader.js.map +1 -0
  73. package/dist/util/id.d.ts +9 -0
  74. package/dist/util/id.d.ts.map +1 -0
  75. package/dist/util/id.js +14 -0
  76. package/dist/util/id.js.map +1 -0
  77. package/dist/util/log.d.ts +13 -0
  78. package/dist/util/log.d.ts.map +1 -0
  79. package/dist/util/log.js +51 -0
  80. package/dist/util/log.js.map +1 -0
  81. package/docs/assets/azul-logo.pdn +0 -0
  82. package/docs/assets/logo-200px.png +0 -0
  83. package/docs/assets/logo.png +0 -0
  84. package/docs/assets/plugin/toolbox.png +0 -0
  85. package/docs/assets/synced.png +0 -0
  86. package/package.json +41 -0
  87. package/plugin/README.md +54 -0
  88. package/plugin/sourcemap.json +264 -0
  89. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/Actor/AzulSync.server.luau +905 -0
  90. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/AzulService.luau +1010 -0
  91. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/Config.luau +29 -0
  92. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/Enums.luau +11 -0
  93. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/CollapsibleTitledSection.luau +214 -0
  94. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/ColorPicker.luau +360 -0
  95. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/CustomTextButton.luau +170 -0
  96. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/DropdownMenu.luau +363 -0
  97. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/HorizontalLine.luau +43 -0
  98. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/ImageButtonWithText.luau +181 -0
  99. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/LabeledCheckbox.luau +295 -0
  100. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/LabeledColorInputPicker.luau +294 -0
  101. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/LabeledMultiChoice.luau +163 -0
  102. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/LabeledNumberInput.luau +312 -0
  103. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/LabeledRadioButton.luau +55 -0
  104. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/LabeledSlider.luau +151 -0
  105. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/LabeledTextInput.luau +222 -0
  106. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/LabeledToggleButton.luau +73 -0
  107. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/StatefulImageButton.luau +125 -0
  108. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/VerticalScrollingFrame.luau +100 -0
  109. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/VerticalSpacer.luau +35 -0
  110. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/Components/VerticallyScalingListFrame.luau +107 -0
  111. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/GuiUtilities.luau +429 -0
  112. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/StudioWidgets/RbxGui.luau +4363 -0
  113. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/UI.luau +425 -0
  114. package/plugin/sync/ReplicatedFirst/AzulCompanionPlugin/WebSocketClient.luau +161 -0
  115. package/src/build.ts +120 -0
  116. package/src/cli.ts +496 -0
  117. package/src/config.ts +170 -0
  118. package/src/fs/fileWriter.ts +414 -0
  119. package/src/fs/treeManager.ts +458 -0
  120. package/src/fs/watcher.ts +142 -0
  121. package/src/index.ts +450 -0
  122. package/src/ipc/httpPolling.ts +214 -0
  123. package/src/ipc/messages.ts +159 -0
  124. package/src/ipc/server.ts +196 -0
  125. package/src/pack.ts +309 -0
  126. package/src/push.ts +726 -0
  127. package/src/snapshot/rojo.ts +467 -0
  128. package/src/snapshot.ts +161 -0
  129. package/src/sourcemap/generator.ts +504 -0
  130. package/src/sourcemap/propertyLoader.ts +195 -0
  131. package/src/util/id.ts +15 -0
  132. package/src/util/log.ts +94 -0
  133. package/tsconfig.json +24 -0
@@ -0,0 +1,181 @@
1
+ ----------------------------------------
2
+ --
3
+ -- ImageButtonWithText.lua
4
+ --
5
+ -- An image button with text underneath. Standardized hover, clicked, and
6
+ -- selected states.
7
+ --
8
+ ----------------------------------------
9
+ GuiUtilities = require("../GuiUtilities")
10
+
11
+ ImageButtonWithTextClass = {}
12
+ ImageButtonWithTextClass.__index = ImageButtonWithTextClass
13
+
14
+ local kSelectedBaseTransparency = 0.2
15
+ local kAdditionalTransparency = 0.1
16
+
17
+ --- ImageButtonWithTextClass constructor.
18
+ --- @param name string -- The name of the button instance.
19
+ --- @param layoutOrder number -- The layout order for the button in a UI layout.
20
+ --- @param icon string -- The asset ID or path for the image icon.
21
+ --- @param text string -- The text label to display on the button.
22
+ --- @param buttonSize UDim2 -- The size of the entire button.
23
+ --- @param imageSize UDim2 -- The size of the image icon inside the button.
24
+ --- @param imagePos UDim2 -- The position of the image icon within the button.
25
+ --- @param textSize UDim2 -- The size of the text label inside the button.
26
+ --- @param textPos UDim2 -- The position of the text label within the button.
27
+ --- @return ImageButtonWithTextClass -- A new instance of ImageButtonWithTextClass.
28
+ function ImageButtonWithTextClass.new(name: string, layoutOrder: number, icon: string, text: string, buttonSize: UDim2, imageSize: UDim2, imagePos: UDim2, textSize: UDim2, textPos: UDim2)
29
+ local self = {}
30
+ setmetatable(self, ImageButtonWithTextClass)
31
+
32
+ self._clickedFunction = nil
33
+
34
+ local button = Instance.new("ImageButton")
35
+ button.Name = name
36
+ button.AutoButtonColor = false
37
+ button.Size = buttonSize
38
+ button.BorderSizePixel = 1
39
+ -- Image-with-text button has translucent background and "selected" background color.
40
+ -- When selected we set transluency to not-zero so we see selected color.
41
+ button.BackgroundTransparency = 1
42
+
43
+ button.LayoutOrder = layoutOrder
44
+
45
+ local buttonIcon = Instance.new("ImageLabel")
46
+ buttonIcon.BackgroundTransparency = 1
47
+ buttonIcon.Image = icon or ""
48
+ buttonIcon.Size = imageSize
49
+ buttonIcon.Position = imagePos
50
+ buttonIcon.Parent = button
51
+
52
+ local textLabel = Instance.new("TextLabel")
53
+ textLabel.BackgroundTransparency = 1
54
+ textLabel.Text = text
55
+ textLabel.Size = textSize
56
+ textLabel.Position = textPos
57
+ textLabel.TextScaled = true
58
+ textLabel.Font = Enum.Font.SourceSans
59
+ textLabel.Parent = button
60
+
61
+ GuiUtilities.syncGuiElementFontColor(textLabel)
62
+
63
+ local uiTextSizeConstraint = Instance.new("UITextSizeConstraint")
64
+ -- Spec asks for fontsize of 12 pixels, but in Roblox the text font sizes look smaller than the mock
65
+ --Note: For this font the Roblox text size is 25.7% larger than the design spec.
66
+ uiTextSizeConstraint.MaxTextSize = 15
67
+ uiTextSizeConstraint.Parent = textLabel
68
+
69
+ self._button = button
70
+ self._clicked = false
71
+ self._hovered = false
72
+ self._selected = false
73
+
74
+ button.InputBegan:Connect(function(input)
75
+ if (input.UserInputType == Enum.UserInputType.MouseMovement) then
76
+ self._hovered = true
77
+ self:_UpdateButtonVisual()
78
+ end
79
+ end)
80
+
81
+
82
+ button.InputEnded:Connect(function(input)
83
+ if (input.UserInputType == Enum.UserInputType.MouseMovement) then
84
+ self._hovered = false
85
+ self._clicked = false
86
+ self:_UpdateButtonVisual()
87
+ end
88
+ end)
89
+
90
+ button.MouseButton1Down:Connect(function()
91
+ self._clicked = true
92
+ self:_UpdateButtonVisual()
93
+ end)
94
+
95
+ button.MouseButton1Up:Connect(function()
96
+ self._clicked = false
97
+ self:_UpdateButtonVisual()
98
+ end)
99
+
100
+ button.Activated:Connect(function (inputObject, timesPressed)
101
+ if self._clickedFunction then
102
+ self._clickedFunction(inputObject, timesPressed)
103
+ end
104
+ end)
105
+
106
+ local function updateButtonVisual()
107
+ self:_UpdateButtonVisual()
108
+ end
109
+ GuiUtilities.BindThemeChanged(updateButtonVisual)
110
+
111
+ self:_UpdateButtonVisual()
112
+
113
+ return self
114
+ end
115
+
116
+ function ImageButtonWithTextClass:_UpdateButtonVisual()
117
+ -- Possibilties:
118
+ if (self._clicked) then
119
+ -- This covers 'clicked and selected' or 'clicked'
120
+ self._button.BackgroundColor3 = GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.Button,
121
+ Enum.StudioStyleGuideModifier.Selected)
122
+ self._button.BorderColor3 = GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.Border,
123
+ Enum.StudioStyleGuideModifier.Selected)
124
+ if (self._selected) then
125
+ self._button.BackgroundTransparency = GuiUtilities.kButtonBackgroundIntenseTransparency
126
+ else
127
+ self._button.BackgroundTransparency = GuiUtilities.kButtonBackgroundTransparency
128
+ end
129
+ elseif (self._hovered) then
130
+ -- This covers 'hovered and selected' or 'hovered'
131
+ self._button.BackgroundColor3 = GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.Button,
132
+ Enum.StudioStyleGuideModifier.Hover)
133
+ self._button.BorderColor3 = GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.Border,
134
+ Enum.StudioStyleGuideModifier.Hover)
135
+ if (self._selected) then
136
+ self._button.BackgroundTransparency = GuiUtilities.kButtonBackgroundIntenseTransparency
137
+ else
138
+ self._button.BackgroundTransparency = GuiUtilities.kButtonBackgroundTransparency
139
+ end
140
+ elseif (self._selected) then
141
+ -- This covers 'selected'
142
+ self._button.BackgroundColor3 = GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.Button,
143
+ Enum.StudioStyleGuideModifier.Selected)
144
+ self._button.BorderColor3 = GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.Border,
145
+ Enum.StudioStyleGuideModifier.Selected)
146
+ self._button.BackgroundTransparency = GuiUtilities.kButtonBackgroundTransparency
147
+ else
148
+ -- This covers 'no special state'
149
+ self._button.BackgroundColor3 = GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.Button)
150
+ self._button.BorderColor3 = GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.Border)
151
+ self._button.BackgroundTransparency = 1
152
+ end
153
+ end
154
+
155
+ --- Returns the internal ImageButton instance.
156
+ --- @return ImageButton -- The ImageButton associated with this class instance.
157
+ function ImageButtonWithTextClass:GetButton()
158
+ return self._button
159
+ end
160
+
161
+ --- Sets the selected state of the button and updates its visual appearance.
162
+ --- @param selected boolean -- Whether the button should be marked as selected.
163
+ function ImageButtonWithTextClass:SetSelected(selected)
164
+ self._selected = selected
165
+ self:_UpdateButtonVisual()
166
+ end
167
+
168
+ --- Returns whether the button is currently selected.
169
+ --- @return boolean -- True if the button is selected; false otherwise.
170
+ function ImageButtonWithTextClass:GetSelected()
171
+ return self._selected
172
+ end
173
+
174
+ --- Sets the function to be called when the button is clicked.
175
+ --- @param cf (inputObject: InputObject, timesPressed: number) -> () -- A callback function or nil to remove the function.
176
+ function ImageButtonWithTextClass:SetClickedFunction(cf: (inputObject: InputObject, timesPressed: number) -> () | nil)
177
+ self._clickedFunction = cf
178
+ end
179
+
180
+
181
+ return ImageButtonWithTextClass
@@ -0,0 +1,295 @@
1
+ ----------------------------------------
2
+ --
3
+ -- LabeledCheckbox.lua
4
+ --
5
+ -- Creates a frame containing a label and a checkbox.
6
+ --
7
+ ----------------------------------------
8
+ GuiUtilities = require("../GuiUtilities")
9
+
10
+ local kCheckboxWidth = GuiUtilities.kCheckboxWidth
11
+
12
+ local kMinTextSize = 14
13
+ local kMinHeight = 24
14
+ local kMinLabelWidth = GuiUtilities.kCheckboxMinLabelWidth
15
+ local kMinMargin = GuiUtilities.kCheckboxMinMargin
16
+ local kMinButtonWidth = kCheckboxWidth
17
+ local kStandardButtonPos = UDim2.new(0, GuiUtilities.StandardLineLabelLeftMargin, 0.5, 0)
18
+ local kStandardLabelPos = UDim2.new(
19
+ 0,
20
+ GuiUtilities.StandardLineLabelLeftMargin + kCheckboxWidth + kMinMargin,
21
+ 0.5,
22
+ GuiUtilities.kTextVerticalFudge
23
+ )
24
+ local kStandardLabelSize = UDim2.new(1, -(GuiUtilities.StandardLineLabelLeftMargin + kCheckboxWidth + kMinMargin), 1, 0)
25
+
26
+ local kMinLabelSize = UDim2.new(0, kMinLabelWidth, 0, kMinHeight)
27
+ local kMinLabelPos = UDim2.new(0, kMinButtonWidth + kMinMargin, 0, kMinHeight / 2)
28
+
29
+ local kMinButtonSize = UDim2.new(0, kMinButtonWidth, 0, kMinButtonWidth)
30
+ local kMinButtonPos = UDim2.new(0, 0, 0, kMinHeight / 2)
31
+
32
+ local kCheckImageWidth = 8
33
+ local kMinCheckImageWidth = kCheckImageWidth
34
+
35
+ local _kCheckImageSize = UDim2.new(0, kCheckImageWidth, 0, kCheckImageWidth)
36
+ local kMinCheckImageSize = UDim2.new(0, kMinCheckImageWidth, 0, kMinCheckImageWidth)
37
+
38
+ local kDisabledCheckImage = "rbxasset://textures/DeveloperFramework/checkbox_unchecked_dark.png"
39
+ local kEnabledCheckImageLight = "rbxasset://textures/PluginManagement/checked_light.png"
40
+ local kEnabledCheckImageDark = "rbxasset://textures/PluginManagement/checked_dark.png"
41
+ local kCheckboxFrameImage = kDisabledCheckImage
42
+
43
+ LabeledCheckboxClass = {}
44
+ LabeledCheckboxClass.__index = LabeledCheckboxClass
45
+
46
+ LabeledCheckboxClass.kMinFrameSize = UDim2.new(0, kMinLabelWidth + kMinMargin + kMinButtonWidth, 0, kMinHeight)
47
+
48
+ --- LabeledCheckboxClass constructor.
49
+ --- @param nameSuffix string -- Suffix to append to the checkbox's name for uniqueness.
50
+ --- @param labelText string -- Text to display next to the checkbox.
51
+ --- @param initValue boolean -- Initial checked state of the checkbox.
52
+ --- @param initDisabled boolean -- Whether the checkbox should be initially disabled.
53
+ --- @return LabeledCheckboxClass -- A new instance of the labeled checkbox class.
54
+ function LabeledCheckboxClass.new(nameSuffix: string, labelText: string, initValue: boolean, initDisabled: boolean)
55
+ local self = {}
56
+ setmetatable(self, LabeledCheckboxClass)
57
+
58
+ initValue = not not initValue
59
+ initDisabled = not not initDisabled
60
+
61
+ local frame = GuiUtilities.MakeStandardFixedHeightFrame("CBF" .. nameSuffix)
62
+
63
+ local fullBackgroundButton = Instance.new("TextButton")
64
+ fullBackgroundButton.Name = "FullBackground"
65
+ fullBackgroundButton.Parent = frame
66
+ fullBackgroundButton.BackgroundTransparency = 1
67
+ fullBackgroundButton.Size = UDim2.new(1, 0, 1, 0)
68
+ fullBackgroundButton.Position = UDim2.new(0, 0, 0, 0)
69
+ fullBackgroundButton.Text = ""
70
+
71
+ local label = GuiUtilities.MakeStandardPropertyLabel(labelText, true)
72
+ label.Parent = fullBackgroundButton
73
+ label.Position = kStandardLabelPos
74
+ label.Size = kStandardLabelSize
75
+ label.TextXAlignment = Enum.TextXAlignment.Left
76
+
77
+ local button = Instance.new("ImageButton")
78
+ button.Name = "Button"
79
+ button.Size = UDim2.new(0, kCheckboxWidth, 0, kCheckboxWidth)
80
+ button.AnchorPoint = Vector2.new(0, 0.5)
81
+ button.BackgroundTransparency = 1
82
+ button.Position = kStandardButtonPos
83
+ button.Parent = fullBackgroundButton
84
+ button.Image = kCheckboxFrameImage
85
+ button.BorderSizePixel = 0
86
+ button.AutoButtonColor = false
87
+
88
+ local checkImage = Instance.new("ImageLabel")
89
+ checkImage.Name = "CheckImage"
90
+ checkImage.Parent = button
91
+ checkImage.Image = kEnabledCheckImageLight
92
+ checkImage.Visible = false
93
+ checkImage.Size = UDim2.new(1, 3, 1, 3)
94
+ checkImage.AnchorPoint = Vector2.new(0.5, 0.5)
95
+ checkImage.Position = UDim2.new(0.5, 0, 0.5, 0)
96
+ checkImage.BackgroundTransparency = 1
97
+ checkImage.BorderSizePixel = 0
98
+
99
+ self._frame = frame
100
+ self._button = button
101
+ self._label = label
102
+ self._checkImage = checkImage
103
+ self._fullBackgroundButton = fullBackgroundButton
104
+ self._useDisabledOverride = false
105
+ self._disabledOverride = false
106
+ self:SetDisabled(initDisabled)
107
+
108
+ self._value = not initValue
109
+ self:SetValue(initValue)
110
+
111
+ self:_SetupMouseClickHandling()
112
+
113
+ GuiUtilities.BindThemeChanged(function()
114
+ self:_UpdateFontColors()
115
+ end)
116
+ GuiUtilities.BindThemeChanged(function()
117
+ self:_UpdateAppearance()
118
+ end)
119
+ self:_UpdateAppearance()
120
+ self:_UpdateFontColors()
121
+
122
+ return self
123
+ end
124
+
125
+ function LabeledCheckboxClass:_MaybeToggleState()
126
+ if not self._disabled then self:SetValue(not self._value) end
127
+ end
128
+
129
+ function LabeledCheckboxClass:_SetupMouseClickHandling()
130
+ self._button.MouseButton1Down:Connect(function()
131
+ self:_MaybeToggleState()
132
+ end)
133
+
134
+ self._fullBackgroundButton.MouseButton1Down:Connect(function()
135
+ self:_MaybeToggleState()
136
+ end)
137
+ end
138
+
139
+ function LabeledCheckboxClass:_HandleUpdatedValue()
140
+ --self._checkImage.Visible = self:GetValue()
141
+
142
+ if not self._checkImage.Visible then self._checkImage.Visible = true end
143
+
144
+ self:_UpdateAppearance()
145
+
146
+ if self._valueChangedFunction then self._valueChangedFunction(self:GetValue()) end
147
+ end
148
+
149
+ function LabeledCheckboxClass:_UpdateFontColors()
150
+ if self._disabled then
151
+ self._label.TextColor3 =
152
+ GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.MainText, Enum.StudioStyleGuideModifier.Disabled)
153
+ else
154
+ self._label.TextColor3 = GuiUtilities.GetThemeColor(Enum.StudioStyleGuideColor.MainText)
155
+ end
156
+ end
157
+
158
+ function LabeledCheckboxClass:_UpdateAppearance()
159
+ if self:GetValue() then
160
+ self._checkImage.Image = if GuiUtilities.GetThemeName() == "Light"
161
+ then kEnabledCheckImageLight
162
+ else kEnabledCheckImageDark
163
+ self._checkImage.ImageColor3 = if GuiUtilities.GetThemeName() == "Light"
164
+ then Color3.fromRGB(219, 219, 219)
165
+ else Color3.new(1, 1, 1)
166
+ else
167
+ self._checkImage.Image = kDisabledCheckImage
168
+ self._checkImage.ImageColor3 = GuiUtilities.GetThemeColor(
169
+ Enum.StudioStyleGuideColor.CheckedFieldBackground,
170
+ Enum.StudioStyleGuideModifier.Default
171
+ )
172
+ end
173
+ self._button.Image = kCheckboxFrameImage
174
+ end
175
+
176
+ --- Enables the small size variant for the checkbox UI.
177
+ --- This adjusts the checkbox to use smaller dimensions, fixed width layout,
178
+ --- and places the checkbox box before the label.
179
+ --- Fixed width instead of flood-fill.
180
+ function LabeledCheckboxClass:UseSmallSize()
181
+ self._label.TextSize = kMinTextSize
182
+ self._label.Size = kMinLabelSize
183
+ self._label.Position = kMinLabelPos
184
+ self._label.TextXAlignment = Enum.TextXAlignment.Left
185
+
186
+ self._button.Size = kMinButtonSize
187
+ self._button.Position = kMinButtonPos
188
+
189
+ self._checkImage.Size = kMinCheckImageSize
190
+
191
+ self._frame.Size = LabeledCheckboxClass.kMinFrameSize
192
+ self._frame.BackgroundTransparency = 1
193
+ end
194
+
195
+ --- Returns the UI frame of the labeled checkbox.
196
+ --- @return Frame -- The main frame containing the checkbox and label.
197
+ function LabeledCheckboxClass:GetFrame(): Frame
198
+ return self._frame
199
+ end
200
+
201
+ --- Returns the current value of the checkbox.
202
+ --- If disabled and an override is active, returns the override value instead.
203
+ --- @return boolean -- The current effective value of the checkbox.
204
+ function LabeledCheckboxClass:GetValue(): boolean
205
+ -- If button is disabled, and we should be using a disabled override,
206
+ -- use the disabled override.
207
+ if self._disabled and self._useDisabledOverride then
208
+ return self._disabledOverride
209
+ else
210
+ return self._value
211
+ end
212
+ end
213
+
214
+ --- Returns the label UI element associated with the checkbox.
215
+ --- @return TextLabel -- The label component of the checkbox.
216
+ function LabeledCheckboxClass:GetLabel(): TextLabel
217
+ return self._label
218
+ end
219
+
220
+ --- Returns the button UI element that represents the checkbox.
221
+ --- @return TextButton -- The button used to toggle the checkbox state.
222
+ function LabeledCheckboxClass:GetButton(): TextButton
223
+ return self._button
224
+ end
225
+
226
+ --- Sets a callback function to be called when the checkbox value changes.
227
+ --- @param vcFunction (newValue: boolean) -> () -- The function to call on value change.
228
+ function LabeledCheckboxClass:SetValueChangedFunction(vcFunction: (newValue: boolean) -> ())
229
+ self._valueChangedFunction = vcFunction
230
+ end
231
+
232
+ --- Sets the disabled state of the checkbox.
233
+ --- Updates visuals and optionally triggers a value update if the state change affects the value.
234
+ --- @param newDisabled boolean -- Whether the checkbox should be disabled.
235
+ function LabeledCheckboxClass:SetDisabled(newDisabled: boolean)
236
+ local originalValue = self:GetValue()
237
+
238
+ if newDisabled ~= self._disabled then
239
+ self._disabled = newDisabled
240
+
241
+ -- if we are no longer disabled, then we don't need or want
242
+ -- the override any more. Forget it.
243
+ if not self._disabled then self._useDisabledOverride = false end
244
+
245
+ if newDisabled then
246
+ self._checkImage.Image = kDisabledCheckImage
247
+ else
248
+ self._checkImage.Image = kEnabledCheckImageLight
249
+ end
250
+
251
+ self:_UpdateFontColors()
252
+ self:_UpdateAppearance()
253
+ self._button.BackgroundColor3 = self._disabled and GuiUtilities.kButtonDisabledBackgroundColor
254
+ or GuiUtilities.kButtonStandardBackgroundColor
255
+ self._button.BorderColor3 = self._disabled and GuiUtilities.kButtonDisabledBorderColor
256
+ or GuiUtilities.kButtonStandardBorderColor
257
+ if self._disabledChangedFunction then self._disabledChangedFunction(self._disabled) end
258
+ end
259
+
260
+ local newValue = self:GetValue()
261
+ if newValue ~= originalValue then self:_HandleUpdatedValue() end
262
+ end
263
+
264
+ --- Returns whether the checkbox is currently disabled.
265
+ --- @return boolean -- True if the checkbox is disabled; otherwise false.
266
+ function LabeledCheckboxClass:GetDisabled(): boolean
267
+ return self._disabled
268
+ end
269
+
270
+ --- Disables the checkbox and forces it to use an override value while disabled.
271
+ --- This is useful for displaying a locked state while maintaining UI logic.
272
+ --- @param overrideValue boolean -- The forced value to use while disabled.
273
+ function LabeledCheckboxClass:DisableWithOverrideValue(overrideValue: boolean)
274
+ -- Disable this checkbox. While disabled, force value to override
275
+ -- value.
276
+ local oldValue = self:GetValue()
277
+ self._useDisabledOverride = true
278
+ self._disabledOverride = overrideValue
279
+ self:SetDisabled(true)
280
+ local newValue = self:GetValue()
281
+ if oldValue ~= newValue then self:_HandleUpdatedValue() end
282
+ end
283
+
284
+ --- Sets the value of the checkbox manually.
285
+ --- Triggers any relevant updates if the value has changed.
286
+ --- @param newValue boolean -- The new value to assign to the checkbox.
287
+ function LabeledCheckboxClass:SetValue(newValue: boolean)
288
+ if newValue ~= self._value then
289
+ self._value = newValue
290
+
291
+ self:_HandleUpdatedValue()
292
+ end
293
+ end
294
+
295
+ return LabeledCheckboxClass