- local PM_MENU_CONTROL_OPTIONS			= 1  
-   
- local CONTROL_SCHEME_BUTTON_ID = -1  
-   
- local Data = { } 
-   
- local Anims = {} 
-   
- local Input_tracker  
- local Mouse_input_tracker  
-   
- local Screen_width = 800  
-   
- local Tween_done = true  
-   
- function pause_options_controls_init()  
- 	-- Subscribe to the button presses we need  
- 	  
- 	Input_tracker = Vdo_input_tracker:new()  
- 	Input_tracker:add_input("select", "options_controls_button_a", 50) 
- 	Input_tracker:add_input("back", "options_controls_button_b", 50) 
- 	if In_pause_menu then  
- 		Input_tracker:add_input("pause", "options_controls_button_start", 50) 
- 	end  
- 	Input_tracker:add_input("alt_select", "options_controls_button_x", 50) 
- 	Input_tracker:add_input("nav_up", "options_controls_nav_up", 50) 
- 	Input_tracker:add_input("nav_down", "options_controls_nav_down", 50) 
- 	Input_tracker:add_input("nav_left", "options_controls_nav_left", 50) 
- 	Input_tracker:add_input("nav_right", "options_controls_nav_right", 50) 
- 	Input_tracker:subscribe(false)  
-   
- 	--Initialize Header  
- 	if game_get_platform() == "PC" then  
- 		Header_obj:set_text("MENU_CONTROLLER_OPTIONS_TITLE", Screen_width) 
- 	else  
- 		Header_obj:set_text("CONTROLS_TITLE", Screen_width) 
- 	end  
-   
- 	--Get the selection option from when the menu was last loaded  
- 	local last_option_selected = menu_common_stack_get_index()  
-   
- 	--Setup button hints  
- 	local hint_data = { 
- 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
- 		{CTRL_BUTTON_X, "MENU_RESTORE_DEFAULTS"}, 
- 	}  
- 	Menu_hint_bar:set_hints(hint_data)    
-   
- 	-- Initialize and draw list object  
- 	vint_dataresponder_request("pause_menu_options", "options_controls_populate", 0, PM_MENU_CONTROL_OPTIONS)	 
- 	  
- 	List:set_input_tracker(Input_tracker)  
- 	List:draw_items(Data, last_option_selected, Screen_width)  
- 	  
- 	--Store some locals to the pause menu common for screen processing.  
- 	menu_common_set_list_style(List, Header_obj, Screen_width)  
- 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim)  
- 	  
- 	-- Add mouse inputs for the PC  
- 	if game_get_platform() == "PC" then  
- 		Menu_hint_bar:set_highlight(0)  
- 		  
- 		Mouse_input_tracker = Vdo_input_tracker:new()  
- 		List:add_mouse_inputs("options_controls", Mouse_input_tracker) 
- 		Menu_hint_bar:add_mouse_inputs("options_controls", Mouse_input_tracker) 
- 		Mouse_input_tracker:subscribe(true)  
- 		  
- 		--menu_common_set_mouse_tracker(Mouse_input_tracker)  
- 	end  
- end  
-   
- function pause_options_controls_cleanup()  
- 	-- Nuke all button subscriptions  
- 	Input_tracker:subscribe(false)  
- 	if Mouse_input_tracker ~= nil then  
- 		Mouse_input_tracker:subscribe(false)  
- 	end  
- 	List:enable_toggle_input(false)  
- end  
-   
- function options_controls_populate(invert_y, invert_rotation, veh_camera_snap, airplane_controls, vertical_sens, horz_sens, vibration, toggle_crouch)  
-   
- 	Data = { } 
- 	if game_get_platform() == "PC" then  
- 		Data[#Data + 1] = { 
- 			type = TYPE_BUTTON,  
- 			label = "MENU_CONTROL_SCHEMES",  
- 			id = CONTROL_SCHEME_BUTTON_ID,  
- 			current_value = 0  
- 		}  
- 	end  
- 	Data[#Data + 1] = { 
- 		type = TYPE_TOGGLE,  
- 		label = "MENU_CONTROLS_INVERT_Y",  
- 		options = {"OPTION_NO", "OPTION_YES"}, 
- 		id = 1,  
- 		current_value = 1  
- 	}  
- 	if invert_y == 1 then  
- 		Data[#Data].current_value = 2  
- 	else   
- 		Data[#Data].current_value = 1  
- 	end  
- 	  
- 	Data[#Data + 1] = { 
- 		type = TYPE_TOGGLE,  
- 		label = "MENU_CONTROLS_INVERT_ROTATION",  
- 		options = {"OPTION_NO", "OPTION_YES"}, 
- 		id = 2,  
- 		current_value = 1  
- 	}  
- 	if invert_rotation == 1 then  
- 		Data[#Data].current_value = 2  
- 	else   
- 		Data[#Data].current_value = 1  
- 	end  
-   
- 	local vehicle_snap_option = { 
- 		type = TYPE_TOGGLE,  
- 		label = "MENU_VEHICLE_CAMERA_SNAP",  
- 		options = {"MENU_INSTANT", "MENU_DELAYED"}, 
- 		id = 3,  
- 		current_value = 1  
- 	}  
- 	if veh_camera_snap == 1 then  
- 		vehicle_snap_option.current_value = 2  
- 	else  
- 		vehicle_snap_option.current_value = 1  
- 	end  
-   
- 	if game_get_platform() ~= "PC" then  
- 	  
- 		Data[#Data + 1] = vehicle_snap_option  
- 	  
- 		Data[#Data + 1] = { 
- 			type = TYPE_TOGGLE,  
- 			label = "MENU_AIRPLANE_CONTROLS",  
- 			options = {"MENU_ADVANCED", "MENU_NORMAL"}, 
- 			id = 4,  
- 			current_value = 1  
- 		}  
- 		  
- 		if airplane_controls == 1 then  
- 			Data[#Data].current_value = 2  
- 		else  
- 			Data[#Data].current_value = 1  
- 		end  
- 	end  
-   
- 	Data[#Data + 1] = { 
- 		type = TYPE_SLIDER,  
- 		label = "CONTROLS_SENSE_V",  
- 		min = 0,  
- 		max = 100,  
- 		step = 1,  
- 		id = 5,  
- 		current_value = floor(vertical_sens * 100)  
- 	}  
-   
- 	Data[#Data + 1] = { 
- 		type = TYPE_SLIDER,  
- 		label = "CONTROLS_SENSE_H",  
- 		min = 0,  
- 		max = 100,  
- 		step = 1,  
- 		id = 6,  
- 		current_value = floor(horz_sens * 100)  
- 	}  
- 	Data[#Data + 1] = { 
- 		type = TYPE_TOGGLE,  
- 		label = "CONTROLS_FORCE_FEED",  
- 		options = {"OPTION_NO", "OPTION_YES"}, 
- 		id = 7,  
- 		current_value = 1  
- 	}  
- 	if vibration == 1 or vibration == true then  
- 		Data[#Data].current_value = 2  
- 	else  
- 		Data[#Data].current_value = 1  
- 	end  
- 	  
- 	Data[#Data + 1] = { 
- 		type = TYPE_TOGGLE,  
- 		label = "CONTROLS_CROUCH_TOGGLE",  
- 		options = {"OPTION_NO", "OPTION_YES"}, 
- 		id = 8,  
- 		current_value = 1  
- 	}  
- 	if toggle_crouch == 1 then  
- 		Data[#Data].current_value = 2  
- 	else  
- 		Data[#Data].current_value = 1  
- 	end  
-   
- 	if game_get_platform() == "PC" then  
- 		Data[#Data + 1] = vehicle_snap_option  
- 	end		  
- end  
-   
- function options_controls_nav_up(event, acceleration)  
- 	-- Move highlight up  
- 	List:move_cursor(-1)  
- end  
-   
- function options_controls_nav_down(event, acceleration)  
- 	-- Move highlight down  
- 	List:move_cursor(1)  
- end  
-   
- function options_controls_nav_left(event, acceleration)  
- 	-- Move highlight left  
- 	List:move_slider(-1)  
- 	options_controls_update_option_value()  
- end  
-   
- function options_controls_nav_right(event, acceleration)  
- 	-- Move highlight right  
- 	List:move_slider(1)  
- 	options_controls_update_option_value()  
- end  
-   
- function options_controls_update_option_value()  
- 	local current_idx = List:get_selection()  
- 	local menu_item = Data[current_idx]  
- 	  
- 	local bool_val = true  
- 	if menu_item.current_value == 1 then  
- 		bool_val = false  
- 	end  
- 	  
- 	-- Convert the value to [0.0 - 1.0]  
- 	local converted_float = menu_item.current_value  
- 	if converted_float ~= 0 then  
- 		converted_float = menu_item.current_value / 100  
- 	end  
- 	  
- 	pause_menu_update_option(PM_MENU_CONTROL_OPTIONS, menu_item.id, bool_val, converted_float)  
- end  
-   
- function options_controls_button_a(event, acceleration)  
- 	options_controls_nav_right()  
- 	  
- 	if Tween_done == true then  
- 		--set the screen data to the list data  
- 		Data = List:return_data()  
- 		  
- 		--Add current selection to the stack to store the selected position on the menu  
- 		local current_id = List:get_id()  
- 		menu_common_stack_add(current_id)  
- 			  
- 		--pass off the input to the list  
- 		List:button_a()  
- 			  
- 		if current_id == CONTROL_SCHEME_BUTTON_ID then  
- 			menu_common_transition_push("pause_ctrl_scheme") 
- 			pause_options_controls_cleanup()  
- 			return  
- 		end  
- 	end  
- end  
-   
- function options_controls_button_b(event, acceleration)  
- 	if Tween_done == true then  
- 		List:button_b()  
- 		-- save options to the profile  
- 		pause_menu_accept_options()  
-   
- 		Input_tracker:subscribe(false)  
- 		if Mouse_input_tracker ~= nil then  
- 			Mouse_input_tracker:subscribe(false)  
- 		end  
- 		List:enable_toggle_input(false)  
- 		  
- 		--Remove current menu from the stack  
- 		menu_common_stack_remove()  
- 		menu_common_transition_pop(1)  
- 	end  
- end  
-   
- function options_controls_button_x(event, acceleration)  
- 	dialog_box_confirmation("OPTIONS_MENU_DEFAULTS_TITLE", "OPTIONS_MENU_DEFAULTS_DESC", "options_controls_revert", true, true,1) 
- end  
-   
- function options_controls_revert(result, action)  
- 	if result == 0 then  
- 		pause_menu_restore_defaults(PM_MENU_CONTROL_OPTIONS)  
- 		vint_dataresponder_request("pause_menu_options", "options_controls_populate", 0, PM_MENU_CONTROL_OPTIONS)	 
- 		List:draw_items(Data, List:get_selection(), Screen_width)  
- 		if Mouse_input_tracker ~= nil then  
- 			Mouse_input_tracker:remove_all()  
- 			List:add_mouse_inputs("options_controls", Mouse_input_tracker) 
- 			Menu_hint_bar:add_mouse_inputs("options_controls", Mouse_input_tracker) 
- 			Mouse_input_tracker:subscribe(true)  
- 		end  
- 	end  
- end  
-   
- function options_controls_button_start(event, acceleration)  
- 	menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim)	  
- 	Input_tracker:subscribe(false)  
- 	if game_get_platform() == "PC" then  
- 		menu_common_transition_pop(5) --controls, mouse_controls, options, pause menu top, pause menu common  
- 	else  
- 		menu_common_transition_pop(4) --controls, options, pause menu top, pause menu common  
- 	end  
- 	bg_saints_slide_out()  
- end  
-   
- -- Mouse inputs  
- function options_controls_mouse_click(event, target_handle, mouse_x, mouse_y)  
- 	local hint_index = Menu_hint_bar:get_hint_index(target_handle)  
- 	if hint_index == 1 then  
- 		options_controls_button_b()  
- 	elseif hint_index == 2 then  
- 		options_controls_button_x()  
- 	end  
-   
- 	local new_index = List:get_button_index(target_handle)  
- 	if new_index ~= 0 then  
- 		List:set_selection(new_index)  
- 		options_controls_button_a()  
- 	end  
- 	  
- 	if List:is_left_arrow(target_handle) then  
- 		List:move_slider(-1)  
- 		options_controls_update_option_value()  
- 	elseif List:is_right_arrow(target_handle) then  
- 		List:move_slider(1)  
- 		options_controls_update_option_value()  
- 	end  
- 	if List:is_slider(target_handle) then  
- 		List:move_slider(0, mouse_x)  
- 		options_controls_update_option_value()  
- 	end  
- end  
-   
- function options_controls_mouse_move(event, target_handle)  
- 	Menu_hint_bar:set_highlight(0)  
- 	  
- 	local hint_index = Menu_hint_bar:get_hint_index(target_handle)  
- 	if hint_index ~= 0 then  
- 		Menu_hint_bar:set_highlight(hint_index)  
- 	end  
- 	  
- 	local new_index = List:get_button_index(target_handle)  
- 	if new_index ~= 0 then  
- 		List:set_selection(new_index)  
- 		List:move_cursor(0, true)  
- 	end  
- end  
-   
- function options_controls_mouse_drag(event, target_handle, mouse_x, mouse_y)  
- 	if List:is_slider(target_handle) then  
- 		List:move_slider(0, mouse_x)  
- 	end  
- end  
-   
- function options_controls_mouse_drag_release(event, target_handle, mouse_x, mouse_y)  
- 	if List:is_slider(target_handle) then  
- 		List:move_slider(0, mouse_x)  
- 		options_controls_button_a()  
- 	end  
- end  
-