Advertisement
Guest User

gui.lua

a guest
Jun 4th, 2017
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. -- Credit : Ideo
  2.  
  3. function drawNotification(text)
  4. SetNotificationTextEntry("STRING")
  5. AddTextComponentString(text)
  6. DrawNotification(true, true)
  7. end
  8.  
  9. Menu = {}
  10. Menu.GUI = {}
  11. Menu.TitleGUI = {}
  12. Menu.buttonCount = 10
  13. Menu.titleCount = 0
  14. Menu.selection = 0
  15. Menu.hidden = true
  16. MenuTitle = "Menu"
  17.  
  18. -------------------
  19. posXMenu = 0.700 -- List = Left and Right
  20. posYMenu = 0.02 -- Smaller List, 1=Too Small
  21. width = 0.1 -- Make List Wider
  22. height = 0.02 -- Blue Strip
  23.  
  24. posXMenuTitle = 0.700 -- Red Title = Left and Right
  25. posYMenuTitle = 0.02
  26. widthMenuTitle = 0.1 -- Make Red Strip Wider
  27. heightMenuTitle = 0.02 -- Red Strip
  28. -------------------
  29.  
  30. function Menu.addTitle(name)
  31.  
  32. local yoffset = 0.04 -- Move Red Strip Down
  33. local xoffset = 0
  34.  
  35. local xmin = posXMenuTitle
  36. local ymin = posYMenuTitle
  37. local xmax = widthMenuTitle
  38. local ymax = heightMenuTitle
  39.  
  40.  
  41. Menu.TitleGUI[Menu.titleCount +1] = {}
  42. Menu.TitleGUI[Menu.titleCount +1]["name"] = name
  43. Menu.TitleGUI[Menu.titleCount+1]["xmin"] = xmin + xoffset
  44. Menu.TitleGUI[Menu.titleCount+1]["ymin"] = ymin * (Menu.titleCount + 0.01) +yoffset
  45. Menu.TitleGUI[Menu.titleCount+1]["xmax"] = xmax
  46. Menu.TitleGUI[Menu.titleCount+1]["ymax"] = ymax
  47. Menu.titleCount = Menu.titleCount+1
  48. end
  49.  
  50. function Menu.addButton(name, func, args)
  51.  
  52. local yoffset = 0.04 -- Move List Down
  53. local xoffset = 0
  54.  
  55. local xmin = posXMenu
  56. local ymin = posYMenu
  57. local xmax = width
  58. local ymax = height
  59.  
  60.  
  61. Menu.GUI[Menu.buttonCount +1] = {}
  62. Menu.GUI[Menu.buttonCount +1]["name"] = name
  63. Menu.GUI[Menu.buttonCount+1]["func"] = func
  64. Menu.GUI[Menu.buttonCount+1]["args"] = args
  65. Menu.GUI[Menu.buttonCount+1]["active"] = false
  66. Menu.GUI[Menu.buttonCount+1]["xmin"] = xmin + xoffset
  67. Menu.GUI[Menu.buttonCount+1]["ymin"] = ymin * (Menu.buttonCount + 0.01) +yoffset
  68. Menu.GUI[Menu.buttonCount+1]["xmax"] = xmax
  69. Menu.GUI[Menu.buttonCount+1]["ymax"] = ymax
  70. Menu.buttonCount = Menu.buttonCount+1
  71. end
  72.  
  73.  
  74. function Menu.updateSelection()
  75. if IsControlJustPressed(1, 175) then -- INPUT_CELLPHONE_RIGHT
  76. if(Menu.selection < Menu.buttonCount -1 )then
  77. Menu.selection = Menu.selection +1
  78. else
  79. Menu.selection = 0
  80. end
  81. elseif IsControlJustPressed(1, 174) then -- INPUT_CELLPHONE_LEFT
  82. if(Menu.selection > 0)then
  83. Menu.selection = Menu.selection -1
  84. else
  85. Menu.selection = Menu.buttonCount-1
  86. end
  87. elseif IsControlJustPressed(1, 176) then -- INPUT_CELLPHONE_SELECT
  88. MenuCallFunction(Menu.GUI[Menu.selection +1]["func"], Menu.GUI[Menu.selection +1]["args"])
  89. end
  90. local iterator = 0
  91. for id, settings in ipairs(Menu.GUI) do
  92. Menu.GUI[id]["active"] = false
  93. if(iterator == Menu.selection ) then
  94. Menu.GUI[iterator +1]["active"] = true
  95. end
  96. iterator = iterator +1
  97. end
  98. end
  99.  
  100. function Menu.renderGUI()
  101. if not Menu.hidden then
  102. Menu.renderTitle()
  103. Menu.renderButtons()
  104. Menu.updateSelection()
  105. end
  106. end
  107.  
  108. function Menu.renderBox(xMin,xMax,yMin,yMax,color1,color2,color3,color4)
  109. DrawRect(xMin, yMin,xMax, yMax, color1, color2, color3, color4);
  110. end
  111.  
  112. function Menu.renderTitle()
  113. local yoffset = 0.2
  114. local xoffset = 0
  115.  
  116. local xmin = posXMenuTitle
  117. local ymin = posYMenuTitle
  118. local xmax = widthMenuTitle
  119. local ymax = heightMenuTitle
  120. for id, settings in pairs(Menu.TitleGUI) do
  121. local screen_w = 0
  122. local screen_h = 0
  123. screen_w, screen_h = GetScreenResolution(0, 0)
  124. boxColor = {255,23,0,200}
  125.  
  126. SetTextFont(0)
  127. SetTextScale(0.0,0.35)
  128. SetTextColour(255, 255, 255, 255)
  129. SetTextCentre(true)
  130. SetTextDropShadow(0, 0, 0, 0, 0)
  131. SetTextEdge(0, 0, 0, 0, 0)
  132. SetTextEntry("STRING")
  133. AddTextComponentString(string.upper(settings["name"]))
  134. DrawText(settings["xmin"], (settings["ymin"] - heightMenuTitle - 0.0125))
  135. Menu.renderBox(settings["xmin"] ,settings["xmax"], settings["ymin"] - heightMenuTitle, settings["ymax"],boxColor[1],boxColor[2],boxColor[3],boxColor[4])
  136. end
  137. end
  138.  
  139. function Menu.renderButtons()
  140.  
  141. for id, settings in pairs(Menu.GUI) do
  142. local screen_w = 0
  143. local screen_h = 0
  144. screen_w, screen_h = GetScreenResolution(0, 0)
  145. boxColor = {0,127,255,17}
  146.  
  147. if(settings["active"]) then
  148. boxColor = {0,130,255,200}
  149. end
  150. SetTextFont(0)
  151. SetTextScale(0.0,0.35)
  152. SetTextColour(255, 255, 255, 255)
  153. SetTextCentre(true)
  154. SetTextDropShadow(0, 0, 0, 0, 0)
  155. SetTextEdge(0, 0, 0, 0, 0)
  156. SetTextEntry("STRING")
  157. AddTextComponentString(settings["name"])
  158. DrawText(settings["xmin"], (settings["ymin"] - 0.0125 ))
  159. Menu.renderBox(settings["xmin"] ,settings["xmax"], settings["ymin"], settings["ymax"],boxColor[1],boxColor[2],boxColor[3],boxColor[4])
  160. end
  161. end
  162.  
  163.  
  164. --------------------------------------------------------------------------------------------------------------------
  165.  
  166. function ClearMenu()
  167. --Menu = {}
  168. Menu.GUI = {}
  169. Menu.buttonCount = 0
  170. Menu.titleCount = 0
  171. Menu.selection = 0
  172. end
  173.  
  174. function MenuCallFunction(fnc, arg)
  175. _G[fnc](arg)
  176. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement