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