@quenty/iris 1.1.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.
- package/CHANGELOG.md +14 -0
- package/LICENSE.md +22 -0
- package/README.md +33 -0
- package/default.project.json +14 -0
- package/package.json +42 -0
- package/src/Shared/Iris.lua +702 -0
- package/src/Shared/iris_API.lua +231 -0
- package/src/Shared/iris_Internal.lua +923 -0
- package/src/Shared/iris_PubTypes.lua +44 -0
- package/src/Shared/iris_Types.lua +674 -0
- package/src/Shared/iris_WidgetTypes.lua +522 -0
- package/src/Shared/iris_config.lua +306 -0
- package/src/Shared/iris_demoWindow.lua +2148 -0
- package/src/Shared/widgets/iris_Button.lua +91 -0
- package/src/Shared/widgets/iris_Checkbox.lua +116 -0
- package/src/Shared/widgets/iris_Combo.lua +498 -0
- package/src/Shared/widgets/iris_Format.lua +141 -0
- package/src/Shared/widgets/iris_Image.lua +156 -0
- package/src/Shared/widgets/iris_Input.lua +1430 -0
- package/src/Shared/widgets/iris_Menu.lua +603 -0
- package/src/Shared/widgets/iris_Plot.lua +642 -0
- package/src/Shared/widgets/iris_RadioButton.lua +127 -0
- package/src/Shared/widgets/iris_Root.lua +148 -0
- package/src/Shared/widgets/iris_Tab.lua +334 -0
- package/src/Shared/widgets/iris_Table.lua +641 -0
- package/src/Shared/widgets/iris_Text.lua +133 -0
- package/src/Shared/widgets/iris_Tree.lua +291 -0
- package/src/Shared/widgets/iris_Window.lua +1158 -0
- package/src/Shared/widgets/iris_widgets.lua +487 -0
- package/src/jest.config.lua +3 -0
- package/src/node_modules.project.json +7 -0
- package/test/default.project.json +25 -0
- package/test/scripts/Server/ServerMain.server.lua +13 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
--!nocheck
|
|
2
|
+
local Types = require(script.Parent.Parent.iris_Types)
|
|
3
|
+
|
|
4
|
+
local widgets = {} :: Types.WidgetUtility
|
|
5
|
+
|
|
6
|
+
return function(Iris: Types.Internal)
|
|
7
|
+
widgets.GuiService = game:GetService("GuiService")
|
|
8
|
+
widgets.RunService = game:GetService("RunService")
|
|
9
|
+
widgets.UserInputService = game:GetService("UserInputService")
|
|
10
|
+
widgets.ContextActionService = game:GetService("ContextActionService")
|
|
11
|
+
widgets.TextService = game:GetService("TextService")
|
|
12
|
+
|
|
13
|
+
widgets.ICONS = {
|
|
14
|
+
BLANK_SQUARE = "rbxassetid://83265623867126",
|
|
15
|
+
RIGHT_POINTING_TRIANGLE = "rbxassetid://105541346271951",
|
|
16
|
+
DOWN_POINTING_TRIANGLE = "rbxassetid://95465797476827",
|
|
17
|
+
MULTIPLICATION_SIGN = "rbxassetid://133890060015237", -- best approximation for a close X which roblox supports, needs to be scaled about 2x
|
|
18
|
+
BOTTOM_RIGHT_CORNER = "rbxassetid://125737344915000", -- used in window resize icon in bottom right
|
|
19
|
+
CHECKMARK = "rbxassetid://109638815494221",
|
|
20
|
+
BORDER = "rbxassetid://133803690460269",
|
|
21
|
+
ALPHA_BACKGROUND_TEXTURE = "rbxassetid://114090016039876", -- used for color4 alpha
|
|
22
|
+
UNKNOWN_TEXTURE = "rbxassetid://95045813476061",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
widgets.IS_STUDIO = widgets.RunService:IsStudio()
|
|
26
|
+
function widgets.getTime()
|
|
27
|
+
-- time() always returns 0 in the context of plugins
|
|
28
|
+
if widgets.IS_STUDIO then
|
|
29
|
+
return os.clock()
|
|
30
|
+
else
|
|
31
|
+
return time()
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
-- acts as an offset where the absolute position of the base frame is not zero, such as IgnoreGuiInset or for stories
|
|
36
|
+
widgets.GuiOffset = if Iris._config.IgnoreGuiInset then -widgets.GuiService:GetGuiInset() else Vector2.zero
|
|
37
|
+
-- the registered mouse position always ignores the topbar, so needs a separate variable offset
|
|
38
|
+
widgets.MouseOffset = if Iris._config.IgnoreGuiInset then Vector2.zero else widgets.GuiService:GetGuiInset()
|
|
39
|
+
|
|
40
|
+
-- the topbar inset changes updates a frame later.
|
|
41
|
+
local connection: RBXScriptConnection
|
|
42
|
+
connection = widgets.GuiService:GetPropertyChangedSignal("TopbarInset"):Once(function()
|
|
43
|
+
widgets.MouseOffset = if Iris._config.IgnoreGuiInset then Vector2.zero else widgets.GuiService:GetGuiInset()
|
|
44
|
+
widgets.GuiOffset = if Iris._config.IgnoreGuiInset then -widgets.GuiService:GetGuiInset() else Vector2.zero
|
|
45
|
+
connection:Disconnect()
|
|
46
|
+
end)
|
|
47
|
+
-- in case the topbar doesn't change, we cancel the event.
|
|
48
|
+
task.delay(5, function()
|
|
49
|
+
connection:Disconnect()
|
|
50
|
+
end)
|
|
51
|
+
|
|
52
|
+
function widgets.getMouseLocation()
|
|
53
|
+
return widgets.UserInputService:GetMouseLocation() - widgets.MouseOffset
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
function widgets.isPosInsideRect(pos: Vector2, rectMin: Vector2, rectMax: Vector2)
|
|
57
|
+
return pos.X >= rectMin.X and pos.X <= rectMax.X and pos.Y >= rectMin.Y and pos.Y <= rectMax.Y
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
function widgets.findBestWindowPosForPopup(refPos: Vector2, size: Vector2, outerMin: Vector2, outerMax: Vector2)
|
|
61
|
+
local CURSOR_OFFSET_DIST = 20
|
|
62
|
+
|
|
63
|
+
if refPos.X + size.X + CURSOR_OFFSET_DIST > outerMax.X then
|
|
64
|
+
if refPos.Y + size.Y + CURSOR_OFFSET_DIST > outerMax.Y then
|
|
65
|
+
-- placed to the top
|
|
66
|
+
refPos += Vector2.new(0, -(CURSOR_OFFSET_DIST + size.Y))
|
|
67
|
+
else
|
|
68
|
+
-- placed to the bottom
|
|
69
|
+
refPos += Vector2.new(0, CURSOR_OFFSET_DIST)
|
|
70
|
+
end
|
|
71
|
+
else
|
|
72
|
+
-- placed to the right
|
|
73
|
+
refPos += Vector2.new(CURSOR_OFFSET_DIST)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
return Vector2.new(
|
|
77
|
+
math.max(math.min(refPos.X + size.X, outerMax.X) - size.X, outerMin.X),
|
|
78
|
+
math.max(math.min(refPos.Y + size.Y, outerMax.Y) - size.Y, outerMin.Y)
|
|
79
|
+
)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
function widgets.getScreenSizeForWindow(thisWidget: Types.Widget) -- possible parents are GuiBase2d, CoreGui, PlayerGui
|
|
83
|
+
if thisWidget.Instance:IsA("GuiBase2d") then
|
|
84
|
+
return thisWidget.Instance.AbsoluteSize
|
|
85
|
+
else
|
|
86
|
+
local rootParent = thisWidget.Instance.Parent
|
|
87
|
+
if rootParent:IsA("GuiBase2d") then
|
|
88
|
+
return rootParent.AbsoluteSize
|
|
89
|
+
else
|
|
90
|
+
if rootParent.Parent:IsA("GuiBase2d") then
|
|
91
|
+
return rootParent.AbsoluteSize
|
|
92
|
+
else
|
|
93
|
+
return workspace.CurrentCamera.ViewportSize
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
function widgets.extend(superClass: Types.WidgetClass, subClass: Types.WidgetClass): Types.WidgetClass
|
|
100
|
+
local newClass = table.clone(superClass)
|
|
101
|
+
for index, value in subClass do
|
|
102
|
+
newClass[index] = value
|
|
103
|
+
end
|
|
104
|
+
return newClass
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
function widgets.UIPadding(Parent: GuiObject, PxPadding: Vector2)
|
|
108
|
+
local UIPaddingInstance = Instance.new("UIPadding")
|
|
109
|
+
UIPaddingInstance.PaddingLeft = UDim.new(0, PxPadding.X)
|
|
110
|
+
UIPaddingInstance.PaddingRight = UDim.new(0, PxPadding.X)
|
|
111
|
+
UIPaddingInstance.PaddingTop = UDim.new(0, PxPadding.Y)
|
|
112
|
+
UIPaddingInstance.PaddingBottom = UDim.new(0, PxPadding.Y)
|
|
113
|
+
UIPaddingInstance.Parent = Parent
|
|
114
|
+
return UIPaddingInstance
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
function widgets.UIListLayout(Parent: GuiObject, FillDirection: Enum.FillDirection, Padding: UDim)
|
|
118
|
+
local UIListLayoutInstance = Instance.new("UIListLayout")
|
|
119
|
+
UIListLayoutInstance.SortOrder = Enum.SortOrder.LayoutOrder
|
|
120
|
+
UIListLayoutInstance.Padding = Padding
|
|
121
|
+
UIListLayoutInstance.FillDirection = FillDirection
|
|
122
|
+
UIListLayoutInstance.Parent = Parent
|
|
123
|
+
return UIListLayoutInstance
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
function widgets.UIStroke(Parent: GuiObject, Thickness: number, Color: Color3, Transparency: number)
|
|
127
|
+
local UIStrokeInstance = Instance.new("UIStroke")
|
|
128
|
+
UIStrokeInstance.Thickness = Thickness
|
|
129
|
+
UIStrokeInstance.Color = Color
|
|
130
|
+
UIStrokeInstance.Transparency = Transparency
|
|
131
|
+
UIStrokeInstance.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
|
|
132
|
+
UIStrokeInstance.LineJoinMode = Enum.LineJoinMode.Round
|
|
133
|
+
UIStrokeInstance.Parent = Parent
|
|
134
|
+
return UIStrokeInstance
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
function widgets.UICorner(Parent: GuiObject, PxRounding: number?)
|
|
138
|
+
local UICornerInstance = Instance.new("UICorner")
|
|
139
|
+
UICornerInstance.CornerRadius = UDim.new(PxRounding and 0 or 1, PxRounding or 0)
|
|
140
|
+
UICornerInstance.Parent = Parent
|
|
141
|
+
return UICornerInstance
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
function widgets.UISizeConstraint(Parent: GuiObject, MinSize: Vector2?, MaxSize: Vector2?)
|
|
145
|
+
local UISizeConstraintInstance = Instance.new("UISizeConstraint")
|
|
146
|
+
UISizeConstraintInstance.MinSize = MinSize or UISizeConstraintInstance.MinSize -- made these optional
|
|
147
|
+
UISizeConstraintInstance.MaxSize = MaxSize or UISizeConstraintInstance.MaxSize
|
|
148
|
+
UISizeConstraintInstance.Parent = Parent
|
|
149
|
+
return UISizeConstraintInstance
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
-- below uses Iris
|
|
153
|
+
|
|
154
|
+
function widgets.applyTextStyle(thisInstance: TextLabel & TextButton & TextBox)
|
|
155
|
+
thisInstance.FontFace = Iris._config.TextFont
|
|
156
|
+
thisInstance.TextSize = Iris._config.TextSize
|
|
157
|
+
thisInstance.TextColor3 = Iris._config.TextColor
|
|
158
|
+
thisInstance.TextTransparency = Iris._config.TextTransparency
|
|
159
|
+
thisInstance.TextXAlignment = Enum.TextXAlignment.Left
|
|
160
|
+
thisInstance.TextYAlignment = Enum.TextYAlignment.Center
|
|
161
|
+
thisInstance.RichText = Iris._config.RichText
|
|
162
|
+
thisInstance.TextWrapped = Iris._config.TextWrapped
|
|
163
|
+
|
|
164
|
+
thisInstance.AutoLocalize = false
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
function widgets.applyInteractionHighlights(
|
|
168
|
+
Property: string,
|
|
169
|
+
Button: GuiButton,
|
|
170
|
+
Highlightee: GuiObject,
|
|
171
|
+
Colors: { [string]: any }
|
|
172
|
+
)
|
|
173
|
+
local exitedButton = false
|
|
174
|
+
widgets.applyMouseEnter(Button, function()
|
|
175
|
+
Highlightee[Property .. "Color3"] = Colors.HoveredColor
|
|
176
|
+
Highlightee[Property .. "Transparency"] = Colors.HoveredTransparency
|
|
177
|
+
|
|
178
|
+
exitedButton = false
|
|
179
|
+
end)
|
|
180
|
+
|
|
181
|
+
widgets.applyMouseLeave(Button, function()
|
|
182
|
+
Highlightee[Property .. "Color3"] = Colors.Color
|
|
183
|
+
Highlightee[Property .. "Transparency"] = Colors.Transparency
|
|
184
|
+
|
|
185
|
+
exitedButton = true
|
|
186
|
+
end)
|
|
187
|
+
|
|
188
|
+
widgets.applyInputBegan(Button, function(input: InputObject)
|
|
189
|
+
if
|
|
190
|
+
not (
|
|
191
|
+
input.UserInputType == Enum.UserInputType.MouseButton1
|
|
192
|
+
or input.UserInputType == Enum.UserInputType.Gamepad1
|
|
193
|
+
)
|
|
194
|
+
then
|
|
195
|
+
return
|
|
196
|
+
end
|
|
197
|
+
Highlightee[Property .. "Color3"] = Colors.ActiveColor
|
|
198
|
+
Highlightee[Property .. "Transparency"] = Colors.ActiveTransparency
|
|
199
|
+
end)
|
|
200
|
+
|
|
201
|
+
widgets.applyInputEnded(Button, function(input: InputObject)
|
|
202
|
+
if
|
|
203
|
+
not (
|
|
204
|
+
input.UserInputType == Enum.UserInputType.MouseButton1
|
|
205
|
+
or input.UserInputType == Enum.UserInputType.Gamepad1
|
|
206
|
+
) or exitedButton
|
|
207
|
+
then
|
|
208
|
+
return
|
|
209
|
+
end
|
|
210
|
+
if input.UserInputType == Enum.UserInputType.MouseButton1 then
|
|
211
|
+
Highlightee[Property .. "Color3"] = Colors.HoveredColor
|
|
212
|
+
Highlightee[Property .. "Transparency"] = Colors.HoveredTransparency
|
|
213
|
+
end
|
|
214
|
+
if input.UserInputType == Enum.UserInputType.Gamepad1 then
|
|
215
|
+
Highlightee[Property .. "Color3"] = Colors.Color
|
|
216
|
+
Highlightee[Property .. "Transparency"] = Colors.Transparency
|
|
217
|
+
end
|
|
218
|
+
end)
|
|
219
|
+
|
|
220
|
+
Button.SelectionImageObject = Iris.SelectionImageObject
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
function widgets.applyInteractionHighlightsWithMultiHighlightee(
|
|
224
|
+
Property: string,
|
|
225
|
+
Button: GuiButton,
|
|
226
|
+
Highlightees: { { GuiObject | { [string]: Color3 | number } } }
|
|
227
|
+
)
|
|
228
|
+
local exitedButton = false
|
|
229
|
+
widgets.applyMouseEnter(Button, function()
|
|
230
|
+
for _, Highlightee in Highlightees do
|
|
231
|
+
Highlightee[1][Property .. "Color3"] = Highlightee[2].HoveredColor
|
|
232
|
+
Highlightee[1][Property .. "Transparency"] = Highlightee[2].HoveredTransparency
|
|
233
|
+
|
|
234
|
+
exitedButton = false
|
|
235
|
+
end
|
|
236
|
+
end)
|
|
237
|
+
|
|
238
|
+
widgets.applyMouseLeave(Button, function()
|
|
239
|
+
for _, Highlightee in Highlightees do
|
|
240
|
+
Highlightee[1][Property .. "Color3"] = Highlightee[2].Color
|
|
241
|
+
Highlightee[1][Property .. "Transparency"] = Highlightee[2].Transparency
|
|
242
|
+
|
|
243
|
+
exitedButton = true
|
|
244
|
+
end
|
|
245
|
+
end)
|
|
246
|
+
|
|
247
|
+
widgets.applyInputBegan(Button, function(input: InputObject)
|
|
248
|
+
if
|
|
249
|
+
not (
|
|
250
|
+
input.UserInputType == Enum.UserInputType.MouseButton1
|
|
251
|
+
or input.UserInputType == Enum.UserInputType.Gamepad1
|
|
252
|
+
)
|
|
253
|
+
then
|
|
254
|
+
return
|
|
255
|
+
end
|
|
256
|
+
for _, Highlightee in Highlightees do
|
|
257
|
+
Highlightee[1][Property .. "Color3"] = Highlightee[2].ActiveColor
|
|
258
|
+
Highlightee[1][Property .. "Transparency"] = Highlightee[2].ActiveTransparency
|
|
259
|
+
end
|
|
260
|
+
end)
|
|
261
|
+
|
|
262
|
+
widgets.applyInputEnded(Button, function(input: InputObject)
|
|
263
|
+
if
|
|
264
|
+
not (
|
|
265
|
+
input.UserInputType == Enum.UserInputType.MouseButton1
|
|
266
|
+
or input.UserInputType == Enum.UserInputType.Gamepad1
|
|
267
|
+
) or exitedButton
|
|
268
|
+
then
|
|
269
|
+
return
|
|
270
|
+
end
|
|
271
|
+
for _, Highlightee in Highlightees do
|
|
272
|
+
if input.UserInputType == Enum.UserInputType.MouseButton1 then
|
|
273
|
+
Highlightee[1][Property .. "Color3"] = Highlightee[2].HoveredColor
|
|
274
|
+
Highlightee[1][Property .. "Transparency"] = Highlightee[2].HoveredTransparency
|
|
275
|
+
end
|
|
276
|
+
if input.UserInputType == Enum.UserInputType.Gamepad1 then
|
|
277
|
+
Highlightee[1][Property .. "Color3"] = Highlightee[2].Color
|
|
278
|
+
Highlightee[1][Property .. "Transparency"] = Highlightee[2].Transparency
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end)
|
|
282
|
+
|
|
283
|
+
Button.SelectionImageObject = Iris.SelectionImageObject
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
function widgets.applyFrameStyle(thisInstance: GuiObject, noPadding: boolean?, noCorner: boolean?)
|
|
287
|
+
-- padding, border, and rounding
|
|
288
|
+
-- optimized to only use what instances are needed, based on style
|
|
289
|
+
local FrameBorderSize = Iris._config.FrameBorderSize
|
|
290
|
+
local FrameRounding = Iris._config.FrameRounding
|
|
291
|
+
thisInstance.BorderSizePixel = 0
|
|
292
|
+
|
|
293
|
+
if FrameBorderSize > 0 then
|
|
294
|
+
widgets.UIStroke(thisInstance, FrameBorderSize, Iris._config.BorderColor, Iris._config.BorderTransparency)
|
|
295
|
+
end
|
|
296
|
+
if FrameRounding > 0 and not noCorner then
|
|
297
|
+
widgets.UICorner(thisInstance, FrameRounding)
|
|
298
|
+
end
|
|
299
|
+
if not noPadding then
|
|
300
|
+
widgets.UIPadding(thisInstance, Iris._config.FramePadding)
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
function widgets.applyButtonClick(thisInstance: GuiButton, callback: () -> ())
|
|
305
|
+
thisInstance.MouseButton1Click:Connect(function()
|
|
306
|
+
callback()
|
|
307
|
+
end)
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
function widgets.applyButtonDown(thisInstance: GuiButton, callback: (x: number, y: number) -> ())
|
|
311
|
+
thisInstance.MouseButton1Down:Connect(function(x: number, y: number)
|
|
312
|
+
local position = Vector2.new(x, y) - widgets.MouseOffset
|
|
313
|
+
callback(position.X, position.Y)
|
|
314
|
+
end)
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
function widgets.applyMouseEnter(thisInstance: GuiObject, callback: (x: number, y: number) -> ())
|
|
318
|
+
thisInstance.MouseEnter:Connect(function(x: number, y: number)
|
|
319
|
+
local position = Vector2.new(x, y) - widgets.MouseOffset
|
|
320
|
+
callback(position.X, position.Y)
|
|
321
|
+
end)
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
function widgets.applyMouseMoved(thisInstance: GuiObject, callback: (x: number, y: number) -> ())
|
|
325
|
+
thisInstance.MouseMoved:Connect(function(x: number, y: number)
|
|
326
|
+
local position = Vector2.new(x, y) - widgets.MouseOffset
|
|
327
|
+
callback(position.X, position.Y)
|
|
328
|
+
end)
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
function widgets.applyMouseLeave(thisInstance: GuiObject, callback: (x: number, y: number) -> ())
|
|
332
|
+
thisInstance.MouseLeave:Connect(function(x: number, y: number)
|
|
333
|
+
local position = Vector2.new(x, y) - widgets.MouseOffset
|
|
334
|
+
callback(position.X, position.Y)
|
|
335
|
+
end)
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
function widgets.applyInputBegan(thisInstance: GuiButton, callback: (input: InputObject) -> ())
|
|
339
|
+
thisInstance.InputBegan:Connect(function(...)
|
|
340
|
+
callback(...)
|
|
341
|
+
end)
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
function widgets.applyInputEnded(thisInstance: GuiButton, callback: (input: InputObject) -> ())
|
|
345
|
+
thisInstance.InputEnded:Connect(function(...)
|
|
346
|
+
callback(...)
|
|
347
|
+
end)
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
function widgets.discardState(thisWidget: Types.StateWidget)
|
|
351
|
+
for _, state in thisWidget.state do
|
|
352
|
+
state.ConnectedWidgets[thisWidget.ID] = nil
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
function widgets.registerEvent(event: string, callback: (...any) -> ())
|
|
357
|
+
table.insert(Iris._initFunctions, function()
|
|
358
|
+
table.insert(Iris._connections, widgets.UserInputService[event]:Connect(callback))
|
|
359
|
+
end)
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
widgets.EVENTS = {
|
|
363
|
+
hover = function(pathToHovered: (thisWidget: Types.Widget) -> GuiObject)
|
|
364
|
+
return {
|
|
365
|
+
["Init"] = function(thisWidget: Types.Widget & Types.Hovered)
|
|
366
|
+
local hoveredGuiObject = pathToHovered(thisWidget)
|
|
367
|
+
widgets.applyMouseEnter(hoveredGuiObject, function()
|
|
368
|
+
thisWidget.isHoveredEvent = true
|
|
369
|
+
end)
|
|
370
|
+
widgets.applyMouseLeave(hoveredGuiObject, function()
|
|
371
|
+
thisWidget.isHoveredEvent = false
|
|
372
|
+
end)
|
|
373
|
+
thisWidget.isHoveredEvent = false
|
|
374
|
+
end,
|
|
375
|
+
["Get"] = function(thisWidget: Types.Widget & Types.Hovered)
|
|
376
|
+
return thisWidget.isHoveredEvent
|
|
377
|
+
end,
|
|
378
|
+
}
|
|
379
|
+
end,
|
|
380
|
+
|
|
381
|
+
click = function(pathToClicked: (thisWidget: Types.Widget) -> GuiButton)
|
|
382
|
+
return {
|
|
383
|
+
["Init"] = function(thisWidget: Types.Widget & Types.Clicked)
|
|
384
|
+
local clickedGuiObject = pathToClicked(thisWidget)
|
|
385
|
+
thisWidget.lastClickedTick = -1
|
|
386
|
+
|
|
387
|
+
widgets.applyButtonClick(clickedGuiObject, function()
|
|
388
|
+
thisWidget.lastClickedTick = Iris._cycleTick + 1
|
|
389
|
+
end)
|
|
390
|
+
end,
|
|
391
|
+
["Get"] = function(thisWidget: Types.Widget & Types.Clicked)
|
|
392
|
+
return thisWidget.lastClickedTick == Iris._cycleTick
|
|
393
|
+
end,
|
|
394
|
+
}
|
|
395
|
+
end,
|
|
396
|
+
|
|
397
|
+
rightClick = function(pathToClicked: (thisWidget: Types.Widget) -> GuiButton)
|
|
398
|
+
return {
|
|
399
|
+
["Init"] = function(thisWidget: Types.Widget & Types.RightClicked)
|
|
400
|
+
local clickedGuiObject = pathToClicked(thisWidget)
|
|
401
|
+
thisWidget.lastRightClickedTick = -1
|
|
402
|
+
|
|
403
|
+
clickedGuiObject.MouseButton2Click:Connect(function()
|
|
404
|
+
thisWidget.lastRightClickedTick = Iris._cycleTick + 1
|
|
405
|
+
end)
|
|
406
|
+
end,
|
|
407
|
+
["Get"] = function(thisWidget: Types.Widget & Types.RightClicked)
|
|
408
|
+
return thisWidget.lastRightClickedTick == Iris._cycleTick
|
|
409
|
+
end,
|
|
410
|
+
}
|
|
411
|
+
end,
|
|
412
|
+
|
|
413
|
+
doubleClick = function(pathToClicked: (thisWidget: Types.Widget) -> GuiButton)
|
|
414
|
+
return {
|
|
415
|
+
["Init"] = function(thisWidget: Types.Widget & Types.DoubleClicked)
|
|
416
|
+
local clickedGuiObject = pathToClicked(thisWidget)
|
|
417
|
+
thisWidget.lastClickedTime = -1
|
|
418
|
+
thisWidget.lastClickedPosition = Vector2.zero
|
|
419
|
+
thisWidget.lastDoubleClickedTick = -1
|
|
420
|
+
|
|
421
|
+
widgets.applyButtonDown(clickedGuiObject, function(x: number, y: number)
|
|
422
|
+
local currentTime = widgets.getTime()
|
|
423
|
+
local isTimeValid = currentTime - thisWidget.lastClickedTime < Iris._config.MouseDoubleClickTime
|
|
424
|
+
if
|
|
425
|
+
isTimeValid
|
|
426
|
+
and (Vector2.new(x, y) - thisWidget.lastClickedPosition).Magnitude
|
|
427
|
+
< Iris._config.MouseDoubleClickMaxDist
|
|
428
|
+
then
|
|
429
|
+
thisWidget.lastDoubleClickedTick = Iris._cycleTick + 1
|
|
430
|
+
else
|
|
431
|
+
thisWidget.lastClickedTime = currentTime
|
|
432
|
+
thisWidget.lastClickedPosition = Vector2.new(x, y)
|
|
433
|
+
end
|
|
434
|
+
end)
|
|
435
|
+
end,
|
|
436
|
+
["Get"] = function(thisWidget: Types.Widget & Types.DoubleClicked)
|
|
437
|
+
return thisWidget.lastDoubleClickedTick == Iris._cycleTick
|
|
438
|
+
end,
|
|
439
|
+
}
|
|
440
|
+
end,
|
|
441
|
+
|
|
442
|
+
ctrlClick = function(pathToClicked: (thisWidget: Types.Widget) -> GuiButton)
|
|
443
|
+
return {
|
|
444
|
+
["Init"] = function(thisWidget: Types.Widget & Types.CtrlClicked)
|
|
445
|
+
local clickedGuiObject = pathToClicked(thisWidget)
|
|
446
|
+
thisWidget.lastCtrlClickedTick = -1
|
|
447
|
+
|
|
448
|
+
widgets.applyButtonClick(clickedGuiObject, function()
|
|
449
|
+
if
|
|
450
|
+
widgets.UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)
|
|
451
|
+
or widgets.UserInputService:IsKeyDown(Enum.KeyCode.RightControl)
|
|
452
|
+
then
|
|
453
|
+
thisWidget.lastCtrlClickedTick = Iris._cycleTick + 1
|
|
454
|
+
end
|
|
455
|
+
end)
|
|
456
|
+
end,
|
|
457
|
+
["Get"] = function(thisWidget: Types.Widget & Types.CtrlClicked)
|
|
458
|
+
return thisWidget.lastCtrlClickedTick == Iris._cycleTick
|
|
459
|
+
end,
|
|
460
|
+
}
|
|
461
|
+
end,
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
Iris._utility = widgets
|
|
465
|
+
|
|
466
|
+
require(script.Parent.iris_Root)(Iris, widgets)
|
|
467
|
+
require(script.Parent.iris_Window)(Iris, widgets)
|
|
468
|
+
|
|
469
|
+
require(script.Parent.iris_Menu)(Iris, widgets)
|
|
470
|
+
|
|
471
|
+
require(script.Parent.iris_Format)(Iris, widgets)
|
|
472
|
+
|
|
473
|
+
require(script.Parent.iris_Text)(Iris, widgets)
|
|
474
|
+
require(script.Parent.iris_Button)(Iris, widgets)
|
|
475
|
+
require(script.Parent.iris_Checkbox)(Iris, widgets)
|
|
476
|
+
require(script.Parent.iris_RadioButton)(Iris, widgets)
|
|
477
|
+
require(script.Parent.iris_Image)(Iris, widgets)
|
|
478
|
+
|
|
479
|
+
require(script.Parent.iris_Tree)(Iris, widgets)
|
|
480
|
+
require(script.Parent.iris_Tab)(Iris, widgets)
|
|
481
|
+
|
|
482
|
+
require(script.Parent.iris_Input)(Iris, widgets)
|
|
483
|
+
require(script.Parent.iris_Combo)(Iris, widgets)
|
|
484
|
+
require(script.Parent.iris_Plot)(Iris, widgets)
|
|
485
|
+
|
|
486
|
+
require(script.Parent.iris_Table)(Iris, widgets)
|
|
487
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "IrisTest",
|
|
3
|
+
"globIgnorePaths": [
|
|
4
|
+
"**/.package-lock.json",
|
|
5
|
+
"**/.pnpm",
|
|
6
|
+
"**/.pnpm-workspace-state-v1.json",
|
|
7
|
+
"**/.modules.yaml",
|
|
8
|
+
"**/.ignored",
|
|
9
|
+
"**/.ignored_*"
|
|
10
|
+
],
|
|
11
|
+
"tree": {
|
|
12
|
+
"$className": "DataModel",
|
|
13
|
+
"ServerScriptService": {
|
|
14
|
+
"$properties": {
|
|
15
|
+
"LoadStringEnabled": true
|
|
16
|
+
},
|
|
17
|
+
"iris": {
|
|
18
|
+
"$path": ".."
|
|
19
|
+
},
|
|
20
|
+
"Script": {
|
|
21
|
+
"$path": "scripts/Server"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
@class ServerMain
|
|
3
|
+
]]
|
|
4
|
+
local ServerScriptService = game:GetService("ServerScriptService")
|
|
5
|
+
|
|
6
|
+
local root = ServerScriptService.iris
|
|
7
|
+
local loader = root:FindFirstChild("LoaderUtils", true).Parent
|
|
8
|
+
local require = require(loader).bootstrapGame(root)
|
|
9
|
+
|
|
10
|
+
local NevermoreTestRunnerUtils = require("NevermoreTestRunnerUtils")
|
|
11
|
+
if NevermoreTestRunnerUtils.runTestsIfNeededAsync(root) then
|
|
12
|
+
return
|
|
13
|
+
end
|