./pause_invite_friends.lua

  1. local Data = {} 
  2.  
  3. local Anims = {} 
  4.  
  5. local Input_tracker 
  6. local Mouse_input_tracker 
  7. local Hint_bar_input_tracker = nil 
  8. local Hint_y_index = -1 
  9. local Hint_x_index = -1 
  10.  
  11. local List_width 
  12. if vint_is_std_res() then 
  13. 	List_width = 750 
  14. else 
  15. 	List_width = 840 
  16. end 
  17.  
  18. local MIN_SCROLL_ITEMS = 12 
  19. local HINT_BAR_OFFSET = 21 
  20.  
  21. local Tween_done = true 
  22. local Started_syslink_search = false 
  23. local SYSLINK_UPDATE_DELAY = 3 
  24. local Search_thread = -1 
  25. local Num_friends = 0 
  26.  
  27. local Party_invite = false 
  28. local Party_show = false 
  29.  
  30. local Invite_friends_error = 0 
  31. local Network_check_thread = -1 
  32.  
  33. local SEARCHING_OPTION = { 
  34. 	type = TYPE_BUTTON, 
  35. 	label = "MENU_SEARCHING", 
  36. 	id = -1, 
  37. 	disabled = true 
  38. } 
  39.  
  40. local NO_GAMES_FOUND_OPTION = { 
  41. 	type = TYPE_BUTTON, 
  42. 	label = "MENU_NO_GAMES_FOUND", 
  43. 	id = -1, 
  44. 	disabled = true 
  45. } 
  46.  
  47. local NO_FRIENDS_FOUND_OPTION = { 
  48. 	type = TYPE_BUTTON, 
  49. 	label = "MENU_NO_FRIENDS_FOUND", 
  50. 	id = -1, 
  51. 	disabled = true 
  52. } 
  53.  
  54. local Data = { 
  55. 	[1] = SEARCHING_OPTION 
  56. } 
  57.  
  58. local function build_hint_bar(searching) 
  59. 	--Setup Button Hints 
  60. 	local hint_data = { 
  61. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  62. 	} 
  63.  
  64. 	Hint_x_index = -1 
  65. 	if game_get_platform() ~= "PC" and Coop_connect_operation == COOP_SYSLINK_JOIN_LIST then 
  66. 		hint_data[#hint_data + 1] = {CTRL_BUTTON_X, "MENU_REFRESH_SYSLINK"} 
  67. 		Hint_x_index = #hint_data 
  68. 	elseif Num_friends > 0  then 
  69. 		hint_data[#hint_data + 1] = {CTRL_BUTTON_X, "PLT_MENU_VIEW_GAMERCARD"} 
  70. 		Hint_x_index = #hint_data 
  71. 	end 
  72.  
  73. 	Party_invite = false 
  74. 	Party_show = false 
  75. 	if (game_get_platform() == "XBOX360") or (game_get_platform() == "XBOX3") then 
  76. 		if Coop_connect_operation == COOP_ONLINE_JOIN_LIST and game_get_party_member_count() > 1 then 
  77. 			Party_show = true 
  78. 		elseif Coop_connect_operation == COOP_INVITE_LIST and game_get_party_member_count() > 1 then 
  79. 			Party_invite = true 
  80. 		end 
  81. 	end 
  82. 	 
  83. 	Hint_y_index = -1 
  84. 	if Party_show == true then 
  85. 		hint_data[#hint_data + 1] = { CTRL_BUTTON_Y, "MENU_XBOX_PARTY_JOIN" } 
  86. 		Hint_y_index = #hint_data  
  87. 	elseif Party_invite == true then 
  88. 		Input_tracker:add_input("exit", "pause_invite_friends_button_y", 50) 
  89. 		hint_data[#hint_data + 1] = { CTRL_BUTTON_Y, "MENU_XBOX_PARTY_INVITE" } 
  90. 		Hint_y_index = #hint_data 
  91. 	elseif searching ~= true and game_get_platform() == "PC" then 
  92. 		hint_data[#hint_data + 1] = {CTRL_BUTTON_Y, "MENU_REFRESH_SYSLINK"} 
  93. 		Hint_y_index = #hint_data 
  94. 	end  
  95. 	 
  96. 	Menu_hint_bar:set_width_max(List_width - HINT_BAR_OFFSET) 
  97. 	Menu_hint_bar:set_hints(hint_data) 
  98.  
  99. 	if Hint_bar_input_tracker ~= nil then 
  100. 		Hint_bar_input_tracker:remove_all() 
  101. 		Menu_hint_bar:add_mouse_inputs("pause_invite_friends", Hint_bar_input_tracker) 
  102. 		Hint_bar_input_tracker:subscribe(true) 
  103. 		--vint_force_mouse_move_event() 
  104. 	end 
  105.  
  106. 	Menu_hint_bar:set_visible(true)  
  107. end 
  108.  
  109. function pause_invite_friends_init() 
  110. 	--Initialize Header 
  111. 	if Coop_connect_operation == COOP_INVITE_LIST then 
  112. 		Header_obj:set_text("COOP_MENU_INVITE", List_width) 
  113. 	elseif Coop_connect_operation == COOP_SYSLINK_JOIN_LIST then 
  114. 		Header_obj:set_text("MULTI_FIND_GAMES", List_width) 
  115. 	else 
  116. 		Header_obj:set_text("MULTI_JOIN_FRIEND", List_width) 
  117. 	end 
  118.  
  119. 	-- Subscribe to the button presses we need 
  120. 	Input_tracker = Vdo_input_tracker:new() 
  121. 	Input_tracker:add_input("select", "pause_invite_friends_button_a", 60) 
  122. 	Input_tracker:add_input("back", "pause_invite_friends_button_b", 60) 
  123. 	Input_tracker:add_input("alt_select", "pause_invite_friends_button_x", 60) 
  124. 	Input_tracker:add_input("exit", "pause_invite_friends_button_y", 60) 
  125. 	Input_tracker:add_input("pause", "pause_invite_friends_button_start", 60) 
  126. 	Input_tracker:add_input("nav_up", "pause_invite_friends_nav_up", 60) 
  127. 	Input_tracker:add_input("nav_down", "pause_invite_friends_nav_down", 60) 
  128. 	Input_tracker:add_input("nav_left", "pause_invite_friends_nav_left", 60) 
  129. 	Input_tracker:add_input("nav_right", "pause_invite_friends_nav_right", 60) 
  130.  
  131. 	build_hint_bar() 
  132. 	 
  133. 	--set up the list in twns 
  134. 	local list_back_in = Vdo_tween_object:new("back_in_twn2", Screen_back_in_anim.handle) 
  135. 	local header_back_in = Vdo_tween_object:new("back_in_twn3", Screen_back_in_anim.handle) 
  136. 	 
  137. 	list_back_in:set_property("start_value", 100, 140) 
  138. 	header_back_in:set_property("start_value", 130, 83) 
  139. 	 
  140. 	list_back_in:set_property("end_value", 100, 140) 
  141. 	header_back_in:set_property("end_value", 130, 83) 
  142. 	 
  143. 	--set up the list out twns 
  144. 	local list_slide_out = Vdo_tween_object:new("screen_slide_out_twn2", Screen_slide_out_anim.handle) 
  145. 	local header_slide_out = Vdo_tween_object:new("screen_slide_out_twn3", Screen_slide_out_anim.handle) 
  146. 	 
  147. 	list_slide_out:set_property("start_value", 100, 140) 
  148. 	header_slide_out:set_property("start_value", 130, 83) 
  149. 		 
  150. 	list_slide_out:set_property("end_value", 100, 140) 
  151. 	header_slide_out:set_property("end_value", 130, 83) 
  152. 	 
  153. 	local list_slide_in = Vdo_tween_object:new("screen_slide_in_twn2", Screen_slide_in_anim.handle) 
  154. 	local header_slide_in = Vdo_tween_object:new("screen_slide_in_twn3", Screen_slide_in_anim.handle) 
  155. 	 
  156. 	list_slide_in:set_property("start_value", 100, 140) 
  157. 	header_slide_in:set_property("start_value", 130, 83) 
  158. 	 
  159. 	list_slide_in:set_property("end_value", 100, 140) 
  160. 	header_slide_in:set_property("end_value", 130, 83) 
  161. 	 
  162. 	--Store some locals to the pause menu common for screen processing. 
  163. 	menu_common_set_list_style(List, Header_obj, List_width) 
  164. 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim) 
  165. 	List:set_visible(false) 
  166.  
  167. 	Input_tracker:subscribe(false) 
  168. 	if game_get_platform() == "PC" then 
  169. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  170. 		Mouse_input_tracker:subscribe(false) 
  171. 		 
  172. 		Hint_bar_input_tracker = Vdo_input_tracker:new() 
  173. 		Hint_bar_input_tracker:subscribe(false) 
  174. 	end 
  175. 	 
  176. 	if Coop_connect_operation ~= COOP_SYSLINK_JOIN_LIST then 
  177. 		Network_check_thread = thread_new("pause_invite_check_for_network") 
  178. 	end 
  179. end 
  180.  
  181. function pause_invite_check_for_network() 
  182. 	while true do 
  183. 		if game_is_connected_to_internet() == false then 
  184.          delay(1.0)  
  185.  
  186.          -- Try again! If another user signs into their profile  
  187.          -- game_is_connected_to_internet() may return the wrong thing for 
  188.          -- a frame.  CMD 6/12/2013 
  189.          if game_is_connected_to_internet() == false then 
  190. 			if game_get_platform() == "PC" then 
  191. 				dialog_box_message("MENU_TITLE_WARNING", "MENU_PC_SIGN_IN_ERROR", false, false, "pause_invite_boot_to_main_menu") 
  192.             elseif game_get_platform() == "PS3" then 
  193. 				pause_invite_friends_button_b() 
  194. 			else 
  195. 				dialog_box_message("MENU_TITLE_WARNING", "MENU_COOP_CONNECTION_ERROR", false, false, "pause_invite_boot_to_main_menu") 
  196.             end 
  197.             return 
  198.          end 
  199.  
  200. 		end 
  201. 		thread_yield() 
  202. 	end 
  203. end 
  204.  
  205. function pause_invite_friends_get_data() 
  206. 	if Coop_connect_operation == COOP_SYSLINK_JOIN_LIST then 
  207. 		Search_thread = thread_new("pause_invite_refresh_syslink") 
  208. 	else 
  209. 		Search_thread = thread_new("pause_invite_friends_get_list") 
  210. 	end 
  211. end 
  212.  
  213. function pause_invite_friends_cleanup() 
  214.  
  215. end 
  216.  
  217. -- We want to perform this stuff when the screen is popped because the cleanup function can happen AFTER the "gained_focus" call back on the next screen. That messes with animations. 
  218. function pause_invite_friends_exited() 
  219. 	thread_kill(Network_check_thread) 
  220. 	Network_check_thread = -1 
  221.  
  222. 	--cleanup hintbar... 
  223. 	Menu_hint_bar:set_width_max(nil) 
  224. 	if Search_thread ~= -1 then 
  225. 		thread_kill(Search_thread) 
  226. 		Search_thread = -1 
  227. 	end 
  228. 	 
  229. 	if Started_syslink_search == true then 
  230. 		game_stop_find_syslink_servers(); 
  231. 	end 
  232.  
  233. 	if Mouse_input_tracker ~= nil then 
  234. 		Mouse_input_tracker:subscribe(false) 
  235. 	end 
  236.  
  237. 	List:enable_toggle_input(false) 
  238. 	 
  239. 	--used by screen 
  240. 	--set up the list in twns 
  241. 	local list_back_in = Vdo_tween_object:new("back_in_twn2", Screen_back_in_anim.handle) 
  242. 	local header_back_in = Vdo_tween_object:new("back_in_twn3", Screen_back_in_anim.handle) 
  243. 	 
  244. 	--used by screen 
  245. 	--set up the list out twns 
  246. 	local list_slide_out = Vdo_tween_object:new("screen_slide_out_twn2", Screen_slide_out_anim.handle) 
  247. 	local header_slide_out = Vdo_tween_object:new("screen_slide_out_twn3", Screen_slide_out_anim.handle) 
  248. 	 
  249. 	local list_back_out = Vdo_tween_object:new("back_out_twn3", Screen_back_out_anim.handle) 
  250. 	local header_back_out = Vdo_tween_object:new("back_out_twn2", Screen_back_out_anim.handle) 
  251. 	 
  252. 	 
  253. 	local list_slide_in = Vdo_tween_object:new("screen_slide_in_twn2", Screen_slide_in_anim.handle) 
  254. 	local header_slide_in = Vdo_tween_object:new("screen_slide_in_twn3", Screen_slide_in_anim.handle) 
  255. 	 
  256. 	list_slide_in:set_property("start_value", 100, 267) 
  257. 	header_slide_in:set_property("start_value", 130, 210) 
  258. 	 
  259. 	list_slide_in:set_property("end_value", 100, 267) 
  260. 	header_slide_in:set_property("end_value", 130, 210) 
  261. 	 
  262. 	list_back_in:set_property("start_value", 100, 267) 
  263. 	header_back_in:set_property("start_value", 130, 210) 
  264. 	 
  265. 	list_back_in:set_property("end_value", 100, 267) 
  266. 	header_back_in:set_property("end_value", 130, 210) 
  267.  
  268. 	list_slide_out:set_property("start_value", 100, 267) 
  269. 	header_slide_out:set_property("start_value", 130, 210) 
  270. 	 
  271. 	list_slide_out:set_property("end_value", 100, 267) 
  272. 	header_slide_out:set_property("end_value", 130, 210) 
  273. 	 
  274. 	list_back_out:set_property("start_value", 100, 267) 
  275. 	header_back_out:set_property("start_value", 130, 210) 
  276. 	 
  277. 	list_back_out:set_property("end_value", 100, 267) 
  278. 	header_back_out:set_property("end_value", 130, 210) 
  279. 	 
  280. 	-- Nuke all button subscriptions 
  281. 	Input_tracker:subscribe(false) 
  282. end 
  283.  
  284. function pause_invite_friends_get_list() 
  285. 	Input_tracker:subscribe(true) 
  286. 	 
  287. 	Data = { 
  288. 		[1] = SEARCHING_OPTION 
  289. 	} 
  290.  
  291. 	List:set_visible(true) 
  292. 	List:draw_items(Data, 1, List_width, MIN_SCROLL_ITEMS, nil, nil, false) 
  293.  
  294. 	Num_friends = 0 
  295. 	build_hint_bar(true) 
  296.  
  297. 	delay(.5) -- Make sure we show that "Searching" message for at least half a second. 
  298.  
  299. 	while true do           
  300. 		Invite_friends_error = 0 
  301. 		 
  302. 		Num_friends = 0 
  303. 		Data = {} 
  304. 		vint_dataresponder_request("coop_list_responder", "pause_invite_friends_populate", 0, Coop_connect_operation) 
  305. 		 
  306. 		if Invite_friends_error ~= 0 then 
  307. 			if game_get_platform() == "PC" then 
  308. 				dialog_box_message("MENU_TITLE_WARNING", "MENU_PC_SIGN_IN_ERROR", false, false, "pause_invite_boot_to_main_menu") 
  309. 			elseif game_get_platform() == "PS3" then 
  310. 				pause_invite_friends_button_b() 
  311. 			else 
  312. 				dialog_box_message("MENU_TITLE_WARNING", "MENU_COOP_CONNECTION_ERROR", false, false, "pause_invite_boot_to_main_menu")				 
  313. 			end 
  314. 			 
  315. 			Search_thread = -1 
  316. 			return 
  317. 		end 
  318.  
  319. 		if Num_friends == 0 then 
  320. 			if Coop_connect_operation == COOP_INVITE_LIST then 
  321. 				Data = { [1] = NO_FRIENDS_FOUND_OPTION } 
  322. 			else 
  323. 				Data = { [1] = NO_GAMES_FOUND_OPTION } 
  324. 			end 
  325. 		end 
  326.  
  327. 		pause_invite_friends_update_list_width(#Data) 
  328. 		local selection = List:get_selection() 
  329. 		selection = min(selection, #Data) 
  330. 		--REMOVED true FROM LIST DRAW CALL TO FIX ASSERT JAM 5/3/11 
  331. 		List:draw_items(Data, selection, List_width, MIN_SCROLL_ITEMS, nil, false, false) 
  332. 		build_hint_bar() 
  333. 		 
  334. 		--do this after we have redrawn the list 
  335. 		if Mouse_input_tracker ~= nil then 
  336. 			Mouse_input_tracker:remove_all() 
  337. 			List:add_mouse_inputs("pause_invite_friends", Mouse_input_tracker) 
  338. 			Mouse_input_tracker:subscribe(true) 
  339. 		end 
  340. 	 
  341. 		if game_get_platform() == "PC" then -- Only search once on PC 
  342. 			Search_thread = -1 
  343. 			break 
  344. 		end 
  345. 	 
  346. 		delay(2.0) 
  347. 	end 
  348. 	 
  349. 	Search_thread = -1 
  350. end 
  351.  
  352. function pause_invite_friends_set_error(error_number) 
  353. 	Invite_friends_error = error_number 
  354. end 
  355.  
  356. function pause_invite_boot_to_main_menu() 
  357. 	menu_common_stack_remove() 
  358. 	--[[ 
  359. 	Forcing the player to always pop back out to the game instead of the pause menu. 
  360. 	This fixes an issue if the player loads from the main menu into co-op invite and the game is  
  361. 		disconneted. 
  362. 	I actually think its impossible for the In_pause_menu variable to be false ever since the  
  363. 		player always enters invite friends from a pause menu. 
  364. 	If we want to pop the player to more specific places we'll have re-write how we detect where  
  365. 		the player originally came from 
  366. 			-Mike Rossi 3-27-2013 
  367. 	]]-- 
  368. 	if In_pause_menu then 
  369. 		menu_common_transition_pop(6) -- Really only needs to be 3, but set to 6 just in case. 
  370. 	else 
  371. 		menu_common_transition_pop(3) 
  372. 	end 
  373. end 
  374.  
  375. --HVS_JPM[KING] 12/11/2014: added invite_flags from XBOX3 version to differentiate between friends online playing the game and ones just online 
  376. function pause_invite_friends_populate(name, id, invite_tag, invite_flags) 
  377. 	Num_friends = Num_friends + 1 
  378. 	Data[Num_friends] = { type = TYPE_BUTTON, label = name, id = Num_friends, invite_tag = invite_tag, invite_flags = invite_flags } 
  379. end 
  380.  
  381. function pause_invite_friends_do_responder() 
  382. 	Num_friends = 0 
  383. 	Data = { } 
  384. 	vint_dataresponder_request("coop_list_responder", "pause_invite_friends_populate", 0, Coop_connect_operation) 
  385.  
  386. 	if Num_friends == 0 then 
  387. 		if Coop_connect_operation == COOP_INVITE_LIST then 
  388. 			Data = { 
  389. 				[1] = NO_FRIENDS_FOUND_OPTION 
  390. 			} 
  391. 		else 
  392. 			Data = {  
  393. 				[1] = NO_GAMES_FOUND_OPTION 
  394. 			} 
  395. 		end 
  396. 	end 
  397. 	 
  398. 	--Get the selection option from when the menu was last loaded 
  399. 	pause_invite_friends_update_list_width(#Data) 
  400. 	local selection = List:get_selection() 
  401. 	selection = min(selection, #Data) 
  402. 	--REMOVED true FROM LIST DRAW CALL TO FIX ASSERT JAM 5/3/11 
  403. 	List:draw_items(Data, selection, List_width, MIN_SCROLL_ITEMS, nil, false, false) 
  404. 	 
  405. 	Hint_y_index = -1 
  406. 	 
  407. 	local hint_data 
  408. 	if Coop_connect_operation == COOP_SYSLINK_JOIN_LIST then 
  409. 		if game_get_platform() ~= "PC" then 
  410. 			hint_data = { 
  411. 				{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  412. 				{CTRL_BUTTON_X, "MENU_REFRESH_SYSLINK"}, 
  413. 			} 
  414. 			Hint_x_index = 2 
  415. 		else 
  416. 			hint_data = { 
  417. 				{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  418. 				{CTRL_BUTTON_Y, "MENU_REFRESH_SYSLINK"}, 
  419. 			} 
  420. 			Hint_y_index = 2 
  421. 		end 
  422. 	elseif Num_friends == 0  then 
  423. 		hint_data = { 
  424. 			{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  425. 			} 
  426. 		Hint_x_index = -1 
  427. 	else 
  428. 		hint_data = { 
  429. 			{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  430. 			{CTRL_BUTTON_X, "PLT_MENU_VIEW_GAMERCARD"}, 
  431. 		} 
  432. 		Hint_x_index = 2 
  433. 	end 
  434. 	 
  435. 	if Party_show == true then 
  436. 		hint_data[#hint_data + 1] = { CTRL_BUTTON_Y, "MENU_XBOX_PARTY_JOIN" } 
  437. 		Hint_y_index = #hint_data  
  438. 	elseif Party_invite == true then 
  439. 		hint_data[#hint_data + 1] = { CTRL_BUTTON_Y, "MENU_XBOX_PARTY_INVITE" } 
  440. 		Hint_y_index = #hint_data 
  441. 	end 
  442. 	 
  443. 	Menu_hint_bar:set_width_max(List_width - HINT_BAR_OFFSET) 
  444. 	Menu_hint_bar:set_hints(hint_data)  
  445. 	 
  446. 	--UNLOCK INPUT HERE JAM 5/3/11 
  447. 	Input_tracker:subscribe(true) 
  448. 	if Mouse_input_tracker ~= nil then 
  449. 		Mouse_input_tracker:remove_all() 
  450. 		List:add_mouse_inputs("pause_invite_friends", Mouse_input_tracker) 
  451. 		Mouse_input_tracker:subscribe(true) 
  452. 	end 
  453. 	 
  454. 	if Hint_bar_input_tracker ~= nil then 
  455. 		Hint_bar_input_tracker:remove_all() 
  456. 		Menu_hint_bar:add_mouse_inputs("pause_invite_friends", Hint_bar_input_tracker) 
  457. 		Hint_bar_input_tracker:subscribe(true) 
  458. 	end 
  459. end 
  460.  
  461. function pause_invite_refresh_syslink(quick_refresh) 
  462. 	game_start_find_syslink_servers() 
  463. 	Started_syslink_search = true 
  464. 	 
  465. 	Data = { 
  466. 		[1] = SEARCHING_OPTION 
  467. 	} 
  468. 	pause_invite_friends_update_list_width(#Data) 
  469. 	List:draw_items(Data, 1, List_width, MIN_SCROLL_ITEMS, nil, nil, false) 
  470. 	List:set_visible(true) 
  471.  
  472. 	local hint_data = { 
  473. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  474. 	} 
  475. 	 
  476. 	Menu_hint_bar:set_width_max(List_width - HINT_BAR_OFFSET) 
  477. 	Menu_hint_bar:set_hints(hint_data)   
  478. 	Hint_y_index = -1 
  479. 	Hint_x_index = -1 
  480.  
  481. 	--REMOVED quick_refresh FROM LIST DRAW CALL TO FIX ASSERT JAM 5/3/11 
  482. 	pause_invite_friends_update_list_width(#Data) 
  483. 	List:draw_items(Data, 1, List_width, MIN_SCROLL_ITEMS, nil, false, false) 
  484. 	 
  485. 	Input_tracker:subscribe(true) 
  486. 	if Mouse_input_tracker ~= nil then 
  487. 		Mouse_input_tracker:remove_all() 
  488. 		List:add_mouse_inputs("pause_invite_friends", Mouse_input_tracker) 
  489. 		Mouse_input_tracker:subscribe(true) 
  490. 	end 
  491. 	 
  492. 	if Hint_bar_input_tracker ~= nil then 
  493. 		Hint_bar_input_tracker:remove_all() 
  494. 		Menu_hint_bar:add_mouse_inputs("pause_invite_friends", Hint_bar_input_tracker) 
  495. 		Hint_bar_input_tracker:subscribe(true) 
  496. 	end 
  497.  
  498. 	delay(SYSLINK_UPDATE_DELAY) 
  499. 	 
  500. 	pause_invite_friends_do_responder() 
  501.  
  502. 	-- Does not live update. 
  503. 	game_stop_find_syslink_servers()	 
  504. 	Started_syslink_search = false 
  505. 	 
  506. 	Search_thread = -1 
  507. end 
  508.  
  509. function pause_invite_friends_nav_up(event, acceleration) 
  510. 	-- Move highlight up 
  511. 	List:move_cursor(-1) 
  512. end 
  513.  
  514. function pause_invite_friends_nav_down(event, acceleration) 
  515. 	-- Move highlight down 
  516. 	List:move_cursor(1) 
  517. end 
  518.  
  519. function pause_invite_friends_nav_left(event, acceleration) 
  520. 	-- Move highlight left 
  521. 	List:move_slider(-1) 
  522. end 
  523.  
  524. function pause_invite_friends_nav_right(event, acceleration) 
  525. 	-- Move highlight right 
  526. 	List:move_slider(1) 
  527. end 
  528.  
  529. function pause_invite_friends_button_a(event, acceleration) 
  530. 	if Tween_done == true then 
  531. 		--set the screen data to the list data 
  532. 		Data = List:return_data() 
  533. 		local current_id = List:get_id() 
  534. 				 
  535. 		if current_id == -1 then 
  536. 			return 
  537. 		end 
  538. 		 
  539. 		if Coop_connect_operation == COOP_INVITE_LIST then 
  540. 			 
  541. 			local insert_values = { [0] = Data[List:get_selection()].invite_tag } 
  542. 			if game_can_send_player_invite(List:get_selection() - 1) == false then 
  543. 				local body = vint_insert_values_in_string("INVITE_FAILED_BODY", insert_values) 
  544. 				dialog_box_message("INVITE_FAILED_TITLE", body) 
  545. 				return 
  546. 			end 
  547. 			 
  548. 			if game_send_pause_menu_player_invite(List:get_selection() - 1) == true and game_is_joinable() then -- offset index by 1 
  549. 				local body = vint_insert_values_in_string("MP_INVITE_SENT_BODY", insert_values) 
  550. 				dialog_box_message("MP_INVITE_SENT_TITLE", body) 
  551. 			else 
  552. 				local body = vint_insert_values_in_string("INVITE_FAILED_BODY", insert_values) 
  553. 				dialog_box_message("INVITE_FAILED_TITLE", body) 
  554. 			end 
  555. 			 
  556. 			if Exit_after_closing == true then 
  557. 				menu_common_transition_pop(3) 
  558. 			end 
  559. 		elseif Coop_connect_operation == COOP_ONLINE_JOIN_LIST then 
  560. 		 
  561. 			local insert_values = { [0] = Data[List:get_selection()].invite_tag } 
  562. 			if game_can_send_player_invite(List:get_selection() - 1) == false then 
  563. 				local body = vint_insert_values_in_string("INVITE_FAILED_BODY", insert_values) 
  564. 				dialog_box_message("INVITE_FAILED_TITLE", body) 
  565. 				return 
  566. 			end 
  567. 		 
  568. 			local has_seen_cal_screen = pause_menu_has_seen_display_cal_screen() 
  569. 			if has_seen_cal_screen then 
  570. 				local successful = game_main_menu_join_friend_in_progress(List:get_selection() - 1); 
  571. 				pause_invite_friends_lock_input(successful) 
  572. 			else 
  573. 				Join_friend_after_display = List:get_selection() - 1 
  574. 				push_screen("pause_options_display_cal") 
  575. 			end 
  576. 			 
  577. 		elseif Coop_connect_operation == COOP_SYSLINK_JOIN_LIST then 
  578. 			game_join_syslink_game(current_id) 
  579. 		end 
  580. 	 
  581. 	end 
  582. end 
  583.  
  584. function pause_invite_friends_button_b(event, acceleration) 
  585. 	if Tween_done == true then 
  586. 		--pass off the input to the list 
  587. 		List:button_b() 
  588. 	 
  589. 		--set up the list out twns 
  590. 		local list_slide_out = Vdo_tween_object:new("screen_slide_out_twn2", Screen_slide_out_anim.handle) 
  591. 		local header_slide_out = Vdo_tween_object:new("screen_slide_out_twn3", Screen_slide_out_anim.handle) 
  592. 		 
  593. 		list_slide_out:set_property("start_value", 100, 140) 
  594. 		header_slide_out:set_property("start_value", 130, 83) 
  595. 		 
  596. 		list_slide_out:set_property("end_value", 100, 140) 
  597. 		header_slide_out:set_property("end_value", 130, 83) 
  598. 		 
  599. 		local list_slide_in = Vdo_tween_object:new("screen_slide_in_twn2", Screen_slide_in_anim.handle) 
  600. 		local header_slide_in = Vdo_tween_object:new("screen_slide_in_twn3", Screen_slide_in_anim.handle) 
  601. 		 
  602. 		list_slide_in:set_property("start_value", 100, 267) 
  603. 		header_slide_in:set_property("start_value", 130, 210) 
  604. 	 
  605. 		list_slide_in:set_property("end_value", 100, 267) 
  606. 		header_slide_in:set_property("end_value", 130, 210) 
  607. 	 
  608. 		Input_tracker:subscribe(false) 
  609. 		if Mouse_input_tracker ~= nil then 
  610. 			Mouse_input_tracker:subscribe(false) 
  611. 		end 
  612. 		if Exit_after_closing == true then 
  613. 			menu_common_transition_pop(3) 
  614. 		else 
  615. 			--Remove current menu from the stack 
  616. 			menu_common_stack_remove() 
  617. 			menu_common_transition_pop(1) 
  618. 		end 
  619. 	end 
  620. end 
  621.  
  622. function pause_invite_friends_button_x(event, acceleration) 
  623. 	if Tween_done == true and Hint_x_index ~= -1 then 
  624. 		if game_get_platform() ~= "PC" and Coop_connect_operation == COOP_SYSLINK_JOIN_LIST then 
  625. 		 
  626. 		 
  627. 			if Search_thread == -1 then 
  628. 				Search_thread = thread_new("pause_invite_refresh_syslink", true) 
  629. 			end 
  630. 			 
  631. 			return 
  632. 		end 
  633. 	 
  634. 		local current_id = List:get_id() 
  635. 		if current_id == -1 then 
  636. 			return 
  637. 		end 
  638. 	 
  639. 		game_show_coop_gamercard(List:get_selection() - 1) 
  640. 	end 
  641. end 
  642.  
  643. function pause_invite_friends_button_y(event, acceleration) 
  644. 	if Party_invite then 
  645. 		game_send_party_invites() 
  646. 	elseif Party_show then 
  647. 		if game_get_party_member_count() > 1 then 
  648. 			game_show_community_sessions_ui() 
  649. 		else 
  650. 			game_show_party_ui() 
  651. 		end 
  652. 	elseif game_get_platform() == "PC" then 
  653. 		if Search_thread == -1 then 
  654. 			pause_invite_friends_get_data() 
  655. 		end 
  656. 	end 
  657. end 
  658.  
  659. function pause_invite_friends_button_start(event, acceleration) 
  660. 	if In_pause_menu == false then 
  661. 		return 
  662. 	end 
  663. 	 
  664. 	if Tween_done == true then 
  665. 		menu_common_set_screen_data(List, Header_obj, nil, Screen_back_out_anim, Screen_out_anim)	 
  666. 		Input_tracker:subscribe(false) 
  667. 		-- stack is part of common, which is getting popped, so we don't update it. 
  668. 		menu_common_transition_pop(4) -- invite_friends, pause_co_op_menu, pause_menu_top, menu_common 
  669. 		bg_saints_slide_out() 
  670. 	end 
  671. end 
  672.  
  673. -- Update the list width (depending on if it will scroll or not) 
  674. function pause_invite_friends_update_list_width(list_items) 
  675. 	--[[ 
  676. 	if list_items > MIN_SCROLL_ITEMS then 
  677. 		List_width = 685 
  678. 	else 
  679. 		List_width = 700 
  680. 	end 
  681. 	]] 
  682. end 
  683.  
  684. -- Mouse inputs 
  685. function pause_invite_friends_mouse_click(event, target_handle) 
  686. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  687. 	if hint_index == 1 then 
  688. 		pause_invite_friends_button_b() 
  689. 	elseif hint_index == Hint_y_index then 
  690. 		pause_invite_friends_button_y() 
  691. 	elseif hint_index == Hint_x_index then 
  692. 		pause_invite_friends_button_x() 
  693. 	end 
  694.  
  695. 	local new_index = List:get_button_index(target_handle) 
  696. 	if new_index ~= 0 then 
  697. 		List:set_selection(new_index) 
  698. 		pause_invite_friends_button_a() 
  699. 	end 
  700. end 
  701.  
  702. function pause_invite_friends_mouse_move(event, blah1, blah2, blah3, blah4, target_handle) 
  703. 	 
  704. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  705. 	if hint_index ~= 0 then 
  706. 		Menu_hint_bar:set_highlight(hint_index) 
  707. 	else 
  708. 		Menu_hint_bar:set_highlight(0)	 
  709. 	end 
  710. 	 
  711. 	local new_index = List:get_button_index(target_handle) 
  712. 	if new_index ~= 0 then 
  713. 		List:set_selection(new_index) 
  714. 		List:move_cursor(0, true) 
  715. 	end 
  716. end 
  717.  
  718. function pause_invite_friends_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  719. 	if scroll_lines ~= 0 then 
  720. 		if List:get_scroll_region_handle() == target_handle then 
  721. 			List:scroll_list(scroll_lines * -1) 
  722. 			List:update_mouse_inputs("pause_invite_friends", Mouse_input_tracker) 
  723. 			Mouse_input_tracker:subscribe(true) 
  724. 		end 
  725. 	end 
  726. end 
  727.  
  728. function pause_invite_friends_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  729. 	if List.scrollbar.tab_grp.handle == target_handle then 
  730. 		local new_start_index = List.scrollbar:drag_scrolltab(mouse_y, List.num_buttons - (List.max_buttons - 1)) 
  731. 		List:scroll_list(0, new_start_index) 
  732. 	end 
  733. end 
  734.  
  735. -- Updates the mouse inputs for the list and snaps the scrolltab to the closest notch based on the visible index 
  736. -- 
  737. function pause_invite_friends_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  738. 	if List.scrollbar.tab_grp.handle == target_handle then 
  739. 		local start_index = List:get_visible_indices() 
  740. 		List.scrollbar:release_scrolltab(start_index, List.num_buttons - (List.max_buttons - 1)) 
  741. 		List:update_mouse_inputs("pause_invite_friends", Mouse_input_tracker) 
  742. 		Mouse_input_tracker:subscribe(true) 
  743. 	end 
  744. end 
  745.  
  746. function pause_invite_friends_lock_input(lock) 
  747. 	-- Nuke all button subscriptions 
  748. 	Input_tracker:subscribe(not lock) 
  749. 	if Mouse_input_tracker ~= nil then 
  750. 		Mouse_input_tracker:subscribe(not lock) 
  751. 	end 
  752. end 
  753.  
  754. --nasty hack because the load character popup calls this function to unlock input from C, yuck 
  755. function main_menu_coop_lock_controls(lock) 
  756. 	pause_invite_friends_lock_input(lock) 
  757. end 
  758.