Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.33 KB | None | 0 0
  1. local y = 0
  2. function Auth.render()
  3.     dxDrawImage(0, 0, sx, sy, Auth.textures["background"])
  4.  
  5.     local fft = getSoundFFTData(Auth.music, 2048, 256)
  6.     if fft[0] then fft = math.sqrt(fft[0]) end
  7.     fft = (math.max(0, math.min(fft, 1)) * 135)
  8.  
  9.    
  10.     if Auth.inAnimation then
  11.         dxDrawImage(sx / 2 - 187 / zoom, sy / 2 - 385 / zoom, 375 / zoom, 375 / zoom, Auth.textures["bass2"], 0, 0, 0, tocolor(245, 34, 87, fft))
  12.         dxDrawImage(sx / 2 - 154 / zoom, sy / 2 - 385 / zoom, 309 / zoom, 354 / zoom, Auth.textures["logo"])   
  13.     end
  14.    
  15.     dxDrawImage(0, 0 + y, sx, sy, Auth.textures["background"], 0, 0, 0)
  16.    
  17.     local fft2 = getSoundFFTData(Auth.music, 2048, 256)
  18.     if fft2 then
  19.         for i = 0, 255 do
  20.             if tonumber(math.sqrt(fft2[i])) then
  21.                 dxDrawRectangle(i*15/zoom, sy, 10 / zoom, -(math.sqrt(fft2[i]) * 256), tocolor(0, 0, 0, 25))
  22.             end
  23.         end
  24.     end
  25.    
  26.     for k, v in pairs(Auth.ui) do
  27.         if Auth.inAnimation then
  28.             if not v.initPos then
  29.                 v.initPos = v.y
  30.                 v.postgui = true
  31.             end
  32.  
  33.             v.y = v.initPos + y
  34.         end
  35.     end
  36.  
  37.     dxDrawImage(0, 0, sx, sy, Auth.textures["bass"], 0, 0, 0, tocolor(255, 255, 255, fft))
  38.     -- dxDrawImage(sx / 2 - 154 / zoom - fft / 2, sy / 2 - 385 / zoom - fft / 2, 309 / zoom + fft, 354 / zoom + fft, Auth.textures["logo"])
  39.     dxDrawImage(sx / 2 - 187 / zoom, sy / 2 - 385 / zoom + y, 375 / zoom, 375 / zoom, Auth.textures["bass2"], 0, 0, 0, tocolor(245, 34, 87, fft))
  40.     dxDrawImage(sx / 2 - 154 / zoom, sy / 2 - 385 / zoom + y, 309 / zoom, 354 / zoom, Auth.textures["logo"], 0, 0, 0)
  41.    
  42.     dxDrawText("♫ Aktualnie: Dua Lipa - Don't Start Now", 0, 0, sx, sy, white, 1, Auth.roboto_big, "left", "bottom")
  43.    
  44.     if Auth.page == 1 then
  45.         dxDrawText("Nie posiadasz konta?", 0, 35 / zoom + y, sx - 310 / zoom, 90 / zoom + y, white, 1, Auth.roboto, "right", "center")
  46.     elseif Auth.page == 2 then
  47.         dxDrawText("Posiadasz już konto?", 0, 35 / zoom + y, sx - 310 / zoom, 90 / zoom + y, white, 1, Auth.roboto, "right", "center")    
  48.     end
  49. end
  50.  
  51. function Auth.initGUI()
  52.     for k, v in pairs(Auth.ui) do
  53.         v:destroy()
  54.     end
  55.  
  56.     if Auth.page == 1 then
  57.         Auth.ui.sign_up = GUI.createButton({x = sx - 300 / zoom, y = 35 / zoom, width = 197 / zoom, height = 55 / zoom, text = "Zarejestruj się", color = {30, 30, 30, 140}})
  58.        
  59.         Auth.ui.user_edit = GUI.createEdit({x = sx / 2 - 259 / zoom, y = sy / 2 - 50 / zoom, width = 518 / zoom, height = 50 / zoom, placeholder = "Wpisz login..", textOffset = {10 / zoom, 0}, icon = {Auth.textures["user"], 25 / zoom, 25 / zoom, -35 / zoom, 18 / zoom}})
  60.         Auth.ui.pass_edit = GUI.createEdit({x = sx / 2 - 259 / zoom, y = sy / 2 + 15 / zoom, width = 518 / zoom, height = 50 / zoom, placeholder = "Wpisz hasło..", textOffset = {10 / zoom, 0}, icon = {Auth.textures["pass"], 25 / zoom, 25 / zoom, -35 / zoom, 18 / zoom}})
  61.         Auth.ui.pass_edit.masking = true
  62.  
  63.         Auth.ui.login = GUI.createButton({x = sx / 2 + 62 / zoom, y = sy / 2 + 110 / zoom, width = 197 / zoom, height = 55 / zoom, text = "Zaloguj", color = {19, 161, 216}})
  64.         Auth.ui.checkbox = GUI.createCheckbox({x = sx / 2 - 292 / zoom, y = sy / 2 + 125 / zoom, textColor = {215, 215, 215}, text = "Zapamiętaj mnie"})
  65.  
  66.         Auth.ui.login.click = function()
  67.             local user = Auth.ui.user_edit:getText()
  68.             local pass = Auth.ui.pass_edit:getText()
  69.  
  70.             triggerServerEvent("Authorization.checkCredentials", localPlayer, user, pass)
  71.         end
  72.  
  73.         Auth.ui.sign_up.click = function()
  74.             Auth.page = 2
  75.             Auth.inAnimation = true
  76.  
  77.             animate(0, sy, "OutQuad", 2500, function(_) y = _ end, function() y = 0 Auth.initGUI() Auth.inAnimation = false end)
  78.         end
  79.     elseif Auth.page == 2 then
  80.         Auth.ui.login = GUI.createButton({x = sx - 300 / zoom, y = 35 / zoom, width = 197 / zoom, height = 55 / zoom, text = "Zaloguj się", color = {30, 30, 30, 140}})
  81.  
  82.         Auth.ui.user_edit = GUI.createEdit({x = sx / 2 - 259 / zoom, y = sy / 2 - 50 / zoom, width = 518 / zoom, height = 50 / zoom, placeholder = "Wpisz login..", textOffset = {10 / zoom, 0}, icon = {Auth.textures["user"], 25 / zoom, 25 / zoom, -35 / zoom, 18 / zoom}})
  83.         Auth.ui.pass_edit = GUI.createEdit({x = sx / 2 - 259 / zoom, y = sy / 2 + 15 / zoom, width = 518 / zoom, height = 50 / zoom, placeholder = "Wpisz hasło..", textOffset = {10 / zoom, 0}, icon = {Auth.textures["pass"], 25 / zoom, 25 / zoom, -35 / zoom, 18 / zoom}})
  84.         Auth.ui.pass_edit.masking = true
  85.         Auth.ui.email_edit = GUI.createEdit({x = sx / 2 - 259 / zoom, y = sy / 2 + 80 / zoom, width = 518 / zoom, height = 50 / zoom, placeholder = "Wpisz e-mail..", textOffset = {10 / zoom, 0}, icon = {Auth.textures["mail"], 25 / zoom, 25 / zoom, -35 / zoom, 18 / zoom}})
  86.  
  87.         Auth.ui.register = GUI.createButton({x = sx / 2 + 62 / zoom, y = sy / 2 + 175 / zoom, width = 197 / zoom, height = 55 / zoom, text = "Zarejestruj", color = {19, 161, 216}})
  88.  
  89.         Auth.ui.register.click = function()
  90.             local user = Auth.ui.user_edit:getText()
  91.             local pass = Auth.ui.pass_edit:getText()
  92.             local email = Auth.ui.email_edit:getText()
  93.  
  94.             triggerServerEvent("Authorization.createAccount", localPlayer, user, pass, email)
  95.         end
  96.  
  97.         Auth.ui.login.click = function()
  98.             Auth.page = 1
  99.             Auth.inAnimation = true
  100.  
  101.             animate(0, -sy, "OutQuad", 2500, function(_) y = _ end, function() y = 0 Auth.initGUI() Auth.inAnimation = false end)
  102.         end
  103.     end
  104.  
  105.     for k, v in pairs(Auth.ui) do
  106.         v:setAlpha(0)
  107.     end
  108.  
  109.     animate(0, 255, "Linear", 500, function(alpha)
  110.         for k, v in pairs(Auth.ui) do
  111.             v:setAlpha(alpha)
  112.         end
  113.     end)
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement