./main_menu_extras.lua

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