@rbxts/touch-button 1.0.2 → 1.0.4

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.
@@ -1,11 +1,13 @@
1
1
  import { TouchButtonConfig } from '../shared/remotes';
2
2
  export declare class TouchButton {
3
+ static configEditingMode: import("@rbxts/charm").Atom<boolean>;
4
+ static touchButtons: TouchButton[];
5
+ private static initialized;
3
6
  private touchBtn;
4
7
  private name;
5
8
  private defaultConfig;
6
9
  private configUpdateScheduled;
7
- static configEditingMode: import("@rbxts/charm").Atom<boolean>;
8
- static touchButtons: TouchButton[];
10
+ private static init;
9
11
  constructor(options: {
10
12
  name: string;
11
13
  icon: string;
@@ -73,6 +73,7 @@ do
73
73
  end
74
74
  function TouchButton:constructor(options)
75
75
  self.configUpdateScheduled = false
76
+ TouchButton:init()
76
77
  for _1, otherTouchBtn in TouchButton.touchButtons do
77
78
  local _arg0 = otherTouchBtn.name ~= options.name
78
79
  local _arg1 = `A TouchButton with the name {options.name} already exists`
@@ -138,29 +139,6 @@ do
138
139
  touchBtn.Active = true
139
140
  touchBtn.ImageColor3 = EDITING_MODE_BUTTON_COLOR
140
141
  iconImage.ImageColor3 = EDITING_MODE_BUTTON_COLOR
141
- do
142
- local resetBtn = Instance.new("TextButton")
143
- resetBtn.Name = "Reset"
144
- resetBtn.AnchorPoint = Vector2.new(0.5, 0.5)
145
- resetBtn.BackgroundColor3 = Color3.new()
146
- resetBtn.BackgroundTransparency = 0.25
147
- resetBtn.FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json", Enum.FontWeight.Medium, Enum.FontStyle.Normal)
148
- resetBtn.Position = UDim2.fromScale(0.5, 0.5)
149
- resetBtn.Size = UDim2.fromOffset(120, 32)
150
- resetBtn.Text = "Reset Buttons"
151
- resetBtn.TextColor3 = Color3.new(1, 1, 1)
152
- resetBtn.TextSize = 16
153
- resetBtn.Parent = touchGui
154
- editingTrove:add(resetBtn)
155
- local UICorner = Instance.new("UICorner")
156
- UICorner.CornerRadius = UDim.new(0, 5)
157
- UICorner.Parent = resetBtn
158
- resetBtn.MouseButton1Click:Connect(function()
159
- for _1, touchBtn in TouchButton.touchButtons do
160
- touchBtn:resetConfigToDefault()
161
- end
162
- end)
163
- end
164
142
  local resizeBtn = Instance.new("ImageButton")
165
143
  resizeBtn.AnchorPoint = Vector2.new(0.5, 0.5)
166
144
  resizeBtn.BackgroundTransparency = 1
@@ -252,6 +230,41 @@ do
252
230
  local _self = self
253
231
  table.insert(_touchButtons, _self)
254
232
  end
233
+ function TouchButton:init()
234
+ if self.initialized then
235
+ return nil
236
+ end
237
+ self.initialized = true
238
+ local editingTrove = Trove.new()
239
+ effect(function()
240
+ local isEditing = TouchButton.configEditingMode()
241
+ if isEditing then
242
+ local resetBtn = Instance.new("TextButton")
243
+ resetBtn.Name = "Reset"
244
+ resetBtn.AnchorPoint = Vector2.new(0.5, 0.5)
245
+ resetBtn.BackgroundColor3 = Color3.new()
246
+ resetBtn.BackgroundTransparency = 0.25
247
+ resetBtn.FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json", Enum.FontWeight.Medium, Enum.FontStyle.Normal)
248
+ resetBtn.Position = UDim2.fromScale(0.5, 0.5)
249
+ resetBtn.Size = UDim2.fromOffset(120, 32)
250
+ resetBtn.Text = "Reset Buttons"
251
+ resetBtn.TextColor3 = Color3.new(1, 1, 1)
252
+ resetBtn.TextSize = 16
253
+ resetBtn.Parent = touchGui
254
+ editingTrove:add(resetBtn)
255
+ local UICorner = Instance.new("UICorner")
256
+ UICorner.CornerRadius = UDim.new(0, 5)
257
+ UICorner.Parent = resetBtn
258
+ resetBtn.MouseButton1Click:Connect(function()
259
+ for _, touchBtn in TouchButton.touchButtons do
260
+ touchBtn:resetConfigToDefault()
261
+ end
262
+ end)
263
+ else
264
+ editingTrove:clean()
265
+ end
266
+ end)
267
+ end
255
268
  function TouchButton:setIcon(icon)
256
269
  self.touchBtn.Icon.Image = icon
257
270
  end
@@ -296,6 +309,7 @@ do
296
309
  end
297
310
  TouchButton.configEditingMode = atom(false)
298
311
  TouchButton.touchButtons = {}
312
+ TouchButton.initialized = false
299
313
  end
300
314
  return {
301
315
  TouchButton = TouchButton,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/touch-button",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "out/init.lua",
6
6
  "scripts": {