local PM_MENU_DIFFICULTY_OPTIONS = 0
local DIFFICULTY_INDEX = 1
local AIRPLANE_INDEX = 2
local SUBTITLES_INDEX = 3
local RADIO_INDEX = 4
local MINIMAP_INDEX = 5
local PAUSE_FOCUS_INDEX = 6
local Data = {
[DIFFICULTY_INDEX] = {
type = TYPE_TOGGLE,
label = "MENU_DIFFICULTY",
options = {"DLT_CASUAL", "DLT_NORMAL", "DLT_HARDCORE"},
tool_tip_text = "MENU_OPTIONS_GAMEPLAY_DIFFICULTY_TIP",
current_value = 1
}
}
local Input_tracker
local Mouse_input_tracker
local Screen_width = 700
local Tween_done = true
local Difficulty_doc_handle
local Tool_tip_h
function pause_options_difficulty_set_tool_tip(new_tip_text)
vint_set_property(Tool_tip_h, "text_tag", new_tip_text)
end
function pause_options_difficulty_init()
Difficulty_doc_handle = vint_document_find("pause_options_difficulty")
Tool_tip_h = vint_object_find("tool_tip_text", 0, Difficulty_doc_handle)
if game_get_platform() ~= "PC" then
vint_set_property(Tool_tip_h, "visible", false)
else
-- Align the tooltip to the list
if In_pause_menu then
local anchor_in_h = vint_object_find("new_tween2")
local anchor_out_h = vint_object_find("new_tween4")
local anchor_in_x,anchor_in_y = vint_get_property(anchor_in_h, "start_value")
local anchor_out_x,anchor_out_y = vint_get_property(anchor_out_h, "start_value")
if vint_is_std_res() then
vint_set_property(anchor_in_h, "start_value", 282, anchor_in_y)
vint_set_property(anchor_in_h, "end_value", 282, anchor_out_y)
vint_set_property(anchor_out_h, "start_value", 282, anchor_out_y)
vint_set_property(anchor_out_h, "end_value", 282, anchor_in_y)
else
vint_set_property(anchor_in_h, "start_value", 448, anchor_in_y)
vint_set_property(anchor_in_h, "end_value", 448, anchor_out_y)
vint_set_property(anchor_out_h, "start_value", 448, anchor_out_y)
vint_set_property(anchor_out_h, "end_value", 448, anchor_in_y)
end
end
end
pause_options_difficulty_set_tool_tip(Data[1].tool_tip_text) --("X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X") -- Use this to figure out the correct anchor for In_pause_menu
-- animate tooltip in
local anim_h = vint_object_find("animate_in", 0, Difficulty_doc_handle)
lua_play_anim(anim_h, 0, Difficulty_doc_handle)
--game_peg_load_with_cb("pause_options_difficulty_finish_init", 1, "ui_cell_homies")
--game_peg_load_with_cb("options_difficulty_finish_init", 1, "ui_bms_cell_homies")
options_difficulty_finish_init()
end
function options_difficulty_add_pc_options()
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "MENU_AIRPLANE_HANDLING",
options = {"MENU_ADVANCED", "MENU_NORMAL"},
current_value = 1,
tool_tip_text = "MENU_OPTIONS_GAMEPLAY_AIRPLANE_TIP",
id = #Data
}
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "MENU_CONTROLS_SUBTITLES",
options = {"OPTION_NO", "OPTION_YES"},
current_value = 1,
tool_tip_text = "MENU_OPTIONS_GAMEPLAY_SUBTITLES_TIP",
id = #Data
}
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "MENU_AUDIO_RADIO",
options = {"RADIO_ALWAYS_ON", "RADIO_HIJACK_ON", "RADIO_LIFE_LIKE" },
current_value = 1,
tool_tip_text = "MENU_OPTIONS_GAMEPLAY_RADIO_TIP",
id = #Data
}
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "CONTROLS_MINIMAP_VIEW",
options = {"MINIMAP_ROTATIONAL", "MINIMAP_STATIC"},
current_value = 1,
tool_tip_text = "MENU_OPTIONS_GAMEPLAY_MINIMAP_TIP",
id = #Data
}
--Data[#Data].current_value = Current_static_map and 2 or 1
--Data[#Data].old_value = Data[#Data].current_value
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_PAUSE_FOCUS",
options = {"OPTION_NO", "OPTION_YES"},
current_value = 2,
tool_tip_text = "MENU_OPTIONS_GAMEPLAY_FOCUS_TIP",
id = #Data
}
end
function options_difficulty_finish_init()
--Initialize Header
if game_get_platform() == "PC" then
Header_obj:set_text("MENU_GAMEPLAY", Screen_width)
options_difficulty_add_pc_options()
else
Header_obj:set_text("MENU_DIFFICULTY", Screen_width)
end
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "options_difficulty_button_a", 50)
Input_tracker:add_input("back", "options_difficulty_button_b", 50)
if In_pause_menu then
Input_tracker:add_input("pause", "options_difficulty_button_start", 50)
end
Input_tracker:add_input("nav_up", "options_difficulty_nav_up", 50)
Input_tracker:add_input("nav_down", "options_difficulty_nav_down", 50)
Input_tracker:add_input("nav_left", "options_difficulty_nav_left", 50)
Input_tracker:add_input("nav_right", "options_difficulty_nav_right", 50)
Input_tracker:subscribe(false)
--Set Button hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
if game_get_platform() == "PC" then
hint_data[2] = {CTRL_BUTTON_X, "MENU_RESTORE_DEFAULTS"}
Input_tracker:add_input("alt_select", "options_difficulty_button_x", 50)
end
Menu_hint_bar:set_hints(hint_data)
Data[DIFFICULTY_INDEX].current_value = get_current_difficulty() + 1 -- Difficulties start at 0
vint_dataresponder_request("pause_menu_options", "options_difficulty_populate", 0, PM_MENU_DIFFICULTY_OPTIONS)
List:draw_items(Data, 1, 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_difficulty", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("options_difficulty", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
--menu_common_set_mouse_tracker(Mouse_input_tracker)
end
end
function options_difficulty_populate(airplane, subtitles, radio, minimap, pause_focus)
Data[AIRPLANE_INDEX].previous_value = Data[AIRPLANE_INDEX].current_value
Data[AIRPLANE_INDEX].current_value = airplane + 1
Data[SUBTITLES_INDEX].previous_value = Data[SUBTITLES_INDEX].current_value
Data[SUBTITLES_INDEX].current_value = subtitles and 2 or 1
Data[RADIO_INDEX].previous_value = Data[RADIO_INDEX].current_value
Data[RADIO_INDEX].current_value = radio + 1
Data[MINIMAP_INDEX].previous_value = Data[MINIMAP_INDEX].current_value
Data[MINIMAP_INDEX].current_value = minimap and 2 or 1
Data[PAUSE_FOCUS_INDEX].previous_value = Data[PAUSE_FOCUS_INDEX].current_value
Data[PAUSE_FOCUS_INDEX].current_value = pause_focus and 2 or 1
end
function pause_options_difficulty_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_difficulty_nav_up(event, acceleration)
-- Move highlight up
List:move_cursor(-1)
-- Set the tool_tip_text
local current_idx = List:get_selection()
local menu_item = Data[current_idx]
pause_options_difficulty_set_tool_tip(menu_item.tool_tip_text)
end
function options_difficulty_nav_down(event, acceleration)
-- Move highlight down
List:move_cursor(1)
-- Set the tool_tip_text
local current_idx = List:get_selection()
local menu_item = Data[current_idx]
pause_options_difficulty_set_tool_tip(menu_item.tool_tip_text)
end
function options_difficulty_nav_left(event, acceleration)
List:move_slider(-1)
options_controls_update_option_value()
end
function options_difficulty_nav_right(event, acceleration)
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
local converted_float = menu_item.current_value
pause_menu_update_option(PM_MENU_DIFFICULTY_OPTIONS, current_idx, bool_val, converted_float)
end
function options_difficulty_button_b(event, acceleration)
--back up a screen
game_difficulty_select(Data[DIFFICULTY_INDEX].current_value - 1) -- Difficulties indexed by 0
pause_menu_accept_options()
List:button_b()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
List:enable_toggle_input(false)
-- animate tooltip out
local anim_h = vint_object_find("animate_out", 0, Difficulty_doc_handle)
lua_play_anim(anim_h, 0, Difficulty_doc_handle)
--Remove current menu from the stack
menu_common_stack_remove()
menu_common_transition_pop(1)
end
function options_difficulty_button_a(event, acceleration)
options_difficulty_nav_right(event, acceleration)
end
function options_difficulty_button_x(event, acceleration)
dialog_box_confirmation("OPTIONS_MENU_DEFAULTS_TITLE", "OPTIONS_MENU_DEFAULTS_DESC", "options_difficulty_revert", true, true,1)
end
function options_difficulty_revert(result, action)
if result == 0 then
pause_menu_restore_defaults(PM_MENU_DIFFICULTY_OPTIONS)
vint_dataresponder_request("pause_menu_options", "options_difficulty_populate", 0, PM_MENU_DIFFICULTY_OPTIONS)
List:draw_items(Data, List:get_selection(), 700)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:remove_all()
List:add_mouse_inputs("options_difficulty", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("options_difficulty", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
end
function options_difficulty_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)
menu_common_transition_pop(4) -- options_difficulty, options, pause_menu_top, menu_common
bg_saints_slide_out()
end
-- Mouse inputs
function options_difficulty_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_difficulty_button_b()
end
if hint_index == 2 then
options_difficulty_button_x()
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
List:set_selection(new_index)
-- Because only toggles are used in this menu, this acts as nav_right
options_difficulty_nav_right()
end
if List:is_left_arrow(target_handle) then
List:move_slider(-1)
options_controls_update_option_value()
end
end
function options_difficulty_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)
-- Set the tool_tip_text
local current_idx = List:get_selection()
local menu_item = Data[current_idx]
pause_options_difficulty_set_tool_tip(menu_item.tool_tip_text)
end
end