Created
May 10, 2019 01:52
-
-
Save lennyRBLX/4730727213cd90814e4d079ebdfb6d4b to your computer and use it in GitHub Desktop.
Graphical User Interface Library; Creates a Base Interface to add Interface on top of; Created with intent to be used in Roblox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- notes | |
--[[ | |
size_pos = table, arranged as so: {<udim2>size, <udim2>pos} | |
size of objects: | |
toggle - {height = 21, width = 99} | |
slider - {height = 27, width = UDim2.new(1, -(posOffset))} | |
dropdown - {height = 25, width = 160} | |
textinput - {height = 21, width = 120} | |
changelog: | |
- added textinput (returns: mainframe, inputobj) | |
- added textinputbounds | |
- dropdown value backgrounds now use darkcoloring | |
previous update: | |
- redid the math for loading object sizes | |
- changed dropdown values to change top value and replaces old slot with previous top value | |
--]] | |
-- locals | |
mouse = game:GetService('Players').LocalPlayer:GetMouse() | |
dragging, dropdowns = {}, {} | |
-- width / heights for objects | |
toggleBounds = UDim2.new(0, 99, 0, 21) | |
sliderBounds = UDim2.new(1, -5, 0, 27) | |
dropdownBounds = UDim2.new(0, 160, 0, 25) | |
textinputBounds = UDim2.new(0, 120, 0, 21) | |
-- settings | |
local ui = {} | |
ui.Name = "" | |
ui.Credits = "inspired by bmcq_12, and copied from wallyhub" | |
ui.loadsize = UDim2.new(0, 598, 0, 325) | |
ui.theme = true -- true = dark, false = light | |
--[[ | |
dark theme | |
ui.textcolor = Color3.fromRGB(255,255,255) | |
ui.dark = Color3.fromRGB(26, 26, 26) | |
ui.light = Color3.fromRGB(30, 30, 30) | |
ui.border = Color3.fromRGB(42, 42, 42) | |
ui.slider = Color3.fromRGB(34, 34, 34) | |
light theme | |
ui.textcolor = Color3.fromRGB(0, 0, 0) | |
ui.dark = Color3.fromRGB(206, 206, 206) | |
ui.light = Color3.fromRGB(240, 240, 240) | |
ui.border = Color3.fromRGB(222, 222, 222) | |
ui.slider = Color3.fromRGB(245, 245, 245) | |
]] | |
ui.font = Enum.Font.SourceSansLight | |
ui.font2 = Enum.Font.SourceSans | |
-- load / default ui elements | |
store = game:GetService('Players').LocalPlayer and game:GetService('Players').LocalPlayer:FindFirstChild('PlayerGui') or game.CoreGui | |
-- start of ui lib functions | |
function createBaseUI() | |
local bg = Instance.new("Frame") | |
local lightbg = Instance.new("Frame") | |
local gametext = Instance.new("TextLabel") | |
local credits = Instance.new("TextLabel") | |
local drop = Instance.new("TextButton") | |
bg.Name = "bg" | |
bg.Parent = main | |
bg.Active = true | |
bg.BackgroundColor3 = ui.dark | |
bg.BorderColor3 = ui.border | |
bg.Draggable = true | |
bg.Position = UDim2.new(0.300000012, 0, 0.379999995, 0) | |
bg.Selectable = true | |
bg.Size = ui.loadsize | |
gametext.Name = "gametext" | |
gametext.Parent = bg | |
gametext.BackgroundColor3 = Color3.new(1, 1, 1) | |
gametext.BackgroundTransparency = 1 | |
gametext.BorderSizePixel = 0 | |
gametext.Size = UDim2.new(0, 9999999, 0, 30) | |
gametext.Text = ui.Name | |
gametext.Size = UDim2.new(0, gametext.TextBounds.X * 2, 0, 30) | |
gametext.ZIndex = 2 | |
gametext.Font = ui.font | |
gametext.TextColor3 = ui.textcolor | |
gametext.TextSize = 20 | |
gametext.TextWrapped = true | |
credits.Name = "credits" | |
credits.Parent = bg | |
credits.BackgroundColor3 = Color3.new(1, 1, 1) | |
credits.BackgroundTransparency = 1 | |
credits.BorderSizePixel = 0 | |
credits.Position = UDim2.new(0, -9, 1, -16) | |
credits.Size = UDim2.new(1, 0, 0, 15) | |
credits.ZIndex = 2 | |
credits.Font = ui.font | |
credits.Text = ui.Credits | |
credits.TextColor3 = ui.textcolor | |
credits.TextSize = 18 | |
credits.TextWrapped = true | |
credits.TextXAlignment = Enum.TextXAlignment.Right | |
credits.TextYAlignment = Enum.TextYAlignment.Bottom | |
lightbg.Name = "lightbg" | |
lightbg.Parent = bg | |
lightbg.BackgroundColor3 = ui.light | |
lightbg.BorderColor3 = ui.border | |
lightbg.Size = UDim2.new(1, -8, 1, -(credits.TextBounds.Y + gametext.TextBounds.Y + 2.5)) | |
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)) | |
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)) | |
lightbg.ZIndex = 2 | |
drop.Name = "drop" | |
drop.Parent = bg | |
drop.BackgroundColor3 = Color3.new(1, 1, 1) | |
drop.BackgroundTransparency = 1 | |
drop.BorderSizePixel = 0 | |
drop.Position = UDim2.new(1, -30, 0, 2) | |
drop.Size = UDim2.new(0, 30, 0, 20) | |
drop.ZIndex = 2 | |
drop.AutoButtonColor = false | |
drop.Font = ui.font | |
drop.Text = "v" | |
drop.TextColor3 = ui.textcolor | |
drop.TextSize = 23 | |
local dropdebounce = false | |
local dropdelayed = false | |
drop.MouseButton1Click:connect(function() | |
dropdebounce = not dropdebounce | |
-- non tween: {0, 598},{0, 325}, tween: {0, 598},{0, 33} | |
if dropdelayed == false then | |
if dropdebounce == true then | |
lightbg.Visible = false | |
credits.Visible = false | |
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) | |
else | |
bg:TweenSize(ui.loadsize,Enum.EasingDirection.Out,Enum.EasingStyle.Quint,0.7) | |
wait(0.2) | |
--wait(0.7) | |
credits.Visible = true | |
lightbg.Visible = true | |
end | |
pcall(function() | |
dropdelayed = true | |
wait(0.8) | |
dropdelayed = false | |
end) | |
end | |
end) | |
return bg, lightbg, gametext, credits, drop | |
end | |
function createTab(name, override) | |
local tabs = 1 | |
local main = Instance.new('TextButton', lightbg) | |
local area = Instance.new("Frame", lightbg) | |
local highlight = Instance.new("Frame", main) | |
local tab = Instance.new("BoolValue", main) | |
local notdisabled | |
main.Name = name | |
main.BackgroundColor3 = ui.light | |
main.BorderColor3 = ui.border | |
main.BorderSizePixel = 0 | |
main.Position = UDim2.new(0, 10, 0, -10) | |
main.Size = UDim2.new(1, -20, 0, 11) | |
main.ZIndex = 4 | |
main.Font = ui.font2 | |
main.Text = name | |
main.TextColor3 = ui.textcolor | |
main.TextSize = 14 | |
main.Selectable = false | |
main.AutoButtonColor = false | |
main.TextYAlignment = Enum.TextYAlignment.Top | |
highlight.Name = "highlight" | |
highlight.BackgroundColor3 = Color3.new(0,0,0) | |
highlight.BorderColor3 = ui.border | |
highlight.Size = UDim2.new(1, 0, 1, 0) | |
tab.Name = "tab" | |
tab.Value = override or false | |
area.Name = name..'_' | |
area.BackgroundColor3 = ui.light | |
area.BorderColor3 = ui.border | |
area.Position = UDim2.new(0,0,0,0) | |
area.Size = UDim2.new(1, 0, 1, 0) | |
area.ZIndex = 2 | |
area.Visible = override or false | |
-- size & position adjustment | |
if not override then | |
-- count tabs | |
for i,v in pairs(lightbg:GetChildren()) do | |
if v:FindFirstChild('tab') then | |
tabs = tabs + 1 | |
end | |
end | |
tabs = tabs - 1 | |
-- adjustments | |
for i,v in pairs(lightbg:GetChildren()) do | |
if typeof(v) == 'Instance' and v:FindFirstChild('tab') then | |
v.Size = UDim2.new(1 / tabs, -15, 0, 11) | |
if v.tab.Value == true then | |
v.Position = UDim2.new(0, 10, 0, -10) | |
else | |
v.Position = UDim2.new(1 / tabs, 5, 0, -10) | |
end | |
end | |
end | |
end | |
if tab.Value == false then | |
main.BackgroundColor3 = ui.dark | |
area.BackgroundColor3 = ui.dark | |
main.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01) | |
area.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01) | |
area.ZIndex = 2 | |
main.ZIndex = 2 | |
area.Visible = false | |
else | |
main.BackgroundColor3 = ui.light | |
area.BackgroundColor3 = ui.light | |
main.BorderColor3 = ui.border | |
area.BorderColor3 = ui.border | |
area.ZIndex = 3 | |
main.ZIndex = 4 | |
area.Visible = true | |
end | |
-- button clicks | |
main.MouseButton1Click:connect(function() | |
tab.Value = not tab.Value | |
if tab.Value == true then | |
for i,v in pairs(lightbg:GetChildren()) do | |
if not v:FindFirstChild('tab') then | |
v.Visible = false | |
elseif v:FindFirstChild('tab') or string.find(v.Name, '_') then | |
v.BackgroundColor3 = ui.dark | |
v.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01) | |
v.ZIndex = 2 | |
if v:FindFirstChild('tab') then | |
v.tab.Value = false | |
end | |
end | |
end | |
main.BackgroundColor3 = ui.light | |
area.BackgroundColor3 = ui.light | |
main.BorderColor3 = ui.border | |
area.BorderColor3 = ui.border | |
area.ZIndex = 3 | |
main.ZIndex = 4 | |
area.Visible = true | |
else | |
for i,v in pairs(lightbg:GetChildren()) do | |
if not v:FindFirstChild('tab') then | |
v.Visible = false | |
elseif v:FindFirstChild('tab') or string.find(v.Name, '_') then | |
v.BackgroundColor3 = ui.dark | |
v.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01) | |
v.ZIndex = 2 | |
end | |
if v:FindFirstChild('tab') and v.tab.Value == true then | |
notdisabled = v | |
end | |
if v:FindFirstChild('tab') then | |
v.tab.Value = false | |
notdisabled.tab.Value = true | |
end | |
end | |
main.BackgroundColor3 = ui.dark | |
area.BackgroundColor3 = ui.dark | |
main.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01) | |
area.BorderColor3 = Color3.new(ui.border.r - 0.01, ui.border.g - 0.01, ui.border.b - 0.01) | |
area.ZIndex = 2 | |
main.ZIndex = 2 | |
area.Visible = false | |
if not notdisabled then | |
for i,v in pairs(lightbg:GetChildren()) do | |
if v:FindFirstChild('tab') then | |
v.BackgroundColor3 = ui.light | |
v.BorderColor3 = ui.border | |
v.ZIndex = 4 | |
lightbg:FindFirstChild(v.Name..'_').BackgroundColor3 = ui.light | |
lightbg:FindFirstChild(v.Name..'_').BorderColor3 = ui.border | |
lightbg:FindFirstChild(v.Name..'_').ZIndex = 3 | |
lightbg:FindFirstChild(v.Name..'_').Visible = true | |
v.tab.Value = true | |
break; | |
end | |
end | |
else | |
notdisabled.BackgroundColor3 = ui.light | |
notdisabled.BorderColor3 = ui.border | |
notdisabled.ZIndex = 4 | |
lightbg:FindFirstChild(notdisabled.Name..'_').BackgroundColor3 = ui.light | |
lightbg:FindFirstChild(notdisabled.Name..'_').BorderColor3 = ui.border | |
lightbg:FindFirstChild(notdisabled.Name..'_').ZIndex = 3 | |
lightbg:FindFirstChild(notdisabled.Name..'_').Visible = true | |
notdisabled.tab.Value = true | |
end | |
end | |
end) | |
return main | |
end | |
function createSection(name, tab, size_pos) | |
tab = lightbg:WaitForChild(tab.Name..'_') | |
local size = size_pos[1] or size_pos["size"] | |
local pos = size_pos[2] or size_pos["pos"] | |
local bg = Instance.new("Frame", tab) | |
local label = Instance.new("TextLabel", bg) | |
bg.Name = name | |
bg.BackgroundColor3 = ui.light | |
bg.BorderColor3 = ui.border | |
bg.Position = pos | |
bg.Size = size | |
bg.ZIndex = 3 | |
label.Name = "label" | |
label.Text = name | |
label.BackgroundColor3 = ui.light | |
label.BorderSizePixel = 0 | |
label.Size = UDim2.new(0, #name * 10, 0, 10) | |
label.Position = UDim2.new(0.5, -(label.Size.X.Offset / 2), 0, -5) | |
label.ZIndex = 4 | |
label.Font = ui.font2 | |
label.TextColor3 = ui.textcolor | |
label.TextSize = 14 | |
return bg | |
end | |
function createToggle(name, section, pos, originalvalue, f, ...) | |
local debounce = originalvalue or false; | |
local fargs = {...} | |
local tmain = Instance.new("Frame") | |
local toggle = Instance.new("ImageButton") | |
local label = Instance.new("TextLabel") | |
--Properties: | |
tmain.Name = name | |
tmain.Parent = section | |
tmain.BackgroundTransparency = 1 | |
tmain.BorderSizePixel = 0 | |
tmain.Position = pos | |
tmain.Size = UDim2.new(0, 0, 0, 21) | |
tmain.ZIndex = 4 | |
toggle.Name = "toggle" | |
toggle.Parent = tmain | |
toggle.BackgroundColor3 = ui.dark | |
toggle.BorderColor3 = ui.border | |
toggle.Position = UDim2.new(0, 5, 0.5, -7) | |
toggle.Size = UDim2.new(0, 14, 0, 14) | |
toggle.ZIndex = 5 | |
toggle.Image = ui.toggleImg | |
toggle.ImageTransparency = 1 | |
toggle.ScaleType = Enum.ScaleType.Fit | |
label.Name = "label" | |
label.Parent = tmain | |
label.BackgroundTransparency = 1 | |
label.BorderSizePixel = 0 | |
label.Position = UDim2.new(0, 25, 0, 0) | |
label.Size = UDim2.new(0, 75, 1, 0) | |
label.ZIndex = 5 | |
label.Font = ui.font2 | |
label.Text = name | |
label.TextColor3 = ui.textcolor | |
label.TextSize = 14 | |
label.TextXAlignment = Enum.TextXAlignment.Left | |
if debounce == false then toggle.ImageTransparency = 1 else toggle.ImageTransparency = 0 end | |
toggle.MouseButton1Click:connect(function() | |
debounce = not debounce | |
if debounce == false then toggle.ImageTransparency = 1 else toggle.ImageTransparency = 0 end | |
f(debounce, unpack(fargs)) | |
end) | |
game:GetService("ContentProvider"):PreloadAsync({toggle}) | |
return tmain | |
end | |
function createSlider(name, section, pos, maximum, tochange, originalvalue, ...) | |
local fargs = {...} | |
local smain = Instance.new("Frame") | |
local sbound = Instance.new("Frame") | |
local sobj = Instance.new("TextButton") | |
local label = Instance.new("TextLabel") | |
local current = Instance.new("TextLabel") | |
local valueComp = Instance.new("NumberValue", sobj) | |
local ComparableValue = 0; | |
smain.Name = name | |
smain.Parent = section | |
smain.BackgroundColor3 = ui.light | |
smain.BorderColor3 = ui.border | |
smain.Position = pos | |
smain.Size = UDim2.new(1, -(pos.X.Offset * 2), 0, 22) | |
smain.ZIndex = 5 | |
sbound.Name = "sbound" | |
sbound.Parent = smain | |
sbound.Active = true | |
sbound.BackgroundColor3 = ui.dark | |
sbound.BorderColor3 = ui.border | |
sbound.Position = UDim2.new(0, 8, 0.5, -3) | |
sbound.Size = UDim2.new(1, -16, 0, 7) | |
sbound.ZIndex = 5 | |
sobj.Name = "sobj" | |
sobj.Parent = sbound | |
sobj.BackgroundColor3 = ui.slider | |
sobj.BorderColor3 = ui.border | |
sobj.Size = UDim2.new(0, 10, 1, 0) | |
sobj.ZIndex = 6 | |
sobj.AutoButtonColor = false | |
sobj.Text = "" | |
sobj.TextScaled = true | |
sobj.TextSize = 96 | |
sobj.TextWrapped = true | |
label.Name = "label" | |
label.Parent = smain | |
label.BackgroundColor3 = ui.light | |
label.BorderSizePixel = 0 | |
label.Position = UDim2.new(0.04581438, 0, -0.363247961, 0) | |
label.Size = UDim2.new(0, 9999, 0, 9999) | |
label.Size = UDim2.new(0, label.TextBounds.Y + 14, 0, 12) | |
label.ZIndex = 6 | |
label.Font = ui.font2 | |
label.Text = name | |
label.TextColor3 = ui.textcolor | |
label.TextSize = 14 | |
current.Name = "current" | |
current.Parent = smain | |
current.BackgroundColor3 = ui.light | |
current.BorderSizePixel = 0 | |
current.Position = UDim2.new(0.800000012, 0, -0.349999994, 0) | |
current.Size = UDim2.new(0, 33, 0, 12) | |
current.ZIndex = 6 | |
current.Font = ui.font | |
current.Text = "0" | |
current.TextColor3 = ui.textcolor | |
current.TextSize = 14 | |
valueComp.Name = "ComparableValue" | |
if originalvalue ~= nil then | |
valueComp.Value = originalvalue | |
end | |
local compare = (math.floor(valueComp.Value) > 1 and math.floor(valueComp.Value) / 10 ^ (#tostring(valueComp.Value))) or valueComp.Value | |
sobj.Position = UDim2.new(sobj.Position.X.Scale, -(compare * ((sbound.AbsoluteSize.X * compare) - sbound.AbsoluteSize.X)), sobj.Position.Y.Scale, sobj.Position.Y.Offset) | |
current.Text = tostring(valueComp.Value) | |
sobj.MouseButton1Down:connect(function() | |
dragging[name] = true | |
repeat | |
sobj.Position = UDim2.new(0,(mouse.X - sbound.AbsolutePosition.X),0,0) | |
if sobj.Position.X.Offset < 0 then | |
sobj.Position = UDim2.new(0,0,0,0) | |
elseif sobj.Position.X.Offset + sobj.Size.X.Offset > sbound.AbsoluteSize.X then | |
sobj.Position = UDim2.new(0,(sbound.AbsoluteSize.X-sobj.Size.X.Offset),0,0) | |
end | |
ComparableValue = math.floor((sobj.AbsolutePosition.X-sbound.AbsolutePosition.X) / (sbound.AbsoluteSize.X-sobj.Size.X.Offset) * (maximum * 10)) | |
valueComp.Value = ComparableValue / 10 | |
current.Text = tostring(valueComp.Value) | |
if typeof(tochange) == 'number' then | |
tochange = valueComp.Value | |
elseif typeof(tochange) == 'function' then | |
tochange(valueComp.Value, unpack(fargs)) | |
end | |
wait() | |
until dragging[name] == false | |
end) | |
return smain | |
end | |
function createButton(name, section, size_pos, f, ...) | |
local size = size_pos[1] or size_pos["size"] | |
local pos = size_pos[2] or size_pos["pos"] | |
local fargs = {...} | |
local button = Instance.new("TextButton", section) | |
button.Name = name | |
button.BackgroundColor3 = ui.light | |
button.BorderColor3 = ui.border | |
button.Position = pos | |
button.Size = size | |
button.ZIndex = 5 | |
button.Font = ui.font2 | |
button.Text = name | |
button.TextColor3 = ui.textcolor | |
button.TextSize = 14 | |
button.MouseButton1Click:connect(function() | |
f(unpack(fargs)) | |
end) | |
return button | |
end | |
function createDropDown(name, section, pos) | |
local debounce = Instance.new('BoolValue'); | |
local selected = Instance.new('ObjectValue'); | |
local dmain = Instance.new("Frame") | |
local label = Instance.new("TextLabel") | |
local drop = Instance.new("TextButton") | |
local dropdownbg = Instance.new("Frame") | |
dmain.Name = name | |
dmain.Parent = section | |
dmain.BackgroundColor3 = ui.light | |
dmain.BorderColor3 = ui.border | |
dmain.Position = pos | |
dmain.Size = UDim2.new(0, 160, 0, 25) | |
dmain.ZIndex = 4 | |
label.Name = "label" | |
label.Parent = dmain | |
label.BackgroundTransparency = 1 | |
label.BorderSizePixel = 0 | |
label.Position = UDim2.new(0, 5, 0, 0) | |
label.Size = UDim2.new(0, 75, 1, 0) | |
label.ZIndex = 5 | |
label.Font = ui.font2 | |
label.Text = name | |
label.TextColor3 = ui.textcolor | |
label.TextSize = 14 | |
label.TextXAlignment = Enum.TextXAlignment.Left | |
drop.Name = "drop" | |
drop.Parent = dmain | |
drop.BackgroundColor3 = Color3.new(1, 1, 1) | |
drop.BackgroundTransparency = 1 | |
drop.BorderSizePixel = 0 | |
drop.Position = UDim2.new(1, -25, 0, 6) | |
drop.Size = UDim2.new(0, 20, 0, 10) | |
drop.ZIndex = 8 | |
drop.AutoButtonColor = false | |
drop.Font = ui.font | |
drop.Text = "v" | |
drop.TextColor3 = ui.textcolor | |
drop.TextSize = 14 | |
dropdownbg.Name = "dropdownbg" | |
dropdownbg.Parent = dmain | |
dropdownbg.BackgroundColor3 = ui.light | |
dropdownbg.BorderColor3 = ui.border | |
dropdownbg.Position = UDim2.new(0, 70, 0, 0) | |
dropdownbg.Size = UDim2.new(0, 90, 0, 25) | |
dropdownbg.ZIndex = 6 | |
debounce.Value = false | |
debounce.Parent = dmain | |
debounce.Name = "debounce" | |
selected.Parent = dmain | |
selected.Name = "selected" | |
drop.MouseButton1Click:connect(function() | |
debounce.Value = not debounce.Value | |
if debounce.Value and (#dmain:GetChildren() - 6) > 0 then | |
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 | |
local s = dropdownbg.Size | |
for _,obj in pairs(dmain:GetChildren()) do | |
if obj:IsA('TextButton') and obj ~= drop then | |
if s.Y.Offset > obj.Position.Y.Offset then | |
obj.Visible = true | |
obj.AutoButtonColor = true | |
end | |
end | |
end | |
end) | |
else | |
for _,obj in pairs(dmain:GetChildren()) do | |
if obj:IsA('TextButton') and obj ~= drop then | |
if obj.Position.Y.Offset > 5 then | |
obj.Visible = false | |
obj.AutoButtonColor = false | |
end | |
end | |
end | |
dropdownbg:TweenSize(UDim2.new(0, 90, 0, 25), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.3, true) | |
end | |
end) | |
dropdowns[dmain] = {} | |
return dmain | |
end | |
function createDropDownValue(name, dropdown, f, ...) | |
local fargs = {...} | |
local debounce = dropdown:FindFirstChild('debounce'); | |
local dropdownbg = dropdown:FindFirstChild('dropdownbg') | |
local drop = dropdown:FindFirstChild('drop') | |
local selected = dropdown:FindFirstChild('selected') | |
local ddmain = Instance.new("TextButton") | |
ddmain.Name = name | |
ddmain.Parent = dropdown | |
ddmain.BackgroundColor3 = ui.dark | |
ddmain.BorderColor3 = ui.border | |
ddmain.Position = UDim2.new(0, 75, 0, (20 * (#dropdown:GetChildren() - 6)) + 5) -- depends on amount of objects in dropdown | |
ddmain.Size = UDim2.new(0, 80, 1, -10) | |
ddmain.ZIndex = 7 | |
ddmain.AutoButtonColor = false | |
ddmain.Font = ui.font2 | |
ddmain.Text = name | |
ddmain.TextColor3 = ui.textcolor | |
ddmain.TextSize = 14 | |
ddmain.TextXAlignment = Enum.TextXAlignment.Left | |
if (#dropdown:GetChildren() - 6) > 0 then -- depends on amount of objects in dropdown | |
ddmain.Visible = false | |
end | |
ddmain.MouseButton1Click:connect(function() | |
if type(dropdowns[dropdown]) == "table" and #dropdowns[dropdown] > 0 then | |
local backup, backupval = dropdowns[dropdown][0] | |
for i,v in pairs(dropdowns[dropdown]) do | |
if v == ddmain then | |
backupval = i | |
end | |
end | |
dropdowns[dropdown][0] = ddmain | |
dropdowns[dropdown][backupval] = backup | |
for __,obj in pairs(dropdowns[dropdown]) do | |
obj.Position = UDim2.new(0, 75, 0, (20 * __) + 5) | |
end | |
ddmain.Position = UDim2.new(0, 75, 0, 5) | |
selected.Value = ddmain | |
end | |
if f and type(f) == 'function' then | |
f(unpack(fargs)) | |
end | |
end) | |
dropdowns[dropdown][#dropdown:GetChildren() - 6] = ddmain -- depends on amount of objects in dropdown | |
return ddmain | |
end | |
function createTextInput(name, section, pos, originalval, f, ...) | |
local fargs = {...} | |
local timain = Instance.new("Frame") | |
local label = Instance.new("TextLabel") | |
local input = Instance.new("TextBox") | |
timain.Name = name | |
timain.Parent = section | |
timain.BackgroundColor3 = ui.light | |
timain.BorderColor3 = ui.border | |
timain.Position = pos | |
timain.Size = UDim2.new(0, 120, 0, 21) | |
timain.ZIndex = 4 | |
label.Name = "label" | |
label.Parent = timain | |
label.BackgroundTransparency = 1 | |
label.BorderSizePixel = 0 | |
label.Size = UDim2.new(0, 75, 1, 0) | |
label.ZIndex = 5 | |
label.Font = ui.font2 | |
label.Text = name | |
label.TextColor3 = ui.textcolor | |
label.TextSize = 14 | |
input.Name = "input" | |
input.Parent = timain | |
input.BackgroundColor3 = ui.dark | |
input.BorderColor3 = ui.border | |
input.Position = UDim2.new(0, 75, 0, 0) | |
input.Size = UDim2.new(0, 45, 1, 0) | |
input.ZIndex = 5 | |
input.Font = ui.font2 | |
input.Text = originalval or "" | |
input.PlaceholderText = "" | |
input.PlaceholderColor3 = ui.textcolor | |
input.TextColor3 = ui.textcolor | |
input.TextSize = 14 | |
if input.TextBounds.X > input.Size.X.Offset then | |
input.TextScaled = true | |
end | |
-- callback always puts text as first arguement, 2nd arguement is always the input object | |
input:GetPropertyChangedSignal("Text"):connect(function() | |
if input.TextBounds.X > input.Size.X.Offset then | |
input.TextScaled = true | |
else | |
input.TextScaled = false | |
end | |
if f and type(f) == 'function' then | |
f(input.Text, input, unpack(fargs)) | |
end | |
end) | |
return timain, input | |
end | |
ui.func = function() end | |
ui.store = store | |
return ui |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment