./cat_mouse_results.lua

  1. -- enums 
  2. local	CAMSUR_RETRY 	= 0 
  3. local CAMSUR_QUIT		= 1 
  4.  
  5. --Global Vdo's 
  6. local Input_tracker 
  7. local Mouse_input_tracker = 0 
  8. local Cat_mouse_results_doc_h = -1 
  9. Cat_mouse_mega_list = 0 
  10.  
  11. local MENU_ID_PLAY_AGAIN 	= 1 
  12. local MENU_ID_STOP 			= 2 
  13. local MENU_ID_CONTINUE 		= 3 
  14.  
  15. -- Scoring types 
  16. local SCORE_TYPE_POINTS 	= 0 
  17. local SCORE_TYPE_KILLS 		= 1 
  18.  
  19. local DIV_TYPE_DEATHTAG		= 0 
  20. local DIV_TYPE_CAT_MOUSE	= 1 
  21. local DIV_TYPE_SURVIVAL		= 2 
  22.  
  23. local STATUS_TYPE_WIN 	= 0 
  24. local STATUS_TYPE_LOSE 	= 1 
  25. local STATUS_TYPE_TIE	= 2 
  26.  
  27. -- Host list data... 
  28. Cat_mouse_host_list = { 
  29. 	[1] = {	 
  30. 		type = TYPE_BUTTON, 
  31. 		label = "CAT_MOUSE_PLAY_AGAIN", 
  32. 		id = MENU_ID_PLAY_AGAIN, 
  33. 	}, 
  34. 	[2] = {	 
  35. 		type = TYPE_BUTTON, 
  36. 		label = "CAT_MOUSE_QUIT_DIVERSION", 
  37. 		id = MENU_ID_STOP, 
  38. 	} 
  39. } 
  40.  
  41. -- Host list data... 
  42. Cat_mouse_client_list = { 
  43. 	[1] = {	 
  44. 		type = TYPE_BUTTON, 
  45. 		label = "COMPLETION_CONTINUE", 
  46. 		id = MENU_ID_CONTINUE, 
  47. 	}, 
  48. } 
  49.  
  50. function cat_mouse_results_init() 
  51. 	Cat_mouse_results_doc_h = vint_document_find("cat_mouse_results") 
  52.  
  53. 	--init megalist... 
  54. 	Cat_mouse_mega_list = Vdo_mega_list:new("megalist", 0, Cat_mouse_results_doc_h, "cat_mouse_results.lua", "Cat_mouse_mega_list") 
  55. 	Input_tracker = Vdo_input_tracker:new() 
  56. 		 
  57. 	--Set background type of bg_saints... 
  58. 	bg_saints_set_type(BG_TYPE_PAUSE) 
  59. 	bg_saints_slide_in() 
  60.  
  61. 	vint_dataresponder_request("cat_mouse_results_populate", "cat_mouse_results_populate", 0, 0) 
  62. 	--cat_mouse_results_populate(DIV_TYPE_CAT_MOUSE, STATUS_TYPE_WIN, true, SCORE_TYPE_POINTS, "HARRIS", 4000, "MASTER", 3000, 4000) 
  63. end 
  64.  
  65.  
  66. function cat_mouse_results_cleanup() 
  67. 	if Mouse_input_tracker ~= 0 then 
  68. 		Mouse_input_tracker:subscribe(false) 
  69. 	end 
  70. 	Input_tracker:subscribe(false) 
  71. end 
  72.  
  73. --	@param	diversion_type	 		Diversion type (0 = Death Tag, 1 = Cat & Mouse, 2 = Co-op Survival) 
  74. -- @param 	win_status				Win status (0 = Win, 1 = Lose, 2 = Tie) 
  75. -- @param	is_host					Am I the host? (used for determining whether or not to let the player "retry") 
  76. -- @param	points_type				Points type (0 = Points, 1 = Kills) 
  77. -- @param 	my_name					My name				 
  78. -- @param 	my_points				My points				 
  79. -- @param 	enemy_name				Partner's name			 
  80. -- @param 	enemy_points			Partner's points 
  81. -- @param 	reward					Reward 
  82. 	 
  83. function cat_mouse_results_populate(diversion_type, win_status, is_host, points_type, my_name, my_points, enemy_name, enemy_points, reward) 
  84. 	 
  85. 	--Set Screen Title 
  86. 	local diversion_titles = { 
  87. 		[DIV_TYPE_DEATHTAG] = "DIVERSION_COOP_DEATH_TAG_TITLE",			--Death Tag 
  88. 		[DIV_TYPE_CAT_MOUSE] = "DIVERSION_COOP_CAT_AND_MOUSE_TITLE",	--Cat And Mouse	 
  89. 		[DIV_TYPE_SURVIVAL] = "DIVERSION_COOP_SURVIVAL_TITLE",			--Survival 
  90. 	}	 
  91. 	local title_string = diversion_titles[diversion_type] 
  92. 	 
  93. 	local title_game_h = vint_object_find("title_game_txt") 
  94. 	vint_set_property(title_game_h, "text_tag", title_string) 
  95. 	 
  96. 	--Win Status 
  97. 	local status_titles = { 
  98. 		[STATUS_TYPE_WIN] = "MP_WINNERS_YOU_WIN",		--You Win 
  99. 		[STATUS_TYPE_LOSE] = "MP_WINNERS_YOU_LOSE",	--You Lose 
  100. 		[STATUS_TYPE_TIE] = "MP_WINNERS_TIE"			--Tie 
  101. 	} 
  102. 	 
  103. 	local status_string = status_titles[win_status] 
  104. 	 
  105. 	local title_status_h = vint_object_find("title_status_txt") 
  106. 	vint_set_property(title_status_h, "text_tag", status_string) 
  107. 	 
  108. 	if win_status == STATUS_TYPE_LOSE then 
  109. 		vint_set_property(title_status_h, "tint", COLOR_CAT_MOUSE_TITLE_LOSE.R, COLOR_CAT_MOUSE_TITLE_LOSE.G, COLOR_CAT_MOUSE_TITLE_LOSE.B) 
  110. 	elseif win_status == STATUS_TYPE_TIE then 
  111. 		vint_set_property(title_status_h, "tint", COLOR_CAT_MOUSE_TITLE_TIE.R, COLOR_CAT_MOUSE_TITLE_TIE.G, COLOR_CAT_MOUSE_TITLE_TIE.B) 
  112. 	end 
  113. 	 
  114. 	--Show Scores 
  115. 		 
  116. 	--Determine winner position 
  117. 	local winner_name = my_name 
  118. 	local winner_points = my_points 
  119. 	local loser_name = my_name 
  120. 	local loser_points = my_points 
  121. 	if my_points >= enemy_points then 
  122. 		-- Host is winner 
  123. 		loser_name = enemy_name 
  124. 		loser_points = enemy_points 
  125. 	else 
  126. 		winner_name = enemy_name 
  127. 		winner_points = enemy_points 
  128. 	end 
  129. 	 
  130. 	--Winner 
  131. 	local score_winner_label_txt_h = vint_object_find("score_winner_label_txt") 
  132. 	local score_winner_value_txt_h = vint_object_find("score_winner_value_txt") 
  133. 	vint_set_property(score_winner_label_txt_h, "text_tag", winner_name) 
  134. 	vint_set_property(score_winner_value_txt_h, "text_tag", format_cash(winner_points)) 
  135.  
  136. 	--Loser 
  137. 	local score_loser_label_txt_h = vint_object_find("score_loser_label_txt") 
  138. 	local score_loser_value_txt_h = vint_object_find("score_loser_value_txt") 
  139. 	vint_set_property(score_loser_label_txt_h, "text_tag", loser_name) 
  140. 	vint_set_property(score_loser_value_txt_h, "text_tag", format_cash(loser_points)) 
  141. 	 
  142. 	--Set points Description string for scores 
  143. 	local points_string = "" 
  144. 	if points_type == SCORE_TYPE_POINTS then 
  145. 		points_string = "HUD_DIVERSION_POINTS" 
  146. 	elseif points_type == SCORE_TYPE_KILLS then 
  147. 		points_string = "MULTI_MENU_STATS_KILLS" 
  148. 	end 
  149. 	 
  150. 	local score_loser_type_txt_h 	= vint_object_find("score_loser_type_txt") 
  151. 	local score_winner_type_txt_h = vint_object_find("score_winner_type_txt") 
  152. 	vint_set_property(score_loser_type_txt_h, "text_tag", points_string) 
  153. 	vint_set_property(score_winner_type_txt_h, "text_tag", points_string) 
  154. 	 
  155. 	local cash_award_type_txt_h = vint_object_find("cash_award_label") 
  156. 	vint_set_property(cash_award_type_txt_h, "text_tag", "HUD_DIVERSION_CASH_AWARDED") 
  157. 	 
  158. 	--Move points to align with scores... 
  159. 	local winner_val_x, winner_val_y = vint_get_property(score_winner_value_txt_h, "anchor") 
  160. 	local loser_val_x, loser_val_y = vint_get_property(score_loser_value_txt_h, "anchor") 
  161. 	local winner_val_width, winner_val_height = element_get_actual_size(score_winner_value_txt_h)  
  162. 	local loser_val_width, loser_val_height = element_get_actual_size(score_loser_value_txt_h)  
  163. 	 
  164. 	local x, y = vint_get_property(score_winner_type_txt_h, "anchor") 
  165. 	vint_set_property(score_winner_type_txt_h, "anchor", winner_val_x + winner_val_width + 10, y) 
  166. 	 
  167. 	x, y = vint_get_property(score_loser_type_txt_h, "anchor") 
  168. 	vint_set_property(score_loser_type_txt_h, "anchor", loser_val_x + loser_val_width + 10, y) 
  169. 	 
  170. 	--My Reward 
  171. 	local award_grp_h = vint_object_find("award_grp") 
  172. 	local cash_award_value_txt_h = vint_object_find("cash_award_value_txt") 
  173. 	 
  174. 	if reward > 0 then 
  175. 		vint_set_property(cash_award_value_txt_h, "text_tag", "{GAME_CASH}" .. format_cash(reward)) 
  176. 	else 
  177. 		vint_set_property(award_grp_h, "visible", false) 
  178. 	end 
  179. 	 
  180. 	-- List data is different if we are the host or client... 
  181. 	local list_data = Cat_mouse_host_list 
  182. 	if is_host == false then 
  183. 		list_data = Cat_mouse_client_list 
  184. 	end 
  185. 	 
  186. 	Cat_mouse_mega_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY) 
  187. 	Cat_mouse_mega_list:draw_items(list_data, 1, 430) 
  188. 	 
  189. 	--TODO: Play any Animations here... 
  190. 	 
  191. 	Input_tracker:add_input("nav_up", 	"cat_mouse_results_input", 50) 
  192. 	Input_tracker:add_input("nav_down", "cat_mouse_results_input", 50) 
  193. 	Input_tracker:add_input("select",	"cat_mouse_results_input", 50) 
  194. 	Input_tracker:add_input("back", 		"cat_mouse_results_input", 50) 
  195. 	Input_tracker:subscribe(true) 
  196. 	 
  197. 	if game_get_platform() == "PC" then 
  198. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  199. 		Cat_mouse_mega_list:add_mouse_inputs("cat_mouse_results", Mouse_input_tracker) 
  200. 		Mouse_input_tracker:subscribe(true) 
  201. 	end 
  202. end 
  203.  
  204. function cat_mouse_results_input(event) 
  205. 	if event == "select" then 
  206. 		if Cat_mouse_mega_list:list_is_playing() == false then 
  207. 			--Select item from list and do it 
  208. 			local id = Cat_mouse_mega_list:get_id() 
  209. 			if id == MENU_ID_PLAY_AGAIN or id == MENU_ID_CONTINUE then 
  210. 				--select continue 
  211. 				cat_mouse_results_select(CAMSUR_RETRY) 
  212. 			elseif id == MENU_ID_STOP then 
  213. 				cat_mouse_results_select(CAMSUR_QUIT) 
  214. 			end 
  215. 			pop_screen() 
  216. 		end 
  217. 	elseif event == "back" then 
  218. 		cat_mouse_results_select(CAMSUR_QUIT) 
  219. 		pop_screen() 
  220. 	elseif event == "nav_up" then 
  221. 		Cat_mouse_mega_list:move_cursor(-1) 
  222. 	elseif event == "nav_down" then 
  223. 		Cat_mouse_mega_list:move_cursor(1) 
  224. 	end 
  225. end 
  226.  
  227. ------------------------------------------------------------------------------- 
  228. -- Mouse Inputs 
  229. --  
  230. function cat_mouse_results_mouse_click(event, target_handle) 
  231. 	if Cat_mouse_mega_list:list_is_playing() == false then 
  232. 		-- If the target_handle matches a button, activate it 
  233. 		local new_index = Cat_mouse_mega_list:get_button_index(target_handle) 
  234. 		if new_index ~= 0 then 
  235. 			-- Enter an option if the target_handle is in the List 
  236. 			Cat_mouse_mega_list:set_selection(new_index) 
  237. 			cat_mouse_results_input("select") 
  238. 		end 
  239. 	end 
  240. end 
  241.  
  242. function cat_mouse_results_mouse_move(event, target_handle) 
  243. 	local new_index = Cat_mouse_mega_list:get_button_index(target_handle) 
  244. 	if new_index ~= 0 then 
  245. 		-- Set the button as the new selected highlight 
  246. 		Cat_mouse_mega_list:set_selection(new_index) 
  247. 		Cat_mouse_mega_list:move_cursor(0, true) 
  248. 	end 
  249. end 
  250.  
  251. function cat_mouse_results_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  252. end 
  253.  
  254. function cat_mouse_results_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  255. end 
  256.  
  257. function cat_mouse_results_drag_release(event, target_handle, mouse_x, mouse_y) 
  258. end