./pause_menu_top.lua

  1. -- Globals 
  2. -- These are from mission_info.h 
  3. local MT_MISSION_NONE 		= -1 
  4. local MT_MISSION 			= 0 
  5. local MT_ACTIVITY			= 1 
  6. local MT_SILENT				= 2 
  7. local MT_DIVERSION_ACTIVE	= 3 
  8.  
  9. local ID_SAVE_GAME		= 1 
  10. local ID_LOAD_GAME		= 2 
  11. local ID_OPTIONS			= 3 
  12. local ID_CO_OP				= 4 
  13. local ID_QUIT_GAME		= 5 
  14. local ID_CANCEL_MISSION	= 8 
  15. --HVS_TBT 7/23/2014 
  16. local ID_HELP = 12 
  17. --HVS_TBT 7/30/2014 
  18. local ID_PAUSE_VOICE_TUT = 13 
  19.  
  20. local Cleanup_from_b = false 
  21.  
  22. local Quit_message_normal = "QUIT_GAME_TEXT_FULL" 
  23. local Quit_message 
  24.  
  25. local Data 
  26. local Save_button = { 
  27. 	type = TYPE_BUTTON, 
  28. 	label = "SAVELOAD_SAVE_GAME", 
  29. 	id = ID_SAVE_GAME, 
  30. } 
  31.  
  32. local Load_button = { 
  33. 	type = TYPE_BUTTON, 
  34. 	label = "SAVELOAD_LOAD_GAME", 
  35. 	id = ID_LOAD_GAME, 
  36. } 
  37.  
  38. local Options_button = { 
  39. 	type = TYPE_BUTTON, 
  40. 	label = "PAUSE_MENU_OPTIONS", 
  41. 	id = ID_OPTIONS, 
  42. } 
  43.  
  44. local Coop_button = { 
  45. 	type = TYPE_BUTTON, 
  46. 	label = "PAUSE_MENU_COOP", 
  47. 	id = ID_CO_OP, 
  48. } 
  49.  
  50. --HVS_TBT 7/23/2014 
  51. local Help_button = { 
  52. 	type = TYPE_BUTTON, 
  53. 	label = "PAUSE_MENU_HELP", 
  54. 	id = ID_HELP 
  55. } 
  56.  
  57. --HVS_TBT 7/30/2014 
  58. local Voice_tut_button = { 
  59. 	type = TYPE_BUTTON, 
  60. 	label = "PAUSE_VOICE_TUT", 
  61. 	id = ID_PAUSE_VOICE_TUT 
  62. } 
  63.  
  64. local Quit_button = { 
  65. 	type = TYPE_BUTTON, 
  66. 	label = "HORDE_MODE_MENU_EXIT", 
  67. 	id = ID_QUIT_GAME, 
  68. } 
  69.  
  70. local Cancel_button = { 
  71. 	type = TYPE_BUTTON, 
  72. 	id = ID_CANCEL_MISSION, 
  73. 	label = "HUD_CANCEL_MISSION", 
  74. } 
  75.  
  76. local Anims = {} 
  77.  
  78. local Input_tracker 
  79. local Mouse_input_tracker 
  80. local Online_check_thread = -1 
  81.  
  82. local Screen_width 
  83. if vint_is_std_res() then 
  84. 	Screen_width = 750 
  85. else 
  86. 	Screen_width = 840 
  87. end 
  88.  
  89. local Tween_done = true 
  90.  
  91. local Checking_dlc = false 
  92.  
  93. ---------------------------------------------------------------------------  
  94. -- Initialize Pause Menu Top (First Level of Pause Menu) 
  95. --------------------------------------------------------------------------- 
  96. function pause_menu_top_init() 
  97. 	-- Subscribe to the button presses we need 
  98. 	 
  99. 	Input_tracker = Vdo_input_tracker:new() 
  100. 	Input_tracker:add_input("select", "pause_menu_top_button_a", 50) 
  101. 	Input_tracker:add_input("pause", "pause_menu_top_button_b", 50) 
  102. 	Input_tracker:add_input("back", "pause_menu_top_button_b", 50) 
  103. 	Input_tracker:add_input("nav_up", "pause_menu_top_nav_up", 50) 
  104. 	Input_tracker:add_input("nav_down", "pause_menu_top_nav_down", 50) 
  105. 	Input_tracker:add_input("nav_left", "pause_menu_top_nav_left", 50) 
  106. 	Input_tracker:add_input("nav_right", "pause_menu_top_nav_right", 50) 
  107. 	Input_tracker:subscribe(false) 
  108.  
  109. 	ui_audio_post_event("ui_pause") 
  110. 	 
  111. 	--Initialize Header 
  112. 	Header_obj:set_text("SYSTEM_PAUSED", Screen_width) --("MENU_GAME_PAUSED") 
  113. 	 
  114. 	-- Clear pause menu and build a new one 
  115. 	Data = {} 
  116. 	 
  117. 	 
  118. 	if game_machinima_is_recording() == false then 
  119. 		if game_is_prologue_complete(true) == true and vint_game_is_safe_to_save_game() == true then 
  120. 			Data[#Data+1] = Save_button 
  121. 		end 
  122. 		if vint_game_is_safe_to_load_game() == true then 
  123. 			Data[#Data+1] = Load_button 
  124. 		end 
  125. 	end 
  126. 	 
  127. 	local gameplay_type = game_get_in_progress_type() 
  128. 	local cancel_button_tag = nil 
  129. 	--HVS_RCK - If you haven't completed the prologue, you can't exit/retry the mission. Specifying true means we include the flight tutorial 
  130. 	if not mission_is_active("mIntro") then 
  131. 		if gameplay_type == MT_MISSION then 
  132. 			cancel_button_tag = "HUD_CANCEL_MISSION" 
  133. 		elseif gameplay_type == MT_ACTIVITY then 
  134. 			cancel_button_tag = "HUD_CANCEL_ACTIVITY" 
  135. 		elseif gameplay_type == MT_DIVERSION_ACTIVE then 
  136. 			cancel_button_tag = "HUD_CANCEL_DIVERSION" 
  137. 		end 
  138. 	end 
  139.  
  140. 	if cancel_button_tag then 
  141. 		Data[#Data+1] = Cancel_button 
  142. 		Cancel_button.label = cancel_button_tag 
  143. 		if pause_menu_cant_retry_because_host_in_creation() then 
  144. 			Cancel_button.disabled = true 
  145. 		end 
  146. 	end 
  147. 	 
  148. 	Data[#Data+1] = Options_button 
  149.  
  150. 	if game_get_is_host() == false and cancel_button_tag ~= nil then 
  151. 		Load_button.disabled = true 
  152. 	end 
  153. 	 
  154. 	-- HVS_JBG - don't allow the client to load during the intro. They should load a character when joining, or can load after the intro is complete. 
  155. 	-- This should be fine because the player's abilities should be fixed during the intro anyway. 
  156. 	-- This addresses Hansoft #11006 
  157. 	if game_get_is_host() == false and mission_is_active("mIntro") then 
  158. 		Load_button.disabled = true 
  159. 	end 
  160. 	 
  161. 	if game_machinima_is_recording() == false and game_is_demo() == false then 
  162. 		Data[#Data+1] = Coop_button 
  163. 	end 
  164.  
  165. 	if game_record_mode_is_supported() then 
  166. 		--Data[#Data+1] = Casual_record_button 
  167. 		--[[if game_machinima_is_recording() == true then 
  168. 			Data[#Data+1] = Playback_button; 
  169. 		else 
  170. 			Data[#Data+1] = Record_button; 
  171. 		end]] 
  172. 	end 
  173.  
  174. 	if game_get_platform() == "XBOX3" then 
  175. 		Data[#Data+1] = Help_button 
  176. 	end 
  177.  
  178. 	if (game_get_platform() == "XBOX3" or game_get_platform() == "PS4") and hvs_voice_controls_active() then 
  179. 		Data[#Data+1] = Voice_tut_button 
  180. 	end 
  181.  
  182. 	Data[#Data+1] = Quit_button 
  183. 	 
  184. 	Quit_message = Quit_message_normal 
  185.  
  186. 	 
  187. 	--Setup button hints 
  188. 	local hint_data = { 
  189. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  190. 	} 
  191. 	Menu_hint_bar:set_hints(hint_data) 
  192. 	 
  193. 	--Get the selection option from when the menu was last loaded 
  194. 	local last_option_selected = menu_common_stack_get_index(Data) 
  195. 	--[[ 
  196. 	--this HACK stinks, we should get the longest string width back and adjust for that 
  197. 	if game_get_language() == "DE" then 
  198. 		Screen_width = 680 
  199. 	end 
  200. 	]] 
  201. 	-- Initialize and draw list object 
  202. 	List:draw_items(Data, last_option_selected, Screen_width)	 
  203. 	 
  204. 	--Store some locals to the pause menu common for screen processing. 
  205. 	menu_common_set_list_style(List, Header_obj, Screen_width) 
  206. 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim, pause_menu_top_anim_in_done) 
  207. 	 
  208. 	 
  209. 	-- Add mouse input subscriptions for the PC 
  210. 	if game_get_platform() == "PC" then 
  211. 		Menu_hint_bar:set_highlight(0) 
  212. 	 
  213. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  214. 		List:add_mouse_inputs("pause_menu_top", Mouse_input_tracker) 
  215. 		Menu_hint_bar:add_mouse_inputs("pause_menu_top", Mouse_input_tracker) 
  216. 		Mouse_input_tracker:subscribe(true) 
  217. 	end 
  218. 	 
  219. 	if First_time then 
  220. 		local bg_anchor = 100 
  221. 		if vint_is_std_res() then 
  222. 			bg_anchor = 74 
  223. 		end 
  224. 		Screen_in_anim:play(0) 
  225. 		bg_saints_slide_in(Screen_width, bg_anchor) 
  226. 		bg_saints_dimmer_show(true)	--Dim out the game... 
  227. 		First_time = false 
  228. 	end 
  229. 	 
  230. 	vint_set_mouse_cursor("") 
  231. 	 
  232. 	 
  233. end 
  234.  
  235. function pause_menu_top_force_save() 
  236. 	local current_id = List:get_id() 
  237. 	--Add current selection to the stack to store the selected position on the menu 
  238. 	menu_common_stack_add(current_id) 
  239. 	Save_system_operation = SAVE_OPERATION_SAVE_GAME 
  240. 	Close_all_menu = true 
  241. 	menu_common_transition_push("pause_save_game") 
  242. 	Save_message_displayed = true	 
  243. end 
  244.  
  245. function pause_menu_top_gained_focus() 
  246. 	--Initialize Header 
  247. 	Header_obj:set_text("SYSTEM_PAUSED", Screen_width) --("MENU_GAME_PAUSED") 
  248.  
  249. 		--Setup button hints 
  250. 	local hint_data = { 
  251. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  252. 	} 
  253. 	Menu_hint_bar:set_hints(hint_data) 
  254.  
  255. 	--Get the selection option from when the menu was last loaded 
  256. 	local last_option_selected = menu_common_stack_get_index(Data) 
  257. 	 
  258. 	-- Remove subscriptions 
  259. 	if Mouse_input_tracker ~= nil then 
  260. 		Mouse_input_tracker:remove_all() 
  261. 	end 
  262. 	 
  263. 	-- Initialize and draw list object 
  264. 	List:draw_items(Data, last_option_selected, Screen_width)	 
  265. 	 
  266. 	-- Re-add subscriptions 
  267. 	if Mouse_input_tracker ~= nil then 
  268. 		List:add_mouse_inputs("pause_menu_top", Mouse_input_tracker) 
  269. 		Menu_hint_bar:add_mouse_inputs("pause_menu_top", Mouse_input_tracker) 
  270. 		Mouse_input_tracker:subscribe(true) 
  271. 	end 
  272. 	 
  273. 	--Store some locals to the pause menu common for screen processing. 
  274. 	menu_common_set_list_style(List, Header_obj, Screen_width) 
  275. 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim, pause_menu_top_anim_in_done) 
  276.  
  277. end 
  278.  
  279. function pause_menu_top_lost_focus() 
  280. 	-- Nuke all button subscriptions 
  281. 	Input_tracker:subscribe(false) 
  282. 	 
  283. 	if Mouse_input_tracker ~= nil then 
  284. 		Mouse_input_tracker:subscribe(false) 
  285. 	end 
  286. 	List:enable_toggle_input(false) 
  287. end 
  288.  
  289. function pause_menu_top_cleanup() 
  290. 	if Online_check_thread ~= -1 then 
  291. 		thread_kill(Online_check_thread) 
  292. 	end 
  293. 	 
  294. 	-- Nuke all button subscriptions 
  295. 	Input_tracker:subscribe(false) 
  296. 	 
  297. 	if Mouse_input_tracker ~= nil then 
  298. 		Mouse_input_tracker:subscribe(false) 
  299. 	end 
  300. 	List:enable_toggle_input(false) 
  301. 	 
  302. 	if Cleanup_from_b ~= true then 
  303. 		ui_audio_post_event("ui_unpause") 
  304. 	end 
  305. 	 
  306. end 
  307.  
  308. function pause_menu_top_anim_in_done() 
  309. 	if Exit_after_closing == true then 
  310. 		Input_tracker:subscribe(false) 
  311. 		 
  312. 		if Mouse_input_tracker ~= nil then 
  313. 			Mouse_input_tracker:subscribe(false) 
  314. 		end 
  315. 	else 
  316. 		Input_tracker:subscribe(true) 
  317. 	 
  318. 		if Mouse_input_tracker ~= nil then 
  319. 			Mouse_input_tracker:subscribe(true) 
  320. 		end 
  321. 	end 
  322. 	 
  323. 	--send them straight to save 
  324. 	if pause_menu_point_of_no_return() then 
  325. 		pause_menu_top_force_save() 
  326. 	end 
  327. 	 
  328. 	pause_menu_common_top_finished_loading() 
  329. end 
  330.  
  331. function pause_menu_top_nav_up(event, acceleration) 
  332. 	-- Move highlight up 
  333. 	List:move_cursor(-1) 
  334. end 
  335.  
  336. function pause_menu_top_nav_down(event, acceleration) 
  337. 	-- Move highlight down 
  338. 	List:move_cursor(1) 
  339. end 
  340.  
  341. function pause_menu_top_nav_left(event, acceleration) 
  342. 	-- Move highlight left 
  343. 	List:move_slider(-1) 
  344. end 
  345.  
  346. function pause_menu_top_nav_right(event, acceleration) 
  347. 	-- Move highlight right 
  348. 	List:move_slider(1) 
  349. end 
  350.  
  351. function pause_menu_save_callback(result, action) 
  352. 	menu_common_transition_push("pause_save_game") 
  353. end 
  354.  
  355. function coop_dlc_checked(has_dlc, cancelled) 
  356. 	if has_dlc then 
  357. 		Input_tracker:subscribe(true)	 
  358. 		menu_common_transition_push("pause_co_op_menu") 
  359. 		List:button_a() 
  360. 		return 
  361. 	end 
  362. 	 
  363. 	if not cancelled then  
  364. 		dialog_box_message("DIALOG_COOP_DLC_TITLE", "DIALOG_COOP_DLC_BODY") 
  365. 	end 
  366. 	Input_tracker:subscribe(true) 
  367. end 
  368.  
  369. function pause_menu_top_button_a(event, acceleration) 
  370. 	local package_chunk_movies = 1 
  371. 	if game_get_platform() == "XBOX3" then 
  372. 		package_chunk_movies = 2 
  373. 	end 
  374.  
  375. 	if Tween_done == true then 
  376. 		--Set the screen data to the list data 
  377. 		Data = List:return_data() 
  378. 		local current_id = List:get_id() 
  379. 		 
  380. 		--Add current selection to the stack to store the selected position on the menu 
  381. 		menu_common_stack_add(current_id) 
  382. 		 
  383. 		--pass off the input to the list  
  384. 		 
  385. 		if current_id == ID_SAVE_GAME then 
  386. 			-- check if the game is autosaving 
  387. 			if game_is_autosaving() then 
  388. 				dialog_box_message("MENU_TITLE_NOTICE", "SAVELOAD_CANT_ENTER_AUTOSAVE") 
  389. 			else 
  390. 				Save_system_operation = SAVE_OPERATION_SAVE_GAME 
  391. 				List:button_a() 
  392. 				local progress_type = game_get_in_progress_type() 
  393. 				if Save_message_displayed == false and (progress_type == MT_MISSION or progress_type == MT_SILENT) then 
  394. 					dialog_box_message("MENU_TITLE_WARNING", "SAVELOAD_MISSION_WARNING", nil, nil, "pause_menu_save_callback") 
  395. 				elseif Save_message_displayed == false and (progress_type == MT_ACTIVITY or progress_type == MT_DIVERSION_ACTIVE) then 
  396. 					dialog_box_message("MENU_TITLE_WARNING", "SAVELOAD_ACTIVITY_WARNING", nil, nil, "pause_menu_save_callback") 
  397. 				else 
  398. 					menu_common_transition_push("pause_save_game") 
  399. 				end 
  400. 				Save_message_displayed = true			 
  401. 			end 
  402. 			return 
  403. 		elseif current_id == ID_LOAD_GAME then 
  404. 			-- check if the game is autosaving 
  405. 			if game_is_autosaving() then 
  406. 				dialog_box_message("MENU_TITLE_NOTICE", "SAVELOAD_CANT_ENTER_AUTOSAVE") 
  407. 			elseif game_is_waiting_for_partner() then 
  408. 				dialog_box_message("MENU_TITLE_NOTICE", "SAVELOAD_CANT_ENTER_JOINING") 
  409. 			else 
  410. 				Save_system_operation = SAVE_OPERATION_LOAD_GAME 
  411. 				menu_common_transition_push("pause_save_game") 
  412. 				List:button_a() 
  413. 			end 
  414. 			return	 
  415. 		elseif current_id == ID_OPTIONS then 
  416. 			menu_common_transition_push("pause_options_menu") 
  417. 			List:button_a() 
  418. 		 
  419. 			return	 
  420. 		elseif current_id == ID_CO_OP then 
  421. 			if game_get_platform() == "PS3" then 
  422. 				if not game_user_has_online_privilege() then 
  423. 					dialog_box_message( "MENU_TITLE_NOTICE", "PLATFORM_PS3_ONLINE_AGE_RESTRICTED" ) 
  424. 					return 
  425. 				end 
  426. 			end 
  427. 			if package_chunk_loaded(package_chunk_movies) == false then 
  428. 				dialog_box_message( "GAME_INSTALL_INCOMPLETE_TITLE", "GAME_INSTALL_INCOMPLETE_LOAD" ) 
  429. 				return 
  430. 			end 
  431. 			Input_tracker:subscribe(false) 
  432. 			game_check_coop_dlc("coop_dlc_checked") 
  433. 			return	 
  434. 		elseif current_id == ID_CANCEL_MISSION then 
  435. 			game_cancel_mission() 
  436. 			return 
  437. 		elseif current_id == ID_QUIT_GAME then 
  438. 			dialog_box_destructive_confirmation("PAUSE_MENU_QUIT_TITLE", Quit_message,"pause_menu_top_confirm_quit") 
  439. 			if Mouse_input_tracker ~= nil then 
  440. 				Mouse_input_tracker:subscribe(false) 
  441. 			end 
  442. 			return 
  443. 		elseif current_id == ID_PAUSE_VOICE_TUT then 
  444. 			pause_menu_show_voice_tut() 
  445. 		elseif current_id == ID_HELP then 
  446. 			hvs_xb1_voice_snap_help() 
  447. 		end 
  448. 	end 
  449. end 
  450.  
  451. --HVS_TBT 8/15/2014: use proper transition to push voice tutorial 
  452. function pause_menu_show_voice_tut() 
  453. 	menu_common_transition_push("pause_voice_tut") 
  454. end 
  455.  
  456. function pause_menu_top_confirm_quit(result, action) 
  457. --	if action == 1 then 
  458. --		return 
  459. --	end 
  460. 	 
  461. 	if result == 0 then 
  462. 		-- Dialog box result YES 
  463. 		Input_tracker:subscribe(false) 
  464. 		pause_menu_quit_game_internal() 
  465. --		menu_common_transition_pop(2) 
  466. --		bg_saints_slide_out() 
  467. 	elseif result == 1 then 
  468. 		-- Dialog box result NO 
  469. 		-- Restore inputs to the pause menu 
  470. 		if Mouse_input_tracker ~= nil then 
  471. 			Mouse_input_tracker:subscribe(true) 
  472. 		end 
  473. 	end 
  474. end 
  475.  
  476. function record_mode_confirm(result, action) 
  477. 	--[[ 
  478. 	if result == 0 then 
  479. 		-- Dialog box result YES 
  480. 		game_machinima_record() 
  481. 		menu_common_transition_pop(2) 
  482. 	elseif result == 1 then 
  483. 		-- Dialog box result NO 
  484. 		-- Restore inputs to the pause menu 
  485. 		if Mouse_input_tracker ~= nil then 
  486. 			Mouse_input_tracker:subscribe(true) 
  487. 		end 
  488. 	end 
  489. 	]] 
  490. end 
  491.  
  492. function playback_mode_confirm(result, action) 
  493. 	--[[ 
  494. 	if result == 0 then 
  495. 		-- Dialog box result YES 
  496. 		game_machinima_playback_enter("machinima") 
  497. 		menu_common_transition_pop(2) 
  498. 	elseif result == 1 then 
  499. 		-- Dialog box result NO 
  500. 		-- Restore inputs to the pause menu 
  501. 		if Mouse_input_tracker ~= nil then 
  502. 			Mouse_input_tracker:subscribe(true) 
  503. 		end 
  504. 	end 
  505. 	]] 
  506. end 
  507.  
  508. function pause_menu_top_button_b(event, acceleration) 
  509. 	if Tween_done == true then 
  510. 		Input_tracker:subscribe(false) 
  511. 		if Mouse_input_tracker ~= nil then 
  512. 			Mouse_input_tracker:subscribe(true) 
  513. 		end 
  514. 		List:button_b() 
  515. 		menu_common_transition_pop(2) 
  516. 		bg_saints_slide_out() 
  517. 		Cleanup_from_b = true 
  518. 		ui_audio_post_event("ui_unpause") 
  519. 	end 
  520. end 
  521.  
  522. function pause_menu_top_mouse_click(event, target_handle) 
  523. 	-- First check if the target_handle is in the hint bar 
  524. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  525. 	if hint_index == 1 then 
  526. 		pause_menu_top_button_b() 
  527. 	end 
  528.  
  529. 	local new_index = List:get_button_index(target_handle) 
  530. 	if new_index ~= 0 then 
  531. 		-- Enter an option if the target_handle is in the List 
  532. 		List:set_selection(new_index) 
  533. 		pause_menu_top_button_a() 
  534. 	end 
  535. end 
  536.  
  537. function pause_menu_top_mouse_move(event, target_handle) 
  538. 	-- Reset highlights 
  539. 	Menu_hint_bar:set_highlight(0) 
  540. 	 
  541. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  542. 	if hint_index ~= 0 then 
  543. 		Menu_hint_bar:set_highlight(hint_index) 
  544. 	end 
  545. 	 
  546. 	local new_index = List:get_button_index(target_handle) 
  547. 	if new_index ~= 0 then 
  548. 		-- Set the button as the new selected highlight 
  549. 		List:set_selection(new_index) 
  550. 		List:move_cursor(0, true) 
  551. 	end 
  552. end