Advertisement
asgargg

ctfvguionkm,p

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