Advertisement
NanoBob

MTA main menu

Jul 20th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.13 KB | None | 0 0
  1. local screenx,screeny=guiGetScreenSize()
  2. local mainMenuDrawn=true
  3.  
  4. function setUpButtons()
  5.     buttonsOver={}
  6.     buttonsDefault={}
  7.     buttonHeight=screeny*0.2
  8.     buttonWidth=screenx*0.25
  9.     buttonsDefault["Classes"]={['x']=0,['y']=screeny*0.6,['w']=buttonWidth,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(200,200,200,255),['scale']=2,['font']="default"}
  10.     buttonsOver["Classes"]   ={['x']=0,['y']=screeny*0.6,['w']=buttonWidth*1.25,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(50,200,200,255),['scale']=3,['font']="default"}
  11.     buttonsDefault["Skin"]={['x']=0,['y']=screeny*0.8,['w']=buttonWidth,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(200,200,200,255),['scale']=2,['font']="default"}
  12.     buttonsOver["Skin"]   ={['x']=0,['y']=screeny*0.8,['w']=buttonWidth*1.25,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(50,200,200,255),['scale']=3,['font']="default"}
  13.     buttonsDefault["Gang Management"]={['x']=screenx-buttonWidth,['y']=screeny*0.8,['w']=buttonWidth,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(200,200,200,255),['scale']=2,['font']="default"}
  14.     buttonsOver["Gang Management"]   ={['x']=screenx-buttonWidth-buttonWidth*0.25,['y']=screeny*0.8,['w']=buttonWidth*1.25,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(50,200,200,255),['scale']=3,['font']="default"}
  15.     buttonsDefault["Button"]={['x']=screenx-buttonWidth,['y']=screeny*0.6,['w']=buttonWidth,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(200,200,200,255),['scale']=2,['font']="default"}
  16.     buttonsOver["Button"]   ={['x']=screenx-buttonWidth-buttonWidth*0.25,['y']=screeny*0.6,['w']=buttonWidth*1.25,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(50,200,200,255),['scale']=3,['font']="default"}
  17.     buttonsDefault["Paul is not fat"]={['x']=screenx-buttonWidth,['y']=screeny*0.4,['w']=buttonWidth,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(200,200,200,255),['scale']=2,['font']="default"}
  18.     buttonsOver["Paul is not fat"]   ={['x']=screenx-buttonWidth-buttonWidth*0.25,['y']=screeny*0.4,['w']=buttonWidth*1.25,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(50,200,200,255),['scale']=3,['font']="default"}
  19.     buttonsDefault["Stats"]={['x']=screenx-buttonWidth,['y']=screeny*0.2,['w']=buttonWidth,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(200,200,200,255),['scale']=2,['font']="default"}
  20.     buttonsOver["Stats"]   ={['x']=screenx-buttonWidth-buttonWidth*0.25,['y']=screeny*0.2,['w']=buttonWidth*1.25,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(50,200,200,255),['scale']=3,['font']="default"}   
  21.     buttonsDefault["Leaderboard"]={['x']=screenx-buttonWidth,['y']=0,['w']=buttonWidth,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(200,200,200,255),['scale']=2,['font']="default"}
  22.     buttonsOver["Leaderboard"]   ={['x']=screenx-buttonWidth-buttonWidth*0.25,['y']=screeny*0.0,['w']=buttonWidth*1.25,['h']=buttonHeight,['color']=tocolor(100,100,100,100),['textColor']=tocolor(50,200,200,255),['scale']=3,['font']="default"}
  23.     --buttonsDefault[""]={['x']=,['y']=,['w']=,['h']=,['color']=,['textColor']=,['font']=}
  24.     --buttonsOver[""]   ={['x']=,['y']=,['w']=,['h']=,['color']=,['textColor']=,['font']=} 
  25.    
  26.     currentButtons=buttonsDefault
  27. end
  28. setUpButtons()
  29.  
  30. function handleMenu()
  31.     if mainMenuDrawn==true then
  32.         if isCursorShowing()==true then
  33.             local cursorx,cursory=getCursorPosition()
  34.             local cursorx=cursorx*screenx
  35.             local cursory=cursory*screeny
  36.             for buttonName,buttonData in pairs(currentButtons) do
  37.                 if cursorx>buttonData['x'] and cursorx<buttonData['x']+buttonData['w'] and cursory>buttonData['y'] and cursory<buttonData['y']+buttonData['h'] then
  38.                     currentButtons[buttonName]=buttonsOver[buttonName]
  39.                 elseif cursorx<buttonData['x'] or cursorx>buttonData['x']+buttonData['w'] or cursory<buttonData['y'] or cursory>buttonData['y']+buttonData['h'] then
  40.                     currentButtons[buttonName]=buttonsDefault[buttonName]
  41.                 else
  42.                     currentButtons[buttonName]=buttonsDefault[buttonName]  
  43.                 end
  44.             end
  45.         end
  46.         --drawing
  47.         --dxDrawImage(screenx-300,screeny-300,600,600,"images/map",0,0,0,tocolor(0,0,0),true)
  48.         dxDrawRectangle(0,0,screenx,screeny,tocolor(50,50,50,200))
  49.         for id,data in pairs(currentButtons) do
  50.             dxDrawRectangle(data['x'],data['y'],data['w'],data['h'],data['color'],true)
  51.             dxDrawRectangle(data['x']+5,data['y']+5,data['w']-10,data['h']-10,data['color'],true)
  52.             dxDrawText(id,data['x'],data['y'],data['x']+data['w'],data['y']+data['h'],data['textColor'],data['scale'],data['font'],"center","center",true)
  53.         end
  54.        
  55.        
  56.     end
  57. end
  58. addEventHandler("onClientRender",getRootElement(),handleMenu)
  59.  
  60. function handleClicks()
  61.     if menuDrawn==true then
  62.        
  63.        
  64.     end
  65. end
  66.  
  67. addEventHandler("onClientClick",getRootElement(),handleMenu)
  68.  
  69. function clickedF1(button,state)
  70.     if state==true and button=="F1" then
  71.         local mainmenuDrawn=not mainMenuDrawn
  72.         local menuDrawn=not menuDrawn
  73.     end
  74. end
  75.  
  76. addEventHandler("onClientKey",getRootElement(),clickedF1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement