./cell_extras.lua

  1. ID_CHEATS		= 0 
  2. ID_STATS		= 1 
  3. ID_COLLECTION	= 2 
  4.  
  5. local Data = { 
  6. 	[ID_CHEATS] = { 
  7. 		label = "MENU_CHEATS", 
  8. 		icon = "ui_cell_icon_cheats" 
  9. 	},	 
  10. 	[ID_STATS] = { 
  11. 		label = "MENU_STATS", 
  12. 		icon = "ui_cell_icon_stats", 
  13. 		can_wrap = false 
  14. 	}, 
  15. 	[ID_COLLECTION] = { 
  16. 		label = "MENU_COLLECTION", 
  17. 		icon = "ui_cell_icon_tomes", 
  18. 		can_wrap = false 
  19. 	}, 
  20. } 
  21.  
  22. local Menu_extras 
  23. local Hint_bar 
  24. local Input_tracker 
  25. local Mouse_input_tracker 
  26. local Cell_extras_doc_h = -1 
  27.  
  28. function cell_extras_init() 
  29. 	-- Subscribe to the button presses we need 
  30. 	Cell_extras_doc_h = vint_document_find("cell_extras") 
  31. 	 
  32. 	--Build input tracker... 
  33. 	Input_tracker = Vdo_input_tracker:new() 
  34. 	Input_tracker:add_input("map", "cell_extras_button_map", 50) 
  35. 	Input_tracker:add_input("select", "cell_extras_button_a", 50) 
  36. 	Input_tracker:add_input("back", "cell_extras_button_b", 50) 
  37. 	Input_tracker:add_input("nav_up", "cell_extras_nav_up", 50) 
  38. 	Input_tracker:add_input("nav_down", "cell_extras_nav_down", 50) 
  39. 	Input_tracker:add_input("nav_left", "cell_extras_nav_left", 50) 
  40. 	Input_tracker:add_input("nav_right", "cell_extras_nav_right", 50) 
  41. 	 
  42. 	--Build menu... 
  43. 	Menu_extras = Vdo_cell_menu:new("cell_menu") 
  44. 	Menu_extras:populate_menu(Data) 
  45. 	 
  46. 	if game_get_platform() == "PC" then 
  47. 		-- Setup Button Hints 
  48. 		Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Cell_extras_doc_h) 
  49. 		local hint_data = { 
  50. 			{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  51. 		} 
  52. 		Hint_bar:set_hints(hint_data)  
  53. 		Hint_bar:set_visible(true)	 
  54. 		Hint_bar:set_highlight(0) 
  55. 		 
  56. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  57. 		Menu_extras:add_mouse_inputs("cell_extras", Mouse_input_tracker) 
  58. 		Hint_bar:add_mouse_inputs("cell_extras", Mouse_input_tracker) 
  59. 	end 
  60.  
  61. 	debug_print("vint", "double transition\n") 
  62. 	--Transition the screen in... 
  63. 	cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_EXTRAS, CELL_SCREEN_MAIN, cell_extras_gained_focus) 
  64. end 
  65.  
  66. function cell_extras_cleanup() 
  67. 	-- Nuke all button subscriptions 
  68. 	Input_tracker:subscribe(false) 
  69. 	if Mouse_input_tracker ~= nil then 
  70. 		Mouse_input_tracker:subscribe(false) 
  71. 	end 
  72. end 
  73.  
  74. function cell_extras_nav_up(event, acceleration) 
  75. 	Menu_extras:nav_up() 
  76. end 
  77.  
  78. function cell_extras_nav_down(event, acceleration) 
  79. 	Menu_extras:nav_down() 
  80. end 
  81.  
  82. function cell_extras_nav_left(event, acceleration) 
  83. 	Menu_extras:nav_left() 
  84. end 
  85.  
  86. function cell_extras_nav_right(event, acceleration) 
  87. 	Menu_extras:nav_right() 
  88. end 
  89.  
  90. function cell_extras_button_map(event, acceleration) 
  91. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  92. 	cell_extras_lock_controls() 
  93. 	cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_EXTRAS, cell_extras_exit_to_game) 
  94. end 
  95.  
  96. function cell_extras_button_b(event, acceleration) 
  97. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  98. 	cell_extras_lock_controls() 
  99. 	Menu_extras:show_highlight(false) 
  100. 	cell_transition_screen(CELL_STATE_PORTRAIT,  CELL_SCREEN_MAIN, CELL_SCREEN_EXTRAS, cell_extras_exit_to_main) 
  101. end 
  102.  
  103. function cell_extras_exit_to_main() 
  104. 	pop_screen()	--Extras 
  105. end 
  106.  
  107. function cell_extras_exit_to_game() 
  108. 	pop_screen()	--Extras 
  109. 	pop_screen()	--Main 
  110. 	pop_screen()	--frame 
  111. end 
  112.  
  113. function cell_extras_button_a(event, acceleration) 
  114. 	cell_extras_lock_controls() 
  115. 	--TODO: Check to see if tween is done before you move to next screen. 
  116. 	--Get id and change state... 
  117. 	local current_id = Menu_extras:get_id() 
  118. 	cell_extras_handle_state(current_id) 
  119. end 
  120.  
  121. function cell_extras_mouse_click(event, target_handle) 
  122. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  123. 	if hint_index == 1 then 
  124. 		cell_extras_button_b() 
  125. 	end 
  126. 	 
  127. 	-- If the target_handle matches a button, activate it 
  128. 	if Menu_extras:select_button(target_handle) == true then 
  129. 		cell_extras_button_a() 
  130. 	end 
  131. end 
  132.  
  133. function cell_extras_mouse_move(event, target_handle) 
  134. 	Hint_bar:set_highlight(0) 
  135. 	 
  136. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  137. 	if hint_index ~= 0 then 
  138. 		Hint_bar:set_highlight(hint_index) 
  139. 		ui_audio_post_event("UI_Hub_Navigate") 
  140. 	end 
  141. 	 
  142. 	-- If the target_handle matches a button, highlight it and play a sound 
  143. 	if Menu_extras:select_button(target_handle) == true then 
  144. 		ui_audio_post_event("UI_Hub_Navigate") 
  145. 	end 
  146. end 
  147.  
  148. function cell_extras_handle_state(state) 
  149. 	-- If we are in a different state than -1, then we need the phone to "load that application" 
  150. 	local safe_frame = vint_object_find("safe_frame") 
  151. 	vint_set_property(safe_frame, "visible", true) 
  152. 	 
  153. 	if state == ID_STATS then 
  154. 		push_screen("cell_stats") 
  155. 		ui_audio_post_event("UI_Hub_Menu_Forward") 
  156. 	elseif state == ID_CHEATS then 
  157. 		push_screen("cell_cheats") 
  158. 		ui_audio_post_event("UI_Hub_Menu_Forward") 
  159. 	elseif state == ID_COLLECTION then 
  160. 		push_screen("col_main") 
  161. 		ui_audio_post_event("UI_Hub_Menu_Forward") 
  162. 	end 
  163. 	 
  164. end 
  165.  
  166. function cell_extras_unlock_controls() 
  167. 	Input_tracker:subscribe(true) 
  168. 	if Mouse_input_tracker ~= nil then 
  169. 		Mouse_input_tracker:subscribe(true) 
  170. 	end 
  171. end 
  172.  
  173. function cell_extras_lock_controls() 
  174. 	Input_tracker:subscribe(false) 
  175. 	if Mouse_input_tracker ~= nil then 
  176. 		Mouse_input_tracker:subscribe(false) 
  177. 	end 
  178. end 
  179.  
  180. function cell_extras_lost_focus() 
  181. 	Input_tracker:subscribe(false) 
  182. 	if Mouse_input_tracker ~= nil then 
  183. 		Mouse_input_tracker:subscribe(false) 
  184. 	end 
  185. end 
  186.  
  187. function cell_extras_gained_focus() 
  188. 	Input_tracker:subscribe(true) 
  189. 	if Mouse_input_tracker ~= nil then 
  190. 		Mouse_input_tracker:subscribe(true) 
  191. 	end 
  192. 	--glitch 
  193. 	--glitch_cell() 
  194. end 
  195.