-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathTypes.lua
More file actions
494 lines (471 loc) · 12.7 KB
/
Copy pathTypes.lua
File metadata and controls
494 lines (471 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
--!strict
-- GoodSignal Types (...but simpler!)
--- Connection
type Connection<Variant... = ...any> = {
Disconnect: (self: Connection<Variant...>) -> (),
}
--- Signal
type Signal<Variant... = ...any> = {
Connect: (self: Signal<Variant...>, func: (Variant...) -> ()) -> Connection<Variant...>,
Once: (self: Signal<Variant...>, func: (Variant...) -> ()) -> Connection<Variant...>,
Wait: (self: Signal<Variant...>) -> Variant...,
}
----------------------
export type IconState = "Deselected" | "Selected" | "Viewing"
export type Events = "selected" | "deselected" | "toggled" | "viewingStarted" | "viewingEnded" | "notified"
export type Alignment = "Left" | "Center" | "Right"
export type EventSource = "User" | "OneClick" | "AutoDeselect" | "HideParentFeature" | "Overflow"
export type Modification = { any }
type StaticFunctions = {
getIcons: typeof(
--[[
Returns a dictionary of icons where the key is the icon's UID and value the icon.
]]
function(): { Icon }
return (nil :: any) :: { Icon }
end
),
getIcon: typeof(
--[[
Returns an icon of the given name or UID.
]]
function(nameOrUID: string): Icon?
return nil :: any
end
),
setTopbarEnabled: typeof(
--[[
When set to <code>false</code> all TopbarPlus ScreenGuis are hidden.
This does not impact Roblox's Topbar.
]]
function(enabled: boolean)
end
),
modifyBaseTheme: typeof(
--[[
Updates the appearance of all icons.
]]
function(modifications: { Modification })
end
),
setDisplayOrder: typeof(
--[[
Sets the base DisplayOrder of all TopbarPlus ScreenGuis.
]]
function(order: number)
end
),
}
type Methods = {
-- CLASS FUNCTIONS
setName: typeof(
--[[
Sets the name of the Widget instance. This can be used in conjunction with <code>Icon.getIcon(name)</code>
]]
function(self: Icon, name: string): Icon
return nil :: any
end
),
getInstance: typeof(
--[[
Returns the first descendant found within the widget of name <code>instanceName</code>.
]]
function(self: Icon, instanceName: string): Instance?
return (nil :: any) :: Instance?
end
),
modifyTheme: typeof(
--[[
Updates the appearance of the icon.
]]
function(self: Icon, modifications: {Modification} | Modification): Icon
return nil :: any
end
),
modifyChildTheme: typeof(
--[[
Updates the appearance of all icons that are parented to this icon (for example when a menu or dropdown).
]]
function(self: Icon, modifications: { Modification }): Icon
return nil :: any
end
),
setEnabled: typeof(
--[[
When set to <code>false</code> the icon will be disabled and hidden.
]]
function(self: Icon, enabled: boolean): Icon
return nil :: any
end
),
select: typeof(
--[[
Selects the icon (as if it were clicked once).
]]
function(self: Icon): Icon
return nil :: any
end
),
deselect: typeof(
--[[
Deselects the icon (as if it were clicked, then clicked again).
]]
function(self: Icon): Icon
return nil :: any
end
),
notify: typeof(
--[[
Prompts a notice bubble which accumulates the further it is prompted.
If the icon belongs to a dropdown or menu, then the notice will appear on the parent icon when the parent icon is deselected.
]]
function(self: Icon, clearNoticeEvent: Signal?): Icon
return nil :: any
end
),
clearNotices: typeof(
--[[
]]
function(self: Icon): Icon
return nil :: any
end
),
disableOverlay: typeof(
--[[
When set to <code>true</code>, disables the shade effect which appears when the icon is pressed and released.
]]
function(self: Icon, disabled: boolean): Icon
return nil :: any
end
),
setImage: typeof(
--[[
Applies an image to the icon based on the given <code>imageId</code>. <code>imageId</code> can be an assetId or a complete asset string.
]]
function(self: Icon, imageId: string | number, iconState: IconState?): Icon
return nil :: any
end
),
setLabel: typeof(
--[[
]]
function(self: Icon, text: string, iconState: IconState?): Icon
return nil :: any
end
),
setOrder: typeof(
--[[
]]
function(self: Icon, order: number, iconState: IconState?): Icon
return nil :: any
end
),
setCornerRadius: typeof(
--[[
]]
function(self: Icon, udim: UDim2, iconState: IconState?): Icon
return nil :: any
end
),
align: typeof(
--[[
This enables you to set the icon to the <code>"Left"</code> (default), <code>"Center"</code> or <code>"Right"</code> side of the screen.
]]
function(self: Icon, alignment: Alignment?): Icon
return nil :: any
end
),
setWidth: typeof(
--[[
This sets the minimum width the icon can be (it can be larger for instance when setting a long label). The default width is <code>44</code>.
]]
function(self: Icon, minimumSize: number, iconState: IconState?): Icon
return nil :: any
end
),
setImageScale: typeof(
--[[
How large the image is relative to the icon. The default value is <code>0.5</code>.
]]
function(self: Icon, scale: number, iconState: IconState?): Icon
return nil :: any
end
),
setImageRatio: typeof(
--[[
How stretched the image will appear. The default value is <code>1</code> (a perfect square).
]]
function(self: Icon, ratio: number, iconState: IconState?): Icon
return nil :: any
end
),
setTextSize: typeof(
--[[
The size of the icon labels' text. The default value is <code>16</code>.
]]
function(self: Icon, textSize: number, iconState: IconState?): Icon
return nil :: any
end
),
setTextColor: typeof(
--[[
The color of the icon labels' text
]]
function(self: Icon, color: Color3, iconState: IconState?): Icon
return nil :: any
end
),
setTextFont: typeof(
--[[
Sets the labels FontFace.
<code>font</code> can be a font family name (such as <code>"Creepster"</code>),
a font enum (such as <code>Enum.Font.Bangers</code>),
a font ID (such as <code>12187370928</code>),
or font family link (such as <code>"rbxasset://fonts/families/Sarpanch.json"</code>).
]]
function(self: Icon, font: string | Enum.Font, fontWeight: Enum.FontWeight?, fontStyle: Enum.FontSize?, iconState: IconState?): Icon
return nil :: any
end
),
bindToggleItem: typeof(
--[[
Binds a GuiObject or LayerCollector to appear and disappeared when the icon is toggled.
]]
function(self: Icon, guiObjectOrLayerCollector: GuiObject | LayerCollector): Icon
return nil :: any
end
),
unbindToggleItem: typeof(
--[[
Unbinds the given GuiObject or LayerCollector from the toggle.
]]
function(self: Icon, guiObjectOrLayerCollector: GuiObject | LayerCollector): Icon
return nil :: any
end
),
bindEvent: typeof(
--[[
Connects to an icon event with <code>iconEventName</code>.
It's important to remember all event names are in <code>camelCase</code>.
<code>callback</code> is called with arguments <code>(self, ...)</code> when the event is triggered.
]]
function(self: Icon, event: Events, callback: (...any) -> ()): Icon
return nil :: any
end
),
unbindEvent: typeof(
--[[
Unbinds the connection of the associated <code>iconEventName</code>.
]]
function(self: Icon, event: Events): Icon
return nil :: any
end
),
bindSignal: typeof(
--[[
Connects an <code>RBXScriptSignal</code> (such as <code>Touched</code> or <code>Changed</code>) to the icon.
<code>callback</code> is called with arguments <code>(self, ...)</code> when the signal fires.
]]
function(self: Icon, signal: RBXScriptSignal, callback: (...any) -> ()): Icon
return nil :: any
end
),
unbindSignal: typeof(
--[[
Disconnects a signal previously bound with <code>:bindSignal()</code>.
]]
function(self: Icon, signal: RBXScriptSignal): Icon
return nil :: any
end
),
bindToggleKey: typeof(
--[[
Binds a keycode which toggles the icon when pressed.
]]
function(self: Icon, keycode: Enum.KeyCode): Icon
return nil :: any
end
),
unbindToggleKey: typeof(
--[[
Unbinds the given keycode.
]]
function(self: Icon, keycode: Enum.KeyCode): Icon
return nil :: any
end
),
call: typeof(
--[[
Calls the function immediately via <code>task.spawn</code>.
The first argument passed is the icon itself.
This is useful when needing to extend the behaviour of an icon while remaining in the chain.
]]
function(self: Icon, func: (self: Icon) -> (...any), ...: any): Icon
return nil :: any
end
),
addToJanitor: typeof(
--[[
Passes the given userdata to the icons janitor to be destroyed/disconnected on the icons destruction.
If a function is passed, it will be called when the icon is destroyed.
]]
function(self: Icon, userdata: unknown): Icon
return nil :: any
end
),
lock: typeof(
--[[
Prevents the icon being toggled by user-input (such as clicking), however, the icon can still be toggled via localscript using methods such as <code>icon:select()</code>.
]]
function(self: Icon): Icon
return nil :: any
end
),
unlock: typeof(
--[[
Re-enables user-input to toggle the icon again.
]]
function(self: Icon): Icon
return nil :: any
end
),
debounce: typeof(
--[[
Locks the icon, yields for the given time, then unlocks the icon, effectively shorthand for <code>icon:lock() task.wait(seconds) icon:unlock()</code>.
This is useful for applying cooldowns (to prevent an icon from being pressed again) after an icon has been selected or deselected.
]]
function(self: Icon, seconds: number): Icon
return nil :: any
end
),
autoDeselect: typeof(
--[[
When set to <code>true</code> (the default) the icon is deselected when another icon (with autoDeselect enabled) is pressed.
Set to <code>false</code> to prevent the icon being deselected when another icon is selected (a useful behaviour in dropdowns).
]]
function(self: Icon, enabled: boolean?): Icon
return nil :: any
end
),
oneClick: typeof(
--[[
When set to true the icon will automatically deselect when selected.
This creates the effect of a single click button.
]]
function(self: Icon, enabled: boolean?): Icon
return nil :: any
end
),
setCaption: typeof(
--[[
Sets a caption. To remove, pass <code>nil</code> as <code>text</code>.
]]
function(self: Icon, text: string?): Icon
return nil :: any
end
),
setCaptionHint: typeof(
--[[
This customizes the appearance of the caption's hint without having to use <code>icon:bindToggleKey</code>.
]]
function(self: Icon, keyCode: Enum.KeyCode): Icon
return nil :: any
end
),
setDropdown: typeof(
--[[
Creates a vertical dropdown based upon the given table array of icons.
Pass an empty table <code>{}</code> to remove the dropdown.
]]
function(self: Icon, icons: { Icon }): Icon
return nil :: any
end
),
joinDropdown: typeof(
--[[
Joins the dropdown of <code>parentIcon</code>.
This is what <code>icon:setDropdown</code> calls internally on the icons within its array.
]]
function(self: Icon, parent: Icon): Icon
return nil :: any
end
),
setMenu: typeof(
--[[
Creates a horizontal menu based upon the given array of icons.
Pass an empty table <code>{}</code> to remove the menu.
]]
function(self: Icon, icons: { Icon }): Icon
return nil :: any
end
),
setFixedMenu: typeof(
--[[
Creates a menu that is always selected and has it's close button hidden.
Pass an empty table <code>{}</code> to remove the menu.
]]
function(self: Icon, icons: { Icon }): Icon
return nil :: any
end
),
joinMenu: typeof(
--[[
Joins the menu of <code>parentIcon</code>.
This is what <code>icon:setMenu</code> calls internally on the icons within its array.
]]
function(self: Icon, parentIcon: Icon): Icon
return nil :: any
end
),
leave: typeof(
--[[
Unparents an icon from a parentIcon if it belongs to a dropdown or menu.
]]
function(self: Icon): Icon
return nil :: any
end
),
convertLabelToNumberSpinner: typeof(
--[[
Unparents an icon from a parentIcon if it belongs to a dropdown or menu.
]]
function(self: Icon, numberSpinner: any, func: (...any) -> (...any), ...: any): Icon
return nil :: any
end
),
destroy: typeof(
--[[
Clears all connections and destroys all instances associated with the icon.
]]
function(self: Icon): Icon
return nil :: any
end
),
} & StaticFunctions
type Fields = {
-- CLASS PROPERTIES
name: string,
isSelected: boolean,
isEnabled: boolean,
totalNotices: number,
locked: boolean,
-- CLASS EVENTS
selected: Signal<EventSource>,
deselected: Signal<EventSource>,
toggled: Signal<boolean, EventSource>,
viewingStarted: Signal,
viewingEnded: Signal,
notified: Signal,
}
export type Icon = Methods & StaticFunctions --typeof(setmetatable({} :: Fields, MT))
export type StaticIcon = {
new: typeof(
--[[
Constructs an empty <code>32x32</code> icon on the topbar.
]]
function(): Icon
return (nil :: any) :: Icon
end
),
} & StaticFunctions
return {}