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