Advertisement
Guest User

New UI

a guest
Aug 22nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.90 KB | None | 0 0
  1. -- Wally library modified by Aztup
  2. -- Design idea by 7th
  3. -- You don't have the perm to use it without the perm of Aztup
  4.  
  5. local Heartbeat = game:GetService("RunService").Heartbeat;
  6. local library = {
  7. windowcount = 0;
  8. }
  9.  
  10. local defaults = defaults or {
  11. boxcolor = nil,
  12. Rainbow = true,
  13. slidingbarcolor = nil,
  14. txtcolor = Color3.fromRGB(255, 255, 255),
  15. underline = Color3.fromRGB(0, 255, 140),
  16. barcolor = Color3.fromRGB(50, 50, 50),
  17. bgcolor = Color3.fromRGB(50, 50, 50)
  18. };
  19.  
  20. if game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("Aztup's UI") then
  21. game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("Aztup's UI"):Destroy();
  22. end
  23.  
  24. if game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("Aztup's UI") then
  25. local text = string.split(game.Players.LocalPlayer.PlayerGui["Aztup's UI"]['Player Cheats'].Container.Frame.TextLabel.Text, ":")
  26. local Val = tonumber(text[2])
  27. end
  28.  
  29. local tweenPosition = function (object, newpos)
  30. object.Position = newpos
  31. end;
  32.  
  33. local dragger = {};
  34. local resizer = {};
  35. local frames = {};
  36. local Callbacks = {};
  37. local Enabled = {};
  38.  
  39. do
  40. local mouse = game:GetService("Players").LocalPlayer:GetMouse();
  41. local inputService = game:GetService('UserInputService');
  42.  
  43. function dragger.new(frame)
  44. local s, event = pcall(function()
  45. return frame.MouseEnter;
  46. end);
  47.  
  48. if s then
  49. frame.Active = true;
  50.  
  51. event:connect(function()
  52. local input = frame.InputBegan:connect(function(key)
  53. if key.UserInputType == Enum.UserInputType.MouseButton1 then
  54. local objectPosition = Vector2.new(mouse.X - frame.AbsolutePosition.X, mouse.Y - frame.AbsolutePosition.Y);
  55. while Heartbeat:wait() and inputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
  56. 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, true);
  57. end;
  58. end;
  59. end);
  60.  
  61. local leave;
  62. leave = frame.MouseLeave:connect(function()
  63. input:disconnect();
  64. leave:disconnect();
  65. end)
  66. end)
  67. end
  68. end
  69.  
  70. function resizer.new(p, s)
  71. p:GetPropertyChangedSignal('AbsoluteSize'):connect(function()
  72. s.Size = UDim2.new(s.Size.X.Scale, s.Size.X.Offset, s.Size.Y.Scale, p.AbsoluteSize.Y);
  73. end)
  74. end
  75. end;
  76.  
  77. function library:Create(class, props)
  78. local object = Instance.new(class);
  79.  
  80. for i, prop in next, props do
  81. if i ~= "Parent" then
  82. object[i] = prop;
  83. end
  84. end
  85.  
  86. object.Parent = props.Parent;
  87. return object;
  88. end
  89.  
  90.  
  91. function library:CreateWindow(options)
  92. assert(options.text, "no name");
  93. local window = {
  94. count = 0;
  95. toggles = {},
  96. closed = false;
  97. }
  98.  
  99. local options = options or {};
  100. setmetatable(options, {__index = defaults})
  101.  
  102. self.windowcount = self.windowcount + 1;
  103.  
  104. library.gui = library.gui or self:Create("ScreenGui", {Name = "Aztup's UI", Parent = game:GetService("Players").LocalPlayer.PlayerGui})
  105. library.gui.ResetOnSpawn = false
  106.  
  107. window.frame = self:Create("Frame", {
  108. Name = options.text;
  109. Parent = self.gui,
  110. Visible = false,
  111. Active = true,
  112. BackgroundTransparency = 0,
  113. Size = UDim2.new(0, 178, 0, 30),
  114. Position = UDim2.new(0, (5 + ((178 * self.windowcount) - 178)), 0, 5),
  115. BackgroundColor3 = options.barcolor,
  116. BorderSizePixel = 0
  117. });
  118.  
  119. frames[#frames + 1] = window.frame;
  120.  
  121. window.background = self:Create('Frame', {
  122. Name = 'Background';
  123. Parent = window.frame,
  124. BorderSizePixel = 0;
  125. BackgroundColor3 = options.bgcolor,
  126. Position = UDim2.new(0, 0, 1, 0),
  127. Size = UDim2.new(1, 0, 0, 25),
  128. BackgroundTransparency = 0.4,
  129. ClipsDescendants = true;
  130. })
  131.  
  132. window.container = self:Create('ScrollingFrame', {
  133. Name = 'Container';
  134. Parent = window.frame,
  135. BorderSizePixel = 0,
  136. BorderSizePixel = 0,
  137. BackgroundColor3 = options.bgcolor,
  138. CanvasSize = UDim2.new(0, 0, 0, 0),
  139. BottomImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  140. TopImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  141. Position = UDim2.new(0, 0, 1, 0),
  142. Size = UDim2.new(1, 0, 0, 25),
  143. BackgroundTransparency = 0.4,
  144. ClipsDescendants = true,
  145. ScrollBarThickness = 10
  146. })
  147.  
  148. window.organizer = self:Create('UIListLayout', {
  149. Name = 'Sorter';
  150. SortOrder = Enum.SortOrder.LayoutOrder;
  151. Parent = window.container;
  152. })
  153.  
  154. window.padder = self:Create('UIPadding', {
  155. Name = 'Padding';
  156. PaddingLeft = UDim.new(0, 10);
  157. PaddingTop = UDim.new(0, 5);
  158. Parent = window.container;
  159. })
  160.  
  161. local underline = self:Create("Frame", {
  162. Name = 'Underline';
  163. Size = UDim2.new(1, 0, 0, 3),
  164. Position = UDim2.new(0, 0, 1, -1),
  165. BorderSizePixel = 0;
  166. BackgroundColor3 = options.underline;
  167. Parent = window.frame
  168. })
  169.  
  170. local togglebutton = self:Create("TextButton", {
  171. Name = 'Toggle';
  172. ZIndex = 2,
  173. BackgroundTransparency = 1;
  174. Position = UDim2.new(1, -25, 0, 0),
  175. Size = UDim2.new(0, 25, 1, 0),
  176. Text = "-",
  177. TextSize = 17,
  178. TextColor3 = options.txtcolor,
  179. Font = Enum.Font.SourceSans,
  180. Parent = window.frame,
  181. });
  182.  
  183. togglebutton.MouseButton1Click:connect(function()
  184. window.closed = not window.closed;
  185. togglebutton.Text = (window.closed and "+" or "-");
  186. if window.closed then
  187. window:Resize(true, UDim2.new(1, 0, 0, 0));
  188. wait(0.4)
  189. window.container.Visible = false
  190. else
  191. window.container.Visible = true
  192. window:Resize(true);
  193. end;
  194. end);
  195.  
  196. self:Create("TextLabel", {
  197. Size = UDim2.new(1, 0, 1, 0),
  198. BackgroundTransparency = 1,
  199. BorderSizePixel = 0,
  200. TextColor3 = options.txtcolor,
  201. TextColor3 = (options.bartextcolor or Color3.fromRGB(255, 255, 255)),
  202. TextSize = 17,
  203. Font = Enum.Font.SourceSansSemibold,
  204. Text = options.text or "window",
  205. Name = "Window",
  206. Parent = window.frame,
  207. })
  208.  
  209. local open = {}
  210.  
  211. do
  212. dragger.new(window.frame)
  213. resizer.new(window.background, window.container);
  214. end
  215.  
  216. local function getSize()
  217. local ySize = 0;
  218. for i, object in next, window.container:GetChildren() do
  219. if (not object:IsA('UIListLayout')) and (not object:IsA('UIPadding')) then
  220. ySize = ySize + object.AbsoluteSize.Y
  221. end
  222. end
  223.  
  224. if ySize > 400 then
  225. ySize = 400;
  226. window.container.CanvasSize = UDim2.new(0, 0, 0, (#window.container:GetChildren() - 1) * 20)
  227. end;
  228.  
  229. return UDim2.new(1, 0, 0, ySize + 10)
  230. end
  231.  
  232. function window:Resize(tween, change)
  233. local size = change or getSize()
  234. self.container.ClipsDescendants = true;
  235.  
  236. if tween then
  237. self.background:TweenSize(size, "Out", "Sine", 0.5, true)
  238. else
  239. self.background.Size = size
  240. end
  241. end
  242.  
  243. function window:AddSlidingBar(text, minval, maxval, callback)
  244. self.count = self.count + 1;
  245. callback = callback or function() end;
  246. minval = minval or 0;
  247. maxval = maxval or 100;
  248.  
  249. maxval = maxval / 8;
  250.  
  251. local newContainer = library:Create("Frame", {
  252. Parent = self.container,
  253. Size = UDim2.new(1, -10, 0, 20),
  254. BackgroundColor3 = options.slidingbarcolor,
  255. BackgroundTransparency = 1,
  256. })
  257.  
  258. local slidingbar = library:Create("ScrollingFrame", {
  259. Parent = newContainer,
  260. Size = UDim2.new(1, -10, 0, 20),
  261. CanvasSize = UDim2.new(8, 0, 0, 0),
  262. BackgroundColor3 = options.slidingbarcolor,
  263. BottomImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  264. TopImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  265. MidImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  266. ScrollBarThickness = 20,
  267. ScrollBarImageColor3 = Color3.fromRGB(0, 0, 0),
  268. ScrollBarImageTransparency = 0.3,
  269. });
  270.  
  271. local label = library:Create("TextLabel", {
  272. Size = UDim2.new(1, 0, 1, 0),
  273. BackgroundTransparency = 1,
  274. BackgroundColor3 = options.slidingbarcolor,
  275. TextColor3 = Color3.fromRGB(255, 255, 255),
  276. TextXAlignment = Enum.TextXAlignment.Center,
  277. TextSize = 16,
  278. Text = text .. ": " .. minval,
  279. Font = Enum.Font.SourceSans,
  280. LayoutOrder = self.Count,
  281. BorderSizePixel = 0,
  282. Parent = newContainer,
  283. })
  284.  
  285. slidingbar.Changed:Connect(function(p)
  286. if p ~= "CanvasPosition" then return end
  287.  
  288. local Val = minval - math.floor((slidingbar.CanvasPosition.X / (slidingbar.CanvasSize.X.Offset - slidingbar.AbsoluteWindowSize.X)) * maxval)
  289. label.Text = text .. ": " .. tostring(Val);
  290. callback(Val);
  291. end)
  292.  
  293. self:Resize();
  294.  
  295. end;
  296.  
  297. function window:AddToggle(text, callback)
  298. self.count = self.count + 1;
  299.  
  300. callback = callback or function() end;
  301.  
  302. local label = library:Create("TextLabel", {
  303. Text = text,
  304. Size = UDim2.new(1, -10, 0, 20),
  305. BackgroundTransparency = 1,
  306. TextColor3 = Color3.fromRGB(255, 255, 255),
  307. TextXAlignment = Enum.TextXAlignment.Left,
  308. LayoutOrder = self.Count,
  309. TextSize = 16,
  310. Font = Enum.Font.SourceSans,
  311. Parent = self.container,
  312. })
  313.  
  314. local button = library:Create("TextButton", {
  315. Text = "OFF",
  316. TextColor3 = Color3.fromRGB(255, 25, 25),
  317. BackgroundTransparency = 1,
  318. Position = UDim2.new(1, -25, 0, 0),
  319. Size = UDim2.new(0, 25, 1, 0),
  320. TextSize = 17,
  321. Font = Enum.Font.SourceSansSemibold,
  322. Parent = label,
  323. })
  324.  
  325. Callbacks[text] = function(toggle)
  326. if not toggle then
  327. toggle = not self.toggles[text];
  328. end;
  329.  
  330. self.toggles[text] = toggle;
  331. Enabled[text] = toggle;
  332. button.TextColor3 = (self.toggles[text] and Color3.fromRGB(0, 255, 140) or Color3.fromRGB(255, 25, 25));
  333. button.Text = (self.toggles[text] and "ON" or "OFF");
  334.  
  335. callback(self.toggles[text]);
  336. end;
  337.  
  338. button.MouseButton1Click:connect(Callbacks[text]);
  339.  
  340. self:Resize();
  341. return button;
  342. end
  343.  
  344. function window:AddBox(text, callback)
  345. self.count = self.count + 1
  346. callback = callback or function() end
  347.  
  348. local box = library:Create("TextBox", {
  349. PlaceholderText = text,
  350. Size = UDim2.new(1, -10, 0, 20),
  351. BackgroundTransparency = 0.75,
  352. BackgroundColor3 = options.boxcolor,
  353. TextColor3 = Color3.fromRGB(255, 255, 255),
  354. TextXAlignment = Enum.TextXAlignment.Center,
  355. TextSize = 16,
  356. Text = "",
  357. Font = Enum.Font.SourceSans,
  358. LayoutOrder = self.Count,
  359. BorderSizePixel = 0,
  360. Parent = self.container,
  361. })
  362.  
  363. box.FocusLost:connect(function(...)
  364. callback(box, ...)
  365. end)
  366.  
  367. self:Resize()
  368. return box
  369. end
  370.  
  371. function window:AddButton(text, callback)
  372. self.count = self.count + 1
  373.  
  374. callback = callback or function() end
  375.  
  376. local button = library:Create("TextButton", {
  377. Text = text,
  378. Size = UDim2.new(1, -10, 0, 20),
  379. BackgroundTransparency = 1,
  380. TextColor3 = Color3.fromRGB(255, 255, 255),
  381. TextXAlignment = Enum.TextXAlignment.Left,
  382. TextSize = 16,
  383. Font = Enum.Font.SourceSans,
  384. LayoutOrder = self.Count,
  385. Parent = self.container,
  386. })
  387.  
  388. button.MouseButton1Click:connect(callback)
  389. self:Resize()
  390. return button
  391. end
  392.  
  393. function window:AddLabel(text)
  394. self.count = self.count + 1;
  395.  
  396. local tSize = game:GetService('TextService'):GetTextSize(text, 16, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  397.  
  398. local button = library:Create("TextLabel", {
  399. Text = text,
  400. Size = UDim2.new(1, -10, 0, tSize.Y + 5),
  401. TextScaled = false,
  402. BackgroundTransparency = 1,
  403. TextColor3 = Color3.fromRGB(255, 255, 255),
  404. TextXAlignment = Enum.TextXAlignment.Left,
  405. TextSize = 16,
  406. Font = Enum.Font.SourceSans,
  407. LayoutOrder = self.Count,
  408. Parent = self.container,
  409. });
  410.  
  411. self:Resize();
  412. return button;
  413. end;
  414.  
  415. function window:AddDropdown(options, callback)
  416. self.count = self.count + 1
  417. local default = options[1] or "";
  418.  
  419. callback = callback or function() end
  420. local dropdown = library:Create("TextLabel", {
  421. Size = UDim2.new(1, -10, 0, 20),
  422. BackgroundTransparency = 0.75,
  423. BackgroundColor3 = options.boxcolor,
  424. TextColor3 = Color3.fromRGB(255, 255, 255),
  425. TextXAlignment = Enum.TextXAlignment.Center,
  426. TextSize = 16,
  427. Text = default,
  428. Font = Enum.Font.SourceSans,
  429. BorderSizePixel = 0;
  430. LayoutOrder = self.Count,
  431. Parent = self.container,
  432. })
  433.  
  434. local button = library:Create("ImageButton",{
  435. BackgroundTransparency = 1,
  436. Image = 'rbxassetid://3234893186',
  437. Size = UDim2.new(0, 18, 1, 0),
  438. Position = UDim2.new(1, -20, 0, 0),
  439. Parent = dropdown,
  440. })
  441.  
  442. local frame;
  443.  
  444. local function isInGui(frame)
  445. local mloc = game:GetService('UserInputService'):GetMouseLocation();
  446. local mouse = Vector2.new(mloc.X, mloc.Y - 36);
  447.  
  448. local x1, x2 = frame.AbsolutePosition.X, frame.AbsolutePosition.X + frame.AbsoluteSize.X;
  449. local y1, y2 = frame.AbsolutePosition.Y, frame.AbsolutePosition.Y + frame.AbsoluteSize.Y;
  450.  
  451. return (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2);
  452. end;
  453.  
  454. local function count(t)
  455. local c = 0;
  456. for i, v in next, t do
  457. c = c + 1;
  458. end;
  459. return c;
  460. end;
  461.  
  462. button.MouseButton1Click:connect(function()
  463. if count(options) == 0 then
  464. return;
  465. end;
  466.  
  467. if frame then
  468. frame:Destroy();
  469. frame = nil;
  470. end
  471.  
  472. self.container.ClipsDescendants = false;
  473.  
  474. frame = library:Create('Frame', {
  475. Position = UDim2.new(0, 0, 1, 0);
  476. BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  477. Size = UDim2.new(0, dropdown.AbsoluteSize.X, 0, (count(options) * 21));
  478. BorderSizePixel = 0;
  479. Parent = dropdown;
  480. ClipsDescendants = true;
  481. ZIndex = 2;
  482. })
  483.  
  484. library:Create('UIListLayout', {
  485. Name = 'Layout';
  486. Parent = frame;
  487. })
  488.  
  489. for i, option in next, options do
  490. local selection = library:Create('TextButton', {
  491. Text = option;
  492. BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  493. TextColor3 = Color3.fromRGB(255, 255, 255);
  494. BorderSizePixel = 0;
  495. TextSize = 16;
  496. Font = Enum.Font.SourceSans;
  497. Size = UDim2.new(1, 0, 0, 21);
  498. Parent = frame;
  499. ZIndex = 2;
  500. })
  501.  
  502. selection.MouseButton1Click:connect(function()
  503. dropdown.Text = option;
  504. callback(option);
  505. frame.Size = UDim2.new(1, 0, 0, 0);
  506. game:GetService('Debris'):AddItem(frame, 0.1);
  507. end);
  508. end;
  509. end);
  510.  
  511. game:GetService('UserInputService').InputBegan:connect(function(m)
  512. if m.UserInputType == Enum.UserInputType.MouseButton1 then
  513. if frame and (not isInGui(frame)) then
  514. game:GetService('Debris'):AddItem(frame);
  515. end
  516. end
  517. end)
  518.  
  519. callback(default);
  520. self:Resize();
  521. return {
  522. Refresh = function(self, array)
  523. game:GetService('Debris'):AddItem(frame);
  524. options = array;
  525. dropdown.Text = options[1];
  526. end;
  527. };
  528. end;
  529.  
  530. return window;
  531. end;
  532.  
  533. if defaults.Rainbow then
  534. Heartbeat:Connect(function()
  535. for i, v in pairs(frames) do
  536. if v.Parent ~= nil then
  537. local r = (math.sin(workspace.DistributedGameTime/2)/2)+0.5
  538. local g = (math.sin(workspace.DistributedGameTime)/2)+0.5
  539. local b = (math.sin(workspace.DistributedGameTime*1.5)/2)+0.5
  540. local color = Color3.new(r, g, b);
  541. v.Underline.BackgroundColor3 = color;
  542. end;
  543. end;
  544. end);
  545. end;
  546.  
  547. return library, frames, Callbacks, Enabled
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement