GO0GL3_CHR0M3

Crack wally ui lib ver

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