./main_menu_extras.lua

  1. local Input_tracker 
  2. local Mouse_input_tracker 
  3.  
  4. local Screen_width = 495 
  5.  
  6. local Tween_done = true 
  7.  
  8. local ID_OPTIONS				= 1 
  9. local ID_CREDITS				= 2 
  10. local ID_MANUAL_INDEX 		= 3 
  11.  
  12. local Data = {} 
  13.  
  14. local function build_list() 
  15.  
  16. 	if game_get_platform() ~= "PC" then 
  17. 		Data[#Data + 1] = { 
  18. 			type = TYPE_BUTTON, 
  19. 			label = "MAINMENU_OPTIONS", 
  20. 			id = ID_OPTIONS, 
  21. 		} 
  22. 	end 
  23.  
  24. 	Data[#Data + 1] = { 
  25. 		type = TYPE_BUTTON, 
  26. 		label = "MAINMENU_CREDITS", 
  27. 		id = ID_CREDITS, 
  28. 	} 
  29. 	Data[#Data + 1] = { 
  30. 		type = TYPE_BUTTON, 
  31. 		label = "MAINMENU_DIGITAL_MANUAL", 
  32. 		id = ID_MANUAL_INDEX, 
  33. 	} 
  34.  
  35. end 
  36.  
  37. ---------------------------------------------------------------------------  
  38. -- Initialize Pause Options Menu. 
  39. --------------------------------------------------------------------------- 
  40. function main_menu_extras_init() 
  41.  
  42. 	build_list() 
  43.  
  44. 	-- Subscribe to the button presses we need 
  45. 	Input_tracker = Vdo_input_tracker:new() 
  46. 	Input_tracker:add_input("select", 		"main_menu_extras_button_a", 50) 
  47. 	Input_tracker:add_input("back", 			"main_menu_extras_button_b", 50) 
  48. 	Input_tracker:add_input("nav_up", 		"main_menu_extras_nav", 50) 
  49. 	Input_tracker:add_input("nav_down", 	"main_menu_extras_nav", 50) 
  50. 	Input_tracker:add_input("nav_left", 	"main_menu_extras_nav", 50) 
  51. 	Input_tracker:add_input("nav_right", 	"main_menu_extras_nav", 50) 
  52. 	Input_tracker:subscribe(false) 
  53.  
  54. 	--Initialize Header 
  55. 	Header_obj:set_text("MAINMENU_EXTRAS", Screen_width) 
  56.  
  57. 	--Setup Button Hints 
  58. 	local hint_data = { 
  59. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  60. 	} 
  61. 	Menu_hint_bar:set_hints(hint_data)   
  62. 	 
  63. 	--Get the selection option from when the menu was last loaded 
  64. 	local last_option_selected = menu_common_stack_get_index(Data) 
  65. 	 
  66. 	List:draw_items(Data, last_option_selected, Screen_width) 
  67. 	 
  68. 	--Store some locals to the pause menu common for screen processing. 
  69. 	menu_common_set_list_style(List, Header_obj, Screen_width) 
  70. 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim) 
  71.  
  72. 	if First_time then 
  73. 		Screen_in_anim:play(0) 
  74. 		bg_saints_slide_in(Screen_width) 
  75. 		First_time = false 
  76. 	end 
  77. 	 
  78. 	-- Add mouse inputs for the PC 
  79. 	if game_get_platform() == "PC" then 
  80. 		Menu_hint_bar:set_highlight(0) 
  81. 		 
  82. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  83. 		List:add_mouse_inputs("main_menu_extras", Mouse_input_tracker) 
  84. 		Menu_hint_bar:add_mouse_inputs("main_menu_extras", Mouse_input_tracker) 
  85. 		Mouse_input_tracker:subscribe(true) 
  86. 		 
  87. 		--menu_common_set_mouse_tracker(Mouse_input_tracker) 
  88. 	end 
  89. end 
  90.  
  91. function main_menu_extras_cleanup() 
  92. 	-- Nuke all button subscriptions 
  93. 	Input_tracker:subscribe(false) 
  94. 	if Mouse_input_tracker ~= nil then 
  95. 		Mouse_input_tracker:subscribe(false) 
  96. 	end 
  97. 	List:enable_toggle_input(false) 
  98. end 
  99.  
  100. function main_menu_extras_nav(event, acceleration) 
  101. 	if Tween_done == true then 
  102. 		if event == "nav_up" then 
  103. 			-- Move highlight up 
  104. 			List:move_cursor(-1) 
  105. 		elseif event == "nav_down" then 
  106. 			-- Move highlight down 
  107. 			List:move_cursor(1) 
  108. 		elseif event == "nav_left" then 
  109. 			-- Move highlight left 
  110. 			List:move_slider(-1) 
  111. 		elseif event == "nav_right" then 
  112. 			-- Move highlight right 
  113. 			List:move_slider(1) 
  114. 		end 
  115. 	end 
  116. end 
  117.  
  118. function main_menu_extras_button_a(event, acceleration) 
  119. 	 
  120. 	if Tween_done == true then 
  121. 		--Set the screen data to the list data 
  122. 		Data = List:return_data() 
  123. 		local current_id = List:get_id() 
  124. 	 
  125. 		--Add current selection to the stack to store the selected position on the menu 
  126. 		menu_common_stack_add(current_id) 
  127.  
  128. 		--pass off the input to the list 
  129. 		--List:button_a() 
  130. 		if current_id == ID_CREDITS then 
  131. 			menu_common_transition_push("credits") 
  132. 			return 
  133. 		elseif current_id == ID_MANUAL_INDEX then 
  134. 			--menu_common_transition_push("")			 
  135. 			-- mm_wireless.vint_doc 
  136. 			if game_get_platform() == "PC" and game_is_connected_to_service() then 
  137. 				game_steam_open_url("http://www.thq.com/manual") 
  138. 			else 
  139. 				dialog_box_message("MENU_TITLE_NOTICE", "MAINMENU_DIGITAL_MANUAL_TEXT", true, true) 
  140. 			end 
  141. 			return 
  142. 		elseif current_id == ID_OPTIONS then 
  143. 			menu_common_transition_push("pause_options_menu") 
  144. 		end 
  145. 	end 
  146. end 
  147.  
  148. function main_menu_extras_button_b(event, acceleration) 
  149. 	if Tween_done == true then 
  150. 		--pass off the input to the list 
  151. 		List:button_b() 
  152. 		 
  153. 		--Remove current menu from the stack 
  154. 		menu_common_stack_remove() 
  155. 		 
  156. 		--Pop Screen off the list 
  157. 		menu_common_transition_pop(1) 
  158. 		 
  159. 		bg_saints_slide_out() 
  160. 	end 
  161. end 
  162.  
  163. function main_menu_extras_mouse_click(event, target_handle) 
  164. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  165. 	if hint_index == 1 then 
  166. 		main_menu_extras_button_b() 
  167. 	end 
  168.  
  169. 	local new_index = List:get_button_index(target_handle) 
  170. 	if new_index ~= 0 then 
  171. 		List:set_selection(new_index) 
  172. 		main_menu_extras_button_a() 
  173. 	end 
  174. end 
  175.  
  176. function main_menu_extras_mouse_move(event, target_handle) 
  177. 	Menu_hint_bar:set_highlight(0) 
  178. 	 
  179. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  180. 	if hint_index ~= 0 then 
  181. 		Menu_hint_bar:set_highlight(hint_index) 
  182. 	end 
  183. 	 
  184. 	local new_index = List:get_button_index(target_handle) 
  185. 	if new_index ~= 0 then 
  186. 		List:set_selection(new_index) 
  187. 		List:move_cursor(0, true) 
  188. 	end 
  189. end