local CONTROLS_INDEX = 1
local CONTROL_CONFIG_INDEX = 2
local DIFFICULTY_INDEX = 3
local DISPLAY_INDEX = 4
local AUDIO_INDEX = 5
local REMAP_INDEX = 6
local MOUSE_INDEX = 7
local ID_CONTROLS = 1
local ID_CONTROL_CONFIG = 2
local ID_DIFFICULTY = 3
local ID_DISPLAY = 4
local ID_AUDIO = 5
local ID_REMAP = 6
local ID_MOUSE = 7
local Data = { }
function option_menu_init_data ()
Data = { }
if game_get_platform() == "PC" then
CONTROLS_INDEX = -1
CONTROL_CONFIG_INDEX = -1
Data[#Data + 1] = {
type = TYPE_BUTTON,
label = "MENU_OPTIONS_MOUSE",
id = ID_MOUSE
}
MOUSE_INDEX = #Data
REMAP_INDEX = -1
else
Data[#Data + 1] = {
type = TYPE_BUTTON,
label = "MENU_CONTROL_OPTIONS",
id = ID_CONTROLS,
}
CONTROLS_INDEX = #Data
Data[#Data + 1] = {
type = TYPE_BUTTON,
label = "MENU_CONTROL_SCHEMES",
id = ID_CONTROL_CONFIG,
}
CONTROL_CONFIG_INDEX = #Data
end
local diff_label = "MENU_DIFFICULTY"
if game_get_platform() == "PC" then
diff_label = "MENU_GAMEPLAY"
end
Data[#Data + 1] = {
type = TYPE_BUTTON,
label = diff_label,
id = ID_DIFFICULTY,
}
DIFFICULTY_INDEX = #Data
Data[#Data + 1] = {
type = TYPE_BUTTON,
label = "MENU_OPTIONS_DISPLAY",
id = ID_DISPLAY,
}
DISPLAY_INDEX = #Data
Data[#Data + 1] = {
type = TYPE_BUTTON,
label = "MENU_OPTIONS_AUDIO",
id = ID_AUDIO,
}
AUDIO_INDEX = #Data
end
local Anims = {}
local Input_tracker
local Mouse_input_tracker
local Screen_width = 495
local Tween_done = true
---------------------------------------------------------------------------
-- Initialize Pause Options Menu.
---------------------------------------------------------------------------
function pause_options_menu_init()
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "options_menu_button_a", 50)
Input_tracker:add_input("back", "options_menu_button_b", 50)
Input_tracker:add_input("nav_up", "options_menu_nav_up", 50)
Input_tracker:add_input("nav_down", "options_menu_nav_down", 50)
Input_tracker:add_input("nav_left", "options_menu_nav_left", 50)
Input_tracker:add_input("nav_right", "options_menu_nav_right", 50)
if In_pause_menu then
Input_tracker:add_input("pause", "options_menu_button_start", 50)
end
Input_tracker:subscribe(false)
--Initialize Header
Header_obj:set_text("MENU_OPTIONS_TITLE")
--Setup Button Hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Menu_hint_bar:set_hints(hint_data)
-- Initialize the list object and draw
option_menu_init_data()
--Get the selection option from when the menu was last loaded
local last_option_selected = menu_common_stack_get_index(Data)
--Draw items...
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)
bg_saints_show(true)
menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim)
if not In_pause_menu then
main_menu_logo_hide()
if First_time then
Screen_in_anim:play(0)
bg_saints_slide_in(Screen_width)
First_time = false
end
end
-- 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_menu", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("options_menu", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
--menu_common_set_mouse_tracker(Mouse_input_tracker)
end
end
function pause_options_menu_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_menu_nav_up(event, acceleration)
-- Move highlight up
List:move_cursor(-1)
end
function options_menu_nav_down(event, acceleration)
-- Move highlight down
List:move_cursor(1)
end
function options_menu_nav_left(event, acceleration)
-- Move highlight left
List:move_slider(-1)
end
function options_menu_nav_right(event, acceleration)
-- Move highlight right
List:move_slider(1)
end
function options_menu_button_a(event, acceleration)
if Tween_done == true then
--Set the screen data to the list data
Data = List:return_data()
local current_id = List:get_id()
--Add current selection to the stack to store the selected position on the menu
menu_common_stack_add(current_id)
--pass off the input to the list
List:button_a()
if current_id == ID_CONTROLS then
menu_common_transition_push("pause_options_controls")
return
elseif current_id == ID_CONTROL_CONFIG then
menu_common_transition_push("pause_ctrl_scheme")
return
elseif current_id == ID_DIFFICULTY then
menu_common_transition_push("pause_options_difficulty")
return
elseif current_id == ID_DISPLAY then
if game_get_platform() == "PC" then
menu_common_transition_push("pause_options_display_pc")
else
menu_common_transition_push("pause_options_display")
end
return
elseif current_id == ID_AUDIO then
menu_common_transition_push("pause_options_audio")
return
elseif current_id == ID_REMAP then
menu_common_transition_push("pause_options_remap")
return
elseif current_id == ID_MOUSE then
menu_common_transition_push("pause_options_mouse")
return
end
end
end
function options_menu_button_b(event, acceleration)
if Tween_done == true then
List:button_b()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
--Remove current menu from the stack
menu_common_stack_remove()
--Pop Screen off the list
menu_common_transition_pop(1)
end
end
function options_menu_button_start(event, acceleration)
if Tween_done == true then
menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim)
Input_tracker:subscribe(false)
menu_common_transition_pop(3) -- options, pause_menu_top, pause_menu_top
bg_saints_slide_out()
end
end
function options_menu_mouse_click(event, target_handle)
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
options_menu_button_b()
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
List:set_selection(new_index)
options_menu_button_a()
end
end
function options_menu_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