./cell_missions.lua

  1. --Lists 
  2. Mission_list = -1 
  3. Objective_list = -1 
  4.  
  5. --Doc handle 
  6. local Cell_missions_doc_h = -1 
  7.  
  8. local just_swapped = false 
  9.  
  10. --Input trackers 
  11. local Input_tracker_left = -1 
  12. local Input_tracker_right = -1 
  13. local Active_input = -1 
  14. local Hint_bar_mouse_input_tracker = -1 
  15. local Mouse_input_tracker = -1 
  16.  
  17. --Challenges and complete quests index in quests list 
  18. local Challenges_index = -1 
  19. local Completed_quests_index = -1 
  20. local Quests_index = -1 
  21.  
  22. --Which platform are we? 
  23. local Game_platform = false 
  24.  
  25. --Used to load challenges images 
  26. local Cell_missions_peg_load_thread_h = -1 
  27.  
  28. local Challenge_tutorial_pending_clear = false 
  29.  
  30. --List indices 
  31. local Curr_mission_index = -1 
  32. local Curr_objective_index = -1 
  33.  
  34. --Used for quest info 
  35. local Hint_bar = -1 
  36. local Arrow_img_h = -1 
  37. local Arrow_x =  -1 
  38. local Arrow_y = -1 
  39. local Challenges_grp_h = -1 
  40. local Challenges_overview_grp_h = -1 
  41. local Summary_grp_h = -1 
  42.  
  43. --HVS_RCK - Current left-side quest 
  44. local Current_left_quest = -1 
  45.  
  46. --Screen title 
  47. local Cell_missions_title_h = -1 
  48.  
  49. --Flags for switch to challenges and completed quests states 
  50. local Challenges_is_active = true 
  51. local Completed_quests_is_active = false 
  52.  
  53. local In_mission = false 
  54. local Objective_is_valid = true 
  55.  
  56. --Data tables 
  57. local Objective_data = {} 
  58. local Challenges_data = {} 
  59. local Completed_quests_data = {} 
  60. local Crit_path_quest_data = {} 
  61. local Full_challenge_list = {} 
  62. Mission_data = {} 
  63.  
  64. --Temp data tables 
  65. local Cell_missions_completed_objective_temp = {} 
  66. local Cell_missions_uncompleted_objective_temp = {} 
  67. local Cell_missions_rewards_temp = {} 
  68. local Cell_missions_challenges_temp = { 
  69. 	{ -- Activities 
  70. 		category = {}, 
  71. 		label_name = "CHALLENGE_HEADER_ACTIVITY" 
  72. 	}, 
  73. 	{ -- Diversions 
  74. 		category = {}, 
  75. 		label_name = "CHALLENGE_HEADER_DIVERSIONS" 
  76. 	}, 
  77. 	{ -- Arcane Powers 
  78. 		category = {}, 
  79. 		label_name = "CHALLENGE_HEADER_ARCANE" 
  80. 	}, 
  81. 	{ -- Weapons 
  82. 		category = {}, 
  83. 		label_name = "CHALLENGE_HEADER_WEAPONS" 
  84. 	}, 
  85. 	{ -- Enemies 
  86. 		category = {}, 
  87. 		label_name = "CHALLENGE_HEADER_ENEMIES" 
  88. 	}, 
  89. 	{ -- Misc 
  90. 		category = {}, 
  91. 		label_name = "CHALLENGE_HEADER_MISC" 
  92. 	}, 
  93. } 
  94.  
  95. --Constants 
  96. local MISSION_LIST_WIDTH = 400 
  97. local OBJECTIVE_LIST_WIDTH = 465 
  98. local OBJECT_LIST_MAX_BUTTONS = 7 
  99. local OBJECT_LIST_MAX_BUTTONS_COMPLETED = 10 
  100. local MISSION_LIST_MAX_BUTTONS = 13 
  101. local INPUT_LEFT = 0 
  102. local INPUT_RIGHT = 1 
  103. local LIST_ALPHA_ACTIVE = 1 
  104. local LIST_ALPHA_INACTIVE = .5 
  105. local ARROW_OFFSET = 37.5 
  106.  
  107. local REWARD_TYPE_ACHIEVEMENT = 0 
  108. local REWARD_TYPE_UNLOCKABLE = 1 
  109.  
  110. local OBJECTIVE_TYPE_MISSION = 0 
  111. local OBJECTIVE_TYPE_ACTIVITY = 1 
  112. local OBJECTIVE_TYPE_RIFT = 2 
  113. local OBJECTIVE_TYPE_COLLECTIBLE = 3 
  114.  
  115. local GAMEPLAY_TYPE_MISSION = 0 
  116.  
  117. -- These are from mission_info.h 
  118. local MT_MISSION_NONE 		= -1 
  119. local MT_MISSION 				= 0 
  120. local MT_ACTIVITY				= 1 
  121. local MT_SILENT				= 2 
  122. local MT_DIVERSION_ACTIVE	= 3 
  123.  
  124. -- challenge overview junk 
  125. local Cell_mission_chal_ov_total = 0 
  126. local Cell_mission_chal_ov_completed = 0 
  127. local Cell_mission_chal_ov_milestone_goal = 0 
  128. local Cell_mission_chal_ov_progress = 0 
  129. local Cell_mission_chal_ov_cash_reward = 0 
  130. local Cell_mission_chal_ov_respect_reward = 0 
  131. local Cell_mission_chal_ov_unlockable_reward = 0 
  132.  
  133. --Hints data 
  134. local Mission_list_hints_data = { 
  135. 	{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  136. 	{CTRL_MENU_BUTTON_A, "MENU_SELECT"}, 
  137. 	 
  138. } 
  139.  
  140. local Clear_objective_hints_data = { 
  141. 	{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  142. 	{CTRL_MENU_BUTTON_A, "MENU_SELECT"}, 
  143. 	{CTRL_BUTTON_X, "MENU_CLEAR_OBJECTIVE"}, 
  144. } 
  145.  
  146. local Objective_list_hints_data = { 
  147. 	{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  148. 	{CTRL_MENU_BUTTON_A, "MENU_START_OBJECTIVE"}, 
  149. 	{CTRL_BUTTON_X, "MENU_CLEAR_OBJECTIVE"}, 
  150. } 
  151.  
  152. local Challenges_hints_data = { 
  153. 	{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  154. 	{CTRL_MENU_BUTTON_A, "MENU_SELECT"}, 
  155. 	{CTRL_BUTTON_X, "MENU_CLEAR_OBJECTIVE"}, 
  156. } 
  157.  
  158. local Completed_quests_hints_data = { 
  159. 	{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  160. } 
  161.  
  162. local In_mission_hints_data = { 
  163. 	{CTRL_MENU_BUTTON_A, "MENU_SELECT"}, 
  164. 	{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  165. 	{CTRL_BUTTON_X, "HUD_CANCEL_MISSION"}, 
  166. } 
  167.  
  168. --In a quest, but no mission is active (hotspots, flashpoints, survival) 
  169. local No_mission_hints_data = { 
  170. 	{CTRL_MENU_BUTTON_A, "MENU_SELECT"}, 
  171. 	{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  172. } 
  173.  
  174.  
  175. --Data example 
  176. 	--[[ [1] = { 
  177. 		id = "m01", 
  178. 		label = "THE POWER OF LOVE", 
  179. 		type = TYPE_BUTTON, 
  180. 		summary = 3515151786, 
  181. 		contact_img = "ui_homie_35_donnie", 
  182. 		icon_name = "ui_homie_35_donnie", 
  183. 		contact_name = "DONNIE", 
  184. 		reward_cache = 2000, 
  185. 		reward_power = 1000, 
  186. 		units_type = "ORBS", 
  187. 		units_collected = 20, 
  188. 		units_total = 100, 
  189. 		objective_data = { 
  190. 			[1] = { 
  191. 				label = "OBJECTIVES", 
  192. 				type = TYPE_HEADER,				 
  193. 			}, 
  194. 			[2] = { 
  195. 				label = "HACK LET'S PRETEND", 
  196. 				type = TYPE_BUTTON,				 
  197. 			},	 
  198. 			[3] = { 
  199. 				label = "INSURANCE FRAUD", 
  200. 				type = TYPE_BUTTON, 
  201. 			}, 
  202. 			[4] = { 
  203. 				label = "", 
  204. 				type = TYPE_LINE_BREAK, 
  205. 			}, 
  206. 			[5] = { 
  207. 				label = "COMPLETED", 
  208. 				type = TYPE_HEADER, 
  209. 			}, 
  210. 			[6] = { 
  211. 				label = "HELI ASSAULT", 
  212. 				type = TYPE_BUTTON, 
  213. 				completed = true, 
  214. 			}, 
  215. 		}, 
  216. 	}, 
  217. 	[2] = { 
  218. 		id = "m02", 
  219. 		label = "BOATS 'N HOES", 
  220. 		type = TYPE_BUTTON, 
  221. 		summary = 3515151786, 
  222. 		contact_img = "ui_homie_35_julius", 
  223. 		contact_name = "JULIUS", 
  224. 		reward_cache = 2500, 
  225. 		reward_power = 1500,	 
  226. 		objective_data = { 
  227. 			[1] = { 
  228. 				label = "OBJECTIVES", 
  229. 				type = TYPE_HEADER, 
  230. 			},			 
  231. 			[2] = { 
  232. 				label = "BLAZIN", 
  233. 				type = TYPE_BUTTON, 
  234. 			}, 
  235. 			[3] = { 
  236. 				label = "", 
  237. 				type = TYPE_LINE_BREAK, 
  238. 			}, 
  239. 			[4] = { 
  240. 				label = "REWARDS", 
  241. 				type = TYPE_HEADER, 
  242. 			},				 
  243. 			[5] = { 
  244. 				label = "WRAITH", 
  245. 				type = TYPE_BUTTON, 
  246. 			},			 
  247. 		}, 
  248. 	}, 
  249. } ]] 
  250.  
  251.  
  252. function cell_missions_init() 
  253.  
  254. 	vint_force_lua_gc() --Force Garbage Collection 
  255. 	pause_map_dump() 
  256. 	 
  257. 	Cell_missions_doc_h = vint_document_find("cell_missions") 
  258. 	 
  259. 	Mission_list = Vdo_mega_list:new("mission_list", 0, Cell_missions_doc_h, "cell_missions.lua", "Mission_list") 
  260. 	Objective_list = Vdo_mega_list:new("objective_list", 0, Cell_missions_doc_h, "cell_missions.lua", "Objective_list") 
  261. 	 
  262. 	Input_tracker_left = Vdo_input_tracker:new() 
  263. 	Input_tracker_left:add_input("map", "cell_missions_exit_to_game", 50) 
  264. 	Input_tracker_left:add_input("select", "cell_missions_nav_a", 50) 
  265. 	Input_tracker_left:add_input("back", "cell_missions_nav_b", 50)	 
  266. 	Input_tracker_left:add_input("alt_select", "cell_missions_nav_x", 50)	 
  267. 	Input_tracker_left:add_input("nav_up", "cell_missions_nav_list", 50) 
  268. 	Input_tracker_left:add_input("nav_down", "cell_missions_nav_list", 50) 
  269. 	Input_tracker_left:add_input("nav_left", "cell_missions_nav_left", 50) 
  270. 	Input_tracker_left:add_input("nav_right", "cell_missions_nav_right", 50) 
  271. 	if game_get_platform() == "PC" then 
  272. 		Input_tracker_left:add_input("alt_joy_up", "cell_missions_scroll_left", 50) 
  273. 		Input_tracker_left:add_input("alt_joy_down", "cell_missions_scroll_left", 50) 
  274. 	end 
  275. 	Input_tracker_left:add_input("all_unassigned", "cell_missions_nav_do_nothing", 50) 
  276. 	Input_tracker_left:subscribe(false) 
  277. 		 
  278. 	Input_tracker_right = Vdo_input_tracker:new() 
  279. 	Input_tracker_right:add_input("map", "cell_missions_exit_to_game", 50) 
  280. 	Input_tracker_right:add_input("select", "cell_missions_nav_a", 50) 
  281. 	Input_tracker_right:add_input("back", "cell_missions_nav_b", 50)	 
  282. 	Input_tracker_right:add_input("alt_select", "cell_missions_nav_x", 50)	 
  283. 	Input_tracker_right:add_input("nav_up", "cell_missions_nav_list", 50) 
  284. 	Input_tracker_right:add_input("nav_down", "cell_missions_nav_list", 50) 
  285. 	Input_tracker_right:add_input("nav_left", "cell_missions_nav_left", 50) 
  286. 	Input_tracker_right:add_input("nav_right", "cell_missions_nav_right", 50) 
  287. 	Input_tracker_right:add_input("all_unassigned", "cell_missions_nav_do_nothing", 50) 
  288. 	Input_tracker_right:subscribe(false) 
  289. 	 
  290. 	Mouse_input_tracker = Vdo_input_tracker:new() 
  291. 	Hint_bar_mouse_input_tracker = Vdo_input_tracker:new()	 
  292. 	 
  293. 	Hint_bar = Vdo_hint_bar:new("cell_hint_bar", 0, Cell_missions_doc_h) 
  294. 	 
  295. 	Game_platform = game_get_platform() 
  296. 	 
  297. 	--Setup hints for PC 
  298. 	if Game_platform == "PC" then 
  299. 		Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000) 
  300. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  301. 	end 
  302. 	 
  303. 	--Set up title 
  304. 	Cell_missions_title_h = Vdo_cell_title:new("cell_title", 0, Cell_missions_doc_h) 
  305. 	Cell_missions_title_h:set_text("MENU_MISSIONS") 
  306. 	Cell_missions_title_h:set_icon("ui_cell_icon_missions") 
  307. 	Cell_missions_title_h:play_dots_anim() 
  308. 	 
  309. 	--Set left as active input intially 
  310. 	--Controls unlocked after sceen animates in 
  311. 	Active_input = INPUT_LEFT	 
  312. 	 
  313. 	--Hide the screen until peg is loaded 
  314. 	local screen_grp_h = vint_object_find("screen_grp", 0, Cell_missions_doc_h) 
  315. 	vint_set_property(screen_grp_h, "alpha", 0) 
  316. 	 
  317. 	--Setup initial alpha and color of lists 
  318. 	Mission_list:set_alpha(LIST_ALPHA_ACTIVE) 
  319. 	Objective_list:set_alpha(LIST_ALPHA_INACTIVE) 
  320. 	 
  321. 	Mission_list:set_highlight_color(COLOR_SAINTS_PURPLE) 
  322. 	Objective_list:set_highlight_color(COLOR_LIST_LOST_FOCUS)	 
  323.  
  324. 	--Store off arrow position and color arrow 
  325. 	Arrow_img_h = vint_object_find("arrow_img", 0, Cell_missions_doc_h) 
  326. 	Arrow_x, Arrow_y = vint_get_property(Arrow_img_h, "anchor") 
  327. 	vint_set_property(Arrow_img_h, "tint", COLOR_SAINTS_PURPLE.R, COLOR_SAINTS_PURPLE.G, COLOR_SAINTS_PURPLE.B) 
  328. 	 
  329. 	--Find summary grp for when we need it 
  330. 	Summary_grp_h = vint_object_find("summary_grp", 0, Cell_missions_doc_h) 
  331. 	 
  332. 	--Hide challenges grp until we need it 
  333. 	Challenges_grp_h = vint_object_find("challenges_grp", 0, Cell_missions_doc_h) 
  334. 	vint_set_property(Challenges_grp_h, "visible", false) 
  335. 	 
  336. 	--Hide challenges overview grp until needed 
  337. 	Challenges_overview_grp_h = vint_object_find("challenges_overview_grp", 0, Cell_missions_doc_h) 
  338. 	vint_set_property(Challenges_overview_grp_h, "visible", false) 
  339. 	 
  340. 	--Make sure background is visible in case we enter directly from HUD to quest log 
  341. 	cell_show_frame() 
  342. 	 
  343. 	--Get quest data from code 
  344. 	cell_missions_quests_update() 
  345. 	 
  346. 	--Draw the quest list 
  347. 	cell_missions_update(Mission_data, nil, true) 
  348. 	--Update challenges		 
  349. 	cell_missions_challenges_update(2, false) 
  350. 	 
  351. 	--Hide A button 
  352. 	Objective_list:highlight_set_button("") 
  353. 	Objective_list:stop_marquee() 
  354. 	 
  355. 	--Load challenges peg 
  356. 	Cell_missions_peg_load_thread_h = thread_new("cell_missions_peg_load") 
  357. 	 
  358. 	-- grab challenges data 
  359. 	vint_dataresponder_request( "saintsbook_categories", "cell_missions_chal_overview_update", 0, 4 ) 
  360.  
  361.   --HVS_RCK - Switch to Challenges immediately. We're not going to show anything else.	 
  362. 	Challenges_is_active = true 
  363. 				 
  364. 	--Update screen title 
  365. 	Cell_missions_title_h:set_text("QUEST_LOG_CHALLENGES", 320) 
  366. 	 
  367. 	--Save off challenges index for when we return 
  368. 	Challenges_index = Curr_mission_index 
  369. 	 
  370. 	--Update challenges and redraw list				 
  371. 	cell_missions_challenges_update(2, true) 
  372.  
  373. 	--Call the nav function clear the first quest's new status 
  374. 	cell_missions_nav_list(0) 
  375. 	 
  376. 	if Game_platform == "PC" then 
  377. 		Hint_bar_mouse_input_tracker:remove_all() 
  378. 	end 
  379. 	 
  380. 	Hint_bar:set_hints(Mission_list_hints_data) 
  381. 	 
  382. 	if Game_platform == "PC" then 
  383. 		Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000) 
  384. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  385. 	end 
  386. 	 
  387. 	cell_foreground_update_tutorial("set_challenge") 
  388. end 
  389.  
  390.  
  391. --Cleanup, kill threads, unload pegs, reload pause map 
  392. function cell_missions_cleanup() 
  393. 	game_peg_unload("ui_bms_sb_challenges") 
  394. 	 
  395. 	pause_map_restore() 
  396. 	 
  397. 	thread_kill(Cell_missions_peg_load_thread_h) 
  398. 	 
  399. 	Cell_missions_peg_load_thread_h = -1 
  400. 	 
  401. 	Input_tracker_left:remove_all() 
  402. 	Input_tracker_left:subscribe(false) 
  403. 	Input_tracker_right:remove_all() 
  404. 	Input_tracker_right:subscribe(false) 
  405. 	 
  406. 	if Mouse_input_tracker ~= nil then 
  407. 		Mouse_input_tracker:remove_all() 
  408. 		Mouse_input_tracker:subscribe(false) 
  409. 		Hint_bar_mouse_input_tracker:remove_all() 
  410. 		Hint_bar_mouse_input_tracker:subscribe(false) 
  411. 	end 
  412. 	 
  413. 	 
  414. 	Hint_bar:cleanup() 
  415. 	 
  416. 	table_clear(Objective_data, true) 
  417. 	table_clear(Challenges_data, true) 
  418. 	table_clear(Completed_quests_data, true) 
  419. 	table_clear(Crit_path_quest_data, true) 
  420. 	table_clear(Mission_data, true) 
  421. 	table_clear(Cell_missions_completed_objective_temp, true) 
  422. 	table_clear(Cell_missions_uncompleted_objective_temp, true) 
  423. 	table_clear(Cell_missions_rewards_temp, true) 
  424. 	table_clear(Cell_missions_challenges_temp, true) 
  425. 	table_clear(Full_challenge_list, true) 
  426. 	 
  427. 	 
  428. end 
  429.  
  430.  
  431. --Load challenges peg 
  432. function cell_missions_peg_load() 
  433. 	pause_map_dump( true ) 
  434. 	game_peg_load_with_cb("cell_missions_peg_load_complete", 1, "ui_bms_sb_challenges") 
  435. end 
  436.  
  437.  
  438. --Everything is loaded, transition screen in 
  439. function cell_missions_peg_load_complete() 
  440. 	 
  441. 	--Transition screen in and unlock controls 
  442. 	if Missions_from_menu then 
  443. 		--Transition the screen in... 
  444. 		cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MISSIONS, CELL_SCREEN_MAIN, cell_missions_unlock_controls) 
  445. 	else 
  446. 		--Transition the screen in... 
  447. 		cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MISSIONS, CELL_SCREEN_NONE, cell_missions_unlock_controls) 
  448. 	end	 
  449. end 
  450.  
  451.  
  452. ------------------------------------------------------------------------------------------------ 
  453. -- Function cell_missions_update() 
  454. -- 
  455. -- @param data					-- List data 
  456. -- @param index				-- Current index 
  457. -- @param draw_list			-- Determines if the Mission list should redraw or not 
  458. -- 
  459. -- Quest Log Modes: 
  460. -- 
  461. -- 1. In a mission with an active objective 
  462. --			-Hide everything expect Quest Title and Active Objective. 
  463. --       -The user can only back out or exit mission from this state. 
  464. -- 
  465. -- 2. In a mission with NO active objective 
  466. --			-Show the quest log, when the user trys to start an objective- 
  467. --       -throw up a popup that says you can't start an objective right now. 
  468. -- 
  469. -- 3. Not in a mission 
  470. --			-Show the quest log as normal. 
  471. -- 
  472. ------------------------------------------------------------------------------------------------ 
  473. function cell_missions_update(data, index, draw_list) 
  474. 	 
  475. 	--Find active quest  
  476. 	local active_quest_index = nil 
  477. 	for i=1, #data do 
  478. 		if data[i].quest_pinned == true then 
  479. 			active_quest_index = i				 
  480. 		end				 
  481. 	end 
  482.  
  483. 	local valid_quest_index = nil 
  484. 	for i=1, #data do 
  485. 		if data[i].type ~= TYPE_HEADER then 
  486. 			valid_quest_index = i 
  487. 			break 
  488. 		end 
  489. 	end 
  490. 	 
  491. 	--Challenges is always second to last 
  492. 	Challenges_index = #Mission_data - 1 
  493. 	--If no index specified, go to active quest 
  494. 	if index == nil then 
  495. 		index = active_quest_index or valid_quest_index  
  496. 	end	 
  497. 	 
  498. 	--Store off mission index 
  499. 	Curr_mission_index = index 
  500. 	 
  501. 	--Completed quests is always last 
  502. 	--Completed_quests_index = #Mission_data 
  503. 	 
  504. 	--Store off current mission 
  505. 	local curr_mission = data[Curr_mission_index]	 
  506.  
  507. 	local in_mission_grp_h = vint_object_find("in_mission_grp", 0, Cell_missions_doc_h) 
  508. 	vint_set_property(in_mission_grp_h, "visible", false)	 
  509.  
  510. 	--HVS_JPM fix for HS 6605 - not sure how current mission is becoming null here, but if it is, we should just early out 
  511. 	if curr_mission == nil then 
  512. 		return 
  513. 	end 
  514. 	 
  515. 	--Loop through objective data to find active objective and first available objective 
  516. 	local active_objective_index = nil 
  517. 	local available_objective_index = -1 
  518. 	for i=1, #curr_mission.objective_data do 
  519. 		local curr_objective = curr_mission.objective_data[i] 
  520. 	 
  521. 		if curr_objective.quest_pinned == true then 
  522. 			active_objective_index = i							 
  523. 		end	 
  524. 		 
  525. 		if curr_objective.completed == false and available_objective_index == -1 then 
  526. 			available_objective_index = i 
  527. 		end 
  528. 	end	 
  529. 		 
  530. 	--Figure out what state we're in	 
  531. 	--Are we in a mission?	 
  532. 	In_mission = not cell_missions_can_start_objective() 
  533. 	 
  534. 	local quest_log_grp_h = vint_object_find("quest_log_grp", 0, Cell_missions_doc_h) 
  535. 	vint_set_property(quest_log_grp_h, "visible", false)	 
  536. 	 
  537. 	 
  538. 	if In_mission then	 
  539. 		 
  540. 		-- HVS_JPM we don't need to do this for SRGAT because we don't have missions per say. Fixes HS 9581 
  541. 		--[[ 
  542. 		--Do we have an active objective 
  543. 		if active_quest_index ~= nil then 
  544. 					 
  545. 			--We're in a mission with a valid objective, go to in mission state 
  546. 			vint_set_property(in_mission_grp_h, "visible", true)	 
  547. 			vint_set_property(quest_log_grp_h, "visible", false)	 
  548. 			 
  549. 			if Game_platform == "PC" then --Hint bar is about to be reset, remove old input 
  550. 				Hint_bar_mouse_input_tracker:remove_all() 
  551. 			end 
  552. 			 
  553. 			local gameplay_type = game_get_in_progress_type() 
  554. 			 
  555. 			if game_get_in_progress_type() == -1 then 
  556. 				Hint_bar:set_hints(No_mission_hints_data) 	 
  557. 			else 
  558. 				if gameplay_type == MT_MISSION then 
  559. 					In_mission_hints_data[2][2] = "HUD_CANCEL_MISSION" 
  560. 				elseif gameplay_type == MT_ACTIVITY then 
  561. 					In_mission_hints_data[2][2] = "HUD_CANCEL_ACTIVITY" 
  562. 				elseif gameplay_type == MT_DIVERSION_ACTIVE then 
  563. 					In_mission_hints_data[2][2] = "HUD_CANCEL_DIVERSION" 
  564. 				end 
  565.  
  566. 				Hint_bar:set_hints(In_mission_hints_data)				 
  567. 			end 
  568.  
  569. 			if Game_platform == "PC" then --Hint bar has been reset so resubscribe mouse input 
  570. 				Hint_bar:set_highlight(0) 
  571. 				Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000) 
  572. 				Hint_bar_mouse_input_tracker:subscribe(true) 
  573. 			end 
  574.  
  575. 			--In mission text fields 
  576. 			local quest_title_txt_h = vint_object_find("quest_title_txt", 0 , Cell_missions_doc_h) 
  577. 			local objective_title_txt_h = vint_object_find("objective_title_txt", 0 , Cell_missions_doc_h) 
  578. 			 
  579. 			vint_set_property(quest_title_txt_h, "text_tag_crc", curr_mission.label_crc)			 
  580. 			vint_set_property(objective_title_txt_h, "text_tag_crc", curr_mission.objective_data[active_objective_index].label_crc)	 
  581.  
  582. 			return 
  583. 		else 
  584. 		--]]	 
  585. 		 
  586. 		--Set flag to deny objective start if/when it is selected 
  587. 		Objective_is_valid = false 
  588. 		--end 
  589. 	else	 
  590. 		 
  591. 		--Set flag to allow objectives to start 
  592. 		Objective_is_valid = true 
  593. 	end 
  594.  
  595. 	--Show Quest Log as normal 
  596. 	vint_set_property(in_mission_grp_h, "visible", false)	 
  597. 	vint_set_property(quest_log_grp_h, "visible", true)	 
  598. 	 
  599. 	if Game_platform == "PC" then --Hint bar is about to be reset, remove old input 
  600. 		Hint_bar_mouse_input_tracker:remove_all() 
  601. 	end 
  602. 		 
  603. 	Hint_bar:set_hints(Mission_list_hints_data)  
  604. 	 
  605. 	if Game_platform == "PC" then --Hint bar has been reset so resubscribe mouse input 
  606. 		Hint_bar:set_highlight(0) 
  607. 		Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000) 
  608. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  609. 	end		 
  610.  
  611. 	--Update summary info on right side 
  612. 	cell_missions_summary_update(curr_mission) 
  613. 	 
  614. 	--Skip redrawing the list if not required to save framerate 
  615. 	if draw_list == true then 
  616. 				 
  617. 		--Remove all inputs before drawing the list... 
  618. 		if Game_platform == "PC" then 
  619. 			Mouse_input_tracker:remove_all() 
  620. 		end 
  621.  
  622. 		--Draw missions list 
  623. 		Mission_list:draw_items(data, index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false) 
  624. 		 
  625. 		--Update mouse inputs because we've redrawn the list 
  626. 		if Game_platform == "PC" then 
  627. 			Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  628. 			if curr_mission.is_quest then 
  629. 				Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  630. 			end 
  631. 			Mouse_input_tracker:subscribe(true) 
  632. 		end 
  633. 	end			 
  634. 		 
  635. 	--Hide challenges grp until challenges are called 
  636. 	vint_set_property(Challenges_grp_h, "visible", false)			 
  637. 	 
  638. 	--We're not in challenges or completed quests so we are an active mission 
  639. 	if Challenges_is_active == false and Completed_quests_is_active == false then 
  640. 		if curr_mission.is_challenges ~= true and curr_mission.is_completed_quests ~= true then 
  641. 		 
  642. 			--Update objectives list 
  643. 			cell_missions_objective_update(curr_mission.objective_data, available_objective_index) 
  644. 			Objective_list:set_visible(true) 
  645. 			vint_set_property(Summary_grp_h, "visible", true) 
  646. 		end 
  647. 		 
  648. 		if curr_mission.is_challenges == true and Challenges_is_active == false then 
  649. 		 
  650. 			--Switch to challenges mode 
  651. 			Objective_list:set_visible(false) 
  652. 			vint_set_property(Summary_grp_h, "visible", false)			 
  653.  
  654. 			--Update info for challenges overview 
  655. 			cell_missions_challenges_overview_update()			 
  656. 			 
  657. 			--Show Challenges overview group 
  658. 			vint_set_property(Challenges_overview_grp_h, "visible", true)			 
  659. 		else 
  660. 		 
  661. 			--Hide Challenges overview group 
  662. 			vint_set_property(Challenges_overview_grp_h, "visible", false) 
  663. 		end 
  664. 		 
  665. 		if curr_mission.is_completed_quests == true then 
  666. 		 
  667. 			--Switch to completed missions mode 
  668. 			Objective_list:set_visible(false) 
  669. 			vint_set_property(Summary_grp_h, "visible", false)		 
  670. 		end 
  671. 	end 
  672. 	 
  673. 	--Handle completed quests mode 
  674. 	if Completed_quests_is_active == true then 
  675. 		vint_set_property(Summary_grp_h, "visible", true)		 
  676. 		 
  677. 		Mission_list:highlight_set_button("")		 
  678. 		 
  679. 		Objective_list:set_visible(true) 
  680. 				 
  681. 		cell_missions_objective_update(curr_mission.objective_data, 1)		 
  682. 	end	 
  683. end 
  684.  
  685.  
  686. --Update objectives list 
  687. function cell_missions_objective_update(data, index) 
  688. 	 
  689. 	--Save off Objective data 
  690. 	Objective_data = data 
  691. 	 
  692. 	if Game_platform == "PC" then 
  693. 		Mouse_input_tracker:remove_all() 
  694. 	end 
  695. 	 
  696. 	--Draw objectives list 
  697. 	if Completed_quests_is_active then 
  698. 		Objective_list:draw_items(data, index, OBJECTIVE_LIST_WIDTH, OBJECT_LIST_MAX_BUTTONS_COMPLETED, .7, true, false)	 
  699. 	else 
  700. 		Objective_list:draw_items(data, index, OBJECTIVE_LIST_WIDTH, OBJECT_LIST_MAX_BUTTONS, .7, true, false) 
  701. 	end 
  702. 	 
  703. 	--If objective list is active update mouse inputs 
  704. 	if Game_platform == "PC" then 
  705. 		Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  706. 		Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  707. 		Mouse_input_tracker:subscribe(true)			 
  708. 	end 
  709. 	 
  710. 	--If list is inactive or the highlighted option is a reward don't show A button 
  711. 	if Active_input == INPUT_LEFT then 
  712. 		Objective_list:highlight_set_button("")		 
  713. 		Objective_list:stop_marquee()		 
  714. 	end 
  715. end 
  716.  
  717.  
  718. ------------------------------------------------------------------------------- 
  719. -- Function cell_missions_quests_update() 
  720. -- 
  721. -- Get all quest data.  Add objectives to quest data.  Filter out any host only 
  722. -- quests.  Add headers for each section and store everything  
  723. -- back in Mission_data. 
  724. --  
  725. -- Quest sections: 
  726. -- 	PRIMARY QUESTS 
  727. -- 	SIDE QUESTS 
  728. -- 	HOST ONLY QUESTS 
  729. -- 	EXTRAS 
  730. -- 
  731. ------------------------------------------------------------------------------- 
  732. function cell_missions_quests_update() 
  733. 	 
  734. 	Crit_path_quest_data = {} 
  735. 	 
  736. 	-- Get the quest list 
  737. 	vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_quest_populate", 0 ) 
  738. 		 
  739. 	-- now get the objectives for each quest 
  740. 	cell_missions_objectives_add(Mission_data) 
  741. 	cell_missions_objectives_add(Crit_path_quest_data) 
  742. 	 
  743. 	-- and challenges list 
  744. 	 
  745. 	for k, category in pairs(Cell_missions_challenges_temp) do 
  746. 		Cell_missions_challenges_temp[k].category = { } 
  747. 	 
  748. 		Cell_missions_challenges_temp[k].category[ #Cell_missions_challenges_temp[k].category + 1 ] = { 
  749. 			name = 0, 
  750. 			label = Cell_missions_challenges_temp[k].label_name, 
  751. 			type = TYPE_HEADER,		 
  752. 			summary = 0, 
  753. 			contact_img = "ui_homie_gat", 
  754. 			contact_name = nil, 
  755. 			reward_cache = 0, 
  756. 			reward_power = 0,	 
  757. 			reward_label = nil, 
  758. 			icon_name = nil, 
  759. 			complete_pct = 0, 
  760. 			units_collected = 0, 
  761. 			units_total = 1, 
  762. 		} 
  763. 	end 
  764. 	 
  765. 	--vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_quest_populate", 0 ) 
  766. 	vint_dataresponder_request( "saintsbook_categories", "cell_missions_challenges_populate", 0, 3 ) 
  767. 	 
  768. 	-- Loop through mission data to check for any host only objectives 
  769. 	local host_only_quests_data ={} 
  770.  
  771. 	local temp_quest_data = {} 
  772. 	 
  773. 	-- HVS_RCK 10/20/14 - All of our quests as client come from the host. There's no need for this. 
  774. 	-- Filters out host only quests from side quests data 
  775. 	-- for k, quest in pairs(Mission_data) do 
  776. 		-- local host_only_count = 0 
  777. 		-- for k2, objective in pairs(quest.objective_data) do 
  778. 			 
  779. 			-- -- Determine which objectives are host only 
  780. 			-- if objective.host_only == true then 
  781. 				-- host_only_count = host_only_count + 1 
  782. 			-- end			 
  783. 		-- end 
  784. 		 
  785. 		-- -- If all objectives are host only (minus the header) then add it to the host only quest data 
  786. 		-- -- and remove it from the side quests data.  We compress the list later when we append all the sections. 
  787. 		-- if host_only_count == #quest.objective_data - 1 then 
  788. 			-- host_only_quests_data[#host_only_quests_data + 1] = table_clone( Mission_data[ k ] ) 
  789. 			-- Mission_data[ k ] = nil 
  790. 		-- end 
  791. 	-- end	 
  792. 	 
  793. 	-- Appends a table to a table 
  794. 	-- Compresses the list (if it's sparse) 
  795. 	local function append(a,b) 
  796. 		for k, v in pairs(b) do 
  797. 			a[ #a + 1 ] = v 
  798. 		end 
  799. 	end 
  800. 	 
  801. 	-- Sort the list by crit and non-crit path quests 
  802. 	local has_crit_path_quests = #Crit_path_quest_data > 0 
  803. 	local has_optional_quests = #Mission_data > 0		 
  804. 	 
  805. 	-- Append crit path quests 
  806. 	-- if has_crit_path_quests then	 
  807. 	 
  808. 		-- --Add a header for primary quests 
  809. 		-- temp_quest_data[ #temp_quest_data + 1 ] = { 
  810. 			-- label = "QUEST_LOG_PRIMARY_QUESTS",  
  811. 			-- type = TYPE_HEADER,  
  812. 			-- summary = 0, 
  813. 			-- contact_img = "ui_homie_gat", 
  814. 			-- contact_name = nil, 
  815. 			-- reward_cache = 0, 
  816. 			-- reward_power = 0, 
  817. 			-- objective_data = { }, 
  818. 			-- quest_complete = false, 
  819. 			-- is_challenges = true, 
  820. 			-- is_completed_quests = false, 
  821. 			-- equipped = false, 
  822. 			-- quest_pinned = false, 
  823. 			-- is_new = false, 
  824. 		-- }			 
  825. 	 
  826. 		-- append(temp_quest_data, Crit_path_quest_data) 
  827. 	-- end 
  828. 	 
  829. 	Quests_index = #temp_quest_data 
  830.  
  831. 	--Add a header for side quests 
  832. 	--HVS_RCK - Use this header for both players. 
  833. 	temp_quest_data[ #temp_quest_data + 1 ] = { 
  834. 		label = "QUEST_LOG_SIDE_QUESTS",  
  835. 		type = TYPE_HEADER,  
  836. 		summary = 0, 
  837. 		contact_img = "ui_homie_gat", 
  838. 		contact_name = nil, 
  839. 		reward_cache = 0, 
  840. 		reward_power = 0, 
  841. 		objective_data = { }, 
  842. 		quest_complete = false, 
  843. 		is_challenges = true, 
  844. 		is_completed_quests = false, 
  845. 		equipped = false, 
  846. 		quest_pinned = false, 
  847. 		is_new = false, 
  848. 	} 
  849. 		 
  850. 	-- Append side quests : If we're host only. Client will have their own list built from host quests below 
  851. 	if has_optional_quests == true then		 
  852. 		 
  853. 		append(temp_quest_data, Mission_data)	 
  854. 	end 
  855. 	 
  856. 	-- Append all host only quest, obviously if we are host we don't want to do this (but just be sure) 
  857. 	if #host_only_quests_data > 0 and game_get_is_coop_client() == true then 
  858. 		 
  859. 		--Add a header with host's gamertag for host only quests 
  860. 		-- temp_quest_data[ #temp_quest_data + 1 ] = { 
  861. 			-- label = "QUEST_LOG_HOST_QUESTS", 
  862. 			-- type = TYPE_HEADER,  
  863. 			-- summary = 0, 
  864. 			-- contact_img = "ui_homie_gat", 
  865. 			-- contact_name = nil, 
  866. 			-- reward_cache = 0, 
  867. 			-- reward_power = 0, 
  868. 			-- objective_data = { }, 
  869. 			-- quest_complete = false, 
  870. 			-- is_challenges = true, 
  871. 			-- is_completed_quests = false, 
  872. 			-- equipped = false, 
  873. 			-- quest_pinned = false, 
  874. 			-- is_new = false, 
  875. 		-- }	 
  876. 		 
  877. 		append(temp_quest_data, host_only_quests_data)	 
  878. 	end 
  879. 	 
  880. 	Mission_data = temp_quest_data 
  881. 	 
  882. 	-- Adding "Challenges" and "Completed Missions" to the bottom of the list 
  883. 	-- is_challenges = is the "Challenges" option in the list 
  884. 	-- is_completed_quests = is the "Completed Missions" option in the list 
  885. 	 
  886. 	local has_challenges = #Cell_missions_challenges_temp > 0  
  887. 	local has_completed_quests = #Completed_quests_data > 0 
  888. 	 
  889. 	-- If we have either, show the header for this section 
  890. 	-- if has_challenges or has_completed_quests then 
  891. 		-- Mission_data[ #Mission_data + 1 ] = { 
  892. 			-- id = "m01", 
  893. 			-- label = "QUEST_LOG_EXTRAS",				 
  894. 			-- type = TYPE_HEADER, 
  895. 			-- summary = 0, 
  896. 			-- contact_img = "ui_homie_gat", 
  897. 			-- contact_name = nil, 
  898. 			-- reward_cache = 0, 
  899. 			-- reward_power = 0, 
  900. 			-- objective_data = { }, 
  901. 			-- quest_complete = false, 
  902. 			-- is_challenges = true, 
  903. 			-- is_completed_quests = false, 
  904. 			-- equipped = false, 
  905. 			-- quest_pinned = false, 
  906. 			-- is_new = false, 
  907. 		-- } 
  908. 	-- end 
  909. 	 
  910. 	-- If we have challenges show the option	 
  911. 	-- if has_challenges then	 
  912. 		-- Mission_data[ #Mission_data + 1 ] = { 
  913. 			-- id = "m01", 
  914. 			-- label = "QUEST_LOG_CHALLENGES",				 
  915. 			-- type = TYPE_BUTTON, 
  916. 			-- summary = 0, 
  917. 			-- contact_img = "ui_homie_gat", 
  918. 			-- contact_name = nil, 
  919. 			-- reward_cache = 0, 
  920. 			-- reward_power = 0, 
  921. 			-- objective_data = { }, 
  922. 			-- quest_complete = false, 
  923. 			-- is_challenges = true, 
  924. 			-- is_completed_quests = false, 
  925. 			-- equipped = false, 
  926. 			-- quest_pinned = false, 
  927. 			-- is_new = false, 
  928. 		-- } 
  929. 	-- end 
  930.  
  931. 	-- If we have completed quests show the option on the list 
  932. 	if has_completed_quests then	 
  933. 		 
  934. 		--get objectives for each completed quest 
  935. 		cell_missions_objectives_add(Completed_quests_data) 
  936. 		 
  937. 		Mission_data[ #Mission_data + 1 ] = { 
  938. 			id = "m01", 
  939. 			label = "QUEST_LOG_COMPLETED_QUESTS",		 
  940. 			type = TYPE_BUTTON, 
  941. 			summary = 0, 
  942. 			contact_img = "ui_homie_gat", 
  943. 			contact_name = nil, 
  944. 			reward_cache = 0, 
  945. 			reward_power = 0, 
  946. 			objective_data = { }, 
  947. 			quest_complete = false, 
  948. 			is_challenges = false, 
  949. 			is_completed_quests = true, 
  950. 			equipped = false, 
  951. 			is_new = false, 
  952. 		} 
  953. 		 
  954. 		Completed_quests_index = #Mission_data 
  955. 	end 
  956. end 
  957.  
  958.  
  959. ----------------------------------------------------------------------------------------------- 
  960. -- Function cell_missions_quest_populate 
  961. -- 
  962. -- @param id								-- quest id 
  963. -- @param display_name					-- quest name 
  964. -- @param summary							-- quest summary text 
  965. -- @param contact_img					-- homie head contact image 
  966. -- @param contact name					-- homie contact name 
  967. -- @param cache_reward					-- amount of cache rewarded for quest 
  968. -- @param power_reward					-- amount of power rewarded for quest 
  969. -- @param num_avail_objectives		-- how many available objectives 
  970. -- @param num_complted_objectives	-- how many completed objectives 
  971. -- @param is_new							-- is a new quest 
  972. -- @param is_active						-- is the quest active? 
  973. -- @param remote_objective				-- remote player's active objective 
  974. -- 
  975. ----------------------------------------------------------------------------------------------- 
  976. function cell_missions_quest_populate( id, display_name, summary, contact_img, contact_name, cache_reward, power_reward, num_avail_objectives, num_completed_objectives, is_new, is_active, is_crit_path, complete, remote_objective, is_dlc2)	 
  977. 	local temp_data = { 
  978. 		id = id, 
  979. 		label_crc = display_name, 
  980. 		type = TYPE_BUTTON, 
  981. 		summary = summary, 
  982. 		contact_img = contact_img, 
  983. 		contact_name = contact_name, 
  984. 		reward_cache = cache_reward, 
  985. 		reward_power = power_reward, 
  986. 		equipped = false, 
  987. 		quest_pinned = is_active, 
  988. 		objective_data = { }, 
  989. 		quest_complete = complete, 
  990. 		is_new = is_new, 
  991. 		is_crit_path = is_crit_path, 
  992. 		remote_objective = remote_objective, 
  993. 		is_completed_quests = false, 
  994. 		is_dlc2 = is_dlc2, -- This uses the second icon as opposed to other instances where we set the first icon to the dlc fleur -Rossi 8/7/13 
  995. 		is_quest = true, 
  996. 	} 
  997. 	 
  998. 	if temp_data.quest_complete then 
  999. 	 
  1000. 		--Safety check, if the quest is complete then it shouldn't be new 
  1001. 		temp_data.is_new = false 
  1002. 		 
  1003. 		Completed_quests_data[ #Completed_quests_data + 1 ] = temp_data 
  1004. 	elseif temp_data.is_crit_path then 
  1005. 		Crit_path_quest_data[ #Crit_path_quest_data + 1 ] = temp_data 
  1006. 	else 
  1007. 		Mission_data[ #Mission_data + 1 ] = temp_data		 
  1008. 	end 
  1009. end 
  1010.  
  1011.  
  1012. ------------------------------------------------------------------------------- 
  1013. --Adds objective data to quest data 
  1014. -- 
  1015. function cell_missions_objectives_add(data) 
  1016. 	 
  1017. 	 
  1018. 	for k, v in pairs( data ) do 
  1019. 		 
  1020. 		-- get the objectives in two lists, completed and uncompleted 
  1021. 		vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_objective_populate", 0, "objectives", v.id ) 
  1022. 		vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_reward_populate", 0, "rewards", v.id ) 
  1023. 		 
  1024. 		-- merge them with headers and whatnot 
  1025. 		v.objective_data = { } 
  1026. 		v.objective_data[ 1 ] = { label = "QUEST_LOG_OBJECTIVES", type = TYPE_HEADER, } 
  1027. 		 
  1028. 		for k2, v2 in pairs( Cell_missions_uncompleted_objective_temp ) do 
  1029. 			v.objective_data[ #v.objective_data + 1 ] = v2 
  1030. 		end 
  1031. 		 
  1032. 		-- Adding completed objectives 
  1033. 		if #Cell_missions_completed_objective_temp > 0 then 
  1034. 			--v.objective_data[ #v.objective_data + 1 ] = { label = "", type = TYPE_LINE_BREAK, } 
  1035. 			v.objective_data[ #v.objective_data + 1 ] = { label = "COMPLETED", type = TYPE_HEADER, } 
  1036.  
  1037. 			for k2, v2 in pairs( Cell_missions_completed_objective_temp ) do 
  1038. 				v.objective_data[ #v.objective_data + 1 ] = v2 
  1039. 			end 
  1040. 		end 
  1041. 		 
  1042. 		--If we have a reward then place it in the quest data 
  1043. 		if #Cell_missions_rewards_temp > 0 then 
  1044. 			v.reward_label = Cell_missions_rewards_temp[1].label	 
  1045. 		end	 
  1046. 		 
  1047. 		------------------------------------------------------------------------- 
  1048. 		-- Removing rewards from the objectives list.  Replaced with a static 
  1049. 		-- rewards section at the bottom of the screen. 
  1050. 		------------------------------------------------------------------------- 
  1051. 		--[[if #Cell_missions_rewards_temp > 0 then 
  1052. 			--v.objective_data[ #v.objective_data + 1 ] = { label = "", type = TYPE_LINE_BREAK, } 
  1053. 			v.objective_data[ #v.objective_data + 1 ] = { label = "MENU_REWARDS", type = TYPE_HEADER, } 
  1054. 			 
  1055. 			for k2, v2 in pairs( Cell_missions_rewards_temp ) do 
  1056. 				v.objective_data[ #v.objective_data + 1 ] = v2 
  1057. 			end 
  1058. 		end]]		 
  1059. 		-------------------------------------------------------------------------- 
  1060. 		 
  1061. 		Cell_missions_uncompleted_objective_temp = { } 
  1062. 		Cell_missions_completed_objective_temp = { } 
  1063. 		Cell_missions_rewards_temp = { } 
  1064. 	end 
  1065. end 
  1066.  
  1067.  
  1068. ----------------------------------------------------------------------------------------------- 
  1069. -- Function cell_missions_objective_populate 
  1070. -- 
  1071. -- @param id								-- objective id 
  1072. -- @param display_name					-- objective name 
  1073. -- @param completed						-- is objective complete? 
  1074. -- @param icon name						-- an icon to show gameplay type (same as on pause map) 
  1075. -- @param objective_type				-- corresponds to the following enums: 
  1076. 														--OBJECTIVE_TYPE_MISSION		= 0 
  1077. 														--OBJECTIVE_TYPE_ACTIVITY 		= 1 
  1078. 														--OBJECTIVE_TYPE_RIFT 			= 2 
  1079. 														--OBJECTIVE_TYPE_COLLECTIBLE 	= 3					 
  1080. 														--JAM 2/7/13: Not sure if we need this  
  1081. -- @param is_active						-- is this objective active? 
  1082. -- @param host_only						--only the host can start this objective (always false in SP and host) 
  1083. -- @param remote_objective				--remote player's objective 
  1084. -- 
  1085. ----------------------------------------------------------------------------------------------- 
  1086. function cell_missions_objective_populate( id, display_name, completed, icon_name, objective_type, is_active, host_only, remote_objective )	 
  1087. 	Cell_missions_uncompleted_objective_temp[ #Cell_missions_uncompleted_objective_temp + 1 ] = { 
  1088. 		name = id, 
  1089. 		label_crc = display_name, 
  1090. 		completed = completed, 
  1091. 		obj_complete = completed, 
  1092. 		type = TYPE_BUTTON, 
  1093. 		objective_type = objective_type, 
  1094. 		equipped = false, 
  1095. 		quest_pinned = is_active, 
  1096. 		disabled = completed, 
  1097. 		host_only = host_only, 
  1098. 		remote_objective = remote_objective, 
  1099. 	}	 
  1100. end 
  1101.  
  1102.  
  1103. ----------------------------------------------------------------------------------------------- 
  1104. -- Function cell_missions_reward_populate 
  1105. -- 
  1106. -- Populates a temp table with available rewards from a quest 
  1107. -- 
  1108. -- @param reward_type					-- corresponds to the following enums: 
  1109. 														--REWARD_TYPE_ACHIEVEMENT = 0 
  1110. 														--REWARD_TYPE_UNLOCKABLE = 1 
  1111. 														 
  1112. -- @param display_name					-- reward name 
  1113. -- 
  1114. ----------------------------------------------------------------------------------------------- 
  1115. function cell_missions_reward_populate( reward_type, display_name ) 
  1116. 	Cell_missions_rewards_temp[ #Cell_missions_rewards_temp + 1 ] = { 
  1117. 		reward_type = reward_type, 
  1118. 		label = display_name,  
  1119. 		type = TYPE_BUTTON, 
  1120. 	} 
  1121. end 
  1122.  
  1123.  
  1124. -- Updates quest list with list of challenges 
  1125. function cell_missions_challenges_update(index, draw_list) 
  1126. 	 
  1127. 	for k, category in pairs(Cell_missions_challenges_temp) do 
  1128. 		Cell_missions_challenges_temp[k].category = { } 
  1129. 		 
  1130. 		Cell_missions_challenges_temp[k].category[ #Cell_missions_challenges_temp[k].category + 1 ] = { 
  1131. 			name = 0, 
  1132. 			label = Cell_missions_challenges_temp[k].label_name, 
  1133. 			type = TYPE_HEADER,		 
  1134. 			summary = 0, 
  1135. 			contact_img = "ui_homie_gat", 
  1136. 			contact_name = nil, 
  1137. 			reward_cache = 0, 
  1138. 			reward_power = 0,	 
  1139. 			reward_label = nil, 
  1140. 			icon_name = nil, 
  1141. 			complete_pct = 0, 
  1142. 			units_collected = 0, 
  1143. 			units_total = 1, 
  1144. 		} 
  1145. 	end 
  1146. 	 
  1147. 	-- get the challenges data 
  1148. 	vint_dataresponder_request( "saintsbook_categories", "cell_missions_challenges_populate", 0, 3 ) 
  1149. 	--vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_quest_populate", 0 ) 
  1150. 	 
  1151. 	-- update list with challenges 
  1152. 	--Remove all inputs before drawing the list...	 
  1153. 	 
  1154. 	local function append(a,b) 
  1155. 		for k, v in pairs(b) do 
  1156. 			if v.equipped == true then 
  1157. 				if v.name ~= Curr_tracked_challenge_id then 
  1158. 					v.equipped = false 
  1159. 				end 
  1160. 			end 
  1161. 			if v.name == Curr_tracked_challenge_id then 
  1162. 				v.equipped = true 
  1163. 			end 
  1164. 			a[ #a + 1 ] = v 
  1165. 		end 
  1166. 	end 
  1167. 	 
  1168. 	--table_clear(Full_challenge_list, true) 
  1169. 	 
  1170. 	local has_optional_quests = #Mission_data > 0 
  1171. 	if has_optional_quests then 
  1172. 	 
  1173. 		-- --Add a header for side quests 
  1174. 		-- Full_challenge_list[ #Full_challenge_list + 1 ] = { 
  1175. 			-- label = "QUEST_LOG_SIDE_QUESTS",  
  1176. 			-- type = TYPE_HEADER,  
  1177. 			-- summary = 0, 
  1178. 			-- contact_img = "ui_homie_gat", 
  1179. 			-- contact_name = nil, 
  1180. 			-- reward_cache = 0, 
  1181. 			-- reward_power = 0, 
  1182. 			-- objective_data = { }, 
  1183. 			-- quest_complete = false, 
  1184. 			-- is_challenges = true, 
  1185. 			-- is_completed_quests = false, 
  1186. 			-- equipped = false, 
  1187. 			-- quest_pinned = false, 
  1188. 			-- is_new = false, 
  1189. 		-- }		 
  1190. 		 
  1191. 		Full_challenge_list = table_clone(Mission_data) 
  1192. 	else 
  1193. 		Full_challenge_list = {} 
  1194. 	end 
  1195. 	 
  1196. 	--Full_challenge_list = Cell_missions_challenges_temp[1].category 
  1197. 	for k, category in pairs(Cell_missions_challenges_temp) do 
  1198. 		 
  1199. 			append(Full_challenge_list, category.category) 
  1200. 		 
  1201. 	end 
  1202. 	 
  1203. 	if draw_list == true then	 
  1204. 		if Game_platform == "PC" then 
  1205. 			Mouse_input_tracker:subscribe(false) 
  1206. 			Mouse_input_tracker:remove_all() 
  1207. 		end 
  1208.  
  1209. 		 
  1210. 		--Draw missions list 
  1211. 		Mission_list:draw_items(Full_challenge_list, index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false) 
  1212. 		 
  1213. 		--Update mouse inputs because we've redrawn the list 
  1214. 		if Game_platform == "PC" then 
  1215. 			Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  1216. 			Mouse_input_tracker:subscribe(true) 
  1217. 		end	 
  1218. 	end 
  1219. 	 
  1220. 	--Show summary and challenge grp 
  1221. 	vint_set_property(Summary_grp_h, "visible", true)	 
  1222. 	vint_set_property(Challenges_grp_h, "visible", true)	 
  1223. 	 
  1224. 	--Hide Challenges overview group 
  1225. 	vint_set_property(Challenges_overview_grp_h, "visible", false) 
  1226. 	 
  1227. 	--Hide the A button 
  1228. 	--Mission_list:highlight_set_button("")		 
  1229. 	 
  1230. 	--Get current challenge 
  1231. 	local curr_challenge = Full_challenge_list[index] 
  1232. 	 
  1233. 	Curr_mission_index = index 
  1234. 	 
  1235. 	--Update summary info on right side 
  1236. 	cell_missions_summary_update(curr_challenge)	 
  1237. 	 
  1238. 	--Update challenge widget 
  1239. 	local chal_unit_title_txt_h = vint_object_find("chal_unit_title_txt", 0, Cell_missions_doc_h) 
  1240. 	local chal_unit_txt_h = vint_object_find("chal_unit_txt", 0, Cell_missions_doc_h) 
  1241. 	local chal_icon_img_h = vint_object_find("chal_icon_img", 0, Cell_missions_doc_h) 
  1242. 	 
  1243. 	vint_set_property(chal_unit_title_txt_h, "text_tag_crc", curr_challenge.units_type) 
  1244. 	vint_set_property(chal_unit_txt_h, "text_tag", var_to_string(curr_challenge.units_collected).."/"..var_to_string(curr_challenge.units_total)) 
  1245. 	 
  1246. 	--Set image if there is one 
  1247. 	 
  1248. 	vint_debug_print("challenge icon", curr_challenge.icon_name) 
  1249. 	 
  1250. 	if curr_challenge.icon_name ~= nil then 
  1251. 		vint_set_property(chal_icon_img_h, "image", curr_challenge.icon_name) 
  1252. 		vint_set_property(chal_icon_img_h, "visible", true) 
  1253. 	else 
  1254. 		vint_set_property(chal_icon_img_h, "visible", false) 
  1255. 	end 
  1256. 			 
  1257. 	--Update meter 
  1258. 	local chal_meter_clip_h = vint_object_find("chal_meter_clip", 0, Cell_missions_doc_h) 
  1259. 	if curr_challenge.is_quest == false then 
  1260. 		local METER_FULL_PCT = 340	 
  1261. 		 
  1262. 		local chal_meter_width, chal_meter_height = vint_get_property(chal_meter_clip_h, "clip_size") 
  1263. 		local new_width = METER_FULL_PCT * curr_challenge.complete_pct 
  1264. 		 
  1265. 		if curr_challenge.complete_pct ~= 1 then --if 1 then set it to full 
  1266. 			local increment = METER_FULL_PCT/49 
  1267. 			for i = 0, METER_FULL_PCT, increment do 
  1268. 				if new_width >= i and new_width < (i + increment) then 
  1269. 					new_width = i 
  1270. 				end 
  1271. 			end 
  1272. 		end 
  1273. 		 
  1274. 		vint_set_property(Challenges_grp_h, "visible", true) 
  1275. 		vint_set_property(chal_unit_title_txt_h, "visible", true) 
  1276. 		vint_set_property(chal_unit_txt_h, "visible", true) 
  1277. 		vint_set_property(chal_meter_clip_h, "visible", true) 
  1278. 		vint_set_property(chal_meter_clip_h, "clip_size", new_width, chal_meter_height)	 
  1279. 		Objective_list:set_visible(false) 
  1280.  
  1281. 		if Game_platform == "PC" then 
  1282. 			Mouse_input_tracker:subscribe(false) 
  1283. 			Mouse_input_tracker:remove_all() 
  1284. 			Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  1285. 			Mouse_input_tracker:subscribe(true) 
  1286. 		end	 
  1287.  
  1288. 	else 
  1289. 	 
  1290. 		vint_set_property(Challenges_grp_h, "visible", false) 
  1291. 		vint_set_property(chal_meter_clip_h, "visible", false)	 
  1292. 		vint_set_property(chal_unit_title_txt_h, "visible", false) 
  1293. 		vint_set_property(chal_unit_txt_h, "visible", false) 
  1294. 		Objective_list:set_visible(true) 
  1295. 		 
  1296. 		if curr_challenge.is_completed_quests == false and curr_challenge.objective_data[1] then 
  1297. 			cell_missions_objective_update(curr_challenge.objective_data, 1) 
  1298. 		end 
  1299. 	end 
  1300. 	 
  1301. 	if curr_challenge.is_new then 
  1302.  
  1303. 		Mission_list:remove_new_flag(index) 
  1304.  
  1305. 		if curr_challenge.is_quest then 
  1306. 			vint_scriptevent_post("quest_log_clear_new", "quest", curr_challenge.id) 
  1307. 		else 
  1308. 			vint_scriptevent_post("quest_log_clear_new", "challenge", curr_challenge.name) 
  1309. 		end 
  1310.  
  1311. 		--Remove our mouse inputs first... 
  1312. 		if Mouse_input_tracker ~= 0 then 
  1313. 			Mouse_input_tracker:remove_all() 
  1314. 		end 
  1315.  
  1316. 		curr_challenge.is_new = false				 
  1317. 				 
  1318. 		--Update mouse inputs because we've redrawn the list 
  1319. 		if Game_platform == "PC" then 
  1320. 			Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  1321. 			if curr_challenge.is_quest then 
  1322. 				Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  1323. 			end 
  1324. 			Mouse_input_tracker:subscribe(true) 
  1325. 		end 
  1326. 		 
  1327. 	end		 
  1328.  
  1329. 	--if Mission_data[Curr_mission_index].is_completed_quests == true then 
  1330. 	if Curr_mission_index == Completed_quests_index then 
  1331. 	 
  1332. 		--Switch to completed missions mode 
  1333. 		Objective_list:set_visible(false) 
  1334. 		vint_set_property(Summary_grp_h, "visible", false)		 
  1335. 	end	 
  1336. end 
  1337.  
  1338.  
  1339. ----------------------------------------------------------------------------------------------- 
  1340. -- Function cell_missions_chal_overview_update() 
  1341. -- 
  1342. -- Stores challenge overview data in globals so we only have to call them once. 
  1343. -- 
  1344. -- @param total_challenges				--total number of challenges 
  1345. -- @param completed_challenges		--number of completed challenges 
  1346. -- @param milestone_goal				--number of challenges needed to reach next milestone 
  1347. -- @param progress						--progress towards the milestone 
  1348. -- @param cash								--cash reward for meeting the milestone 
  1349. -- @param respect							--respect reward for meeting the milestone 
  1350. -- @param unlockable						--unlockable reward for meeting the milestone 
  1351. -- 
  1352. ----------------------------------------------------------------------------------------------- 
  1353. function cell_missions_chal_overview_update( total_challenges, completed_challenges, milestone_goal, progress, cash, respect, unlockable ) 
  1354. 	Cell_mission_chal_ov_total = total_challenges 
  1355. 	Cell_mission_chal_ov_completed = completed_challenges 
  1356. 	Cell_mission_chal_ov_milestone_goal = milestone_goal 
  1357. 	Cell_mission_chal_ov_progress = progress 
  1358. 	Cell_mission_chal_ov_cash_reward = cash 
  1359. 	Cell_mission_chal_ov_respect_reward = respect 
  1360. 	Cell_mission_chal_ov_unlockable_reward = unlockable 
  1361. end 
  1362.  
  1363.  
  1364. ----------------------------------------------------------------------------------------------- 
  1365. -- Function cell_missions_challenges_overview_update 
  1366. -- 
  1367. -- Updates the challenges overview section on the right side of the screen 
  1368. -- when the user has "challenges" highlighted in the quest list 
  1369. -- 
  1370. -- Params used: 
  1371. 	-- Total challenges 
  1372. 	-- Completed challenges 
  1373. 	-- Current milestone 
  1374. 	-- Progress towards current milestone 
  1375. 	-- Rewards for current milestone 
  1376. 		-- Cash 
  1377. 		-- Respect 
  1378. 		-- Unlockable 
  1379. -- 
  1380. ----------------------------------------------------------------------------------------------- 
  1381. function cell_missions_challenges_overview_update() 
  1382. 	 
  1383. 	-- Find all challenge overview elements 
  1384. 	local challenges_title_txt_h = vint_object_find("challenges_title_txt", 0, Cell_missions_doc_h) 
  1385. 	local progress_txt_h = vint_object_find("progress_txt", 0, Cell_missions_doc_h) 
  1386. 	local progress_value_txt_h = vint_object_find("progress_value_txt", 0, Cell_missions_doc_h) 
  1387. 	local completed_txt_h = vint_object_find("completed_txt", 0, Cell_missions_doc_h) 
  1388. 	local goal_txt_h = vint_object_find("goal_txt", 0, Cell_missions_doc_h) 
  1389. 	local goal_label_txt_h = vint_object_find("goal_label_txt", 0, Cell_missions_doc_h) 
  1390. 	local goal_meter_fill_img_h = vint_object_find("goal_meter_fill_img", 0, Cell_missions_doc_h) 
  1391. 	local goal_meter_grp_h = vint_object_find("goal_meter_grp", 0, Cell_missions_doc_h) 
  1392. 	 
  1393. 	-- Set localization tags 
  1394. 	vint_set_property(challenges_title_txt_h, "text_tag", "QUEST_LOG_CHALLENGES_OVERVIEW") 
  1395. 	vint_set_property(progress_txt_h, "text_tag", "QUEST_LOG_TOTAL_PROGRESS") 
  1396. 	vint_set_property(completed_txt_h, "text_tag", "ACTIVITY_COMPLETED") 
  1397. 	vint_set_property(goal_txt_h, "text_tag", "QUEST_LOG_CURRENT_GOAL") 
  1398. 		 
  1399. 	-- Set challenges x/y 
  1400. 	local color = "[format][color:#9300C5]" 
  1401. 	local insert_values = {[0] = color, [1] = Cell_mission_chal_ov_completed, [2] = Cell_mission_chal_ov_total} 
  1402. 	local body = vint_insert_values_in_string("QUEST_LOG_CHALLENGES_X_Y", insert_values) 
  1403. 	vint_set_property(progress_value_txt_h, "text_tag", body) 
  1404. 	 
  1405. 	-- Set challlenge milestone info		 
  1406. 	local insert_values = {[0] = Cell_mission_chal_ov_milestone_goal} 
  1407. 	local body 
  1408. 	 
  1409. 	-- For 1 Challenge	 
  1410. 	if Cell_mission_chal_ov_milestone_goal == 1 then		 
  1411. 		body = vint_insert_values_in_string("QUEST_LOG_COMPLETE_CHALLENGE", insert_values) 
  1412. 	else 
  1413. 		-- For more than 1 Challenge 
  1414. 		body = vint_insert_values_in_string("QUEST_LOG_COMPLETE_CHALLENGES", insert_values) 
  1415. 	end 
  1416. 	 
  1417. 	vint_set_property(goal_label_txt_h, "text_tag", body) 
  1418. 	 
  1419. 	-- Reposition completed text 
  1420. 	local progress_width, progress_height = element_get_actual_size(progress_value_txt_h) 
  1421. 	local progress_x, progress_y = vint_get_property(progress_value_txt_h, "anchor") 
  1422. 	local completed_x, completed_y = vint_get_property(completed_txt_h, "anchor") 
  1423. 	 
  1424. 	vint_set_property(completed_txt_h, "anchor", progress_x + progress_width + 5, completed_y)	 
  1425. 	 
  1426. 	--Set reward info 
  1427. 	local reward_data = { 
  1428. 		is_crit_path = false, 
  1429. 		reward_label = Cell_mission_chal_ov_unlockable_reward, 
  1430. 		reward_cache = Cell_mission_chal_ov_cash_reward, 
  1431. 		reward_power = Cell_mission_chal_ov_respect_reward, 
  1432. 	} 
  1433. 	 
  1434. 	cell_missions_reward_update(reward_data, true) 
  1435. 	 
  1436. 	--Update meter 
  1437. 	local GOAL_FULL_PCT = 340	 
  1438. 	local goal_clip_h = vint_object_find("goal_clip", 0, Cell_missions_doc_h) 
  1439. 	local goal_meter_width, goal_meter_height = vint_get_property(goal_clip_h, "clip_size") 
  1440. 	local new_width = GOAL_FULL_PCT * Cell_mission_chal_ov_progress 
  1441. 	 
  1442. 	if Cell_mission_chal_ov_progress ~= 1 then --if 1 then set it to full 
  1443. 		local increment = GOAL_FULL_PCT/49 
  1444. 		for i = 0, GOAL_FULL_PCT, increment do 
  1445. 			if new_width >= i and new_width < (i + increment) then 
  1446. 				new_width = i 
  1447. 			end 
  1448. 		end 
  1449. 	end 
  1450. 	 
  1451. 	vint_set_property(goal_clip_h, "clip_size", new_width, goal_meter_height)	 
  1452. 		 
  1453. end 
  1454.  
  1455.  
  1456. ----------------------------------------------------------------------------------------------- 
  1457. -- Function cell_missions_summary_update 
  1458. -- 
  1459. -- Updates the quest/challenge summary text, header, and icon on the right side of the screen 
  1460. -- 
  1461. -- @param summary_data			-- summary data for highlighted menu item 
  1462. -- 
  1463. ----------------------------------------------------------------------------------------------- 
  1464. function cell_missions_summary_update(summary_data) 
  1465. 	 
  1466. 	--Hide rewards if we're in completed quests mode 
  1467. 	if summary_data.is_completed_quests ~= true and Completed_quests_is_active ~= true then		 
  1468. 		cell_missions_reward_update(summary_data, true) 
  1469. 	else 
  1470. 		cell_missions_reward_update(summary_data, false) 
  1471. 	end 
  1472. 	 
  1473. 	--Find summary elements 
  1474. 	local contact_img_h = vint_object_find("contact_img", 0, Cell_missions_doc_h) 
  1475. 	local contact_name_txt_h = vint_object_find("contact_name_txt", 0, Cell_missions_doc_h) 
  1476. 	local summary_txt_h = vint_object_find("summary_txt", 0, Cell_missions_doc_h)	 
  1477. 	 
  1478. 	--Set text fields 
  1479. 	vint_set_property(contact_img_h, "image", summary_data.contact_img) 
  1480. 	vint_set_property(contact_name_txt_h, "text_tag", summary_data.contact_name)				 
  1481. 	vint_set_property(summary_txt_h, "text_tag_crc", summary_data.summary)	 
  1482. 	 
  1483. 	--Move arrow with megalist highlight 
  1484. 	vint_set_property(Arrow_img_h, "anchor", Arrow_x, Arrow_y + ((Curr_mission_index - 1) * ARROW_OFFSET)) 
  1485. 	 
  1486. 	--Set size of speech bubble 
  1487. 	local bubble_top_img_h = vint_object_find("bubble_top_img", 0, Cell_missions_doc_h) 
  1488. 	local bubble_bot_img_h = vint_object_find("bubble_bot_img", 0, Cell_missions_doc_h) 
  1489. 	local bubble_left_img_h = vint_object_find("bubble_left_img", 0, Cell_missions_doc_h) 
  1490. 	local bubble_right_img_h = vint_object_find("bubble_right_img", 0, Cell_missions_doc_h) 
  1491. 	 
  1492. 	local bubble_side_width, bubble_side_height = element_get_actual_size(bubble_left_img_h) 
  1493. 	local summary_width, summary_height = element_get_actual_size(summary_txt_h)	 
  1494. 	local bubble_left_x, bubble_left_y = vint_get_property(bubble_left_img_h, "anchor")	 
  1495. 	local bubble_bot_x, bubble_bot_y = vint_get_property(bubble_bot_img_h, "anchor") 
  1496. 	 
  1497. 	element_set_actual_size(bubble_left_img_h, bubble_side_width, summary_height) 
  1498. 	element_set_actual_size(bubble_right_img_h, bubble_side_width, summary_height)	 
  1499. 	 
  1500. 	vint_set_property(bubble_bot_img_h, "anchor", bubble_bot_x, bubble_left_y + summary_height - 1) --TODO: inset the graphic to remove the -1 
  1501. end 
  1502.  
  1503.  
  1504. ----------------------------------------------------------------------------------------------- 
  1505. -- Function cell_missions_reward_update 
  1506. -- 
  1507. -- Updates the reward section of a quest 
  1508. -- 
  1509. -- @param reward_data			-- reward data for a quest 
  1510. -- @param show_rewards			-- toggles rewards group visibility 
  1511. -- 
  1512. ----------------------------------------------------------------------------------------------- 
  1513. function cell_missions_reward_update(reward_data, show_rewards) 
  1514.  
  1515. 	--Hide rewards for crith path quest 
  1516. 	if reward_data.is_crit_path == true then 
  1517. 		show_rewards = false 
  1518. 	end	 
  1519.  
  1520. 	--Show/hide the reward grp 
  1521. 	local reward_grp_h = vint_object_find("reward_grp", 0 , Cell_missions_doc_h)	 
  1522. 	vint_set_property(reward_grp_h, "visible", show_rewards) 
  1523. 	 
  1524. 	--No rewards to update, return early 
  1525. 	if show_rewards == false then 
  1526. 		return			 
  1527. 	end 
  1528. 	 
  1529. 	--Find the reward elements 
  1530. 	local reward_label_txt_h = vint_object_find("reward_label_txt", 0, Cell_missions_doc_h) 
  1531. 	local reward_txt_h = vint_object_find("reward_txt", 0, Cell_missions_doc_h) 
  1532. 	local cache_txt_h = vint_object_find("cache_txt", 0 , Cell_missions_doc_h) 
  1533. 	local power_txt_h = vint_object_find("power_txt", 0 , Cell_missions_doc_h) 
  1534. 	 
  1535. 	--Do we have a reward? 
  1536. 	if reward_data.reward_label ~= nil and reward_data.reward_label ~= 0 then 
  1537. 	 
  1538. 		if type(reward_data.reward_label) == "string" then 
  1539. 			vint_set_property(reward_txt_h, "text_tag", reward_data.reward_label) 
  1540. 		else 
  1541. 			vint_set_property(reward_txt_h, "text_tag_crc", reward_data.reward_label) 
  1542. 		end 
  1543. 		 
  1544. 		--Shrink text to make sure it fits 
  1545. 		resize_text_element(reward_txt_h, 445)						 
  1546. 		 
  1547. 		vint_set_property(reward_txt_h, "visible", true)		 
  1548. 	else 
  1549. 		vint_set_property(reward_txt_h, "visible", false) 
  1550. 	end 
  1551. 				 
  1552. 	--Set text fields 
  1553. 	vint_set_property(reward_label_txt_h, "text_tag", "MENU_REWARDS_TOTAL")	 
  1554. 	vint_set_property(cache_txt_h, "text_tag", "{GAME_CASH}"..format_cash(reward_data.reward_cache)) 
  1555. 	vint_set_property(power_txt_h, "text_tag", var_to_string(reward_data.reward_power)) 
  1556. 	 
  1557. 	--Resize and position reward box 
  1558. 	local REWARD_TEXT_PADDING = 5 
  1559. 	local LINE_HEIGHT = 2 
  1560. 	local power_img_h = vint_object_find("power_img", 0, Cell_missions_doc_h) 
  1561. 	local power_img_width, power_img_height = element_get_actual_size(power_img_h) 
  1562. 	local power_txt_x, power_txt_y = vint_get_property(power_txt_h, "anchor") 
  1563. 	local power_txt_width, power_txt_height = element_get_actual_size(power_txt_h) 
  1564. 	 
  1565. 	local box_grp_h = vint_object_find("box_grp", 0, Cell_missions_doc_h) 
  1566. 	local top_img_h = vint_object_find("top_img", 0, Cell_missions_doc_h) 
  1567. 	local cache_box_grp_h = vint_object_find("cache_box_grp", 0, Cell_missions_doc_h) 
  1568. 	local box_x, box_y = vint_get_property(box_grp_h, "anchor") 
  1569. 	local cache_box_x, cache_box_y = vint_get_property(cache_box_grp_h, "anchor") 
  1570. 	local top_img_with, top_img_height = element_get_actual_size(top_img_h)	 
  1571. 		 
  1572. 	--Position cache and power text 
  1573. 	vint_set_property(power_img_h, "anchor", power_txt_x - power_txt_width, power_txt_y) 
  1574. 	vint_set_property(cache_txt_h, "anchor", power_txt_x - power_txt_width - REWARD_TEXT_PADDING - power_img_width - REWARD_TEXT_PADDING, power_txt_y) 
  1575. 	 
  1576. 	local cache_x, cache_y = vint_get_property(cache_txt_h, "anchor") 
  1577. 	local cache_width, cache_height = element_get_actual_size(cache_txt_h)	 
  1578. 	local new_top_img_width = cache_x - cache_width - box_x - REWARD_TEXT_PADDING 
  1579. 	 
  1580. 	--Resize outer box 
  1581. 	element_set_actual_size(top_img_h, new_top_img_width - REWARD_TEXT_PADDING, LINE_HEIGHT)	 
  1582. 	vint_set_property(cache_box_grp_h, "anchor", new_top_img_width, cache_box_y) 
  1583. 	 
  1584. 	local cache_top_img_h = vint_object_find("cache_top_img", 0, Cell_missions_doc_h) 
  1585. 	local cache_bot_img_h = vint_object_find("cache_bot_img", 0, Cell_missions_doc_h) 
  1586. 	local cache_right_img_h = vint_object_find("cache_right_img", 0, Cell_missions_doc_h) 
  1587. 	local bot_img_h = vint_object_find("bot_img", 0, Cell_missions_doc_h) 
  1588. 	local bot_width, bot_height = element_get_actual_size(bot_img_h) 
  1589. 		 
  1590. 	local new_cache_box_width = bot_width - new_top_img_width 
  1591. 	 
  1592. 	--Rock the cache box 
  1593. 	element_set_actual_size(cache_top_img_h, new_cache_box_width,  LINE_HEIGHT) 
  1594. 	element_set_actual_size(cache_bot_img_h, new_cache_box_width,  LINE_HEIGHT) 
  1595. 	vint_set_property(cache_right_img_h, "anchor", new_cache_box_width,  0) 
  1596. end 
  1597.  
  1598.  
  1599.  
  1600. ----------------------------------------------------------------------------------------------- 
  1601. -- Function cell_missions_challenges_populate 
  1602. -- 
  1603. -- Populates challenges data 
  1604. -- 
  1605. -- @param id								-- challenge id 
  1606. -- @param display_name					-- challenge name 
  1607. -- @param summary							-- challenge summary text 
  1608. -- @param contact_img					-- homie head contact image 
  1609. -- @param contact name					-- homie contact name 
  1610. -- @param cache_reward					-- amount of cache rewarded for challenge 
  1611. -- @param power_reward					-- amount of power rewarded for challenge 
  1612. -- @param icon_name						-- challenge icon 
  1613. -- @param units_collected				-- number of units collected 
  1614. -- @param units_total					-- max number of units available to collect 
  1615. -- @param units_type						-- type of units 
  1616. -- @param reward_label					-- string for reward 
  1617. -- 
  1618. ----------------------------------------------------------------------------------------------- 
  1619. function cell_missions_challenges_populate(id, display_name, summary, contact_img, contact_name, cache_reward, power_reward, icon_name, units_collected, units_total, units_type, reward_label, completed, type_index, is_new) 
  1620. 	local type_category = Cell_missions_challenges_temp[type_index].category 
  1621. 	 
  1622. 	local is_equipped = false 
  1623. 	if id == Curr_tracked_challenge_id then 
  1624. 		is_equipped = true 
  1625. 	end 
  1626.  
  1627. 	type_category[ #type_category + 1 ] = { 
  1628. 		name = id, 
  1629. 		label_crc = display_name, 
  1630. 		type = TYPE_BUTTON,		 
  1631. 		summary = summary, 
  1632. 		contact_img = contact_img, 
  1633. 		contact_name = contact_name, 
  1634. 		reward_cache = cache_reward, 
  1635. 		reward_power = power_reward,	 
  1636. 		reward_label = reward_label, 
  1637. 		icon_name = icon_name, 
  1638. 		complete_pct = units_collected / units_total, 
  1639. 		units_collected = units_collected, 
  1640. 		units_total = units_total, 
  1641. 		units_type = units_type, 
  1642. 		equipped = is_equipped, 
  1643. 		is_new = is_new, 
  1644. 		is_quest = false, 
  1645. 	} 
  1646. 	 
  1647. end 
  1648.  
  1649.  
  1650. -- Exit back to hub menu 
  1651. function cell_missions_exit_to_menu() 
  1652. 	if Challenge_tutorial_pending_clear then 
  1653. 		challenge_tutorial_set_active(false) 
  1654. 		 
  1655. 		hud_prompt_clear_all() 
  1656. 	end 
  1657.  
  1658. 	--Play menu back audio 
  1659. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  1660. 	 
  1661. 	--Set HUB state to main menu 
  1662. 	vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MAIN) 
  1663. 	 
  1664. 	pop_screen()	--missions 
  1665. end 
  1666.  
  1667.  
  1668. --Exit back to game 
  1669. function cell_missions_exit_to_game(play_audio) 
  1670. 	if Challenge_tutorial_pending_clear then 
  1671. 		challenge_tutorial_set_active(false) 
  1672. 		 
  1673. 		hud_prompt_clear_all() 
  1674. 	end 
  1675. 	 
  1676. 	--Don't play back out audio if starting a new objective 
  1677. 	if play_audio ~= false then 
  1678. 		 
  1679. 		--Play menu back audio 
  1680. 		ui_audio_post_event("UI_Hub_Menu_Back") 
  1681. 	end 
  1682. 	 
  1683. 	--Store off HUB state so we can return to missions next time 
  1684. 	vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MISSIONS)  
  1685. 	 
  1686. 	pop_screen()	--missions 
  1687. 	pop_screen()	--main menu 
  1688. 	pop_screen()	--cellphone frame 
  1689. end 
  1690.  
  1691.  
  1692. --Unlock input 
  1693. function cell_missions_unlock_controls() 
  1694. 	if Active_input == INPUT_LEFT then 
  1695. 		Input_tracker_left:subscribe(true)	 
  1696. 		Input_tracker_right:subscribe(false) 
  1697. 	else 
  1698. 		Input_tracker_left:subscribe(false)	 
  1699. 		Input_tracker_right:subscribe(true) 
  1700. 	end 
  1701. end 
  1702.  
  1703.  
  1704. --Lock input 
  1705. function cell_missions_lock_controls() 
  1706. 	Input_tracker_left:subscribe(false) 
  1707. 	Input_tracker_right:subscribe(false) 
  1708. end 
  1709.  
  1710.  
  1711. --Swap input trackers, set which input is active 
  1712. function cell_missions_nav_swap(objective)	 
  1713.  
  1714. 	--We're in a mission, disabling controls 
  1715. 	if In_mission == true and Objective_is_valid == true then 
  1716. 		return 
  1717. 	end 
  1718. 	 
  1719. 	if Active_input == INPUT_LEFT then 
  1720. 		 
  1721. 		--Going left to right 
  1722. 	 
  1723. 		--Switch input subscriptions 
  1724. 		Input_tracker_left:subscribe(false) 
  1725. 		Input_tracker_right:subscribe(true)		 
  1726. 										 
  1727. 		--Alpha out quests list and turn on objectives list 
  1728. 		Mission_list:set_alpha(LIST_ALPHA_INACTIVE) 
  1729. 		Objective_list:set_alpha(LIST_ALPHA_ACTIVE) 
  1730. 	 
  1731. 		--Set active highlight to purple and inactive to grey 
  1732. 		Mission_list:set_highlight_color(COLOR_LIST_LOST_FOCUS) 
  1733. 		Objective_list:set_highlight_color(COLOR_SAINTS_PURPLE)		 
  1734. 		vint_set_property(Arrow_img_h, "tint", COLOR_LIST_LOST_FOCUS.R, COLOR_LIST_LOST_FOCUS.G, COLOR_LIST_LOST_FOCUS.B) 
  1735. 		vint_set_property(Arrow_img_h, "alpha", LIST_ALPHA_INACTIVE)		 
  1736.  
  1737. 		--Hide the A button 
  1738. 		Mission_list:highlight_set_button("")		 
  1739. 		 
  1740. 		--Stop marquee for long quest titles 
  1741. 		Mission_list:stop_marquee() 
  1742. 		 
  1743. 		--Adding a move cursor so that marqueeing will restart 
  1744. 		Objective_list:move_cursor(0)		 
  1745. 		 
  1746. 		local objective_idx = Objective_list:get_selection() 
  1747. 		local current_objective = objective.objective_data[objective_idx] 
  1748. 		 
  1749. 		Current_left_quest = objective 
  1750. 		cell_missions_objective_update(objective.objective_data, 1) 
  1751. 				 
  1752. 		--If in completed quests or challenges hide A button for objectives 
  1753. 		if Completed_quests_is_active == true or Challenges_is_active == true then 
  1754. 			Objective_list:highlight_set_button("")					 
  1755. 		else 
  1756. 			Objective_list:highlight_set_button(CTRL_MENU_BUTTON_A)		 
  1757. 		end		 
  1758. 		 
  1759. 		--Switch active input 
  1760. 		Active_input = INPUT_RIGHT 
  1761. 		 
  1762. 		if Current_left_quest.id == challenge_get_challenge_tut_id() then 
  1763. 			cell_foreground_update_tutorial("pick_objective") 
  1764. 		end 
  1765. 		 
  1766. 		ui_audio_post_event("ui_quest_forward")  
  1767. 	else 
  1768. 	 
  1769. 		--Going right to left 
  1770. 	 
  1771. 		--Switch input subscriptions 
  1772. 		Input_tracker_left:subscribe(true) 
  1773. 		Input_tracker_right:subscribe(false)	 
  1774. 		 
  1775. 		--Alpha out objectives list and turn on quest list 
  1776. 		Mission_list:set_alpha(LIST_ALPHA_ACTIVE) 
  1777. 		Objective_list:set_alpha(LIST_ALPHA_INACTIVE) 
  1778. 	 
  1779. 		--Set active highlight to purple and inactive to grey 
  1780. 		Mission_list:set_highlight_color(COLOR_SAINTS_PURPLE) 
  1781. 		Objective_list:set_highlight_color(COLOR_LIST_LOST_FOCUS)		 
  1782. 		vint_set_property(Arrow_img_h, "tint", COLOR_SAINTS_PURPLE.R, COLOR_SAINTS_PURPLE.G, COLOR_SAINTS_PURPLE.B)	 
  1783. 		vint_set_property(Arrow_img_h, "alpha", LIST_ALPHA_ACTIVE)					 
  1784. 		 
  1785. 		--Stop marquee for long objective titles 
  1786. 		Objective_list:stop_marquee() 
  1787. 		 
  1788. 		--Adding a move cursor so that marqueeing will restart 
  1789. 		Mission_list:move_cursor(0)				 
  1790. 		 
  1791. 		--Show A button for quests and hide for objectives 
  1792. 		Mission_list:highlight_set_button(CTRL_MENU_BUTTON_A) 
  1793. 		Objective_list:highlight_set_button("")							 
  1794. 		 
  1795. 		if Completed_quests_is_active == true or Challenges_is_active == true then 
  1796. 			Mission_list:highlight_set_button("")			 
  1797. 		end		 
  1798. 		 
  1799. 		--Switch active input 
  1800. 		Active_input = INPUT_LEFT 
  1801. 		 
  1802. 		just_swapped = true 
  1803. 		 
  1804. 		if not Challenge_tutorial_pending_clear then 
  1805. 			cell_foreground_update_tutorial("set_challenge") 
  1806. 		end 
  1807. 		 
  1808. 		ui_audio_post_event("ui_quest_back")  
  1809. 	end	 
  1810.  
  1811. 	local mission_index = Mission_list:get_selection() 
  1812. 	--Determine which hints to show 
  1813. 	cell_missions_hints_update(mission_index) 
  1814. 	 
  1815. 	--On PC we have to refresh mouse inputs when inputs are swapped 
  1816. 	if game_is_active_input_gamepad() == false then 
  1817. 		--Get current mission index 
  1818. 		Curr_mission_index = Mission_list:get_selection() 
  1819. 				 
  1820. 		Mission_list:move_cursor(0) 
  1821. 		 
  1822. 		--Get current objective index 
  1823. 		Curr_objective_index = Objective_list:get_selection()	 
  1824. 		Objective_list:move_cursor(0)		 
  1825. 		 
  1826. 		--Update lists to refresh mouse inputs 
  1827. 		--cell_missions_nav_list()			 
  1828. 	end 
  1829. 	 
  1830. 	vint_debug_print("Active_input", Active_input) 
  1831. end 
  1832.  
  1833. --Handle events for A button 
  1834. function cell_missions_nav_a()	 
  1835. 	 
  1836. 	--We're in a mission, you can't use the A button 
  1837. 	if In_mission == true and Objective_is_valid == true then 
  1838. 		return 
  1839. 	end 
  1840.  
  1841. 	if Active_input == INPUT_LEFT then 
  1842. 		if Mission_list:list_is_playing() == false then		 
  1843. 			 
  1844. 			--Do nothing for completed quest.  All you can do is scroll the list on the left. 
  1845. 			--Don't need to check anything in Mission_data 
  1846. 			if Completed_quests_is_active == true then 
  1847. 				return 
  1848. 			end 
  1849. 			 
  1850. 			if Challenges_is_active == true and Full_challenge_list[Curr_mission_index].is_quest == false then 
  1851. 				if Curr_tracked_challenge_id ~= Full_challenge_list[Curr_mission_index].name then 
  1852. 					Challenge_tracker_enabled = true 
  1853. 					 
  1854. 					Curr_tracked_challenge = Full_challenge_list[Curr_mission_index] 
  1855. 					Curr_tracked_challenge_id = Curr_tracked_challenge.name 
  1856. 					Curr_tracked_challenge.equipped = true 
  1857. 					 
  1858. 					ui_hud_set_current_challenge(Curr_tracked_challenge.name) -- HVS_RCK - For some reason "name" is the id number of the challenge 
  1859. 					 
  1860. 					local METER_FULL_PCT = 140	 
  1861. 					local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE) 
  1862. 					vint_set_property(challenges_bar_h, "visible", true) 
  1863.  
  1864. 					local chal_meter_title = vint_object_find("chal_unit_title_txt", 0, HUD_DOC_HANDLE) 
  1865. 					vint_set_property(chal_meter_title, "text_tag_crc", Curr_tracked_challenge.label_crc) 
  1866.  
  1867. 					local chal_meter_unit_type = vint_object_find("chal_unit_txt", 0, HUD_DOC_HANDLE) 
  1868.  
  1869. 					local base_units_string = "{0}/{1}" 
  1870. 					local values = {[0] = Curr_tracked_challenge.units_collected, [1] = Curr_tracked_challenge.units_total} 
  1871. 					local units_tag = vint_insert_values_in_string(base_units_string, values) 
  1872.  
  1873. 					vint_set_property(chal_meter_unit_type, "text_tag", units_tag) 
  1874.  
  1875. 					local chal_meter_clip_h = vint_object_find("chal_meter_bar_clip", 0, HUD_DOC_HANDLE) 
  1876. 					local chal_meter_width, chal_meter_height = vint_get_property(chal_meter_clip_h, "clip_size") 
  1877. 					local new_width = METER_FULL_PCT * Curr_tracked_challenge.complete_pct 
  1878. 	 
  1879. 					--Update challenge widget 
  1880. 					local chal_icon_img_h = vint_object_find("chal_icon_sm", 0, HUD_DOC_HANDLE) 
  1881.  
  1882. 					local chal_background_h = vint_object_find("challenge_backer", 0, HUD_DOC_HANDLE) 
  1883. 					local chal_background_width, chal_background_height = vint_get_property(chal_background_h, "screen_size") 
  1884. 					local chal_text_width, chal_text_height = vint_get_property(chal_meter_title, "screen_size") 
  1885.  
  1886. 					local new_backer_width = chal_text_width + 10  
  1887. 					if new_backer_width < 150 then 
  1888. 						new_backer_width = 150 
  1889. 					end 
  1890.  
  1891. 					vint_set_property(chal_background_h, "screen_size", new_backer_width, chal_background_height)	 
  1892. 					 
  1893. 					--Set image if there is one 
  1894. 					 
  1895. 					--vint_debug_print("challenge icon", Curr_tracked_challenge.icon_name) 
  1896. 					 
  1897. 					-- if Curr_tracked_challenge.icon_name ~= nil then 
  1898. 						-- vint_set_property(chal_icon_img_h, "image", Curr_tracked_challenge.icon_name) 
  1899. 						-- vint_set_property(chal_icon_img_h, "visible", true) 
  1900. 					-- else 
  1901. 						vint_set_property(chal_icon_img_h, "visible", false) 
  1902. 					--end 
  1903. 					 
  1904. 					if Curr_tracked_challenge.complete_pct ~= 1 then --if 1 then set it to full 
  1905. 						local increment = METER_FULL_PCT/20 
  1906. 						for i = 0, METER_FULL_PCT, increment do 
  1907. 							if new_width >= i and new_width < (i + increment) then 
  1908. 								new_width = i 
  1909. 							end 
  1910. 						end 
  1911. 					end 
  1912. 					 
  1913. 					vint_set_property(chal_meter_clip_h, "clip_size", new_width, chal_meter_height)	 
  1914. 				else 
  1915. 					Challenge_tracker_enabled = false 
  1916. 					Curr_tracked_challenge.equipped = false 
  1917. 					 
  1918. 					ui_hud_set_current_challenge(-1) 
  1919. 					Curr_tracked_challenge_id = -1 
  1920. 					 
  1921. 					local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE) 
  1922. 					vint_set_property(challenges_bar_h, "visible", false) 
  1923. 				end 
  1924. 					 
  1925. 				-- HVS_RCK - I hate this, but it seems to be the only way to get this crap to turn off the "equipped" on the previous challenge. Thanks, Lua. 
  1926. 				for k, challenge in pairs(Full_challenge_list) do 
  1927. 					if challenge.name == Curr_tracked_challenge_id then 
  1928. 						challenge.equipped = true 
  1929. 					else 
  1930. 						challenge.equipped = false 
  1931. 					end 
  1932. 				end 
  1933. 				 
  1934. 				--local first_category = Cell_missions_challenges_temp[1].category 
  1935. 				 
  1936. 				if Game_platform == "PC" then 
  1937. 					Mouse_input_tracker:subscribe(false) 
  1938. 					Mouse_input_tracker:remove_all() 
  1939. 				end 
  1940.  
  1941. 				 
  1942. 				--Draw missions list 
  1943. 				Mission_list:draw_items(Full_challenge_list, Curr_mission_index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false) 
  1944. 				 
  1945. 				--Update mouse inputs because we've redrawn the list 
  1946. 				if Game_platform == "PC" then 
  1947. 					Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  1948. 					--Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  1949. 					Mouse_input_tracker:subscribe(true) 
  1950. 				end	 
  1951. 				 
  1952. 				cell_missions_hints_update() 
  1953.  
  1954. 				--You can't select anything in the challenges screen 
  1955. 				return 
  1956. 			end 
  1957. 			 
  1958. 			--If Challenges are selected in quest list update list on left to display challenges 
  1959. 			-- if Mission_data[Curr_mission_index].is_challenges == true then 
  1960. 				-- Challenges_is_active = true 
  1961. 				 
  1962. 				-- --Update screen title 
  1963. 				-- Cell_missions_title_h:set_text("QUEST_LOG_CHALLENGES", 320) 
  1964. 				 
  1965. 				-- --Save off challenges index for when we return 
  1966. 				-- Challenges_index = Curr_mission_index 
  1967. 				 
  1968. 				-- --Update challenges and redraw list				 
  1969. 				-- cell_missions_challenges_update(2, true) 
  1970. 				 
  1971. 				-- if Game_platform == "PC" then 
  1972. 					-- Hint_bar_mouse_input_tracker:remove_all() 
  1973. 				-- end 
  1974. 				 
  1975. 				-- Hint_bar:set_hints(Challenges_hints_data) 
  1976. 				 
  1977. 				-- if Game_platform == "PC" then 
  1978. 					-- Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000) 
  1979. 					-- Hint_bar_mouse_input_tracker:subscribe(true) 
  1980. 				-- end 
  1981. 				 
  1982. 				-- return 
  1983. 			-- end 
  1984. 			 
  1985. 			--If Completed quests are selected in quest list update list on left to display completed quests 
  1986. 			if Mission_data[Curr_mission_index].is_completed_quests == true then 
  1987. 				Completed_quests_is_active = true 
  1988. 				 
  1989. 				--Save off completed quests index for when we return 
  1990. 				Completed_quests_index = Curr_mission_index 
  1991. 				 
  1992. 				cell_missions_update(Completed_quests_data, 1, true) 
  1993. 				 
  1994. 				cell_missions_hints_update() 
  1995. 				 
  1996. 				return 
  1997. 			end 
  1998. 			 
  1999. 			local mission_index = Mission_list:get_selection() 
  2000. 			cell_missions_nav_swap(Full_challenge_list[mission_index])			 
  2001. 		end 
  2002. 	else 
  2003. 		if Objective_list:list_is_playing() == false then			 
  2004. 			 
  2005. 			--Are we on an active objective? 
  2006. 			local curr_mission = Mission_data[ Curr_mission_index ] 
  2007. 			local objective_idx = Objective_list:get_selection() 
  2008. 			local curr_objective = Objective_data[objective_idx]			 
  2009. 			 
  2010. 			if curr_objective.reward_type == nil and curr_objective.completed ~= true and Completed_quests_is_active ~= true then 
  2011. 			 
  2012. 				--Are we able to start the objective? 
  2013. 				if cell_missions_objective_locked_by_contact( curr_objective.name ) == true then 
  2014. 					 
  2015. 					--Homie is unavailable message 
  2016. 					dialog_box_message( "MENU_TITLE_NOTICE", "MENU_OBJ_HOMIE_LOCKED_BODY", true, true ) 
  2017.  
  2018. 				elseif cell_missions_objective_mystery_locked( curr_objective.name ) == true then 
  2019. 				 
  2020. 					--We have the quest unlocked, but not all components. Drained & Tutorials. Do the rally event first. 
  2021. 					--Until then, show ???? and "NOT AVAILABLE" for log menu and on selection 
  2022. 					dialog_box_message( "MENU_TITLE_NOTICE", "SRG_OBJECTIVE_NOT_AVAILABLE", true, true ) 
  2023.  
  2024. 					 
  2025. 				elseif cell_missions_client_objective_locked_by_host_progress( curr_objective.name ) == true then 
  2026. 				 
  2027. 					--Host has not progressed far enough to unlock this gameplay message 
  2028. 					dialog_box_message( "MENU_TITLE_NOTICE", "MENU_OBJ_HOST_LOCK_BODY", true, true ) 
  2029.  
  2030. 				elseif cell_missions_host_should_wait_for_client( curr_objective.name ) == true then 
  2031. 				 
  2032. 					--We're still waiting on the client to join the game 
  2033. 					--Too late to add new text, but this existing hud message should be the right thing to reuse 
  2034. 					--from the mission trigger use messages 
  2035. 					dialog_box_message( "MENU_TITLE_NOTICE", "HUD_WAIT_FOR_PARTNER_TO_JOIN", true, true ) 
  2036. 					 
  2037. 				elseif Objective_is_valid == true then 
  2038. 					--This flag is determined by checking for active objectives sent by code 
  2039. 					 
  2040. 					--Are we already pinned?  If so, don't restart the mission. 
  2041. 					if curr_objective.quest_pinned == true then 
  2042. 						cell_missions_exit_to_game(true) 
  2043. 						return 
  2044. 					end 
  2045. 					 
  2046. 					--Pin objective and quest 
  2047. 					Current_left_quest.quest_pinned = true 
  2048. 					Current_left_quest.objective_data[ objective_idx ].quest_pinned = true	 
  2049.  
  2050. 					if Current_left_quest.id == challenge_get_challenge_tut_id() then 
  2051. 						cell_foreground_update_tutorial("exit_hub") 
  2052. 						Challenge_tutorial_pending_clear = true 
  2053. 					end					 
  2054. 					 
  2055. 					--Hide any quest complete animations playing in the hud 
  2056. 					local hud_msg_doc_h = vint_document_find("hud_msg") 
  2057. 					if hud_msg_doc_h ~= nil then 
  2058. 						hud_msg_quest_hide() 
  2059. 					end 
  2060. 				 
  2061. 					--Exit screen 
  2062. 					cell_missions_exit_to_game(false) 
  2063. 				 
  2064. 					--Popping the screen before calling additional script seems weird, but according to SEH the function executes fully before the screen is allowed to pop. 
  2065. 					--Launch gameplay 
  2066. 					vint_scriptevent_post( "set_active_objective", Current_left_quest.objective_data[ objective_idx ].name )	 
  2067. 				else 
  2068. 				 
  2069. 					--Display a dialog box explaining why we can't start an objective at this time 
  2070. 					dialog_box_message("MENU_TITLE_NOTICE", "QUEST_NEW_OBJECTIVE_DENY")				 
  2071. 				end 
  2072. 			end 
  2073. 		end 
  2074. 	end 
  2075. end 
  2076.  
  2077.  
  2078. --Handle events for B button 
  2079. function cell_missions_nav_b() 
  2080. 	if Active_input == INPUT_RIGHT then 
  2081. 		--If in objectives list swap back to quests list	 
  2082. 		if Objective_list:list_is_playing() == false then 
  2083. 			cell_missions_nav_swap() 
  2084. 		end 
  2085. 	else 
  2086. 		--If in Challenges, redraw quest list 
  2087.     --HVS_RCK - Challenges IS the new quests menu. Backing out takes us all the way out of quests. 
  2088. 		-- if Challenges_is_active == true then 
  2089. 			-- Challenges_is_active = false 
  2090. 			 
  2091. 			-- --Set screen title back to "QUESTS" 
  2092. 			-- Cell_missions_title_h:set_text("MENU_MISSIONS") 
  2093. 			 
  2094. 			-- cell_missions_update(Mission_data, Challenges_index, true) 
  2095. 			 
  2096. 			-- if Game_platform == "PC" then 
  2097. 				-- Hint_bar_mouse_input_tracker:remove_all() 
  2098. 				 
  2099. 				-- Hint_bar:set_hints(Mission_list_hints_data)	 
  2100. 				 
  2101. 				-- Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000) 
  2102. 				-- Hint_bar_mouse_input_tracker:subscribe(true)				 
  2103. 			-- else 
  2104. 			 
  2105. 				-- Hint_bar:set_hints(Mission_list_hints_data)		 
  2106. 			-- end 
  2107. 			 
  2108. 			-- return 
  2109. 		-- end		 
  2110. 		 
  2111. 		if Completed_quests_is_active == true then 
  2112. 			Completed_quests_is_active = false 
  2113. 			 
  2114. 			Hint_bar:set_hints(Mission_list_hints_data) 
  2115. 	 
  2116. 			--Update challenges and redraw list				 
  2117. 			cell_missions_challenges_update(2, true)		 
  2118. 			return 
  2119. 		end 
  2120. 		if not Challenge_tutorial_pending_clear then 
  2121. 			cell_foreground_update_tutorial("open_menu") 
  2122. 		end 
  2123. 		 
  2124. 		--Exit game 
  2125. 		cell_missions_lock_controls() 
  2126. 	 
  2127. 		--Transition the menu in 
  2128. 		cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_MISSIONS, cell_missions_exit_to_menu) 
  2129. 	end 
  2130. end 
  2131.  
  2132. -- HVS_TBT 5/19/2014: added missing *_unload function 
  2133. function cell_missions_unload() 
  2134.  
  2135. 	--Play menu back audio 
  2136. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  2137. 	 
  2138. 	--Set HUB state to main menu 
  2139. 	vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MAIN) 
  2140. 	 
  2141. 	cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_MISSIONS, nil) 
  2142. end 
  2143.  
  2144.  
  2145. ------------------------------------------------------------------------------- 
  2146. -- Function cell_missions_nav_x() 
  2147. -- 
  2148. -- If we're in a mission (X) is used to retry/exit the mission. 
  2149. -- 
  2150. -- If not in a mission, but an objective is active the (X) button is used to  
  2151. -- clear/unpin pinned that quest and objective. 
  2152. -- 
  2153. ------------------------------------------------------------------------------- 
  2154. function cell_missions_nav_x() 
  2155. 	 
  2156. 	if Active_input == INPUT_LEFT then 
  2157. 		if Mission_list:list_is_playing() == false and Curr_tracked_challenge_id == Full_challenge_list[Curr_mission_index].name then 
  2158. 			Challenge_tracker_enabled = false 
  2159. 			Curr_tracked_challenge.equipped = false 
  2160. 					 
  2161. 			ui_hud_set_current_challenge(-1) 
  2162. 			Curr_tracked_challenge_id = -1 
  2163. 					 
  2164. 			local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE) 
  2165. 			vint_set_property(challenges_bar_h, "visible", false) 
  2166.  
  2167. 			-- HVS_RCK - I hate this, but it seems to be the only way to get this crap to turn off the "equipped" on the previous challenge. Thanks, Lua. 
  2168. 			for k, challenge in pairs(Full_challenge_list) do 
  2169. 				if challenge.name == Curr_tracked_challenge_id then 
  2170. 					challenge.equipped = true 
  2171. 				else 
  2172. 					challenge.equipped = false 
  2173. 				end 
  2174. 			end 
  2175. 				 
  2176. 			--local first_category = Cell_missions_challenges_temp[1].category 
  2177. 				 
  2178. 			if Game_platform == "PC" then 
  2179. 				Mouse_input_tracker:subscribe(false) 
  2180. 				Mouse_input_tracker:remove_all() 
  2181. 			end 
  2182.  
  2183. 			--Draw missions list 
  2184. 			Mission_list:draw_items(Full_challenge_list, Curr_mission_index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false) 
  2185. 				 
  2186. 			--Update mouse inputs because we've redrawn the list 
  2187. 			if Game_platform == "PC" then 
  2188. 				Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  2189. 				--Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  2190. 				Mouse_input_tracker:subscribe(true) 
  2191. 			end	 
  2192.  
  2193. 			cell_missions_hints_update() 
  2194.  
  2195. 			--You can't select anything in the challenges screen 
  2196. 			return 
  2197. 		end 
  2198. 	elseif Active_input == INPUT_RIGHT then 
  2199. 		 
  2200. 		--We're in a mission, you can't use the A button 
  2201. 		if In_mission == true and Objective_is_valid == true then 
  2202. 			return 
  2203. 		end 
  2204.  
  2205. 		local objective_idx = Objective_list:get_selection() 
  2206. 		local current_quest  = Mission_data[ Curr_mission_index ] 
  2207. 		local current_objective = Mission_data[ Curr_mission_index ].objective_data[ objective_idx ] 
  2208. 		 
  2209. 		if current_objective.quest_pinned == true then 
  2210. 			--Unpin objective and quest			 
  2211. 			current_quest.quest_pinned = false 
  2212. 			current_objective.quest_pinned = false		 
  2213. 			 
  2214. 			--Tell code to clear objective 
  2215. 			vint_scriptevent_post( "set_active_objective", "" ) 
  2216.  
  2217. 			--refresh objective list 
  2218. 			cell_missions_objective_update(current_quest.objective_data, objective_idx)	 
  2219. 			 
  2220. 			if Game_platform == "PC" then 
  2221. 				Mouse_input_tracker:subscribe(false) 
  2222. 				Mouse_input_tracker:remove_all() 
  2223. 			end 
  2224.  
  2225. 			Mission_list:set_highlight_color(COLOR_SAINTS_PURPLE) 
  2226. 			--Draw missions list 
  2227. 			Mission_list:draw_items(Full_challenge_list, Curr_mission_index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false) 
  2228. 				 
  2229. 			--Update mouse inputs because we've redrawn the list 
  2230. 			if Game_platform == "PC" then 
  2231. 				Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  2232. 				Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  2233. 				Mouse_input_tracker:subscribe(true) 
  2234. 			end	 
  2235. 			 
  2236. 			cell_missions_nav_swap()			 
  2237. 		end	 
  2238. 	end 
  2239.  
  2240. end 
  2241.  
  2242.  
  2243. -- Determines which state we're in and which hints to show 
  2244. function cell_missions_hints_update(mission_index) 
  2245. 	if Game_platform == "PC" then 
  2246. 		Hint_bar_mouse_input_tracker:remove_all() 
  2247. 	end 
  2248. 	 
  2249. 	if ( Completed_quests_is_active ) then 
  2250. 		Hint_bar:set_hints(Completed_quests_hints_data) 
  2251. 	elseif Active_input == INPUT_LEFT then 
  2252. 		if Mission_list:list_is_playing() == false then 
  2253. 			if Curr_tracked_challenge_id == Full_challenge_list[Curr_mission_index].name then 
  2254. 				Hint_bar:set_hints(Challenges_hints_data) 
  2255. 			else 
  2256. 				Hint_bar:set_hints(Mission_list_hints_data) 
  2257. 			end 
  2258. 		else 
  2259. 			Hint_bar:set_hints(Mission_list_hints_data) --Challenges_hints_data 
  2260. 		end 
  2261. 	else 
  2262. 		local mission_idx = Curr_mission_index 
  2263. 		if mission_index ~= nil then 
  2264. 			mission_idx = mission_index 
  2265. 		end 
  2266.  
  2267. 		local objective_idx = Objective_list:get_selection() 
  2268. 		local current_quest  = Mission_data[ mission_idx ] 
  2269. 		local current_objective = Mission_data[ mission_idx ].objective_data[ objective_idx ] 
  2270.  
  2271. 		if current_objective.quest_pinned == true then 
  2272. 			Hint_bar:set_hints(Challenges_hints_data) 
  2273. 		else 
  2274. 			Hint_bar:set_hints(Mission_list_hints_data) 
  2275. 		end 
  2276. 	end 
  2277. 	 
  2278. 	if Game_platform == "PC" then 
  2279. 		Hint_bar:set_highlight(0) 
  2280. 		Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000)		 
  2281. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  2282. 	end 
  2283. end 
  2284.  
  2285. ------------------------------------------------------------------------------- 
  2286. -- Handles navigating the lists 
  2287. -- 
  2288. function cell_missions_nav_list(event) 
  2289.  
  2290. 	--If in a mission return early 
  2291. 	if In_mission == true and Objective_is_valid == true then 
  2292. 		return 
  2293. 	end 
  2294. 	 
  2295. 	--What direction did we move? 
  2296. 	local direction = 0 
  2297. 	if event == "nav_up" then 
  2298. 		direction = -1 
  2299. 	elseif event == "nav_down" then 
  2300. 		direction = 1 
  2301. 	end 
  2302. 	 
  2303. 	if Active_input == INPUT_LEFT then 
  2304. 					 
  2305. 		--Clear the new flag for the quest we moved from			 
  2306. 		if Challenges_is_active == false and Completed_quests_is_active == false then 
  2307. 			local prev_quest = Mission_data[Curr_mission_index] 
  2308. 			 
  2309. 			if prev_quest.is_new == true then 
  2310. 			 
  2311. 				--Remove all inputs before drawing the list... 
  2312. 				if Game_platform == "PC" then 
  2313. 					Mouse_input_tracker:remove_all() 
  2314. 				end 
  2315. 				 
  2316. 				--Remove new flag from the list and post it to the game. 
  2317. 				Mission_list:remove_new_flag(Curr_mission_index) 
  2318. 				vint_scriptevent_post("quest_log_clear_new", "quest", prev_quest.id)		 
  2319. 				prev_quest.is_new = false				 
  2320. 				 
  2321. 				--Update mouse inputs because we've redrawn the list 
  2322. 				if Game_platform == "PC" then 
  2323. 					Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  2324. 					--Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker) 
  2325. 					Mouse_input_tracker:subscribe(true) 
  2326. 				end 
  2327. 			end 
  2328. 		end 
  2329. 		 
  2330. 		if direction ~= 0 or Mission_list.data[Curr_mission_index].disabled == true or event == "mouse_move" or just_swapped == true then 
  2331. 			--Move cursor for quests list 
  2332. 			Mission_list:move_cursor(direction) 
  2333. 			 
  2334. 			--Get new index 
  2335. 			Curr_mission_index = Mission_list:get_selection() 
  2336. 		end 
  2337. 		 
  2338. 		just_swapped = false 
  2339. 		 
  2340. 		if Completed_quests_is_active == true then		 
  2341. 		 
  2342. 			--Update list to completed quests			 
  2343. 			cell_missions_update(Completed_quests_data, Curr_mission_index, false)		 
  2344. 		elseif Challenges_is_active == true then		 
  2345. 		 
  2346. 			--Update list to challenges			 
  2347. 			cell_missions_challenges_update(Curr_mission_index, false)						 
  2348. 		else 
  2349. 			--Update mission details 
  2350. 			cell_missions_update(Mission_data, Curr_mission_index, false)				 
  2351. 		end 
  2352. 	else 
  2353. 		local orig_idx = Objective_list:get_selection() 
  2354. 		local orig_objective = Current_left_quest.objective_data[orig_idx] 
  2355. 		 
  2356. 		--HVS_RCK[KING] 8/29/14 - If we're on a disabled objective, we don't have one available. Don't allow us to scroll. 
  2357. 		if not orig_objective.disabled then 
  2358. 			--Move the objective list cursor 
  2359. 			Objective_list:move_cursor(direction) 
  2360. 				 
  2361. 			local objective_idx = Objective_list:get_selection()				 
  2362. 			 
  2363. 			--Determine which data to use - complete quests or mission data 
  2364. 			local current_quest 
  2365. 			if Completed_quests_is_active == true then 
  2366. 				current_quest = Completed_quests_data[Curr_mission_index] 
  2367. 			else		 
  2368. 				current_quest = Mission_data[Curr_mission_index]		 
  2369. 			end 
  2370. 			 
  2371. 			local current_objective = Current_left_quest.objective_data[objective_idx] 
  2372. 							 
  2373. 			--Make sure we're not a reward and the id is valid - if so, clear the "new" flag 
  2374. 			if current_objective.reward_type ~= 1 and current_objective.id ~= nil and current_objective.is_new == true then 
  2375. 				Objective_list:remove_new_flag(objective_idx) 
  2376. 				vint_scriptevent_post("quest_log_clear_new", "objective", current_objective.id) 
  2377. 			end 
  2378. 					 
  2379. 			--Get new index 
  2380. 			Curr_objective_index = Objective_list:get_selection()		 
  2381. 			 
  2382. 			--Update objectives				 
  2383. 			cell_missions_objective_update(Current_left_quest.objective_data, Curr_objective_index)				 
  2384. 		end 
  2385. 	end 
  2386. 	 
  2387. 	cell_missions_hints_update() 
  2388. end 
  2389.  
  2390. function cell_missions_scroll_left(event) 
  2391. 	 
  2392. 	--What direction did we move? 
  2393. 	local direction = 0 
  2394. 	if event == "alt_joy_up" then 
  2395. 		direction = -1 
  2396. 	elseif event == "alt_joy_down" then 
  2397. 		direction = 1 
  2398. 	end 
  2399.  
  2400. 	--scroll lines are inverted for some reason 
  2401. 	local scroll_lines = direction 
  2402.  
  2403. 	if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then	 
  2404. 		if scroll_lines ~= 0 then 
  2405. 			Mission_list:scroll_list(scroll_lines) 
  2406. 			 
  2407. 			if game_get_platform() == "PC" then 
  2408. 				Mission_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50) 
  2409. 			end 
  2410. 			--Get the new selection index 
  2411. 			Curr_mission_index = Mission_list:get_selection() 
  2412. 			--Update both lists with new data 
  2413. 			cell_missions_nav_list()			 
  2414. 		end	 
  2415. 	end 
  2416. 	 
  2417. 	if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false then 
  2418. 		if scroll_lines ~= 0 then 
  2419. 			Objective_list:scroll_list(scroll_lines) 
  2420. 			 
  2421. 			if game_get_platform() == "PC" then 
  2422. 				Objective_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50) 
  2423. 			end 
  2424.  
  2425. 			--Get the new selection index 
  2426. 			--Curr_objective_index = Objective_list:get_selection()	 
  2427. 			 
  2428. 			--Update both lists with new data 
  2429. 			cell_missions_nav_list() 
  2430. 		end	 
  2431. 	end 
  2432. end 
  2433.  
  2434.  
  2435. --Handle input for moving left 
  2436. function cell_missions_nav_left() 
  2437. 	if Active_input == INPUT_RIGHT then		 
  2438. 		cell_missions_nav_swap()		 
  2439. 	end 
  2440. end 
  2441.  
  2442.  
  2443. --Handle input for moving right 
  2444. function cell_missions_nav_right() 
  2445. 	if Active_input == INPUT_LEFT then 
  2446. 		if Challenges_is_active == false and Mission_data[Curr_mission_index].is_challenges ~= true and Mission_data[Curr_mission_index].is_completed_quests ~= true and Completed_quests_is_active == false then 
  2447. 			cell_missions_nav_swap()		 
  2448. 		end 
  2449. 	end 
  2450. end 
  2451.  
  2452.  
  2453. --Used as empty callback 
  2454. function cell_missions_nav_do_nothing() 
  2455. end 
  2456.  
  2457.  
  2458. -------------------------------------------------------------------------------------- 
  2459. -- PC INPUTS 
  2460. -------------------------------------------------------------------------------------- 
  2461.  
  2462. function cell_missions_mouse_move(event, target_handle) 
  2463. 	 
  2464. 	if Mission_list:list_is_playing() == false then 
  2465. 		 
  2466. 		--Select mission 
  2467. 		local new_index = Mission_list:get_button_index(target_handle) 
  2468. 		if new_index ~= 0 then 
  2469. 		 
  2470. 			if Active_input == INPUT_LEFT then 
  2471. 				--Update list highlight 
  2472. 				Mission_list:set_selection(new_index) 
  2473. 			 
  2474. 				--Update both lists with new data 
  2475. 				cell_missions_nav_list("mouse_move") 
  2476. 			end 
  2477. 		end 
  2478. 	end 
  2479. 	 
  2480. 	if Objective_list:list_is_playing() == false then 
  2481. 		 
  2482. 		--Select Objective 
  2483. 		local new_index = Objective_list:get_button_index(target_handle) 
  2484. 		if new_index ~= 0 then 
  2485.  
  2486. 			if Active_input == INPUT_RIGHT then 
  2487. 				--Update list highlight 
  2488. 				Objective_list:set_selection(new_index) 
  2489. 				 
  2490. 				--Update both lists with new data 
  2491. 				cell_missions_nav_list("mouse_move") 
  2492. 			end 
  2493. 		end	 
  2494. 	end 
  2495. 	 
  2496. 	--Reset hints every move 
  2497. 	Hint_bar:set_highlight(0) 
  2498. 	 
  2499. 	--Handle selecting hints 
  2500. 	local hint_index = Hint_bar:get_hint_index(target_handle)	 
  2501. 	if hint_index == 1 then 
  2502. 		Hint_bar:set_highlight(1, COLOR_SAINTS_PURPLE) 
  2503. 	elseif hint_index == 2 then 
  2504. 		Hint_bar:set_highlight(2, COLOR_SAINTS_PURPLE) 
  2505. 	elseif hint_index == 3 then 
  2506. 		Hint_bar:set_highlight(3, COLOR_SAINTS_PURPLE) 
  2507. 	end 
  2508. end 
  2509.  
  2510.  
  2511. function cell_missions_mouse_click(event, target_handle, mouse_x, mouse_y) 
  2512. 	--If active input is on the right and we want to navigate to the left. 
  2513. 	if Active_input == INPUT_RIGHT and Mission_list:list_is_playing() == false then 
  2514. 	 
  2515. 		--Find which button is selected and check if it's valid. 
  2516. 		local new_index = Mission_list:get_button_index(target_handle) 
  2517. 		if new_index ~= 0 then 
  2518. 		 
  2519. 			--Swap nav to the left side... 
  2520. 			cell_missions_nav_swap() 
  2521. 			 
  2522. 			--Update list highlight 
  2523. 			Mission_list:set_selection(new_index) 
  2524. 			 
  2525. 			--Update the list 
  2526. 			Mission_list:move_cursor(0, true)	 
  2527.  
  2528. 			--Update both lists with new data 
  2529. 			cell_missions_nav_list() 
  2530. 			 
  2531. 			--Do not process the click as a button press and return 
  2532. 			return 
  2533. 		end 
  2534. 	end 
  2535. 	 
  2536. 	--If active input is on the left and we want to navigate to the right. 
  2537. 	if Active_input == INPUT_LEFT and Objective_list:list_is_playing() == false and Challenges_is_active == false and Completed_quests_is_active == false and Mission_data[Curr_mission_index].is_challenges == false and Mission_data[Curr_mission_index].is_completed_quests == false then 
  2538. 		 
  2539. 		--Find which button is selected and check if it's valid. 
  2540. 		local new_index = Objective_list:get_button_index(target_handle) 
  2541. 		if new_index ~= 0 then 
  2542. 		 
  2543. 			--Swap nav to the right side... 
  2544. 			cell_missions_nav_swap() 
  2545. 		 
  2546. 			--Update list highlight 
  2547. 			Objective_list:set_selection(new_index) 
  2548. 			 
  2549. 			--Update the list 
  2550. 			Objective_list:move_cursor(0, true)			 
  2551.  
  2552. 			--Do not process the click as a button press and return 
  2553. 			return 
  2554. 		end 
  2555. 	end 
  2556.  
  2557. 	local focus_change = false  
  2558. 	--If left has focus and we clicked a button 
  2559. 	if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then 
  2560.  
  2561. 		--Find which button is selected and check if its valid. 
  2562. 		local new_index = Mission_list:get_button_index(target_handle) 
  2563. 		if new_index ~= 0 then 
  2564. 		 
  2565. 			--Update list highlight 
  2566. 			Mission_list:set_selection(new_index) 
  2567. 			 
  2568. 			--Update the list 
  2569. 			Mission_list:move_cursor(0, true)			 
  2570. 			 
  2571. 			--Process the input 
  2572. 			cell_missions_nav_a()	 
  2573. 		end 
  2574. 		 
  2575. 		new_index = Objective_list:get_button_index(target_handle) 
  2576. 		if new_index ~= 0 then		 
  2577. 			--Process the input 
  2578. 			cell_missions_nav_a() 
  2579. 			 
  2580. 			focus_change = true 
  2581. 		end 
  2582. 	end 
  2583. 	 
  2584. 	--If right has focus and we clicked a button 
  2585. 	if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false and focus_change == false then 
  2586. 		 
  2587. 		--Find which button is selected and check if its valid. 
  2588. 		local new_index = Objective_list:get_button_index(target_handle) 
  2589. 		if new_index ~= 0 then 
  2590. 		 
  2591. 			--Update list highlight 
  2592. 			Objective_list:set_selection(new_index) 
  2593. 			 
  2594. 			--Update the list 
  2595. 			Objective_list:move_cursor(0, true)			 
  2596. 			 
  2597. 			--Process the input 
  2598. 			cell_missions_nav_a() 
  2599. 		end 
  2600. 	end 
  2601. 	 
  2602. 	--Update hints 
  2603. 	local hint_index = Hint_bar:get_hint_index(target_handle)		 
  2604. 	if In_mission then 
  2605. 		if hint_index == 1 then 
  2606. 			cell_missions_nav_b() 
  2607. 		elseif hint_index == 2 then 
  2608. 			cell_missions_nav_x() 
  2609. 		end 
  2610. 		 
  2611. 		return 
  2612. 	end 
  2613. 	 
  2614.  
  2615. 	if hint_index ~= nil then 
  2616. 		if hint_index == 1 then 
  2617. 			cell_missions_nav_b() 
  2618. 		elseif hint_index == 2 then 
  2619. 			cell_missions_nav_a() 
  2620. 		elseif hint_index == 3 then 
  2621. 			cell_missions_nav_x() 
  2622. 		end 
  2623. 	end 
  2624. end 
  2625.  
  2626.  
  2627. function cell_missions_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  2628. 	 
  2629. 	--scroll lines are inverted for some reason 
  2630. 	scroll_lines = scroll_lines * -1 
  2631.  
  2632. 	if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then	 
  2633. 		if scroll_lines ~= 0 then 
  2634. 			Mission_list:scroll_list(scroll_lines) 
  2635. 			 
  2636. 			Mission_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50) 
  2637. 			--Get the new selection index 
  2638. 			Curr_mission_index = Mission_list:get_selection() 
  2639. 			--Update both lists with new data 
  2640. 			cell_missions_nav_list()			 
  2641. 		end	 
  2642. 	end 
  2643. 	 
  2644. 	if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false then 
  2645. 		if scroll_lines ~= 0 then 
  2646. 			Objective_list:scroll_list(scroll_lines) 
  2647. 			 
  2648. 			Objective_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50) 
  2649. 			 
  2650. 			--Get the new selection index 
  2651. 			--Curr_objective_index = Objective_list:get_selection()	 
  2652. 			 
  2653. 			--Update both lists with new data 
  2654. 			cell_missions_nav_list() 
  2655. 		end	 
  2656. 	end 
  2657. end 
  2658.  
  2659.  
  2660. function cell_missions_mouse_drag(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  2661. 	 
  2662. 	--Max items is number of buttons in the list minus the max buttons that can be displayed. 
  2663. 	if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then	 
  2664. 		local scrollbar = Mission_list.scrollbar 
  2665. 		if scrollbar.tab_grp.handle == target_handle then 
  2666. 			 
  2667. 			local max_items = Mission_list.num_buttons - (Mission_list.max_buttons - 1) 
  2668. 			 
  2669. 			--Get new start index from scroll tab 
  2670. 			local new_start_index = scrollbar:drag_scrolltab(mouse_y, max_items) 
  2671. 		 
  2672. 			--Scroll Mission list 
  2673. 			Mission_list:scroll_list(0, new_start_index)			 
  2674. 		end		 
  2675. 	end 
  2676. 	 
  2677. 	if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false then	 
  2678. 		local scrollbar = Objective_list.scrollbar 
  2679. 		if scrollbar.tab_grp.handle == target_handle then 
  2680. 		 
  2681. 			local max_items = Objective_list.num_buttons - (Objective_list.max_buttons - 1) 
  2682. 		 
  2683. 			--Get new start index from scroll tab 
  2684. 			local new_start_index = scrollbar:drag_scrolltab(mouse_y, max_items) 
  2685. 		 
  2686. 			--Scroll Mission list 
  2687. 			Objective_list:scroll_list(0, new_start_index)			 
  2688. 		end		 
  2689. 	end	 
  2690. end 
  2691.  
  2692.  
  2693. function cell_missions_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  2694. 		 
  2695. 	if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then	 
  2696. 		local scrollbar = Mission_list.scrollbar 
  2697. 		if scrollbar.tab_grp.handle == target_handle then 
  2698. 			local start_index, end_index = Mission_list:get_visible_indices() 
  2699. 			 
  2700. 			--Max items is number of buttons in the list minus the max buttons that can be displayed. 
  2701. 			local max_items = Mission_list.num_buttons - (Mission_list.max_buttons - 1) 
  2702. 			 
  2703. 			--Set scrolltab position... 
  2704. 			scrollbar:release_scrolltab(start_index, max_items)	 
  2705.  
  2706. 			Mission_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50) 
  2707. 		end 
  2708. 	end 
  2709. 	 
  2710. 	if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false then	 
  2711. 		local scrollbar = Objective_list.scrollbar 
  2712. 		if scrollbar.tab_grp.handle == target_handle then 
  2713. 			local start_index, end_index = Objective_list:get_visible_indices() 
  2714. 			 
  2715. 			--Max items is number of buttons in the list minus the max buttons that can be displayed. 
  2716. 			local max_items = Objective_list.num_buttons - (Objective_list.max_buttons - 1) 
  2717. 			 
  2718. 			vint_debug_print("start_index", start_index) 
  2719. 			 
  2720. 			--Set scrolltab position... 
  2721. 			scrollbar:release_scrolltab(start_index, max_items)	 
  2722. 					 
  2723. 			vint_debug_print("Objective_list current selection", Objective_list:get_selection()) 
  2724.  
  2725. 			--Objective_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50) 
  2726. 		end 
  2727. 	end	 
  2728. end 
  2729.  
  2730. -- C is telling you to get out now 
  2731. function cell_mission_force_exit() 
  2732. 	cell_missions_nav_b() 
  2733. end 
  2734.  
  2735. -------------------------------------------------------------------------------------- 
  2736. -- END PC INPUTS 
  2737. -------------------------------------------------------------------------------------- 
  2738.