./pause_options_display.lua

  1. local PM_MENU_DISPLAY_OPTIONS 		= 2 
  2.  
  3. --Menu ID's 
  4. local ID_BRIGHTNESS_GAMMA 				= 1 
  5.  
  6. local Data = {} 
  7.  
  8. BRIGHTNESS_GAMMA_OPTION = { 
  9. 	type = TYPE_BUTTON, 
  10. 	label = "MENU_DISPLAY_MONITOR_ADJUSTMENT", 
  11. 	id = ID_BRIGHTNESS_GAMMA, 
  12. } 
  13. VSYNC_GAMEPLAY_OPTION = { 
  14. 	type = TYPE_TOGGLE, 
  15. 	label = "MENU_VSYNC_GAMEPLAY_TEXT", 
  16. 	options = {"OPTION_NO", "OPTION_YES"}, 
  17. 	current_value = 1, 
  18. 	option_index = 1 -- corresponds to an enum in pause_menu_options.cpp 
  19. } 
  20. VSYNC_CUTSCENE_OPTION = { 
  21. 	type = TYPE_TOGGLE, 
  22. 	label = "MENU_VSYNC_CUTSCENE_TEXT", 
  23. 	options = {"OPTION_NO", "OPTION_YES"}, 
  24. 	current_value = 1, 
  25. 	option_index = 2 
  26. } 
  27. MINIMAP_OPTION = { 
  28. 	type = TYPE_TOGGLE, 
  29. 	label = "CONTROLS_MINIMAP_VIEW", 
  30. 	options = {"MINIMAP_ROTATIONAL", "MINIMAP_STATIC"}, 
  31. 	current_value = 1, 
  32. 	option_index = 3 
  33. } 
  34.  
  35. local Anims = {} 
  36.  
  37. local Input_tracker 
  38.  
  39. local Screen_width = 700 
  40.  
  41. local Tween_done = true 
  42.  
  43. function pause_options_display_init() 
  44. 	-- Subscribe to the button presses we need 
  45. 	 
  46. 	Input_tracker = Vdo_input_tracker:new() 
  47. 	Input_tracker:add_input("select", "options_display_button_a", 50) 
  48. 	Input_tracker:add_input("back", "options_display_button_b", 50) 
  49. 	Input_tracker:add_input("alt_select", "options_display_button_x", 50) 
  50. 	if In_pause_menu then 
  51. 		Input_tracker:add_input("pause", "options_display_button_start", 50) 
  52. 	end 
  53. 	Input_tracker:add_input("nav_up", "options_display_nav_up", 50) 
  54. 	Input_tracker:add_input("nav_down", "options_display_nav_down", 50) 
  55. 	Input_tracker:add_input("nav_left", "options_display_nav_left", 50) 
  56. 	Input_tracker:add_input("nav_right", "options_display_nav_right", 50) 
  57. 	Input_tracker:subscribe(false) 
  58.  
  59.  
  60. 	--Set Button hints 
  61. 	local hint_data = { 
  62. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  63. 		{CTRL_BUTTON_X, "MENU_RESTORE_DEFAULTS"}, 
  64. 	} 
  65. 	Menu_hint_bar:set_hints(hint_data)  
  66. 	Menu_hint_bar:set_visible(true) 
  67. 	 
  68. 	Header_obj:set_text("MENU_DISPLAY_TITLE", Screen_width) 
  69. 	 
  70. 	vint_dataresponder_request("pause_menu_options", "options_display_populate", 0, PM_MENU_DISPLAY_OPTIONS)	 
  71. 	 
  72. 	List:draw_items(Data, 1, Screen_width, 10) 
  73.  
  74. 	--Store some locals to the pause menu common for screen processing. 
  75. 	menu_common_set_list_style(List, Header_obj, Screen_width) 
  76. 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim) 
  77. 	 
  78. end 
  79.  
  80. function pause_options_display_cleanup() 
  81. 	-- Nuke all button subscriptions 
  82. 	Input_tracker:subscribe(false) 
  83. end 
  84.  
  85. function options_display_populate(gameplay_vsync, cutscene_vsync, static_map) 
  86.  
  87. 	VSYNC_GAMEPLAY_OPTION.current_value = gameplay_vsync and 2 or 1 
  88. 	VSYNC_CUTSCENE_OPTION.current_value = cutscene_vsync and 2 or 1 
  89. 	MINIMAP_OPTION.current_value = static_map and 2 or 1 
  90. 	 
  91. 	Data = {} 
  92. 	Data[#Data + 1] = BRIGHTNESS_GAMMA_OPTION 
  93. 	if game_get_platform() ~= "PS3" then 
  94. 		Data[#Data + 1] = VSYNC_GAMEPLAY_OPTION 
  95. 		Data[#Data + 1] = VSYNC_CUTSCENE_OPTION 
  96. 	end 
  97. 	Data[#Data + 1] = MINIMAP_OPTION 
  98. end 
  99.  
  100. function options_display_nav_up(event, acceleration) 
  101. 	-- Move highlight up 
  102. 	List:move_cursor(-1) 
  103. end 
  104.  
  105. function options_display_nav_down(event, acceleration) 
  106. 	-- Move highlight down 
  107. 	List:move_cursor(1) 
  108. end 
  109.  
  110. function options_display_nav_left(event, acceleration) 
  111. 	local current_idx = List:get_selection() 
  112. 	local menu_item = Data[current_idx] 
  113. 	if menu_item.type == TYPE_SLIDER or menu_item.type == TYPE_TOGGLE then 
  114. 		-- Move highlight left 
  115. 		List:move_slider(-1) 
  116. 		options_display_update_option_value() 
  117. 	end 
  118. end 
  119.  
  120. function options_display_nav_right(event, acceleration) 
  121. 	local current_idx = List:get_selection() 
  122. 	local menu_item = Data[current_idx] 
  123. 	if menu_item.type == TYPE_SLIDER or menu_item.type == TYPE_TOGGLE then 
  124. 		-- Move highlight right 
  125. 		List:move_slider(1) 
  126. 		options_display_update_option_value() 
  127. 	end 
  128. end 
  129.  
  130. function options_display_update_option_value() 
  131. 	local current_idx = List:get_selection() 
  132. 	local menu_item = Data[current_idx] 
  133. 	 
  134. 	local bool_val = true 
  135. 	if menu_item.current_value == 1 then 
  136. 		bool_val = false 
  137. 	end 
  138. 	 
  139. 	-- Convert the value to [0.0 - 1.0] 
  140. 	local converted_float = menu_item.current_value 
  141. 	if converted_float ~= 0 then 
  142. 		converted_float = menu_item.current_value / 100 
  143. 	end 
  144. 	 
  145. 	pause_menu_update_option(PM_MENU_DISPLAY_OPTIONS, menu_item.option_index, bool_val, converted_float) 
  146. end 
  147.  
  148. function options_display_button_a(event, acceleration) 
  149. 	local current_id = List:get_id() 
  150.  
  151. 	--Check to see if we are on the other menus 
  152. 	if current_id == ID_BRIGHTNESS_GAMMA then 
  153. 		menu_common_stack_add(current_id) 
  154. 		menu_common_transition_push("pause_options_display_cal") 
  155. 		 
  156. 		return 
  157. 	else  
  158. 		options_display_nav_right() 
  159. 	end 
  160. 	 
  161. 	if Tween_done == true then 
  162. 		--set the screen data to the list data 
  163. 		Data = List:return_data() 
  164. 	end 
  165. end 
  166.  
  167. function options_display_button_b(event, acceleration) 
  168. 	if Tween_done == true then 
  169. 		--set the screen data to the list data 
  170. 		--Data = List:return_data() 
  171. 		--pause_options_display_return_values() 
  172. 		 
  173. 		--check if the list is open or closed 
  174. 		--[[if List:return_state() == true then 
  175. 			--pass off the input to the list 
  176. 			List:button_b() 
  177. 		else--]] 
  178. 			--back up a screen	 
  179. 			--pass off the input to the list 
  180. 			List:button_b() 
  181. 			 
  182. 			-- save the options 
  183. 			pause_menu_accept_options() 
  184. 			 
  185. 			Input_tracker:subscribe(false) 
  186. 			 
  187. 			--Remove current menu from the stack 
  188. 			menu_common_stack_remove() 
  189. 			menu_common_transition_pop(1) 
  190. 		--end 
  191. 	end 
  192. end 
  193.  
  194. function options_display_button_x(event, acceleration) 
  195. 	dialog_box_confirmation("OPTIONS_MENU_DEFAULTS_TITLE", "OPTIONS_MENU_DEFAULTS_DESC", "options_display_revert", true, true,1) 
  196. end 
  197.  
  198. function options_display_revert(result, action) 
  199. 	if result == 0 then 
  200. 		pause_menu_restore_defaults(PM_MENU_DISPLAY_OPTIONS) 
  201. 		vint_dataresponder_request("pause_menu_options", "options_display_populate", 0, PM_MENU_DISPLAY_OPTIONS)	 
  202. 		List:draw_items(Data, List:get_selection(), 700, 10) 
  203. 	end 
  204. end 
  205.  
  206. function options_display_button_start(event, acceleration) 
  207. 	if Tween_done == true then 
  208. 		-- we still want to save the options? 
  209. 		pause_menu_accept_options() 
  210. 		 
  211. 		menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim)	 
  212. 		Input_tracker:subscribe(false) 
  213. 		-- stack is part of common, which is getting popped, so we don't update it. 
  214. 		menu_common_transition_pop(4) -- options_display, options_menu, pause_menu_top, menu_common 
  215. 		bg_saints_slide_out() 
  216. 	end 
  217. end