Ameno__GodOH

libtest

Oct 11th, 2024 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. -- UI Lib
  2. local UILib = {}
  3.  
  4. -- Função para permitir que um Frame seja arrastável com mouse ou toque
  5. local function MakeDraggable(frame, dragHandle)
  6. local dragging
  7. local dragInput
  8. local dragStart
  9. local startPos
  10.  
  11. local function Update(input)
  12. local delta = input.Position - dragStart
  13. frame.Position = UDim2.new(
  14. startPos.X.Scale,
  15. startPos.X.Offset + delta.X,
  16. startPos.Y.Scale,
  17. startPos.Y.Offset + delta.Y
  18. )
  19. end
  20.  
  21. dragHandle.InputBegan:Connect(function(input)
  22. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  23. dragging = true
  24. dragStart = input.Position
  25. startPos = frame.Position
  26.  
  27. input.Changed:Connect(function()
  28. if input.UserInputState == Enum.UserInputState.End then
  29. dragging = false
  30. end
  31. end)
  32. end
  33. end)
  34.  
  35. dragHandle.InputChanged:Connect(function(input)
  36. if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  37. dragInput = input
  38. end
  39. end)
  40.  
  41. game:GetService("UserInputService").InputChanged:Connect(function(input)
  42. if input == dragInput and dragging then
  43. Update(input)
  44. end
  45. end)
  46. end
  47.  
  48. -- Função para criar uma janela (window) com cantos arredondados
  49. function UILib:CreateWindow(title)
  50. local ScreenGui = Instance.new("ScreenGui")
  51. local MainFrame = Instance.new("Frame")
  52. local TitleLabel = Instance.new("TextLabel")
  53. local MinimizeButton = Instance.new("TextButton")
  54. local CloseButton = Instance.new("TextButton")
  55. local UICornerMain = Instance.new("UICorner")
  56. local UICornerButton = Instance.new("UICorner")
  57.  
  58. -- Propriedades do ScreenGui
  59. ScreenGui.Name = "UILib"
  60. ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  61. ScreenGui.ResetOnSpawn = false
  62.  
  63. -- Propriedades da MainFrame (largura aumentada)
  64. MainFrame.Name = "MainFrame"
  65. MainFrame.Parent = ScreenGui
  66. MainFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
  67. MainFrame.Position = UDim2.new(0.2, 0, 0.3, 0)
  68. MainFrame.Size = UDim2.new(0, 600, 0, 300) -- Interface mais larga
  69.  
  70. -- Propriedades do UICorner (arredondando a janela)
  71. UICornerMain.Parent = MainFrame
  72. UICornerMain.CornerRadius = UDim.new(0, 12)
  73.  
  74. -- Propriedades do Título
  75. TitleLabel.Name = "TitleLabel"
  76. TitleLabel.Parent = MainFrame
  77. TitleLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  78. TitleLabel.BackgroundTransparency = 1
  79. TitleLabel.Position = UDim2.new(0, 0, 0, 0)
  80. TitleLabel.Size = UDim2.new(1, 0, 0, 50)
  81. TitleLabel.Font = Enum.Font.Custom
  82. TitleLabel.Text = title or "New Window"
  83. TitleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  84. TitleLabel.TextSize = 24
  85. TitleLabel.FontFace = Font.fromId(12187371840) -- Fonte customizada
  86.  
  87. -- Botão de minimizar no canto superior direito
  88. MinimizeButton.Name = "MinimizeButton"
  89. MinimizeButton.Parent = MainFrame
  90. MinimizeButton.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
  91. MinimizeButton.Position = UDim2.new(1, -80, 0, 10)
  92. MinimizeButton.Size = UDim2.new(0, 30, 0, 30)
  93. MinimizeButton.Font = Enum.Font.Custom
  94. MinimizeButton.Text = "-"
  95. MinimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  96. MinimizeButton.TextSize = 20
  97. MinimizeButton.FontFace = Font.fromId(12187371840)
  98.  
  99. -- Botão de fechar no canto superior direito
  100. CloseButton.Name = "CloseButton"
  101. CloseButton.Parent = MainFrame
  102. CloseButton.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
  103. CloseButton.Position = UDim2.new(1, -40, 0, 10)
  104. CloseButton.Size = UDim2.new(0, 30, 0, 30)
  105. CloseButton.Font = Enum.Font.Custom
  106. CloseButton.Text = "×"
  107. CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  108. CloseButton.TextSize = 20
  109. CloseButton.FontFace = Font.fromId(12187371840)
  110.  
  111. -- Aplicando cantos arredondados nos botões de minimizar e fechar
  112. local UICornerMinimize = Instance.new("UICorner")
  113. UICornerMinimize.CornerRadius = UDim.new(0, 6)
  114. UICornerMinimize.Parent = MinimizeButton
  115.  
  116. local UICornerClose = Instance.new("UICorner")
  117. UICornerClose.CornerRadius = UDim.new(0, 6)
  118. UICornerClose.Parent = CloseButton
  119.  
  120. -- Funções para minimizar e fechar a janela
  121. MinimizeButton.MouseButton1Click:Connect(function()
  122. MainFrame.Visible = not MainFrame.Visible
  123. end)
  124.  
  125. CloseButton.MouseButton1Click:Connect(function()
  126. ScreenGui:Destroy()
  127. end)
  128.  
  129. -- Tornar o Frame "draggable" com mouse e toque
  130. MakeDraggable(MainFrame, TitleLabel)
  131.  
  132. return {
  133. Frame = MainFrame
  134. }
  135. end
  136.  
  137. -- Função para criar botões menores e com cantos arredondados na janela
  138. function UILib:CreateButton(window, buttonText, callback)
  139. local Button = Instance.new("TextButton")
  140. local UICornerButton = Instance.new("UICorner")
  141.  
  142. -- Propriedades do Button (botões menores, alinhados à esquerda)
  143. Button.Name = "Button"
  144. Button.Parent = window.Frame
  145. Button.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
  146. Button.Size = UDim2.new(0, 150, 0, 40) -- Botões menores
  147. Button.Position = UDim2.new(0, 10, 0, 60) -- Botões à esquerda
  148. Button.Font = Enum.Font.Custom
  149. Button.Text = buttonText or "Button"
  150. Button.TextColor3 = Color3.fromRGB(255, 255, 255)
  151. Button.TextSize = 20
  152. Button.FontFace = Font.fromId(12187371840) -- Fonte customizada
  153.  
  154. -- Propriedades do UICorner (para arredondar os cantos do botão)
  155. UICornerButton.Parent = Button
  156. UICornerButton.CornerRadius = UDim.new(0, 10)
  157.  
  158. Button.MouseButton1Click:Connect(function()
  159. pcall(callback)
  160. end)
  161.  
  162. return Button
  163. end
  164.  
  165. return UILib
Advertisement
Add Comment
Please, Sign In to add comment