BrandonDeVirgin

UI Library

Dec 21st, 2019
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.08 KB | None | 0 0
  1. local Library = {
  2. windowCount = 0;
  3. };
  4.  
  5. local dragger = {};
  6. local resizer = {};
  7.  
  8. do
  9. local UserInputService = game:GetService("UserInputService");
  10. local heartBeat = game:GetService("RunService").Heartbeat;
  11. local TweenService = game:GetService("TweenService");
  12. local mouse = game:GetService("Players").LocalPlayer:GetMouse();
  13.  
  14. function dragger.new(frame)
  15. local success, event = pcall(function()
  16. return frame.MouseEnter;
  17. end);
  18.  
  19. assert(success, "#1 Expected UI element got "..frame.ClassName);
  20.  
  21. frame.Active = true;
  22.  
  23. event:Connect(function()
  24. local input = frame.InputBegan:Connect(function(input)
  25. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  26. local objectPosition = Vector2.new(mouse.X - frame.AbsolutePosition.X, mouse.Y - frame.AbsolutePosition.Y);
  27. while heartBeat:Wait() and UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
  28. frame:TweenPosition(UDim2.new(0, mouse.X - objectPosition.X + (frame.Size.X.Offset * frame.AnchorPoint.X), 0, mouse.Y - objectPosition.Y + (frame.Size.Y.Offset * frame.AnchorPoint.Y)), 'Out', 'Quad', 0.1, true);
  29. end;
  30. end
  31. end);
  32.  
  33. local leave;
  34. leave = frame.MouseLeave:Connect(function()
  35. input:Disconnect();
  36. leave:Disconnect();
  37. end);
  38. end);
  39. end;
  40.  
  41. function resizer.new(p, s)
  42. p:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
  43. s.Size = UDim2.new(s.Size.X.Scale, s.Size.X.Offset, s.Size.Y.Scale, p.AbsoluteSize.Y);
  44. end);
  45. end;
  46.  
  47. function Library:ServiceTween(object, info, goals)
  48. assert(object, '#1 GUI object expected got nil');
  49. return TweenService:Create(object, TweenInfo.new(unpack(info)), goals);
  50. end
  51.  
  52. function Library:Tween(object, Type,goals)
  53. assert(object, "#1 Expceted gui object got nil");
  54. if Type == "SP" then
  55. object:TweenSizeAndPosition(unpack(goals));
  56. elseif Type == "S" then
  57. object:TweenSize(unpack(goals));
  58. elseif Type == "P" then
  59. object:TweenPosition(unpack(goals));
  60. else
  61. error('Invalid Type');
  62. end
  63. end;
  64. end;
  65.  
  66. local defaults = {}; --default colours
  67.  
  68. function Library:Create(class, props)
  69. local object = Instance.new(class);
  70.  
  71. for i, v in pairs(props) do
  72. if i ~= "Parent" then
  73. object[i] = v;
  74. end;
  75. end;
  76.  
  77. object.Parent = props.Parent;
  78.  
  79. return object;
  80. end;
  81.  
  82. function Library:CreateIntiation(options)
  83. assert(options, "#1 Table expected got nil");
  84. setmetatable(options, {__index = defaults}); -- inheritance :sunglasses:
  85.  
  86. local window = {};
  87.  
  88. Library.gui = Library.gui or self:Create("ScreenGui", {Name = "BrandonCoolio", Parent = game:GetService("CoreGui")});
  89. window.logoFrame = self:Create("ImageLabel", {
  90. BackgroundTransparency = 1;
  91. Size = UDim2.new(0, 0, 0, 0);
  92. Position = UDim2.new(0.5, 0, 0.5, 0);
  93. AnchorPoint = Vector2.new(0.5, 0.5);
  94. ImageColor3 = options.ImageColor3 or Color3.fromRGB(255, 255, 255);
  95. Image = 'rbxassetid://4132450915'; -- rbxassetid://282305376 rbxassetid://4387074074
  96. Parent = self.gui;
  97. });
  98.  
  99. window.logo = self:Create("ImageLabel", {
  100. BackgroundTransparency = 1;
  101. Size = UDim2.new(0, 74, 0, 74);
  102. AnchorPoint = Vector2.new(0.5, 0.5);
  103. Position = UDim2.new(0, 0.5, 0, 0.5);
  104. Image = options.Logo;
  105. ImageTransparency = 2;
  106. Parent = window.logoFrame;
  107. });
  108.  
  109. window.mainFrame = self:Create("Frame", {
  110. BorderSizePixel = 0;
  111. AnchorPoint = Vector2.new(0.5, 0.5);
  112. ZIndex = 1;
  113. Visible = false;
  114. BackgroundColor3 = Color3.fromRGB(54, 54, 54);
  115. Position = UDim2.new(0, -145,0, -86);
  116. Size = UDim2.new(0, 0, 0, 0);
  117. Parent = self.gui;
  118. });
  119. Library:Tween(window.logoFrame, 'SP', {UDim2.new(0, 100, 0, 100), UDim2.new(0.5, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 0.8});
  120. wait(1);
  121. Library:ServiceTween(window.logo, {.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out}, {ImageTransparency = 0}):Play();
  122. wait(1);
  123. Library:Tween(window.logoFrame, 'SP', {UDim2.new(0, 0, 0, 0), UDim2.new(0.5, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.7});
  124. Library:Tween(window.logo, 'SP', {UDim2.new(0, 0, 0, 0), UDim2.new(0.5, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.7});
  125. wait(1);
  126. window.logo.Size = UDim2.new(0, 0, 0, 0);
  127. window.logo.Position = UDim2.new(0, -145,0, -86);
  128. Library:Tween(window.logo, 'S', {UDim2.new(0, 54,0, 54), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 0.4});
  129. Library:Tween(window.mainFrame, 'S', {UDim2.new(0, 341,0, 213), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.4});
  130.  
  131. return window;
  132. end;
  133.  
  134. return Library;
Advertisement
Add Comment
Please, Sign In to add comment