Advertisement
SirrVindict

Untitled

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