Advertisement
Guest User

test

a guest
Jul 12th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.21 KB | None | 0 0
  1. -- Made by wallythebird on V3rmillion!
  2.  
  3. local library = {}
  4.  
  5. function library.new()
  6.     local temp = {windowcount = 0}
  7.     local dragger = {};
  8.     local resizer = {};
  9.    
  10.     do
  11.         local mouse = game:GetService("Players").LocalPlayer:GetMouse();
  12.         local inputService = game:GetService('UserInputService');
  13.         local heartbeat = game:GetService("RunService").Heartbeat;
  14.         -- // credits to Ririchi / Inori for this cute drag function :)
  15.         function dragger.new(frame)
  16.             local s, event = pcall(function()
  17.                 return frame.MouseEnter
  18.             end)
  19.    
  20.             if s then
  21.                 frame.Active = true;
  22.    
  23.                 event:connect(function()
  24.                     local input = frame.InputBegan:connect(function(key)
  25.                         if key.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 inputService: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.         end
  41.        
  42.         function resizer.new(p, s)
  43.             p:GetPropertyChangedSignal('AbsoluteSize'):connect(function()
  44.                 s.Size = UDim2.new(s.Size.X.Scale, s.Size.X.Offset, s.Size.Y.Scale, p.AbsoluteSize.Y);
  45.             end)
  46.         end
  47.     end
  48.  
  49.     function rainbow(obj)
  50.         spawn(function()
  51.             while true do
  52.                 for i = 0,1,0.004 do
  53.                     obj.BackgroundColor3 = Color3.fromHSV(i,1,1)
  54.                     if obj:IsA"TextLabel" then
  55.                         obj.TextColor3 = Color3.fromHSV(i,1,1)
  56.                     end
  57.                     wait(0.01)
  58.                 end
  59.             end
  60.         end)
  61.     end
  62.    
  63.    
  64.     local defaults = {
  65.         txtcolor = Color3.fromRGB(255, 255, 255),
  66.         underline = Color3.fromRGB(0, 255, 140),
  67.         barcolor = Color3.fromRGB(40, 40, 40),
  68.         bgcolor = Color3.fromRGB(30, 30, 30),
  69.     }
  70.    
  71.     function temp:Create(class, props)
  72.         local object = Instance.new(class);
  73.    
  74.         for i, prop in next, props do
  75.             if i ~= "Parent" then
  76.                 object[i] = prop;
  77.             end
  78.         end
  79.    
  80.         object.Parent = props.Parent;
  81.         return object;
  82.     end
  83.    
  84.     function temp:CreateWindow(options)
  85.         assert(options.text, "no name");
  86.         local window = {
  87.             count = 0;
  88.             toggles = {},
  89.             closed = false;
  90.         }
  91.    
  92.         local options = options or {};
  93.         setmetatable(options, {__index = defaults})
  94.        
  95.         self.windowcount = self.windowcount + 1;
  96.    
  97.         temp.gui = temp.gui or self:Create("ScreenGui", {Name = "UILibrary", Parent = game:GetService("Players").LocalPlayer.PlayerGui})
  98.         window.frame = self:Create("Frame", {
  99.             Name = options.text;
  100.             Parent = self.gui,
  101.             Active = true,
  102.             BackgroundTransparency = 0,
  103.             Size = UDim2.new(0, 190, 0, 30),
  104.             Position = UDim2.new(0, (15 + ((200 * self.windowcount) - 200)), 0, 15),
  105.             BackgroundColor3 = options.barcolor,
  106.             BorderSizePixel = 0;
  107.         })
  108.    
  109.         window.background = self:Create('Frame', {
  110.             Name = 'Background';
  111.             Parent = window.frame,
  112.             BorderSizePixel = 0;
  113.             BackgroundColor3 = options.bgcolor,
  114.             Position = UDim2.new(0, 0, 1, 0),
  115.             Size = UDim2.new(1, 0, 0, 25),
  116.             ClipsDescendants = true;
  117.         })
  118.        
  119.         window.container = self:Create('Frame', {
  120.             Name = 'Container';
  121.             Parent = window.frame,
  122.             BorderSizePixel = 0;
  123.             BackgroundColor3 = options.bgcolor,
  124.             Position = UDim2.new(0, 0, 1, 0),
  125.             Size = UDim2.new(1, 0, 0, 25),
  126.             ClipsDescendants = true;
  127.         })
  128.        
  129.         window.organizer = self:Create('UIListLayout', {
  130.             Name = 'Sorter';
  131.             --Padding = UDim.new(0, 0);
  132.             SortOrder = Enum.SortOrder.LayoutOrder;
  133.             Parent = window.container;
  134.         })
  135.        
  136.         window.padder = self:Create('UIPadding', {
  137.             Name = 'Padding';
  138.             PaddingLeft = UDim.new(0, 10);
  139.             PaddingTop = UDim.new(0, 5);
  140.             Parent = window.container;
  141.         })
  142.    
  143.         self:Create("Frame", {
  144.             Name = 'Underline';
  145.             Size = UDim2.new(1, 0, 0, 1),
  146.             Position = UDim2.new(0, 0, 1, -1),
  147.             BorderSizePixel = 0;
  148.             rainbow(underline);
  149.             Parent = window.frame
  150.         })
  151.    
  152.         local togglebutton = self:Create("TextButton", {
  153.             Name = 'Toggle';
  154.             ZIndex = 2,
  155.             BackgroundTransparency = 1;
  156.             Position = UDim2.new(1, -25, 0, 0),
  157.             Size = UDim2.new(0, 25, 1, 0),
  158.             Text = "-",
  159.             TextSize = 17,
  160.             TextColor3 = options.txtcolor,
  161.             Font = Enum.Font.SourceSans;
  162.             Parent = window.frame,
  163.         });
  164.    
  165.         togglebutton.MouseButton1Click:connect(function()
  166.             window.closed = not window.closed
  167.             togglebutton.Text = (window.closed and "+" or "-")
  168.             if window.closed then
  169.                 window:Resize(true, UDim2.new(1, 0, 0, 0))
  170.             else
  171.                 window:Resize(true)
  172.             end
  173.         end)
  174.    
  175.         self:Create("TextLabel", {
  176.             Size = UDim2.new(1, 0, 1, 0),
  177.             BackgroundTransparency = 1;
  178.             BorderSizePixel = 0;
  179.             TextColor3 = options.txtcolor,
  180.             TextColor3 = (options.bartextcolor or Color3.fromRGB(255, 255, 255));
  181.             TextSize = 17,
  182.             Font = Enum.Font.SourceSansSemibold;
  183.             Text = options.text or "window",
  184.             Name = "Window",
  185.             Parent = window.frame,
  186.         })
  187.    
  188.         do
  189.             dragger.new(window.frame)
  190.             resizer.new(window.background, window.container);
  191.         end
  192.    
  193.         local function getSize()
  194.             local ySize = 0;
  195.             for i, object in next, window.container:GetChildren() do
  196.                 if (not object:IsA('UIListLayout')) and (not object:IsA('UIPadding')) then
  197.                     ySize = ySize + object.AbsoluteSize.Y
  198.                 end
  199.             end
  200.             return UDim2.new(1, 0, 0, ySize + 10)
  201.         end
  202.    
  203.         function window:Resize(tween, change)
  204.             local size = change or getSize()
  205.             self.container.ClipsDescendants = true;
  206.            
  207.             if tween then
  208.                 self.background:TweenSize(size, "Out", "Sine", 0.5, true)
  209.             else
  210.                 self.background.Size = size
  211.             end
  212.         end
  213.    
  214.         function window:AddToggle(text, callback)
  215.             self.count = self.count + 1
  216.    
  217.             callback = callback or function() end
  218.             local label = temp:Create("TextLabel", {
  219.                 Text =  text,
  220.                 Size = UDim2.new(1, -10, 0, 20);
  221.                 --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  222.                 BackgroundTransparency = 1;
  223.                 TextColor3 = Color3.fromRGB(255, 255, 255);
  224.                 TextXAlignment = Enum.TextXAlignment.Left;
  225.                 LayoutOrder = self.Count;
  226.                 TextSize = 16,
  227.                 Font = Enum.Font.SourceSans,
  228.                 Parent = self.container;
  229.             })
  230.    
  231.             local button = temp:Create("TextButton", {
  232.                 Text = "OFF",
  233.                 TextColor3 = Color3.fromRGB(255, 25, 25),
  234.                 BackgroundTransparency = 1;
  235.                 Position = UDim2.new(1, -25, 0, 0),
  236.                 Size = UDim2.new(0, 25, 1, 0),
  237.                 TextSize = 17,
  238.                 Font = Enum.Font.SourceSansSemibold,
  239.                 Parent = label;
  240.             })
  241.    
  242.             button.MouseButton1Click:connect(function()
  243.                 self.toggles[text] = (not self.toggles[text])
  244.                 button.TextColor3 = (self.toggles[text] and Color3.fromRGB(0, 255, 140) or Color3.fromRGB(255, 25, 25))
  245.                 button.Text =(self.toggles[text] and "ON" or "OFF")
  246.    
  247.                 callback(self.toggles[text])
  248.             end)
  249.    
  250.             self:Resize()
  251.             return button
  252.         end
  253.    
  254.         function window:AddBox(text, callback)
  255.             self.count = self.count + 1
  256.             callback = callback or function() end
  257.    
  258.             local box = temp:Create("TextBox", {
  259.                 PlaceholderText = text,
  260.                 Size = UDim2.new(1, -10, 0, 20);
  261.                 --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  262.                 BackgroundTransparency = 0.75;
  263.                 BackgroundColor3 = options.boxcolor,
  264.                 TextColor3 = Color3.fromRGB(255, 255, 255);
  265.                 TextXAlignment = Enum.TextXAlignment.Center;
  266.                 TextSize = 16,
  267.                 Text = "",
  268.                 Font = Enum.Font.SourceSans,
  269.                 LayoutOrder = self.Count;
  270.                 BorderSizePixel = 0;
  271.                 Parent = self.container;
  272.             })
  273.    
  274.             box.FocusLost:connect(function(...)
  275.                 callback(box, ...)
  276.             end)
  277.    
  278.             self:Resize()
  279.             return box
  280.         end
  281.    
  282.         function window:AddButton(text, callback)
  283.             self.count = self.count + 1
  284.    
  285.             callback = callback or function() end
  286.             local button = temp:Create("TextButton", {
  287.                 Text =  text,
  288.                 Size = UDim2.new(1, -10, 0, 20);
  289.                 --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  290.                 BackgroundTransparency = 1;
  291.                 TextColor3 = Color3.fromRGB(255, 255, 255);
  292.                 TextXAlignment = Enum.TextXAlignment.Left;
  293.                 TextSize = 16,
  294.                 Font = Enum.Font.SourceSans,
  295.                 LayoutOrder = self.Count;
  296.                 Parent = self.container;
  297.             })
  298.    
  299.             button.MouseButton1Click:connect(callback)
  300.             self:Resize()
  301.             return button
  302.         end
  303.        
  304.         function window:AddLabel(text)
  305.             self.count = self.count + 1;
  306.            
  307.             local tSize = game:GetService('TextService'):GetTextSize(text, 16, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  308.    
  309.             local button = temp:Create("TextLabel", {
  310.                 Text =  text,
  311.                 Size = UDim2.new(1, -10, 0, tSize.Y + 5);
  312.                 TextScaled = false;
  313.                 BackgroundTransparency = 1;
  314.                 TextColor3 = Color3.fromRGB(255, 255, 255);
  315.                 TextXAlignment = Enum.TextXAlignment.Left;
  316.                 TextSize = 16,
  317.                 Font = Enum.Font.SourceSans,
  318.                 LayoutOrder = self.Count;
  319.                 Parent = self.container;
  320.             })
  321.    
  322.             self:Resize()
  323.             return button
  324.         end
  325.    
  326.         function window:AddDropdown(options, callback)
  327.             self.count = self.count + 1
  328.             local default = options[1] or "";
  329.            
  330.             callback = callback or function() end
  331.             local dropdown = temp:Create("TextLabel", {
  332.                 Size = UDim2.new(1, -10, 0, 20);
  333.                 BackgroundTransparency = 0.75;
  334.                 BackgroundColor3 = options.boxcolor,
  335.                 TextColor3 = Color3.fromRGB(255, 255, 255);
  336.                 TextXAlignment = Enum.TextXAlignment.Center;
  337.                 TextSize = 16,
  338.                 Text = default,
  339.                 Font = Enum.Font.SourceSans,
  340.                 BorderSizePixel = 0;
  341.                 LayoutOrder = self.Count;
  342.                 Parent = self.container;
  343.             })
  344.            
  345.             local button = temp:Create("ImageButton",{
  346.                 BackgroundTransparency = 1;
  347.                 Image = 'rbxassetid://3234893186';
  348.                 Size = UDim2.new(0, 18, 1, 0);
  349.                 Position = UDim2.new(1, -20, 0, 0);
  350.                 Parent = dropdown;
  351.             })
  352.            
  353.             local frame;
  354.            
  355.             local function isInGui(frame)
  356.                 local mloc = game:GetService('UserInputService'):GetMouseLocation();
  357.                 local mouse = Vector2.new(mloc.X, mloc.Y - 36);
  358.                
  359.                 local x1, x2 = frame.AbsolutePosition.X, frame.AbsolutePosition.X + frame.AbsoluteSize.X;
  360.                 local y1, y2 = frame.AbsolutePosition.Y, frame.AbsolutePosition.Y + frame.AbsoluteSize.Y;
  361.            
  362.                 return (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2)
  363.             end
  364.    
  365.             local function count(t)
  366.                 local c = 0;
  367.                 for i, v in next, t do
  368.                     c = c + 1
  369.                 end
  370.                 return c;
  371.             end
  372.            
  373.             button.MouseButton1Click:connect(function()
  374.                 if count(options) == 0 then
  375.                     return
  376.                 end
  377.    
  378.                 if frame then
  379.                     frame:Destroy();
  380.                     frame = nil;
  381.                 end
  382.                
  383.                 self.container.ClipsDescendants = false;
  384.    
  385.                 frame = temp:Create('Frame', {
  386.                     Position = UDim2.new(0, 0, 1, 0);
  387.                     BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  388.                     Size = UDim2.new(0, dropdown.AbsoluteSize.X, 0, (count(options) * 21));
  389.                     BorderSizePixel = 0;
  390.                     Parent = dropdown;
  391.                     ClipsDescendants = true;
  392.                     ZIndex = 2;
  393.                 })
  394.                
  395.                 temp:Create('UIListLayout', {
  396.                     Name = 'Layout';
  397.                     Parent = frame;
  398.                 })
  399.    
  400.                 for i, option in next, options do
  401.                     local selection = temp:Create('TextButton', {
  402.                         Text = option;
  403.                         BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  404.                         TextColor3 = Color3.fromRGB(255, 255, 255);
  405.                         BorderSizePixel = 0;
  406.                         TextSize = 16;
  407.                         Font = Enum.Font.SourceSans;
  408.                         Size = UDim2.new(1, 0, 0, 21);
  409.                         Parent = frame;
  410.                         ZIndex = 2;
  411.                     })
  412.                    
  413.                     selection.MouseButton1Click:connect(function()
  414.                         dropdown.Text = option;
  415.                         callback(option)
  416.                         frame.Size = UDim2.new(1, 0, 0, 0);
  417.                         game:GetService('Debris'):AddItem(frame, 0.1)
  418.                     end)
  419.                 end
  420.             end);
  421.    
  422.             game:GetService('UserInputService').InputBegan:connect(function(m)
  423.                 if m.UserInputType == Enum.UserInputType.MouseButton1 then
  424.                     if frame and (not isInGui(frame)) then
  425.                         game:GetService('Debris'):AddItem(frame);
  426.                     end
  427.                 end
  428.             end)
  429.            
  430.             callback(default);
  431.             self:Resize()
  432.             return {
  433.                 Refresh = function(self, array)
  434.                     game:GetService('Debris'):AddItem(frame);
  435.                     options = array
  436.                     dropdown.Text = options[1];
  437.                 end
  438.             }
  439.         end;
  440.        
  441.        
  442.         return window
  443.     end
  444.    
  445.     return temp
  446. end
  447.  
  448. function library:Get()
  449.     return self.new()
  450. end
  451.  
  452. return library
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement