./pause_options_record_mode.lua

  1. local PM_MENU_CASUAL_RECORD_MODE = 7 
  2.  
  3. local ENABLE_INDEX = 1 
  4. local QUALITY_INDEX = 2 
  5. local HUD_INDEX = 3 
  6.  
  7. local Data = { 
  8. 	[ENABLE_INDEX] = { 
  9. 		type = TYPE_TOGGLE, 
  10. 		label = "PC_ENABLE", 
  11. 		options = {"CELL_CAMERA_MODE_DISABLED", "CELL_CAMERA_MODE_ENABLED"}, 
  12. 		current_value = 1 
  13. 	}, 
  14. 	[QUALITY_INDEX] = { 
  15. 		type = TYPE_TOGGLE, 
  16. 		label = "PC_VIDEO_QUALITY", 
  17. 		options = {"PC_RECORD_MODE_QUALITY_LOW", "PC_RECORD_MODE_QUALITY_MED", "PC_RECORD_MODE_QUALITY_HIGH"}, 
  18. 		current_value = 1 
  19. 	}, 
  20. 	[HUD_INDEX] = { 
  21. 		type = TYPE_TOGGLE, 
  22. 		label = "PC_SHOW_HUD", 
  23. 		options = {"CELL_CAMERA_MODE_DISABLED", "CELL_CAMERA_MODE_ENABLED"}, 
  24. 		current_value = 1 
  25. 	}, 
  26. } 
  27.  
  28. local DISABLE_VALUE_INDEX = 1 
  29. local ENABLE_VALUE_INDEX  = 2 
  30.  
  31. local Input_tracker 
  32. local Mouse_input_tracker 
  33.  
  34. local Record_mode_doc_handle 
  35.  
  36. local Screen_width = 700 
  37.  
  38. local Tween_done = true 
  39.  
  40. function pause_options_record_mode_init() 
  41. 	options_record_mode_finish_init() 
  42. end 
  43.  
  44. function options_record_mode_finish_init() 
  45. 	Record_mode_doc_handle = vint_document_find("pause_options_record_mode") 
  46.  
  47. 	--Initialize Header 
  48. 	Header_obj:set_text("PC_RECORD_VIDEO", Screen_width) 
  49.  
  50. 	-- Subscribe to the button presses we need 
  51. 	Input_tracker = Vdo_input_tracker:new() 
  52. 	Input_tracker:add_input("select", "options_record_mode_button_a", 50) 
  53. 	Input_tracker:add_input("back", "options_record_mode_button_b", 50) 
  54. 	if In_pause_menu then 
  55. 		Input_tracker:add_input("pause", "options_record_mode_button_start", 50) 
  56. 	end 
  57. 	Input_tracker:add_input("nav_up", "options_record_mode_nav_up", 50) 
  58. 	Input_tracker:add_input("nav_down", "options_record_mode_nav_down", 50) 
  59. 	Input_tracker:add_input("nav_left", "options_record_mode_nav_left", 50) 
  60. 	Input_tracker:add_input("nav_right", "options_record_mode_nav_right", 50) 
  61. 	Input_tracker:subscribe(false) 
  62. 	 
  63. 	--Set Button hints 
  64. 	local hint_data = { 
  65. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  66. 	} 
  67. 	if game_get_platform() == "PC" then 
  68. 		hint_data[2] = {CTRL_BUTTON_X, "MENU_RESTORE_DEFAULTS"} 
  69. 		Input_tracker:add_input("alt_select", "options_record_mode_button_x", 50) 
  70. 	end 
  71. 	Menu_hint_bar:set_hints(hint_data)   
  72. 	 
  73. 	--Data[record_mode_INDEX].current_value = get_current_record_mode() + 1	-- Difficulties start at 0 
  74. 	--vint_dataresponder_request("pause_menu_options", "options_record_mode_populate", 0, PM_MENU_CASUAL_RECORD_MODE) 
  75. 	vint_dataresponder_request("pause_menu_options", "options_record_mode_populate", 0, PM_MENU_CASUAL_RECORD_MODE) 
  76. 	List:draw_items(Data, 1, Screen_width) 
  77.  
  78. 	--Store some locals to the pause menu common for screen processing. 
  79. 	menu_common_set_list_style(List, Header_obj, Screen_width) 
  80. 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim) 
  81. 	 
  82. 	--set the tootip text with the correct PC button 
  83. 	local record_key = game_get_key_name_for_action( "CBA_GAC_MACHINIMA_QUICKSAVE" ) 
  84. 	local insert_values = { [0] = record_key } 
  85. 	local body = vint_insert_values_in_string("PC_RECORD_MODE_TEXT", insert_values) 
  86. 	local detail_text_h = vint_object_find("record_text") 
  87. 	vint_set_property( detail_text_h, "text_tag", body ) 
  88. 	 
  89. 	--position the file path text 
  90. 	local record_path_h = vint_object_find("record_path", 0, Record_mode_doc_handle) 
  91. 	local body_w,body_h = element_get_actual_size(detail_text_h) 
  92. 	vint_set_property(record_path_h, "anchor", 0, body_h + 3) 
  93. 	 
  94. 	--scale the file path text 
  95. 	local path_width,crap = vint_get_property(record_path_h, "screen_size") 
  96. 	local max_width = 400 
  97. 	local base_scale = 0.5 
  98. 	 
  99. 	if path_width > max_width then 
  100. 		local text_scale = (max_width/path_width)*base_scale 
  101. 		vint_set_property(record_path_h, "scale", text_scale, text_scale) 
  102. 	else 
  103. 		vint_set_property(record_path_h, "scale", base_scale, base_scale) 
  104. 	end 
  105. 	 
  106. 	-- animate tooltip in 
  107. 	local anim_h = vint_object_find("animate_in", 0, Record_mode_doc_handle) 
  108. 	lua_play_anim(anim_h, 0, Record_mode_doc_handle) 
  109. 	 
  110. 	-- Add mouse inputs for the PC 
  111. 	if game_get_platform() == "PC" then 
  112. 		Menu_hint_bar:set_highlight(0) 
  113. 		 
  114. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  115. 		List:add_mouse_inputs("options_record_mode", Mouse_input_tracker) 
  116. 		Menu_hint_bar:add_mouse_inputs("options_record_mode", Mouse_input_tracker) 
  117. 		Mouse_input_tracker:subscribe(true) 
  118. 		 
  119. 		--menu_common_set_mouse_tracker(Mouse_input_tracker) 
  120. 	end 
  121. end 
  122.  
  123. function options_record_mode_populate(enable, quality, hud) 
  124.  
  125. 	Data[ENABLE_INDEX].previous_value = Data[ENABLE_INDEX].current_value 
  126. 	Data[ENABLE_INDEX].current_value = enable + 1 
  127. 	Data[QUALITY_INDEX].previous_value = Data[QUALITY_INDEX].current_value 
  128. 	Data[QUALITY_INDEX].current_value = quality 
  129. 	Data[HUD_INDEX].previous_value = Data[HUD_INDEX].current_value 
  130. 	Data[HUD_INDEX].current_value = hud + 1 
  131.  
  132. end 
  133.  
  134. function pause_options_record_mode_cleanup() 
  135. 	-- Nuke all button subscriptions 
  136. 	Input_tracker:subscribe(false) 
  137. 	if Mouse_input_tracker ~= nil then 
  138. 		Mouse_input_tracker:subscribe(false) 
  139. 	end 
  140. end 
  141.  
  142. function options_record_mode_nav_up(event, acceleration) 
  143. 	-- Move highlight up 
  144. 	List:move_cursor(-1) 
  145. end 
  146.  
  147. function options_record_mode_nav_down(event, acceleration) 
  148. 	-- Move highlight down 
  149. 	List:move_cursor(1) 
  150. end 
  151.  
  152. function options_record_mode_nav_left(event, acceleration) 
  153. 	List:move_slider(-1) 
  154. end 
  155.  
  156. function options_record_mode_nav_right(event, acceleration) 
  157. 	List:move_slider(1) 
  158. end 
  159.  
  160. function options_record_mode_confirm_enable(result) 
  161. 	if result == 0 then 
  162. 		options_record_mode_save_and_exit() 
  163. 	end 
  164. end 
  165.  
  166. function options_record_mode_button_b(event, acceleration) 
  167.  
  168. 	-- if they are enabling record mode, then they must confirm this 
  169. 	if Data[ENABLE_INDEX].current_value == ENABLE_VALUE_INDEX then 
  170. 	 
  171. 		-- make sure they have the required codec installed 
  172. 		if game_record_mode_can_encode() == false then 
  173. 			dialog_box_message("MENU_TITLE_WARNING", "PC_RECORD_MODE_ERROR_NO_CODEC") 
  174. 			return 
  175. 		end 
  176. 	 
  177. 	 
  178. 		local header = "MENU_TITLE_NOTICE" 
  179. 		local body = "PC_RECORD_MODE_ENABLE_WARNING"	 
  180. 		dialog_box_confirmation(header, body, "options_record_mode_confirm_enable") 
  181. 		return 
  182. 	end 
  183.  
  184. 	options_record_mode_save_and_exit() 
  185. end 
  186. 	 
  187. function options_record_mode_save_and_exit() 
  188. 	--back up a screen 
  189. 	game_record_set_quality_level(Data[QUALITY_INDEX].current_value) 
  190. 	game_record_mode_enable(Data[ENABLE_INDEX].current_value == ENABLE_VALUE_INDEX) 
  191. 	game_record_mode_show_hud(Data[HUD_INDEX].current_value == ENABLE_VALUE_INDEX) 
  192. 	pause_menu_accept_options() 
  193. 	List:button_b() 
  194. 	 
  195. 	-- animate tooltip in 
  196. 	local anim_h = vint_object_find("animate_out", 0, Record_mode_doc_handle) 
  197. 	lua_play_anim(anim_h, 0, Record_mode_doc_handle)	 
  198. 	 
  199. 	--Remove current menu from the stack 
  200. 	menu_common_stack_remove()	 
  201. 	 
  202. 	-- if they are enabling record mode, exit completely from the pause menu 
  203. 	if Data[ENABLE_INDEX].current_value == ENABLE_VALUE_INDEX then 
  204. 		menu_common_transition_pop(3) 
  205. 		bg_saints_slide_out() 
  206. 	else 
  207. 		menu_common_transition_pop(1) 
  208. 	end 
  209. 	 
  210. 	if Mouse_input_tracker ~= nil then 
  211. 		Mouse_input_tracker:subscribe(false) 
  212. 	end 
  213. end 
  214.  
  215. function options_record_mode_button_a(event, acceleration) 
  216. 	options_record_mode_nav_right(event, acceleration) 
  217. end 
  218.  
  219. function options_record_mode_button_x(event, acceleration) 
  220. 	dialog_box_confirmation("OPTIONS_MENU_DEFAULTS_TITLE", "OPTIONS_MENU_DEFAULTS_DESC", "options_record_mode_revert", true, true,1) 
  221. end 
  222.  
  223. function options_record_mode_revert(result, action) 
  224. 	if result == 0 then 
  225. 		pause_menu_restore_defaults(PM_MENU_CASUAL_RECORD_MODE) 
  226. 		vint_dataresponder_request("pause_menu_options", "options_record_mode_populate", 0, PM_MENU_CASUAL_RECORD_MODE)	 
  227. 		List:draw_items(Data, List:get_selection(), 700) 
  228. 		if Mouse_input_tracker ~= nil then 
  229. 			Mouse_input_tracker:remove_all() 
  230. 			List:add_mouse_inputs("options_record_mode", Mouse_input_tracker) 
  231. 			Menu_hint_bar:add_mouse_inputs("options_record_mode", Mouse_input_tracker) 
  232. 			Mouse_input_tracker:subscribe(true) 
  233. 		end 
  234. 	end 
  235. end 
  236.  
  237. function options_record_mode_button_start(event, acceleration) 
  238. 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim)	 
  239. 	Input_tracker:subscribe(false) 
  240. 	menu_common_transition_pop(4) -- options_record_mode, options, pause_menu_top, menu_common 
  241. 	bg_saints_slide_out() 
  242. end 
  243.  
  244. -- Mouse inputs 
  245. function options_record_mode_mouse_click(event, target_handle, mouse_x, mouse_y) 
  246. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  247. 	if hint_index == 1 then 
  248. 		options_record_mode_button_b() 
  249. 	end 
  250. 	if hint_index == 2 then 
  251. 		options_record_mode_button_x() 
  252. 	end 
  253.  
  254. 	local new_index = List:get_button_index(target_handle) 
  255. 	if new_index ~= 0 then 
  256. 		List:set_selection(new_index) 
  257. 		-- Because only toggles are used in this menu, this acts as nav_right 
  258. 		options_record_mode_nav_right() 
  259. 	end 
  260. 	if List:is_left_arrow(target_handle) then 
  261. 		List:move_slider(-1) 
  262. 	end 
  263. end 
  264.  
  265. function options_record_mode_mouse_move(event, target_handle) 
  266. 	Menu_hint_bar:set_highlight(0) 
  267. 	 
  268. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  269. 	if hint_index ~= 0 then 
  270. 		Menu_hint_bar:set_highlight(hint_index) 
  271. 	end 
  272. 	 
  273. 	local new_index = List:get_button_index(target_handle) 
  274. 	if new_index ~= 0 then 
  275. 		List:set_selection(new_index) 
  276. 		List:move_cursor(0, true) 
  277. 	end 
  278. end 
  279.