./game_lobby.lua

  1. -- "Defines" 
  2. local COOP_INVITE_LIST 	= 0 
  3. local ID_PRIV 				= 1 
  4. local ID_FF					= 2 
  5. local ID_MAP				= 3 
  6. local ID_CHARACTER 		= 4 
  7. local ID_CANCEL_READY	= 5 
  8.  
  9. local HMLD_MAPS 			= 0 
  10. local HMLD_CHARS			= 1 
  11.  
  12. local HOST_ID				= true 
  13. local CLIENT_ID			= false 
  14.  
  15. -- "Globals" 
  16. local Lobby_data = { } 
  17. local Data = {} 
  18. local LOBBY_LIST_SCALE = .9 
  19. local LOBBY_LIST_WIDTH = 440		-- 495 
  20. local LOBBY_LIST_MAX_ITEMS = 9 
  21. local LOBBY_LIST_FORCE_SCALE = false 
  22. local Horde_button  
  23. local Horde_mode_continue = false 
  24. local Menu_has_shown = false 
  25.  
  26. local Local_ready = false 
  27. local Remote_ready = false 
  28.  
  29. local	Host_char_bmp_h			 
  30. local	Host_info_grp_h			 
  31. local	Host_speak_bmp_h			 
  32. local	Host_name_txt_h			 
  33. local	Client_char_bmp_h			 
  34. local	Client_info_grp_h			 
  35. local	Client_speak_bmp_h		 
  36. local	Client_name_txt_h			 
  37.  
  38. local In_invite = false 
  39.  
  40. --Internal name is on left, bitmap on right. 
  41. local Char_image_names = { 
  42. 	["Bobert"] 		= "ui_lobby_char_bobert", 
  43. 	["Cowgirl"] 	= "ui_lobby_char_cowgirl", 
  44. 	["Cyril"] 		= "ui_lobby_char_cyril", 
  45. 	["Gimpy"] 		= "ui_lobby_char_gimpy", 
  46. 	["Super"] 		= "ui_lobby_char_super", 
  47. } 
  48.  
  49. --Internal name is on left, bitmap on right. 
  50. local Map_image_names = { 
  51. 	["angels_area"] 		= "ui_lobby_level_casino", 
  52. 	["daedelus_area"] 	= "ui_lobby_level_daetelus", 
  53. 	["zombie_area"] 		= "ui_lobby_level_zombie", 
  54. } 
  55.  
  56. -- VDOs 
  57. local Input_tracker 
  58. local Mouse_input_tracker = 0 
  59. local List = {} 
  60. local Hint_bar 
  61. local Header_obj 
  62.  
  63. local Char_client_grp_h 
  64. local Char_host_grp_h 
  65.  
  66. -- Menu Data 
  67. local Lobby_data 			= { } 
  68. local Cooptions_data		= { } 
  69. local Data 					= { } 
  70.  
  71. -- "Globals" 
  72. local Back_callback 			= -1 
  73. local Invite_show_thread 	= -1 
  74. local Num_friends 			= 0 
  75. local Connected 				= false 
  76. local Join_completed 		= false 
  77.  
  78. -- Main menu indices 
  79. local UNAVAILABLE_INDEX = -1 
  80. local INVITE_INDEX		= UNAVAILABLE_INDEX 
  81. local OPTIONS_INDEX		= UNAVAILABLE_INDEX 
  82. local START_INDEX 		= UNAVAILABLE_INDEX 
  83. local QUIT_INDEX			= UNAVAILABLE_INDEX 
  84. -- Whored Mode indices 
  85. local MAP_INDEX			= UNAVAILABLE_INDEX 
  86. local CHARACTER_INDEX	= UNAVAILABLE_INDEX 
  87. local CONTINUE_INDEX		= UNAVAILABLE_INDEX 
  88. -- Coop options menu indices 
  89. local PRIVACY_INDEX 		= 1 
  90. local FF_INDEX 			= 2 
  91.  
  92. local Party_invite = false 
  93. local Can_refresh_friend_list = false 
  94. local Show_partner_gamercard = false 
  95.  
  96.  
  97. local function build_hint_bar(show_invite_friends, searching) 
  98.  
  99. 	Hint_bar:set_visible(false) 
  100.  
  101. 	Show_partner_gamercard = false 
  102.  
  103. 	if show_invite_friends then 
  104. 		-- Show the hint bar 
  105. 		local hint_data = {} 
  106. 		if Num_friends == 0 then 
  107. 			hint_data = { 
  108. 				{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  109. 			} 
  110. 		else 
  111. 			hint_data = { 
  112. 				{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  113. 				{CTRL_BUTTON_X, "PLT_MENU_VIEW_GAMERCARD"}, 
  114. 			} 
  115. 		end 
  116.  
  117. 		Party_invite = false 
  118. 		if game_get_platform() == "XBOX360" then 
  119. 			if game_get_party_member_count() > 1 then 
  120. 				hint_data[#hint_data + 1] = { CTRL_BUTTON_Y, "MENU_XBOX_PARTY_INVITE" } 
  121. 				Party_invite = true 
  122. 			end 
  123. 		end 
  124. 		 
  125. 		Can_refresh_friend_list = false 
  126. 		if searching ~= true and game_get_platform() == "PC" then 
  127. 			hint_data[#hint_data + 1] = { CTRL_BUTTON_Y, "MENU_REFRESH_SYSLINK" } 
  128. 			Can_refresh_friend_list = true 
  129. 		end 
  130. 		 
  131. 		Hint_bar:set_hints(hint_data) 
  132. 		 
  133. 		Hint_bar:set_visible(true) 
  134.  
  135. 	else 
  136. 	 
  137. 		if (Connected or not game_get_is_host()) and game_is_syslink() == false then 
  138. 			local hint_data = { 
  139. 				{CTRL_BUTTON_X, "PLT_MENU_VIEW_PARTNER_GAMERCARD"}, 
  140. 			} 
  141. 			Show_partner_gamercard = true 
  142. 			Hint_bar:set_hints(hint_data) 
  143. 			Hint_bar:set_visible(true) 
  144. 		else 
  145. 			Hint_bar:set_hints(nil) 
  146. 			Hint_bar:set_visible(false) 
  147. 		end 
  148. 	 
  149. 	end 
  150. 	 
  151. end 
  152.  
  153. -------------------------------------------------------- 
  154. -- Init/Clean up 
  155. function game_lobby_init() 
  156. 	--Do we need to pause map dump? 
  157. 	pause_map_dump() 
  158. 	 
  159. 	--Set background for "bg_saints" 
  160. 	bg_saints_set_type(BG_TYPE_FULLSCREEN, false) 
  161.  
  162. 	--Setup Button Hints 
  163. 	Hint_bar = Vdo_hint_bar:new("hint_bar") 
  164. 	 
  165. 	--Setup the list 
  166. 	List = Vdo_mega_list:new("list") 
  167. 	List:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY) 
  168. 	 
  169. 	Char_client_grp_h = vint_object_find("client_char_bmp") 
  170. 	Char_host_grp_h = vint_object_find("host_char_bmp") 
  171. 	 
  172. 	--Initialize Input Tracker 
  173. 	Input_tracker = Vdo_input_tracker:new() 
  174. 	Input_tracker:add_input("pause", 		"game_lobby_button_start", 	50) 
  175. 	Input_tracker:add_input("select", 		"game_lobby_button_a", 			50) 
  176. 	Input_tracker:add_input("alt_select", 	"game_lobby_button_x", 			50) 
  177. 	Input_tracker:add_input("exit",			"game_lobby_button_y",			50) 
  178. 	Input_tracker:add_input("back", 			"game_lobby_button_b", 			50) 
  179. 	Input_tracker:add_input("nav_up", 		"game_lobby_nav_up", 			50) 
  180. 	Input_tracker:add_input("nav_down", 	"game_lobby_nav_down", 			50) 
  181. 	Input_tracker:add_input("nav_left", 	"game_lobby_nav_left", 			50) 
  182. 	Input_tracker:add_input("nav_right", 	"game_lobby_nav_right", 		50) 
  183. 	 
  184. 	-- Add mouse inputs for the PC 
  185. 	if game_get_platform() == "PC" then 
  186. 		Hint_bar:set_highlight(0) 
  187. 		 
  188. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  189.  
  190. 		Mouse_input_tracker:subscribe(false) 
  191. 	 
  192. 		--menu_common_set_mouse_tracker(Mouse_input_tracker) 
  193. 	end 
  194. 	 
  195. 	if game_get_is_host() and game_coop_get_starting_coop() then 
  196. 		game_lobby_show_spinner(true, "COOP_LOBBY_WAITING") 
  197. 	else 
  198. 		game_lobby_show_spinner(false, nil) 
  199. 	end 
  200. 	 
  201. 	local base_grp_h = vint_object_find("base_grp") 
  202. 	vint_set_property(base_grp_h, "visible", false) 
  203. 	 
  204. 	build_hint_bar() 
  205. 	 
  206. end 
  207.  
  208. function game_lobby_cleanup() 
  209. 	if Invite_show_thread ~= -1 then 
  210. 		thread_kill(Invite_show_thread) 
  211. 	end 
  212.  
  213. 	--Unload logos and characters... 
  214. 	game_peg_unload("ui_bms_lobby_whored") 
  215. 	game_peg_unload("ui_bms_lobby_coop") 
  216. 	game_peg_unload("ui_bms_lobby_levels") 
  217.  
  218. 	pause_map_restore() 
  219. end 
  220.  
  221. ------------------------------------------------------------------------------- 
  222. -- Called from game after we've unloaded the pause map... 
  223. -- 
  224. function game_lobby_init_done() 
  225. 	if horde_mode_is_active() then 
  226. 		game_peg_load_with_cb("game_lobby_peg_loaded", 2, "ui_bms_lobby_whored", "ui_bms_lobby_levels") 
  227. 	else 
  228. 		--load coop  
  229. 		game_peg_load_with_cb("game_lobby_peg_loaded", 2, "ui_bms_lobby_coop", "ui_bms_lobby_levels") 
  230. 	end 
  231. end 
  232.  
  233. function game_lobby_peg_loaded() 
  234. 	--base group.... 
  235. 	local base_grp_h = vint_object_find("base_grp") 
  236. 	vint_set_property(base_grp_h, "visible", true) 
  237.  
  238. 	-- Grab some common handles 
  239. 	Host_char_bmp_h			= vint_object_find("host_char_bmp") 
  240. 	Host_info_grp_h			= vint_object_find("host_info_grp") 
  241. 	Host_speak_bmp_h			= vint_object_find("host_speak_bmp") 
  242. 	Host_name_txt_h			= vint_object_find("host_name_txt") 
  243. 	Client_char_bmp_h			= vint_object_find("client_char_bmp") 
  244. 	Client_info_grp_h			= vint_object_find("client_info_grp") 
  245. 	Client_speak_bmp_h		= vint_object_find("client_speak_bmp") 
  246. 	Client_name_txt_h			= vint_object_find("client_name_txt") 
  247.  
  248. 	-- Set the waiting text, if necessary 
  249. 	game_lobby_set_waiting_prompt() 
  250. 	 
  251. 	-- Adjust the screen layout 
  252. 	game_lobby_set_screen_layout() 
  253. 	 
  254. 	-- Create the main lobby list 
  255. 	game_lobby_create_lobby() 
  256. 	 
  257. 	-- Show the main coop lobby menu 
  258. 	game_lobby_show_main() 
  259.  
  260. 	game_lobby_finished_loading() 
  261. 	 
  262. 	Input_tracker:subscribe(true) 
  263. end 
  264.  
  265. ------------------------------------------------------------------------------- 
  266. -- 
  267. -- Updates from code 
  268. -- 
  269. ------------------------------------------------------------------------------- 
  270. -- Called from code when a client connects, and again when finished connecting 
  271. -- @param 	join_complete				true when the client is fully connected, false when still connecting 
  272. -- 
  273. function game_lobby_joined(join_complete) 
  274. 	local values = { [0] = game_lobby_get_remote_player_name(), } 
  275. 	local tag = nil 
  276. 	 
  277. 	if In_invite == true then 
  278. 		game_lobby_button_b() 
  279. 	end 
  280. 	 
  281. 	if game_is_syslink() == false then  
  282. 		Lobby_data[1] = Kick_button 
  283. 	end 
  284. 		 
  285. 	if join_complete then  
  286. 		Lobby_data[START_INDEX].label = "COOP_LOBBY_COOP_START" 
  287. 		Lobby_data[START_INDEX].disabled = false 
  288. 				 
  289. 		Join_completed = true 
  290. 		tag = vint_insert_values_in_string("COOP_LOBBY_JOINED", values) 
  291. 		 
  292. 		if horde_mode_is_active() then 
  293. 			-- Update client name 
  294. 			vint_set_property(Client_name_txt_h, "text_tag", game_lobby_get_remote_player_name()) 
  295.  
  296. 			-- We are not ready! 
  297. 			game_lobby_update_local_ready(false) 
  298. 		end 
  299. 	else 
  300. 		Join_completed = false 
  301. 		tag = vint_insert_values_in_string("COOP_LOBBY_JOINING", values) 
  302. 	end 
  303. 	 
  304. 	Connected = true 
  305. 	game_lobby_show_spinner((join_complete ~= true), tag) 
  306.  
  307. 	build_hint_bar() 
  308.  
  309. 	 
  310. 	if Data == Lobby_data then 
  311. 		local selection = List:get_selection() 
  312. 		List:draw_items(Data, selection, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  313. 		 
  314. 		if Mouse_input_tracker ~= 0 then 
  315. 			Mouse_input_tracker:remove_all() 
  316. 			List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  317. 			Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  318. 			Mouse_input_tracker:subscribe(true) 
  319. 		end 
  320. 	end 
  321. 	 
  322. end 
  323.  
  324. ------------------------------------------------ 
  325. -- Called from code when the client disconnects 
  326. -- 
  327. function game_lobby_disconnect() 
  328. 	-- reset the globals, we're disconnected	 
  329. 	Join_completed = false 
  330. 	Connected = false 
  331. 	 
  332. 	-- Flag start button for not being enabled 
  333. 	if horde_mode_is_active() then 
  334. 		Lobby_data[START_INDEX].disabled = true 
  335. 	else 
  336. 		Lobby_data[START_INDEX].label = "COOP_LOBBY_START_GAME" 
  337. 	end 
  338. 	 
  339. 	-- Update the imagery 
  340. 	game_lobby_set_screen_layout() 
  341. 	 
  342. 	-- Update the spinner to show "Left" text 
  343. 	local values = { [0] = game_lobby_get_remote_player_name(), } 
  344. 	local tag = vint_insert_values_in_string("COOP_LOBBY_LEFT", values) 
  345. 	game_lobby_show_spinner(false, tag) 
  346. 	 
  347. 	-- Spawn a thread to reset the text to "waiting for player" after 5 seconds 
  348. 	thread_new("game_lobby_reset_waiting") 
  349. 	 
  350. 	-- Update the invite button 
  351. 	if game_is_syslink() == false then  
  352. 		Lobby_data[1] = Invite_button 
  353. 	end 
  354. 	 
  355. 	-- Hide the client in horde mode 
  356. 	if horde_mode_is_active() then  
  357. 		-- hide the client 
  358. 		game_lobby_show_char(false, false) 
  359. 	end 
  360. 	 
  361. 	-- We're always ready when we're the only bros 
  362. 	--game_lobby_update_local_ready(true) 
  363.  
  364. 	build_hint_bar() 
  365. 	 
  366. 	-- Redraw the list with the updated button 
  367. 	if Data == Lobby_data then 
  368. 		local selection = List:get_selection() 
  369. 		List:draw_items(Data, selection, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  370. 		 
  371. 		if Mouse_input_tracker ~= 0 then 
  372. 			Mouse_input_tracker:remove_all() 
  373. 			List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  374. 			Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  375. 			Mouse_input_tracker:subscribe(true) 
  376. 		end 
  377. 	end 
  378. 	 
  379. end 
  380.  
  381. ------------------------------------------------ 
  382. -- Set the waiting text back to "waiting" 
  383. -- 
  384. function game_lobby_reset_waiting() 
  385. 	delay(5) 
  386. 	game_lobby_show_spinner(true, "COOP_LOBBY_WAITING") 
  387. end 
  388.  
  389. ------------------------------------------------ 
  390. -- Update the map from the server (client only) 
  391. -- 
  392. function game_lobby_update_map(new_value) 
  393. 	local new_selection = 0 
  394. 	for i = 1, #Map_button.options_data do 
  395. 		if Map_button.options_data[i].id == new_value then 
  396. 			new_selection = i 
  397. 		end 
  398. 	end 
  399.  
  400. 	Map_button.current_value = new_selection 
  401. 	 
  402. 	game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  403. 	 
  404. 	game_lobby_update_map_display() 
  405. 	game_lobby_update_continue_button() 
  406. 	 
  407. 	local last_option_selected = List:get_selection() 
  408. 	List:draw_items(Data, last_option_selected, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  409. 	 
  410. 	if Mouse_input_tracker ~= 0 then 
  411. 		Mouse_input_tracker:remove_all() 
  412. 		List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  413. 		Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  414. 		Mouse_input_tracker:subscribe(true) 
  415. 	end 
  416. end 
  417.  
  418. ------------------------------------------------ 
  419. -- Update the other player's character 
  420. -- 
  421. function game_lobby_update_char(new_value) 
  422. 	local new_selection = 0 
  423. 	for i = 1, #Character_button.options_data do 
  424. 		if Character_button.options_data[i].id == new_value then 
  425. 			new_selection = i 
  426. 		end 
  427. 	end 
  428.  
  429. 	-- If I'm the host, we're updating the client 
  430. 	if game_get_is_host() then 
  431. 		game_lobby_update_char_display(false, new_selection) 
  432. 	else 
  433. 	-- If I'm the client, we're updating the host 
  434. 		game_lobby_update_char_display(true, new_selection) 
  435. 	end 
  436. end 
  437.  
  438. ------------------------------------------------ 
  439. -- Update the other player's ready state 
  440. -- 
  441. function game_lobby_update_ready(new_value, redraw_list) 
  442. 	local char_grp_h = 0  
  443. 	 
  444. 	if game_get_is_host() then 
  445. 		char_grp_h = Char_client_grp_h 
  446. 	else 
  447. 		char_grp_h = Char_host_grp_h 
  448. 	end 
  449. 	 
  450. 	Remote_ready = new_value 
  451. 	 
  452. 	if new_value == false then 
  453. 		vint_set_property(char_grp_h, "tint", 0.2, 0.2, 0.2) 
  454. 		game_lobby_show_spinner(false,"") 
  455. 		if game_get_is_host() then 
  456. 			Lobby_data[START_INDEX].disabled = true 
  457. 			Lobby_data[CONTINUE_INDEX].disabled = true 
  458. 			 
  459. 			-- If the remote player is no longer ready and we are doing a countdown, then cancel it 
  460. 			if Local_ready == true then 
  461. 				game_lobby_cancel_ready() 
  462. 			end 
  463. 			 
  464. 			if redraw_list == true then 
  465. 				local last_option_selected = List:get_selection() 
  466. 				List:draw_items(Data, last_option_selected, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  467. 				 
  468. 				if Mouse_input_tracker ~= 0 then 
  469. 					Mouse_input_tracker:remove_all() 
  470. 					List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  471. 					Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  472. 					Mouse_input_tracker:subscribe(true) 
  473. 				end 
  474. 			end 
  475. 		end 
  476. 	else 
  477. 		vint_set_property(char_grp_h, "tint", 1.0, 1.0, 1.0) 
  478. 		local values = { [0] = game_lobby_get_remote_player_name() } 
  479. 		local tag = vint_insert_values_in_string("COOP_LOBBY_IS_READY", values) 
  480. 		game_lobby_show_spinner(false, tag) 
  481. 		 
  482. 		if game_get_is_host() then 
  483. 			Lobby_data[START_INDEX].disabled = false 
  484. 			Lobby_data[CONTINUE_INDEX].disabled = false 
  485. 			game_lobby_update_continue_button() 
  486. 			if redraw_list == true then 
  487. 				local last_option_selected = List:get_selection() 
  488. 				List:draw_items(Data, last_option_selected, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  489. 				 
  490. 				if Mouse_input_tracker ~= 0 then 
  491. 					Mouse_input_tracker:remove_all() 
  492. 					List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  493. 					Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  494. 					Mouse_input_tracker:subscribe(true) 
  495. 				end 
  496. 			end 
  497. 		end 
  498. 	end 
  499. end 
  500.  
  501. function game_lobby_countdown_update(should_display, time_left) 
  502. 	if should_display then 
  503. 		game_UI_audio_play("UI_HUD_Countdown") 
  504. 		game_lobby_show_spinner(false, vint_insert_values_in_string("COOP_LOBBY_GAME_STARTING", { [0] = time_left })) 
  505. 	else  
  506. 		game_lobby_hide_spinner(true) 
  507. 	end 
  508. end 
  509.  
  510. ------------------------------------------------------------------------------- 
  511. -- 
  512. -- MENU SETUP / INITIALIZATION 
  513. -- 
  514. ------------------------------------------------------------------------------- 
  515. -- Sets whether or not the map / character stuff is shown, and updates the 
  516. -- bitmaps whether we're in horde/not horde 
  517. -- 
  518. function game_lobby_set_screen_layout() 
  519. 	local whored_char_info_grp_h = vint_object_find("whored_char_info_grp") 
  520. 	local coop_grp_h = vint_object_find("coop_grp") 
  521. 	 
  522. 	if horde_mode_is_active() then 
  523. 		--Horde mode version... 
  524. 		 
  525. 		--Hide what is not used... 
  526. 		vint_set_property(coop_grp_h, "visible", false)		--coop lobby stuff... 
  527.  
  528. 		 
  529. 		--set game lobby logo, whored mode. 
  530. 		game_lobby_set_logo(true) 
  531. 		 
  532. 		-- Check if we're playing singleplayer or not 
  533. 		if game_coop_get_starting_coop() == true then 
  534. 			-- Coop 
  535. 			-- Hide the client group 
  536. 			game_lobby_show_char(false, false) 
  537.  
  538. 			-- Set the host's name 
  539. 			vint_set_property(Host_name_txt_h, "text_tag", game_lobby_get_local_player_name()) 
  540. 		elseif game_get_is_host() then -- not client 
  541. 			-- Hide the client group 
  542. 			game_lobby_show_char(false, false) 
  543. 			 
  544. 			-- Hide the host name and his speaker 
  545. 			vint_set_property(Host_name_txt_h, "visible", false) 
  546. 			vint_set_property(Host_speak_bmp_h, "visible", false) 
  547. 		else 
  548. 			-- Client, so everyone should be visible 
  549.  
  550. 			-- Set the host's name 
  551. 			vint_set_property(Host_name_txt_h, "text_tag", game_lobby_get_remote_player_name()) 
  552. 			game_lobby_update_ready(false) 
  553. 			 
  554. 			-- Set the client's name 
  555. 			vint_set_property(Client_name_txt_h, "text_tag", game_lobby_get_local_player_name()) 
  556. 		end 
  557. 	else 
  558. 		-- For non-whored mode coop lobby... 
  559. 		vint_set_property(whored_char_info_grp_h, "visible", false) 
  560. 		vint_set_property(coop_grp_h, "visible", true) 
  561. 		 
  562. 		--set game lobby logo, non whored mode. 
  563. 		game_lobby_set_logo(false) 
  564. 		 
  565. 		-- Set bitmaps 
  566. 		-- Saints bitmap... 
  567. 		local saints_bmp_h = vint_object_find("saints_bmp") 
  568. 		vint_set_property(saints_bmp_h, "image", "ui_lobby_char_saints") 
  569. 		 
  570. 		-- Map background... 
  571. 		local map_bmp_h = vint_object_find("level_map_bmp") 
  572. 		vint_set_property(map_bmp_h, "image", "ui_lobby_level_sr3city") 
  573. 	end 
  574. end 
  575.  
  576. -- Create the main lobby list 
  577. -- 
  578. function game_lobby_create_lobby() 
  579. 	local coop_client = false 
  580. 	if game_get_is_host() and game_coop_get_starting_coop() == false then 
  581. 		-- Whored mode single player 
  582. 			MAP_INDEX			= 1 
  583. 			CHARACTER_INDEX	= 2 
  584. 			CONTINUE_INDEX		= 3 
  585. 			START_INDEX			= 4 
  586. 			QUIT_INDEX			= 5 
  587. 	elseif game_get_is_host() then 
  588. 		-- Host Lobby 
  589. 		if game_coop_get_starting_syslink() == true then  
  590. 			FF_INDEX = 1	-- No invite button in sys link 
  591. 			if horde_mode_is_active() then 
  592. 				-- Starting a Horde Mode game, so add those options 
  593. 				MAP_INDEX			= 2 
  594. 				CHARACTER_INDEX	= 3 
  595. 				CONTINUE_INDEX		= 4 
  596. 				START_INDEX			= 5 
  597. 				QUIT_INDEX			= 6 
  598. 				Start_game_button.label = "COOP_LOBBY_COOP_START" 
  599. 				Start_game_button.disabled = true 
  600. 			else 
  601. 				-- Non Horde Mode syslink 
  602. 				START_INDEX = 2 
  603. 				QUIT_INDEX = 3 
  604. 			end 
  605. 		else  
  606. 			INVITE_INDEX 			= 1 
  607. 			if horde_mode_is_active() then 
  608. 				-- Starting a Horde Mode game, so add those options 
  609. 				MAP_INDEX			= 2 
  610. 				CHARACTER_INDEX	= 3 
  611. 				OPTIONS_INDEX 		= 4 
  612. 				CONTINUE_INDEX		= 5 
  613. 				START_INDEX			= 6 
  614. 				QUIT_INDEX			= 7 
  615. 				Start_game_button.label = "COOP_LOBBY_COOP_START" 
  616. 				Start_game_button.disabled = true 
  617. 			else 
  618. 				-- Non Horde Mode Live/PSN 
  619. 				OPTIONS_INDEX		= 2 
  620. 				START_INDEX 		= 3 
  621. 				QUIT_INDEX			= 4 
  622. 			end 
  623. 		end 
  624.  
  625. 	else 
  626. 		-- Client menu 
  627. 		local start_index = 1 
  628. 		coop_client = true 
  629. 		if horde_mode_is_active() then 
  630. 			CHARACTER_INDEX 	= 1 
  631. 			start_index 		= 2 
  632. 		end 
  633. 		MAP_INDEX	= start_index 
  634. 		FF_INDEX 	= start_index + 1 
  635. 		START_INDEX = start_index + 2		-- Sets the player in the ready state 
  636. 		QUIT_INDEX 	= start_index + 3 
  637. 		Start_game_button.label = "COOP_LOBBY_CLIENT_READY" 
  638. 		Start_game_button.owned = true 
  639. 		Start_game_button.equipped = false 
  640. 		--Start_game_button.is_checked = false 
  641. 		-- Get FF Updates from host 
  642. 		FF_button.disabled = true	 
  643. 		Map_button.disabled = true 
  644. 		vint_dataitem_add_subscription("friendly_fire_data", "update", "game_lobby_update_ff") 
  645. 	end 
  646.  
  647. 	-- Set all the menu buttons based on the indexes 
  648. 	Lobby_data[INVITE_INDEX]		= Invite_button 
  649. 	Lobby_data[MAP_INDEX]			= Map_button 
  650. 	Lobby_data[CHARACTER_INDEX]	= Character_button 
  651. 	Lobby_data[OPTIONS_INDEX]		= Cooptions_button 
  652. 	Lobby_data[CONTINUE_INDEX]		= Continue_button 
  653. 	Lobby_data[START_INDEX]			= Start_game_button 
  654. 	Lobby_data[QUIT_INDEX]			= Quit_game_button 
  655. 	if coop_client == true or game_coop_get_starting_syslink() then 
  656. 		Lobby_data[FF_INDEX]			= FF_button 
  657. 		--Lobby_data[MAP_INDEX]		= Map_button 
  658. 	else  
  659. 		Cooptions_data[PRIVACY_INDEX]	= Privacy_button 
  660. 		Cooptions_data[FF_INDEX] 		= FF_button 
  661. 	end 
  662. 	-- Items that weren't available overwrote -1, so set it back to nil	 
  663. 	Lobby_data[UNAVAILABLE_INDEX]	= nil 
  664.  
  665. 	-- Get the defaults for these buttons 
  666. 	Privacy_button.current_value = game_get_coop_join_type() + 1 
  667. 	FF_button.current_value = game_get_coop_friendly_fire() + 1 -- the values reverse the options 
  668. 	 
  669. 	-- For horde mode, setup the additional displays 
  670. 	if horde_mode_is_active() then 
  671. 		-- Populate the map options with the map names 
  672. 		Map_button.options = { } 
  673. 		Map_button.options_data = { } 
  674. 		Horde_button = Map_button 
  675. 		vint_dataresponder_request("horde_mode_lobby_populate", "game_lobby_populate_horde_data", 0, HMLD_MAPS) 
  676. 		 
  677. 		Horde_mode_continue = false 
  678. 				 
  679. 		-- Populate the character options with character names 
  680. 		Character_button.options = { } 
  681. 		Character_button.options_data = { } 
  682. 		Horde_button = Character_button 
  683. 		vint_dataresponder_request("horde_mode_lobby_populate", "game_lobby_populate_horde_data", 0, HMLD_CHARS) 
  684. 		 
  685. 		game_lobby_update_map_selection(Map_button.options_data[Map_button.current_value].id) 
  686. 		game_lobby_update_char_selection(Character_button.options_data[Character_button.current_value].id) 
  687.  
  688. 		game_lobby_update_char_display(game_get_is_host(), Character_button.current_value) 
  689. 		game_lobby_update_map_display() 
  690. 		game_lobby_update_continue_button() 
  691. 		 
  692. 		if (game_get_is_host() and game_coop_get_starting_coop() ) then 
  693. 			Lobby_data[START_INDEX].disabled = true 
  694. 			Lobby_data[CONTINUE_INDEX].disabled = true 
  695. 		end 
  696. 		 
  697. 		-- SEH: 8/6/2011: changed following so server isn't ready, as we want to be able to wait until both the server and host say they are ready. 
  698. 		game_lobby_update_local_ready(false) 
  699. 	end 
  700.  
  701. 	-- If coop is already active when the Whored Mode lobby opens, allow immediate access 
  702. 	-- to the start button 
  703. 	if (game_get_is_host() and coop_is_active() and horde_mode_is_active()) then 
  704. 		game_lobby_joined(true)	 
  705. 	end 
  706.  
  707.  
  708. end 
  709.  
  710. function game_lobby_populate_horde_data(display_name, internal_name, id) 
  711. 	local index = #Horde_button.options + 1 
  712. 	Horde_button.options[index] = display_name 
  713. 	Horde_button.options_data[index] = { display_name = display_name, internal_name = internal_name, id = id } 
  714. end 
  715.  
  716. --------------------------- 
  717. -- Show the main lobby Menu 
  718. -- 
  719. function game_lobby_show_main() 
  720. 	if Invite_show_thread ~= -1 then 
  721. 		thread_kill(Invite_show_thread) 
  722. 		Invite_show_thread = -1 
  723. 	end 
  724. 	In_invite = false	 
  725. 	 
  726. 	Num_friends = 0 
  727. 	Party_invite = false 
  728.  
  729. 	build_hint_bar() 
  730. 	 
  731. 	Back_callback = -1	-- No back from here 
  732. 	Data = Lobby_data 
  733. 	List:draw_items(Data, 1, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  734. 	 
  735. 	if Mouse_input_tracker ~= 0 then 
  736. 		Mouse_input_tracker:remove_all() 
  737. 		List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  738. 		Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  739. 		Mouse_input_tracker:subscribe(true) 
  740. 	end 
  741.  
  742. 	Menu_has_shown = true 
  743. end 
  744.  
  745. ------------------------------------------------------------------------------- 
  746. -- 
  747. -- SPINNER FUNCTIONALTIY 
  748. -- 
  749. ------------------------------------------------------------------------------- 
  750. -- Set "Waiting for player" text if we're in coop.  
  751. -- Single player whored mode shows nothing here. 
  752. -- 
  753. function game_lobby_set_waiting_prompt() 
  754. 	if game_coop_get_starting_coop() then 
  755. 		if game_get_is_host() == true then 
  756. 			game_lobby_show_spinner(true, "COOP_LOBBY_WAITING") 
  757. 		else 
  758. 			local values = { [0] = game_lobby_get_remote_player_name() } 
  759. 			local tag = vint_insert_values_in_string("COOP_LOBBY_WAITING_FOR_HOST", values) 
  760. 			game_lobby_show_spinner(false, tag) 
  761. 		end 
  762. 	else  
  763. 		game_lobby_hide_spinner() 
  764. 	end 
  765. end 
  766.  
  767. ------------------------------------------------------------ 
  768. -- Shows spinner 
  769. -- @param	show_spinner		spinner on or off 
  770. -- @param	text					text to appear next to spinner 
  771. -- 
  772. function game_lobby_show_spinner(show_spinner, text) 
  773. 	local spinner_h = vint_object_find("spinner_grp") 
  774. 	local player_waiting_txt_h = vint_object_find("player_waiting_txt") 
  775. 	local spinny_anim_h = vint_object_find("spinny_anim") 
  776. 	if show_spinner then 
  777. 		lua_play_anim(spinny_anim_h) 
  778. 		vint_set_property(spinner_h, "visible", true) 
  779. 	else 
  780. 		vint_set_property(spinner_h, "visible", false) 
  781. 	end 
  782. 	 
  783. 	if Data == Lobby_data then 
  784. 		local last_option_selected = List:get_selection() 
  785. 		List:draw_items(Data, last_option_selected, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  786. 		 
  787. 		if Mouse_input_tracker ~= 0 then 
  788. 			Mouse_input_tracker:remove_all() 
  789. 			List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  790. 			Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  791. 			Mouse_input_tracker:subscribe(true) 
  792. 		end 
  793. 	end 
  794.  
  795. 	if text ~= nil then 
  796. 		--Set Text 
  797. 		vint_set_property(player_waiting_txt_h, "visible", true) 
  798. 		vint_set_property(player_waiting_txt_h, "text_tag", text) 
  799. 	else 
  800. 		vint_set_property(player_waiting_txt_h, "visible", false)		 
  801. 	end 
  802. end 
  803.  
  804. ------------------------------------------------------------ 
  805. -- Hides the spinner and waiting text 
  806. function game_lobby_hide_spinner() 
  807. 	local spinner_h = vint_object_find("spinner") 
  808. 	local player_waiting_txt_h = vint_object_find("player_waiting_txt") 
  809. 	vint_set_property(spinner_h, "visible", false) 
  810. 	vint_set_property(player_waiting_txt_h, "visible", false) 
  811. end 
  812.  
  813. ------------------------------------------------------------------------------- 
  814. -- Sets the style logo depending on what mode we are in 
  815. -- @is_whored_mode	bool true if in whored mode... 
  816. function game_lobby_set_logo(is_whored_mode) 
  817. 	 
  818. 	local game_logo_grp_h = vint_object_find("game_logo_grp") 
  819. 	local whored_logo_grp_h = vint_object_find("whored_logo_grp") 
  820. 	vint_set_property(game_logo_grp_h, "visible", false) 
  821. 	vint_set_property(whored_logo_grp_h, "visible", false) 
  822.  
  823. 	if is_whored_mode then 
  824. 		--whored mode style logo... 
  825. 		vint_set_property(whored_logo_grp_h, "visible", true) 
  826. 		--set logo 
  827. 		local logo_bmp_h = vint_object_find("whored_logo_bmp")  
  828. 		vint_set_property(logo_bmp_h, "image", "ui_whored_logo") 
  829. 		vint_set_property(logo_bmp_h, "visible", true) 
  830. 	else 
  831. 		vint_set_property(game_logo_grp_h, "visible", true) 
  832. 		local logo_bmp_h = vint_object_find("game_logo_bmp") 
  833. 		vint_set_property(logo_bmp_h, "image", "ui_whored_logo_game") 
  834. 	end 
  835. end 
  836.  
  837. ------------------------------------------------------------------------------- 
  838. -- 
  839. -- LOBBY FUNCTIONALITY 
  840. -- 
  841. ------------------------------------------------------------------------------- 
  842. -- Initiate a single player game 
  843. -- (Horde or Regular) 
  844. -- 
  845. function game_lobby_start_single_player() 
  846.  
  847. 	if horde_mode_is_active() then 
  848. 	  -- Horde_mode_continue should only be true if the player has hit the continue button 
  849. 		game_lobby_set_horde_mode_data(Horde_mode_continue) 
  850. 	else 
  851. 		game_lobby_coop_finished() 
  852. 	end 
  853. 	game_UI_audio_play("UI_Main_Menu_Select") 
  854. end 
  855.  
  856. ------------------------------------------------------------------------ 
  857. -- Dialog Confirmation Callback for start with a joining client 
  858. -- @param 	result				Yes / No to kick the joining coop player 
  859. -- @param	action				Make sure this was closed (should always be in SR3) 
  860. -- 
  861. function game_lobby_sp_start_confim(result, action) 
  862. 	if result == 0 then 
  863. 		game_kick_coop_player(true) 
  864. 		game_lobby_start_single_player() 
  865. 	end 
  866. end 
  867.  
  868. -------------------------------------------------------- 
  869. -- Called from C when the countdown to start is complete 
  870. -- 
  871. function game_lobby_countdown_game_start() 
  872. 	if horde_mode_is_active() and game_get_is_host() then 
  873. 		-- Horde_mode_continue should only be true if the player has hit the continue button 
  874. 		game_lobby_set_horde_mode_data(Horde_mode_continue) 
  875. 	else 
  876. 		game_lobby_coop_finished() 
  877. 	end 
  878. end 
  879.  
  880. ------------------------------------------------------ 
  881. -- Respond to Start game button 
  882. -- Prompts to kick a joining coop player if necessary 
  883. -- 
  884. function game_lobby_start_game() 
  885. 	if game_get_is_host() == false then 
  886. 		if horde_mode_is_active() then 
  887. 			if Local_ready then 
  888. 				game_lobby_update_local_ready(false) 
  889. 			else 
  890. 				game_lobby_update_local_ready(true) 
  891. 			end 
  892. 		end 
  893. 		return 
  894. 	end 
  895. 	 
  896. 	if Join_completed == false then 
  897. 		if Connected == true then 
  898. 			-- If a join hasn't been completed, but someone is joining, prompt to kick them 
  899. 			dialog_box_confirmation("CONTROL_START_GAME", "COOP_SINGLE_PLAYER_KICK_MSG", "game_lobby_sp_start_confim", nil, nil, 1) 
  900. 		else  
  901. 			-- If the no one is connected, continue on with a start 
  902. 			game_lobby_start_single_player() 
  903. 		end 
  904. 	else  
  905. 		-- Join's complete 
  906. 		if horde_mode_is_active() then 
  907. 			-- Set us ready! 
  908. 			game_lobby_update_local_ready(Local_ready ~= true) 
  909. 			return 
  910. 		end 
  911. 		game_lobby_coop_finished() 
  912. 	end 
  913. end 
  914.  
  915. ------------------------------------------------------------------ 
  916. -- Set horde mode continuing to true, and go to normal start logic 
  917. -- 
  918. function game_lobby_whored_continue_game() 
  919. 	-- Horde_mode_continue should only be true if the player has hit the continue button 
  920. 	Horde_mode_continue = true 
  921. 	game_lobby_start_game() 
  922. end 
  923.  
  924. ------------------------------------------------------------------------ 
  925. -- Dialog Confirmation Callback for quitting to main menu 
  926. -- @param 	result				Yes / No  
  927. -- @param	action				Make sure this was closed (should always be in SR3) 
  928. -- 
  929. function game_lobby_confirm_quit(result, action) 
  930. 	if result == 0 then 
  931. 		Input_tracker:subscribe(false) 
  932. 		if Mouse_input_tracker ~= 0 then 
  933. 			Mouse_input_tracker:remove_all() 
  934. 			Mouse_input_tracker:subscribe(false) 
  935. 		end 
  936. 		pause_menu_quit_game_internal() 
  937. 	end 
  938. end 
  939.  
  940. --------------------------------------------- 
  941. -- Confirm we want to return to the main menu 
  942. -- 
  943. function game_lobby_quit() 
  944. 	dialog_box_confirmation("PAUSE_MENU_QUIT_TITLE","QUIT_GAME_TEXT_FULL","game_lobby_confirm_quit", nil, nil, 1) 
  945. end 
  946.  
  947. ------------------------------------------ 
  948. -- Called when a toggle option is changed 
  949. -- 
  950. function game_lobby_change_option() 
  951. 	local option_id = List:get_id() 
  952. 	 
  953. 	if option_id == ID_PRIV then 
  954. 		game_set_coop_join_type(Privacy_button.current_value - 1) 
  955. 	elseif option_id == ID_FF then 
  956. 		game_set_coop_friendly_fire(FF_button.current_value - 1) 
  957. 	elseif option_id == ID_MAP then 
  958. 		game_lobby_update_map_selection(Map_button.options_data[Map_button.current_value].id) 
  959. 		game_lobby_update_map_display() 
  960. 		game_lobby_update_continue_button() 
  961. 	elseif option_id == ID_CHARACTER then 
  962. 		game_lobby_update_char_selection(Character_button.options_data[Character_button.current_value].id) 
  963. 		game_lobby_update_char_display(game_get_is_host(), Character_button.current_value) 
  964. 	end 
  965.  
  966. 	local selection = List:get_selection() 
  967. 	List:draw_items(Data, selection, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  968. 	 
  969. 	if Mouse_input_tracker ~= 0 then 
  970. 		Mouse_input_tracker:remove_all() 
  971. 		List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  972. 		Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  973. 		Mouse_input_tracker:subscribe(true) 
  974. 	end 
  975. end 
  976.  
  977. ------------------------------------------------------------------------------ 
  978. -- Update the map image from global data. 
  979. -- 
  980. function game_lobby_update_map_display() 
  981. 	local map_bmp_h = vint_object_find("level_map_bmp") 
  982. 	local map_img_name = Map_image_names[Map_button.options_data[Map_button.current_value].internal_name] 
  983. 	vint_set_property(map_bmp_h, "image", map_img_name) 
  984. end 
  985.  
  986. ------------------------------------------------------------------------------- 
  987. -- Update the character image and name 
  988. -- 
  989. -- @host_update	true if we are the host, false for client 
  990. -- @value			internal name of the character. 
  991. -- 
  992. function game_lobby_update_char_display(host_update, value) 
  993. 	local char_name_h 
  994. 	local char_bmp_h 
  995. 	if host_update == true then 
  996. 		char_bmp_h = Host_char_bmp_h 
  997. 	else  
  998. 		game_lobby_show_char(false, true) 
  999. 		vint_set_property(Client_speak_bmp_h, "visible", false) 
  1000. 		char_bmp_h = Client_char_bmp_h 
  1001. 	end 
  1002. 	local char_img_name = Char_image_names[Character_button.options_data[value].internal_name] 
  1003. 	vint_set_property(char_bmp_h, "image", char_img_name) 
  1004. end 
  1005.  
  1006. ------------------------------------------------------------------------------- 
  1007. -- Shows or hides client or host images and text 
  1008. -- 
  1009. -- @host_update	true if we are the host, false for client 
  1010. -- @value			internal name of the character. 
  1011. -- 
  1012. function game_lobby_show_char(host_update, is_visible) 
  1013. 	local bmp_h 
  1014. 	local info_grp_h  
  1015. 	if host_update then 
  1016. 		bmp_h			= Host_char_bmp_h 
  1017. 		info_grp_h	= Host_info_grp_h 
  1018. 	else 
  1019. 		bmp_h			= Client_char_bmp_h 
  1020. 		info_grp_h	= Client_info_grp_h 
  1021. 	end 
  1022. 	vint_set_property(bmp_h, "visible", is_visible) 
  1023. 	vint_set_property(info_grp_h, "visible", is_visible) 
  1024. end 
  1025.  
  1026.  
  1027. function game_lobby_cancel_ready() 
  1028. 	game_lobby_update_local_ready(false) 
  1029. 	if game_get_is_host() then 
  1030. 		game_lobby_show_main() 
  1031. 	end 
  1032. end 
  1033.  
  1034. function game_lobby_start_dialog_canceled() 
  1035. 	Local_ready = false 
  1036. 	Horde_mode_continue = false 
  1037. 	Start_game_button.on_select = game_lobby_start_game 
  1038. end 
  1039.  
  1040. ------------------------------------------------ 
  1041. -- Update the ready display for the local player 
  1042. -- and send the changed ready state to C 
  1043. function game_lobby_update_local_ready(ready) 
  1044. 	game_lobby_update_ready_state(ready) 
  1045. 	Local_ready = ready 
  1046. 	 
  1047. 	if game_get_is_host() == false then 
  1048. 		Start_game_button.equipped = ready 
  1049. 		game_UI_audio_play("UI_Main_Menu_Select") 
  1050. 	end 
  1051. 	 
  1052. 	-- Swap the list and add cancel 
  1053. 	if Local_ready then 
  1054. 		if Remote_ready ~= true then 
  1055. 			-- Set spinner text to "Waiting for " 
  1056. 		end 
  1057.  
  1058. 		Start_game_button.on_select = game_lobby_cancel_ready 
  1059. 	else 
  1060. 		Horde_mode_continue = false 
  1061. 		Start_game_button.on_select = game_lobby_start_game 
  1062. 	end 
  1063. 	 
  1064. 	local selection = List:get_selection() 
  1065. 	Data = Lobby_data 
  1066. 	List:draw_items(Data, selection, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  1067. 	 
  1068. 	if Mouse_input_tracker ~= 0 then 
  1069. 		Mouse_input_tracker:remove_all() 
  1070. 		List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1071. 		Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1072. 		Mouse_input_tracker:subscribe(true) 
  1073. 	end 
  1074.  
  1075. 	if game_get_is_host() and game_coop_get_starting_coop() == false then 
  1076. 		game_lobby_hide_spinner(true) 
  1077. 	end 
  1078. end 
  1079.  
  1080. ----------------------------------------------------- 
  1081. -- Update the continue button to show wave number 
  1082. -- or be disabled 
  1083. -- 
  1084. function game_lobby_update_continue_button() 
  1085. 	if game_get_is_host() then 
  1086. 		local continue_wave = game_lobby_horde_continue_from_wave() 
  1087. 		if continue_wave == -1 then 
  1088. 			Continue_button.label = "CONTROL_CONTINUE" 
  1089. 			Continue_button.disabled = true 
  1090. 		else 
  1091. 			local tag = vint_insert_values_in_string("COOP_LOBBY_CONTINUE_WAVE", { [0] = continue_wave }) 
  1092. 			Continue_button.label = tag 
  1093. 			 
  1094. 			-- Allow the Continue button name to be updated above, but only enable the button if the 
  1095. 			-- remote player has said they are ready 
  1096. 			if (Remote_ready == false) and (game_coop_get_starting_coop() == true) then 
  1097. 				Continue_button.disabled = true 
  1098. 			else 
  1099. 				Continue_button.disabled = false 
  1100. 			end 
  1101. 		end 
  1102. 	else 
  1103. 		Continue_button.label = "CONTROL_CONTINUE" 
  1104. 		Continue_button.disabled = true 
  1105. 	end 
  1106. end 
  1107.  
  1108. ----------------------------------------------------- 
  1109. -- Kick the client. Prompts with a dialog internally 
  1110. -- 
  1111. function game_lobby_kick() 
  1112. 	game_coop_kick_player() 
  1113. end 
  1114.  
  1115. --------------------------------- 
  1116. -- Show the coop options menu 
  1117. -- 
  1118. function game_lobby_coop_options() 
  1119. 	Data = Cooptions_data 
  1120. 	List:draw_items(Data) 
  1121. 	 
  1122. 	game_UI_audio_play("UI_Main_Menu_Select") 
  1123. 	 
  1124. 	Show_partner_gamercard = false 
  1125. 	 
  1126. 	local hint_data = { 
  1127. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  1128. 	} 
  1129. 	Hint_bar:set_hints(hint_data) 
  1130. 	Hint_bar:set_visible(true) 
  1131. 	 
  1132. 	if Mouse_input_tracker ~= 0 then 
  1133. 		Mouse_input_tracker:remove_all() 
  1134. 		List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1135. 		Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1136. 		Mouse_input_tracker:subscribe(true) 
  1137. 	end 
  1138. end 
  1139.  
  1140. -------------------------------------------------- 
  1141. -- When the Friendly Fire option changes, update it 
  1142. -- (Client only) 
  1143. -- 
  1144. function game_lobby_update_ff(data_item_handle, event_name) 
  1145. 	if game_get_is_host() or Menu_has_shown == false then 
  1146. 		return 
  1147. 	end 
  1148. 	 
  1149. 	local ff_option = vint_dataitem_get(data_item_handle) 
  1150. 	FF_button.current_value = ff_option + 1 
  1151.  
  1152. 	-- Redraw the current menu 
  1153. 	local last_option_selected = List:get_selection() 
  1154. 	List:draw_items(Data, last_option_selected, LOBBY_LIST_WIDTH) 
  1155. 	 
  1156. 	if Mouse_input_tracker ~= 0 then 
  1157. 		Mouse_input_tracker:remove_all() 
  1158. 		List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1159. 		Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1160. 		Mouse_input_tracker:subscribe(true) 
  1161. 	end 
  1162. end 
  1163.  
  1164. ------------------------------------------------------------------------------- 
  1165. -- 
  1166. -- INVITE FRIEND 
  1167. -- 
  1168. ------------------------------------------------------------------------------- 
  1169. -- Spawn a thread to show the invite interface 
  1170. -- (It may have to yield for the dataresponder, so use another thread 
  1171. --  
  1172. function game_lobby_show_invite() 
  1173. 	In_invite = true 
  1174. 	if Invite_show_thread == -1 then 
  1175. 		Invite_show_thread = thread_new("game_lobby_retrieve_invite") 
  1176. 	end 
  1177. end 
  1178.  
  1179. ------------------------------------------ 
  1180. -- Thread to get the friends list 
  1181. -- 
  1182. function game_lobby_retrieve_invite() 
  1183.  
  1184. 	-- Show "Searching" while the other data responder goes for it 
  1185. 	Data = {	[1] = { type = TYPE_BUTTON, label = "MENU_SEARCHING", id = -1,	disabled = true }, 	} 
  1186. 	List:draw_items(Data, 1, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  1187. 	--if Mouse_input_tracker ~= 0 then 
  1188. 	--	List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1189. 	--	Mouse_input_tracker:subscribe(true) 
  1190. 	--end 
  1191.  
  1192. 	Num_friends = 0 
  1193. 	build_hint_bar(true, true) 
  1194. 	 
  1195. 	if Mouse_input_tracker ~= 0 then 
  1196. 		Mouse_input_tracker:remove_all() 
  1197. 		--List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1198. 		Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1199. 		Mouse_input_tracker:subscribe(true) 
  1200. 	end 
  1201.  
  1202. 	delay(.5) -- Make sure we show that "Searching" message for at least half a second. 
  1203.  
  1204. 	-- Populate the friends list 
  1205. 	while true do 
  1206. 	 
  1207. 		Data = { } 
  1208. 		Num_friends = 0 
  1209. 		vint_dataresponder_request("coop_list_responder", "game_lobby_invite_populate", 0, COOP_INVITE_LIST) 
  1210.  
  1211. 		-- Check for no friends found 
  1212. 		if Num_friends == 0 then 
  1213. 			Data = {	[1] = {	type = TYPE_BUTTON, label = "MENU_NO_FRIENDS_FOUND", id = -1, disabled = true	}	} 
  1214. 		end 
  1215.  
  1216. 		--Get the selection option from when the menu was last loaded 
  1217. 		local current_index = 1 
  1218. 		if Num_friends > 0 then 
  1219. 			current_index = min(List:get_selection(), Num_friends) 
  1220. 		end 
  1221. 		List:draw_items(Data, current_index, LOBBY_LIST_WIDTH, LOBBY_LIST_MAX_ITEMS, LOBBY_LIST_SCALE, LOBBY_LIST_FORCE_SCALE) 
  1222. 		 
  1223.  
  1224. 		build_hint_bar(true) 
  1225. 		Input_tracker:subscribe(true) 
  1226.  
  1227. 		if Mouse_input_tracker ~= 0 then 
  1228. 			Mouse_input_tracker:remove_all() 
  1229. 			List:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1230. 			Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1231. 			Mouse_input_tracker:subscribe(true) 
  1232. 		end 
  1233. 		 
  1234. 		if game_get_platform() == "PC" then -- Only search once on PC 
  1235. 			break 
  1236. 		end 
  1237. 		 
  1238. 		delay(2.0) 
  1239. 	end 
  1240. 	 
  1241. 	-- Clear thread 
  1242. 	Invite_show_thread = -1 
  1243. end 
  1244.  
  1245. --------------------------------------------- 
  1246. -- Populate the invite list 
  1247. -- @param 	name				Name of the friend 
  1248. -- 
  1249. function game_lobby_invite_populate(name) 
  1250. 	Num_friends = Num_friends + 1 
  1251. 	Data[Num_friends] = { type = TYPE_BUTTON, label = name, on_select = game_lobby_invite_friend, on_alt_select = game_lobby_view_gamercard, id = (Num_friends - 1) } 
  1252. end 
  1253.  
  1254. --------------------------------------- 
  1255. -- Show the selected friend's gamercard 
  1256. -- 
  1257. function game_lobby_view_gamercard() 
  1258. 	game_show_coop_gamercard(List:get_selection() - 1) 
  1259. end 
  1260.  
  1261. ------------------------------- 
  1262. -- Invite the selected friend 
  1263. -- 
  1264. function game_lobby_invite_friend() 
  1265. 	local friend_index = List:get_id() 
  1266. 	local insert_values = { [0] = Data[List:get_selection()].label } 
  1267. 	local body = vint_insert_values_in_string("MP_INVITE_SENT_BODY", insert_values) 
  1268.  
  1269. 	if game_can_send_player_invite(friend_index) == false then 
  1270. 		return 
  1271. 	end 
  1272.  
  1273. 	game_send_pause_menu_player_invite(friend_index) -- offset index by 1 
  1274. 	dialog_box_message("MP_INVITE_SENT_TITLE", body) 
  1275. end 
  1276.  
  1277. --------------------------------- 
  1278. -- 
  1279. -- Input handlers 
  1280. -- 
  1281. --------------------------------- 
  1282. function game_lobby_button_a(event, acceleration) 
  1283.  
  1284. 	if sfx_faded_out() then 
  1285. 		return 
  1286. 	end 
  1287.  
  1288. 	local current_id = List:get_id() 
  1289. 	local current_index = List:get_selection() 
  1290.  
  1291. 	--Do something different on our toggle options... 
  1292. 	if Data[current_index].type == TYPE_TOGGLE then 
  1293. 		-- Move highlight right 
  1294. 		List:move_slider(1) 
  1295. 		if Data[current_index].on_change ~= nil then 
  1296. 			Data[current_index].on_change() 
  1297. 		end 
  1298. 		return 
  1299. 	end 
  1300. 	 
  1301. 	if Data[current_index].on_select ~= nil then 
  1302. 		if Data[current_index].set_back_callback ~= nil then 
  1303. 			Back_callback = Data[current_index].set_back_callback 
  1304. 		end 
  1305. 		Data[current_index].on_select() 
  1306. 	end 
  1307. end 
  1308.  
  1309. function game_lobby_button_b(event, acceleration) 
  1310. 	if Back_callback ~= nil and Back_callback ~= -1 then 
  1311. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  1312. 		Back_callback() 
  1313. 	end 
  1314. end 
  1315.  
  1316. function game_lobby_button_x(event, acceleration) 
  1317.  
  1318. 	if sfx_faded_out() then 
  1319. 		return 
  1320. 	end 
  1321.  
  1322. 	local current_index = List:get_selection() 
  1323.  
  1324. 	if Data[current_index].on_alt_select ~= nil then 
  1325. 		Data[current_index].on_alt_select() 
  1326. 	elseif Show_partner_gamercard then -- only show the gamercard while on the top menu 
  1327. 		game_show_coop_partner_gamercard() 
  1328. 	end 
  1329. end 
  1330.  
  1331. function game_lobby_button_y() 
  1332.  
  1333. 	if sfx_faded_out() then 
  1334. 		return 
  1335. 	end 
  1336.  
  1337. 	if Party_invite then 
  1338. 		game_send_party_invites() 
  1339. 	elseif Can_refresh_friend_list then 
  1340. 		if Invite_show_thread == -1 then 
  1341. 			Invite_show_thread = thread_new("game_lobby_retrieve_invite") 
  1342. 		end 
  1343. 	end 
  1344. end 
  1345.  
  1346. function game_lobby_button_start() 
  1347. end 
  1348.  
  1349. function game_lobby_nav_up(event, acceleration) 
  1350. 	-- Move highlight up 
  1351. 	List:move_cursor(-1) 
  1352. end 
  1353.  
  1354. function game_lobby_nav_down(event, acceleration) 
  1355. 	-- Move highlight down 
  1356. 	List:move_cursor(1) 
  1357. end 
  1358.  
  1359. function game_lobby_nav_left(event, acceleration) 
  1360. 	local current_index = List:get_selection() 
  1361. 	if current_index < 0 then 
  1362. 		return 
  1363. 	end 
  1364. 	 
  1365. 	-- Move highlight left	 
  1366. 	List:move_slider(-1) 
  1367. 	if Data[current_index].on_change ~= nil then 
  1368. 		Data[current_index].on_change() 
  1369. 	end 
  1370. end 
  1371.  
  1372. function game_lobby_nav_right(event, acceleration) 
  1373. 	local current_index = List:get_selection() 
  1374. 	if current_index < 0 then 
  1375. 		return 
  1376. 	end 
  1377.  
  1378. 	-- Move highlight right 
  1379. 	List:move_slider(1) 
  1380. 	if Data[current_index].on_change ~= nil then 
  1381. 		Data[current_index].on_change() 
  1382. 	end 
  1383. end 
  1384.  
  1385. -- Mouse inputs 
  1386. function game_lobby_mouse_click(event, target_handle, mouse_x, mouse_y) 
  1387.  
  1388. 	if sfx_faded_out() then 
  1389. 		return 
  1390. 	end 
  1391.  
  1392. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  1393. 	if hint_index == 1 then 
  1394. 		if Show_partner_gamercard then 
  1395. 			game_lobby_button_x() 
  1396. 		else 
  1397. 			game_lobby_button_b() 
  1398. 		end 
  1399. 	elseif hint_index == 2 then 
  1400. 		game_lobby_button_x() 
  1401. 	elseif hint_index == 3 then 
  1402. 		game_lobby_button_y() 
  1403. 	end 
  1404. 	 
  1405. 	local new_index = List:get_button_index(target_handle) 
  1406. 	if new_index ~= 0 then 
  1407. 		List:set_selection(new_index) 
  1408. 		game_lobby_button_a() 
  1409. 	end 
  1410. 	 
  1411. 	local current_index = List:get_selection() 
  1412. 	if List:is_left_arrow(target_handle) then 
  1413. 		List:move_slider(-1) 
  1414. 		if Data[current_index].on_change ~= nil then 
  1415. 			Data[current_index].on_change() 
  1416. 		end 
  1417. 	elseif List:is_right_arrow(target_handle) then 
  1418. 		List:move_slider(1) 
  1419. 		if Data[current_index].on_change ~= nil then 
  1420. 			Data[current_index].on_change() 
  1421. 		end 
  1422. 	end 
  1423. 	if List:is_slider(target_handle) then 
  1424. 		List:move_slider(0, mouse_x) 
  1425. 		if Data[current_index].on_change ~= nil then 
  1426. 			Data[current_index].on_change() 
  1427. 		end 
  1428. 	end 
  1429. end 
  1430.  
  1431. function game_lobby_mouse_move(event, target_handle) 
  1432. 	Hint_bar:set_highlight(0) 
  1433. 	 
  1434. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  1435. 	if hint_index ~= 0 then 
  1436. 		Hint_bar:set_highlight(hint_index) 
  1437. 	end 
  1438. 	 
  1439. 	local new_index = List:get_button_index(target_handle) 
  1440. 	if new_index ~= 0 then 
  1441. 		List:set_selection(new_index) 
  1442. 		List:move_cursor(0, true) 
  1443. 	end 
  1444. end 
  1445.  
  1446. function game_lobby_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  1447. 	if List.scrollbar.tab.handle == target_handle then 
  1448. 		local new_start_index = List.scrollbar:drag_scrolltab(mouse_y, List.num_buttons - (List.max_buttons - 1)) 
  1449. 		List:scroll_list(0, new_start_index) 
  1450. 	end 
  1451. end 
  1452.  
  1453. function game_lobby_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  1454. end 
  1455.  
  1456. function game_lobby_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  1457. 	if scroll_lines ~= 0 then 
  1458. 		if List:get_scroll_region_handle() == target_handle then 
  1459. 			List:scroll_list(scroll_lines * -1) 
  1460. 			List:update_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1461. 			Hint_bar:add_mouse_inputs("game_lobby", Mouse_input_tracker) 
  1462. 			Mouse_input_tracker:subscribe(true) 
  1463. 		end 
  1464. 	end 
  1465. end 
  1466.  
  1467. -- List data 
  1468. ------------------------------------------------------------------------------- 
  1469. Invite_button 		= { 	type = TYPE_BUTTON, label = "COOP_MENU_INVITE", on_select = game_lobby_show_invite, set_back_callback = game_lobby_show_main 		} 
  1470. Kick_button 		= { 	type = TYPE_BUTTON, label = "CONTROL_KICK_PLAYER", on_select = game_lobby_kick 																	} 
  1471. Cooptions_button	= {	type = TYPE_BUTTON, label = "COOP_OPTIONS", on_select = game_lobby_coop_options, set_back_callback = game_lobby_show_main 			} 
  1472. Start_game_button	= { 	type = TYPE_BUTTON, label = "COOP_LOBBY_START_GAME", on_select = game_lobby_start_game 														} 
  1473. Quit_game_button	= {	type = TYPE_BUTTON, label = "COOP_LOBBY_QUIT", on_select = game_lobby_quit,																		} 
  1474. -- Coop options, Cooptions. 
  1475. Privacy_button		= { 	type = TYPE_TOGGLE,	label = "COOP_MENU_PRIVACY", on_change = game_lobby_change_option, id = ID_PRIV, 
  1476. 								options = {"COOP_MENU_OPEN", "COOP_MENU_FRIENDS_ONLY", "COOP_MENU_PRIVATE"}, current_value = 1 												} 
  1477. FF_button 			= { 	type = TYPE_TOGGLE, label = "COOP_MENU_FRIENDLY_FIRE", on_change = game_lobby_change_option, id = ID_FF, 
  1478. 								options = {"COOP_MENU_FULL_DAMAGE", "COOP_MENU_LIGHT_DAMAGE", "MENU_NONE"},	current_value = 1 											} 
  1479. -- Whored Mode buttons 
  1480. Continue_button 	= { 	type = TYPE_BUTTON, label = "CONTROL_CONTINUE", on_select = game_lobby_whored_continue_game													} 
  1481. Map_button			= {	type = TYPE_TOGGLE, label = "COOP_LOBBY_MAP", on_change = game_lobby_change_option, id = ID_MAP,  
  1482. 								options = { "Test", "Test 2" }, current_value = 1																											} 
  1483. Character_button	= { 	type = TYPE_TOGGLE, label = "COOP_LOBBY_CHARACTER", on_change = game_lobby_change_option, id = ID_CHARACTER,							 
  1484. 								options = { "Test", "Test 2" }, current_value = 1																											} 
  1485.