./main_sl_rewards.lua

  1. local ID_REWARDS_RECEIVED 	= 1 
  2. local ID_REWARDS_UNLOCKED	= 2 
  3.  
  4.  
  5. local Screen_data = {  
  6. 	[1] = { 
  7. 		type = TYPE_BUTTON, 
  8. 		label = "SL_MENU_REWARDS_RECEIVED", 
  9. 		id = ID_REWARDS_RECEIVED, 
  10. 	}, 
  11. 	[2] = { 
  12. 		type = TYPE_BUTTON, 
  13. 		label = "SL_MENU_REWARDS_UNLOCKED", 
  14. 		id = ID_REWARDS_UNLOCKED, 
  15. 	}, 
  16. } 
  17.  
  18. local Input_tracker	 
  19. local Mouse_input_tracker 
  20.  
  21. local Screen_width 
  22. if vint_is_std_res() then 
  23. 	Screen_width = 750 
  24. else 
  25. 	Screen_width = 840 
  26. end 
  27.  
  28.  
  29. function main_sl_rewards_init() 
  30.  
  31. 	-- Subscribe to the button presses we need 
  32. 	 
  33. 	Input_tracker = Vdo_input_tracker:new() 
  34. 	Input_tracker:add_input("select", 		"main_sl_rewards_button_a", 50) 
  35. 	Input_tracker:add_input("back", 			"main_sl_rewards_button_b", 50) 
  36. 	Input_tracker:add_input("nav_up", 		"main_sl_rewards_nav_up", 50) 
  37. 	Input_tracker:add_input("nav_down", 	"main_sl_rewards_nav_down", 50) 
  38. 	Input_tracker:add_input("nav_left", 	"main_sl_rewards_nav_left", 50) 
  39. 	Input_tracker:add_input("nav_right", 	"main_sl_rewards_nav_right", 50) 
  40. 	Input_tracker:subscribe(false) 
  41.  
  42. 	--Initialize Header 
  43. 	Header_obj:show_me(false) 
  44. 	Header_mini_obj:set_text("SL_TITLE_REWARDS") 
  45. 	Header_mini_obj:set_visible(true) 
  46. 	 
  47. 	--Setup Button Hints 
  48. 	local hint_data = { 
  49. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  50. 	} 
  51. 	Menu_hint_bar:set_hints(hint_data)   
  52. 	 
  53. 	--Get the selection option from when the menu was last loaded 
  54. 	local last_option_selected = menu_common_stack_get_index(Screen_data) 
  55. 	 
  56. 	 
  57. 	--Store some locals to the pause menu common for screen processing. 
  58. 	menu_common_set_list_style(List, Header_obj, Screen_width) 
  59. 	 
  60. 	bg_saints_show(true) 
  61. 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim)	 
  62.  
  63. 	List:set_visible(true) 
  64. 	List:draw_items(Screen_data, last_option_selected, Screen_width) 
  65. 	 
  66. 	--Some stuff i'm not sure what it does yet (JMH- 4/30/2013) 
  67. 	if First_time then 
  68. 		Screen_in_anim:play(0) 
  69. 		bg_saints_slide_in(Screen_width) 
  70. 		First_time = false 
  71. 	end 
  72. 	 
  73. 	-- Add mouse inputs for the PC 
  74. 	if game_get_platform() == "PC" then 
  75. 		Menu_hint_bar:set_highlight(0) 
  76. 		 
  77. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  78. 		List:add_mouse_inputs("main_sl_rewards", Mouse_input_tracker) 
  79. 		Menu_hint_bar:add_mouse_inputs("main_sl_rewards", Mouse_input_tracker) 
  80. 		Mouse_input_tracker:subscribe(true) 
  81. 	end 
  82. end 
  83.  
  84. function main_sl_rewards_cleanup() 
  85. 	-- Nuke all button subscriptions 
  86. 	Input_tracker:subscribe(false) 
  87. 	if Mouse_input_tracker ~= nil then 
  88. 		Mouse_input_tracker:subscribe(false) 
  89. 	end 
  90. 	List:enable_toggle_input(false) 
  91. 	 
  92. 	Header_obj:show_me(true) 
  93. 	Header_mini_obj:set_visible(false) 
  94. end 
  95.  
  96. function main_sl_rewards_nav_up(event, acceleration) 
  97. 	-- Move highlight up 
  98. 	List:move_cursor(-1) 
  99. end 
  100.  
  101. function main_sl_rewards_nav_down(event, acceleration) 
  102. 	-- Move highlight down 
  103. 	List:move_cursor(1) 
  104. end 
  105.  
  106. function main_sl_rewards_nav_left(event, acceleration) 
  107. 	-- Move highlight left 
  108. 	List:move_slider(-1) 
  109. end 
  110.  
  111. function main_sl_rewards_nav_right(event, acceleration) 
  112. 	-- Move highlight right 
  113. 	List:move_slider(1) 
  114. end 
  115.  
  116. function main_sl_rewards_button_a(event, acceleration) 
  117. 	local current_id = List:get_id() 
  118. 	 
  119. 	--Add current selection to the stack to store the selected position on the menu 
  120. 	menu_common_stack_add(current_id) 
  121. 	 
  122. 	--pass off the input to the list 
  123. 	List:button_a() 
  124. 	 
  125. 	--Store off the ID of next screen to determine what to display... 
  126. 	Silverlink_rewards_type = current_id 
  127. 	if current_id == ID_REWARDS_RECEIVED then 
  128. 		--TODO: set some flag... 
  129. 		menu_common_transition_push("main_sl_rewards_list") 
  130. 	elseif current_id == ID_REWARDS_UNLOCKED then  
  131. 		--TODO: set some flag... 
  132. 		menu_common_transition_push("main_sl_rewards_list") 
  133. 	end 
  134. end 
  135.  
  136.  
  137. function main_sl_rewards_button_b(event, acceleration) 
  138. 	List:button_b() 
  139.  
  140. 	Input_tracker:subscribe(false) 
  141. 	if Mouse_input_tracker ~= nil then 
  142. 		Mouse_input_tracker:subscribe(false) 
  143. 	end 
  144. 	 
  145. 	-- final pop... 
  146. 	--Remove current menu from the stack 
  147. 	menu_common_stack_remove() 
  148. 	 
  149. 	--Pop Screen off the list 
  150. 	menu_common_transition_pop(1) 
  151. 	 
  152. 	bg_saints_slide_out() 
  153. end 
  154.  
  155. function main_sl_rewards_mouse_click(event, target_handle) 
  156. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  157. 	if hint_index == 1 then 
  158. 		main_sl_rewards_button_b() 
  159. 	end 
  160.  
  161. 	local new_index = List:get_button_index(target_handle) 
  162. 	if new_index ~= 0 then 
  163. 		List:set_selection(new_index) 
  164. 		main_sl_rewards_button_a() 
  165. 	end 
  166. end 
  167.  
  168. function main_sl_rewards_mouse_move(event, target_handle) 
  169. 	Menu_hint_bar:set_highlight(0) 
  170. 	 
  171. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  172. 	if hint_index ~= 0 then 
  173. 		Menu_hint_bar:set_highlight(hint_index) 
  174. 	end 
  175. 	 
  176. 	local new_index = List:get_button_index(target_handle) 
  177. 	if new_index ~= 0 then 
  178. 		List:set_selection(new_index) 
  179. 		List:move_cursor(0, true) 
  180. 	end 
  181. end