Im_not_a_robot

juniorjacob's ui library

Jul 6th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.74 KB | None | 0 0
  1. --[[
  2.  
  3. size_pos = table, arranged as so: {<udim2>size, <udim2>pos}
  4.  
  5. size of objects:
  6. toggle - {height = 21, width = 99}
  7. slider - {height = 27, width = UDim2.new(1, -(posOffset))}
  8. dropdown - {height = 25, width = 160}
  9. textinput - {height = 21, width = 120}
  10.  
  11. changelog:
  12. - added textinput (returns: mainframe, inputobj)
  13. - added textinputbounds
  14. - dropdown value backgrounds now use darkcoloring
  15.  
  16. previous update:
  17. - redid the math for loading object sizes
  18. - changed dropdown values to change top value and replaces old slot with previous top value
  19.  
  20. --]]
  21.  
  22. -- locals
  23. mouse = game:GetService('Players').LocalPlayer:GetMouse()
  24. dragging, dropdowns = {}, {}
  25.  
  26. -- width / heights for objects
  27. toggleBounds = UDim2.new(0, 99, 0, 21)
  28. sliderBounds = UDim2.new(1, -5, 0, 27)
  29. dropdownBounds = UDim2.new(0, 160, 0, 25)
  30. textinputBounds = UDim2.new(0, 120, 0, 21)
  31.  
  32. -- settings
  33. local ui = {}
  34. ui.Name = ""
  35. ui.Credits = "inspired by bmcq_12, and copied from wallyhub"
  36. ui.loadsize = UDim2.new(0, 598, 0, 325)
  37. ui.theme = true -- true = dark, false = light
  38.  
  39. --[[
  40. dark theme
  41.  
  42. ui.textcolor = Color3.fromRGB(255,255,255)
  43. ui.dark = Color3.fromRGB(26, 26, 26)
  44. ui.light = Color3.fromRGB(30, 30, 30)
  45. ui.border = Color3.fromRGB(42, 42, 42)
  46. ui.slider = Color3.fromRGB(34, 34, 34)
  47.  
  48. light theme
  49.  
  50. ui.textcolor = Color3.fromRGB(0, 0, 0)
  51. ui.dark = Color3.fromRGB(206, 206, 206)
  52. ui.light = Color3.fromRGB(240, 240, 240)
  53. ui.border = Color3.fromRGB(222, 222, 222)
  54. ui.slider = Color3.fromRGB(245, 245, 245)
  55.  
  56. ]]
  57.  
  58. ui.font = Enum.Font.SourceSansLight
  59. ui.font2 = Enum.Font.SourceSans
  60.  
  61. -- load / default ui elements
  62. store = game:GetService('Players').LocalPlayer and game:GetService('Players').LocalPlayer:FindFirstChild('PlayerGui') or game.CoreGui
  63.  
  64. -- start of ui lib functions
  65.  
  66. function createBaseUI()
  67. local bg = Instance.new("Frame")
  68. local lightbg = Instance.new("Frame")
  69. local gametext = Instance.new("TextLabel")
  70. local credits = Instance.new("TextLabel")
  71. local drop = Instance.new("TextButton")
  72.  
  73. bg.Name = "bg"
  74. bg.Parent = main
  75. bg.Active = true
  76. bg.BackgroundColor3 = ui.dark
  77. bg.BorderColor3 = ui.border
  78. bg.Draggable = true
  79. bg.Position = UDim2.new(0.300000012, 0, 0.379999995, 0)
  80. bg.Selectable = true
  81. bg.Size = ui.loadsize
  82.  
  83. gametext.Name = "gametext"
  84. gametext.Parent = bg
  85. gametext.BackgroundColor3 = Color3.new(1, 1, 1)
  86. gametext.BackgroundTransparency = 1
  87. gametext.BorderSizePixel = 0
  88. gametext.Size = UDim2.new(0, 9999999, 0, 30)
  89. gametext.Text = ui.Name
  90. gametext.Size = UDim2.new(0, gametext.TextBounds.X * 2, 0, 30)
  91. gametext.ZIndex = 2
  92. gametext.Font = ui.font
  93. gametext.TextColor3 = ui.textcolor
  94. gametext.TextSize = 20
  95. gametext.TextWrapped = true
  96.  
  97. credits.Name = "credits"
  98. credits.Parent = bg
  99. credits.BackgroundColor3 = Color3.new(1, 1, 1)
  100. credits.BackgroundTransparency = 1
  101. credits.BorderSizePixel = 0
  102. credits.Position = UDim2.new(0, -9, 1, -16)
  103. credits.Size = UDim2.new(1, 0, 0, 15)
  104. credits.ZIndex = 2
  105. credits.Font = ui.font
  106. credits.Text = ui.Credits
  107. credits.TextColor3 = ui.textcolor
  108. credits.TextSize = 18
  109. credits.TextWrapped = true
  110. credits.TextXAlignment = Enum.TextXAlignment.Right
  111. credits.TextYAlignment = Enum.TextYAlignment.Bottom
  112.  
  113. lightbg.Name = "lightbg"
  114. lightbg.Parent = bg
  115. lightbg.BackgroundColor3 = ui.light
  116. lightbg.BorderColor3 = ui.border
  117. lightbg.Size = UDim2.new(1, -8, 1, -(credits.TextBounds.Y + gametext.TextBounds.Y + 2.5))
  118. lightbg.Position = UDim2.new(.5 - (lightbg.Size.X.Scale / 2) or .5, -(lightbg.Size.X.Offset / 2) or 0, 0, (gametext.TextBounds.Y * 2) - ((gametext.TextBounds.Y - credits.TextBounds.Y) * 2))
  119. lightbg.Size = UDim2.new(0, (bg.AbsoluteSize.X - lightbg.Position.X.Offset) - 5, 0, (bg.AbsoluteSize.Y - lightbg.Position.Y.Offset) - (credits.TextBounds.Y + 3))
  120. lightbg.ZIndex = 2
  121.  
  122. drop.Name = "drop"
  123. drop.Parent = bg
  124. drop.BackgroundColor3 = Color3.new(1, 1, 1)
  125. drop.BackgroundTransparency = 1
  126. drop.BorderSizePixel = 0
  127. drop.Position = UDim2.new(1, -30, 0, 2)
  128. drop.Size = UDim2.new(0, 30, 0, 20)
  129. drop.ZIndex = 2
  130. drop.AutoButtonColor = false
  131. drop.Font = ui.font
  132. drop.Text = "v"
  133. drop.TextColor3 = ui.textcolor
  134. drop.TextSize = 23
  135.  
  136. local dropdebounce = false
  137. local dropdelayed = false
  138. drop.MouseButton1Click:connect(function()
  139. dropdebounce = not dropdebounce
  140.  
  141. -- non tween: {0, 598},{0, 325}, tween: {0, 598},{0, 33}
  142. if dropdelayed == false then
  143. if dropdebounce == true then
  144. lightbg.Visible = false
  145. credits.Visible = false
  146. bg:TweenSize(UDim2.new(ui.loadsize.X.Scale, ui.loadsize.X.Offset,ui.loadsize.Y.Scale,33),Enum.EasingDirection.Out,Enum.EasingStyle.Quint,0.7)
  147. else
  148. bg:TweenSize(ui.loadsize,Enum.EasingDirection.Out,Enum.EasingStyle.Quint,0.7)
  149. wait(0.2)
  150. --wait(0.7)
  151. credits.Visible = true
  152. lightbg.Visible = true
  153. end
  154.  
  155. pcall(function()
  156. dropdelayed = true
  157. wait(0.8)
  158. dropdelayed = false
  159. end)
  160. end
  161. end)
  162.  
  163. return bg, lightbg, gametext, credits, drop
  164. end
  165.  
  166. function createTab(name, override)
  167. local tabs = 1
  168.  
  169. local main = Instance.new('TextButton', lightbg)
  170. local area = Instance.new("Frame", lightbg)
  171. local highlight = Instance.new("Frame", main)
  172. local tab = Instance.new("BoolValue", main)
  173. local notdisabled
  174.  
  175. main.Name = name
  176. main.BackgroundColor3 = ui.light
  177. main.BorderColor3 = ui.border
  178. main.BorderSizePixel = 0
  179. main.Position = UDim2.new(0, 10, 0, -10)
  180. main.Size = UDim2.new(1, -20, 0, 11)
  181. main.ZIndex = 4
  182. main.Font = ui.font2
  183. main.Text = name
  184. main.TextColor3 = ui.textcolor
  185. main.TextSize = 14
  186. main.Selectable = false
  187. main.AutoButtonColor = false
  188. main.TextYAlignment = Enum.TextYAlignment.Top
  189.  
  190. highlight.Name = "highlight"
  191. highlight.BackgroundColor3 = Color3.new(0,0,0)
  192. highlight.BorderColor3 = ui.border
  193. highlight.Size = UDim2.new(1, 0, 1, 0)
  194.  
  195. tab.Name = "tab"
  196. tab.Value = override or false
  197.  
  198. area.Name = name..'_'
  199. area.BackgroundColor3 = ui.light
  200. area.BorderColor3 = ui.border
  201. area.Position = UDim2.new(0,0,0,0)
  202. area.Size = UDim2.new(1, 0, 1, 0)
  203. area.ZIndex = 2
  204. area.Visible = override or false
  205.  
  206. -- size & position adjustment
  207. if not override then
  208. -- count tabs
  209. for i,v in pairs(lightbg:GetChildren()) do
  210. if v:FindFirstChild('tab') then
  211. tabs = tabs + 1
  212. end
  213. end
  214. tabs = tabs - 1
  215.  
  216. -- adjustments
  217. for i,v in pairs(lightbg:GetChildren()) do
  218. if typeof(v) == 'Instance' and v:FindFirstChild('tab') then
  219. v.Size = UDim2.new(1 / tabs, -15, 0, 11)
  220.  
  221. if v.tab.Value == true then
  222. v.Position = UDim2.new(0, 10, 0, -10)
  223. else
  224. v.Position = UDim2.new(1 / tabs, 5, 0, -10)
  225. end
  226. end
  227. end
  228. end
  229.  
  230. if tab.Value == false then
  231. main.BackgroundColor3 = ui.dark
  232. area.BackgroundColor3 = ui.dark
  233. main.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01)
  234. area.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01)
  235.  
  236. area.ZIndex = 2
  237. main.ZIndex = 2
  238. area.Visible = false
  239. else
  240. main.BackgroundColor3 = ui.light
  241. area.BackgroundColor3 = ui.light
  242. main.BorderColor3 = ui.border
  243. area.BorderColor3 = ui.border
  244.  
  245. area.ZIndex = 3
  246. main.ZIndex = 4
  247. area.Visible = true
  248. end
  249.  
  250. -- button clicks
  251. main.MouseButton1Click:connect(function()
  252. tab.Value = not tab.Value
  253.  
  254. if tab.Value == true then
  255. for i,v in pairs(lightbg:GetChildren()) do
  256. if not v:FindFirstChild('tab') then
  257. v.Visible = false
  258. elseif v:FindFirstChild('tab') or string.find(v.Name, '_') then
  259. v.BackgroundColor3 = ui.dark
  260. v.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01)
  261.  
  262. v.ZIndex = 2
  263.  
  264. if v:FindFirstChild('tab') then
  265. v.tab.Value = false
  266. end
  267. end
  268. end
  269.  
  270. main.BackgroundColor3 = ui.light
  271. area.BackgroundColor3 = ui.light
  272. main.BorderColor3 = ui.border
  273. area.BorderColor3 = ui.border
  274.  
  275. area.ZIndex = 3
  276. main.ZIndex = 4
  277. area.Visible = true
  278. else
  279. for i,v in pairs(lightbg:GetChildren()) do
  280. if not v:FindFirstChild('tab') then
  281. v.Visible = false
  282. elseif v:FindFirstChild('tab') or string.find(v.Name, '_') then
  283. v.BackgroundColor3 = ui.dark
  284. v.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01)
  285.  
  286. v.ZIndex = 2
  287. end
  288.  
  289. if v:FindFirstChild('tab') and v.tab.Value == true then
  290. notdisabled = v
  291. end
  292.  
  293. if v:FindFirstChild('tab') then
  294. v.tab.Value = false
  295. notdisabled.tab.Value = true
  296. end
  297. end
  298.  
  299. main.BackgroundColor3 = ui.dark
  300. area.BackgroundColor3 = ui.dark
  301. main.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01)
  302. area.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01)
  303.  
  304. area.ZIndex = 2
  305. main.ZIndex = 2
  306. area.Visible = false
  307.  
  308. if not notdisabled then
  309. for i,v in pairs(lightbg:GetChildren()) do
  310. if v:FindFirstChild('tab') then
  311. v.BackgroundColor3 = ui.light
  312. v.BorderColor3 = ui.border
  313. v.ZIndex = 4
  314.  
  315. lightbg:FindFirstChild(v.Name..'_').BackgroundColor3 = ui.light
  316. lightbg:FindFirstChild(v.Name..'_').BorderColor3 = ui.border
  317. lightbg:FindFirstChild(v.Name..'_').ZIndex = 3
  318. lightbg:FindFirstChild(v.Name..'_').Visible = true
  319.  
  320. v.tab.Value = true
  321. break;
  322. end
  323. end
  324. else
  325. notdisabled.BackgroundColor3 = ui.light
  326. notdisabled.BorderColor3 = ui.border
  327. notdisabled.ZIndex = 4
  328.  
  329. lightbg:FindFirstChild(notdisabled.Name..'_').BackgroundColor3 = ui.light
  330. lightbg:FindFirstChild(notdisabled.Name..'_').BorderColor3 = ui.border
  331. lightbg:FindFirstChild(notdisabled.Name..'_').ZIndex = 3
  332. lightbg:FindFirstChild(notdisabled.Name..'_').Visible = true
  333.  
  334. notdisabled.tab.Value = true
  335. end
  336. end
  337. end)
  338.  
  339. return main
  340. end
  341.  
  342. function createSection(name, tab, size_pos)
  343. tab = lightbg:WaitForChild(tab.Name..'_')
  344. local size = size_pos[1] or size_pos["size"]
  345. local pos = size_pos[2] or size_pos["pos"]
  346.  
  347. local bg = Instance.new("Frame", tab)
  348. local label = Instance.new("TextLabel", bg)
  349.  
  350. bg.Name = name
  351. bg.BackgroundColor3 = ui.light
  352. bg.BorderColor3 = ui.border
  353. bg.Position = pos
  354. bg.Size = size
  355. bg.ZIndex = 3
  356.  
  357. label.Name = "label"
  358. label.Text = name
  359. label.BackgroundColor3 = ui.light
  360. label.BorderSizePixel = 0
  361. label.Size = UDim2.new(0, #name * 10, 0, 10)
  362. label.Position = UDim2.new(0.5, -(label.Size.X.Offset / 2), 0, -5)
  363. label.ZIndex = 4
  364. label.Font = ui.font2
  365. label.TextColor3 = ui.textcolor
  366. label.TextSize = 14
  367.  
  368. return bg
  369. end
  370.  
  371. function createToggle(name, section, pos, originalvalue, f, ...)
  372. local debounce = originalvalue or false;
  373. local fargs = {...}
  374.  
  375. local tmain = Instance.new("Frame")
  376. local toggle = Instance.new("ImageButton")
  377. local label = Instance.new("TextLabel")
  378. --Properties:
  379. tmain.Name = name
  380. tmain.Parent = section
  381. tmain.BackgroundTransparency = 1
  382. tmain.BorderSizePixel = 0
  383. tmain.Position = pos
  384. tmain.Size = UDim2.new(0, 0, 0, 21)
  385. tmain.ZIndex = 4
  386.  
  387. toggle.Name = "toggle"
  388. toggle.Parent = tmain
  389. toggle.BackgroundColor3 = ui.dark
  390. toggle.BorderColor3 = ui.border
  391. toggle.Position = UDim2.new(0, 5, 0.5, -7)
  392. toggle.Size = UDim2.new(0, 14, 0, 14)
  393. toggle.ZIndex = 5
  394. toggle.Image = ui.toggleImg
  395. toggle.ImageTransparency = 1
  396. toggle.ScaleType = Enum.ScaleType.Fit
  397.  
  398. label.Name = "label"
  399. label.Parent = tmain
  400. label.BackgroundTransparency = 1
  401. label.BorderSizePixel = 0
  402. label.Position = UDim2.new(0, 25, 0, 0)
  403. label.Size = UDim2.new(0, 75, 1, 0)
  404. label.ZIndex = 5
  405. label.Font = ui.font2
  406. label.Text = name
  407. label.TextColor3 = ui.textcolor
  408. label.TextSize = 14
  409. label.TextXAlignment = Enum.TextXAlignment.Left
  410.  
  411. if debounce == false then toggle.ImageTransparency = 1 else toggle.ImageTransparency = 0 end
  412.  
  413. toggle.MouseButton1Click:connect(function()
  414. debounce = not debounce
  415. if debounce == false then toggle.ImageTransparency = 1 else toggle.ImageTransparency = 0 end
  416. f(debounce, unpack(fargs))
  417. end)
  418.  
  419. game:GetService("ContentProvider"):PreloadAsync({toggle})
  420.  
  421. return tmain
  422. end
  423.  
  424. function createSlider(name, section, pos, maximum, tochange, originalvalue, ...)
  425. local fargs = {...}
  426.  
  427. local smain = Instance.new("Frame")
  428. local sbound = Instance.new("Frame")
  429. local sobj = Instance.new("TextButton")
  430. local label = Instance.new("TextLabel")
  431. local current = Instance.new("TextLabel")
  432. local valueComp = Instance.new("NumberValue", sobj)
  433.  
  434. local ComparableValue = 0;
  435.  
  436. smain.Name = name
  437. smain.Parent = section
  438. smain.BackgroundColor3 = ui.light
  439. smain.BorderColor3 = ui.border
  440. smain.Position = pos
  441. smain.Size = UDim2.new(1, -(pos.X.Offset * 2), 0, 22)
  442. smain.ZIndex = 5
  443.  
  444. sbound.Name = "sbound"
  445. sbound.Parent = smain
  446. sbound.Active = true
  447. sbound.BackgroundColor3 = ui.dark
  448. sbound.BorderColor3 = ui.border
  449. sbound.Position = UDim2.new(0, 8, 0.5, -3)
  450. sbound.Size = UDim2.new(1, -16, 0, 7)
  451. sbound.ZIndex = 5
  452.  
  453. sobj.Name = "sobj"
  454. sobj.Parent = sbound
  455. sobj.BackgroundColor3 = ui.slider
  456. sobj.BorderColor3 = ui.border
  457. sobj.Size = UDim2.new(0, 10, 1, 0)
  458. sobj.ZIndex = 6
  459. sobj.AutoButtonColor = false
  460. sobj.Text = ""
  461. sobj.TextScaled = true
  462. sobj.TextSize = 96
  463. sobj.TextWrapped = true
  464.  
  465. label.Name = "label"
  466. label.Parent = smain
  467. label.BackgroundColor3 = ui.light
  468. label.BorderSizePixel = 0
  469. label.Position = UDim2.new(0.04581438, 0, -0.363247961, 0)
  470. label.Size = UDim2.new(0, 9999, 0, 9999)
  471. label.Size = UDim2.new(0, label.TextBounds.Y + 14, 0, 12)
  472. label.ZIndex = 6
  473. label.Font = ui.font2
  474. label.Text = name
  475. label.TextColor3 = ui.textcolor
  476. label.TextSize = 14
  477.  
  478. current.Name = "current"
  479. current.Parent = smain
  480. current.BackgroundColor3 = ui.light
  481. current.BorderSizePixel = 0
  482. current.Position = UDim2.new(0.800000012, 0, -0.349999994, 0)
  483. current.Size = UDim2.new(0, 33, 0, 12)
  484. current.ZIndex = 6
  485. current.Font = ui.font
  486. current.Text = "0"
  487. current.TextColor3 = ui.textcolor
  488. current.TextSize = 14
  489.  
  490. valueComp.Name = "ComparableValue"
  491.  
  492. if originalvalue ~= nil then
  493. valueComp.Value = originalvalue
  494. end
  495.  
  496. local compare = (math.floor(valueComp.Value) > 1 and math.floor(valueComp.Value) / 10 ^ (#tostring(valueComp.Value))) or valueComp.Value
  497. sobj.Position = UDim2.new(sobj.Position.X.Scale, -(compare * ((sbound.AbsoluteSize.X * compare) - sbound.AbsoluteSize.X)), sobj.Position.Y.Scale, sobj.Position.Y.Offset)
  498. current.Text = tostring(valueComp.Value)
  499.  
  500. sobj.MouseButton1Down:connect(function()
  501. dragging[name] = true
  502. repeat
  503. sobj.Position = UDim2.new(0,(mouse.X - sbound.AbsolutePosition.X),0,0)
  504. if sobj.Position.X.Offset < 0 then
  505. sobj.Position = UDim2.new(0,0,0,0)
  506. elseif sobj.Position.X.Offset + sobj.Size.X.Offset > sbound.AbsoluteSize.X then
  507. sobj.Position = UDim2.new(0,(sbound.AbsoluteSize.X-sobj.Size.X.Offset),0,0)
  508. end
  509.  
  510. ComparableValue = math.floor((sobj.AbsolutePosition.X-sbound.AbsolutePosition.X) / (sbound.AbsoluteSize.X-sobj.Size.X.Offset) * (maximum * 10))
  511. valueComp.Value = ComparableValue / 10
  512. current.Text = tostring(valueComp.Value)
  513. if typeof(tochange) == 'number' then
  514. tochange = valueComp.Value
  515. elseif typeof(tochange) == 'function' then
  516. tochange(valueComp.Value, unpack(fargs))
  517. end
  518. wait()
  519. until dragging[name] == false
  520. end)
  521.  
  522. return smain
  523. end
  524.  
  525. function createButton(name, section, size_pos, f, ...)
  526. local size = size_pos[1] or size_pos["size"]
  527. local pos = size_pos[2] or size_pos["pos"]
  528. local fargs = {...}
  529.  
  530. local button = Instance.new("TextButton", section)
  531. button.Name = name
  532. button.BackgroundColor3 = ui.light
  533. button.BorderColor3 = ui.border
  534. button.Position = pos
  535. button.Size = size
  536. button.ZIndex = 5
  537. button.Font = ui.font2
  538. button.Text = name
  539. button.TextColor3 = ui.textcolor
  540. button.TextSize = 14
  541.  
  542. button.MouseButton1Click:connect(function()
  543. f(unpack(fargs))
  544. end)
  545.  
  546. return button
  547. end
  548.  
  549. function createDropDown(name, section, pos)
  550. local debounce = Instance.new('BoolValue');
  551. local selected = Instance.new('ObjectValue');
  552.  
  553. local dmain = Instance.new("Frame")
  554. local label = Instance.new("TextLabel")
  555. local drop = Instance.new("TextButton")
  556. local dropdownbg = Instance.new("Frame")
  557.  
  558. dmain.Name = name
  559. dmain.Parent = section
  560. dmain.BackgroundColor3 = ui.light
  561. dmain.BorderColor3 = ui.border
  562. dmain.Position = pos
  563. dmain.Size = UDim2.new(0, 160, 0, 25)
  564. dmain.ZIndex = 4
  565.  
  566. label.Name = "label"
  567. label.Parent = dmain
  568. label.BackgroundTransparency = 1
  569. label.BorderSizePixel = 0
  570. label.Position = UDim2.new(0, 5, 0, 0)
  571. label.Size = UDim2.new(0, 75, 1, 0)
  572. label.ZIndex = 5
  573. label.Font = ui.font2
  574. label.Text = name
  575. label.TextColor3 = ui.textcolor
  576. label.TextSize = 14
  577. label.TextXAlignment = Enum.TextXAlignment.Left
  578.  
  579. drop.Name = "drop"
  580. drop.Parent = dmain
  581. drop.BackgroundColor3 = Color3.new(1, 1, 1)
  582. drop.BackgroundTransparency = 1
  583. drop.BorderSizePixel = 0
  584. drop.Position = UDim2.new(1, -25, 0, 6)
  585. drop.Size = UDim2.new(0, 20, 0, 10)
  586. drop.ZIndex = 8
  587. drop.AutoButtonColor = false
  588. drop.Font = ui.font
  589. drop.Text = "v"
  590. drop.TextColor3 = ui.textcolor
  591. drop.TextSize = 14
  592.  
  593. dropdownbg.Name = "dropdownbg"
  594. dropdownbg.Parent = dmain
  595. dropdownbg.BackgroundColor3 = ui.light
  596. dropdownbg.BorderColor3 = ui.border
  597. dropdownbg.Position = UDim2.new(0, 70, 0, 0)
  598. dropdownbg.Size = UDim2.new(0, 90, 0, 25)
  599. dropdownbg.ZIndex = 6
  600.  
  601. debounce.Value = false
  602. debounce.Parent = dmain
  603. debounce.Name = "debounce"
  604.  
  605. selected.Parent = dmain
  606. selected.Name = "selected"
  607.  
  608. drop.MouseButton1Click:connect(function()
  609. debounce.Value = not debounce.Value
  610. if debounce.Value and (#dmain:GetChildren() - 6) > 0 then
  611. dropdownbg:TweenSize(UDim2.new(0, 90, 0, (20 * (#dmain:GetChildren() - 5)) + 5), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.3, true, function(b) -- depends on amount of objects in dropdown
  612. local s = dropdownbg.Size
  613.  
  614. for _,obj in pairs(dmain:GetChildren()) do
  615. if obj:IsA('TextButton') and obj ~= drop then
  616. if s.Y.Offset > obj.Position.Y.Offset then
  617. obj.Visible = true
  618. obj.AutoButtonColor = true
  619. end
  620. end
  621. end
  622. end)
  623. else
  624. for _,obj in pairs(dmain:GetChildren()) do
  625. if obj:IsA('TextButton') and obj ~= drop then
  626. if obj.Position.Y.Offset > 5 then
  627. obj.Visible = false
  628. obj.AutoButtonColor = false
  629. end
  630. end
  631. end
  632.  
  633. dropdownbg:TweenSize(UDim2.new(0, 90, 0, 25), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.3, true)
  634. end
  635. end)
  636.  
  637. dropdowns[dmain] = {}
  638.  
  639. return dmain
  640. end
  641.  
  642. function createDropDownValue(name, dropdown, f, ...)
  643. local fargs = {...}
  644. local debounce = dropdown:FindFirstChild('debounce');
  645. local dropdownbg = dropdown:FindFirstChild('dropdownbg')
  646. local drop = dropdown:FindFirstChild('drop')
  647. local selected = dropdown:FindFirstChild('selected')
  648.  
  649. local ddmain = Instance.new("TextButton")
  650. ddmain.Name = name
  651. ddmain.Parent = dropdown
  652. ddmain.BackgroundColor3 = ui.dark
  653. ddmain.BorderColor3 = ui.border
  654. ddmain.Position = UDim2.new(0, 75, 0, (20 * (#dropdown:GetChildren() - 6)) + 5) -- depends on amount of objects in dropdown
  655. ddmain.Size = UDim2.new(0, 80, 1, -10)
  656. ddmain.ZIndex = 7
  657. ddmain.AutoButtonColor = false
  658. ddmain.Font = ui.font2
  659. ddmain.Text = name
  660. ddmain.TextColor3 = ui.textcolor
  661. ddmain.TextSize = 14
  662. ddmain.TextXAlignment = Enum.TextXAlignment.Left
  663.  
  664. if (#dropdown:GetChildren() - 6) > 0 then -- depends on amount of objects in dropdown
  665. ddmain.Visible = false
  666. end
  667.  
  668. ddmain.MouseButton1Click:connect(function()
  669. if type(dropdowns[dropdown]) == "table" and #dropdowns[dropdown] > 0 then
  670. local backup, backupval = dropdowns[dropdown][0]
  671.  
  672. for i,v in pairs(dropdowns[dropdown]) do
  673. if v == ddmain then
  674. backupval = i
  675. end
  676. end
  677.  
  678. dropdowns[dropdown][0] = ddmain
  679. dropdowns[dropdown][backupval] = backup
  680.  
  681. for __,obj in pairs(dropdowns[dropdown]) do
  682. obj.Position = UDim2.new(0, 75, 0, (20 * __) + 5)
  683. end
  684.  
  685. ddmain.Position = UDim2.new(0, 75, 0, 5)
  686. selected.Value = ddmain
  687. end
  688.  
  689. if f and type(f) == 'function' then
  690. f(unpack(fargs))
  691. end
  692. end)
  693.  
  694. dropdowns[dropdown][#dropdown:GetChildren() - 6] = ddmain -- depends on amount of objects in dropdown
  695.  
  696. return ddmain
  697. end
  698.  
  699. function createTextInput(name, section, pos, originalval, f, ...)
  700. local fargs = {...}
  701.  
  702. local timain = Instance.new("Frame")
  703. local label = Instance.new("TextLabel")
  704. local input = Instance.new("TextBox")
  705.  
  706. timain.Name = name
  707. timain.Parent = section
  708. timain.BackgroundColor3 = ui.light
  709. timain.BorderColor3 = ui.border
  710. timain.Position = pos
  711. timain.Size = UDim2.new(0, 120, 0, 21)
  712. timain.ZIndex = 4
  713.  
  714. label.Name = "label"
  715. label.Parent = timain
  716. label.BackgroundTransparency = 1
  717. label.BorderSizePixel = 0
  718. label.Size = UDim2.new(0, 75, 1, 0)
  719. label.ZIndex = 5
  720. label.Font = ui.font2
  721. label.Text = name
  722. label.TextColor3 = ui.textcolor
  723. label.TextSize = 14
  724.  
  725. input.Name = "input"
  726. input.Parent = timain
  727. input.BackgroundColor3 = ui.dark
  728. input.BorderColor3 = ui.border
  729. input.Position = UDim2.new(0, 75, 0, 0)
  730. input.Size = UDim2.new(0, 45, 1, 0)
  731. input.ZIndex = 5
  732. input.Font = ui.font2
  733. input.Text = originalval or ""
  734. input.PlaceholderText = ""
  735. input.PlaceholderColor3 = ui.textcolor
  736. input.TextColor3 = ui.textcolor
  737. input.TextSize = 14
  738.  
  739. if input.TextBounds.X > input.Size.X.Offset then
  740. input.TextScaled = true
  741. end
  742.  
  743. -- callback always puts text as first arguement, 2nd arguement is always the input object
  744. input:GetPropertyChangedSignal("Text"):connect(function()
  745. if input.TextBounds.X > input.Size.X.Offset then
  746. input.TextScaled = true
  747. else
  748. input.TextScaled = false
  749. end
  750.  
  751. if f and type(f) == 'function' then
  752. f(input.Text, input, unpack(fargs))
  753. end
  754. end)
  755.  
  756. return timain, input
  757. end
  758.  
  759. ui.func = function() end
  760. ui.store = store
  761.  
  762. return ui
Add Comment
Please, Sign In to add comment