Advertisement
Guest User

Untitled

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