./cell_menu_main.lua

  1. local Data = { 
  2. 	[ID_MAP] = { 
  3. 		label = "MENU_MAP", 
  4. 		icon = "ui_cell_icon_map" 
  5. 	}, 
  6. 	[ID_MISSIONS] = { 
  7. 		label = "MENU_MISSIONS", 
  8. 		icon = "ui_cell_icon_missions" 
  9. 	},	 
  10. 	[ID_POWERS] = { 
  11. 		label = "MENU_POWERS", 
  12. 		icon = "ui_cell_icon_saintsbook", 
  13. 		can_wrap = false 
  14. 	}, 
  15. 	[ID_REWARDS] = { 
  16. 		label = "MENU_UPGRADES", 
  17. 		icon = "ui_cell_icon_rewards" 
  18. 	}, 
  19. 	--[[ 
  20. 	[ID_MUSIC] = { 
  21. 		label = "MENU_MUSIC", 
  22. 		icon = "ui_cell_icon_music" 
  23. 	},	 
  24. 	[ID_CAMERA] = { 
  25. 		label = "MENU_CAMERA", 
  26. 		icon = "ui_cell_icon_camera" 
  27. 	}, 
  28. 	[ID_PHONE] = { 
  29. 		label = "MENU_PHONE", 
  30. 		icon = "ui_cell_icon_phone" 
  31. 	}, 
  32. 	[ID_CASH] = { 
  33. 		label = "MENU_CACHE", 
  34. 		icon = "ui_cell_icon_cash",	 
  35. 	}, 
  36. 	[ID_EXTRAS] = { 
  37. 		label = "MENU_EXTRAS", 
  38. 		icon = "ui_cell_icon_extras", 
  39. 	}, 
  40. 	--]] 
  41. 	[ID_STATS] = { 
  42. 		label = "MENU_STATS", 
  43. 		icon = "ui_cell_icon_stats", 
  44. 	}, 
  45. 	[ID_TOMES] = { 
  46. 		label = "MENU_COLLECTION", 
  47. 		icon = "ui_cell_icon_tomes", 
  48. 	},	 
  49. } 
  50.  
  51. PING_RED = 300 
  52. PING_GREEN = 150 
  53.  
  54. COLOR_PIP_EMPTY	= {R=57/255, G=57/255, B=57/255} 
  55. COLOR_PIP_ACT1	= {R=230/255, G=230/255, B=230/255} 
  56. COLOR_PIP_ACT2	= {R=230/255, G=230/255, B=230/255} 
  57. COLOR_PIP_ACT3	= {R=230/255, G=230/255, B=230/255} 
  58.  
  59. local Menu 
  60. local Hint_bar 
  61. local Input_tracker 
  62. local Mouse_input_tracker 
  63. local Cell_menu_main_doc_h = -1 
  64. local New_item_idx = 0 
  65. local Current_idx = 0 
  66. local Found_homie = false 
  67. local Online_check_thread = -1 
  68. local Ping_thread_h = 0 
  69.  
  70. Cell_rewards_to_map = false 
  71. Cell_mission_to_map = false 
  72.  
  73. -- Used by a data responder to indicate there is at least one eligible homie to be called from the cell phone 
  74. function cell_phone_found_homie() 
  75. 	Found_homie = true 
  76. end 
  77.  
  78. function populate_data_is_enabled() 
  79.  
  80. 	Found_homie = false 
  81.  
  82. 	-- Data request for homies in cell phone - if there are none, disable that screen 
  83. 	vint_dataresponder_request("cell_phone_pad_populate", "cell_phone_found_homie", 0, 0)	 
  84.  
  85. 	if Found_homie == false then 
  86. 		--Data[ID_PHONE].is_enabled = false 
  87. 	end 
  88. 	 
  89. 	-- cannot do missions in machina mode 
  90. 	if cell_machinima_is_recording() then 
  91. 		Data[ID_MISSIONS].is_enabled = false	 
  92. 	end 
  93. 	 
  94. 	-- camera allowed 
  95. 	if cell_allow_camera() == false then 
  96. 		--Data[ID_CAMERA].is_enabled = false 
  97. 	end 
  98. 	 
  99. 	--Check if prologue is complete before we bring the quest log online 
  100. 	if game_is_prologue_complete() ~= true then 
  101. 		Data[ID_MISSIONS].is_enabled = false 
  102. 		Data[ID_MISSIONS].label = "MENU_MISSIONS_HIDDEN" 
  103. 	else 
  104. 		Data[ID_MISSIONS].label = "MENU_MISSIONS" 
  105. 	end 
  106. 	 
  107. 	--if Data[ID_MISSIONS].new_items == 0 then 
  108. 	--	Data[ID_MISSIONS].is_enabled = false 
  109. 	--end 
  110. 	 
  111. 	if mission_is_complete("mFlightTutorial") ~= true then 
  112. 		Data[ID_REWARDS].is_enabled = false 
  113. 		Data[ID_REWARDS].label = "MENU_MISSIONS_HIDDEN" 
  114. 	else 
  115. 		Data[ID_REWARDS].label = "MENU_UPGRADES" 
  116. 	end 
  117.  
  118. 	if (game_get_in_progress_type() == 1 or cell_is_phone_disabled()) then -- 1 = Activities 
  119. 		--Data[ID_PHONE].is_enabled = false 
  120. 	end 
  121. 	 
  122. 	-- -- disable based on mission completion 
  123. 	-- if cell_is_mission_complete("m03") then 
  124. 	-- 	-- nothing locked 
  125. 	-- elseif cell_is_mission_complete("m02") then 
  126. 	-- 	-- lock saints book 
  127. 	-- 	Data[ID_POWERS].is_enabled = false 
  128. 	-- else 
  129. 	-- 	-- lock map, missions, saints book, upgrades, music, and phone 
  130. 	-- 	Data[ID_MAP].is_enabled = false 
  131. 	-- 	Data[ID_MISSIONS].is_enabled = false 
  132. 	-- 	Data[ID_POWERS].is_enabled = false 
  133. 	-- 	Data[ID_REWARDS].is_enabled = false 
  134. 	-- 	Data[ID_MUSIC].is_enabled = false 
  135. 	-- 	Data[ID_PHONE].is_enabled = false 
  136. 	-- 	Data[ID_CASH].is_enabled = false 
  137. 	-- end	 
  138. 	 
  139. 	-- Check if any super powers are available 
  140. 	if game_is_any_super_power_unlocked() == false then 
  141. 		Data[ID_POWERS].is_enabled = false 
  142. 		Data[ID_POWERS].label = "MENU_POWERS_HIDDEN" 
  143. 	else 
  144. 		Data[ID_POWERS].label = "MENU_POWERS" 
  145. 	end 
  146.  
  147. 	if game_is_prologue_complete(true) ~= true then 
  148. 		Data[ID_TOMES].is_enabled = false 
  149. 		Data[ID_TOMES].label = "MENU_MISSIONS_HIDDEN" 
  150. 	else 
  151. 		Data[ID_TOMES].label = "MENU_COLLECTION" 
  152. 	end 
  153. 	 
  154. 	-- if the map is disabled for mission or some other state, don't allow it 
  155. 	if cell_is_map_disabled() then 
  156. 		Data[ID_MAP].is_enabled = false		 
  157. 	end 
  158.  
  159. 	-- if we are in an activity, then disable everything but the map because we might run out of bitmap instances 
  160. 	if game_is_any_activity_active() then 
  161. 	 	Data[ID_MISSIONS].is_enabled = false 
  162. 	 	Data[ID_POWERS].is_enabled = false 
  163. 	 	Data[ID_REWARDS].is_enabled = false 
  164. 		Data[ID_STATS].is_enabled = false 
  165. 		Data[ID_TOMES].is_enabled = false 
  166. 	end 
  167. end 
  168.  
  169.  
  170.  
  171. function cell_menu_main_init() 
  172. 	vint_force_lua_gc() --Force Garbage Collection 
  173. 	-- Find our documents... 
  174. 	Cell_menu_main_doc_h = vint_document_find("cell_menu_main") 
  175. 	--Hide safe frame... 
  176. 	local safe_frame_h = vint_object_find("safe_frame", 0, Cell_menu_main_doc_h) 
  177. 	vint_set_property(safe_frame_h, "visible", false) 
  178. 	 
  179. 	-- Setup input tracker.+ 
  180. 	Input_tracker = Vdo_input_tracker:new() 
  181. 	Input_tracker:add_input("map", "cell_menu_main_button_b", 50) 
  182. 	Input_tracker:add_input("select", "cell_menu_main_button_a", 50) 
  183. 	Input_tracker:add_input("back", "cell_menu_main_button_b", 50) 
  184. 	Input_tracker:add_input("nav_up", "cell_menu_main_nav", 50) 
  185. 	Input_tracker:add_input("nav_down", "cell_menu_main_nav", 50) 
  186. 	Input_tracker:add_input("nav_left", "cell_menu_main_nav", 50) 
  187. 	Input_tracker:add_input("nav_right", "cell_menu_main_nav", 50) 
  188.  
  189. 	-- Setup Button Hints 
  190. 	Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Cell_menu_main_doc_h) 
  191. 	local hint_data = { 
  192. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  193. 	} 
  194. 	Hint_bar:set_hints(hint_data)  
  195. 	 
  196. 	game_UI_audio_play("UI_Cell_Activate") 
  197.  
  198. 	vint_dataresponder_request("cell_menu_main_new_items", "cell_menu_main_set_new", 0) 
  199. 	vint_dataresponder_request("cell_menu_state_dr", "cell_menu_handle_state", 0)	 
  200. 	 
  201. 	-- Populate Data::is_enabled fields 
  202. 	-- Do this after above data responder requests, as new item count may determine button availability 
  203. 	populate_data_is_enabled()	 
  204. 	 
  205. 	Menu = Vdo_cell_menu:new("cell_menu") 
  206. 	 
  207. 	--Populate menu and play highlight animation 
  208. 	Menu:populate_menu(Data) 
  209.  
  210. 	--Hide the ping group until we're in coop on PC 
  211. 	local ping_grp_h = vint_object_find("ping_grp", 0, Cell_menu_main_doc_h) 
  212. 	vint_set_property(ping_grp_h, "visible", false)	 
  213. 	 
  214. 	if game_is_prologue_complete() == true then 
  215. 		local rage_grp_h = vint_object_find("rage_meter", 0, Cell_menu_main_doc_h) 
  216. 		vint_set_property(rage_grp_h, "visible", true) 
  217. 	end 
  218. 	 
  219. 	if game_get_platform() == "PC" then 
  220. 		Hint_bar:set_visible(true)	 
  221. 		Hint_bar:set_highlight(0) 
  222. 		 
  223. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  224. 		Menu:add_mouse_inputs("cell_menu_main", Mouse_input_tracker) 
  225. 		Hint_bar:add_mouse_inputs("cell_menu_main", Mouse_input_tracker) 
  226. 		Mouse_input_tracker:subscribe(false) 
  227. 		 
  228. 		if coop_is_active() == true then			 
  229. 			vint_set_property(ping_grp_h, "visible", true) 
  230. 			 
  231. 			-- poll the ping every 2 seconds until the HUB is closed 
  232. 			Ping_thread_h = thread_new("cell_menu_main_ping_thread") 
  233. 		end 
  234. 	end 
  235. 	 
  236. 	-- set up data items for player status 
  237. 	vint_dataitem_add_subscription("sr2_local_player_respect", "update", "cell_menu_main_respect_update") 
  238. 	vint_dataitem_add_subscription("sr2_local_player_status_infrequent", "update", "cell_menu_main_cash_update")		 
  239. 	cell_menu_main_cluster_update() 
  240. 	 
  241. 	-- Localize top bar text	 
  242. 	local power_txt_h = vint_object_find("power_txt", 0, Cell_menu_main_doc_h) 
  243. 	local cache_txt_h = vint_object_find("cache_txt", 0, Cell_menu_main_doc_h) 
  244. 	local cluster_txt_h = vint_object_find("cluster_txt", 0, Cell_menu_main_doc_h) 
  245. 	 
  246. 	vint_set_property(power_txt_h, "text_tag", "RESPECT_WIDGET_LABEL") 
  247. 	vint_set_property(cluster_txt_h, "text_tag", "HUB_CLUSTERS") 
  248. 	vint_set_property(cache_txt_h, "text_tag", "MENU_CACHE") 
  249. 	 
  250. 	-- Resize text to fit grey boxes 
  251. 	resize_text_element(power_txt_h, 60) 
  252. 	resize_text_element(cluster_txt_h, 83) 
  253. 	resize_text_element(cache_txt_h, 125) 
  254. 	 
  255. 	local top_bar_anim_h = vint_object_find("top_bar_anim", 0, Cell_menu_main_doc_h)	 
  256. 	lua_play_anim(top_bar_anim_h, 0) 
  257. 	 
  258. 	local trans_in_anim_h = vint_object_find("trans_in_anim", 0, Cell_menu_main_doc_h) 
  259. 	lua_play_anim(trans_in_anim_h, 0) 
  260. 	Cell_rewards_to_map = false 
  261. 		 
  262. 	--local cache_meter_in_anim_h = vint_object_find("cache_meter_in_anim", 0, Cell_menu_main_doc_h) 
  263. 	--lua_play_anim(cache_meter_in_anim_h, 0) 
  264.  
  265. 	local cache_meter_grp_h = vint_object_find("cache_meter_grp", 0, Cell_menu_main_doc_h) 
  266. 	vint_set_property(cache_meter_grp_h, "visible", false) 
  267. 	 
  268. 	--show tutorial: powers, challenges, or map 
  269. 	cell_foreground_update_tutorial("hub") 
  270. 	cell_foreground_update_tutorial("access_map") 
  271. 	cell_foreground_update_tutorial("open_menu") 
  272.  
  273. 	--Set Localized Text for Satan meter: 
  274. 	local satan_wrath_text_h = vint_object_find("rage_txt", 0, Cell_menu_main_doc_h) 
  275. 	vint_set_property( satan_wrath_text_h, "text_tag", "CELL_MAIN_SATANS_WRATH" ) 
  276.  
  277. end 
  278.  
  279. function cell_menu_main_cleanup() 
  280. 	if Online_check_thread ~= -1 then 
  281. 		thread_kill(Online_check_thread) 
  282. 	end 
  283. 	 
  284. 	-- Nuke all button subscriptions 
  285. 	Input_tracker:remove_all() 
  286. 	Input_tracker:subscribe(false) 
  287. 	 
  288. 	if Mouse_input_tracker ~= nil then 
  289. 		Mouse_input_tracker:remove_all() 
  290. 		Mouse_input_tracker:subscribe(false) 
  291. 	end 
  292. 	 
  293. 	Menu:cleanup() 
  294. 	 
  295. 	thread_kill(Ping_thread_h) 
  296. 	Ping_thread_h = 0	 
  297. 	 
  298. 	--kill the audio drone 
  299. 	ui_audio_post_event("UI_Hub_Exit") 
  300. 	 
  301. 	Hint_bar:cleanup() 
  302. 	 
  303. 	vint_force_lua_gc() --Force Garbage Collection 
  304. end 
  305.  
  306.  
  307. function cell_menu_main_nav(event) 
  308. 	if event == "nav_up" then 
  309. 		Menu:nav_up() 
  310. 	elseif event == "nav_down" then 
  311. 		Menu:nav_down() 
  312. 	elseif event == "nav_left" then 
  313. 		Menu:nav_left() 
  314. 	elseif event == "nav_right" then 
  315. 		Menu:nav_right() 
  316. 	end 
  317. 	 
  318. 	local cache_meter_grp_h = vint_object_find("cache_meter_grp", 0, Cell_menu_main_doc_h) 
  319. 	vint_set_property(cache_meter_grp_h, "visible", false) 
  320. 	--[[	 
  321. 	if Menu:get_id() == ID_CASH then 
  322. 		vint_set_property(cache_meter_grp_h, "tint", COLOR_CELL_CACHE_METER_ID_CASH.R, COLOR_CELL_CACHE_METER_ID_CASH.G, COLOR_CELL_CACHE_METER_ID_CASH.B) 
  323. 	else 
  324. 		vint_set_property(cache_meter_grp_h, "tint", COLOR_CELL_CACHE_METER_ID_ELSE.R, COLOR_CELL_CACHE_METER_ID_ELSE.G, COLOR_CELL_CACHE_METER_ID_ELSE.B) 
  325. 	end 
  326. 	]]-- 
  327. end 
  328.  
  329.  
  330. function cell_menu_main_out(event, acceleration) 
  331. 	-- 2nd pop for cell_foreground doc 
  332. 	pop_screen() 
  333. 	pop_screen() 
  334. end 
  335.  
  336. function cell_menu_main_button_b(event, acceleration) 
  337. 	cell_menu_main_lost_focus() 
  338. 	cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_MAIN, cell_menu_main_out) 
  339. 	cell_foreground_update_tutorial("off") 
  340. end 
  341.  
  342. function cell_menu_main_button_a(event, acceleration) 
  343. 		 
  344. 	--TODO: Check to see if tween is done before you move to next screen. 
  345. 	 
  346. 	local current_id = Menu:get_id() 
  347. 	 
  348. 	-- Pause_map_from_menu is initialized in cell_foreground	 
  349. 	Pause_map_from_menu = true 
  350. 	Rewards_from_menu = true 
  351. 	Missions_from_menu = true 
  352. 	 
  353. 	cell_menu_handle_state(current_id, true) 
  354. end 
  355.  
  356. function cell_menu_main_mouse_click(event, target_handle) 
  357. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  358. 	if hint_index == 1 then 
  359. 		cell_menu_main_button_b() 
  360. 	end 
  361. 	 
  362. 	-- If the target_handle matches a button, activate it 
  363. 	if Menu:select_button(target_handle) == true then 
  364. 		cell_menu_main_button_a() 
  365. 	end 
  366. end 
  367.  
  368. function cell_menu_main_mouse_move(event, target_handle)	 
  369. 	Hint_bar:set_highlight(0) 
  370. 	 
  371. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  372. 	if hint_index ~= 0 then 
  373. 		Hint_bar:set_highlight(hint_index) 
  374. 		game_UI_audio_play("UI_Cell_Nav") 
  375. 	end 
  376. 	 
  377. 	-- If the target_handle matches a button, highlight it and play a sound 
  378. 	if Menu:select_button(target_handle) == true then 
  379. 		game_UI_audio_play("UI_Cell_Nav") 
  380. 		 
  381. 		--[[ 
  382. 		local cache_meter_grp_h = vint_object_find("cache_meter_grp", 0, Cell_menu_main_doc_h)	 
  383. 		if Menu:get_id() == ID_CASH then 
  384. 			vint_set_property(cache_meter_grp_h, "tint", 0, 0, 0) 
  385. 		else 
  386. 			vint_set_property(cache_meter_grp_h, "tint", .86, .86, .86) 
  387. 		end 
  388. 		--]] 
  389. 	end 
  390. end 
  391.  
  392. function cell_menu_check_online_for_camera() 
  393. 	 
  394. 	Input_tracker:subscribe(false) 
  395. 	if game_get_platform() == "PC" then	 
  396. 		Mouse_input_tracker:subscribe(false) 
  397. 	end 
  398.  
  399. 	online_and_privilege_validator_begin(false, true, true, false, true)	-- Check we're signed in and we have content permissions 
  400. 	while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do 
  401. 		thread_yield() 
  402. 	end 
  403. 	 
  404. 	Input_tracker:subscribe(true) 
  405. 	if game_get_platform() == "PC" then	 
  406. 		Mouse_input_tracker:subscribe(true) 
  407. 	end 
  408. 			 
  409. 	cell_menu_main_unlock_controls() 
  410. 	 
  411. 	if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then 
  412. 		return 
  413. 	end 
  414. 		 
  415. 	if main_menu_check_user_content() == false then 
  416. 		dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED") 
  417. 		return 
  418. 	end 
  419. 	 
  420. 	push_screen("cell_camera") 
  421. 	Online_check_thread = -1 
  422. end 
  423.  
  424. function cell_menu_handle_state(state, from_input) 
  425.  
  426. 	-- Don't push on a new screen if we've asked this one to close 
  427. 	if cell_is_closing() then 
  428. 		return 
  429. 	end 
  430.  
  431. 	-- If we are in a different state than -1, then we need the phone to "load that application" 
  432. 	 
  433. 	--Lose focus... 
  434. 	cell_menu_main_lost_focus() 
  435. 	 
  436. 	-- New quest prompt is shown on the hud, open the quest log 
  437. 	local hud_msg_doc_h = vint_document_find("hud_msg") 
  438. 	if pause_map_crib_exit() == false and hud_msg_doc_h ~= nil and Hud_msg_new_quest_displayed == true then	 
  439. 		--HVS_RCK - If we're doing the challenge tutorial, we don't want to skip this step 
  440. 		if challenge_tutorial_mode_is_active() == false then 
  441. 			state = ID_MISSIONS		 
  442. 		end 
  443. 		Hud_msg_new_quest_displayed = false 
  444. 	end	 
  445. 	 
  446. 	Current_idx = state 
  447. 	 
  448. 	local safe_frame_h = vint_object_find("safe_frame", 0, Cell_menu_main_doc_h) 
  449. 	 
  450. 	--If in tutorial mode - go to the main menu if we did NOT select a screen "from input" 
  451. 	if state == -1  or (Powers_main_tutorial_enable == true and from_input ~= true) then  
  452. 		--DEFAULT VIEW 
  453. 		 
  454. 		vint_set_property(safe_frame_h, "visible", true) 
  455. 		 
  456. 		-- Make the foreground and background show up with the frame 
  457. 		cell_show_frame() 
  458. 				 
  459. 		--Transition to main screen 
  460. 		cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN,  CELL_SCREEN_NONE, cell_menu_main_gained_focus) 
  461. 	else		 
  462. 		if state == ID_MAP then 
  463. 			push_screen("pause_map")		 
  464. 			ui_audio_post_event("UI_Hub_Menu_Forward") 
  465. 		elseif state == ID_MISSIONS then 
  466. 			push_screen("cell_missions")		 
  467. 			ui_audio_post_event("UI_Hub_Menu_Forward") 
  468. 		elseif state == ID_POWERS then 
  469. 			push_screen("powers_main")				 
  470. 			ui_audio_post_event("UI_Hub_Menu_Forward") 
  471. 		elseif state == ID_REWARDS then 
  472. 			push_screen("cell_rewards")				 
  473. 			ui_audio_post_event("UI_Hub_Menu_Forward") 
  474. 		--[[ 
  475. 		--elseif state == ID_MUSIC then 
  476. 		--	push_screen("cell_music_sub") 
  477. 		--	ui_audio_post_event("UI_Hub_Menu_Forward") 
  478. 		--elseif state == ID_CAMERA then 
  479. 		--	ui_audio_post_event("UI_Hub_Menu_Forward") 
  480. 		--	Online_check_thread = thread_new("cell_menu_check_online_for_camera") 
  481. 		--elseif state == ID_PHONE then		 
  482. 		--	push_screen("cell_phone") 
  483. 		--	ui_audio_post_event("UI_Hub_Menu_Forward") 
  484. 		elseif state == ID_EXTRAS then 
  485. 			push_screen("cell_extras") 
  486. 			ui_audio_post_event("UI_Hub_Menu_Forward") 
  487. 		elseif state == ID_CASH then 
  488. 			push_screen("store_crib_cash")		 
  489. 			ui_audio_post_event("UI_Hub_Menu_Forward") 
  490. 		--]] 
  491. 		elseif state == ID_STATS then 
  492. 			push_screen("cell_stats")				 
  493. 			ui_audio_post_event("UI_Hub_Menu_Forward") 
  494. 		elseif state == ID_TOMES then 
  495. 			push_screen("col_main")				 
  496. 			ui_audio_post_event("UI_Hub_Menu_Forward") 
  497. 		else  
  498. 			--This shouldn't get hit, keeping as a fail safe against bogus states 
  499. 			--DEFAULT VIEW 
  500. 						 
  501. 			vint_set_property(safe_frame_h, "visible", true) 
  502. 			 
  503. 			-- Make the foreground and background show up with the frame 
  504. 			cell_show_frame() 
  505. 			 
  506. 			--Play intro anim here 
  507. 			 
  508. 			--Transition to main screen 
  509. 			cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN,  CELL_SCREEN_NONE, cell_menu_main_gained_focus) 
  510. 		end 
  511. 	end 
  512. end 
  513.  
  514. -- progress is float 0-1 that shows progress to next new item (cash only) 
  515. -- interaction is bool, player interaction required (cash only) 
  516. function cell_menu_main_set_new(new_items, progress, interaction) 
  517.  
  518. 	--if New_item_idx < 6 and New_item_idx ~= ID_CASH and New_item_idx ~= ID_MISSIONS then 
  519. 	-- HVS_JPM no more cash option 
  520. 	if New_item_idx < 6 then 
  521. 		Data[New_item_idx].new_items = new_items 
  522. 	--[[ 
  523. 	elseif New_item_idx == ID_CASH then 
  524. 		--dataresponer returns cash amount.  If we have cash then show a 1. 
  525. 		 
  526. 		--if new_items > 0 then 
  527. 		--	Data[New_item_idx].new_items = 1 
  528. 		--else 
  529. 		--	Data[New_item_idx].new_items = 0 
  530. 		--end 
  531. 		 
  532. 		 
  533. 		Data[ New_item_idx ].progress = progress 
  534. 		Data[ New_item_idx ].player_interaction_required = interaction 
  535. 	--]] 
  536. 	end 
  537. 	 
  538. 	New_item_idx = New_item_idx + 1 
  539. 	 
  540. end 
  541.  
  542.  
  543. function cell_menu_main_respect_update(di_h) 
  544. 	--HVS_RCK - This has got really gross because the design changed and all the pips are no longer in order for levels 1-15... 
  545. 	--			Let's just deal with it. 
  546.  
  547. 	local respect_total, respect_progress, respect_level, show_upgrades, force_show_respect, highest_scene = vint_dataitem_get(di_h) 
  548. 	local power_level_txt_h = vint_object_find("power_level_txt", 0, Cell_menu_main_doc_h) 
  549. 	respect_level = respect_level + 1 
  550. 	 
  551. 	if game_is_prologue_complete() == true then 
  552. 		local rage_grp_h = vint_object_find("rage_meter", 0, Cell_menu_main_doc_h) 
  553. 		local rage_grp_1_h = vint_object_find("00-05", rage_grp_h, Cell_menu_main_doc_h) 
  554. 		local rage_grp_1_pips_h = vint_object_find("pips00-05", rage_grp_1_h, Cell_menu_main_doc_h) 
  555. 		 
  556. 		local rage_grp_2_h = vint_object_find("06-11", rage_grp_h, Cell_menu_main_doc_h) 
  557. 		local rage_grp_2_pips_h = vint_object_find("pips06-11", rage_grp_2_h, Cell_menu_main_doc_h) 
  558. 		 
  559. 		local rage_grp_3_h = vint_object_find("12-17", rage_grp_h, Cell_menu_main_doc_h) 
  560. 		local rage_grp_3_pips_h = vint_object_find("pips12-17", rage_grp_3_h, Cell_menu_main_doc_h) 
  561. 		 
  562. 		local pip_h = vint_object_find("pip_00", rage_grp_1_pips_h, Cell_menu_main_doc_h) 
  563. 		--vint_set_property(pip_h,"tint", COLOR_PIP_ACT1.R, COLOR_PIP_ACT1.G, COLOR_PIP_ACT1.B) 
  564. 		 
  565. 		local border_left_h = vint_object_find("border_left", rage_grp_h, Cell_menu_main_doc_h) 
  566. 		vint_set_property(border_left_h,"tint", COLOR_PIP_ACT1.R, COLOR_PIP_ACT1.G, COLOR_PIP_ACT1.B) 
  567. 		 
  568. 		local border_right_h = vint_object_find("border_right", rage_grp_h, Cell_menu_main_doc_h) 
  569. 		if respect_level < 15 then 
  570. 			vint_set_property(border_right_h,"tint", COLOR_PIP_EMPTY.R, COLOR_PIP_EMPTY.G, COLOR_PIP_EMPTY.B) 
  571. 		else 
  572. 			vint_set_property(border_right_h,"tint", COLOR_PIP_ACT3.R, COLOR_PIP_ACT3.G, COLOR_PIP_ACT3.B) 
  573. 		end 
  574.  
  575. 		if respect_level >= 15 then 
  576. 			respect_progress = 1.0 
  577. 		end 
  578.  
  579. 		local respect_progress_in_rads = -1 * (360 * respect_progress) * 3.14 / 180 
  580.  
  581. 		local rage_respect_meter_h = vint_object_find("rage_respect_meter", 0, Cell_menu_main_doc_h) 
  582. 		vint_set_property(rage_respect_meter_h, "end_angle", respect_progress_in_rads) 
  583. 		 
  584. 		local color = COLOR_PIP_EMPTY 
  585. 		 
  586. 		for i = 0, 5 do 
  587. 			if i <= respect_level then 
  588. 				color = COLOR_PIP_ACT1 
  589. 			else 
  590. 				color = COLOR_PIP_EMPTY 
  591. 			end 
  592. 			 
  593. 			local h = vint_object_find("pip_0"..i, rage_grp_1_pips_h, Cell_menu_main_doc_h) 
  594. 			--vint_set_property(h,"alpha",1) 
  595. 			vint_set_property(h,"tint", color.R, color.G, color.B) 
  596. 			vint_set_property(h,"visible",true) 
  597. 		end 
  598. 		 
  599. 		if highest_scene >= 1 then 
  600. 			color = COLOR_PIP_ACT2 
  601. 			 
  602. 			local h = vint_object_find("pip_06", rage_grp_2_pips_h, Cell_menu_main_doc_h) 
  603. 			vint_set_property(h,"tint", color.R, color.G, color.B) 
  604. 			vint_set_property(h,"visible",true) 
  605. 		end 
  606. 		 
  607. 		for i = 7, 11 do 
  608. 			if i <= (respect_level+1) then 
  609. 				color = COLOR_PIP_ACT1 
  610. 			else 
  611. 				color = COLOR_PIP_EMPTY 
  612. 			end 
  613. 			 
  614. 			if i >= 10 then 
  615. 				 
  616. 				local h = vint_object_find("pip_"..i, rage_grp_2_pips_h, Cell_menu_main_doc_h) 
  617. 				vint_set_property(h,"tint", color.R, color.G, color.B) 
  618. 				vint_set_property(h,"visible",true) 
  619. 			else 
  620. 				local h = vint_object_find("pip_0"..i, rage_grp_2_pips_h, Cell_menu_main_doc_h) 
  621. 				vint_set_property(h,"tint", color.R, color.G, color.B) 
  622. 				vint_set_property(h,"visible",true) 
  623. 			end 
  624. 		end 
  625. 		 
  626. 		if highest_scene >= 2 then 
  627. 			color = COLOR_PIP_ACT2 
  628. 			 
  629. 			local h = vint_object_find("pip_12", rage_grp_3_pips_h, Cell_menu_main_doc_h) 
  630. 			vint_set_property(h,"tint", color.R, color.G, color.B) 
  631. 			vint_set_property(h,"visible",true) 
  632. 		end 
  633. 		 
  634. 		for i = 13, 17 do 
  635. 			if i <= (respect_level+2) then 
  636. 				color = COLOR_PIP_ACT3 
  637. 			else 
  638. 				color = COLOR_PIP_EMPTY 
  639. 			end 
  640. 			 
  641. 			local h = vint_object_find("pip_"..i, rage_grp_3_pips_h, Cell_menu_main_doc_h) 
  642. 			vint_set_property(h,"tint", color.R, color.G, color.B)		 
  643. 			vint_set_property(h,"visible",true) 
  644.  
  645. 			if i == 17 then 
  646. 				 
  647. 				local final_pips_visibility = true 
  648. 				if color == COLOR_PIP_EMPTY then 
  649. 					final_pips_visibility = false 
  650. 				end 
  651. 				 
  652. 				--local final_pips_color = vint_get_property(final_pip, "tint") 
  653. 				 
  654. 				local final_a = vint_object_find("final_glow_a", rage_grp_h, Cell_menu_main_doc_h) 
  655. 				--vint_set_property(final_a,"tint", color.R, color.G, color.B)		 
  656. 				vint_set_property(final_a,"visible",final_pips_visibility) 
  657.  
  658. 				local final_b = vint_object_find("final_glow_b", rage_grp_h, Cell_menu_main_doc_h) 
  659. 				--vint_set_property(final_b,"tint", color.R, color.G, color.B)		 
  660. 				vint_set_property(final_b,"visible",final_pips_visibility) 
  661. 			end 
  662. 		end 
  663. 	end 
  664. 	 
  665. 	if mission_is_complete("mFlightTutorial") ~= true then 
  666. 		respect_level = 0 
  667. 	end 
  668.  
  669. 	vint_set_property(power_level_txt_h, "text_tag", var_to_string(respect_level)) 
  670. end 
  671.  
  672.  
  673. function cell_menu_main_cluster_update() 
  674. 	local cluster_num_txt_h = vint_object_find("cluster_num_txt", 0, Cell_menu_main_doc_h) 
  675. 	vint_set_property(cluster_num_txt_h, "text_tag", var_to_string(game_get_orbs_banked())) 
  676. end 
  677.  
  678.  
  679. function cell_menu_main_cash_update(di_h) 
  680. 	local cash = vint_dataitem_get(di_h) 
  681. 	local cash_txt_h = vint_object_find("cache_num_txt", 0, Cell_menu_main_doc_h) 
  682. 	vint_set_property(cash_txt_h, "text_tag", "{GAME_CASH}" .. format_cash(cash))	 
  683. end 
  684.  
  685.  
  686. function cell_menu_main_unlock_controls() 
  687. 	Input_tracker:subscribe(true) 
  688. 	if Mouse_input_tracker ~= nil then 
  689. 		Mouse_input_tracker:subscribe(true) 
  690. 	end 
  691. end 
  692.  
  693. function cell_menu_main_lock_controls() 
  694. 	Input_tracker:subscribe(false) 
  695. 	if Mouse_input_tracker ~= nil then 
  696. 		Mouse_input_tracker:subscribe(false) 
  697. 	end 
  698. end 
  699.  
  700. function cell_menu_main_lost_focus() 
  701.  
  702. 	Input_tracker:subscribe(false) 
  703. 	if Mouse_input_tracker ~= nil then 
  704. 		Mouse_input_tracker:subscribe(false) 
  705. 	end 
  706. end 
  707.  
  708. function cell_menu_main_gained_focus() 
  709. 	 
  710. 	--Refresh hints incase user switched between gamepad and keyboard/mouse 
  711. 	local hint_data = { 
  712. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  713. 	} 
  714. 	Hint_bar:set_hints(hint_data) 
  715. 	 
  716. 	cell_menu_main_unlock_controls()  
  717. 	 
  718. 	vint_set_property(vint_object_find("safe_frame"), "visible", true) 
  719. 	 
  720. 	New_item_idx = 0 
  721. 	vint_dataresponder_request("cell_menu_main_new_items", "cell_menu_main_set_new", 0)	 
  722. 	Menu:populate_menu(Data, Current_idx)	 
  723. 	 
  724. 	--cell_menu_main_cache_meter_update(Data[ID_CASH].progress) 
  725. 	 
  726. 	--glitch 
  727. 	--glitch_cell()	 
  728. end 
  729.  
  730.  
  731. function cell_menu_main_animate_in() 
  732. 	if Menu then 
  733. 		Menu:animate_in()	 
  734. 	end 
  735. end 
  736.  
  737.  
  738. function cell_menu_main_cache_meter_update(meter_pct) 
  739. 	local meter_clip_h = vint_object_find("meter_clip", 0, Cell_menu_main_doc_h) 
  740. 	local meter_fill_img_h = vint_object_find("meter_fill_img", 0, Cell_menu_main_doc_h) 
  741. 	local meter_pulse_anim_h = vint_object_find("cache_meter_pulse_anim", 0, Cell_menu_main_doc_h) 
  742. 	local meter_clip_width, meter_clip_height = vint_get_property(meter_clip_h, "clip_size")	 
  743. 	local METER_MAX = 109 
  744. 	 
  745. 	local new_value = (meter_pct) * METER_MAX 
  746. 	 
  747. 	if meter_pct ~= 1 then --if 1 then set it to full 
  748. 		local incriment = METER_MAX/16 
  749. 		 
  750. 		for i = 0, METER_MAX, incriment do 
  751. 			if new_value >= i and new_value < (i + incriment) then 
  752. 				new_value = i 
  753. 			end 
  754. 		end 
  755. 		 
  756. 		--Tint meter white 
  757. 		vint_set_property(meter_fill_img_h, "tint", COLOR_CELL_CACHE_METER_FILL.R, COLOR_CELL_CACHE_METER_FILL.G, COLOR_CELL_CACHE_METER_FILL.B) 
  758. 		 
  759. 		--Pause pulse anim 
  760. 		vint_set_property(meter_pulse_anim_h, "is_paused", true) 
  761. 	else 
  762. 		 
  763. 		--We're full 
  764. 		vint_set_property(meter_fill_img_h, "tint", COLOR_SAINTS_PURPLE.R, COLOR_SAINTS_PURPLE.G, COLOR_SAINTS_PURPLE.B)		 
  765. 		 
  766. 		lua_play_anim(meter_pulse_anim_h, 0) 
  767. 	end 
  768. 	 
  769. 	vint_set_property(meter_clip_h, "clip_size", new_value, meter_clip_height)	 
  770. end 
  771.  
  772.  
  773. function cell_menu_main_trans_to_pause_map() 
  774. 	--pop off screen 
  775. 	Cell_rewards_to_map = true 
  776. 	pop_screen() 
  777. 	push_screen("pause_map") 
  778. end 
  779.  
  780.  
  781. ------------------------------------------------------------------------------- 
  782. -- Get ping every 2 seconds until cell phone is closed 
  783. -- 
  784. function cell_menu_main_ping_thread() 
  785. 	while true do 
  786. 		cell_menu_main_set_ping(game_get_coop_ping())		 
  787. 		delay(2) 
  788. 	end 
  789. end 
  790.  
  791.  
  792. ------------------------------------------------------------------------------- 
  793. -- Sets connection strength for coop PC 
  794. -- 
  795. function cell_menu_main_set_ping(ping) 
  796. 	local ping_grp_h = vint_object_find("ping_grp", 0 , Cell_menu_main_doc_h) 
  797. 	local ping_txt_h = vint_object_find("ping_txt", 0, Cell_menu_main_doc_h) 
  798. 	local bars = {} 
  799. 	local num_bars = 0 
  800. 	local color = COLOR_PING_GREY 
  801.  
  802. 	vint_set_property(ping_txt_h, "text_tag", ping.." ms ") 
  803. 		 
  804. 	-- turn all bars "off" 
  805. 	for i = 1, 5 do 
  806. 		local h = vint_object_find("bar_img_"..i, ping_grp_h, Cell_menu_main_doc_h) 
  807. 		vint_set_property(h, "alpha", .33)				 
  808. 		bars[i] = h 
  809. 	end 
  810. 	 
  811. 	-- determing how many bars and what color to show 
  812. 	if ping <= PING_GREEN then 
  813. 		if ping < 100 then 
  814. 			num_bars = 5 
  815. 		else 
  816. 			num_bars = 4 
  817. 		end		 
  818. 		 
  819. 		color = COLOR_PING_GREEN		 
  820. 	elseif ping > PING_GREEN and ping < PING_RED then 
  821. 		num_bars = 3		 
  822. 	 
  823. 		color = COLOR_PING_YELLOW		 
  824. 	else 
  825. 		if ping < 400 then 
  826. 			num_bars = 2 
  827. 		else 
  828. 			num_bars = 1 
  829. 		end 
  830. 		 
  831. 		color = COLOR_PING_RED 
  832. 		 
  833. 		if ping > 999 then 
  834. 			vint_set_property(ping_txt_h, "text_tag", "999 ms ") 
  835. 		end 
  836. 	end 
  837. 	 
  838. 	-- turn bars "on" 
  839. 	for i = 1, num_bars do 
  840. 		vint_set_property(bars[i], "alpha", 1)	 
  841. 	end 
  842. 	 
  843. 	--set color and show grp 
  844. 	vint_set_property(ping_grp_h,"tint", color.R, color.G, color.B) 
  845. 	vint_set_property(ping_grp_h,"visible", true) 
  846. end 
  847.