Advertisement
SirrVindict

Untitled

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