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