Advertisement
Sufferrrrrr

UI LIBRARY

Dec 21st, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.41 KB | None | 0 0
  1. -- CustomUI UI Library
  2. -- Generated by UI Library Generator
  3. -- Features: draggable, animations, responsive, rounded
  4. -- Components: button, toggle, slider, dropdown, textbox, notification, tabs
  5.  
  6. -- CustomUI Library Implementation
  7.  
  8. local CustomUI = {}
  9.  
  10. -- Function to create a new UI element
  11. function CustomUI.new()
  12.     local self = {}
  13.  
  14.     -- Theme Settings
  15.     local theme = {
  16.         background = Color3.fromRGB(30, 30, 30),
  17.         textColor = Color3.fromRGB(255, 255, 255),
  18.         buttonColor = Color3.fromRGB(50, 50, 255),
  19.         buttonHoverColor = Color3.fromRGB(70, 70, 255)
  20.     }
  21.  
  22.     -- Create the notification system
  23.     function self:notification(type, message, duration)
  24.         local types = {
  25.             success = Color3.fromRGB(0, 255, 0),
  26.             error = Color3.fromRGB(255, 0, 0),
  27.             info = Color3.fromRGB(0, 0, 255)
  28.         }
  29.  
  30.         local notification = Instance.new('TextLabel')
  31.         notification.BackgroundColor3 = types[type] or Color3.fromRGB(255, 255, 255)
  32.         notification.TextColor3 = theme.textColor
  33.         notification.Text = message
  34.         notification.Size = UDim2.new(0, 300, 0, 50)
  35.         notification.Position = UDim2.new(0.5, -150, 0, 10)
  36.         notification.AnchorPoint = Vector2.new(0.5, 0)
  37.         notification.Parent = game.Players.LocalPlayer:WaitForChild('PlayerGui')
  38.  
  39.         wait(duration or 3)
  40.         notification:Destroy()
  41.     end
  42.  
  43.     -- Button Component
  44.     function self:button(text, callback)
  45.         local button = Instance.new('TextButton')
  46.         button.Text = text
  47.         button.BackgroundColor3 = theme.buttonColor
  48.         button.TextColor3 = theme.textColor
  49.         button.Size = UDim2.new(0, 100, 0, 50)
  50.         button.MouseButton1Click:Connect(function() callback() end)
  51.  
  52.         button.MouseEnter:Connect(function()
  53.             button.BackgroundColor3 = theme.buttonHoverColor
  54.         end)
  55.  
  56.         button.MouseLeave:Connect(function()
  57.             button.BackgroundColor3 = theme.buttonColor
  58.         end)
  59.  
  60.         return button
  61.     end
  62.  
  63.     -- Toggle Component
  64.     function self:toggle(text, callback)
  65.         local toggle = Instance.new('TextButton')
  66.         toggle.Text = text
  67.         toggle.BackgroundColor3 = theme.buttonColor
  68.         toggle.TextColor3 = theme.textColor
  69.         toggle.Size = UDim2.new(0, 100, 0, 50)
  70.         local isToggled = false
  71.  
  72.         toggle.MouseButton1Click:Connect(function()
  73.             isToggled = not isToggled
  74.             toggle.BackgroundColor3 = isToggled and Color3.fromRGB(0, 255, 0) or theme.buttonColor
  75.             callback(isToggled)
  76.         end)
  77.  
  78.         return toggle
  79.     end
  80.  
  81.     -- Slider Component
  82.     function self:slider(min, max, callback)
  83.         local slider = Instance.new('Frame')
  84.         slider.Size = UDim2.new(0, 200, 0, 50)
  85.         local sliderButton = Instance.new('TextButton')
  86.         sliderButton.Size = UDim2.new(0, 10, 1, 0)
  87.         sliderButton.BackgroundColor3 = theme.buttonColor
  88.         local value = min
  89.  
  90.         sliderButton.MouseDrag:Connect(function()
  91.             local mouse = game.Players.LocalPlayer:GetMouse()
  92.             local position = math.clamp(mouse.X - slider.AbsolutePosition.X, 0, slider.AbsoluteSize.X)
  93.             value = math.floor((position / slider.AbsoluteSize.X) * (max - min)) + min
  94.             callback(value)
  95.         end)
  96.  
  97.         sliderButton.Parent = slider
  98.         return slider
  99.     end
  100.  
  101.     -- Dropdown Component
  102.     function self:dropdown(items, callback)
  103.         local dropdown = Instance.new('Frame')
  104.         dropdown.Size = UDim2.new(0, 200, 0, 50)
  105.         local isOpen = false
  106.  
  107.         local dropdownButton = Instance.new('TextButton')
  108.         dropdownButton.Text = "Select an option"
  109.         dropdownButton.Size = UDim2.new(1, 0, 1, 0)
  110.         dropdownButton.Parent = dropdown
  111.  
  112.         dropdownButton.MouseButton1Click:Connect(function()
  113.             isOpen = not isOpen
  114.             -- Implementation of dropdown options
  115.         end)
  116.  
  117.         return dropdown
  118.     end
  119.  
  120.     -- Textbox Component
  121.     function self:textbox(placeholder, callback)
  122.         local textbox = Instance.new('TextBox')
  123.         textbox.Text = ""
  124.         textbox.PlaceholderText = placeholder
  125.         textbox.Size = UDim2.new(0, 200, 0, 50)
  126.         textbox.FocusLost:Connect(function(enterPressed)
  127.             if enterPressed then
  128.                 callback(textbox.Text)
  129.             end
  130.         end)
  131.  
  132.         return textbox
  133.     end
  134.  
  135.     -- Tabs Component
  136.     function self:tabs(tabList)
  137.         local tabContainer = Instance.new('Frame')
  138.         tabContainer.Size = UDim2.new(1, 0, 1, 0)
  139.         local currentTab
  140.  
  141.         for _, tab in ipairs(tabList) do
  142.             local tabButton = Instance.new('TextButton')
  143.             tabButton.Text = tab.name
  144.             tabButton.Size = UDim2.new(0, 100, 0, 50)
  145.             tabButton.Parent = tabContainer
  146.  
  147.             tabButton.MouseButton1Click:Connect(function()
  148.                 if currentTab then
  149.                     currentTab.Visible = false
  150.                 end
  151.                 currentTab = tab.content
  152.                 currentTab.Visible = true
  153.             end)
  154.         end
  155.  
  156.         return tabContainer
  157.     end
  158.  
  159.     -- UICorner for rounded corners
  160.     function self:applyUICorner(element)
  161.         local corner = Instance.new('UICorner')
  162.         corner.CornerRadius = UDim.new(0, 10)
  163.         corner.Parent = element
  164.     end
  165.  
  166.     return self
  167. end
  168.  
  169. return CustomUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement