forked from bloodball/UI-Librarys
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotifications.lua
More file actions
872 lines (767 loc) · 36.1 KB
/
Copy pathNotifications.lua
File metadata and controls
872 lines (767 loc) · 36.1 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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
--CREATED BY Jxereas#3766
_G.JxereasExistingHooks = _G.JxereasExistingHooks or {}
if not _G.JxereasExistingHooks.GuiDetectionBypass then
local CoreGui = game.CoreGui
local ContentProvider = game.ContentProvider
local RobloxGuis = {"RobloxGui", "TeleportGui", "RobloxPromptGui", "RobloxLoadingGui", "PlayerList", "RobloxNetworkPauseNotification", "PurchasePrompt", "HeadsetDisconnectedDialog", "ThemeProvider", "DevConsoleMaster"}
local function FilterTable(tbl)
local context = syn_context_get()
syn_context_set(7)
local new = {}
for i,v in ipairs(tbl) do --roblox iterates the array part
if typeof(v) ~= "Instance" then
table.insert(new, v)
else
if v == CoreGui or v == game then
--insert only the default roblox guis
for i,v in pairs(RobloxGuis) do
local gui = CoreGui:FindFirstChild(v)
if gui then
table.insert(new, gui)
end
end
if v == game then
for i,v in pairs(game:GetChildren()) do
if v ~= CoreGui then
table.insert(new, v)
end
end
end
else
if not CoreGui:IsAncestorOf(v) then
table.insert(new, v)
else
--don't insert it if it's a descendant of a different gui than default roblox guis
for j,k in pairs(RobloxGuis) do
local gui = CoreGui:FindFirstChild(k)
if gui then
if v == gui or gui:IsAncestorOf(v) then
table.insert(new, v)
break
end
end
end
end
end
end
end
syn_context_set(context)
return new
end
local old
old = hookfunc(ContentProvider.PreloadAsync, function(self, tbl, cb)
if self ~= ContentProvider or type(tbl) ~= "table" or type(cb) ~= "function" then --note: callback can be nil but in that case it's useless anyways
return old(self, tbl, cb)
end
--check for any errors that I might've missed (such as table being {[2] = "something"} which causes "Unable to cast to Array")
local err
task.spawn(function() --TIL pcalling a C yield function inside a C yield function is a bad idea ("cannot resume non-suspended coroutine")
local s,e = pcall(old, self, tbl)
if not s and e then
err = e
end
end)
if err then
return old(self, tbl) --don't pass the callback, just in case
end
tbl = FilterTable(tbl)
return old(self, tbl, cb)
end)
local old
old = hookmetamethod(game, "__namecall", function(self, ...)
local method = getnamecallmethod()
if self == ContentProvider and (method == "PreloadAsync" or method == "preloadAsync") then
local args = {...}
if type(args[1]) ~= "table" or type(args[2]) ~= "function" then
return old(self, ...)
end
local err
task.spawn(function()
setnamecallmethod(method) --different thread, different namecall method
local s,e = pcall(old, self, args[1])
if not s and e then
err = e
end
end)
if err then
return old(self, args[1])
end
args[1] = FilterTable(args[1])
setnamecallmethod(method)
return old(self, args[1], args[2])
end
return old(self, ...)
end)
_G.JxereasExistingHooks.GuiDetectionBypass = true
end
local Notification = {}
Notification.__index = Notification
local ts = game:GetService("TweenService")
local ss = game:GetService("SoundService")
local txtS = game:GetService("TextService")
local openSound = Instance.new("Sound")
local closeSound = Instance.new("Sound")
local notifications = Instance.new("ScreenGui")
local notifsHolderFrame = Instance.new("Frame")
local notifHolderListLayout = Instance.new("UIListLayout")
local errorTemplate = Instance.new("Frame")
local errorTemplateFrame = Instance.new("Frame")
local errorTemplateCorner = Instance.new("UICorner")
local errorSeverityFrame = Instance.new("Frame")
local errorSeverityCorner = Instance.new("UICorner")
local hideErrorSeverityCornerFrame = Instance.new("Frame")
local errorImage = Instance.new("ImageLabel")
local errorInformationFrame = Instance.new("Frame")
local errorHeadingText = Instance.new("TextLabel")
local errorBodyText = Instance.new("TextLabel")
local errorCornerHidingFrame = Instance.new("Frame")
local errorCloseButton = Instance.new("ImageButton")
local infoTemplate = Instance.new("Frame")
local infoTemplateFrame = Instance.new("Frame")
local infoSeverityFrame = Instance.new("Frame")
local infoSeverityCorner = Instance.new("UICorner")
local hideInfoSeverityCornerFrame = Instance.new("Frame")
local infoImage = Instance.new("ImageLabel")
local infoInformationFrame = Instance.new("Frame")
local infoHeadingText = Instance.new("TextLabel")
local infoBodyText = Instance.new("TextLabel")
local infoCornerHidingFrame = Instance.new("Frame")
local infoCloseButton = Instance.new("ImageButton")
local infoTemplateCorner = Instance.new("UICorner")
local messageTemplate = Instance.new("Frame")
local messageTemplateFrame = Instance.new("Frame")
local messageTemplateCorner = Instance.new("UICorner")
local messageSeverityFrame = Instance.new("Frame")
local messageSeverityCorner = Instance.new("UICorner")
local hideMessageSeverityCornerFrame = Instance.new("Frame")
local messageInformationFrame = Instance.new("Frame")
local messageHeadingText = Instance.new("TextLabel")
local messageBodyText = Instance.new("TextLabel")
local messageCornerHidingFrame = Instance.new("Frame")
local messageCloseButton = Instance.new("ImageButton")
local successTemplate = Instance.new("Frame")
local successTemplateFrame = Instance.new("Frame")
local successTemplateCorner = Instance.new("UICorner")
local successSeverityFrame = Instance.new("Frame")
local successSeverityCorner = Instance.new("UICorner")
local hideSuccessSeverityCornerFrame = Instance.new("Frame")
local successImage = Instance.new("ImageLabel")
local successInformationFrame = Instance.new("Frame")
local successHeadingText = Instance.new("TextLabel")
local successBodyText = Instance.new("TextLabel")
local successCornerHidingFrame = Instance.new("Frame")
local successCloseButton = Instance.new("ImageButton")
local warningTemplate = Instance.new("Frame")
local warningTemplateFrame = Instance.new("Frame")
local warningTemplateCorner = Instance.new("UICorner")
local warningSeverityFrame = Instance.new("Frame")
local warningSeverityCorner = Instance.new("UICorner")
local hideWarningSeverityCornerFrame = Instance.new("Frame")
local warningImage = Instance.new("ImageLabel")
local warningInformationFrame = Instance.new("Frame")
local warningHeadingText = Instance.new("TextLabel")
local warningBodyText = Instance.new("TextLabel")
local warningCornerHidingFrame = Instance.new("Frame")
local warningCloseButton = Instance.new("ImageButton")
local previousUiExists = game:GetService("CoreGui"):FindFirstChild("notifications")
if previousUiExists then previousUiExists:Destroy() end
openSound.Name = "OpenNotifSound"
openSound.Volume = 1
openSound.SoundId = "rbxassetid://9128519965"
openSound.Parent = ss
closeSound.Name = "CloseNotifSound"
closeSound.Volume = 1
closeSound.SoundId = "rbxassetid://9128519965"
closeSound.Parent = ss
notifications.Name = "notifications"
notifications.Parent = game:GetService("CoreGui")
notifications.ZIndexBehavior = Enum.ZIndexBehavior.Global
notifications.ResetOnSpawn = false
notifsHolderFrame.Name = "notifsHolderFrame"
notifsHolderFrame.Parent = notifications
notifsHolderFrame.AnchorPoint = Vector2.new(1, 1)
notifsHolderFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
notifsHolderFrame.BackgroundTransparency = 1
notifsHolderFrame.BorderSizePixel = 0
notifsHolderFrame.ClipsDescendants = true
notifsHolderFrame.Position = UDim2.new(1, 0, 1, -10)
notifsHolderFrame.Size = UDim2.fromScale(0.25, 0.3)
notifHolderListLayout.Name = "notifHolderListLayout"
notifHolderListLayout.Parent = notifsHolderFrame
notifHolderListLayout.SortOrder = Enum.SortOrder.LayoutOrder
notifHolderListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Right
notifHolderListLayout.VerticalAlignment = Enum.VerticalAlignment.Bottom
notifHolderListLayout.Padding = UDim.new(0, 4)
errorTemplate.Name = "error"
errorTemplate.AnchorPoint = Vector2.new(1, 1)
errorTemplate.BackgroundColor3 = Color3.fromRGB(255, 207, 203)
errorTemplate.BorderSizePixel = 0
errorTemplate.BackgroundTransparency = 1
errorTemplate.Position = UDim2.new(1, 0, 1, -100)
errorTemplate.Size = UDim2.new(1, 0, 0, 40)
errorTemplateFrame.Name = "templateFrame"
errorTemplateFrame.Parent = errorTemplate
errorTemplateFrame.BackgroundColor3 = Color3.fromRGB(255, 207, 203)
errorTemplateFrame.BorderSizePixel = 0
errorTemplateFrame.Size = UDim2.new(1, 0, 1, 0)
errorTemplateCorner.Name = "templateCorner"
errorTemplateCorner.Parent = errorTemplateFrame
errorSeverityFrame.Name = "severityFrame"
errorSeverityFrame.Parent = errorTemplateFrame
errorSeverityFrame.BackgroundColor3 = Color3.fromRGB(236, 88, 76)
errorSeverityFrame.Size = UDim2.new(0, 10, 1, 0)
errorSeverityCorner.Name = "severityCorner"
errorSeverityCorner.Parent = errorSeverityFrame
hideErrorSeverityCornerFrame.Name = "hideSeverityCornerFrame"
hideErrorSeverityCornerFrame.Parent = errorSeverityFrame
hideErrorSeverityCornerFrame.BackgroundColor3 = Color3.fromRGB(255, 207, 203)
hideErrorSeverityCornerFrame.BorderSizePixel = 0
hideErrorSeverityCornerFrame.Position = UDim2.new(0.5, 0, 0, 0)
hideErrorSeverityCornerFrame.Size = UDim2.new(0.5, 0, 1, 0)
errorImage.Name = "image"
errorImage.Parent = errorTemplateFrame
errorImage.AnchorPoint = Vector2.new(0, 0.5)
errorImage.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
errorImage.BackgroundTransparency = 1
errorImage.BorderSizePixel = 0
errorImage.Position = UDim2.new(0, 15, 0.5, 0)
errorImage.Size = UDim2.new(0, 20, 0, 20)
errorImage.Image = "rbxassetid://9072920609"
errorImage.ImageColor3 = Color3.fromRGB(236, 88, 76)
errorInformationFrame.Name = "informationFrame"
errorInformationFrame.Parent = errorTemplateFrame
errorInformationFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
errorInformationFrame.BackgroundTransparency = 1
errorInformationFrame.BorderSizePixel = 0
errorInformationFrame.Position = UDim2.new(0, 45, 0, 0)
errorInformationFrame.Size = UDim2.new(1, -45 - 25, 1, 0)
errorHeadingText.Name = "headingText"
errorHeadingText.Parent = errorInformationFrame
errorHeadingText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
errorHeadingText.BackgroundTransparency = 1
errorHeadingText.BorderSizePixel = 0
errorHeadingText.ClipsDescendants = true
errorHeadingText.Size = UDim2.new(1, 0, 0, 20)
errorHeadingText.Font = Enum.Font.GothamBold
errorHeadingText.Text = "Error"
errorHeadingText.TextColor3 = Color3.fromRGB(0, 0, 0)
errorHeadingText.TextSize = 14
errorHeadingText.TextXAlignment = Enum.TextXAlignment.Left
errorHeadingText.TextYAlignment = Enum.TextYAlignment.Bottom
errorBodyText.Name = "bodyText"
errorBodyText.Parent = errorInformationFrame
errorBodyText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
errorBodyText.BackgroundTransparency = 1
errorBodyText.BorderSizePixel = 0
errorBodyText.ClipsDescendants = true
errorBodyText.Position = UDim2.new(0, 0, 0, 20)
errorBodyText.Size = UDim2.new(1, 0, 1, -20)
errorBodyText.Font = Enum.Font.GothamSemibold
errorBodyText.Text = "Error message"
errorBodyText.TextColor3 = Color3.fromRGB(0, 0, 0)
errorBodyText.TextSize = 14
errorBodyText.TextWrapped = true
errorBodyText.TextXAlignment = Enum.TextXAlignment.Left
errorBodyText.TextYAlignment = Enum.TextYAlignment.Top
errorCornerHidingFrame.Name = "cornerHidingFrame"
errorCornerHidingFrame.Parent = errorTemplateFrame
errorCornerHidingFrame.AnchorPoint = Vector2.new(1, 0)
errorCornerHidingFrame.BackgroundColor3 = Color3.fromRGB(255, 207, 203)
errorCornerHidingFrame.BorderSizePixel = 0
errorCornerHidingFrame.Position = UDim2.new(1, 0, 0, 0)
errorCornerHidingFrame.Size = UDim2.new(.1, 0, 1, 0)
errorCornerHidingFrame.ZIndex = 0
errorCloseButton.Name = "closeButton"
errorCloseButton.Parent = errorTemplateFrame
errorCloseButton.AnchorPoint = Vector2.new(1, 0.5)
errorCloseButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
errorCloseButton.BackgroundTransparency = 1
errorCloseButton.BorderSizePixel = 0
errorCloseButton.Position = UDim2.new(1, -5, 0.5, 0)
errorCloseButton.Size = UDim2.new(0, 15, 0, 15)
errorCloseButton.Image = "rbxassetid://9127564477"
errorCloseButton.ImageColor3 = Color3.fromRGB(236, 88, 76)
infoTemplate.Name = "info"
infoTemplate.AnchorPoint = Vector2.new(1, 1)
infoTemplate.BackgroundColor3 = Color3.fromRGB(204, 226, 254)
infoTemplate.BorderSizePixel = 0
infoTemplate.BackgroundTransparency = 1
infoTemplate.Position = UDim2.new(1, 0, 1, -100)
infoTemplate.Size = UDim2.new(1, 0, 0, 40)
infoTemplateFrame.Name = "templateFrame"
infoTemplateFrame.Parent = infoTemplate
infoTemplateFrame.BackgroundColor3 = Color3.fromRGB(204, 226, 254)
infoTemplateFrame.BorderSizePixel = 0
infoTemplateFrame.Size = UDim2.new(1, 0, 1, 0)
infoSeverityFrame.Name = "severityFrame"
infoSeverityFrame.Parent = infoTemplateFrame
infoSeverityFrame.BackgroundColor3 = Color3.fromRGB(50, 131, 226)
infoSeverityFrame.Size = UDim2.new(0, 10, 1, 0)
infoSeverityCorner.Name = "severityCorner"
infoSeverityCorner.Parent = infoSeverityFrame
hideInfoSeverityCornerFrame.Name = "hideSeverityCornerFrame"
hideInfoSeverityCornerFrame.Parent = infoSeverityFrame
hideInfoSeverityCornerFrame.BackgroundColor3 = Color3.fromRGB(204, 226, 254)
hideInfoSeverityCornerFrame.BorderSizePixel = 0
hideInfoSeverityCornerFrame.Position = UDim2.new(0.5, 0, 0, 0)
hideInfoSeverityCornerFrame.Size = UDim2.new(0.5, 0, 1, 0)
infoImage.Name = "image"
infoImage.Parent = infoTemplateFrame
infoImage.AnchorPoint = Vector2.new(0, 0.5)
infoImage.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
infoImage.BackgroundTransparency = 1
infoImage.BorderSizePixel = 0
infoImage.Position = UDim2.new(0, 15, 0.5, 0)
infoImage.Size = UDim2.new(0, 20, 0, 20)
infoImage.Image = "rbxassetid://9072944922"
infoImage.ImageColor3 = Color3.fromRGB(50, 131, 226)
infoInformationFrame.Name = "informationFrame"
infoInformationFrame.Parent = infoTemplateFrame
infoInformationFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
infoInformationFrame.BackgroundTransparency = 1
infoInformationFrame.BorderSizePixel = 0
infoInformationFrame.Position = UDim2.new(0, 45, 0, 0)
infoInformationFrame.Size = UDim2.new(1, -45 - 25, 1, 0)
infoHeadingText.Name = "headingText"
infoHeadingText.Parent = infoInformationFrame
infoHeadingText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
infoHeadingText.BackgroundTransparency = 1
infoHeadingText.BorderSizePixel = 0
infoHeadingText.ClipsDescendants = true
infoHeadingText.Size = UDim2.new(1, 0, 0, 20)
infoHeadingText.Font = Enum.Font.GothamBold
infoHeadingText.Text = "Information"
infoHeadingText.TextColor3 = Color3.fromRGB(0, 0, 0)
infoHeadingText.TextSize = 14
infoHeadingText.TextXAlignment = Enum.TextXAlignment.Left
infoHeadingText.TextYAlignment = Enum.TextYAlignment.Bottom
infoBodyText.Name = "bodyText"
infoBodyText.Parent = infoInformationFrame
infoBodyText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
infoBodyText.BackgroundTransparency = 1
infoBodyText.BorderSizePixel = 0
infoBodyText.ClipsDescendants = true
infoBodyText.Position = UDim2.new(0, 0, 0, 20)
infoBodyText.Size = UDim2.new(1, 0, 1, -20)
infoBodyText.Font = Enum.Font.GothamSemibold
infoBodyText.Text = "Information message"
infoBodyText.TextColor3 = Color3.fromRGB(0, 0, 0)
infoBodyText.TextSize = 14
infoBodyText.TextWrapped = true
infoBodyText.TextXAlignment = Enum.TextXAlignment.Left
infoBodyText.TextYAlignment = Enum.TextYAlignment.Top
infoCornerHidingFrame.Name = "cornerHidingFrame"
infoCornerHidingFrame.Parent = infoTemplateFrame
infoCornerHidingFrame.AnchorPoint = Vector2.new(1, 0)
infoCornerHidingFrame.BackgroundColor3 = Color3.fromRGB(204, 226, 254)
infoCornerHidingFrame.BorderSizePixel = 0
infoCornerHidingFrame.Position = UDim2.new(1, 0, 0, 0)
infoCornerHidingFrame.Size = UDim2.new(.1, 0, 1, 0)
infoCornerHidingFrame.ZIndex = 0
infoCloseButton.Name = "closeButton"
infoCloseButton.Parent = infoTemplateFrame
infoCloseButton.AnchorPoint = Vector2.new(1, 0.5)
infoCloseButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
infoCloseButton.BackgroundTransparency = 1
infoCloseButton.BorderSizePixel = 0
infoCloseButton.Position = UDim2.new(1, -5, 0.5, 0)
infoCloseButton.Size = UDim2.new(0, 15, 0, 15)
infoCloseButton.Image = "rbxassetid://9127564477"
infoCloseButton.ImageColor3 = Color3.fromRGB(50, 131, 226)
infoTemplateCorner.Name = "templateCorner"
infoTemplateCorner.Parent = infoTemplateFrame
messageTemplate.Name = "message"
messageTemplate.AnchorPoint = Vector2.new(1, 1)
messageTemplate.BackgroundColor3 = Color3.fromRGB(233, 233, 235)
messageTemplate.BorderSizePixel = 0
messageTemplate.BackgroundTransparency = 1
messageTemplate.Position = UDim2.new(1, 0, 1, -100)
messageTemplate.Size = UDim2.new(1, 0, 0, 40)
messageTemplateFrame.Name = "templateFrame"
messageTemplateFrame.Parent = messageTemplate
messageTemplateFrame.BackgroundColor3 = Color3.fromRGB(233, 233, 235)
messageTemplateFrame.BorderSizePixel = 0
messageTemplateFrame.Size = UDim2.new(1, 0, 1, 0)
messageTemplateCorner.Name = "templateCorner"
messageTemplateCorner.Parent = messageTemplateFrame
messageSeverityFrame.Name = "severityFrame"
messageSeverityFrame.Parent = messageTemplateFrame
messageSeverityFrame.BackgroundColor3 = Color3.fromRGB(112, 118, 130)
messageSeverityFrame.Size = UDim2.new(0, 10, 1, 0)
messageSeverityCorner.Name = "severityCorner"
messageSeverityCorner.Parent = messageSeverityFrame
hideMessageSeverityCornerFrame.Name = "hideSeverityCornerFrame"
hideMessageSeverityCornerFrame.Parent = messageSeverityFrame
hideMessageSeverityCornerFrame.BackgroundColor3 = Color3.fromRGB(233, 233, 235)
hideMessageSeverityCornerFrame.BorderSizePixel = 0
hideMessageSeverityCornerFrame.Position = UDim2.new(0.5, 0, 0, 0)
hideMessageSeverityCornerFrame.Size = UDim2.new(0.5, 0, 1, 0)
messageInformationFrame.Name = "informationFrame"
messageInformationFrame.Parent = messageTemplateFrame
messageInformationFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
messageInformationFrame.BackgroundTransparency = 1
messageInformationFrame.BorderSizePixel = 0
messageInformationFrame.Position = UDim2.new(0, 15, 0, 0)
messageInformationFrame.Size = UDim2.new(1, -40, 1, 0)
messageHeadingText.Name = "headingText"
messageHeadingText.Parent = messageInformationFrame
messageHeadingText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
messageHeadingText.BackgroundTransparency = 1
messageHeadingText.BorderSizePixel = 0
messageHeadingText.ClipsDescendants = true
messageHeadingText.Size = UDim2.new(1, 0, 0, 20)
messageHeadingText.Font = Enum.Font.GothamBold
messageHeadingText.Text = "Custom message"
messageHeadingText.TextColor3 = Color3.fromRGB(0, 0, 0)
messageHeadingText.TextSize = 14
messageHeadingText.TextXAlignment = Enum.TextXAlignment.Left
messageHeadingText.TextYAlignment = Enum.TextYAlignment.Bottom
messageBodyText.Name = "bodyText"
messageBodyText.Parent = messageInformationFrame
messageBodyText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
messageBodyText.BackgroundTransparency = 1
messageBodyText.BorderSizePixel = 0
messageBodyText.ClipsDescendants = true
messageBodyText.Position = UDim2.new(0, 0, 0, 20)
messageBodyText.Size = UDim2.new(1, 0, 1, -20)
messageBodyText.Font = Enum.Font.GothamSemibold
messageBodyText.Text = "Custom message"
messageBodyText.TextColor3 = Color3.fromRGB(0, 0, 0)
messageBodyText.TextSize = 14
messageBodyText.TextWrapped = true
messageBodyText.TextXAlignment = Enum.TextXAlignment.Left
messageBodyText.TextYAlignment = Enum.TextYAlignment.Top
messageCornerHidingFrame.Name = "cornerHidingFrame"
messageCornerHidingFrame.Parent = messageTemplateFrame
messageCornerHidingFrame.AnchorPoint = Vector2.new(1, 0)
messageCornerHidingFrame.BackgroundColor3 = Color3.fromRGB(233, 233, 235)
messageCornerHidingFrame.BorderSizePixel = 0
messageCornerHidingFrame.Position = UDim2.new(1, 0, 0, 0)
messageCornerHidingFrame.Size = UDim2.new(.1, 0, 1, 0)
messageCornerHidingFrame.ZIndex = 0
messageCloseButton.Name = "closeButton"
messageCloseButton.Parent = messageTemplateFrame
messageCloseButton.AnchorPoint = Vector2.new(1, 0.5)
messageCloseButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
messageCloseButton.BackgroundTransparency = 1
messageCloseButton.BorderSizePixel = 0
messageCloseButton.Position = UDim2.new(1, -5, 0.5, 0)
messageCloseButton.Size = UDim2.new(0, 15, 0, 15)
messageCloseButton.Image = "rbxassetid://9127564477"
messageCloseButton.ImageColor3 = Color3.fromRGB(112, 118, 130)
successTemplate.Name = "success"
successTemplate.AnchorPoint = Vector2.new(1, 1)
successTemplate.BackgroundColor3 = Color3.fromRGB(196, 247, 221)
successTemplate.BorderSizePixel = 0
successTemplate.BackgroundTransparency = 1
successTemplate.Position = UDim2.new(1, 0, 1, -100)
successTemplate.Size = UDim2.new(1, 0, 0, 40)
successTemplateFrame.Name = "templateFrame"
successTemplateFrame.Parent = successTemplate
successTemplateFrame.BackgroundColor3 = Color3.fromRGB(196, 247, 221)
successTemplateFrame.BorderSizePixel = 0
successTemplateFrame.Size = UDim2.new(1, 0, 1, 0)
successTemplateCorner.Name = "templateCorner"
successTemplateCorner.Parent = successTemplateFrame
successSeverityFrame.Name = "severityFrame"
successSeverityFrame.Parent = successTemplateFrame
successSeverityFrame.BackgroundColor3 = Color3.fromRGB(50, 195, 125)
successSeverityFrame.Size = UDim2.new(0, 10, 1, 0)
successSeverityCorner.Name = "severityCorner"
successSeverityCorner.Parent = successSeverityFrame
hideSuccessSeverityCornerFrame.Name = "hideSeverityCornerFrame"
hideSuccessSeverityCornerFrame.Parent = successSeverityFrame
hideSuccessSeverityCornerFrame.BackgroundColor3 = Color3.fromRGB(196, 247, 221)
hideSuccessSeverityCornerFrame.BorderSizePixel = 0
hideSuccessSeverityCornerFrame.Position = UDim2.new(0.5, 0, 0, 0)
hideSuccessSeverityCornerFrame.Size = UDim2.new(0.5, 0, 1, 0)
successImage.Name = "image"
successImage.Parent = successTemplateFrame
successImage.AnchorPoint = Vector2.new(0, 0.5)
successImage.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
successImage.BackgroundTransparency = 1
successImage.BorderSizePixel = 0
successImage.Position = UDim2.new(0, 15, 0.5, 0)
successImage.Size = UDim2.new(0, 20, 0, 20)
successImage.Image = "rbxassetid://9073052584"
successImage.ImageColor3 = Color3.fromRGB(50, 195, 125)
successInformationFrame.Name = "informationFrame"
successInformationFrame.Parent = successTemplateFrame
successInformationFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
successInformationFrame.BackgroundTransparency = 1
successInformationFrame.BorderSizePixel = 0
successInformationFrame.Position = UDim2.new(0, 45, 0, 0)
successInformationFrame.Size = UDim2.new(1, -45 - 25, 1, 0)
successHeadingText.Name = "headingText"
successHeadingText.Parent = successInformationFrame
successHeadingText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
successHeadingText.BackgroundTransparency = 1
successHeadingText.BorderSizePixel = 0
successHeadingText.ClipsDescendants = true
successHeadingText.Size = UDim2.new(1, 0, 0, 20)
successHeadingText.Font = Enum.Font.GothamBold
successHeadingText.Text = "Success"
successHeadingText.TextColor3 = Color3.fromRGB(0, 0, 0)
successHeadingText.TextSize = 14
successHeadingText.TextXAlignment = Enum.TextXAlignment.Left
successHeadingText.TextYAlignment = Enum.TextYAlignment.Bottom
successBodyText.Name = "bodyText"
successBodyText.Parent = successInformationFrame
successBodyText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
successBodyText.BackgroundTransparency = 1
successBodyText.BorderSizePixel = 0
successBodyText.ClipsDescendants = true
successBodyText.Position = UDim2.new(0, 0, 0, 20)
successBodyText.Size = UDim2.new(1, 0, 1, -20)
successBodyText.Font = Enum.Font.GothamSemibold
successBodyText.Text = "Success message"
successBodyText.TextColor3 = Color3.fromRGB(0, 0, 0)
successBodyText.TextSize = 14
successBodyText.TextWrapped = true
successBodyText.TextXAlignment = Enum.TextXAlignment.Left
successBodyText.TextYAlignment = Enum.TextYAlignment.Top
successCornerHidingFrame.Name = "cornerHidingFrame"
successCornerHidingFrame.Parent = successTemplateFrame
successCornerHidingFrame.AnchorPoint = Vector2.new(1, 0)
successCornerHidingFrame.BackgroundColor3 = Color3.fromRGB(196, 247, 221)
successCornerHidingFrame.BorderSizePixel = 0
successCornerHidingFrame.Position = UDim2.new(1, 0, 0, 0)
successCornerHidingFrame.Size = UDim2.new(.1, 0, 1, 0)
successCornerHidingFrame.ZIndex = 0
successCloseButton.Name = "closeButton"
successCloseButton.Parent = successTemplateFrame
successCloseButton.AnchorPoint = Vector2.new(1, 0.5)
successCloseButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
successCloseButton.BackgroundTransparency = 1
successCloseButton.BorderSizePixel = 0
successCloseButton.Position = UDim2.new(1, -5, 0.5, 0)
successCloseButton.Size = UDim2.new(0, 15, 0, 15)
successCloseButton.Image = "rbxassetid://9127564477"
successCloseButton.ImageColor3 = Color3.fromRGB(50, 195, 125)
warningTemplate.Name = "warning"
warningTemplate.AnchorPoint = Vector2.new(1, 1)
warningTemplate.BackgroundColor3 = Color3.fromRGB(255, 232, 197)
warningTemplate.BorderSizePixel = 0
warningTemplate.BackgroundTransparency = 1
warningTemplate.Position = UDim2.new(1, 0, 1, -100)
warningTemplate.Size = UDim2.new(1, 0, 0, 40)
warningTemplateFrame.Name = "templateFrame"
warningTemplateFrame.Parent = warningTemplate
warningTemplateFrame.BackgroundColor3 = Color3.fromRGB(255, 232, 197)
warningTemplateFrame.BorderSizePixel = 0
warningTemplateFrame.Size = UDim2.new(1, 0, 1, 0)
warningTemplateCorner.Name = "templateCorner"
warningTemplateCorner.Parent = warningTemplateFrame
warningSeverityFrame.Name = "severityFrame"
warningSeverityFrame.Parent = warningTemplateFrame
warningSeverityFrame.BackgroundColor3 = Color3.fromRGB(234, 159, 53)
warningSeverityFrame.Size = UDim2.new(0, 10, 1, 0)
warningSeverityCorner.Name = "severityCorner"
warningSeverityCorner.Parent = warningSeverityFrame
hideWarningSeverityCornerFrame.Name = "hideSeverityCornerFrame"
hideWarningSeverityCornerFrame.Parent = warningSeverityFrame
hideWarningSeverityCornerFrame.BackgroundColor3 = Color3.fromRGB(255, 232, 197)
hideWarningSeverityCornerFrame.BorderSizePixel = 0
hideWarningSeverityCornerFrame.Position = UDim2.new(0.5, 0, 0, 0)
hideWarningSeverityCornerFrame.Size = UDim2.new(0.5, 0, 1, 0)
warningImage.Name = "image"
warningImage.Parent = warningTemplateFrame
warningImage.AnchorPoint = Vector2.new(0, 0.5)
warningImage.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
warningImage.BackgroundTransparency = 1
warningImage.BorderSizePixel = 0
warningImage.Position = UDim2.new(0, 15, 0.5, 0)
warningImage.Size = UDim2.new(0, 20, 0, 20)
warningImage.Image = "rbxassetid://9072448788"
warningImage.ImageColor3 = Color3.fromRGB(234, 159, 53)
warningInformationFrame.Name = "informationFrame"
warningInformationFrame.Parent = warningTemplateFrame
warningInformationFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
warningInformationFrame.BackgroundTransparency = 1
warningInformationFrame.BorderSizePixel = 0
warningInformationFrame.Position = UDim2.new(0, 45, 0, 0)
warningInformationFrame.Size = UDim2.new(1, -45 - 25, 1, 0)
warningHeadingText.Name = "headingText"
warningHeadingText.Parent = warningInformationFrame
warningHeadingText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
warningHeadingText.BackgroundTransparency = 1
warningHeadingText.BorderSizePixel = 0
warningHeadingText.ClipsDescendants = true
warningHeadingText.Size = UDim2.new(1, 0, 0, 20)
warningHeadingText.Font = Enum.Font.GothamBold
warningHeadingText.Text = "Warning"
warningHeadingText.TextColor3 = Color3.fromRGB(0, 0, 0)
warningHeadingText.TextSize = 14
warningHeadingText.TextXAlignment = Enum.TextXAlignment.Left
warningHeadingText.TextYAlignment = Enum.TextYAlignment.Bottom
warningBodyText.Name = "bodyText"
warningBodyText.Parent = warningInformationFrame
warningBodyText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
warningBodyText.BackgroundTransparency = 1
warningBodyText.BorderSizePixel = 0
warningBodyText.ClipsDescendants = true
warningBodyText.Position = UDim2.new(0, 0, 0, 20)
warningBodyText.Size = UDim2.new(1, 0, 1, -20)
warningBodyText.Font = Enum.Font.GothamSemibold
warningBodyText.Text = "Warning message"
warningBodyText.TextColor3 = Color3.fromRGB(0, 0, 0)
warningBodyText.TextSize = 14
warningBodyText.TextWrapped = true
warningBodyText.TextXAlignment = Enum.TextXAlignment.Left
warningBodyText.TextYAlignment = Enum.TextYAlignment.Top
warningCornerHidingFrame.Name = "cornerHidingFrame"
warningCornerHidingFrame.Parent = warningTemplateFrame
warningCornerHidingFrame.AnchorPoint = Vector2.new(1, 0)
warningCornerHidingFrame.BackgroundColor3 = Color3.fromRGB(255, 232, 197)
warningCornerHidingFrame.BorderSizePixel = 0
warningCornerHidingFrame.Position = UDim2.new(1, 0, 0, 0)
warningCornerHidingFrame.Size = UDim2.new(.1, 0, 1, 0)
warningCornerHidingFrame.ZIndex = 0
warningCloseButton.Name = "closeButton"
warningCloseButton.Parent = warningTemplateFrame
warningCloseButton.AnchorPoint = Vector2.new(1, 0.5)
warningCloseButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
warningCloseButton.BackgroundTransparency = 1
warningCloseButton.BorderSizePixel = 0
warningCloseButton.Position = UDim2.new(1, -5, 0.5, 0)
warningCloseButton.Size = UDim2.new(0, 15, 0, 15)
warningCloseButton.Image = "rbxassetid://9127564477"
warningCloseButton.ImageColor3 = Color3.fromRGB(234, 159, 53)
local function scaleNotifHolderMaxNotifs(): nil
local amountOfNotifsInFrame = math.floor(notifsHolderFrame.AbsoluteSize.Y/40)
local notifsHolderFramePadding = amountOfNotifsInFrame * notifHolderListLayout.Padding.Offset
notifsHolderFrame.Size = UDim2.new(.25,0,0,amountOfNotifsInFrame * 40 + notifsHolderFramePadding)
end
local function deleteNotifsOutsideFrame(): nil
if notifHolderListLayout.AbsoluteContentSize.Y < notifsHolderFrame.AbsoluteSize.Y then return end
for _, notif in pairs(notifsHolderFrame:GetChildren()) do
if not notif:IsA("Frame") then continue end
if notif.AbsolutePosition.Y > notifsHolderFrame.AbsolutePosition.Y then continue end
notif:Destroy()
end
end
function Notification.new(notifType: string, heading: string, body: string, autoRemove: boolean, autoRemoveTime: number, callback): table
local notificationTypes = {
["error"] = errorTemplate,
["info"] = infoTemplate,
["message"] = messageTemplate,
["success"] = successTemplate,
["warning"] = warningTemplate
}
local notif = notificationTypes[notifType:lower()]
assert(notif, "Notification type not valid\nValid Types: {\n\tError\n\tInfo\n\tMessage\n\tSuccess\n\tWarning\n}")
notif = notif:Clone()
notif.templateFrame.Position = UDim2.new(1,0,0,0)
local function checkTextSize()
local infoFrame = notif.templateFrame.informationFrame
local requiredHeadingSize = txtS:GetTextSize(infoFrame.headingText.Text, infoFrame.headingText.TextSize, infoFrame.headingText.Font, Vector2.new(10000,10000)).X
local requiredBodySize = txtS:GetTextSize(infoFrame.bodyText.Text, infoFrame.bodyText.TextSize, infoFrame.bodyText.Font, Vector2.new(10000,10000)).X
if requiredHeadingSize + 45 + 25 > notifsHolderFrame.AbsoluteSize.X then
warn("Heading size is too long (Notification Library)")
end
if requiredBodySize + 45 + 25 > notifsHolderFrame.AbsoluteSize.X then
warn("Body size is too long (Notification Library)")
end
end
local function openNotif(): nil
local function playOpenNotifTween(): nil
ts:Create(notif.templateFrame, TweenInfo.new(.25), {Position = UDim2.new(0,0,0,0)}):Play()
end
openSound:Play()
playOpenNotifTween()
end
local function closeNotif(): nil
coroutine.wrap(function()
local function playCloseNotifTween(): nil
local closeTween = ts:Create(notif.templateFrame, TweenInfo.new(.25), {Position = UDim2.new(1,0,0,0)})
closeTween:Play()
closeTween.Completed:Wait()
end
closeSound:Play()
if callback then callback() end
playCloseNotifTween()
notif:Destroy()
end)()
end
notif.templateFrame.closeButton.MouseButton1Click:Connect(closeNotif)
notif.templateFrame.informationFrame.headingText.Text = heading
notif.templateFrame.informationFrame.bodyText.Text = body
notif.Parent = notifsHolderFrame
checkTextSize()
openNotif()
if autoRemove then
coroutine.wrap(function()
autoRemoveTime = autoRemoveTime or 5
task.wait(autoRemoveTime)
if notif and notif:FindFirstChild("templateFrame") then
closeNotif()
end
end)()
end
local newNotif = setmetatable({}, Notification)
newNotif.Instance = notif
newNotif.Heading = heading
newNotif.Body = body
newNotif.Type = notifType:lower()
return newNotif
end
function Notification:changeHeading(newHeading: string): nil
coroutine.wrap(function()
if not self.Instance or not self.Instance:FindFirstChild("templateFrame") then return end
self.Instance.templateFrame.informationFrame.headingText.Text = newHeading
end)()
end
function Notification:changeBody(newBody: string): nil
coroutine.wrap(function()
if not self.Instance or not self.Instance:FindFirstChild("templateFrame") then return end
self.Instance.templateFrame.informationFrame.bodyText.Text = newBody
end)()
end
function Notification:deleteTimeout(waitTime: number): nil
coroutine.wrap(function()
if not self.Instance or not self.Instance:FindFirstChild("templateFrame") then return end
local closeTween = ts:Create(self.Instance.templateFrame, TweenInfo.new(.25), {Position = UDim2.new(1,0,0,0)})
waitTime = waitTime or 3
task.wait(waitTime)
if not self.Instance or not self.Instance:FindFirstChild("templateFrame") then return end
closeTween:Play()
closeTween.Completed:Wait()
if self.Instance then return end
self.Instance:Destroy()
end)()
end
function Notification:delete()
coroutine.wrap(function()
if not self.Instance or not self.Instance:FindFirstChild("templateFrame") then return end
local closeTween = ts:Create(self.Instance.templateFrame, TweenInfo.new(.25), {Position = UDim2.new(1,0,0,0)})
closeTween:Play()
closeTween.Completed:Wait()
if not self.Instance then return end
self.Instance:Destroy()
end)()
end
function Notification:changeColor(primary: Color3, secondary: Color3, textColor: Color3): nil
coroutine.wrap(function()
if not self.Instance or not self.Instance:FindFirstChild("templateFrame") then return end
local templateFrame = self.Instance.templateFrame
if primary then
templateFrame.BackgroundColor3 = primary
templateFrame.cornerHidingFrame.BackgroundColor3 = primary
templateFrame.severityFrame.hideSeverityCornerFrame.BackgroundColor3 = primary
end
if secondary then
templateFrame.severityFrame.BackgroundColor3 = secondary
templateFrame.closeButton.ImageColor3 = secondary
if self.Type ~= "message" then
templateFrame.image.ImageColor3 = secondary
end
end
if textColor then
templateFrame.informationFrame.headingText.TextColor3 = textColor
templateFrame.informationFrame.bodyText.TextColor3 = textColor
end
end)()
end
scaleNotifHolderMaxNotifs()
notifHolderListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(deleteNotifsOutsideFrame)
return Notification