DogeOfTheDoges

nonowordlol

Feb 28th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.46 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. BackgroundColor3 = options.underline;
  133. Parent = window.frame
  134. })
  135.  
  136. local togglebutton = self:Create("TextButton", {
  137. Name = 'Toggle';
  138. ZIndex = 2,
  139. BackgroundTransparency = 1;
  140. Position = UDim2.new(1, -25, 0, 0),
  141. Size = UDim2.new(0, 25, 1, 0),
  142. Text = "-",
  143. TextSize = 17,
  144. TextColor3 = options.txtcolor,
  145. Font = Enum.Font.SourceSans;
  146. Parent = window.frame,
  147. });
  148.  
  149. togglebutton.MouseButton1Click:connect(function()
  150. window.closed = not window.closed
  151. togglebutton.Text = (window.closed and "+" or "-")
  152. if window.closed then
  153. window:Resize(true, UDim2.new(1, 0, 0, 0))
  154. else
  155. window:Resize(true)
  156. end
  157. end)
  158.  
  159. self:Create("TextLabel", {
  160. Size = UDim2.new(1, 0, 1, 0),
  161. BackgroundTransparency = 1;
  162. BorderSizePixel = 0;
  163. TextColor3 = options.txtcolor,
  164. TextColor3 = (options.bartextcolor or Color3.fromRGB(255, 255, 255));
  165. TextSize = 17,
  166. Font = Enum.Font.SourceSansSemibold;
  167. Text = options.text or "window",
  168. Name = "Window",
  169. Parent = window.frame,
  170. })
  171.  
  172. do
  173. dragger.new(window.frame)
  174. resizer.new(window.background, window.container);
  175. end
  176.  
  177. local function getSize()
  178. local ySize = 0;
  179. for i, object in next, window.container:GetChildren() do
  180. if (not object:IsA('UIListLayout')) and (not object:IsA('UIPadding')) then
  181. ySize = ySize + object.AbsoluteSize.Y
  182. end
  183. end
  184. return UDim2.new(1, 0, 0, ySize + 10)
  185. end
  186.  
  187. function window:Resize(tween, change)
  188. local size = change or getSize()
  189. self.container.ClipsDescendants = true;
  190.  
  191. if tween then
  192. self.background:TweenSize(size, "Out", "Sine", 0.5, true)
  193. else
  194. self.background.Size = size
  195. end
  196. end
  197.  
  198. function window:AddToggle(text, callback)
  199. self.count = self.count + 1
  200.  
  201. callback = callback or function() end
  202. local label = library:Create("TextLabel", {
  203. Text = text,
  204. Size = UDim2.new(1, -10, 0, 20);
  205. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  206. BackgroundTransparency = 1;
  207. TextColor3 = Color3.fromRGB(255, 255, 255);
  208. TextXAlignment = Enum.TextXAlignment.Left;
  209. LayoutOrder = self.Count;
  210. TextSize = 16,
  211. Font = Enum.Font.SourceSans,
  212. Parent = self.container;
  213. })
  214.  
  215. local button = library:Create("TextButton", {
  216. Text = "OFF",
  217. TextColor3 = Color3.fromRGB(255, 25, 25),
  218. BackgroundTransparency = 1;
  219. Position = UDim2.new(1, -25, 0, 0),
  220. Size = UDim2.new(0, 25, 1, 0),
  221. TextSize = 17,
  222. Font = Enum.Font.SourceSansSemibold,
  223. Parent = label;
  224. })
  225.  
  226. button.MouseButton1Click:connect(function()
  227. self.toggles[text] = (not self.toggles[text])
  228. button.TextColor3 = (self.toggles[text] and Color3.fromRGB(0, 255, 140) or Color3.fromRGB(255, 25, 25))
  229. button.Text =(self.toggles[text] and "ON" or "OFF")
  230.  
  231. callback(self.toggles[text])
  232. end)
  233.  
  234. self:Resize()
  235. return button
  236. end
  237.  
  238. function window:AddBox(text, callback)
  239. self.count = self.count + 1
  240. callback = callback or function() end
  241.  
  242. local box = library:Create("TextBox", {
  243. PlaceholderText = text,
  244. Size = UDim2.new(1, -10, 0, 20);
  245. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  246. BackgroundTransparency = 0.75;
  247. BackgroundColor3 = options.boxcolor,
  248. TextColor3 = Color3.fromRGB(255, 255, 255);
  249. TextXAlignment = Enum.TextXAlignment.Center;
  250. TextSize = 16,
  251. Text = "",
  252. Font = Enum.Font.SourceSans,
  253. LayoutOrder = self.Count;
  254. BorderSizePixel = 0;
  255. Parent = self.container;
  256. })
  257.  
  258. box.FocusLost:connect(function(...)
  259. callback(box, ...)
  260. end)
  261.  
  262. self:Resize()
  263. return box
  264. end
  265.  
  266. function window:AddButton(text, callback)
  267. self.count = self.count + 1
  268.  
  269. callback = callback or function() end
  270. local button = library:Create("TextButton", {
  271. Text = text,
  272. Size = UDim2.new(1, -10, 0, 20);
  273. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  274. BackgroundTransparency = 0.15;
  275. BackgroundColor3 = options.boxcolor,
  276. TextColor3 = Color3.fromRGB(255, 255, 255);
  277. TextXAlignment = Enum.TextXAlignment.Left;
  278. TextSize = 16,
  279. Font = Enum.Font.SourceSans,
  280. LayoutOrder = self.Count;
  281. Parent = self.container;
  282. })
  283.  
  284. button.MouseButton1Click:connect(callback)
  285. self:Resize()
  286. return button
  287. end
  288.  
  289. function window:AddLabel(text)
  290. self.count = self.count + 1;
  291.  
  292. local tSize = game:GetService('TextService'):GetTextSize(text, 16, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  293.  
  294. local button = library:Create("TextLabel", {
  295. Text = text,
  296. Size = UDim2.new(1, -10, 0, tSize.Y + 5);
  297. TextScaled = false;
  298. BackgroundTransparency = 1;
  299. TextColor3 = Color3.fromRGB(255, 255, 255);
  300. TextXAlignment = Enum.TextXAlignment.Left;
  301. TextSize = 16,
  302. Font = Enum.Font.SourceSans,
  303. LayoutOrder = self.Count;
  304. Parent = self.container;
  305. })
  306.  
  307. self:Resize()
  308. return button
  309. end
  310.  
  311. function window:AddDropdown(options, callback)
  312. self.count = self.count + 1
  313. local default = options[1] or "";
  314.  
  315. callback = callback or function() end
  316. local dropdown = library:Create("TextLabel", {
  317. Size = UDim2.new(1, -10, 0, 20);
  318. BackgroundTransparency = 0.75;
  319. BackgroundColor3 = options.boxcolor,
  320. TextColor3 = Color3.fromRGB(255, 255, 255);
  321. TextXAlignment = Enum.TextXAlignment.Center;
  322. TextSize = 16,
  323. Text = default,
  324. Font = Enum.Font.SourceSans,
  325. BorderSizePixel = 0;
  326. LayoutOrder = self.Count;
  327. Parent = self.container;
  328. })
  329.  
  330. local button = library:Create("ImageButton",{
  331. BackgroundTransparency = 1;
  332. Image = 'rbxassetid://3234893186';
  333. Size = UDim2.new(0, 18, 1, 0);
  334. Position = UDim2.new(1, -20, 0, 0);
  335. Parent = dropdown;
  336. })
  337.  
  338. local frame;
  339.  
  340. local function isInGui(frame)
  341. local mloc = game:GetService('UserInputService'):GetMouseLocation();
  342. local mouse = Vector2.new(mloc.X, mloc.Y - 36);
  343.  
  344. local x1, x2 = frame.AbsolutePosition.X, frame.AbsolutePosition.X + frame.AbsoluteSize.X;
  345. local y1, y2 = frame.AbsolutePosition.Y, frame.AbsolutePosition.Y + frame.AbsoluteSize.Y;
  346.  
  347. return (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2)
  348. end
  349.  
  350. local function count(t)
  351. local c = 0;
  352. for i, v in next, t do
  353. c = c + 1
  354. end
  355. return c;
  356. end
  357.  
  358. button.MouseButton1Click:connect(function()
  359. if count(options) == 0 then
  360. return
  361. end
  362.  
  363. if frame then
  364. frame:Destroy();
  365. frame = nil;
  366. end
  367.  
  368. self.container.ClipsDescendants = false;
  369.  
  370. frame = library:Create('Frame', {
  371. Position = UDim2.new(0, 0, 1, 0);
  372. BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  373. Size = UDim2.new(0, dropdown.AbsoluteSize.X, 0, (count(options) * 21));
  374. BorderSizePixel = 0;
  375. Parent = dropdown;
  376. ClipsDescendants = true;
  377. ZIndex = 2;
  378. })
  379.  
  380. library:Create('UIListLayout', {
  381. Name = 'Layout';
  382. Parent = frame;
  383. })
  384.  
  385. for i, option in next, options do
  386. local selection = library:Create('TextButton', {
  387. Text = option;
  388. BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  389. TextColor3 = Color3.fromRGB(255, 255, 255);
  390. BorderSizePixel = 0;
  391. TextSize = 16;
  392. Font = Enum.Font.SourceSans;
  393. Size = UDim2.new(1, 0, 0, 21);
  394. Parent = frame;
  395. ZIndex = 2;
  396. })
  397.  
  398. selection.MouseButton1Click:connect(function()
  399. dropdown.Text = option;
  400. callback(option)
  401. frame.Size = UDim2.new(1, 0, 0, 0);
  402. game:GetService('Debris'):AddItem(frame, 0.1)
  403. end)
  404. end
  405. end);
  406.  
  407. game:GetService('UserInputService').InputBegan:connect(function(m)
  408. if m.UserInputType == Enum.UserInputType.MouseButton1 then
  409. if frame and (not isInGui(frame)) then
  410. game:GetService('Debris'):AddItem(frame);
  411. end
  412. end
  413. end)
  414.  
  415. callback(default);
  416. self:Resize()
  417. return {
  418. Refresh = function(self, array)
  419. game:GetService('Debris'):AddItem(frame);
  420. options = array
  421. dropdown.Text = options[1];
  422. end
  423. }
  424. end;
  425.  
  426.  
  427. return window
  428. end
  429.  
  430. return library
Add Comment
Please, Sign In to add comment