@rbxts/touch-button 1.0.3 → 1.0.5
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/out/client/touch-button.d.ts +6 -3
- package/out/client/touch-button.luau +38 -32
- package/package.json +38 -38
|
@@ -1,16 +1,19 @@
|
|
|
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
|
|
8
|
-
static touchButtons: TouchButton[];
|
|
10
|
+
private static init;
|
|
9
11
|
constructor(options: {
|
|
10
12
|
name: string;
|
|
11
13
|
icon: string;
|
|
12
14
|
size: UDim2;
|
|
13
15
|
position: UDim2;
|
|
16
|
+
sinkInput?: boolean;
|
|
14
17
|
onPress?: () => void;
|
|
15
18
|
onRelease?: () => void;
|
|
16
19
|
});
|
|
@@ -20,6 +23,6 @@ export declare class TouchButton {
|
|
|
20
23
|
setConfig(config: TouchButtonConfig): void;
|
|
21
24
|
private scheduleConfigUpdate;
|
|
22
25
|
private updateConfig;
|
|
23
|
-
resetConfigToDefault
|
|
26
|
+
private resetConfigToDefault;
|
|
24
27
|
destroy(): void;
|
|
25
28
|
}
|
|
@@ -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`
|
|
@@ -86,7 +87,7 @@ do
|
|
|
86
87
|
local configPromise = remotes.getTouchButtonConfig:request(options.name)
|
|
87
88
|
local touchBtn = Instance.new("ImageButton")
|
|
88
89
|
touchBtn.Name = "TouchButton"
|
|
89
|
-
touchBtn.Active =
|
|
90
|
+
touchBtn.Active = not not options.sinkInput
|
|
90
91
|
touchBtn.Image = "http://www.roblox.com/asset/?id=15340864550"
|
|
91
92
|
touchBtn.ImageColor3 = Color3.fromRGB(255, 255, 255)
|
|
92
93
|
touchBtn.ImageTransparency = 0.5
|
|
@@ -138,8 +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
|
-
end
|
|
143
142
|
local resizeBtn = Instance.new("ImageButton")
|
|
144
143
|
resizeBtn.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
145
144
|
resizeBtn.BackgroundTransparency = 1
|
|
@@ -231,6 +230,41 @@ do
|
|
|
231
230
|
local _self = self
|
|
232
231
|
table.insert(_touchButtons, _self)
|
|
233
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
|
|
234
268
|
function TouchButton:setIcon(icon)
|
|
235
269
|
self.touchBtn.Icon.Image = icon
|
|
236
270
|
end
|
|
@@ -275,36 +309,8 @@ do
|
|
|
275
309
|
end
|
|
276
310
|
TouchButton.configEditingMode = atom(false)
|
|
277
311
|
TouchButton.touchButtons = {}
|
|
312
|
+
TouchButton.initialized = false
|
|
278
313
|
end
|
|
279
|
-
local editingTrove = Trove.new()
|
|
280
|
-
effect(function()
|
|
281
|
-
local isEditing = TouchButton.configEditingMode()
|
|
282
|
-
if isEditing then
|
|
283
|
-
local resetBtn = Instance.new("TextButton")
|
|
284
|
-
resetBtn.Name = "Reset"
|
|
285
|
-
resetBtn.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
286
|
-
resetBtn.BackgroundColor3 = Color3.new()
|
|
287
|
-
resetBtn.BackgroundTransparency = 0.25
|
|
288
|
-
resetBtn.FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json", Enum.FontWeight.Medium, Enum.FontStyle.Normal)
|
|
289
|
-
resetBtn.Position = UDim2.fromScale(0.5, 0.5)
|
|
290
|
-
resetBtn.Size = UDim2.fromOffset(120, 32)
|
|
291
|
-
resetBtn.Text = "Reset Buttons"
|
|
292
|
-
resetBtn.TextColor3 = Color3.new(1, 1, 1)
|
|
293
|
-
resetBtn.TextSize = 16
|
|
294
|
-
resetBtn.Parent = touchGui
|
|
295
|
-
editingTrove:add(resetBtn)
|
|
296
|
-
local UICorner = Instance.new("UICorner")
|
|
297
|
-
UICorner.CornerRadius = UDim.new(0, 5)
|
|
298
|
-
UICorner.Parent = resetBtn
|
|
299
|
-
resetBtn.MouseButton1Click:Connect(function()
|
|
300
|
-
for _, touchBtn in TouchButton.touchButtons do
|
|
301
|
-
touchBtn:resetConfigToDefault()
|
|
302
|
-
end
|
|
303
|
-
end)
|
|
304
|
-
else
|
|
305
|
-
editingTrove:clean()
|
|
306
|
-
end
|
|
307
|
-
end)
|
|
308
314
|
return {
|
|
309
315
|
TouchButton = TouchButton,
|
|
310
316
|
}
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rbxts/touch-button",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "out/init.lua",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "rbxtsc",
|
|
8
|
-
"watch": "rbxtsc -w",
|
|
9
|
-
"prepublishOnly": "npm run build"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"author": "CriShoux",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"type": "commonjs",
|
|
15
|
-
"types": "out/index.d.ts",
|
|
16
|
-
"files": [
|
|
17
|
-
"out",
|
|
18
|
-
"!**/*.tsbuildinfo"
|
|
19
|
-
],
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@rbxts/compiler-types": "^3.0.0-types.0",
|
|
25
|
-
"@rbxts/types": "^1.0.848",
|
|
26
|
-
"roblox-ts": "^3.0.0",
|
|
27
|
-
"typescript": "^5.8.3"
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@rbxts/charm": "^0.10.0",
|
|
31
|
-
"@rbxts/remo": "^1.5.1",
|
|
32
|
-
"@rbxts/roblox-observers": "^1.0.7",
|
|
33
|
-
"@rbxts/services": "^1.5.5",
|
|
34
|
-
"@rbxts/sleitnick-signal": "^1.0.8",
|
|
35
|
-
"@rbxts/t": "^3.2.1",
|
|
36
|
-
"@rbxts/trove": "^1.3.0"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@rbxts/touch-button",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "out/init.lua",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rbxtsc",
|
|
8
|
+
"watch": "rbxtsc -w",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "CriShoux",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"type": "commonjs",
|
|
15
|
+
"types": "out/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"out",
|
|
18
|
+
"!**/*.tsbuildinfo"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@rbxts/compiler-types": "^3.0.0-types.0",
|
|
25
|
+
"@rbxts/types": "^1.0.848",
|
|
26
|
+
"roblox-ts": "^3.0.0",
|
|
27
|
+
"typescript": "^5.8.3"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@rbxts/charm": "^0.10.0",
|
|
31
|
+
"@rbxts/remo": "^1.5.1",
|
|
32
|
+
"@rbxts/roblox-observers": "^1.0.7",
|
|
33
|
+
"@rbxts/services": "^1.5.5",
|
|
34
|
+
"@rbxts/sleitnick-signal": "^1.0.8",
|
|
35
|
+
"@rbxts/t": "^3.2.1",
|
|
36
|
+
"@rbxts/trove": "^1.3.0"
|
|
37
|
+
}
|
|
38
|
+
}
|