Advertisement
Guest User

pls

a guest
Jul 12th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.83 KB | None | 0 0
  1. if not SimpleMenu then
  2. SimpleMenu = class()
  3.  
  4. function SimpleMenu:init(title, message, options)
  5. self.dialog_data = { title = title, text = message, button_list = {},
  6. id = tostring(math.random(0,0xFFFFFFFF)) }
  7. self.visible = false
  8. for _,opt in ipairs(options) do
  9. local elem = {}
  10. elem.text = opt.text
  11. opt.data = opt.data or nil
  12. opt.callback = opt.callback or nil
  13. elem.callback_func = callback(self, self, "_do_callback",
  14. { data = opt.data,
  15. callback = opt.callback})
  16. elem.cancel_button = opt.is_cancel_button or false
  17. if opt.is_focused_button then
  18. self.dialog_data.focus_button = #self.dialog_data.button_list+1
  19. end
  20. table.insert(self.dialog_data.button_list, elem)
  21. end
  22. return self
  23. end
  24.  
  25. function SimpleMenu:_do_callback(info)
  26. if info.callback then
  27. if info.data then
  28. info.callback(info.data)
  29. else
  30. info.callback()
  31. end
  32. end
  33. self.visible = false
  34. end
  35.  
  36. function SimpleMenu:show()
  37. if self.visible then
  38. return
  39. end
  40. self.visible = true
  41. managers.system_menu:show(self.dialog_data)
  42. end
  43.  
  44. function SimpleMenu:hide()
  45. if self.visible then
  46. managers.system_menu:close(self.dialog_data.id)
  47. self.visible = false
  48. return
  49. end
  50. end
  51. end
  52.  
  53. patched_update_input = patched_update_input or function (self, t, dt )
  54. if self._data.no_buttons then
  55. return
  56. end
  57.  
  58. local dir, move_time
  59. local move = self._controller:get_input_axis( "menu_move" )
  60.  
  61. if( self._controller:get_input_bool( "menu_down" )) then
  62. dir = 1
  63. elseif( self._controller:get_input_bool( "menu_up" )) then
  64. dir = -1
  65. end
  66.  
  67. if dir == nil then
  68. if move.y > self.MOVE_AXIS_LIMIT then
  69. dir = 1
  70. elseif move.y < -self.MOVE_AXIS_LIMIT then
  71. dir = -1
  72. end
  73. end
  74.  
  75. if dir ~= nil then
  76. if( ( self._move_button_dir == dir ) and self._move_button_time and ( t < self._move_button_time + self.MOVE_AXIS_DELAY ) ) then
  77. move_time = self._move_button_time or t
  78. else
  79. self._panel_script:change_focus_button( dir )
  80. move_time = t
  81. end
  82. end
  83.  
  84. self._move_button_dir = dir
  85. self._move_button_time = move_time
  86.  
  87. local scroll = self._controller:get_input_axis( "menu_scroll" )
  88. -- local sdir
  89. if( scroll.y > self.MOVE_AXIS_LIMIT ) then
  90. self._panel_script:scroll_up()
  91. -- sdir = 1
  92. elseif( scroll.y < -self.MOVE_AXIS_LIMIT ) then
  93. self._panel_script:scroll_down()
  94. -- sdir = -1
  95. end
  96. end
  97. managers.system_menu.DIALOG_CLASS.update_input = patched_update_input
  98. managers.system_menu.GENERIC_DIALOG_CLASS.update_input = patched_update_input
  99.  
  100. add_job = add_job or function(data)
  101. local difficulty_id = tweak_data:difficulty_to_index( data.difficulty )
  102. table.insert( managers.crimenet._presets, { job_id = data.job_id, difficulty_id = difficulty_id, difficulty = data.difficulty, chance = 1 } )
  103. managers.crimenet._MAX_ACTIVE_JOBS = managers.crimenet._MAX_ACTIVE_JOBS + 1
  104. end
  105.  
  106. show_menu = show_menu or function(menu)
  107. menu:show()
  108. end
  109.  
  110. mission = mission or function(job_id)
  111. local difficulty_opts = {
  112. { text = "Normal", callback = add_job, data = { difficulty = "normal", job_id = job_id } },
  113. { text = "Hard", callback = add_job, data = { difficulty = "hard", job_id = job_id } },
  114. { text = "Very Hard", callback = add_job, data = { difficulty = "overkill", job_id = job_id } },
  115. { text = "Overkill", callback = add_job, data = { difficulty = "overkill_145", job_id = job_id } },
  116. { text = "Mega Extreme Mode (Deathwish)", callback = add_job, data = "overkill_290", job_id = job_id } },
  117. { text = "Cancel", is_cancel_button = true},
  118. }
  119. local difficulty_menu = SimpleMenu:new("Mission Selector", "Choose Difficulty", difficulty_opts)
  120. difficulty_menu:show()
  121. end
  122.  
  123.  
  124. --Menu Contractor
  125. bain = bain or {
  126. { text = "Jewelry Store", callback = mission, data = "jewelry_store" },
  127. { text = "Bank Heist: Gold*", callback = mission, data = "branchbank_gold" },
  128. { text = "Bank Heist: Cash", callback = mission, data = "branchbank_cash" },
  129. { text = "Bank Heist: Deposit", callback = mission, data = "branchbank_deposit" },
  130. { text = "Bank Heist*", callback = mission, data="branchbank" },
  131. { text = "Diamond Store", callback = mission, data="family" },
  132. { text = "Jewelry Store (Pro Job)*", callback = mission, data = "jewelry_store_prof" },
  133. { text = "Bank Heist: Gold (Pro Job)", callback = mission, data = "branchbank_gold_prof" },
  134. { text = "Bank Heist: Cash (Pro Job)*", callback = mission, data = "branchbank_cash_prof" },
  135. { text = "Bank Heist: Deposit (Pro Job)*", callback = mission, data = "branchbank_deposit_prof" },
  136. { text = "Bank Heist (Pro Job)", callback = mission, data = "branchbank_prof" },
  137. { text = "Diamond Store (Pro Job)*", callback = mission, data = "family_prof" },
  138. { text = "Cancel", is_cancel_button = true },
  139. }
  140. bainmenu = bainmenu or SimpleMenu:new("Mission Selector", "Choose Map", bain)
  141. hector = hector or {
  142. { text = "Watchdogs", callback = mission, data = "watchdogs" },
  143. { text = "Fire Starter", callback = mission, data = "firestarter" },
  144. { text = "Rats", callback = mission, data = "alex" },
  145. { text = "Watchdogs (Pro Job)", callback = mission, data = "watchdogs_prof" },
  146. { text = "Fire Starter (Pro Job)", callback = mission, data = "firestarter_prof" },
  147. { text = "Rats (Pro Job)", callback = mission, data = "alex_prof" },
  148. { text = "Cancel", is_cancel_button = true},
  149. }
  150. hectormenu = hectormenu or SimpleMenu:new("Mission Selector", "Choose Map", hector)
  151. elephant = elephant or {
  152. { text = "Framing Frame", callback = mission, data = "framing_frame" },
  153. { text = "Big Oil*", callback = mission, data = "welcome_to_the_jungle" },
  154. { text = "Framing Frame (Pro Job)", callback = mission, data = "mallcrasher" },
  155. { text = "Big Oil (Pro Job)", callback = mission, data = "welcome_to_the_jungle_prof" },
  156. { text = "Cancel", is_cancel_button = true},
  157. }
  158. elephantmenu = elephantmenu or SimpleMenu:new("Mission Selector", "Choose Map",elephant)
  159. vlad = vlad or {
  160. { text = "Four Stores", callback = mission, data = "four_stores" },
  161. { text = "Mallcrasher", callback = mission, data = "mallcrasher" },
  162. { text = "Nightclub", callback = mission, data = "nightclub" },
  163. { text = "Ukrainian Job*", callback = mission, data= "ukrainian_job" },
  164. { text = "Four Stores (Pro Job)*", callback = mission, data = "four_stores_prof" },
  165. { text = "Mallcrasher (Pro Job)*", callback = mission, data = "mallcrasher_prof" },
  166. { text = "Nightclub (Pro Job)*", callback = mission, data = "nightclub_prof" },
  167. { text = "Ukrainian Job (Pro Job)", callback = mission, data= "ukrainian_job_prof" },
  168. { text = "Cancel", is_cancel_button = true},
  169. }
  170. vladmenu = vladmenu or SimpleMenu:new("Mission Selector", "Choose Map",vlad)
  171.  
  172. rootopts = rootopts or {
  173. { text = "Bain", callback = show_menu, data = bainmenu},
  174. { text = "Hector", callback = show_menu, data = hectormenu},
  175. { text = "The Elephant", callback = show_menu, data = elephantmenu},
  176. { text = "Vlad", callback = show_menu, data = vladmenu},
  177. { text = "Cancel", is_cancel_button = true},
  178. }
  179. if not rootmenu then
  180. managers.crimenet._NEW_JOB_MIN_TIME = 0
  181. managers.crimenet._NEW_JOB_MAX_TIME = 0
  182. managers.crimenet._presets = { }
  183. managers.crimenet._active_jobs = { }
  184. managers.crimenet._MAX_ACTIVE_JOBS = 0
  185. rootmenu = rootmenu or SimpleMenu:new("Mission Selector", "Choose Contractor", rootopts)
  186. end
  187.  
  188. rootmenu:show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement