sr2lua/mp_match_load.lua

  1. -- Variable section 
  2. Mp_match_load_data = { 
  3. 	player_data = {}, 
  4. 	current_game = {}, 
  5. 	current_state = 0, 
  6. 	handles = {}, 
  7. 	first_update = true, 
  8. 	is_matchmaking = true, 
  9. 	first_state = true, 
  10. 	tip_thread = 0, 
  11. 	map_thread = 0, 
  12. 	old_map = -1, 
  13. 	old_tip = -1, 
  14. 	map_images = {}, 
  15. } 
  16.  
  17. -- Init and cleanup functions 
  18. function mp_match_load_init() 
  19. 	-- Load Pegs 
  20. 	peg_load("ui_mp_lobbywindow") 
  21. 	 
  22. 	-- Set up all the object handles 
  23. 	Mp_match_load_data.handles.player_line = vint_object_find("player_line") 
  24. 	Mp_match_load_data.handles.current_action_h = vint_object_find("current_action") 
  25. 	Mp_match_load_data.handles.current_map_h = vint_object_find("current_map") 
  26. 	Mp_match_load_data.handles.full_1_h = vint_object_find("full_1") 
  27. 	Mp_match_load_data.handles.full_2_h = vint_object_find("full_2") 
  28. 	Mp_match_load_data.handles.full_3_h = vint_object_find("full_3") 
  29. 	Mp_match_load_data.handles.heading_h = vint_object_find("heading") 
  30. 	Mp_match_load_data.handles.matchmaking_h = vint_object_find("matchmaking") 
  31. 	Mp_match_load_data.handles.my_window_h = vint_object_find("my_window") 
  32. 	Mp_match_load_data.handles.starting_game_h = vint_object_find("starting_game") 
  33. 	Mp_match_load_data.handles.tips_h = vint_object_find("tips") 
  34. 	Mp_match_load_data.handles.map_image_h = vint_object_find("map_image") 
  35. 	 
  36. 	-- Set word wrap because it doesn't work automatically for some reason 
  37. 	vint_set_property(vint_object_find("tip_name"), "word_wrap", true) 
  38. 	vint_set_property(vint_object_find("heading"), "word_wrap", true) 
  39. 	 
  40. 	-- Hold on all the animations 
  41. 	Mp_match_load_data.handles.opening_match_anim = vint_object_find("opening_match_anim") 
  42. 	vint_set_property(Mp_match_load_data.handles.opening_match_anim, "is_paused", true) 
  43. 	vint_set_property(vint_object_find("tips_fade_in",Mp_match_load_data.handles.opening_match_anim), "end_event", "mp_match_load_start_cycle_tips") 
  44. 	 
  45. 	Mp_match_load_data.handles.opening_custom_anim = vint_object_find("opening_custom_anim") 
  46. 	vint_set_property(Mp_match_load_data.handles.opening_custom_anim, "is_paused", true) 
  47. 	 
  48. 	Mp_match_load_data.handles.tips_fade_in_anim = vint_object_find("tips_fade_in_anim") 
  49. 	vint_set_property(Mp_match_load_data.handles.tips_fade_in_anim, "is_paused", true) 
  50. 	vint_set_property(vint_object_find("tips_fade_in",Mp_match_load_data.handles.tips_fade_in_anim), "end_event", "mp_match_load_start_cycle_tips") 
  51. 	 
  52. 	Mp_match_load_data.handles.tips_fade_out_anim = vint_object_find("tips_fade_out_anim") 
  53. 	vint_set_property(Mp_match_load_data.handles.tips_fade_out_anim, "is_paused", true) 
  54. 	 
  55. 	Mp_match_load_data.handles.map_fade_in_anim = vint_object_find("map_fade_in_anim") 
  56. 	vint_set_property(Mp_match_load_data.handles.map_fade_in_anim, "is_paused", true) 
  57. 	vint_set_property(vint_object_find("map_image_cust_scale_in",Mp_match_load_data.handles.map_fade_in_anim), "end_event", "mp_match_load_start_cycle_map") 
  58. 	 
  59. 	Mp_match_load_data.handles.map_fade_out_anim = vint_object_find("map_fade_out_anim") 
  60. 	vint_set_property(Mp_match_load_data.handles.map_fade_out_anim, "is_paused", true) 
  61. 	 
  62. 	Mp_match_load_data.handles.time_holder_anim = vint_object_find("time_holder_anim") 
  63. 	vint_set_property(Mp_match_load_data.handles.time_holder_anim, "is_paused", true) 
  64. 	vint_set_property(vint_object_find("time_holder_alpha_twn",Mp_match_load_data.handles.time_holder_anim), "end_event", "mp_match_load_finish_foolin") 
  65. 	 
  66. 	Mp_match_load_data.handles.tips_cycle_anim = vint_object_find("tips_cycle_anim") 
  67. 	vint_set_property(Mp_match_load_data.handles.tips_cycle_anim, "is_paused", true) 
  68. 	vint_set_property(vint_object_find("tips_cycle_fade_out",Mp_match_load_data.handles.tips_cycle_anim), "end_event", "mp_match_load_mid_cycle_tips") 
  69. 	vint_set_property(vint_object_find("tips_cycle_fade_in",Mp_match_load_data.handles.tips_cycle_anim), "end_event", "mp_match_load_finish_cycle_tips") 
  70. 	 
  71. 	Mp_match_load_data.handles.map_cycle_anim = vint_object_find("map_cycle_anim") 
  72. 	vint_set_property(Mp_match_load_data.handles.map_cycle_anim, "is_paused", true) 
  73. 	vint_set_property(vint_object_find("map_cycle_fade_out",Mp_match_load_data.handles.map_cycle_anim), "end_event", "mp_match_load_mid_cycle_map") 
  74. 	vint_set_property(vint_object_find("map_cycle_spin_in",Mp_match_load_data.handles.map_cycle_anim), "end_event", "mp_match_load_finish_cycle_map") 
  75. 			 
  76. 	-- Set up animation triggers 
  77. 	Mp_match_load_data.current_state = 0 
  78. 	 
  79. 	-- Set up the initial screen state 
  80. 	vint_dataitem_add_subscription("sr2_matchmaking_current_state_data", "update", "mp_hud_lobby_state_update") 
  81. 	 
  82. 	-- Get a background 
  83. 	mp_match_load_set_background() 
  84. 	 
  85. 	-- Cancel button 
  86. 	Mp_match_load_data.handles.cancel = vint_object_find("cancel") 
  87. 	vint_set_property(vint_object_find("b_button", Mp_match_load_data.handles.cancel), "image", get_b_button()) 
  88. 	 
  89. end 
  90.  
  91. function mp_hud_lobby_state_update(di_h, event) 
  92. 	-- Get the game data 
  93. 	local is_matchmaking, is_ranked, state, map, mode, variant = vint_dataitem_get(di_h) 
  94.  
  95. 	-- Hang on to matchmaking for graphical setup later 
  96. 	Mp_match_load_data.is_matchmaking = is_matchmaking 
  97. 	 
  98. 	-- If this is the first time, we need to run the initial animations 
  99. 	if Mp_match_load_data.first_update == true then 
  100. 		-- Unset the first update flag 
  101. 		Mp_match_load_data.first_update = false 
  102. 		 
  103. 		-- Set up animation triggers 
  104. 		Mp_match_load_data.current_state = state 
  105. 	 
  106. 		-- If we're matchmaking, start at the beginning of the screen 
  107. 		if is_matchmaking == true then 
  108. 			-- Set ranked text 
  109. 			if is_ranked == true then  
  110. 				vint_set_property(Mp_match_load_data.handles.heading_h, "text_tag", "MULTI_GAMETYPE_3") 
  111. 			else 
  112. 				vint_set_property(Mp_match_load_data.handles.heading_h, "text_tag", "MULTI_GAMETYPE_2") 
  113. 			end 
  114.  
  115. 			-- Animate in 
  116. 			vint_set_property(vint_object_find("my_window_fade_in",Mp_match_load_data.handles.opening_match_anim), "end_event", "mp_match_load_start_players") 
  117. 			lua_play_anim(Mp_match_load_data.handles.opening_match_anim, 1) 
  118. 			 
  119. 		else -- We're not in matchmaking, so fill in all the data and skip to the end 
  120. 			-- Hide heading proscript text 
  121. 			vint_set_property(Mp_match_load_data.handles.matchmaking_h,"visible", false) 
  122. 		 
  123. 			-- Set heading text 
  124. 			vint_set_property(Mp_match_load_data.handles.heading_h, "text_tag", "MULTI_MENU_TITLE") 
  125.  
  126. 			-- Animate in 
  127. 			vint_set_property(vint_object_find("my_window_cust_fade_in",Mp_match_load_data.handles.opening_custom_anim), "end_event", "mp_match_load_start_players") 
  128. 			lua_play_anim(Mp_match_load_data.handles.opening_custom_anim, 1) 
  129. 		end 
  130. 		 
  131. 		-- Adjust for possible text wrapping 
  132. 		local width, height = element_get_actual_size(Mp_match_load_data.handles.heading_h) 
  133. 		vint_set_property(vint_object_find("heading_subgroup"), "anchor", 0.0, height) 
  134. 		 
  135. 		if height > 60 then 
  136. 			local map = vint_object_find("current_map") 
  137. 			local x, y = vint_get_property(map, "anchor") 
  138. 			vint_set_property(map, "anchor", x, y + 53) 
  139. 		end 
  140. 	end 
  141. 	 
  142. 	if state > 1 then -- We know the map info 
  143.  
  144. 		-- Map image 
  145. 		mp_match_load_makemap(map) 
  146. 		 
  147. 		-- Map text 
  148. 		local map_name = vint_object_find("map_name", Mp_match_load_data.handles.current_map_h) 
  149. 		 
  150. 		if vint_hack_is_std_res() == true then 
  151. 			vint_set_property(map_name, "word_wrap", true) 
  152. 			vint_set_property(map_name, "wrap_width", 425) 
  153. 		end 
  154.  
  155. 		vint_set_property(map_name, "text_tag", map) 
  156.  
  157. 		-- Move the rest of the stuff down according to the text wrapping 
  158. 		local x, map_text_height = element_get_actual_size(map_name) 
  159. 		vint_set_property(vint_object_find("map_subgroup", Mp_match_load_data.handles.current_map_h), "anchor", 0, map_text_height) 
  160. 		 
  161. 		-- Mode 
  162. 		vint_set_property(vint_object_find("game_mode", Mp_match_load_data.handles.current_map_h), "text_tag", mode) 
  163. 		 
  164. 		-- Variant 
  165. 		vint_set_property(vint_object_find("variant", Mp_match_load_data.handles.current_map_h), "text_tag", variant) 
  166. 	else 
  167. 		-- Get us a tip 
  168. 		mp_match_load_maketip() 
  169. 	end 
  170. 	 
  171. 	-- Set up the new state 
  172. 	mp_match_load_set_state(state) 
  173. end 
  174.  
  175. function mp_match_load_start_players() 
  176. 	vint_datagroup_add_subscription("sr2_matchmaking_player_data", "update", "mp_match_load_player_update") 
  177. 	vint_datagroup_add_subscription("sr2_matchmaking_player_data", "insert", "mp_match_load_player_update") 
  178. 	vint_datagroup_add_subscription("sr2_matchmaking_player_data", "remove", "mp_match_load_player_update") 
  179. end 
  180.  
  181. function mp_match_load_player_update(di_h, event) 
  182. 	 
  183. 	local team, name, voip, host, in_party, badge, nickname = vint_dataitem_get(di_h) 
  184. 	if event == "insert" then -- Make a new line 
  185. 		-- Clone up a new line 
  186. 		local line_h = vint_object_clone(vint_object_find("player_line")) 
  187. 		Mp_match_load_data.player_data[di_h] = {team = team, voip = voip, host = host, in_party = in_party, line_h = line_h} 
  188. 		 
  189. 		-- Set name text 
  190. 		local name_h = vint_object_find("name", Mp_match_load_data.player_data[di_h].line_h) 
  191. 		vint_set_property(name_h, "text_tag", name) 
  192. 		 
  193. 		-- Set icon 
  194. 		local badge_h = vint_object_find("badge", Mp_match_load_data.player_data[di_h].line_h) 
  195. 		vint_set_property(badge_h, "image", badge) 
  196. 		 
  197. 		-- Set nickname 
  198. 		local nickname_h = vint_object_find("nickname", Mp_match_load_data.player_data[di_h].line_h) 
  199. 		vint_set_property(nickname_h, "text_tag", nickname) 
  200. 		 
  201. 		-- Set voip icon 
  202. 		mp_match_load_set_voip(di_h) 
  203. 		 
  204. 		-- Rebuild the line list 
  205. 		mp_match_load_arrange_lines() 
  206. 		 
  207. 	elseif event == "update" then -- Update an existing line (voip) 
  208. 		-- Adjust teams if they changed 
  209. 		local old_team = Mp_match_load_data.player_data[di_h].team 
  210. 		Mp_match_load_data.player_data[di_h].team = team 
  211. 		 
  212. 		if team ~= old_team then 
  213. 			mp_match_load_arrange_lines() 
  214. 		end 
  215. 		 
  216. 		-- Change voip icon 
  217. 		local old_voip = Mp_match_load_data.player_data[di_h].voip 
  218. 		Mp_match_load_data.player_data[di_h].voip = voip 
  219. 		 
  220. 		if voip ~= old_voip then 
  221. 			mp_match_load_set_voip(di_h) 
  222. 		end 
  223. 		 
  224. 	elseif event == "remove" then -- Remove existing line 
  225. 		vint_object_destroy(Mp_match_load_data.player_data[di_h].line_h) 
  226. 		Mp_match_load_data.player_data[di_h] = nil 
  227. 		 
  228. 		-- Fix the rest of the lines 
  229. 		mp_match_load_arrange_lines() 
  230. 	end 
  231. end 
  232.  
  233. function mp_match_load_set_voip(idx) 
  234. 	if Mp_match_load_data.player_data[idx] ~= nil then 
  235. 		local voip_speaker = vint_object_find("speaker", Mp_match_load_data.player_data[idx].line_h) 
  236. 		local voip_speaker_on = vint_object_find("speaker_on", Mp_match_load_data.player_data[idx].line_h) 
  237. 		 
  238. 		if Mp_match_load_data.player_data[idx].voip == 0 then -- No voip 
  239. 			vint_set_property(voip_speaker, "visible", false) 
  240. 			vint_set_property(voip_speaker_on, "visible", false) 
  241. 			 
  242. 		elseif Mp_match_load_data.player_data[idx].voip == 1 then -- Plugged in 
  243. 			vint_set_property(voip_speaker, "visible", true) 
  244. 			vint_set_property(voip_speaker_on, "visible", false) 
  245. 			 
  246. 		elseif Mp_match_load_data.player_data[idx].voip == 2 then -- Talking 
  247. 			vint_set_property(voip_speaker, "visible", true) 
  248. 			vint_set_property(voip_speaker_on, "visible", true) 
  249. 		end 
  250. 	end 
  251. end 
  252.  
  253. function mp_match_load_arrange_lines() 
  254. 	local LINE_HEIGHT = 40 -- Distance between lines of text 
  255. 	local current_line = 0 
  256. 	local x, y = vint_get_property(Mp_match_load_data.handles.player_line, "anchor") 
  257. 	 
  258. 	 -- Set the colors and states of all team lines 
  259. 	for idx, val in Mp_match_load_data.player_data do 
  260. 		 
  261. 		-- Set player color 
  262. 		local name_h = vint_object_find("name", Mp_match_load_data.player_data[idx].line_h) 
  263. 		local hidden_name_h = vint_object_find("hidden_name", Mp_match_load_data.player_data[idx].line_h) 
  264. 		 
  265. 		if Mp_match_load_data.current_state < 2 then 
  266. 			--Everybody is yellow when players are being found 
  267. 			vint_set_property(name_h, "tint", 160/255, 160/255, 160/255) 
  268. 			vint_set_property(hidden_name_h, "tint", 160/255, 160/255, 160/255) 
  269. 		else 
  270. 			if Mp_match_load_data.player_data[idx].host == true and Mp_match_load_data.is_matchmaking == false then -- Host is yellow in non-matchmaking 
  271. 				vint_set_property(name_h, "tint", 241/255, 227/255, 1/255) 
  272. 				vint_set_property(hidden_name_h, "tint", 241/255, 227/255, 1/255) 
  273. 			else 
  274. 				if Mp_match_load_data.player_data[idx].team == 0 then -- Blue team 
  275. 					vint_set_property(name_h, "tint", 0, 128/255, 255/255) 
  276. 					vint_set_property(hidden_name_h, "tint", 0, 128/255, 255/255) 
  277. 				elseif Mp_match_load_data.player_data[idx].team == 1 then -- Red team 
  278. 					vint_set_property(name_h, "tint", 204/255, 0, 0) 
  279. 					vint_set_property(hidden_name_h, "tint", 204/255, 0, 0) 
  280. 				end 
  281. 			end 
  282. 		end 
  283. 	 
  284. 		-- Show/hide real name and badge based on party and current state 
  285. 		local shown_h = vint_object_find("shown", Mp_match_load_data.player_data[idx].line_h) 
  286. 		local hidden_h = vint_object_find("hidden", Mp_match_load_data.player_data[idx].line_h) 
  287. 		 
  288. 		if Mp_match_load_data.current_state < 2 then 
  289. 			if Mp_match_load_data.player_data[idx].in_party == true then 
  290. 				vint_set_property(shown_h, "visible", true) 
  291. 				vint_set_property(hidden_h, "visible", false) 
  292. 			else 
  293. 				vint_set_property(shown_h, "visible", false) 
  294. 				vint_set_property(hidden_h, "visible", true) 
  295. 			end 
  296. 		else 
  297. 			vint_set_property(shown_h, "visible", true) 
  298. 			vint_set_property(hidden_h, "visible", false) 
  299. 		end 
  300. 	end 
  301. 	 
  302. 	-- Place the blue team lines 
  303. 	for idx, val in Mp_match_load_data.player_data do 
  304. 		if Mp_match_load_data.player_data[idx].team == 0 then 
  305. 			local new_y = y + (current_line * LINE_HEIGHT) 
  306. 			vint_set_property(Mp_match_load_data.player_data[idx].line_h, "anchor", x, new_y) 
  307. 			vint_set_property(Mp_match_load_data.player_data[idx].line_h, "visible", true) 
  308. 			current_line = current_line + 1 
  309. 		end 
  310. 	end 
  311. 	 
  312. 	-- Place the red team lines 
  313. 	for idx, val in Mp_match_load_data.player_data do 
  314. 		if Mp_match_load_data.player_data[idx].team == 1 then 
  315. 			local new_y = y + (current_line * LINE_HEIGHT) 
  316. 			vint_set_property(Mp_match_load_data.player_data[idx].line_h, "anchor", x, new_y) 
  317. 			vint_set_property(Mp_match_load_data.player_data[idx].line_h, "visible", true) 
  318. 			current_line = current_line + 1 
  319. 		end 
  320. 	end 
  321. end 
  322.  
  323. function mp_match_load_set_state(state) 
  324. 	 
  325. 	--[[  States: 
  326. 			0 = Searching for games 
  327. 			1 = Finding players 
  328. 			2 = Configuring game (loading) 
  329. 		]] 
  330. 		 
  331. 	local old_state = Mp_match_load_data.current_state 
  332. 	Mp_match_load_data.current_state = state 
  333. 	 
  334. 	-- Open up new state 
  335. 	if state == 0 then 
  336. 		 
  337. 		-- Cancel button 
  338. 		vint_set_property(Mp_match_load_data.handles.cancel, "visible", true) 
  339. 	 
  340. 		-- Searching for games 
  341. 		vint_set_property(Mp_match_load_data.handles.full_1_h, "tint", 229/255, 191/255,  13/255) 
  342. 		vint_set_property(Mp_match_load_data.handles.full_2_h, "tint", 128/255, 128/255, 128/255) 
  343. 		vint_set_property(Mp_match_load_data.handles.full_3_h, "tint", 128/255, 128/255, 128/255) 
  344. 		vint_set_property(Mp_match_load_data.handles.full_1_h, "visible", true) 
  345. 		vint_set_property(Mp_match_load_data.handles.full_2_h, "visible", true) 
  346. 		vint_set_property(Mp_match_load_data.handles.full_3_h, "visible", true) 
  347. 		 
  348. 		vint_set_property(Mp_match_load_data.handles.current_action_h, "text_tag", "MULTI_MATCHMAKING_STEP_1") 
  349. 		vint_set_property(Mp_match_load_data.handles.current_action_h, "visible", true) 
  350. 		 
  351. 		if old_state > 1 then 
  352. 			-- Animate out the map image 
  353. 			lua_play_anim(Mp_match_load_data.handles.map_fade_out_anim, 0) 
  354. 			 
  355. 			-- Animate in the tips 
  356. 			mp_match_load_maketip() 
  357. 			lua_play_anim(Mp_match_load_data.handles.tips_fade_in_anim, 0) 
  358. 		end 
  359. 			 
  360. 		-- Fun hacky stuff for if somebody yanks their controller 
  361. 		if Mp_match_load_data.is_matchmaking == false then  
  362. 			if Mp_match_load_data.first_state then 
  363. 				Mp_match_load_data.first_state = false 
  364. 			 
  365. 				mp_match_load_maketip() 
  366. 				 
  367. 				mp_match_load_start_fool_testers(Mp_match_load_data.handles.starting_game_h) 
  368. 				vint_set_property(Mp_match_load_data.handles.starting_game_h, "visible", true) 
  369. 				 
  370. 				lua_play_anim(Mp_match_load_data.handles.tips_fade_in_anim, 2) 
  371. 			end 
  372. 		else 
  373. 			vint_set_property(Mp_match_load_data.handles.starting_game_h, "visible", false) 
  374. 		end 
  375. 		 
  376. 	elseif state == 1 then 
  377. 	 
  378. 		-- Cancel button 
  379. 		vint_set_property(Mp_match_load_data.handles.cancel, "visible", true) 
  380. 	 
  381. 		-- Searching for players 
  382. 		vint_set_property(Mp_match_load_data.handles.full_1_h, "tint", 128/255, 128/255, 128/255) 
  383. 		vint_set_property(Mp_match_load_data.handles.full_2_h, "tint", 229/255, 191/255,  13/255) 
  384. 		vint_set_property(Mp_match_load_data.handles.full_3_h, "tint", 128/255, 128/255, 128/255) 
  385. 		vint_set_property(Mp_match_load_data.handles.full_1_h, "visible", true) 
  386. 		vint_set_property(Mp_match_load_data.handles.full_2_h, "visible", true) 
  387. 		vint_set_property(Mp_match_load_data.handles.full_3_h, "visible", true) 
  388. 		 
  389. 		vint_set_property(Mp_match_load_data.handles.current_action_h, "text_tag", "MULTI_MATCHMAKING_STEP_2")		 
  390. 		vint_set_property(Mp_match_load_data.handles.current_action_h, "visible", true) 
  391. 		 
  392. 		if old_state > 1 then 
  393. 			-- Animate out the map image 
  394. 			lua_play_anim(Mp_match_load_data.handles.map_fade_out_anim, 0) 
  395. 			 
  396. 			-- Animate in the tips 
  397. 			mp_match_load_maketip() 
  398. 			lua_play_anim(Mp_match_load_data.handles.tips_fade_in_anim, 0) 
  399. 		end 
  400. 		 
  401. 		-- Fun hacky stuff for if somebody yanks their controller 
  402. 		if Mp_match_load_data.is_matchmaking then 
  403. 			vint_set_property(Mp_match_load_data.handles.starting_game_h, "visible", false) 
  404. 		end 
  405. 		 
  406. 	elseif state == 2 then 
  407. 	 
  408. 		-- Cancel button 
  409. 		vint_set_property(Mp_match_load_data.handles.cancel, "visible", false) 
  410. 	 
  411. 		if Mp_match_load_data.is_matchmaking then 
  412. 			-- Configuring game 
  413. 			vint_set_property(Mp_match_load_data.handles.full_1_h, "tint", 128/255, 128/255, 128/255) 
  414. 			vint_set_property(Mp_match_load_data.handles.full_2_h, "tint", 128/255, 128/255, 128/255) 
  415. 			vint_set_property(Mp_match_load_data.handles.full_3_h, "tint", 229/255, 191/255,  13/255) 
  416. 			vint_set_property(Mp_match_load_data.handles.full_1_h, "visible", true) 
  417. 			vint_set_property(Mp_match_load_data.handles.full_2_h, "visible", true) 
  418. 			vint_set_property(Mp_match_load_data.handles.full_3_h, "visible", true) 
  419. 			 
  420. 			vint_set_property(Mp_match_load_data.handles.starting_game_h, "visible", false) 
  421. 			 
  422. 			mp_match_load_start_fool_testers(Mp_match_load_data.handles.current_action_h) 
  423. 			vint_set_property(Mp_match_load_data.handles.current_action_h, "visible", true) 
  424. 		else 
  425. 			-- Configuring custom game 
  426. 			vint_set_property(Mp_match_load_data.handles.full_1_h, "visible", false) 
  427. 			vint_set_property(Mp_match_load_data.handles.full_2_h, "visible", false) 
  428. 			vint_set_property(Mp_match_load_data.handles.full_3_h, "visible", false) 
  429.  
  430. 			vint_set_property(Mp_match_load_data.handles.current_action_h, "visible", false) 
  431. 		end 
  432. 		 
  433. 		if old_state < 2 then 
  434. 			-- Animate out the tips 
  435. 			vint_set_property(Mp_match_load_data.handles.tips_fade_in_anim, "is_paused", true) 
  436. 			local tips_alpha = vint_get_property(Mp_match_load_data.handles.tips_h, "alpha") 
  437. 			vint_set_property(vint_object_find("tips_fade_out",Mp_match_load_data.handles.tips_fade_out_anim), "start_value", tips_alpha) 
  438. 			 
  439. 			vint_set_property(Mp_match_load_data.handles.tips_cycle_anim, "is_paused", true) 
  440. 			thread_kill(Mp_match_load_data.tip_thread) 
  441. 			lua_play_anim(Mp_match_load_data.handles.tips_fade_out_anim, 0) 
  442. 			 
  443. 			-- Animate in the map image 
  444. 			lua_play_anim(Mp_match_load_data.handles.map_fade_in_anim, 0) 
  445. 		end 
  446. 	end 
  447. 	 
  448. 	-- Make sure the names are hidden correctly 
  449. 	mp_match_load_arrange_lines() 
  450. end 
  451.  
  452. function mp_match_load_start_fool_testers(handle) 
  453. 	vint_set_property(handle, "text_tag", "MM_LOAD_LOADING") 
  454. 	Mp_match_load_data.handles.foolin = handle 
  455. 	lua_play_anim(Mp_match_load_data.handles.time_holder_anim,0) 
  456. end 
  457.  
  458. function mp_match_load_finish_foolin() 
  459. 	if Mp_match_load_data.current_state == 2 then 
  460. 		vint_set_property(Mp_match_load_data.handles.foolin, "text_tag", "MULTI_MATCHMAKING_STEP_3") 
  461. 	end 
  462. end 
  463.  
  464. function mp_match_load_set_background() 
  465. 	local rand_background = rand_int(2,3) 
  466. 	local backdrop_h = vint_object_find("backdrop") 
  467. 	 
  468. 	if rand_background == 2 then 
  469. 		peg_load("ui_matchmaking_bkgnd02") 
  470. 		vint_set_property(backdrop_h, "image", "mp_lobby02_background.tga") 
  471. 	elseif rand_background == 3 then 
  472. 		peg_load("ui_matchmaking_bkgnd03") 
  473. 		vint_set_property(backdrop_h, "image", "mp_lobby03_background.tga") 
  474. 	end 
  475. end 
  476.  
  477. function mp_match_load_start_cycle_tips() 
  478. 	Mp_match_load_data.tip_thread = thread_new("mp_match_load_cycle_tips") 
  479. end 
  480.  
  481. function mp_match_load_cycle_tips() 
  482. 	lua_play_anim(Mp_match_load_data.handles.tips_cycle_anim, 12) 
  483. end 
  484.  
  485. function mp_match_load_mid_cycle_tips() 
  486. 	mp_match_load_maketip() 
  487. end 
  488.  
  489. function mp_match_load_finish_cycle_tips() 
  490. 	Mp_match_load_data.tip_thread = thread_new("mp_match_load_cycle_tips") 
  491. end 
  492.  
  493. function mp_match_load_start_cycle_map() 
  494. 	Mp_match_load_data.map_thread = thread_new("mp_match_load_cycle_map") 
  495. end 
  496.  
  497. function mp_match_load_cycle_map() 
  498. 	lua_play_anim(Mp_match_load_data.handles.map_cycle_anim, 12) 
  499. end 
  500.  
  501. function mp_match_load_mid_cycle_map() 
  502. 	mp_match_load_random_map() 
  503. end 
  504.  
  505. function mp_match_load_finish_cycle_map() 
  506. 	Mp_match_load_data.map_thread = thread_new("mp_match_load_cycle_map") 
  507. end 
  508.  
  509. function mp_match_load_clear_pegs() 
  510. 	peg_unload("ui_ml_car_show") 
  511. 	peg_unload("ui_ml_chinatown") 
  512. 	peg_unload("ui_ml_hangar") 
  513. 	peg_unload("ui_ml_north_shore") 
  514. 	peg_unload("ui_ml_nuke_plant") 
  515. 	peg_unload("ui_ml_oldtown") 
  516. 	peg_unload("ui_ml_parthenon") 
  517. 	peg_unload("ui_ml_poseidons_palace") 
  518. 	peg_unload("ui_ml_shantytown") 
  519. 	peg_unload("ui_ml_stilwater_science") 
  520. 	peg_unload("ui_ml_the_pyramid") 
  521. 	peg_unload("ui_ml_wharfside") 
  522. end 
  523.  
  524. function mp_match_load_makemap(map) 
  525.  
  526. 	-- Blow away all the old pegs 
  527. 	mp_match_load_clear_pegs() 
  528. 	 
  529. 	-- Load up the new peg and assign the pictures 
  530. 	if map == "MULTI_LEVEL_SHANTYTOWN" then 
  531. 		peg_load("ui_ml_shantytown") 
  532. 		Mp_match_load_data.map_images[1] = "shantytown1" 
  533. 		Mp_match_load_data.map_images[2] = "shantytown2" 
  534. 		Mp_match_load_data.map_images[3] = "shantytown3" 
  535.  
  536. 	elseif map == "MULTI_LEVEL_CHINATOWN" then 
  537. 		peg_load("ui_ml_chinatown") 
  538. 		Mp_match_load_data.map_images[1] = "chinatown1" 
  539. 		Mp_match_load_data.map_images[2] = "chinatown2" 
  540. 		Mp_match_load_data.map_images[3] = "chinatown3" 
  541. 		 
  542. 	elseif map == "MULTI_LEVEL_SCIENCE" then 
  543. 		peg_load("ui_ml_stilwater_science") 
  544. 		Mp_match_load_data.map_images[1] = "stilwater_science1" 
  545. 		Mp_match_load_data.map_images[2] = "stilwater_science2" 
  546. 		Mp_match_load_data.map_images[3] = "stilwater_science3" 
  547. 		 
  548. 	elseif map == "MULTI_LEVEL_ULTOR" then 
  549. 		peg_load("ui_ml_the_pyramid") 
  550. 		Mp_match_load_data.map_images[1] = "the_pyramid1" 
  551. 		Mp_match_load_data.map_images[2] = "the_pyramid2" 
  552. 		Mp_match_load_data.map_images[3] = "the_pyramid3" 
  553. 		 
  554. 	elseif map == "MULTI_LEVEL_MALL" then 
  555. 		peg_load("ui_ml_car_show") 
  556. 		Mp_match_load_data.map_images[1] = "car_show1" 
  557. 		Mp_match_load_data.map_images[2] = "car_show2" 
  558. 		Mp_match_load_data.map_images[3] = "car_show3" 
  559. 		 
  560. 	elseif map == "MULTI_LEVEL_HANGAR" then 
  561. 		peg_load("ui_ml_hangar") 
  562. 		Mp_match_load_data.map_images[1] = "hangar1" 
  563. 		Mp_match_load_data.map_images[2] = "hangar2" 
  564. 		Mp_match_load_data.map_images[3] = "hangar3" 
  565. 		 
  566. 	elseif map == "MULTI_LEVEL_SA_BARRIO" then 
  567. 		peg_load("ui_ml_oldtown") 
  568. 		Mp_match_load_data.map_images[1] = "oldtown1" 
  569. 		Mp_match_load_data.map_images[2] = "oldtown2" 
  570. 		Mp_match_load_data.map_images[3] = "oldtown3" 
  571. 		 
  572. 	elseif map == "MULTI_LEVEL_DOCKS" then 
  573. 		peg_load("ui_ml_wharfside") 
  574. 		Mp_match_load_data.map_images[1] = "wharfside1" 
  575. 		Mp_match_load_data.map_images[2] = "wharfside2" 
  576. 		Mp_match_load_data.map_images[3] = "wharfside3" 
  577. 		 
  578. 	elseif map == "MULTI_LEVEL_MUSEUM" then 
  579. 		peg_load("ui_ml_parthenon") 
  580. 		Mp_match_load_data.map_images[1] = "parthenon1" 
  581. 		Mp_match_load_data.map_images[2] = "parthenon2" 
  582. 		Mp_match_load_data.map_images[3] = "parthenon3" 
  583. 		 
  584. 	elseif map == "MULTI_LEVEL_MARINA" then 
  585. 		peg_load("ui_ml_north_shore") 
  586. 		Mp_match_load_data.map_images[1] = "north_shore1" 
  587. 		Mp_match_load_data.map_images[2] = "north_shore2" 
  588. 		Mp_match_load_data.map_images[3] = "north_shore3" 
  589. 		 
  590. 	elseif map == "MULTI_LEVEL_CASINO" then 
  591. 		peg_load("ui_ml_poseidons_palace") 
  592. 		Mp_match_load_data.map_images[1] = "poseidons_palace1" 
  593. 		Mp_match_load_data.map_images[2] = "poseidons_palace2" 
  594. 		Mp_match_load_data.map_images[3] = "poseidons_palace3" 
  595. 		 
  596. 	elseif map == "MULTI_LEVEL_NUKE" then 
  597. 		peg_load("ui_ml_nuke_plant") 
  598. 		Mp_match_load_data.map_images[1] = "nuke_plant1" 
  599. 		Mp_match_load_data.map_images[2] = "nuke_plant2" 
  600. 		Mp_match_load_data.map_images[3] = "nuke_plant3" 
  601. 	end 
  602. 	 
  603. 	-- Display one of the map pics 
  604. 	mp_match_load_random_map() 
  605. end 
  606.  
  607. function mp_match_load_random_map() 
  608. 	-- Throw up a map 
  609. 	local rand_map = rand_int(1,3) 
  610. 	 
  611. 	-- Make sure we don't show the same one twice in a row 
  612. 	while Mp_match_load_data.old_map == rand_map do 
  613. 		rand_map = rand_int(1,3) 
  614. 	end 
  615. 	 
  616. 	-- Set the map image here 
  617. 	vint_set_property(Mp_match_load_data.handles.map_image_h, "image", Mp_match_load_data.map_images[rand_map]) 
  618. 	 
  619. 	-- Set new angle for the map image just for fun 
  620. 	vint_set_property(vint_object_find("map_cycle_spin_in",Mp_match_load_data.handles.map_cycle_anim), "end_value", rand_float(-0.05, 0.05)) 
  621. end 
  622.  
  623. function mp_match_load_maketip() 
  624. 	-- Throw up a tip (just the tip) 
  625. 	local rand_tip = rand_int(1,12) 
  626. 	 
  627. 	-- Make sure we don't show the same one twice in a row 
  628. 	while Mp_match_load_data.old_tip == rand_tip do 
  629. 		rand_tip = rand_int(1,12) 
  630. 	end 
  631. 	 
  632. 	-- Hang on to this tip 
  633. 	Mp_match_load_data.old_tip = rand_tip 
  634. 	 
  635. 	local tip_heading 
  636. 	local tip_text 
  637. 	 
  638. 	if rand_tip == 1 then 
  639. 		tip_heading = "MULTI_MODE_STRONGARM" 
  640. 		tip_text = "MULTI_TIP_STRONGARM" 
  641. 	elseif rand_tip == 2 then 
  642. 		tip_heading = "HELP_TEXT_TAGGING_TITLE" 
  643. 		tip_text = "MULTI_TIP_TAGGING" 
  644. 	elseif rand_tip == 3 then 
  645. 		tip_heading = "MULTI_ACTIVITY_DERBY" 
  646. 		tip_text = "MULTI_TIP_DEMO_DERBY" 
  647. 	elseif rand_tip == 4 then 
  648. 		tip_heading = "MULTI_ACTIVITY_HITMAN" 
  649. 		tip_text = "MULTI_TIP_HITMAN" 
  650. 	elseif rand_tip == 5 then 
  651. 		tip_heading = "MULTI_ACTIVITY_FRAUD" 
  652. 		tip_text = "MULTI_TIP_FRAUD" 
  653. 	elseif rand_tip == 6 then 
  654. 		tip_heading = "MULTI_ACTIVITY_MAYHEM" 
  655. 		tip_text = "MULTI_TIP_MAYHEM" 
  656. 	elseif rand_tip == 7 then 
  657. 		tip_heading = "MULTI_ACTIVITY_RACING" 
  658. 		tip_text = "MULTI_TIP_RACING" 
  659. 	elseif rand_tip == 8 then 
  660. 		tip_heading = "MULTI_ACTIVITY_SNATCH" 
  661. 		tip_text = "MULTI_TIP_SNATCH" 
  662. 	elseif rand_tip == 9 then 
  663. 		tip_heading = "MULTI_ACTIVITY_THEFT" 
  664. 		tip_text = "MULTI_TIP_THEFT" 
  665. 	elseif rand_tip == 10 then 
  666. 		tip_heading = "MULTI_MENU_CUSTOMIZATION" 
  667. 		tip_text = "MULTI_TIP_CUSTOMIZATION" 
  668. 	elseif rand_tip == 11 then 
  669. 		tip_heading = "MULTI_MENU_XBOX_CUSTOM_MATCH" 
  670. 		tip_text = "MULTI_TIP_CUSTOM_MATCH" 
  671. 	elseif rand_tip == 12 then 
  672. 		tip_heading = "MULTI_MENU_TUTORIALS" 
  673. 		tip_text = "MULTI_TIP_TUTORIAL" 
  674. 	end 
  675. 	 
  676. 	local name_h = vint_object_find("tip_name") 
  677. 	local filler_h = vint_object_find("tip_filler") 
  678. 	 
  679. 	vint_set_property(name_h, "text_tag", tip_heading) 
  680. 	vint_set_property(filler_h, "text_tag", tip_text) 
  681. 	 
  682. 	local x, y = element_get_actual_size(name_h) 
  683. 	debug_print("vint", "Y size value = " .. y .. "\n") 
  684.  
  685. 	if y < 60 then 
  686. 		vint_set_property(filler_h, "anchor", -484.0, -32.0) 
  687. 	else 
  688. 		vint_set_property(filler_h, "anchor", -484.0, 18.0) 
  689. 	end 
  690. end 
  691.  
  692. function mp_match_load_cleanup() 
  693. 	-- Unload Pegs 
  694. 	peg_unload("ui_matchmaking_bkgnd02") 
  695. 	peg_unload("ui_matchmaking_bkgnd03") 
  696. 	peg_unload("ui_mp_lobbywindow") 
  697. 	mp_match_load_clear_pegs() 
  698. end 
  699.