Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Commit d1e99b8

Browse files
committed
Bug fixes.
1 parent 80c4fe3 commit d1e99b8

File tree

3 files changed

+55
-44
lines changed

3 files changed

+55
-44
lines changed

src/SignsInternal/StudioWidgets/LabeledButton.lua

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ local kMinTextSize = 14
1111
local kMinHeight = 24
1212
local kMinLabelWidth = GuiUtilities.kCheckboxMinLabelWidth
1313
local kMinMargin = GuiUtilities.kCheckboxMinMargin
14-
local kMinButtonWidth = kCheckboxWidth;
15-
16-
local kButtonDefaultBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.FilterButtonDefault, Enum.StudioStyleGuideModifier.Default)
17-
local kButtonHoverBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.FilterButtonHover, Enum.StudioStyleGuideModifier.Hover)
18-
local kButtonPressedBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.FilterButtonChecked, Enum.StudioStyleGuideModifier.Pressed)
14+
local kMinButtonWidth = kCheckboxWidth
15+
16+
local kButtonDefaultBackgroundColor = settings().Studio.Theme:GetColor(
17+
Enum.StudioStyleGuideColor.FilterButtonDefault,
18+
Enum.StudioStyleGuideModifier.Default
19+
)
20+
local kButtonHoverBackgroundColor =
21+
settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.FilterButtonHover, Enum.StudioStyleGuideModifier.Hover)
22+
local kButtonPressedBackgroundColor = settings().Studio.Theme:GetColor(
23+
Enum.StudioStyleGuideColor.FilterButtonChecked,
24+
Enum.StudioStyleGuideModifier.Pressed
25+
)
1926

2027
LabeledButtonClass = {}
2128
LabeledButtonClass.__index = LabeledButtonClass
@@ -45,7 +52,7 @@ function LabeledButtonClass.new(nameSuffix, labelText, initValue, initDisabled)
4552
local label = Instance.new("TextButton")
4653
label.Text = labelText
4754
label.RichText = true
48-
label.Name = 'Label'
55+
label.Name = "Label"
4956
label.Font = GuiUtilities.kDefaultFontFace
5057
label.TextSize = GuiUtilities.kDefaultFontSize
5158
label.BackgroundTransparency = 1
@@ -91,19 +98,18 @@ function LabeledButtonClass:_MaybeToggleState()
9198
if not self._disabled then
9299
self:SetValue(not self._value)
93100
end
94-
95101
end
96102

97103
function LabeledButtonClass:_SetupMouseClickHandling()
98104
self._label.InputBegan:Connect(function(input)
99-
if (input.UserInputType == Enum.UserInputType.MouseMovement) then
105+
if input.UserInputType == Enum.UserInputType.MouseMovement then
100106
self._hovered = true
101107
self:_updateCheckboxVisual()
102108
end
103109
end)
104110

105111
self._label.InputEnded:Connect(function(input)
106-
if (input.UserInputType == Enum.UserInputType.MouseMovement) then
112+
if input.UserInputType == Enum.UserInputType.MouseMovement then
107113
self._hovered = false
108114
self._clicked = false
109115
self:_updateCheckboxVisual()
@@ -120,36 +126,45 @@ end
120126
function LabeledButtonClass:_HandleUpdatedValue()
121127
self._button.Visible = self:GetValue()
122128

123-
if (self._valueChangedFunction) then
129+
if self._valueChangedFunction then
124130
self._valueChangedFunction(self:GetValue())
125131
end
126132
end
127133

128134
-- Too buggy with other GuiObjects to be used.
129135
function LabeledButtonClass:_updateCheckboxVisual()
130-
local kButtonDefaultBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.FilterButtonDefault, Enum.StudioStyleGuideModifier.Default)
131-
local kButtonHoverBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.FilterButtonHover, Enum.StudioStyleGuideModifier.Hover)
132-
local kButtonPressedBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.FilterButtonChecked, Enum.StudioStyleGuideModifier.Pressed)
133-
134-
if (self._value) then
136+
local kButtonDefaultBackgroundColor = settings().Studio.Theme:GetColor(
137+
Enum.StudioStyleGuideColor.FilterButtonDefault,
138+
Enum.StudioStyleGuideModifier.Default
139+
)
140+
local kButtonHoverBackgroundColor = settings().Studio.Theme:GetColor(
141+
Enum.StudioStyleGuideColor.FilterButtonHover,
142+
Enum.StudioStyleGuideModifier.Hover
143+
)
144+
local kButtonPressedBackgroundColor = settings().Studio.Theme:GetColor(
145+
Enum.StudioStyleGuideColor.FilterButtonChecked,
146+
Enum.StudioStyleGuideModifier.Pressed
147+
)
148+
149+
if self._value then
135150
self._button.BackgroundColor3 = kButtonPressedBackgroundColor
136-
elseif (self._clicked) then
151+
elseif self._clicked then
137152
self._button.BackgroundColor3 = kButtonPressedBackgroundColor
138-
elseif (self._hovered) then
153+
elseif self._hovered then
139154
self._button.BackgroundColor3 = kButtonHoverBackgroundColor
140155
else
141156
self._button.BackgroundColor3 = kButtonDefaultBackgroundColor
142157
end
143158
end
144159

145160
function LabeledButtonClass:_HandleUpdatedValue()
146-
if (self:GetValue())then
161+
if self:GetValue() then
147162
self._button.BackgroundColor3 = kButtonPressedBackgroundColor
148163
else
149164
self._button.BackgroundColor3 = kButtonDefaultBackgroundColor
150165
end
151166

152-
if (self._valueChangedFunction) then
167+
if self._valueChangedFunction then
153168
self._valueChangedFunction(self:GetValue())
154169
end
155170
end
@@ -159,9 +174,9 @@ function LabeledButtonClass:GetFrame()
159174
end
160175

161176
function LabeledButtonClass:GetValue()
162-
-- If button is disabled, and we should be using a disabled override,
177+
-- If button is disabled, and we should be using a disabled override,
163178
-- use the disabled override.
164-
if (self._disabled and self._useDisabledOverride) then
179+
if self._disabled and self._useDisabledOverride then
165180
return self._disabledOverride
166181
else
167182
return self._value
@@ -176,7 +191,7 @@ function LabeledButtonClass:GetButton()
176191
return self._button
177192
end
178193

179-
function LabeledButtonClass:SetValueChangedFunction(vcFunction)
194+
function LabeledButtonClass:SetValueChangedFunction(vcFunction)
180195
self._valueChangedFunction = vcFunction
181196
end
182197

@@ -188,28 +203,30 @@ function LabeledButtonClass:SetDisabled(newDisabled)
188203
if newDisabled ~= self._disabled then
189204
self._disabled = newDisabled
190205

191-
-- if we are no longer disabled, then we don't need or want
206+
-- if we are no longer disabled, then we don't need or want
192207
-- the override any more. Forget it.
193-
if (not self._disabled) then
208+
if not self._disabled then
194209
self._useDisabledOverride = false
195210
end
196211

197212
self:UpdateFontColors()
198-
self._button.BackgroundColor3 = self._disabled and GuiUtilities.kButtonDisabledBackgroundColor or GuiUtilities.kButtonDefaultBackgroundColor
199-
self._button.BorderColor3 = self._disabled and GuiUtilities.kButtonDisabledBorderColor or GuiUtilities.kButtonDefaultBorderColor
213+
self._button.BackgroundColor3 = self._disabled and GuiUtilities.kButtonDisabledBackgroundColor
214+
or GuiUtilities.kButtonDefaultBackgroundColor
215+
self._button.BorderColor3 = self._disabled and GuiUtilities.kButtonDisabledBorderColor
216+
or GuiUtilities.kButtonDefaultBorderColor
200217
if self._disabledChangedFunction then
201218
self._disabledChangedFunction(self._disabled)
202219
end
203220
end
204221

205222
local newValue = self:GetValue()
206-
if (newValue ~= originalValue) then
223+
if newValue ~= originalValue then
207224
self:_HandleUpdatedValue()
208225
end
209226
end
210227

211228
function LabeledButtonClass:UpdateFontColors()
212-
if self._disabled then
229+
if self._disabled then
213230
self._label.TextColor3 = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.DimmedText)
214231
else
215232
self._label.TextColor3 = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.MainText)
@@ -224,9 +241,9 @@ function LabeledButtonClass:DisableWithOverrideValue(overrideValue)
224241
self._disabledOverride = overrideValue
225242
self:SetDisabled(true)
226243
local newValue = self:GetValue()
227-
if (oldValue ~= newValue) then
244+
if oldValue ~= newValue then
228245
self:_HandleUpdatedValue()
229-
end
246+
end
230247
end
231248

232249
function LabeledButtonClass:GetDisabled()
@@ -235,12 +252,12 @@ end
235252

236253
function LabeledButtonClass:SetValue(newValue)
237254
local newValue = not not newValue
238-
255+
239256
if newValue ~= self._value then
240257
self._value = newValue
241258

242259
self:_HandleUpdatedValue()
243260
end
244261
end
245262

246-
return LabeledButtonClass
263+
return LabeledButtonClass

src/SignsInternal/StudioWidgets/LabeledCheckbox.lua

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ LabeledCheckboxClass.__index = LabeledCheckboxClass
4444

4545
LabeledCheckboxClass.kMinFrameSize = UDim2.new(0, kMinLabelWidth + kMinMargin + kMinButtonWidth, 0, kMinHeight)
4646

47-
function LabeledCheckboxClass.new(nameSuffix, labelText, initValue, initDisabled, wikiLink)
47+
function LabeledCheckboxClass.new(nameSuffix, labelText, initValue, initDisabled, url)
4848
local self = {}
4949
setmetatable(self, LabeledCheckboxClass)
5050

@@ -58,7 +58,7 @@ function LabeledCheckboxClass.new(nameSuffix, labelText, initValue, initDisabled
5858
fullBackgroundButton.Position = UDim2.new(0, 0, 0, 0)
5959
fullBackgroundButton.Text = ""
6060

61-
local label = GuiUtilities.MakeDefaultPropertyLabel(labelText, false, wikiLink)
61+
local label = GuiUtilities.MakeDefaultPropertyLabel(labelText, false, url)
6262
label.Parent = fullBackgroundButton
6363

6464
local button = Instance.new("ImageButton")
@@ -140,26 +140,20 @@ function LabeledCheckboxClass:_SetupMouseClickHandling()
140140
self:_MaybeToggleState()
141141
end)
142142

143-
self._fullBackgroundButton.InputBegan:Connect(function(input)
143+
self._button.InputBegan:Connect(function(input)
144144
if input.UserInputType == Enum.UserInputType.MouseMovement then
145145
self._hovered = true
146146
self:_updateCheckboxVisual()
147147
end
148148
end)
149149

150-
self._fullBackgroundButton.InputEnded:Connect(function(input)
150+
self._button.InputEnded:Connect(function(input)
151151
if input.UserInputType == Enum.UserInputType.MouseMovement then
152152
self._hovered = false
153153
self._clicked = false
154154
self:_updateCheckboxVisual()
155155
end
156156
end)
157-
158-
self._fullBackgroundButton.MouseButton1Down:Connect(function()
159-
self._clicked = true
160-
self:_updateCheckboxVisual()
161-
self:_MaybeToggleState()
162-
end)
163157
end
164158

165159
-- Too buggy with other GuiObjects to be used.

src/SignsInternal/StudioWidgets/LabeledMultiChoice.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LabeledMultiChoiceClass.__index = LabeledMultiChoiceClass
2121
-- each entry must have at least 2 fields:
2222
-- "Id" - a unique (in the scope of choices) string id. Not visible to user.
2323
-- "Text" - user-facing string: the label for the choice.
24-
function LabeledMultiChoiceClass.new(nameSuffix, labelText, choices, initChoiceIndex, wikiLink)
24+
function LabeledMultiChoiceClass.new(nameSuffix, labelText, choices, initChoiceIndex, url)
2525
local self = {}
2626
setmetatable(self, LabeledMultiChoiceClass)
2727

@@ -37,7 +37,7 @@ function LabeledMultiChoiceClass.new(nameSuffix, labelText, choices, initChoiceI
3737
local vsl = VerticallyScalingListFrame.new("MCC_" .. nameSuffix)
3838
vsl:AddBottomPadding()
3939

40-
local titleLabel = GuiUtilities.MakeFrameWithSubSectionLabel("Title", labelText, wikiLink)
40+
local titleLabel = GuiUtilities.MakeFrameWithSubSectionLabel("Title", labelText, url)
4141
vsl:AddChild(titleLabel)
4242

4343
-- Container for cells.

0 commit comments

Comments
 (0)