./powers_main.lua

  1. Powers_main_doc_handle = -1 
  2. Powers_screen_state = -1 
  3.  
  4. Powers_cur_type  = -1 
  5. Powers_cur_id = -1 
  6. Powers_cur_power_name  = -1 
  7. Powers_cur_power_bitmap  = -1 
  8. Powers_cur_power_tint  = -1 
  9. Powers_cur_element_bitmap = -1 
  10.  
  11. POWERS_SCREEN_STATE_UPGRADE = 1 
  12. POWERS_SCREEN_STATE_ELEMENT = 2 
  13.  
  14. POWERS_TYPE_RAD = 1 
  15. POWERS_TYPE_ALT = 2 
  16.  
  17. local Safe_frame_h = -1 
  18. local Rad_powers_list = {} 
  19. local Alt_powers_list = {} 
  20. local List_bg_grp_h 
  21. local Rad_bg = {} 
  22. local Alt_bg = {} 
  23.  
  24. local Cur_popup_position 
  25.  
  26.  
  27. local Input_tracker = {} 
  28. local Mouse_input_tracker 
  29. local Hint_bar_mouse_input_tracker 
  30.  
  31. local Hint_bar 
  32.  
  33. local Cur_list 	-- 1-2 (columns) 
  34. local Cur_index  	-- 1-4 (rows) 
  35.  
  36. local Out_anim 
  37. local In_anim 
  38.  
  39.  
  40. local First_cur_list = POWERS_TYPE_ALT 
  41. local Popup_is_active = false 
  42. local Popup_is_rad_power = false 
  43.  
  44. local Rad_powers_data = { 
  45. 	[1] = {id = 0, label = "SUPER_TELEKINESIS_LABEL", power_bitmap = "ui_hud_inv_power_tele", tint = COLOR_POWER_TELE}, 
  46. 	[2] = {id = 1, label = "SUPER_GROUNDPOUND_LABEL", power_bitmap = "ui_hud_inv_power_pound", tint = COLOR_POWER_POUND}, 
  47. 	[3] = {id = 2, label = "SUPER_BUFF_LABEL", power_bitmap = "ui_hud_inv_power_buff", tint = COLOR_POWER_BUFF}, 
  48. 	[4] = {id = 3, label = "SUPER_BLAST_LABEL", power_bitmap = "ui_hud_inv_power_blast", tint = COLOR_POWER_BLAST}, 
  49. } 
  50.  
  51. local Alt_powers_data = { 
  52. 	[1] = {id = 4, label = "SUPER_FORCE_SHIELD_LABEL", power_bitmap = "ui_hud_inv_power_shield", tint = COLOR_POWER_MOVE}, 
  53. 	[2] = {id = 5, label = "SUPER_SPRINT_LABEL", power_bitmap = "ui_hud_inv_power_move", tint = COLOR_POWER_MOVE}, 
  54. 	[3] = {id = 6, label = "SUPER_JUMP_LABEL", power_bitmap = "ui_hud_inv_power_jump", tint = COLOR_POWER_MOVE}, 
  55. 	[4] = {id = 7, label = "SUPER_DFA_LABEL", power_bitmap = "ui_hud_inv_power_dfa", tint = COLOR_POWER_MOVE}, 
  56. } 
  57.  
  58. function powers_main_init() 
  59. 	pause_map_dump() 
  60. 	Powers_main_doc_handle = vint_document_find("powers_main") 
  61. 	Safe_frame_h = vint_object_find("safe_frame", 0, Powers_main_doc_handle) 
  62. 	 
  63. 	--Set up button hints 
  64. 	Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Powers_main_doc_handle) 
  65. 	local hint_data = { 
  66. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"},	 
  67. 	} 
  68. 	Hint_bar:set_hints(hint_data) 	 
  69. 	Hint_bar:set_visible(true) 
  70. 	 
  71. 	--Set up title 
  72. 	local cell_title_h = Vdo_cell_title:new("cell_title", 0, Powers_main_doc_handle) 
  73. 	cell_title_h:set_text("POWERS_HEADER") 
  74. 	cell_title_h:set_icon("ui_cell_icon_saintsbook") 
  75. 	cell_title_h:play_dots_anim() 
  76. 	 
  77. 	-- Setup input tracker 
  78. 	Input_tracker = Vdo_input_tracker:new() 
  79. 	Input_tracker:add_input("map", "powers_main_button_map", 50) 
  80. 	Input_tracker:add_input("select", "powers_main_button_a", 50) 
  81. 	Input_tracker:add_input("back", "powers_main_button_b", 50) 
  82. 	Input_tracker:add_input("nav_up", "powers_main_nav_up", 50) 
  83. 	Input_tracker:add_input("nav_down", "powers_main_nav_down", 50) 
  84. 	Input_tracker:add_input("nav_left", "powers_main_nav_left", 50) 
  85. 	Input_tracker:add_input("nav_right", "powers_main_nav_right", 50)	 
  86. 	 
  87. 	Out_anim = vint_object_find("powers_main_out_anim", 0, Powers_main_doc_handle) 
  88. 	In_anim = vint_object_find("powers_main_in_anim", 0, Powers_main_doc_handle) 
  89. 	 
  90. 	 
  91. 	--send true to signify this is the first time entering the screen 
  92. 	powers_main_populate_screen(true)	 
  93. 	 
  94. 	--power button placeholder bgs 
  95. 	List_bg_grp_h = vint_object_find("list_bg_grp", 0, Powers_main_doc_handle) 
  96.  
  97. 	local bg 
  98. 	--set up rad list 
  99. 	for i = 1, 4 do 
  100. 		bg = "rad_bg_" .. i 
  101. 		Rad_bg[i] = vint_object_find(bg, 0, Powers_main_doc_handle) 
  102. 		bg = "alt_bg_" .. i 
  103. 		Alt_bg[i] = vint_object_find(bg, 0, Powers_main_doc_handle) 
  104. 	end 
  105. 	 
  106. 	 
  107. 	--turn them on or off 
  108. 	for i = 1, 4 do 
  109. 		if Rad_powers_list[i]:get_visible() == false then 
  110. 			vint_set_property(Rad_bg[i], "visible", true)  
  111. 		else 
  112. 			vint_set_property(Rad_bg[i], "visible", false)  
  113. 		end 
  114. 		 
  115. 		if Alt_powers_list[i]:get_visible() == false then 
  116. 			vint_set_property(Alt_bg[i], "visible", true)  
  117. 		else 
  118. 			vint_set_property(Alt_bg[i], "visible", false)  
  119. 		end 
  120. 	end 
  121. 	 
  122. 	 
  123. 	--setup PC inputs after grid is drawn 
  124. 	if game_get_platform() == "PC" then 
  125. 		Hint_bar:set_highlight(0) 
  126. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  127. 		Hint_bar_mouse_input_tracker = Vdo_input_tracker:new() 
  128. 		powers_main_add_mouse_inputs() 
  129. 		Mouse_input_tracker:subscribe(false) 
  130. 		Hint_bar_mouse_input_tracker:subscribe(false) 
  131. 	end 
  132. 	 
  133. 	--show tutorial 
  134. 	cell_foreground_update_tutorial("main") 
  135. 	 
  136. 	--get rid of this line to test 
  137. 	vint_apply_start_values(In_anim) 
  138. 	lua_play_anim(In_anim) 
  139. 	cell_transition_screen(CELL_STATE_LANDSCAPE, CELL_SCREEN_POWERS, CELL_SCREEN_MAIN, powers_main_unlock_controls) 
  140. 	 
  141. 	--glitch 
  142. 	--glitch_cell() 
  143. end 
  144.  
  145. function powers_main_cleanup() 
  146. 	pause_map_restore() 
  147. 	Input_tracker:subscribe(false) 
  148. 	 
  149. 	 
  150. 	if Mouse_input_tracker ~= nil then 
  151. 		Mouse_input_tracker:subscribe(false) 
  152. 	end 
  153. 	if Hint_bar_mouse_input_tracker ~= nil then 
  154. 		Hint_bar_mouse_input_tracker:subscribe(false) 
  155. 	end 
  156.  
  157. end 
  158.  
  159. function powers_main_populate_screen(is_first) 
  160. 	--datarespponder 
  161. 				 
  162. 	local power 
  163. 	--set up main list 
  164. 	for i = 1, 4 do 
  165. 		power = "rad_power_" .. i 
  166. 		Rad_powers_list[i] = Vdo_powers_button:new(power, 0, Powers_main_doc_handle) 
  167. 		Rad_powers_list[i]:set_visible(false) 
  168. 		Rad_powers_list[i]:set_state_off()		 
  169. 		Rad_powers_list[i]:play_pulse_anim() 
  170. 	end 
  171. 	 
  172. 	--set up alt list 
  173. 	for i = 1, 4 do 
  174. 		power = "alt_power_" .. i 
  175. 		Alt_powers_list[i] = Vdo_powers_button:new(power, 0, Powers_main_doc_handle) 
  176. 		Alt_powers_list[i]:set_visible(false) 
  177. 		Alt_powers_list[i]:set_state_off() 
  178. 		Alt_powers_list[i]:play_pulse_anim() 
  179. 	end 
  180. 	 
  181. 	vint_dataresponder_request("powers_upgrades_dr", "powers_main_populate", 0, "get_avail_powers") 
  182. 	--[[ 
  183. 	--testing 
  184. 	powers_main_populate(0, 3, 2) 
  185. 	powers_main_populate(1, 2, 0) 
  186. 	powers_main_populate(2, 2, 12) 
  187. 	powers_main_populate(3, -1, 0) 
  188. 	powers_main_populate(4, -1, 1) 
  189. 	powers_main_populate(5, -1, 3) 
  190. 	powers_main_populate(6, -1, 0) 
  191. 	powers_main_populate(7, -1, 51) 
  192. 	]] 
  193. 	 
  194. 	 
  195. 	--Start the highlight at the top of the populated list 
  196. 	if is_first then 
  197. 		powers_main_set_highlight(First_cur_list, 1) 
  198. 	else 
  199. 		if Cur_list == POWERS_TYPE_RAD then 
  200. 			--When returning to this screen, set popup state if in left list 
  201. 			powers_main_set_highlight(Cur_list, Cur_index, true) 
  202. 		else 
  203. 			local is_popup = false 
  204. 			-- the flight menu has a popup now 
  205. 			if Cur_index == 2 and game_unlockable_is_unlocked( "DLC_Preorder_Saints_Wings" ) then 
  206. 				is_popup = true 
  207. 			end 
  208.  
  209. 			powers_main_set_highlight(Cur_list, Cur_index, is_popup) 
  210. 		end 
  211. 	end 
  212. end 
  213. --Power Enums 
  214.  
  215. --SUPERPOWER_TELEKINESIS, == 0 
  216. --SUPERPOWER_GROUNDPOUND, 
  217. --SUPERPOWER_BUFF, 
  218. --SUPERPOWER_BLAST, 
  219. --SUPERPOWER_FORCE_SHIELD, 
  220. --SUPERPOWER_SPRINT, 
  221. --SUPERPOWER_JUMP, 
  222. --SUPERPOWER_DEATH_FROM_ABOVE, 
  223.  
  224. function powers_main_populate(power, element, num_new_upgrades, num_upgrades, num_new_elements) 
  225. 	power = power + 1 
  226. 	 
  227. 	local data 
  228. 	local list 
  229. 	 
  230. 	--Convert data to Rad and Alt lists 
  231. 	if power < 5 then 
  232. 		data = Rad_powers_data[power] 
  233. 		list = Rad_powers_list 
  234. 		First_cur_list = POWERS_TYPE_RAD 
  235. 	else 
  236. 		power = power - 4 
  237. 		data = Alt_powers_data[power] 
  238. 		list = Alt_powers_list 
  239. 	end 
  240. 	 
  241. 	--Determine the current slot 
  242. 	local list_slot = 1 
  243. 	 
  244. 	--start at the top of list, if first slot is not visible, populate first slot 
  245. 	--if first slot is visible, then its already been populated, and go to the next, and so on... 
  246. 	for i = 1, 4 do 
  247. 		if list[i]:get_visible() then 
  248. 			list_slot = i + 1 
  249. 		end 
  250. 	end 
  251. 	 
  252. 	 
  253. 	data.num_new_upgrades = num_new_upgrades 
  254. 	data.num_upgrades = num_upgrades 
  255. 	data.num_new_elements = num_new_elements 
  256.  
  257. 	 
  258. 	--Set Power name and icon 
  259. 	list[list_slot]:set_power_id(data.id) 
  260. 	list[list_slot]:set_power_name(data.label) 
  261. 	list[list_slot]:set_power_icon(data.power_bitmap) 
  262. 	list[list_slot]:set_power_tint(data.tint) 
  263. 	list[list_slot]:set_power_num_upgrades(data.num_upgrades) 
  264. 	 
  265. 	--Set Element Icon 
  266. 	if element ~= nil and element ~= -1 then 
  267. 		data.element_bitmap = POWERS_ELEMENTS_ENUMS[element].bitmap 
  268. 		list[list_slot]:set_element_icon(true, data.element_bitmap) 
  269. 	else 
  270. 		if list == Rad_powers_list then 
  271. 			-- set empty slot bitmap 
  272. 			list[list_slot]:set_element_icon(true, POWERS_ELEMENTS_ENUMS[element].bitmap) 
  273. 		else 
  274. 			-- show nothing 
  275. 			list[list_slot]:set_element_icon(false, POWERS_ELEMENTS_ENUMS[element].bitmap) 
  276. 		end 
  277. 	end 
  278. 	 
  279. 	--Set New Indicator 
  280. 	 
  281. 	if num_new_upgrades > 0 and num_new_elements > 0 then 
  282. 		list[list_slot]:set_new_indicator(true, "POWERS_NEW_BOTH") 
  283. 	else 
  284. 		if num_new_upgrades > 0 then 
  285. 			list[list_slot]:set_new_indicator(true, "POWERS_NEW_UPGRADES") 
  286. 		elseif num_new_elements > 0 then 
  287. 			list[list_slot]:set_new_indicator(true, "POWERS_NEW_ELEMENTS") 
  288. 		else 
  289. 			list[list_slot]:set_new_indicator(false, "") 
  290. 		end 
  291. 	end 
  292. 	 
  293. 	--Show button 
  294. 	list[list_slot]:set_visible(true) 
  295. 	 
  296. end 
  297.  
  298. function powers_main_set_highlight(list, index, is_popup) 
  299. 	 
  300. 	--Turn off old selection 
  301. 	if Cur_list == POWERS_TYPE_RAD then  
  302. 		Rad_powers_list[Cur_index]:set_state_off() 
  303. 	elseif Cur_list == POWERS_TYPE_ALT then 
  304. 		Alt_powers_list[Cur_index]:set_state_off() 
  305. 	end 
  306. 	 
  307. 	--Turn on new selection 
  308. 	 
  309. 	 
  310. 	if list == POWERS_TYPE_RAD then  
  311. 		--if coming back to this screen on a power with a popup 
  312. 		if is_popup then 
  313. 			Rad_powers_list[index]:set_state_popup(Cur_popup_position) 
  314. 		else 
  315. 			Rad_powers_list[index]:set_state_on() 
  316. 		end 
  317. 		--Store off values for subpage header 
  318. 		Powers_cur_id = Rad_powers_list[index].power_id 
  319. 		Powers_cur_power_name = Rad_powers_list[index]:get_power_name() 
  320. 		Powers_cur_power_bitmap = Rad_powers_list[index]:get_power_icon() 
  321. 		Powers_cur_element_bitmap = Rad_powers_list[index]:get_element_icon() 
  322. 		Powers_cur_power_tint = Rad_powers_list[index]:get_power_tint() 
  323. 		Powers_cur_type = POWERS_TYPE_RAD 
  324. 		 
  325. 	elseif list == POWERS_TYPE_ALT then 
  326.  
  327. 		--if coming back to this screen on a power with a popup 
  328. 		if is_popup then 
  329. 			Alt_powers_list[index]:set_state_popup(Cur_popup_position, true) 
  330. 		else 
  331. 			Alt_powers_list[index]:set_state_on() 
  332. 		end 
  333. 		--Alt_powers_list[index]:set_state_on() 
  334. 		--Store off values for subpage header 
  335. 		Powers_cur_id = Alt_powers_list[index].power_id 
  336. 		Powers_cur_power_name = Alt_powers_list[index]:get_power_name() 
  337. 		Powers_cur_power_bitmap = Alt_powers_list[index]:get_power_icon() 
  338. 		Powers_cur_element_bitmap = Alt_powers_list[index]:get_element_icon() 
  339. 		Powers_cur_power_tint = Alt_powers_list[index]:get_power_tint() 
  340. 		Powers_cur_type = POWERS_TYPE_ALT 
  341. 	end 
  342. 	 
  343. 	 
  344. 	Cur_list = list 
  345. 	Cur_index = index 
  346. 	 
  347. 	 
  348. end 
  349.  
  350. function powers_main_unload() 
  351. 	cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_POWERS, nil) 
  352. end 
  353.  
  354. function powers_main_exit(event) 
  355. 	--Transition to cell main 
  356. 	lua_play_anim(Out_anim) 
  357. 	cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_POWERS, powers_main_exit_to_cell) 
  358. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  359. 	cell_foreground_update_tutorial("hub") 
  360. end 
  361.  
  362. function powers_main_exit_to_cell() 
  363. 	pop_screen() 
  364. end 
  365.  
  366. function powers_main_exit_to_game(event) 
  367. 	pop_screen() 
  368. 	pop_screen() 
  369. 	pop_screen() 
  370. end 
  371.  
  372. function powers_main_return_from_sub() 
  373. 	--returning anim here 
  374. 	--unlock controls at end of this anim 
  375. 	powers_main_populate_screen() 
  376. 	lua_play_anim(In_anim) 
  377. 	cell_transition_screen(CELL_STATE_LANDSCAPE, CELL_SCREEN_POWERS, CELL_SCREEN_NONE, powers_main_unlock_controls) 
  378. 	--glitch 
  379. 	--cell_foreground_update_tutorial("main") 
  380. 	glitch_cell() 
  381. end 
  382.  
  383. --------------- 
  384. --Input tracker 
  385. --------------- 
  386.  
  387. function powers_main_unlock_controls() 
  388. 	Input_tracker:subscribe(true) 
  389. 	if Mouse_input_tracker ~= nil and Hint_bar_mouse_input_tracker ~= nil then 
  390. 		if Popup_is_active and Cur_list == 1 then 
  391. 			powers_main_add_mouse_inputs_popup(Cur_index, false) 
  392. 		elseif Popup_is_active and Cur_list == 2 then 
  393. 			powers_main_add_mouse_inputs_popup(Cur_index, true) 
  394. 		else 
  395. 			powers_main_add_mouse_inputs() 
  396. 		end 
  397. 		Mouse_input_tracker:subscribe(true) 
  398. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  399. 	end 
  400. 	 
  401. end 
  402.  
  403. function powers_main_lock_controls() 
  404. 	Input_tracker:subscribe(false) 
  405. 	if Mouse_input_tracker ~= nil then 
  406. 		Mouse_input_tracker:subscribe(false) 
  407. 	end 
  408. 	if Hint_bar_mouse_input_tracker ~= nil then 
  409. 		Hint_bar_mouse_input_tracker:subscribe(false) 
  410. 	end 
  411. end 
  412.  
  413. function powers_main_button_b(event, acceleration) 
  414. 	 
  415. 	if Popup_is_active then 
  416. 		for i = 1, 4 do 
  417. 			Rad_powers_list[i]:set_color(1, 1, 1) 
  418. 			Alt_powers_list[i]:set_color(1, 1, 1) 
  419. 		end 
  420. 		vint_set_property(List_bg_grp_h, "tint", 1, 1, 1) 
  421. 		if Popup_is_rad_power then 
  422. 			Rad_powers_list[Cur_index]:set_state_on() 
  423. 		else 
  424. 			Alt_powers_list[Cur_index]:set_state_on() 
  425. 		end 
  426. 		if Mouse_input_tracker ~= nil and Hint_bar_mouse_input_tracker ~= nil then 
  427. 			powers_main_add_mouse_inputs() 
  428. 		end 
  429. 		Popup_is_active = false 
  430. 		game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  431. 	else 
  432. 		powers_main_exit() 
  433. 		powers_main_lock_controls() 
  434. 	end 
  435.  
  436. end 
  437.  
  438. function powers_main_button_map(event, acceleration) 
  439. 	cell_foreground_update_tutorial("off") 
  440. 	lua_play_anim(Out_anim) 
  441. 	cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_POWERS, powers_main_exit_to_game) 
  442. end 
  443.  
  444. function powers_main_button_a(event, acceleration) 
  445. 	if Cur_list == POWERS_TYPE_RAD then 
  446. 		if Popup_is_active == false then 
  447. 			for i = 1, 4 do 
  448. 				Rad_powers_list[i]:set_color(.3, .3, .3) 
  449. 				Alt_powers_list[i]:set_color(.3, .3, .3) 
  450. 			end 
  451. 			vint_set_property(List_bg_grp_h, "tint", .3, .3, .3) 
  452. 			Rad_powers_list[Cur_index]:set_color(1, 1, 1) 
  453. 			Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE)	 
  454. 			if game_get_platform() == "PC" then 
  455. 				powers_main_add_mouse_inputs_popup(Cur_index, false) 
  456. 			end 
  457. 			game_UI_audio_play("UI_HUD_Help") 
  458. 			Popup_is_active = true 
  459. 			Popup_is_rad_power = true 
  460. 		else 
  461. 			if Rad_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then 
  462. 				if Rad_powers_list[Cur_index].num_upgrades == 0 then 
  463. 					dialog_box_message("MENU_TITLE_NOTICE", "STORE_NO_ITEMS_IN_CATEGORY", true, true) 
  464. 					return 
  465. 				else 
  466. 					--push upgrades screen 
  467. 					Powers_screen_state = POWERS_SCREEN_STATE_UPGRADE 
  468. 				end 
  469. 			else 
  470. 				--push elements screen 
  471. 				Powers_screen_state = POWERS_SCREEN_STATE_ELEMENT 
  472. 			end 
  473. 			-- Store position for when we return 
  474. 			Cur_popup_position = Rad_powers_list[Cur_index].popup_position 
  475. 			ui_audio_post_event("UI_Hub_Menu_Forward") 
  476. 			push_screen("powers_sub") 
  477. 			 
  478. 			powers_main_lock_controls() 
  479. 			lua_play_anim(Out_anim) 
  480. 			--vint_set_property(Safe_frame_h, "visible", false) 
  481. 		end 
  482. 	else 
  483. 		--The flight menu now has a wing style screen 
  484. 		if Cur_index == 2 and game_unlockable_is_unlocked( "DLC_Preorder_Saints_Wings" ) then 
  485. 			if Popup_is_active == false then 
  486. 				for i = 1, 4 do 
  487. 					Rad_powers_list[i]:set_color(.3, .3, .3) 
  488. 					Alt_powers_list[i]:set_color(.3, .3, .3) 
  489. 				end 
  490. 				vint_set_property(List_bg_grp_h, "tint", .3, .3, .3) 
  491. 				Alt_powers_list[Cur_index]:set_color(1, 1, 1) 
  492. 				Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE, true)	 
  493. 				if game_get_platform() == "PC" then 
  494. 					powers_main_add_mouse_inputs_popup(Cur_index, true) 
  495. 				end 
  496. 				game_UI_audio_play("UI_HUD_Help") 
  497. 				Popup_is_active = true 
  498. 				Popup_is_rad_power = false 
  499. 			else 
  500. 				if Alt_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then 
  501. 					if Alt_powers_list[Cur_index].num_upgrades == 0 then 
  502. 						dialog_box_message("MENU_TITLE_NOTICE", "STORE_NO_ITEMS_IN_CATEGORY", true, true) 
  503. 						return 
  504. 					else 
  505. 						--push upgrades screen 
  506. 						Powers_screen_state = POWERS_SCREEN_STATE_UPGRADE 
  507. 					end 
  508. 				else 
  509. 					--push elements screen 
  510. 					Powers_screen_state = POWERS_SCREEN_STATE_ELEMENT 
  511. 				end 
  512. 				-- Store position for when we return 
  513. 				Cur_popup_position = Alt_powers_list[Cur_index].popup_position 
  514. 				ui_audio_post_event("UI_Hub_Menu_Forward") 
  515. 				push_screen("powers_sub") 
  516. 			 
  517. 				powers_main_lock_controls() 
  518. 				lua_play_anim(Out_anim) 
  519. 				--vint_set_property(Safe_frame_h, "visible", false) 
  520. 			end 
  521. 		else 
  522.  
  523. 			--push upgrades screen 
  524. 			if Alt_powers_list[Cur_index].num_upgrades == 0 then 
  525. 				dialog_box_message("MENU_TITLE_NOTICE", "STORE_NO_ITEMS_IN_CATEGORY", true, true) 
  526. 				return 
  527. 			else 
  528. 				Powers_screen_state = POWERS_SCREEN_STATE_UPGRADE 
  529. 				ui_audio_post_event("UI_Hub_Menu_Forward") 
  530. 				push_screen("powers_sub") 
  531. 				powers_main_lock_controls() 
  532. 				lua_play_anim(Out_anim) 
  533. 				--vint_set_property(Safe_frame_h, "visible", false) 
  534. 			end 
  535. 		end 
  536. 	end 
  537. end 
  538.  
  539. function powers_main_nav_up(event, acceleration) 
  540. 	if Popup_is_active == false then 
  541. 		 
  542. 		local new_list = Cur_list 
  543. 		local new_index = Cur_index 
  544. 		local max_index 
  545. 		 
  546. 		if Cur_list == POWERS_TYPE_RAD then 
  547. 			for i = 4, 1, -1 do  
  548. 				if Rad_powers_list[i]:get_visible() == true then 
  549. 					max_index = i 
  550. 					break 
  551. 				end 
  552. 			end 
  553. 		else  
  554. 			for i = 4, 1, -1 do  
  555. 				if Alt_powers_list[i]:get_visible() == true then 
  556. 					max_index = i 
  557. 					break 
  558. 				end 
  559. 			end 
  560. 		end 
  561. 		 
  562. 		if new_index > 1 then 
  563. 			new_index = Cur_index - 1 
  564. 		else 
  565. 			new_index = max_index 
  566. 		end 
  567. 		 
  568. 		if new_index ~= Cur_index then 
  569. 			powers_main_set_highlight(new_list, new_index) 
  570. 		end 
  571. 		ui_audio_post_event("ui_powers_menu_nav") 
  572. 	else 
  573. 		if Popup_is_rad_power then 
  574. 			if Rad_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then 
  575. 				Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT) 
  576. 			else 
  577. 				Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE) 
  578. 			end 
  579. 		else 
  580. 			if Alt_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then 
  581. 				Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT, true) 
  582. 			else 
  583. 				Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE, true) 
  584. 			end 
  585. 		end 
  586. 		game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  587. 	end 
  588. 	 
  589. end 
  590.  
  591. function powers_main_nav_down(event, acceleration) 
  592. 	if Popup_is_active == false then 
  593. 	 
  594. 		local new_list = Cur_list 
  595. 		local new_index = Cur_index 
  596. 		local max_index 
  597. 		 
  598. 		if Cur_list == POWERS_TYPE_RAD then 
  599. 			for i = 4, 1, -1 do  
  600. 				if Rad_powers_list[i]:get_visible() == true then 
  601. 					max_index = i 
  602. 					break 
  603. 				end 
  604. 			end 
  605. 		else  
  606. 			for i = 4, 1, -1 do  
  607. 				if Alt_powers_list[i]:get_visible() == true then 
  608. 					max_index = i 
  609. 					break 
  610. 				end 
  611. 			end 
  612. 		end 
  613. 			 
  614. 		if new_index < max_index then 
  615. 			new_index = Cur_index + 1 
  616. 		else 
  617. 			new_index = 1 
  618. 		end 
  619. 		 
  620. 		if new_index ~= Cur_index then 
  621. 			powers_main_set_highlight(new_list, new_index) 
  622. 		end 
  623. 		ui_audio_post_event("ui_powers_menu_nav") 
  624. 	else 
  625. 		if Popup_is_rad_power then 
  626. 			if Rad_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then 
  627. 				Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT) 
  628. 			else 
  629. 				Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE) 
  630. 			end 
  631. 		else 
  632. 			if Alt_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then 
  633. 				Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT, true) 
  634. 			else 
  635. 				Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE, true) 
  636. 			end 
  637. 		end 
  638. 		game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  639. 	end 
  640. 	 
  641. end 
  642.  
  643. function powers_main_nav_left(event, acceleration) 
  644. 	 
  645. 	if Popup_is_active == false then 
  646. 	 
  647. 		local new_list = Cur_list 
  648. 		local new_index = Cur_index 
  649. 		 
  650. 		 
  651. 		if Cur_list == POWERS_TYPE_ALT and Rad_powers_list[1]:get_visible() == true then 
  652. 			new_list = Cur_list - 1 
  653. 			 
  654. 			for i = Cur_index, 1, -1 do  
  655. 				if Rad_powers_list[i]:get_visible() == true then 
  656. 					new_index = i 
  657. 					break 
  658. 				end 
  659. 			end 
  660. 		end 
  661. 		 
  662. 		if Cur_list == POWERS_TYPE_RAD and Alt_powers_list[1]:get_visible() == true then 
  663. 			new_list = Cur_list + 1 
  664. 			 
  665. 			for i = Cur_index, 1, -1 do  
  666. 				if Alt_powers_list[i]:get_visible() == true then 
  667. 					new_index = i 
  668. 					break 
  669. 				end 
  670. 			end 
  671. 		end 
  672. 		 
  673. 		if new_list ~= Cur_list or new_index ~= Cur_index then 
  674. 			powers_main_set_highlight(new_list, new_index) 
  675. 		end 
  676. 		 
  677. 	end 
  678. 	ui_audio_post_event("ui_powers_menu_nav") 
  679. end 
  680.  
  681. function powers_main_nav_right(event, acceleration) 
  682. 	if Popup_is_active == false then 
  683. 	 
  684. 		local new_list = Cur_list 
  685. 		local new_index = Cur_index 
  686. 		 
  687. 		if Cur_list == POWERS_TYPE_RAD and Alt_powers_list[1]:get_visible() == true then 
  688. 			new_list = Cur_list + 1 
  689. 			 
  690. 			for i = Cur_index, 1, -1 do  
  691. 				if Alt_powers_list[i]:get_visible() == true then 
  692. 					new_index = i 
  693. 					break 
  694. 				end 
  695. 			end 
  696. 		end 
  697. 		 
  698. 		if Cur_list == POWERS_TYPE_ALT and Rad_powers_list[1]:get_visible() == true then 
  699. 			new_list = Cur_list - 1 
  700. 			 
  701. 			for i = Cur_index, 1, -1 do  
  702. 				if Rad_powers_list[i]:get_visible() == true then 
  703. 					new_index = i 
  704. 					break 
  705. 				end 
  706. 			end 
  707. 		end 
  708. 		 
  709. 		if new_list ~= Cur_list or new_index ~= Cur_index then 
  710. 			powers_main_set_highlight(new_list, new_index) 
  711. 		end 
  712. 		 
  713. 	end 
  714. 	ui_audio_post_event("ui_powers_menu_nav") 
  715. end 
  716.  
  717. ----------------- 
  718. --Mouse Functions 
  719. ----------------- 
  720.  
  721. function powers_main_add_mouse_inputs() 
  722. 	local priority = 500000 
  723. 	--clear all mouse inputs 
  724. 	if Mouse_input_tracker ~= nil then 
  725. 		Mouse_input_tracker:remove_all() 
  726. 	end 
  727. 	 
  728. 	if Hint_bar_mouse_input_tracker ~= nil then 
  729. 		Hint_bar_mouse_input_tracker:remove_all() 
  730. 	end 
  731. 	--rebuild all mouse inputs 
  732. 	Hint_bar:add_mouse_inputs( "powers_main_hint", Hint_bar_mouse_input_tracker, 700000 ) 
  733. 	 
  734. 	for i = 1, 4 do 
  735. 		if Rad_powers_list[i]:get_visible() then 
  736. 			Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Rad_powers_list[i]:get_mouse_region() ) 
  737. 			Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Rad_powers_list[i]:get_mouse_region() ) 
  738. 			 
  739. 		end 
  740. 	end 
  741. 	for i = 1, 4 do 
  742. 		if Alt_powers_list[i]:get_visible() then 
  743. 			Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Alt_powers_list[i]:get_mouse_region() ) 
  744. 			Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Alt_powers_list[i]:get_mouse_region() ) 
  745. 		end 
  746. 	end 
  747. 	Mouse_input_tracker:subscribe(true) 
  748. 	Hint_bar_mouse_input_tracker:subscribe(true) 
  749. end 
  750.  
  751. function powers_main_add_mouse_inputs_popup(index, alt_power) 
  752. 	 
  753. 	--[[ 
  754. 	if alt_power and game_unlockable_is_unlocked( "DLC_Preorder_Saints_Wings" ) then 
  755. 		alt_power = false 
  756. 	end 
  757. 	--]] 
  758.  
  759. 	local priority = 500000 
  760. 	--clear all mouse inputs 
  761. 	if Mouse_input_tracker ~= nil then 
  762. 		Mouse_input_tracker:subscribe(false) 
  763. 		Mouse_input_tracker:remove_all() 
  764. 		 
  765. 		-- Add mouse inputs to all the power categories that aren't currently selected 
  766. 		for i = 1, 4 do 
  767. 			if alt_power then 
  768. 				if Rad_powers_list[i]:get_visible() then 
  769. 					Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Rad_powers_list[i]:get_mouse_region() ) 
  770. 					Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Rad_powers_list[i]:get_mouse_region() ) 
  771. 				end 
  772. 			 
  773. 				if Alt_powers_list[i]:get_visible()  and i ~= Cur_index then  
  774. 					Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Alt_powers_list[i]:get_mouse_region() ) 
  775. 					Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Alt_powers_list[i]:get_mouse_region() ) 
  776. 				end 
  777. 			else 
  778. 				if Rad_powers_list[i]:get_visible() and i ~= Cur_index then 
  779. 					Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Rad_powers_list[i]:get_mouse_region() ) 
  780. 					Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Rad_powers_list[i]:get_mouse_region() ) 
  781. 				end 
  782. 			 
  783. 				if Alt_powers_list[i]:get_visible() then 
  784. 					Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Alt_powers_list[i]:get_mouse_region() ) 
  785. 					Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Alt_powers_list[i]:get_mouse_region() ) 
  786. 				end 
  787. 			end 
  788. 		end 
  789. 	end 
  790. 	 
  791. 	if Hint_bar_mouse_input_tracker ~= nil then 
  792. 		Hint_bar_mouse_input_tracker:remove_all() 
  793. 	end 
  794. 	--rebuild all mouse inputs 
  795. 	Hint_bar:add_mouse_inputs( "powers_main_hint", Hint_bar_mouse_input_tracker, 700000 ) 
  796. 	 
  797. 	if alt_power then 
  798. 		Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", 600000, Alt_powers_list[index].mouse_top_h ) 
  799. 		Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", 600000, Alt_powers_list[index].mouse_bot_h ) 
  800. 		Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", 600000, Alt_powers_list[index].mouse_top_h ) 
  801. 		Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", 600000, Alt_powers_list[index].mouse_bot_h ) 
  802. 	else 
  803. 		Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", 600000, Rad_powers_list[index].mouse_top_h ) 
  804. 		Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", 600000, Rad_powers_list[index].mouse_bot_h ) 
  805. 		Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", 600000, Rad_powers_list[index].mouse_top_h ) 
  806. 		Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", 600000, Rad_powers_list[index].mouse_bot_h ) 
  807. 	end 
  808. 	 
  809. 	Mouse_input_tracker:subscribe(true) 
  810. 	Hint_bar_mouse_input_tracker:subscribe(true) 
  811. end 
  812.  
  813. function powers_main_mouse_click(event, target_handle) 
  814. 	 
  815. 	if Popup_is_active == false then  
  816. 		for i = 1, 4 do 
  817. 			if target_handle == Rad_powers_list[i].bg_off_h then 
  818. 				powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active) 
  819. 			end 
  820. 			if target_handle == Alt_powers_list[i].bg_off_h then 
  821. 				powers_main_set_highlight(POWERS_TYPE_ALT, i, Popup_is_active) 
  822. 			end 
  823. 		end 
  824. 	else 
  825. 		for i = 1, 4 do 
  826. 			-- If the player has selected an item that is not in the pop up, take them back to the main power screen 
  827. 			if target_handle == Rad_powers_list[i].bg_off_h or target_handle == Alt_powers_list[i].bg_off_h then 
  828. 				-- Back out from the pop up 
  829. 				powers_main_button_b() 
  830. 				 
  831. 				--Move the highlight over where the mouse selected 
  832. 				if target_handle == Rad_powers_list[i].bg_off_h then 
  833. 					powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active) 
  834. 				elseif target_handle == Alt_powers_list[i].bg_off_h then 
  835. 					powers_main_set_highlight(POWERS_TYPE_ALT, i, Popup_is_active) 
  836. 				end 
  837. 				 
  838. 				-- We don't want to select the highlighted item so leave this function 
  839. 				return  
  840. 			end 
  841. 		end 
  842. 	end 
  843. 	 
  844. 	powers_main_button_a() 
  845. end 
  846.  
  847. --used so clicking on hint bar doesnt interfere with power buttons 
  848. function powers_main_hint_mouse_click(event, target_handle) 
  849. 	 
  850. 	local hint_index = Hint_bar:get_hint_index( target_handle ) 
  851. 	if hint_index == 1 then 
  852. 		powers_main_button_b() 
  853. 	end 
  854. end 
  855.  
  856. function powers_main_hint_mouse_move(event, target_handle) 
  857. 	Hint_bar:set_highlight(0) 
  858. 	local hint_index = Hint_bar:get_hint_index( target_handle ) 
  859. 	if hint_index == 1 then 
  860. 		Hint_bar:set_highlight(hint_index) 
  861. 	end 
  862. end 
  863.  
  864. function powers_main_mouse_move(event, target_handle) 
  865. 	if Popup_is_active then  
  866. 		if Popup_is_rad_power then 
  867. 			for i = 1, 4 do 
  868. 				if target_handle == Rad_powers_list[i].mouse_top_h then 
  869. 					Rad_powers_list[i].popup_position = POWERS_SCREEN_STATE_UPGRADE 
  870. 					Rad_powers_list[i]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE) 
  871. 					game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  872. 				end 
  873. 				if target_handle == Rad_powers_list[i].mouse_bot_h then 
  874. 					Rad_powers_list[i].popup_position = POWERS_SCREEN_STATE_ELEMENT 
  875. 					Rad_powers_list[i]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT) 
  876. 					game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  877. 					--powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active) 
  878. 				end 
  879. 			end 
  880. 		else 
  881. 			for i = 1, 4 do 
  882. 				if target_handle == Alt_powers_list[i].mouse_top_h then 
  883. 					Alt_powers_list[i].popup_position = POWERS_SCREEN_STATE_UPGRADE 
  884. 					Alt_powers_list[i]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE, true) 
  885. 					game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  886. 				end 
  887. 				if target_handle == Alt_powers_list[i].mouse_bot_h then 
  888. 					Alt_powers_list[i].popup_position = POWERS_SCREEN_STATE_ELEMENT 
  889. 					Alt_powers_list[i]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT, true) 
  890. 					game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  891. 					--powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active) 
  892. 				end 
  893. 			end 
  894. 		end 
  895. 	else 
  896. 		for i = 1, 4 do 
  897. 			if target_handle == Rad_powers_list[i].bg_off_h then 
  898. 				powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active) 
  899. 				ui_audio_post_event("ui_powers_menu_nav") 
  900. 			end 
  901. 			if target_handle == Alt_powers_list[i].bg_off_h then 
  902. 				powers_main_set_highlight(POWERS_TYPE_ALT, i, Popup_is_active) 
  903. 				ui_audio_post_event("ui_powers_menu_nav") 
  904. 			end 
  905. 		end 
  906. 	end 
  907. 	 
  908. 	 
  909. 	 
  910. end 
  911.