Advertisement
Guest User

phone

a guest
Dec 17th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.11 KB | None | 0 0
  1. local sx,sy = guiGetScreenSize()
  2. local sw,sh = 1360,768
  3. local draw = {}
  4.  
  5. appPos = {
  6.     {980,664,262,36},
  7.     {1014,471,48,45},
  8.     {1086,471,48,45},
  9.     {1158,471,48,45},
  10.     {1014,534,48,45},
  11.     {1086,534,48,45},
  12.     {1158,534,48,45},
  13.     {1014,598,48,45},
  14.     {1086,598,48,45},
  15.     {1158,598,48,45}
  16. }
  17.  
  18. function dxRect(...)
  19.     arg[1],arg[2],arg[3],arg[4] = arg[1]/sw*sx,arg[2]/sh*sy,arg[3]/sw*sx,arg[4]/sh*sy
  20.     return dxDrawRectangle(unpack(arg))
  21. end
  22.  
  23. function dxImage(...)
  24.     arg[1],arg[2],arg[3],arg[4] = arg[1]/sw*sx,arg[2]/sh*sy,arg[3]/sw*sx,arg[4]/sh*sy
  25.     return dxDrawImage(unpack(arg))
  26. end
  27.  
  28. function dxText(...)
  29.     arg[2],arg[3],arg[4],arg[5],arg[7] = arg[2]/sw*sx,arg[3]/sh*sy,arg[4]/sw*sx,arg[5]/sh*sy,(arg[7] or 1)/sw*sx
  30.     return dxDrawText(unpack(arg))
  31. end
  32.  
  33. function createPhone()
  34.     local self = {}
  35.     self.visible = true
  36.     self.draw = function()
  37.         if self.visible then
  38.             self.topColor = dxRect(988,392,247,44,tocolor(255,255,255,255))
  39.             self.bottomColor = dxRect(985,709,235,28,tocolor(100,100,100,255))
  40.             self.phoneBase = dxImage(972,375,277,388,'phone.png')
  41.             self.background = dxImage(980,438,260,262,'background.png')
  42.             self.bar = dxRect(appPos[1][1],appPos[1][2],appPos[1][3],appPos[1][4],tocolor(0,0,0,255))
  43.             local x1,y1,w1,h1,x2,y2,w2,h2,x3,y3,w3,h3 = appPos[2][1],appPos[2][2],appPos[2][3],appPos[2][4],appPos[3][1],appPos[3][2],appPos[3][3],appPos[3][4],appPos[4][1],appPos[4][2],appPos[4][3],appPos[4][4]
  44.             self.emailApp = dxImage(x1,y1,w1,h1,'/img/email.png')
  45.             self.messengerApp = dxImage(x2,y2,w2,h2,'/img/messenger.png')
  46.             self.contactsApp = dxImage(x3,y3,w3,h3,'/img/contacts.png')
  47.             local x4,y4,w4,h4,x5,y5,w5,h5,x6,y6,w6,h6 = appPos[5][1],appPos[5][2],appPos[5][3],appPos[5][4],appPos[6][1],appPos[6][2],appPos[6][3],appPos[6][4],appPos[7][1],appPos[7][2],appPos[7][3],appPos[7][4]
  48.             self.cameraApp = dxImage(x4,y4,w4,h4,'/img/camera.png')
  49.             self.missionsApp = dxImage(x5,y5,w5,h5,'/img/missions.png')
  50.             self.internetApp = dxImage(x6,y6,w6,h6,'/img/internet.png')
  51.             local x7,y7,w7,h7,x8,y8,w8,h8 = appPos[8][1],appPos[8][2],appPos[8][3],appPos[8][4],appPos[9][1],appPos[9][2],appPos[9][3],appPos[9][4]
  52.             self.settingsApp = dxImage(x8,y8,w8,h8,'/img/settings.png')
  53.             if selection then
  54.                 --self.overlay = dxRect(selection[3],selection[4],selection[5],selection[6],tocolor(255,0,0,255))
  55.                 dxDrawLine(selection[3],selection[4],selection[3]+selection[5],selection[4],tocolor(255,0,0,255),2)
  56.                 dxDrawLine(selection[3],selection[4]+selection[6],selection[3]+selection[5],selection[4]+selection[6],tocolor(255,0,0,255),2)
  57.                 dxDrawLine(selection[3],selection[4],selection[3],selection[4]+selection[6],tocolor(255,0,0,255),2)
  58.                 dxDrawLine(selection[3]+selection[5],selection[4],selection[3]+selection[5],selection[4]+selection[6],tocolor(255,0,0,255),2)
  59.                 self.selection = dxText(selection[1],980,437,1241,469,tocolor(255,0,0,255),1.00,'pricedown','center','center',false,false,true,false,false)
  60.             end
  61.         end
  62.     end
  63.     table.insert(draw,self)
  64.     return self
  65. end
  66. phone = createPhone()
  67.  
  68. addEventHandler('onClientRender',root,function()
  69.     for i,render in ipairs(draw) do
  70.         render.draw()
  71.     end
  72.     dxText(tostring(sx)..','..tostring(sy)..'/'..tostring(sw)..','..tostring(sh),1200,131,223,25)
  73. end)
  74.  
  75. local selections = {
  76.     {'Email',phone.emailApp,1014,471,48,45},
  77.     {'Messenger',phone.messengerApp,1086,471,48,45},
  78.     {'Contacts',phone.contactsApp,1158,471,48,45},
  79.     {'Camera',phone.cameraApp,1014,534,48,45},
  80.     {'Missions',phone.missionsApp,1086,534,48,45},
  81.     {'Internet',phone.internetApp,1158,534,48,45},
  82.     {'Settings',phone.settingsApp,1086,598,48,45}
  83. }
  84. selection = selections[5]
  85.  
  86. addEventHandler('onClientKey',root,function(key,press)
  87.     if press then
  88.         if key == 'arrow_u' then
  89.             -- row 2
  90.             if selection == selections[5] then
  91.                 selection = selections[2]
  92.             elseif selection == selections[2] then
  93.                 selection = selections[7]
  94.             elseif selection == selections[7] then
  95.                 selection = selections[5]
  96.             -- row 1
  97.             elseif selection == selections[4] then
  98.                 selection = selections[1]
  99.             elseif selection == selections[1] then
  100.                 selection = selections[4]
  101.             -- row 3
  102.             elseif selection == selections[6] then
  103.                 selection = selections[3]
  104.             elseif selection == selections[3] then
  105.                 selection = selections[6]
  106.             end
  107.         elseif key == 'arrow_d' then
  108.             -- row 2
  109.             if selection == selections[5] then
  110.                 selection = selections[7]
  111.             elseif selection == selections[7] then
  112.                 selection = selections[2]
  113.             elseif selection == selections[2] then
  114.                 selection = selections[5]
  115.             -- row 1
  116.             elseif selection == selections[4] then
  117.                 selection = selections[1]
  118.             elseif selection == selections[1] then
  119.                 selection = selections[4]
  120.             -- row 3
  121.             elseif selection == selections[6] then
  122.                 selection = selections[3]
  123.             elseif selection == selections[3] then
  124.                 selection = selections[6]
  125.             end
  126.         elseif key == 'arrow_l' then
  127.             -- row 2
  128.             if selection == selections[5] then
  129.                 selection = selections[4]
  130.             elseif selection == selections[4] then
  131.                 selection = selections[6]
  132.             elseif selection == selections[6] then
  133.                 selection = selections[5]
  134.             -- row 1
  135.             elseif selection == selections[2] then
  136.                 selection = selections[1]
  137.             elseif selection == selections[1] then
  138.                 selection = selections[3]
  139.             elseif selection == selections[3] then
  140.                 selection = selections[2]
  141.             -- row 3
  142.             elseif selection == selections[7] then
  143.                 selection = selections[7]
  144.             end
  145.         elseif key == 'arrow_r' then
  146.             -- row 2
  147.             if selection == selections[5] then
  148.                 selection = selections[6]
  149.             elseif selection == selections[6] then
  150.                 selection = selections[4]
  151.             elseif selection == selections[4] then
  152.                 selection = selections[5]
  153.             -- row 1
  154.             elseif selection == selections[2] then
  155.                 selection = selections[3]
  156.             elseif selection == selections[3] then
  157.                 selection = selections[1]
  158.             elseif selection == selections[1] then
  159.                 selection = selections[2]
  160.             -- row 3
  161.             elseif selection == selections[7] then
  162.                 selection = selections[7]
  163.             end
  164.         end
  165.     end
  166. end)
  167.  
  168. bindKey('f2','down',function()
  169.     if phone.visible then
  170.         phone.visible = false
  171.     else
  172.         phone.visible = true
  173.     end
  174. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement