./main_menu_silverlink.lua

  1. local Main_menu_silverlink_doc_h = 0 
  2. local ID_CONNECT 				= 1 
  3. local ID_CREATE_ACCOUNT 	= 2 
  4. local ID_LOST_PASSWORD		= 3 
  5. local ID_ABOUT_SILVERLINK	= 4 
  6. local ID_REWARDS				= 5 
  7. local ID_SETTINGS				= 6 
  8.  
  9. --If the user is logged out 
  10. local Menu_logged_out = { 
  11. 	[1] = { 
  12. 		type = TYPE_BUTTON, 
  13. 		label = "SL_MENU_CONNECT", 
  14. 		id = ID_CONNECT, 
  15. 	}, 
  16. 	[2] =	{ 
  17. 		type = TYPE_BUTTON, 
  18. 		label = "SL_MENU_CREATE_ACCOUNT", 
  19. 		id = ID_CREATE_ACCOUNT, 
  20. 	}, 
  21. 	[3] = { 
  22. 		type = TYPE_BUTTON, 
  23. 		label = "SL_MENU_LOST_PASSWORD", 
  24. 		id = ID_LOST_PASSWORD, 
  25. 	}, 
  26. 	[4] = { 
  27. 		type = TYPE_BUTTON, 
  28. 		label = "SL_MENU_ABOUT_SILVERLINK", 
  29. 		id = ID_ABOUT_SILVERLINK, 
  30. 	} 
  31. } 
  32.  
  33. --If the user is logged out 
  34. local Menu_logged_in = { 
  35. 	[1] = { 
  36. 		type = TYPE_BUTTON, 
  37. 		label = "SL_MENU_SILVERLINK_REWARDS", 
  38. 		id = ID_REWARDS, 
  39. 	}, 
  40. 	[2] =	{ 
  41. 		type = TYPE_BUTTON, 
  42. 		label = "SL_MENU_SETTINGS", 
  43. 		id = ID_SETTINGS, 
  44. 	}, 
  45. 	[3] = { 
  46. 		type = TYPE_BUTTON, 
  47. 		label = "SL_MENU_ABOUT_SILVERLINK", 
  48. 		id = ID_ABOUT_SILVERLINK, 
  49. 	} 
  50. } 
  51.  
  52.  
  53. local Input_tracker 
  54. local Mouse_input_tracker 
  55.  
  56. local Screen_width 
  57. if vint_is_std_res() then 
  58. 	Screen_width = 750 
  59. else 
  60. 	Screen_width = 840 
  61. end 
  62.  
  63. ---------------------------------------------------------------------------  
  64. -- Initialize Pause Options Menu. 
  65. --------------------------------------------------------------------------- 
  66. function main_menu_silverlink_init() 
  67.  
  68. 	Main_menu_silverlink_doc_h = vint_document_find("main_menu_silverlink") 
  69. 	-- Subscribe to the button presses we need 
  70. 		 
  71. 	Input_tracker = Vdo_input_tracker:new() 
  72. 	Input_tracker:add_input("select", "main_menu_silverlink_button_a", 50) 
  73. 	Input_tracker:add_input("back", "main_menu_silverlink_button_b", 50) 
  74. 	Input_tracker:add_input("nav_up", "main_menu_silverlink_nav_up", 50) 
  75. 	Input_tracker:add_input("nav_down", "main_menu_silverlink_nav_down", 50) 
  76. 	Input_tracker:add_input("nav_left", "main_menu_silverlink_nav_left", 50) 
  77. 	Input_tracker:add_input("nav_right", "main_menu_silverlink_nav_right", 50) 
  78. 	Input_tracker:subscribe(false) 
  79.  
  80. 	--Initialize Header 
  81. 	Header_obj:show_me(false) 
  82. 	--Header_mini_obj:set_text("SILVER LINK 2") 
  83. 	--Header_mini_obj:set_visible(true) 
  84. 	 
  85. 	--Setup Button Hints 
  86. 	local hint_data = { 
  87. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  88. 	} 
  89. 	Menu_hint_bar:set_hints(hint_data)   
  90. 	 
  91. 	--Check to see if we are connected or disconnected... base menu display based on that... 
  92. 	local am_i_logged_in = silverlink_is_connected() 
  93. 	local data 
  94. 	if am_i_logged_in then 
  95. 		data = Menu_logged_in 
  96. 		main_menu_silverlink_update_login(true) 
  97. 	else 
  98. 		data = Menu_logged_out 
  99. 		main_menu_silverlink_update_login(false) 
  100. 	end 
  101. 	 
  102. 	--Get the selection option from when the menu was last loaded 
  103. 	local last_option_selected = menu_common_stack_get_index(data) 
  104. 	 
  105. 	List:set_visible(true) 
  106. 	List:draw_items(data, last_option_selected, Screen_width) 
  107. 	 
  108. 	--Store some locals to the pause menu common for screen processing. 
  109. 	menu_common_set_list_style(List, Header_obj, Screen_width) 
  110. 	 
  111. 	bg_saints_show(true) 
  112. 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim)	 
  113. 	 
  114. 	--Show the silverlink logo 
  115. 	if In_silverlink_menu == false then 
  116. 		main_menu_silverlink_logo_show(true) 
  117. 		main_menu_silverlink_logo_is_visible(true) 
  118. 		In_silverlink_menu = true 
  119. 	end 
  120. 	 
  121. 	--Show silverlink Login 
  122. 	main_menu_silverlink_login_show(true) 
  123. 	 
  124. 	--Some stuff i'm not sure what it does yet (JMH- 4/30/2013) 
  125. 	if First_time then 
  126. 		Screen_in_anim:play(0) 
  127. 		bg_saints_slide_in(Screen_width) 
  128. 		First_time = false 
  129. 	end 
  130. 	 
  131. 	-- Add mouse inputs for the PC 
  132. 	if game_get_platform() == "PC" then 
  133. 		Menu_hint_bar:set_highlight(0) 
  134. 		 
  135. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  136. 		List:add_mouse_inputs("main_menu_silverlink", Mouse_input_tracker) 
  137. 		Menu_hint_bar:add_mouse_inputs("main_menu_silverlink", Mouse_input_tracker) 
  138. 		Mouse_input_tracker:subscribe(true) 
  139. 		 
  140. 		--menu_common_set_mouse_tracker(Mouse_input_tracker) 
  141. 	end 
  142. end 
  143.  
  144. function main_menu_silverlink_cleanup() 
  145. 	-- Nuke all button subscriptions 
  146. 	Input_tracker:subscribe(false) 
  147. 	if Mouse_input_tracker ~= nil then 
  148. 		Mouse_input_tracker:subscribe(false) 
  149. 	end 
  150. 	List:enable_toggle_input(false) 
  151. 	 
  152. 	Header_obj:show_me(true) 
  153. 	Header_mini_obj:set_visible(false) 
  154. end 
  155.  
  156. function main_menu_silverlink_nav_up(event, acceleration) 
  157. 	-- Move highlight up 
  158. 	List:move_cursor(-1) 
  159. end 
  160.  
  161. function main_menu_silverlink_nav_down(event, acceleration) 
  162. 	-- Move highlight down 
  163. 	List:move_cursor(1) 
  164. end 
  165.  
  166. function main_menu_silverlink_nav_left(event, acceleration) 
  167. 	-- Move highlight left 
  168. 	List:move_slider(-1) 
  169. end 
  170.  
  171. function main_menu_silverlink_nav_right(event, acceleration) 
  172. 	-- Move highlight right 
  173. 	List:move_slider(1) 
  174. end 
  175.  
  176. function main_menu_silverlink_button_a(event, acceleration) 
  177. 	local current_id = List:get_id() 
  178. 	 
  179. 	--Add current selection to the stack to store the selected position on the menu 
  180. 	menu_common_stack_add(current_id) 
  181. 	 
  182. 	--pass off the input to the list 
  183. 	List:button_a() 
  184. 	 
  185. 	if current_id == ID_CONNECT then 
  186. 		silverlink_dlg_connect() 
  187. 	elseif current_id == ID_CREATE_ACCOUNT then  
  188. 		silverlink_dlg_create_account() 
  189. 	elseif current_id == ID_LOST_PASSWORD then  
  190. 		silverlink_dlg_lost_password() 
  191. 	elseif current_id == ID_ABOUT_SILVERLINK then 
  192. 		menu_common_transition_push("main_sl_about") 
  193. 		--Hide silverlink Login 
  194. 		main_menu_silverlink_login_show(false) 
  195. 	elseif current_id == ID_REWARDS then 
  196. 		menu_common_transition_push("main_sl_rewards") 
  197. 		--Hide silverlink Login 
  198. 		main_menu_silverlink_login_show(false) 
  199. 	elseif current_id == ID_SETTINGS then 
  200. 		menu_common_transition_push("main_sl_settings") 
  201. 		--Hide silverlink Login 
  202. 		main_menu_silverlink_login_show(false) 
  203. 	end 
  204. end 
  205.  
  206.  
  207. function main_menu_silverlink_button_b(event, acceleration) 
  208. 	List:button_b() 
  209.  
  210. 	Input_tracker:subscribe(false) 
  211. 	if Mouse_input_tracker ~= nil then 
  212. 		Mouse_input_tracker:subscribe(false) 
  213. 	end 
  214. 	 
  215. 	-- final pop... 
  216. 	--Remove current menu from the stack 
  217. 	menu_common_stack_remove() 
  218. 	 
  219. 	--Pop Screen off the list 
  220. 	menu_common_transition_pop(1) 
  221. 	 
  222. 	--Hide the silverlink logo 
  223. 	main_menu_silverlink_logo_show(false) 
  224. 	 
  225. 	--Hide silverlink Login 
  226. 	main_menu_silverlink_login_show(false) 
  227. 	In_silverlink_menu = false 
  228. 	 
  229. 	bg_saints_slide_out() 
  230. end 
  231.  
  232. function main_menu_silverlink_mouse_click(event, target_handle) 
  233. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  234. 	if hint_index == 1 then 
  235. 		main_menu_silverlink_button_b() 
  236. 	end 
  237.  
  238. 	local new_index = List:get_button_index(target_handle) 
  239. 	if new_index ~= 0 then 
  240. 		List:set_selection(new_index) 
  241. 		main_menu_silverlink_button_a() 
  242. 	end 
  243. end 
  244.  
  245. function main_menu_silverlink_mouse_move(event, target_handle) 
  246. 	Menu_hint_bar:set_highlight(0) 
  247. 	 
  248. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  249. 	if hint_index ~= 0 then 
  250. 		Menu_hint_bar:set_highlight(hint_index) 
  251. 	end 
  252. 	 
  253. 	local new_index = List:get_button_index(target_handle) 
  254. 	if new_index ~= 0 then 
  255. 		List:set_selection(new_index) 
  256. 		List:move_cursor(0, true) 
  257. 	end 
  258. end 
  259.  
  260. ------------------------------------------------------------------------------- 
  261. -- When silverlink is connceted...  
  262. -- (This is called From C++) 
  263. -- 
  264. function silverlink_connection_changed() 
  265. 		--Changes menu to a connected screen 
  266. 	local am_i_logged_in = silverlink_is_connected() 
  267. 	local data  
  268. 	 
  269. 	if am_i_logged_in then 
  270. 		data = Menu_logged_in 
  271. 		main_menu_silverlink_update_login(true) 
  272. 	else 
  273. 		data = Menu_logged_out 
  274. 		main_menu_silverlink_update_login(false) 
  275. 	end 
  276. 	List:set_visible(true) 
  277. 	List:draw_items(data, 1, Screen_width) 
  278. end 
  279.  
  280. ------------------------------------------------------------------------------- 
  281. -- When all dialogs are closed...  
  282. -- (This is called From C++) 
  283. -- 
  284. function silverlink_all_dialogs_closed() 
  285. 	--All dialogs closed now lets show the cursor... 
  286. 	List:move_cursor(0) 
  287. 	 
  288. 	if Mouse_input_tracker ~= nil then 
  289. 		Mouse_input_tracker:remove_all() 
  290. 		Menu_hint_bar:add_mouse_inputs("main_menu_silverlink", Mouse_input_tracker) 
  291. 		List:add_mouse_inputs("main_menu_silverlink", Mouse_input_tracker) 
  292. 		Mouse_input_tracker:subscribe(true) 
  293. 	end 
  294. end 
  295.  
  296.