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