Advertisement
NiceBBMBThai

Test - WINDOWS 10 MESSAGE BOX – NOTIFICATION LIBRARY - PCW Hub

Sep 24th, 2022
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.11 KB | None | 0 0
  1. local MessageBoxT = {
  2. BoxIcons = {
  3. ["Question"] = "http://www.roblox.com/asset/?id=10258071211",
  4. ["Error"] = "http://www.roblox.com/asset/?id=8800303348",
  5. ["Warning"] = "http://www.roblox.com/asset/?id=8800428538"
  6. }
  7. }
  8.  
  9. local ID = 8801438982
  10.  
  11. local CurrentCamera;
  12. local plrs = game:GetService("Players")
  13. local plr = game:GetService("Players").LocalPlayer
  14. local TweenService = game:GetService("TweenService")
  15. local inpService = game:GetService("UserInputService")
  16. local Mouse = plr:GetMouse()
  17.  
  18. while (not CurrentCamera) do
  19. CurrentCamera = workspace.CurrentCamera
  20. wait()
  21. end
  22.  
  23. local minimized = false
  24.  
  25. local function ToBounds(X,Y, MW)
  26. if (X - MW.Size.X.Offset / 2 < 0) then
  27. X = MW.Size.X.Offset / 2
  28. end
  29.  
  30. if ((MW.AbsoluteSize.Y - Y) - MW.Size.Y.Offset / 2 >= MW.AbsoluteSize.Y) then
  31. Y = MW.Size.Y.Offset / 2
  32. end
  33.  
  34. if ((X + MW.AbsoluteSize.X) >= (CurrentCamera.ViewportSize.X) + MW.Size.X.Offset / 2) then
  35. X = CurrentCamera.ViewportSize.X - MW.AbsoluteSize.X + MW.Size.X.Offset / 2
  36. end
  37.  
  38. if (((Y + MW.AbsoluteSize.Y) + 35) >= (CurrentCamera.ViewportSize.Y) + MW.Size.Y.Offset / 2) then
  39. Y = (CurrentCamera.ViewportSize.Y - MW.AbsoluteSize.Y) - 35 + MW.Size.Y.Offset / 2
  40. end
  41.  
  42.  
  43. return UDim2.new(0, X, 0, Y)
  44. end
  45.  
  46. local function Tween(object, time, properties)
  47. local info = TweenInfo.new(time, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
  48. TweenService:Create(object, info, properties):Play()
  49. end
  50.  
  51.  
  52. -- thank you kesh for drag :) <3
  53. local function ApplyDrag(Component, MainWindow)
  54. local MouseDown = false
  55. local MB1 = Enum.UserInputType.MouseButton1 -- no way in hell am i indexing that 24/7
  56. local MM = Enum.UserInputType.MouseMovement -- no way in hell am i indexing that 24/7
  57.  
  58. local Position = Vector2.new()
  59.  
  60. local InputBegan = Component.InputBegan:Connect(function(input)
  61. if (input.UserInputType == MB1) then
  62. Component.BackgroundTransparency = 0
  63. Component["Box-Title"].TextColor3 = Color3.fromRGB(255,255,255)
  64. Component["Close"]["btn"].TextColor3 = Color3.fromRGB(255,255,255)
  65. MouseDown = true
  66. Position = Vector2.new(input.Position.X-MainWindow.AbsolutePosition.X-MainWindow.Size.X.Offset / 2, input.Position.Y-MainWindow.AbsolutePosition.Y-MainWindow.Size.Y.Offset / 2)
  67. end
  68. end)
  69.  
  70. local InputEnded = Component.InputEnded:Connect(function(input)
  71. if (input.UserInputType == MB1) then
  72. MouseDown = false
  73. Component.BackgroundTransparency = 1
  74. Component["Box-Title"].TextColor3 = Color3.fromRGB(0,0,0)
  75. Component["Close"]["btn"].TextColor3 = Color3.fromRGB(0,0,0)
  76. end
  77. end)
  78.  
  79. local InputChanged;
  80.  
  81. InputChanged = game:GetService("UserInputService").InputChanged:Connect(function(input)
  82. if (MouseDown and input.UserInputType == MM) then
  83. Tween(MainWindow, 0.1, {Position = ToBounds((Mouse.X-Position.X), (Mouse.Y-Position.Y), MainWindow)})
  84. --MainWindow.Position = ToBounds((Mouse.X-Position.X), (Mouse.Y-Position.Y), MainWindow)
  85. end
  86. end)
  87. end
  88.  
  89. function MessageBoxT.Show(option)
  90. option = typeof(option) == "table" and option or {}
  91. local MessageDescription = tostring(option.Description) and option.Description or "This is an Notification"
  92. local Options = tostring(option.MessageBoxButtons) and option.MessageBoxButtons or "OK"
  93. local MessageIcon = tostring(option.MessageBoxIcon) and option.MessageBoxIcon or "Warning"
  94. local ResultCallback = typeof(option.Result) == "function" and option.Result or function() end
  95. local MessageTitle = tostring(option.Text) and option.Text or ""
  96. local CustomPos = option.Position or UDim2.new(0.5,0,0.5,0)
  97.  
  98. local GUI
  99.  
  100. local Addup = 0
  101.  
  102. if (game.CoreGui:FindFirstChild("Notifications")) then
  103. GUI = game.CoreGui:FindFirstChild("Notifications")
  104. else
  105. GUI = Instance.new("ScreenGui", game.CoreGui)
  106. GUI.Name = "Notifications"
  107. end
  108.  
  109. local MessageBox = game:GetObjects("rbxassetid://"..ID)[1]
  110. MessageBox["UIScale"].Scale = 1
  111. MessageBox:Clone()
  112. MessageBox.Parent = GUI
  113. MessageBox.Position = CustomPos
  114. MessageBox.Position = UDim2.new(0, MessageBox.AbsolutePosition.X, 0, MessageBox.AbsolutePosition.Y)
  115.  
  116. --// Applying Options
  117. MessageBox["Message-Header"]["Box-Title"].Text = MessageTitle
  118. MessageBox["MessageDescription"].Text = MessageDescription
  119. MessageBox["Message-Icons"]["Error"].Image = MessageBoxT.BoxIcons["Error"]
  120. MessageBox["Message-Icons"]["Warning"].Image = MessageBoxT.BoxIcons["Warning"]
  121. MessageBox["Message-Icons"]["Question"].Image = MessageBoxT.BoxIcons["Question"]
  122.  
  123. ApplyDrag(MessageBox["Message-Header"], MessageBox)
  124.  
  125. local Icon = MessageBox["Message-Icons"]:FindFirstChild(MessageIcon)
  126. Icon.Parent = MessageBox
  127. Icon.Visible = true
  128. local Buttons = nil
  129.  
  130. if Options ~= "None" then
  131. Buttons = MessageBox["MessageBoxButtons"][Options]:Clone()
  132. Buttons.Visible = true
  133. Buttons.Parent = MessageBox
  134. Addup = 36
  135. else
  136. Addup = 6
  137. end
  138.  
  139. if MessageBox["MessageDescription"].TextBounds.Y >= 16 then
  140. MessageBox["MessageDescription"].Position = UDim2.new(0, 48,0, 42)
  141. Addup -= 14
  142. end
  143.  
  144. MessageBox.Size = UDim2.new(0, MessageBox["MessageDescription"].TextBounds.X + 100,0, MessageBox["MessageDescription"].TextBounds.Y + 70 + Addup)
  145.  
  146. if Buttons ~= nil then
  147. for i,v in pairs(Buttons:GetChildren()) do
  148. if v:IsA("TextButton") then
  149. v.MouseButton1Click:Connect(function()
  150. ResultCallback(v.Text)
  151. game.TweenService:Create(MessageBox["UIScale"], TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
  152. Scale = 0
  153. }):Play()
  154. wait(0.1)
  155. MessageBox:Destroy()
  156. end)
  157. end
  158. end
  159. end
  160.  
  161. MessageBox["UIScale"].Scale = 0
  162.  
  163. game.TweenService:Create(MessageBox["UIScale"], TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {
  164. Scale = 1
  165. }):Play()
  166. end
  167.  
  168. return MessageBoxT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement