./main_menu_top.lua

  1. --Globals... 
  2. Main_menu_press_start_peg = -1			--Peg to load language specific pess start button... 
  3. Main_menu_list_h = -1 
  4. Menu_newsticker = -1 
  5.  
  6. MAIN_MENU_MEGA_LIST_SIZE = 435 
  7. Main_menu_input_tracker = -1 
  8.  
  9. local Main_menu_mouse_input_tracker = -1 
  10. local Main_menu_returned_to_start = false 
  11. local Main_menu_top_doc = -1 
  12. local Main_menu_top = { } 
  13. local Online_check_thread = -1 
  14.  
  15. local Main_menu_buttons = {} 
  16. local Main_menu_idx = 1 
  17.  
  18. -- PC Menu has height adjusted 
  19. local PC_menu_adjusted = false 
  20.  
  21. MAIN_MENU_DIALOG_UPDATE_TIME = 1.0									--HVS_JRP[PRINCE] 3/20/2014 (PlayGo) Time between download progress text updates. 
  22. local Main_menu_dialog_update_timer = MAIN_MENU_DIALOG_UPDATE_TIME	--HVS_JRP[PRINCE] 3/20/2014 (PlayGo) Track the time since the last download progress check. 
  23. local main_menu_top_dowload_dialog_box = nil						--HVS_JRP[PRINCE] 3/20/2014 (PlayGo) Track the download information dialog box. 
  24.  
  25. function main_menu_top_init() 
  26. 	Main_menu_top_doc = vint_document_find("main_menu_top") 
  27.  
  28. 	--Load appropriate press start button... 
  29. 	local language = game_get_language() 
  30.  
  31. 	--Hide press start... 
  32. 	main_menu_top_press_start_hide() 
  33.  
  34. 	--Initialize Hint Bar store it to global Menu_hint_bar 
  35. 	Menu_hint_bar = Vdo_hint_bar:new("hint_bar", 0, Main_menu_common_doc_h) 
  36.  
  37. 		-- Subscribe to common inputs 
  38. 	Main_menu_input_tracker = Vdo_input_tracker:new() 
  39. 	Main_menu_input_tracker:add_input("map",		"main_menu_do_nothing",	50) 
  40. 	Main_menu_input_tracker:add_input("select", 	"main_menu_button_a",		50) 
  41. 	Main_menu_input_tracker:add_input("back", 	"main_menu_button_b",		50) 
  42. 	Main_menu_input_tracker:add_input("nav_up", 	"main_menu_nav_up", 			50) 
  43. 	Main_menu_input_tracker:add_input("nav_down", "main_menu_nav_down",		50) 
  44. 	Main_menu_input_tracker:subscribe(false) 
  45.  
  46. 	-- Add mouse inputs for the PC, don't subscribe until menu is created 
  47. 	if game_get_platform() == "PC" then 
  48. 		Main_menu_mouse_input_tracker = Vdo_input_tracker:new() 
  49. 		Main_menu_mouse_input_tracker:subscribe(false) 
  50. 	end 
  51.  
  52. 	--Setup button hints 
  53. 	--Menu_hint_bar:set_hints() 
  54. 	Menu_hint_bar:set_visible(false) 
  55.  
  56. 	main_menu_top_show_list(false) 
  57.  
  58. 	--Hide megalist 
  59. 	Main_menu_list_h = vint_object_find("list_grp", 0, Main_menu_top_doc) 
  60. 	vint_set_property(Main_menu_list_h, "visible", false) 
  61.  
  62. 	if game_get_platform() == "PC" then 
  63. 		vint_set_property(Main_menu_list_h, "scale", .92, .92) 
  64. 	else 
  65. 		vint_set_property(Main_menu_list_h, "scale", 1, 1) 
  66. 	end 
  67. 	 
  68. 	local newsticker_h = vint_object_find("newsticker") 
  69. 	vint_set_property(newsticker_h, "visible", false) 
  70.  
  71. 	vint_apply_start_values(Screen_in_anim.handle) 
  72.  
  73. 	if Main_menu_gameboot_complete == true then 
  74. 		--Game is already loaded, so we know we are coming from game, there is no loading or press start... 
  75.  
  76. 		--Skip load Screen... 
  77. 		main_menu_load_skip() 
  78.  
  79. 		--Skip press start... 
  80. 		main_menu_top_press_start_skip() 
  81.  
  82. 		--Show menu... 
  83. 		main_menu_top_menu_show() 
  84.  
  85. 		--Show MM logo... 
  86. 		main_menu_logo_show() 
  87.  
  88. 	else 
  89. 		-- Start load sequence... 
  90. 		main_menu_load_start() 
  91. 	end 
  92. 	main_menu_package_chunk_init() 
  93. end 
  94.  
  95.  
  96. function main_menu_top_reset() 
  97. 	-- Move the ticker down, and everything else up on PC 
  98. 	if game_get_platform() == "PC" then 
  99.  
  100. 		local screen_grp_h = vint_object_find("screen_grp", 0, Main_menu_common_doc_h) 
  101. 		local base_grp_h = vint_object_find("base_grp") 
  102. 		local x, y = vint_get_property(base_grp_h, "anchor") 
  103. 		if vint_is_std_res() then 
  104. 			vint_set_property(base_grp_h, "anchor", x, y - 30) 
  105. 		else 
  106. 			vint_set_property(base_grp_h, "anchor", x, y - 40) 
  107. 			vint_set_property(screen_grp_h, "anchor", 118, 0) 
  108. 		end 
  109.  
  110. 		x, y = Menu_newsticker:get_anchor() 
  111. 		if vint_is_std_res() then 
  112. 			Menu_newsticker:set_anchor(x, y + 40) 
  113. 		else 
  114. 			Menu_newsticker:set_anchor(x, y + 50) 
  115. 		end 
  116. 		 
  117. 		vint_set_property(Main_menu_list_h, "scale", .9, .9) 
  118. 		PC_menu_adjusted = true 
  119. 	end 
  120. end 
  121.  
  122. function main_menu_top_lost_focus() 
  123. 	main_menu_top_show_list(false) 
  124.  
  125. 	List:set_visible(true) 
  126. 	Header_obj:set_visible(true) 
  127.  
  128. 	main_menu_logo_hide() 
  129.  
  130. 	Main_menu_input_tracker:subscribe(false) 
  131. 	if Main_menu_mouse_input_tracker ~= -1 then 
  132. 		Main_menu_mouse_input_tracker:subscribe(false) 
  133. 	end 
  134. end 
  135.  
  136.  
  137. function main_menu_top_input_lock(locked) 
  138. 	if Online_validator_result ~= ONLINE_VALIDATOR_IN_PROGRESS then 
  139. 		Main_menu_input_tracker:subscribe(not locked) 
  140. 		if Main_menu_mouse_input_tracker ~= -1 then 
  141. 			Main_menu_mouse_input_tracker:subscribe(not locked) 
  142. 		end 
  143. 	end 
  144. end 
  145.  
  146.  
  147. function main_menu_top_gained_focus() 
  148. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  149. 	glitch_cell() 
  150. 	if( game_get_platform() == "PC" ) then 
  151.  
  152. 		main_menu_top_cleanup() 
  153. 		main_menu_top_init() 
  154.  
  155. 		bg_saints_set_type(BG_TYPE_VIDEO, true) 
  156. 		bg_saints_show(true) 
  157. 		main_menu_start_video(true) 
  158. 	else 
  159. 		List:set_visible(false) 
  160. 		Header_obj:set_visible(false) 
  161.  
  162. 		-- Hide hint bar hints 
  163. 		Menu_hint_bar:set_hints() 
  164.  
  165. 		bg_saints_set_type(BG_TYPE_VIDEO, true) 
  166. 		bg_saints_show(true) 
  167. 		main_menu_logo_show() 
  168.  
  169. 		if Main_menu_returned_to_start == true then 
  170. 			main_menu_top_show_list(false) 
  171.  
  172. 			main_menu_top_show_list(false) 
  173.  
  174. 			Menu_newsticker:set_visible(false) 
  175. 			return 
  176. 		else 
  177. 			main_menu_top_show_list(true) 
  178. 		end 
  179.  
  180. 		Main_menu_input_tracker:subscribe(true) 
  181. 		if Main_menu_mouse_input_tracker ~= -1 then 
  182. 			Main_menu_mouse_input_tracker:subscribe(true) 
  183. 		end 
  184.  
  185. 		if Enter_dlc_menu == true then 
  186. 			main_menu_top_dlc() 
  187. 			Enter_dlc_menu = false 
  188. 		end 
  189. 	end 
  190. 	 
  191. 	--Reset flag for silverlink menu. 
  192. 	In_silverlink_menu = false 
  193. 	main_menu_silverlink_logo_is_visible(false) 
  194. end 
  195.  
  196. function main_menu_top_cleanup() 
  197. 	if Main_menu_press_start_peg ~= -1 then 
  198. 		game_peg_unload(Main_menu_press_start_peg) 
  199. 	end 
  200.  
  201. 	if Online_check_thread ~= -1 then 
  202. 		thread_kill(Online_check_thread) 
  203. 	end 
  204.  
  205. 	Menu_hint_bar:cleanup() 
  206. end 
  207.  
  208. ------------------------------------------------------------------------------- 
  209. -- Initialize press start screen... 
  210. -- Setup controls, and show proper press start bitmap... 
  211. ------------------------------------------------------------------------------- 
  212. function main_menu_top_press_start_init() 
  213. 	--Start init... 
  214. end 
  215.  
  216. function main_menu_top_press_start_show() 
  217.  
  218. 	if Menu_hint_bar ~= -1 then 
  219. 		Menu_hint_bar:set_visible(false) 
  220. 	end 
  221.  
  222. 	--[[ 
  223. 	if Main_menu_list ~= -1 then 
  224.  
  225. 		--Clear any submenu stacks... 
  226. 		menu_common_stack_clear() 
  227.  
  228. 		Main_menu_returned_to_start = true 
  229. 		vint_set_property(Main_menu_list, "visible", false) 
  230. 	end 
  231. 	]] 
  232.  
  233. 	menu_common_stack_clear() 
  234. 	Main_menu_returned_to_start = true 
  235. 	vint_set_property(Main_menu_list_h, "visible", false) 
  236.  
  237. 	if Main_menu_input_tracker ~= -1 then 
  238. 		Main_menu_input_tracker:subscribe(false) 
  239. 	end 
  240.  
  241. 	if Main_menu_mouse_input_tracker ~= -1 then 
  242. 		Main_menu_mouse_input_tracker:subscribe(false) 
  243. 	end 
  244.  
  245. 	local press_start_pulse_h = vint_object_find("press_start_pulse", 0, Main_menu_top_doc) 
  246. 	lua_play_anim(press_start_pulse_h, 0, Main_menu_top_doc) 
  247.  
  248. 	--Show start group stuff... 
  249. 	local h = vint_object_find("press_start_grp", 0, Main_menu_top_doc) 
  250. 	vint_set_property(h, "visible", true) 
  251. 	vint_set_property(h, "alpha", 0) 
  252.  
  253. 	local anim_h = vint_object_find("intro_press_start_anim", 0, Main_menu_top_doc) 
  254. 	lua_play_anim(anim_h, 0, Main_menu_top_doc) 
  255.  
  256. 	local screen_grp_h = vint_object_find("screen_grp", 0, Main_menu_common_doc_h) 
  257. 	vint_set_property(screen_grp_h, "anchor", -1000, 0) 
  258. 	 
  259. 	main_menu_silverlink_logo_is_visible(false) 
  260. end 
  261.  
  262.  
  263. function main_menu_top_press_start_hide() 
  264. 	--Show start group stuff... 
  265. 	local h = vint_object_find("press_start_grp") 
  266. 	vint_set_property(h, "visible", false) 
  267. end 
  268.  
  269.  
  270. -- Turns off press start... 
  271. function main_menu_top_press_start_skip() 
  272. 	--Show start group stuff... 
  273. 	local h = vint_object_find("press_start_grp") 
  274. 	vint_set_property(h, "visible", false) 
  275. end 
  276.  
  277.  
  278. function main_menu_create_top_menu() 
  279. 	bg_saints_show(true) 
  280.  
  281. 	Main_menu_top = { } 
  282. 	Main_menu_buttons = { } 
  283.  
  284. 	if game_is_demo() then 
  285. 		Main_menu_top[#Main_menu_top + 1] = Campaign_button 
  286. 		if game_get_platform() == "PC" then 
  287. 			-- Main_menu_top[#Main_menu_top + 1] = Machinima_button 
  288. 			Main_menu_top[#Main_menu_top + 1] = Mm_quit_game 
  289. 		end 
  290. 	else 
  291. 		if Show_continue then 
  292. 			Main_menu_top[#Main_menu_top + 1] = Continue_button 
  293. 		end 
  294.  
  295. 		Main_menu_top[#Main_menu_top + 1] = Campaign_button 
  296. 		Main_menu_top[#Main_menu_top + 1] = Coop_button 
  297. 	--	Main_menu_top[#Main_menu_top + 1] = DLC_button	-- HVS_JRP[PRINCE] 4/8/2014 DLC is included. 
  298. 	 
  299. 		-- No Community options for SRGAT 
  300. 		--if game_get_platform() ~= "PS3" then 
  301. 			--Main_menu_top[#Main_menu_top + 1] = Community_button 
  302. 		--end 
  303.  
  304. 		--Add this back in once we submit 
  305. 		if (silverlink_is_enabled()) then 
  306. 			Main_menu_top[#Main_menu_top + 1] = Silverlink_button 
  307. 		end 
  308. 	 
  309. 		if game_get_platform() == "PC" then 
  310. 			Main_menu_top[#Main_menu_top + 1] = Options_button 
  311. 		end 
  312.  
  313. 		Main_menu_top[#Main_menu_top + 1] = Extras_button 
  314.  
  315. 		if game_get_platform() == "PC" then 
  316. 			-- Main_menu_top[#Main_menu_top + 1] = Machinima_button 
  317. 			Main_menu_top[#Main_menu_top + 1] = Mm_quit_game 
  318. 		end 
  319.  
  320. 		if game_get_platform() == "XBOX3" then --HVS_BT 8/18/2014 - adding account picker for xbox3 
  321. 			local string = main_menu_get_gamer_tag() 
  322. 			Account_picker.label = string 
  323. 			Main_menu_top[#Main_menu_top + 1] = Account_picker 
  324. 		end 
  325.  
  326. 	end 
  327.  
  328. 	--Create the main menu list 
  329. 	main_menu_top_list_draw_items(Main_menu_top) 
  330. end 
  331.  
  332. --Show menu... 
  333. function main_menu_top_menu_show(show_continue) 
  334.  
  335. 	if show_continue then 
  336. 		Show_continue = true 
  337. 	end 
  338.  
  339. 	Menu_hint_bar:set_hints() 
  340. 	Menu_hint_bar:set_visible(true) 
  341.  
  342. 	Main_menu_returned_to_start = false 
  343.  
  344. 	-- Check for money shot unlocks after Press Start. 
  345. 	main_menu_money_shot_check() 
  346.  
  347. 	main_menu_create_top_menu() 
  348.  
  349. 	--Disabling Newsticker for demo... 
  350. 	if not game_is_demo() then 
  351. 		if Menu_newsticker == -1 then 
  352. 			Menu_newsticker = Vdo_newsticker:new("newsticker", 0, 0, "main_menu_top.lua", "Menu_newsticker") 
  353. 		end 
  354.  
  355. 		Menu_newsticker:set_visible(true) 
  356.  
  357. 		-- Move the ticker down, and everything else up on PC 
  358.  
  359. 		if game_get_platform() == "PC" and PC_menu_adjusted == false then 
  360. 			local main_menu_list_h = vint_object_find("main_menu_list") 
  361. 			vint_set_property(main_menu_list_h, "scale", 0.9, 0.9) 
  362.  
  363. 			local base_grp_h = vint_object_find("base_grp") 
  364. 			local x, y = vint_get_property(base_grp_h, "anchor") 
  365. 			if vint_is_std_res() then 
  366. 				vint_set_property(base_grp_h, "anchor", x, y - 30) 
  367. 			else 
  368. 				vint_set_property(base_grp_h, "anchor", x, y - 40) 
  369. 			end 
  370.  
  371. 			x, y = Menu_newsticker:get_anchor() 
  372. 			if vint_is_std_res() then 
  373. 				Menu_newsticker:set_anchor(x, y + 40) 
  374. 			else 
  375. 				Menu_newsticker:set_anchor(x, y + 50) 
  376. 			end 
  377. 			PC_menu_adjusted = true 
  378. 		end 
  379.  
  380. 	end 
  381.  
  382. 	-- Subscribe to inputs 
  383. 	Main_menu_input_tracker:subscribe(true) 
  384.  
  385. 	-- Add mouse inputs for the PC 
  386. 	if game_get_platform() == "PC" then 
  387. 		Main_menu_mouse_input_tracker:subscribe(true) 
  388. 	end 
  389. 	 
  390. 	bg_saints_set_type(BG_TYPE_VIDEO,true) 
  391. end 
  392.  
  393.  
  394. -- show main menu 
  395. function main_menu_start() 
  396. -- legacy shit... 
  397. --	pause_save_get_global_info(false)	-- this can block across frames 
  398. --	pause_save_get_global_info(get_device) 
  399.  
  400. 	-- Show main menu on screen... 
  401. end 
  402.  
  403.  
  404. function main_menu_do_nothing() 
  405. end 
  406.  
  407.  
  408. function main_menu_top_clear_list_objects( grp_h ) 
  409. 	local child_list = { } 
  410.  
  411. 	-- build a list of all children before we start destroying 
  412. 	-- don't add the base button, we need that 
  413. 	local h = vint_object_first_child( grp_h ) 
  414. 	local base_button = vint_object_find( "btn_grp", grp_h ) 
  415. 	local highlight_grp = vint_object_find( "highlight_grp", grp_h ) 
  416.  
  417. 	while h ~= nil do 
  418. 		if h ~= base_button and h ~= highlight_grp --[[and h ~= mask]] then 
  419. 			child_list[ h ] = true 
  420. 		end 
  421.  
  422. 		h = vint_object_next_sibling(h) 
  423. 	end 
  424.  
  425. 	-- kill em all! 
  426. 	for k, v in pairs( child_list ) do 
  427. 		vint_object_destroy( k ) 
  428. 	end 
  429. end 
  430.  
  431.  
  432. function main_menu_top_list_draw_items(data) 
  433. 	local base_btn_h = vint_object_find("btn_grp", Main_menu_list_h, Main_menu_top_doc) 
  434.  
  435. 	local base_btn_x, base_btn_y = vint_get_property(base_btn_h, "anchor") 
  436. 	local BTN_Y_OFFSET = 42 
  437.  
  438. 	--Clear any buttons in old list... 
  439. 	main_menu_top_clear_list_objects( Main_menu_list_h ) 
  440.  
  441. 	if game_get_platform() == "PC" then 
  442. 		--Clear all mouse inputs 
  443. 		Main_menu_mouse_input_tracker:remove_all() 
  444. 	end 
  445.  
  446. 	--Clone new buttons and add mouse inputs. 
  447. 	for i = 1, #data do 
  448. 		local btn_h = vint_object_clone(base_btn_h) 
  449. 		local btn_txt_h = vint_object_find("btn_txt", btn_h, Main_menu_top_doc) 
  450. 		local btn_bg_img_h = vint_object_find("btn_bg_img", btn_h, Main_menu_top_doc) 
  451.  
  452. 		vint_set_property(btn_h, "anchor", base_btn_x, BTN_Y_OFFSET * i - 1) 
  453. 		vint_set_property(btn_txt_h, "text_tag", data[i].label) 
  454.  
  455. 		--Save handles for later 
  456. 		Main_menu_buttons[i] = { 
  457. 			btn_h = btn_h, 
  458. 			btn_txt_h = btn_txt_h, 
  459. 			btn_bg_img_h = btn_bg_img_h, 
  460. 		} 
  461.  
  462. 		if game_get_platform() == "PC" then 
  463. 			--Add new mouse inputs... 
  464. 			Main_menu_mouse_input_tracker:add_mouse_input("mouse_move", "main_menu_mouse_move", 100, btn_bg_img_h) 
  465. 			Main_menu_mouse_input_tracker:add_mouse_input("mouse_click", "main_menu_mouse_click", 100, btn_bg_img_h) 
  466. 		end 
  467. 	end 
  468.  
  469. 	if game_get_platform() == "PC" then 
  470. 		--Subscribe new Mouse inputs 
  471. 		Main_menu_mouse_input_tracker:subscribe(true) 
  472. 	end 
  473.  
  474. 	vint_set_property(base_btn_h, "visible", false) 
  475. 	vint_set_property(Main_menu_list_h, "visible", true) 
  476.  
  477. 	--reset all buttons to off state 
  478. 	for i = 1, #Main_menu_buttons do 
  479. 		local btn_h = Main_menu_buttons[i].btn_h 
  480. 		local txt_h = vint_object_find("btn_txt", btn_h, Main_menu_top_doc) 
  481. 		local bg_h = vint_object_find("btn_bg_img", btn_h, Main_menu_top_doc) 
  482. 		vint_set_property(bg_h, "visible", true) 
  483. 		vint_set_property(txt_h, "tint", 167/255, 167/255, 167/255) 
  484. 	end 
  485.  
  486. 	--Update the highlight and set it at 1 
  487. 	Main_menu_idx = 1 
  488. 	main_menu_top_list_move_cursor(0) 
  489. end 
  490.  
  491.  
  492. function main_menu_top_list_move_cursor(direction) 
  493.  
  494. 	--Move up or down from where we are currently 
  495. 	local idx = Main_menu_idx + direction 
  496.  
  497. 	--Wrap if we need to 
  498. 	if idx > #Main_menu_buttons then 
  499. 		idx = 1 
  500. 	elseif idx < 1 then 
  501. 		idx = #Main_menu_buttons 
  502. 	end 
  503.  
  504. 	--Highlight new index, reset old button 
  505. 	--This is a separate function for mouse inputs 
  506. 	main_menu_top_list_set_selection(idx) 
  507.  
  508. 	--Store off new index 
  509. 	Main_menu_idx = idx 
  510. end 
  511.  
  512.  
  513. --Highlight new index, reset old button 
  514. function main_menu_top_list_set_selection(idx) 
  515. 	local current_btn_h = Main_menu_buttons[idx].btn_h 
  516. 	local current_txt_h = vint_object_find("btn_txt", current_btn_h, Main_menu_top_doc) 
  517. 	local current_bg_h = vint_object_find("btn_bg_img", current_btn_h, Main_menu_top_doc) 
  518.  
  519. 	local old_btn_h = Main_menu_buttons[Main_menu_idx].btn_h 
  520. 	local old_txt_h = vint_object_find("btn_txt", old_btn_h, Main_menu_top_doc) 
  521. 	local old_bg_h = vint_object_find("btn_bg_img", old_btn_h, Main_menu_top_doc) 
  522.  
  523.  
  524.  
  525. 	--hide the dark bg for highlighted item, show others for unhighlighted 
  526. 	vint_set_property(old_bg_h, "visible", true) 
  527. 	vint_set_property(old_txt_h, "tint", 167/255, 167/255, 167/255) 
  528.  
  529. 	vint_set_property(current_bg_h, "visible", false) 
  530. 	vint_set_property(current_txt_h, "tint", 0, 0, 0) 
  531.  
  532. 	local highlight_grp_h = vint_object_find("highlight_grp", 0, Main_menu_top_doc) 
  533. 	local highlight_x, new_y = vint_get_property(current_btn_h, "anchor") 
  534. 	vint_set_property(highlight_grp_h, "anchor", highlight_x, new_y) 
  535. end 
  536.  
  537.  
  538. --Set the visibility of the main menu list 
  539. function main_menu_top_show_list(is_visible) 
  540. 	vint_set_property(Main_menu_list_h, "visible", is_visible) 
  541. end 
  542.  
  543. ------------------------------------------------------------------------------- 
  544. -- PlayGo / QuickStart Functions... 
  545. ------------------------------------------------------------------------------- 
  546. function main_menu_package_chunk_init()	--HVS_JRP[PRINCE] 3/25/2014 
  547. 	-- Generate a list of all the package IDs we care about. 
  548. 	local all_package_chunk_ids = { } 
  549. 	for i = 1, #Main_menu_top do 
  550. 		local menu_button = Main_menu_top[i] 
  551. 		local package_chunk_ids = menu_button.package_chunk_ids 
  552. 		if package_chunk_ids ~= nil then 
  553. 			for j = 1, #package_chunk_ids do 
  554. 				local new_id 
  555. 				local bFound = false 
  556. 				for k = 1, #all_package_chunk_ids do 
  557. 					if new_id == all_package_chunk_ids[k] then 
  558. 						bFound = true 
  559. 						break 
  560. 					end 
  561. 				end 
  562. 				if not bFound then 
  563. 					all_package_chunk_ids[#all_package_chunk_ids + 1] = new_id 
  564. 				end 
  565. 			end 
  566. 		end 
  567. 	end 
  568.  
  569. 	if (all_package_chunk_ids == nil) or (#all_package_chunk_ids <= 0) then 
  570. 		return 
  571. 	end 
  572. 	 
  573. 	-- Start tracking information for these package chunks. 
  574. 	-- If the game is already fully downloaded, hopefully we will have that information before the user attempts to access a button that would otherwise pop up a progress dialog. 
  575. 	for i = 1, #all_package_chunk_ids do 
  576. 		package_chunk_tracking_add(all_package_chunk_ids[i]) 
  577. 	end 
  578. 	package_chunk_tracking_start() 
  579. end 
  580.  
  581.  
  582. function main_menu_is_button_available(menu_button)	--HVS_JRP[PRINCE] 3/20/2014 Determine if we have downloaded all of the package chunks this button depends on. 
  583. 	local package_chunk_movies = 1 
  584. 	if game_get_platform() == "XBOX3" then 
  585. 		package_chunk_movies = 2 
  586. 	end 
  587.  
  588. 	-- HVS_EC  don't allow co-op until full game is installed. 
  589. 	if menu_button == Coop_button then 
  590. 		if not package_chunk_loaded(package_chunk_movies) then 
  591. 			return false 
  592. 		end 
  593. 	end 
  594. 	return true 
  595.  
  596. 	-- HVS_EC  Don't bother executing any of this for King... 
  597. 	--local package_chunk_ids = menu_button.package_chunk_ids 
  598. 	--if (package_chunk_ids == nil) or (#package_chunk_ids <= 0) then 
  599. 	--	return true	--Not dependent on a package chunk. 
  600. 	--end 
  601. 	--for i = 1, #package_chunk_ids do 
  602. 	--	if not package_chunk_loaded(package_chunk_ids[i]) then 
  603. 	--		return false 
  604. 	--	end 
  605. 	--end 
  606. 	--return true 
  607. end 
  608.  
  609.  
  610. function main_menu_attempt_button(menu_button)	--HVS_JRP[PRINCE] 3/20/2014 If we haven't finished downloading, display a progress dialog. 
  611. 	if main_menu_is_button_available(menu_button) then 
  612. 		return true 
  613. 	end 
  614.  
  615. 	-- HVS_EC  We already set up the tracking list when we started the game.  This is redundant. 
  616. 	-- Start tracking information for the package chunks associated with this button. 
  617. 	--local package_chunk_ids = menu_button.package_chunk_ids 
  618. 	--for i = 1, #package_chunk_ids do 
  619. 	--	package_chunk_tracking_add(package_chunk_ids[i]) 
  620. 	--end 
  621. 	--package_chunk_tracking_start() 
  622.  
  623. 	-- Open the download dialog. 
  624. 	local options = { [0] = "CONTROL_CONTINUE" } 
  625. 	main_menu_top_dowload_dialog_box = dialog_box_open("GAME_INSTALL_INCOMPLETE_TITLE", "GAME_INSTALL_INCOMPLETE_LOAD", options, "main_menu_download_dialog_callback", 0, DIALOG_PRIORITY_ACTION, false, false, false, false, false, 0) 
  626. 	main_menu_update_download_dialog() 
  627. 	Main_menu_dialog_update_timer = MAIN_MENU_DIALOG_UPDATE_TIME 
  628. 	return false 
  629. end 
  630.  
  631.  
  632. function main_menu_download_dialog_callback()	--HVS_JRP[PRINCE] 3/20/2014 Clear reference to the dialog box, so we don't try to access it. 
  633. 	main_menu_top_dowload_dialog_box = nil 
  634. end 
  635.  
  636.  
  637. function main_menu_top_process(time_diff)	--HVS_JRP[PRINCE] 3/17/2014 Periodically update the download dialog box progress. 
  638. 	if main_menu_top_dowload_dialog_box then 
  639. 		Main_menu_dialog_update_timer = Main_menu_dialog_update_timer - time_diff 
  640. 		if Main_menu_dialog_update_timer <= 0.0 then 
  641. 			Main_menu_dialog_update_timer = Main_menu_dialog_update_timer + MAIN_MENU_DIALOG_UPDATE_TIME 
  642. 			package_chunk_tracking_update() 
  643. 			main_menu_update_download_dialog() 
  644. 		end 
  645. 	end 
  646. end 
  647.  
  648.  
  649. function main_menu_update_download_dialog()	--HVS_JRP[PRINCE] 3/20/2014 Update the body text of the download progress dialog. 
  650. 	-- HVS_EC  Enable this function once we figure out how to fix the percentages/times being wrong. 
  651. 	if true then 
  652. 		return 
  653. 	end 
  654.  
  655. 	if not main_menu_top_dowload_dialog_box then 
  656. 		return 
  657. 	end 
  658.  
  659. 	local menu_button = Main_menu_top[Main_menu_idx] 
  660.  
  661. 	--Check if it's done downloading. 
  662. 	if main_menu_is_button_available(menu_button) then 
  663. 		ui_audio_post_event("clothing_purchase") 
  664. 		dialog_box_force_close(main_menu_top_dowload_dialog_box) 
  665. 		return 
  666. 	end 
  667.  
  668. 	--Update the body text. 
  669. 	local platform = game_get_platform() 
  670. 	local body_text = "" 
  671. 	local progress = floor(100 * package_chunk_tracking_progress()) 
  672. 	if platform == "PS4" then 
  673. 		-- Determine the total download remaining. 
  674. 		local chunk_size_MB = floor(package_chunk_tracking_size() / 1024 / 1024) 
  675. 		local chunk_size_loaded_MB = floor(package_chunk_tracking_size_loaded() / 1024 / 1024) 
  676. 		local chunk_eta = package_chunk_tracking_eta() 
  677. 		local eta_text = format_time(chunk_eta, false, false, false, true) 
  678. 		body_text = progress.."%%\n"..chunk_size_loaded_MB.." MB / "..chunk_size_MB.." MB\n"..get_localized_string_for_tag("STREAMING_INSTALL_TIME")..": "..eta_text 
  679. 	elseif platform == "XBOX3" then 
  680. 		body_text = progress.."%%" 
  681. 	end 
  682. 	dialog_box_set_body(main_menu_top_dowload_dialog_box, body_text) 
  683. end 
  684.  
  685. ------------------------------------------------------------------------------- 
  686. -- Navigation Functions... 
  687. ------------------------------------------------------------------------------- 
  688. function main_menu_nav_up() 
  689. 	-- Move highlight up 
  690. 	--Main_menu_list:move_cursor(-1) 
  691. 	game_UI_audio_play("UI_MAIN_MENU_NAV_UP") 
  692. 	main_menu_top_list_move_cursor(-1) 
  693. end 
  694.  
  695.  
  696. function main_menu_nav_down() 
  697. 	-- Move highlight down 
  698. 	--Main_menu_list:move_cursor(1) 
  699. 	game_UI_audio_play("UI_MAIN_MENU_NAV_DOWN") 
  700. 	main_menu_top_list_move_cursor(1) 
  701. end 
  702.  
  703.  
  704. function main_menu_button_b() 
  705. 	if game_get_platform() == "PC" then 
  706. 		main_menu_initiate_quit_game() 
  707. 	end 
  708. 	--Nav the screen back... 
  709. end 
  710.  
  711.  
  712. function main_menu_button_a() 
  713. 	--Nav the screen forward... 
  714.  
  715. 	--Set the screen data to the list data 
  716. 	--local data = Main_menu_list:return_data() 
  717. 	local current_selection = Main_menu_idx --Main_menu_list:get_selection() 
  718. 	if current_selection == -1 then 
  719. 		return 
  720. 	end 
  721.  
  722. 	--Clear any sub menu stacks... 
  723. 	menu_common_stack_clear() 
  724.  
  725. 	--pass off the input to the list 
  726. 	--Main_menu_list:button_a() 
  727.  
  728. 	Main_menu_top[Main_menu_idx].on_select(Main_menu_top) 
  729. end 
  730.  
  731.  
  732. function main_menu_mouse_click(event, target_handle) 
  733. 	for i =1, #Main_menu_buttons do 
  734. 		if target_handle == Main_menu_buttons[i].btn_bg_img_h then 
  735. 			main_menu_button_a() 
  736. 		end 
  737. 	end 
  738. end 
  739.  
  740.  
  741. function main_menu_mouse_move(event, target_handle) 
  742. 	for i =1, #Main_menu_buttons do 
  743. 		if target_handle == Main_menu_buttons[i].btn_bg_img_h then 
  744.  
  745. 			--Directly set selection then update list index after 
  746. 			main_menu_top_list_set_selection(i) 
  747. 			game_UI_audio_play("UI_MAIN_MENU_NAV_DOWN") 
  748. 			Main_menu_idx = i 
  749. 		end 
  750. 	end 
  751. end 
  752.  
  753.  
  754. -- Continue button 
  755. function main_menu_top_continue() 
  756. 	if not main_menu_attempt_button(Continue_button) then	--HVS_JRP[PRINCE] 3/20/2014 (PlayGo) 
  757. 		return 
  758. 	end 
  759. 	main_menu_continue() 
  760. end 
  761.  
  762.  
  763. -- Campaign menu 
  764. function main_menu_top_campaign() 
  765. 	if not main_menu_attempt_button(Campaign_button) then	--HVS_JRP[PRINCE] 3/20/2014 (PlayGo) 
  766. 		return 
  767. 	end 
  768. 	--Do Campaign Game 
  769. 	push_screen("main_menu_campaign") 
  770. end 
  771.  
  772.  
  773. function mm_top_redeem_check() 
  774. 	main_menu_supress_profile_change(true) 
  775.  
  776. 	Main_menu_input_tracker:subscribe(false) 
  777. 	if game_get_platform() == "PC" then 
  778. 		Main_menu_mouse_input_tracker:subscribe(false) 
  779. 	end 
  780.  
  781. 	online_and_privilege_validator_begin(true, true, true, false, false) 
  782. 	while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do 
  783. 		thread_yield() 
  784. 	end 
  785.  
  786. 	Main_menu_input_tracker:subscribe(true) 
  787. 	if game_get_platform() == "PC" then 
  788. 		Main_menu_mouse_input_tracker:subscribe(true) 
  789. 	end 
  790.  
  791. 	main_menu_supress_profile_change(false) 
  792.  
  793. 	main_menu_top_input_lock(false) 
  794. 	if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then 
  795. 		return 
  796. 	end 
  797.  
  798. 	main_menu_redeem_code() 
  799. 	Online_check_thread = -1 
  800. end 
  801.  
  802.  
  803. function mm_top_coop_dlg_cb(result, action) 
  804. 	if game_get_platform() == "PC" then 
  805. 		if result == 0 then 
  806. 			main_menu_top_dlc() 
  807. 		end 
  808. 	else 
  809. 		if result == 0 then 
  810. 			Online_check_thread = thread_new("mm_top_redeem_check") 
  811. 		elseif result == 1 then 
  812. 			main_menu_top_dlc() 
  813. 		end 
  814. 	end 
  815. end 
  816.  
  817.  
  818. function main_menu_top_coop_dlc_checked(has_coop, cancelled) 
  819. 	if has_coop then 
  820. 		--Do coop Coop 
  821. 		push_screen("main_menu_coop_top") 
  822. 	elseif not cancelled then 
  823. 		local options 
  824. 		local back_option = 1 
  825. 		if game_get_platform() == "PC" then 
  826. 			options = { [0] = "GO_DLC_STORE", [1] = "CONTROL_CANCEL" } 
  827. 		else 
  828. 			options = { [0] = "REDEEM_CODE", [1] = "GO_DLC_STORE", [2] = "CONTROL_CANCEL" } 
  829. 			back_option = 2 
  830. 		end 
  831. 		dialog_box_open("DIALOG_COOP_DLC_TITLE", "DLC_COOP_DLC_MAIN_BODY", options, "mm_top_coop_dlg_cb", 
  832. 								0, DIALOG_PRIORITY_ACTION, false, nil, false, false, false, back_option) 
  833.  
  834. 	end 
  835. end 
  836.  
  837.  
  838. function main_menu_top_check_coop() 
  839. 	main_menu_top_input_lock(false) 
  840.  
  841. 	game_check_coop_dlc("main_menu_top_coop_dlc_checked") 
  842. 	Online_check_thread = -1 
  843. end 
  844.  
  845.  
  846. function main_menu_top_coop() 
  847. 	if not main_menu_attempt_button(Coop_button) then	--HVS_JRP[PRINCE] 3/20/2014 (PlayGo) 
  848. 		return 
  849. 	end 
  850. 	main_menu_top_input_lock(true) 
  851.  
  852. 	Online_check_thread = thread_new("main_menu_top_check_coop") 
  853. end 
  854.  
  855.  
  856. function mm_check_dlc() 
  857. 	-- If there's a previous check, let it finish 
  858. 	while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do 
  859. 		thread_yield() 
  860. 	end 
  861.  
  862. 	Main_menu_input_tracker:subscribe(false) 
  863. 	if game_get_platform() == "PC" then 
  864. 		Main_menu_mouse_input_tracker:subscribe(false) 
  865. 	end 
  866.  
  867. 	online_and_privilege_validator_begin(true, true, false, false, false) 
  868. 	while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do 
  869. 		thread_yield() 
  870. 	end 
  871.  
  872. 	Main_menu_input_tracker:subscribe(true) 
  873. 	if game_get_platform() == "PC" then 
  874. 		Main_menu_mouse_input_tracker:subscribe(true) 
  875. 	end 
  876.  
  877. 	main_menu_top_input_lock(false) 
  878. 	if Online_validator_result == ONLINE_VALIDATOR_PASSED then 
  879. 		push_screen("store_dlc") 
  880. 	end 
  881.  
  882. 	Online_check_thread = -1 
  883. end 
  884.  
  885.  
  886. function main_menu_top_dlc() 
  887. 	if game_get_platform() == "PC" then 
  888. 		game_steam_open_dlc_page_overlay() 
  889. 		return 
  890. 	end 
  891.  
  892. 	main_menu_top_input_lock(true) 
  893. 	Online_check_thread = thread_new("mm_check_dlc") 
  894. end 
  895.  
  896.  
  897. function mm_community_check() 
  898.  
  899. 	Main_menu_input_tracker:subscribe(false) 
  900. 	if game_get_platform() == "PC" then 
  901. 		Main_menu_mouse_input_tracker:subscribe(false) 
  902. 	end 
  903.  
  904. 	online_and_privilege_validator_begin(true, true, true, false, false) 
  905. 	while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do 
  906. 		thread_yield() 
  907. 	end 
  908.  
  909. 	Main_menu_input_tracker:subscribe(true) 
  910. 	if game_get_platform() == "PC" then 
  911. 		Main_menu_mouse_input_tracker:subscribe(true) 
  912. 	end 
  913.  
  914. 	if Online_validator_result == ONLINE_VALIDATOR_PASSED then 
  915. 		 
  916. 		if (game_get_platform() == "XBOX360") or (game_get_platform() == "XBOX3") then 
  917. 			if main_menu_xbox_get_age_group() ~= "adult" then 
  918. 				dialog_box_message( "MENU_TITLE_NOTICE", "PLATFORM_XBOX_COMMUNITY_AGE_RESTRICTED" ) 
  919. 				return 
  920. 			end 
  921. 		end 
  922. 	 
  923. 		if main_menu_check_user_content() == false or main_menu_check_social_privilege() == false then 
  924. 			dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED") 
  925. 		else 
  926. 			community_login_open() 
  927. 		end 
  928. 	end 
  929.  
  930. 	Online_check_thread = -1 
  931. end 
  932.  
  933. function mm_silverlink_check() 
  934.  
  935. 	Main_menu_input_tracker:subscribe(false) 
  936. 	if game_get_platform() == "PC" then 
  937. 		Main_menu_mouse_input_tracker:subscribe(false) 
  938. 	end 
  939.  
  940. 	online_and_privilege_validator_begin(true, true, true, false, false) 
  941. 	while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do 
  942. 		thread_yield() 
  943. 	end 
  944.  
  945. 	Main_menu_input_tracker:subscribe(true) 
  946. 	if game_get_platform() == "PC" then 
  947. 		Main_menu_mouse_input_tracker:subscribe(true) 
  948. 	end 
  949.  
  950. 	if Online_validator_result == ONLINE_VALIDATOR_PASSED then 
  951. 		if main_menu_check_user_content() == false or main_menu_check_social_privilege() == false then 
  952. 			dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED") 
  953. 		else 
  954. 			push_screen("main_menu_silverlink") 
  955. 			--silverlink_login_open() 
  956. 		end 
  957. 	end 
  958.  
  959. 	Online_check_thread = -1 
  960. end 
  961.  
  962. function main_menu_top_community() 
  963. 	Online_check_thread = thread_new("mm_community_check") 
  964. end 
  965.  
  966. function main_menu_top_silverlink() 
  967. 	Online_check_thread = thread_new("mm_silverlink_check") 
  968. end 
  969.  
  970. function main_menu_top_options() 
  971. 	--Top Options 
  972. 	push_screen("pause_options_menu") 
  973. end 
  974.  
  975.  
  976. function main_menu_top_extras() 
  977. 	--Top Extras 
  978. 	push_screen("main_menu_extras") 
  979. end 
  980.  
  981.  
  982. function main_menu_top_machinima() 
  983. 	-- This should bring up cinema_clip_manager, or show a dialog box saying that there are no clips to edit 
  984. 	push_screen("pause_options_clip_select") 
  985. end 
  986.  
  987.  
  988. function main_menu_initiate_quit_game() 
  989. 	dialog_box_destructive_confirmation("PLT_QUIT_GAME", "PLT_QUIT_GAME_WARNING", "main_menu_top_confirm_quit") 
  990. end 
  991.  
  992.  
  993. function main_menu_top_confirm_quit(return_value) 
  994. 	if return_value == 0 then -- YES 
  995. 		game_request_game_terminate() 
  996. 	end 
  997. end 
  998.  
  999. function main_menu_top_account_picker() --HVS_BT 8/18/2014 
  1000. 	main_menu_account_picker() 
  1001. end 
  1002.  
  1003. ------------------------------------------------------------------------------- 
  1004. -- Main Menu BMS Loaded 
  1005. ------------------------------------------------------------------------------- 
  1006. function main_menu_top_bmp_loaded() 
  1007. 	--This is for the press start image... 
  1008. 	--It is a null function callback... 
  1009. end 
  1010.  
  1011.  
  1012. ------------------------------------------------------------------------------- 
  1013. -- Temp function to remove the demo disabling..stuff... 
  1014. -- use the console to access... "vint_lua main_menu_top mm_coop" 
  1015. ------------------------------------------------------------------------------- 
  1016. function mm_coop() 
  1017. 	for i, v in pairs(Main_menu_top) do 
  1018. 		v.disabled = nil 
  1019. 	end 
  1020. 	-- Create megalist... 
  1021. 	--Main_menu_list:draw_items(Main_menu_top, 1, MAIN_MENU_MEGA_LIST_SIZE, "center") 
  1022. --	Main_menu_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY) 
  1023. end 
  1024.  
  1025.  
  1026. Continue_button		= { label = "MAINMENU_CONTINUE",			type = TYPE_BUTTON,	on_select = main_menu_top_continue,			package_chunk_ids = nil					} -- HVS_EC King doesn't use these... 
  1027. Campaign_button 	= { label = "MAINMENU_CAMPAIGN",			type = TYPE_BUTTON,	on_select = main_menu_top_campaign,			package_chunk_ids = nil					} 
  1028. Coop_button 		= { label = "MAINMENU_COOP_OPTION", 		type = TYPE_BUTTON,	on_select = main_menu_top_coop,				package_chunk_ids = nil					} 
  1029. DLC_button			= { label = "MAINMENU_DLC",					type = TYPE_BUTTON,	on_select = main_menu_top_dlc,				package_chunk_ids = nil					} 
  1030. Community_button	= { label = "MAINMENU_COMMUNITY", 			type = TYPE_BUTTON,	on_select = main_menu_top_community,		package_chunk_ids = nil					} 
  1031. Silverlink_button	= { label = "SILVERLINK", 					type = TYPE_BUTTON,	on_select = main_menu_top_silverlink,		package_chunk_ids = nil					} 
  1032. Options_button		= { label = "MAINMENU_OPTIONS",				type = TYPE_BUTTON,	on_select = main_menu_top_options,			package_chunk_ids = nil					} 
  1033. Extras_button		= { label = "MAINMENU_EXTRAS", 				type = TYPE_BUTTON,	on_select = main_menu_top_extras,			package_chunk_ids = nil					} 
  1034. Machinima_button	= { label = "MAINMENU_MACHINIMA_MODE",		type = TYPE_BUTTON,	on_select = main_menu_top_machinima,		package_chunk_ids = nil					} 
  1035. Mm_quit_game 		= { label = "PLT_QUIT_GAME",				type = TYPE_BUTTON,	on_select = main_menu_initiate_quit_game,	package_chunk_ids = nil					} 
  1036. Account_picker		= { label = "MAIN_MENU_ACCOUNT_PICKER",		type = TYPE_BUTTON, on_select = main_menu_top_account_picker,	package_chunk_ids = nil					} --HVS_BT 8/18/2014 - adding account picker for xbox one