local Anims = {}
local Input_tracker
local Mouse_input_tracker
local Display_pc_doc_handle
local Tween_done = true
local Exit_pending = false
local Show_dialog = true
local Confirm_dialog_h = 0
local Confirm_dialog_thread_h = -1
local ID_DISPLAY_PRESET = 0
local ID_VSYNC = 1
local ID_MINIMAP = 2
local ID_DISPLAY_IDX = 3
local ID_ASPECT = 4
local ID_RESOLUTIONS = 5
local ID_WINDOW_MODE = 6
local ID_ANTI_ALIASING = 7
local ID_TEXTURE_FILTER_MODE = 8
local ID_SCENE_DETAIL = 9
local ID_LIGHTING_DETAIL = 10
local ID_SHADOW_DETAIL = 11
local ID_REFLECTIONS = 12
local ID_POST_PROCESSING_DETAIL = 13
local ID_AMBIENT_OCCLUSION = 14
local ID_BRIGHTNESS = 15
local PRESET_INDEX = -1
local ASPECT_INDEX = -1
local RESOLUTIONS_INDEX = -1
local ANTI_ALIASING_INDEX = -1
local AMBIENT_OCCLUSION_INDEX = -1
local DX11_INDEX = -1
local Max_visible = 15
local Display_modes = {}
local MSAA_levels = {}
local Current_display_preset = 5
local Current_vsync = false
local Current_static_map = false
local Current_num_displays = 0
local Current_display_idx = 0
local Current_width = 0
local Current_height = 0
local Current_aspect_is_widescreen = false
local Current_refresh_rate = 0
local Current_display_mode_idx = 0
local Current_msaa_level = 0
local Current_fullscreen = false
local Current_texture_filter = 0
local Current_scene_detatil = 0
local Current_lighting_detatil = 0
local Current_shadow_level = 0
local Current_reflections_level = 0
local Current_post_processing_detail = 0
local Current_ambient_occlusion_level = 0
local Screen_width = 800
local Screen_id = -1
local Data = {}
local Setting_changed = false
function update_disabled()
Data[ASPECT_INDEX].disabled = In_pause_menu
local should_disable = not (Data[PRESET_INDEX].current_value == 5)
for i = ANTI_ALIASING_INDEX, AMBIENT_OCCLUSION_INDEX do
Data[i].disabled = should_disable
end
end
local function build_list()
if game_is_pc_dx11() and Current_num_displays > 1 then
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_DISPLAY_INDEX",
options = {},
tool_tip_text = "PLT_MENU_DISPLAY_INDEX_TOOLTIP",
id = ID_DISPLAY_IDX,
}
for i = 1, Current_num_displays do
Data[#Data].options[i] = "PLT_MENU_DISPLAY_"..var_to_string(i)
end
Data[#Data].disabled = Current_num_displays < 2
Data[#Data].current_value = Current_display_idx + 1
Data[#Data].old_value = Data[#Data].current_value
end
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_ASPECT",
options = {"PLT_MENU_WIDESCREEN", "PLT_MENU_STANDARD"},
tool_tip_text = "PLT_MENU_ASPECT_TOOLTIP",
id = ID_ASPECT
}
ASPECT_INDEX = #Data
Data[ASPECT_INDEX].disabled = In_pause_menu -- disable if in gameplay
Data[ASPECT_INDEX].current_value = Current_aspect_is_widescreen and 1 or 2
Data[ASPECT_INDEX].old_value = Data[ASPECT_INDEX].current_values
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_RESOLUTIONS",
options = {},
tool_tip_text = "PLT_MENU_RESOLUTIONS_TOOLTIP",
id = ID_RESOLUTIONS,
}
RESOLUTIONS_INDEX = #Data
Data[RESOLUTIONS_INDEX].current_value = -1
populate_display_modes(Current_display_idx, Current_aspect_is_widescreen)
Data[RESOLUTIONS_INDEX].old_value = Data[RESOLUTIONS_INDEX].current_value
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_DISPLAY_MODE",
options = {"PLT_MENU_FULL_SCREEN", "PLT_MENU_WINDOWED"},
tool_tip_text = "PLT_MENU_DISPLAY_MODE_TOOLTIP",
id = ID_WINDOW_MODE,
}
Data[#Data].current_value = Current_fullscreen and 1 or 2
Data[#Data].old_value = Data[#Data].current_value
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_DISPLAY_PRESET",
options = {"MENU_LOW", "MENU_MEDIUM", "MENU_HIGH", "MENU_ULTRA", "MENU_CUSTOM"},
tool_tip_text = "PLT_MENU_DISPLAY_PRESET_TOOLTIP",
id = ID_DISPLAY_PRESET
}
PRESET_INDEX = #Data
Data[#Data].current_value = Current_display_preset
Data[#Data].old_value = Data[#Data].current_value
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_ANTI_ALIASING",
options = {},
tool_tip_text = "PLT_MENU_ANTI_ALIASING_TOOLTIP",
id = ID_ANTI_ALIASING,
}
ANTI_ALIASING_INDEX = #Data
populate_anti_aliasing_levels(Current_display_idx)
Data[ANTI_ALIASING_INDEX].current_value = 1
for i, msaa_level in pairs (MSAA_levels) do
if Current_msaa_level == msaa_level.level then
Data[ANTI_ALIASING_INDEX].current_value = i
Data[ANTI_ALIASING_INDEX].old_value = Data[ANTI_ALIASING_INDEX].current_value
end
end
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_TEXTURE_FILTER_MODE",
options = {"PLT_TRILINEAR", "PLT_ANISOTROPIC_TWO", "PLT_ANISOTROPIC_FOUR", "PLT_ANISOTROPIC_EIGHT", "PLT_ANISOTROPIC_SIXTEEN"},
tool_tip_text = "PLT_MENU_TEXTURE_FILTER_MODE_TOOLTIP",
id = ID_TEXTURE_FILTER_MODE,
}
Data[#Data].current_value = Current_texture_filter
Data[#Data].old_value = Data[#Data].current_value
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_SCENE_DETAIL",
options = {"MENU_LOW", "MENU_MEDIUM", "MENU_HIGH"},
tool_tip_text = "PLT_MENU_SCENE_DETAIL_TOOLTIP",
id = ID_SCENE_DETAIL,
}
Data[#Data].current_value = Current_scene_detatil
Data[#Data].old_value = Data[#Data].current_value
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_LIGHTING_DETAIL",
options = {"MENU_LOW", "MENU_HIGH"},
tool_tip_text = "PLT_MENU_LIGHTING_DETAIL_TOOLTIP",
id = ID_LIGHTING_DETAIL,
}
Data[#Data].current_value = Current_lighting_detatil
Data[#Data].old_value = Data[#Data].current_value
if Current_lighting_detatil == 3 then
Data[#Data].options[3] = "MENU_ULTRA"
end
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_SHADOW_DETAIL",
options = {"MENU_OFF", "MENU_LOW", "MENU_MEDIUM", "MENU_HIGH"},
tool_tip_text = "PLT_MENU_SHADOW_DETAIL_TOOLTIP",
id = ID_SHADOW_DETAIL,
}
Data[#Data].current_value = Current_shadow_level
Data[#Data].old_value = Data[#Data].current_value
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_REFLECTIONS",
options = {"MENU_OFF", "MENU_LOW", "PLT_MENU_HIGH_DX10_ONLY"},
tool_tip_text = "PLT_MENU_REFLECTIONS_TOOLTIP",
id = ID_REFLECTIONS,
}
Data[#Data].current_value = Current_reflections_level
Data[#Data].old_value = Data[#Data].current_value
DX11_INDEX = #Data
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_POST_PROCESSING_DETAIL",
options = {"MENU_OFF", "MENU_LOW", "PLT_MENU_HIGH_DX10_ONLY"},
tool_tip_text = "PLT_MENU_POST_PROCESSING_DETAIL_TOOLTIP",
id = ID_POST_PROCESSING_DETAIL,
}
Data[#Data].current_value = Current_post_processing_detail
Data[#Data].old_value = Data[#Data].current_value
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_AMBIENT_OCCLUSION",
options = {"MENU_OFF", "MENU_LOW", "PLT_MENU_MED_DX10_ONLY", "PLT_MENU_HIGH_DX10_ONLY"},
tool_tip_text = "PLT_MENU_AMBIENT_OCCLUSION_TOOLTIP",
id = ID_AMBIENT_OCCLUSION,
}
AMBIENT_OCCLUSION_INDEX = #Data
Data[#Data].current_value = Current_ambient_occlusion_level
Data[#Data].old_value = Data[#Data].current_value
Data[#Data + 1] = {
type = TYPE_TOGGLE,
label = "PLT_MENU_VSYNC",
options = {"OPTION_NO", "OPTION_YES"},
tool_tip_text = "PLT_MENU_VSYNC_TOOLTIP",
id = ID_VSYNC
}
Data[#Data].current_value = Current_vsync and 2 or 1
Data[#Data].old_value = Data[#Data].current_value
Data[#Data + 1] = {
type = TYPE_BUTTON,
label = "MENU_DISPLAY_BRIGHTNESS",
tool_tip_text = "PLT_MENU_BRIGHTNESS_TOOLTIP",
id = ID_BRIGHTNESS
}
update_disabled()
List:set_properties(nil, nil, nil, nil, nil, nil, true)
List:draw_items(Data, 1, Screen_width, Max_visible)
end
function enforce_dx9()
if game_is_pc_dx11() then
return
end
local changed = false
if List:get_data_from_id(ID_REFLECTIONS).current_value == 3 then
Data[DX11_INDEX + 0].current_value = 2
changed = true
end
if List:get_data_from_id(ID_POST_PROCESSING_DETAIL).current_value == 3 then
Data[DX11_INDEX + 1].current_value = 2
changed = true
end
if List:get_data_from_id(ID_AMBIENT_OCCLUSION).current_value > 2 then
Data[DX11_INDEX + 2].current_value = 2
changed = true
end
if changed then
local idx = List.visible_start_idx
List:draw_items(Data, List:get_selection(), Screen_width, Max_visible)
-- Recreate mouse input tracking
Mouse_input_tracker:remove_all()
List:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
function populate_display_modes(display_idx, widescreen)
local orig_w = Current_width
local orig_h = Current_height
if Display_modes[Data[RESOLUTIONS_INDEX].current_value] ~= nil then
orig_w = Display_modes[Data[RESOLUTIONS_INDEX].current_value].width
orig_h = Display_modes[Data[RESOLUTIONS_INDEX].current_value].height
end
Data[RESOLUTIONS_INDEX].options = {}
Display_modes = {}
vint_dataresponder_request("options_display_populate_display_modes", "options_display_populate_display_modes", 0, display_idx, widescreen)
-- Add all the display modes to the list.
local best_mode_w = 100000;
local best_mode_h = 100000;
for i, mode in pairs (Display_modes) do
Data[RESOLUTIONS_INDEX].options[i] = var_to_string(mode.width).." x "..var_to_string(mode.height)
-- See if this is the closest mode to our current.
local diff_w = abs(mode.width - orig_w)
local diff_h = abs(mode.height - orig_h)
if diff_w <= best_mode_w and diff_h <= best_mode_h then
-- If so, select it.
Data[RESOLUTIONS_INDEX].current_value = i
best_mode_w = diff_w
best_mode_h = diff_h
end
end
-- If we didn't add any, just add the current mode. It'll get grayed out below.
if #Data[RESOLUTIONS_INDEX].options == 0 then
Data[RESOLUTIONS_INDEX].options[1] = var_to_string(Current_width).." x "..var_to_string(Current_height)
Data[RESOLUTIONS_INDEX].current_value = 1
end
-- Set the disabled state of the resolutions, depending on if there are more resolutions to choose from
Data[RESOLUTIONS_INDEX].disabled = #Display_modes < 2
end
function options_display_populate_display_modes(width, height, refresh_rate, display_mode_idx)
local num_modes = #Display_modes + 1
Display_modes[num_modes] = {}
Display_modes[num_modes].width = width
Display_modes[num_modes].height = height
Display_modes[num_modes].refresh_rate = refresh_rate
Display_modes[num_modes].display_mode_idx = display_mode_idx
end
function populate_anti_aliasing_levels(display_idx)
MSAA_levels = {}
vint_dataresponder_request("options_display_populate_msaa", "options_display_populate_msaa", 0, display_idx)
for idx, msaa_level in pairs(MSAA_levels) do
if msaa_level.level == 0 or msaa_level.level == 1 then
-- MSAA level 1 is in DirectX 11
Data[ANTI_ALIASING_INDEX].options[idx] = "MENU_OFF"
else
Data[ANTI_ALIASING_INDEX].options[idx] = var_to_string(msaa_level.level).."X MSAA"
end
end
-- Set the disabled state of the anti aliasing option, depending on if there are more msaa levels to choose from
Data[ANTI_ALIASING_INDEX].disabled = #MSAA_levels < 2
end
function options_display_populate_msaa(level)
local num_msaa_levels = #MSAA_levels + 1
MSAA_levels[num_msaa_levels] = {}
MSAA_levels[num_msaa_levels].level = level
end
function options_display_populate_current_settings(preset, vsync, static_map, num_displays, display_idx, width, height, is_widescreen, refresh_rate, display_mode_idx, current_msaa, fullscreen,
current_texture_filter, current_scene_detail, current_lighting_detatil, current_shadow_level, current_reflections_level, post_processing_detail, current_ambient_occlusion_level)
Current_display_preset = preset
Current_vsync = vsync
--Current_static_map = static_map
Current_num_displays = num_displays
Current_display_idx = display_idx
Current_width = width
Current_height = height
Current_aspect_is_widescreen = is_widescreen
Current_refresh_rate = refresh_rate
Current_display_mode_idx = display_mode_idx
Current_msaa_level = current_msaa
Current_fullscreen = fullscreen
Current_texture_filter = current_texture_filter
Current_scene_detatil = current_scene_detail
Current_lighting_detatil = current_lighting_detatil
Current_shadow_level = current_shadow_level
Current_reflections_level = current_reflections_level
Current_post_processing_detail = post_processing_detail
Current_ambient_occlusion_level = current_ambient_occlusion_level
end
function pause_options_display_pc_init()
Display_pc_doc_handle = vint_document_find("pause_options_display_pc")
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "options_display_button_a", 50)
Input_tracker:add_input("back", "options_display_button_b", 50)
Input_tracker:add_input("alt_select", "options_display_button_x", 50)
if In_pause_menu then
Input_tracker:add_input("pause", "options_display_button_start", 50)
end
Input_tracker:add_input("nav_up", "options_display_nav_up", 50)
Input_tracker:add_input("nav_down", "options_display_nav_down", 50)
Input_tracker:add_input("nav_left", "options_display_nav_left", 50)
Input_tracker:add_input("nav_right", "options_display_nav_right", 50)
Input_tracker:add_input("scancode", "options_display_apply", 50, false, 60) --'F2' key
Input_tracker:add_input("gamepad_y", "options_display_apply", 50)
Input_tracker:subscribe(false)
--Set Button hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
{CTRL_BUTTON_X, "PLT_MENU_AUTO_DETECT"},
{CTRL_BUTTON_Y, "PLT_MENU_APPLY", "F2"},
}
Menu_hint_bar:set_hints(hint_data)
Header_obj:set_text("MENU_DISPLAY_TITLE")
vint_dataresponder_request("options_display_populate_current_settings", "options_display_populate_current_settings", 0)
build_list()
--set up the list in twns
local list_back_in = Vdo_tween_object:new("back_in_twn2", Screen_back_in_anim.handle)
local header_back_in = Vdo_tween_object:new("back_in_twn3", Screen_back_in_anim.handle)
list_back_in:set_property("start_value", 1000, 80)
header_back_in:set_property("start_value", 1000, 40)
list_back_in:set_property("end_value", 100, 80)
header_back_in:set_property("end_value", 130, 40)
--set up the list out twns
local list_slide_out = Vdo_tween_object:new("screen_slide_out_twn2", Screen_slide_out_anim.handle)
local header_slide_out = Vdo_tween_object:new("screen_slide_out_twn3", Screen_slide_out_anim.handle)
list_slide_out:set_property("start_value", 100, 80)
header_slide_out:set_property("start_value", 130, 40)
list_slide_out:set_property("end_value", 1000, 80)
header_slide_out:set_property("end_value", 1000, 40)
local list_slide_in = Vdo_tween_object:new("screen_slide_in_twn2", Screen_slide_in_anim.handle)
local header_slide_in = Vdo_tween_object:new("screen_slide_in_twn3", Screen_slide_in_anim.handle)
list_slide_in:set_property("start_value", -200, 80)
header_slide_in:set_property("start_value", -200, 40)
list_slide_in:set_property("end_value", 100, 80)
header_slide_in:set_property("end_value", 130, 40)
--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
Menu_hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
List:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
-- 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
-- animate tooltip in
local anim_h = vint_object_find("animate_in", 0, Display_pc_doc_handle)
lua_play_anim(anim_h, 0, Display_pc_doc_handle)
pause_options_display_pc_set_tool_tip(Data[1].tool_tip_text) --("X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X") -- Use this to figure out the correct anchor for In_pause_menu
--menu_common_set_mouse_tracker(Mouse_input_tracker)
end
function pause_options_display_pc_reset()
if Exit_pending then
return
end
Mouse_input_tracker:remove_all()
local resolution_index = -1
-- Rebuild the list
if Data[ASPECT_INDEX] ~= nil then
Current_aspect_is_widescreen = Data[ASPECT_INDEX].current_value == 1
end
if Data[RESOLUTIONS_INDEX] ~= nil then
resolution_index = Data[RESOLUTIONS_INDEX].current_value
end
Data = {}
build_list()
if resolution_index ~= -1 then
Data[RESOLUTIONS_INDEX].current_value = resolution_index
List:set_properties(nil, nil, nil, nil, nil, nil, true)
List:draw_items(Data, 1, Screen_width, Max_visible)
end
pause_options_display_pc_set_tool_tip(Data[1].tool_tip_text)
--set up the list in twns
local list_back_in = Vdo_tween_object:new("back_in_twn2", Screen_back_in_anim.handle)
local header_back_in = Vdo_tween_object:new("back_in_twn3", Screen_back_in_anim.handle)
list_back_in:set_property("start_value", 1000, 80)
header_back_in:set_property("start_value", 1000, 40)
list_back_in:set_property("end_value", 100, 80)
header_back_in:set_property("end_value", 130, 40)
--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)
-- Recreate mouse input tracking
List:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
function pause_options_display_pc_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)
--set up the list in twns
local list_back_in = Vdo_tween_object:new("back_in_twn2", Screen_back_in_anim.handle)
local header_back_in = Vdo_tween_object:new("back_in_twn3", Screen_back_in_anim.handle)
--set up the list out twns
local list_slide_out = Vdo_tween_object:new("screen_slide_out_twn2", Screen_slide_out_anim.handle)
local header_slide_out = Vdo_tween_object:new("screen_slide_out_twn3", Screen_slide_out_anim.handle)
local list_slide_in = Vdo_tween_object:new("screen_slide_in_twn2", Screen_slide_in_anim.handle)
local header_slide_in = Vdo_tween_object:new("screen_slide_in_twn3", Screen_slide_in_anim.handle)
local list_back_out = Vdo_tween_object:new("back_out_twn3", Screen_back_out_anim.handle)
local header_back_out = Vdo_tween_object:new("back_out_twn2", Screen_back_out_anim.handle)
list_back_in:set_property("start_value", 1000, 267)
header_back_in:set_property("start_value", 1000, 230)
list_back_in:set_property("end_value", 100, 267)
header_back_in:set_property("end_value", 130, 230)
list_slide_out:set_property("start_value", 100, 267)
header_slide_out:set_property("start_value", 130, 230)
list_slide_out:set_property("end_value", 1000, 267)
header_slide_out:set_property("end_value", 1000, 230)
list_slide_in:set_property("start_value", -200, 267)
header_slide_in:set_property("start_value", -200, 230)
list_slide_in:set_property("end_value", 100, 267)
header_slide_in:set_property("end_value", 130, 230)
local current_id = List:get_id()
if Screen_id ~= ID_BRIGHTNESS then
list_back_out:set_property("start_value", 100, 267)
header_back_out:set_property("start_value", 130, 230)
list_back_out:set_property("end_value", -300, 267)
header_back_out:set_property("end_value", -300, 230)
end
end
function options_display_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_display_pc_set_tool_tip(menu_item.tool_tip_text)
enforce_dx9()
end
function options_display_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_display_pc_set_tool_tip(menu_item.tool_tip_text)
enforce_dx9()
end
function options_display_nav_left_or_right(direction)
local current_idx = List:get_selection()
local menu_item = Data[current_idx]
if menu_item.type == TYPE_SLIDER or menu_item.type == TYPE_TOGGLE then
-- Move highlight left
List:move_slider(direction)
end
local refresh_list = false
if menu_item.id == ID_ASPECT then
local display_idx = List:get_data_from_id(ID_DISPLAY_IDX) ~= nil and List:get_data_from_id(ID_DISPLAY_IDX).current_value - 1 or Current_display_idx
local widescreen = List:get_data_from_id(ID_ASPECT).current_value == 1
populate_display_modes(display_idx, widescreen)
Data[RESOLUTIONS_INDEX].current_value = 1
refresh_list = true
end
if menu_item.id == ID_DISPLAY_IDX then
local display_idx = List:get_data_from_id(ID_DISPLAY_IDX).current_value - 1
local widescreen = List:get_data_from_id(ID_ASPECT).current_value == 1
populate_display_modes(display_idx, widescreen)
populate_anti_aliasing_levels(display_idx)
Data[RESOLUTIONS_INDEX].current_value = min(#Data[RESOLUTIONS_INDEX].options, Data[RESOLUTIONS_INDEX].current_value)
Data[ANTI_ALIASING_INDEX].current_value = min(#Data[ANTI_ALIASING_INDEX].options, Data[ANTI_ALIASING_INDEX].current_value)
update_disabled()
refresh_list = true
end
if menu_item.id == ID_DISPLAY_PRESET then
-- Apply the presets
vint_dataresponder_request("options_display_pc_set_preset", "options_display_populate_current_settings", 1, Data[PRESET_INDEX].current_value)
Current_display_preset = Data[PRESET_INDEX].current_value
Data = {}
build_list()
refresh_list = true
end
Setting_changed = true
Menu_hint_bar:set_visible(true)
if refresh_list then
-- Redraw the items
List:draw_items(Data, current_idx, Screen_width, Max_visible)
-- Recreate mouse input tracking
Mouse_input_tracker:remove_all()
List:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
function options_display_nav_left(event, acceleration)
options_display_nav_left_or_right(-1)
end
function options_display_nav_right(event, acceleration)
options_display_nav_left_or_right(1)
end
function options_display_confirm(result, action)
debug_print("vint", "result: "..result)
if Confirm_dialog_thread_h ~= -1 then
thread_kill(Confirm_dialog_thread_h)
Confirm_dialog_thread_h = -1
end
Confirm_dialog_h = 0
if result == 0 then -- Changes accepted.
if Exit_pending then -- If we're waiting to leave the screen.
pause_options_display_pc_cleanup()
--Remove current menu from the stack
menu_common_stack_remove()
menu_common_transition_pop(1)
else
-- Recreate mouse input tracking
Mouse_input_tracker:remove_all()
List:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
else -- Canceled changes.
-- Reread the settings and rebuild the list.
Mouse_input_tracker:remove_all()
vint_dataresponder_request("options_display_populate_current_settings", "options_display_populate_current_settings", 0)
Data = { }
build_list()
-- Recreate mouse input tracking
List:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
-- Reapply the old settings and make sure we don't leave the screen.
Show_dialog = false
Exit_pending = false
options_display_update_option_value()
end
end
function options_display_confirm_dialog_process()
local destruct_timer_start = vint_get_time_index()
local done = false
while not done do
thread_yield()
--debug_print("vint","timer: "..var_to_string(vint_get_time_index()).."\n")
--debug_print("vint","timer start "..destruct_timer_start.."\n")
if vint_get_time_index() > destruct_timer_start + 15 then
debug_print("vint","timer up\n")
done = true
dialog_box_force_close(Confirm_dialog_h)
end
end
Confirm_dialog_thread_h = -1
end
function options_display_update_option_value()
local vsync = List:get_data_from_id(ID_VSYNC).current_value == 2
local display_idx = List:get_data_from_id(ID_DISPLAY_IDX) ~= nil and List:get_data_from_id(ID_DISPLAY_IDX).current_value - 1 or Current_display_idx
local display_mode_selected_index = List:get_data_from_id(ID_RESOLUTIONS).current_value
local display_mode_idx = Display_modes[display_mode_selected_index].display_mode_idx
local fullscreen = List:get_data_from_id(ID_WINDOW_MODE).current_value == 1
local msaa_index = List:get_data_from_id(ID_ANTI_ALIASING).current_value
local msaa_level = MSAA_levels[msaa_index].level
local texture_filter = List:get_data_from_id(ID_TEXTURE_FILTER_MODE).current_value
local scene_detail = List:get_data_from_id(ID_SCENE_DETAIL).current_value
local lighting_detail = List:get_data_from_id(ID_LIGHTING_DETAIL).current_value
local shadow_detail = List:get_data_from_id(ID_SHADOW_DETAIL).current_value
local scene_detail = List:get_data_from_id(ID_SCENE_DETAIL).current_value
local reflections = List:get_data_from_id(ID_REFLECTIONS).current_value
local post_processing_detail = List:get_data_from_id(ID_POST_PROCESSING_DETAIL).current_value
local ambient_occlusion_level = List:get_data_from_id(ID_AMBIENT_OCCLUSION).current_value
options_display_pc_set_options( vsync, display_idx, display_mode_idx, fullscreen, msaa_level, texture_filter,
lighting_detail, shadow_detail, scene_detail, reflections, post_processing_detail, ambient_occlusion_level)
Setting_changed = false
options_display_change_resolution()
end
function options_display_change_resolution()
thread_new("options_display_change_resolution_cb")
end
function options_display_change_resolution_cb()
delay(0.1)
if Show_dialog then
local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" }
Confirm_dialog_h = dialog_box_open("PLT_MENU_DISPLAY_OPTIONS_CONFIRM", "PLT_MENU_DISPLAY_OPTIONS_CONFIRM_TEXT", options, "options_display_confirm", 1, DIALOG_PRIORITY_ACTION, true)
Confirm_dialog_thread_h = thread_new("options_display_confirm_dialog_process")
else
Show_dialog = true
end
end
function options_display_button_a(event, acceleration)
local current_id = List:get_id()
if Tween_done == true then
options_display_nav_right()
List:button_a()
Screen_id = -1
if current_id == ID_BRIGHTNESS then
local list_back_out = Vdo_tween_object:new("back_out_twn3", Screen_back_out_anim.handle)
local header_back_out = Vdo_tween_object:new("back_out_twn2", Screen_back_out_anim.handle)
list_back_out:set_property("start_value", 100, 80)
header_back_out:set_property("start_value", 130, 40)
list_back_out:set_property("end_value", -550, 80)
header_back_out:set_property("end_value", -550, 40)
Screen_id = ID_BRIGHTNESS
-- animate tooltip in
local anim_h = vint_object_find("animate_out", 0, Display_pc_doc_handle)
lua_play_anim(anim_h, 0, Display_pc_doc_handle)
menu_common_transition_push("pause_options_display_cal")
pause_options_display_pc_cleanup()
end
end
end
function options_display_apply(event, acceleration)
local current_id = List:get_id()
if Tween_done == true then
if Setting_changed then
Exit_pending = false
options_display_update_option_value()
end
end
end
function options_display_accept_cancel(result, action)
if result ~= 2 then
List:button_b()
if result == 0 then
Exit_pending = true
options_display_update_option_value()
else
pause_options_display_pc_cleanup()
--set up the list out twns
local list_slide_out = Vdo_tween_object:new("screen_slide_out_twn2", Screen_slide_out_anim.handle)
local header_slide_out = Vdo_tween_object:new("screen_slide_out_twn3", Screen_slide_out_anim.handle)
list_slide_out:set_property("start_value", 100, 80)
header_slide_out:set_property("start_value", 130, 40)
list_slide_out:set_property("end_value", 1000, 80)
header_slide_out:set_property("end_value", 1000, 40)
-- animate tooltip in
local anim_h = vint_object_find("animate_out", 0, Display_pc_doc_handle)
lua_play_anim(anim_h, 0, Display_pc_doc_handle)
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
end
function options_display_button_b(event, acceleration)
if Tween_done == true then
if Setting_changed then
local options = { "PLT_MENU_APPLY", "MENU_DISCARD", "CONTROL_CANCEL" }
dialog_box_open("MENU_CHANGES_MADE_TITLE", "MENU_CHANGES_MADE_BODY", options, "options_display_accept_cancel", 2, DIALOG_PRIORITY_SYSTEM_CRITICAL, false, nil, false, false, nil, 2)
else
options_display_accept_cancel(1)
end
end
end
function options_display_button_x(event, acceleration)
dialog_box_confirmation("OPTIONS_MENU_DEFAULTS_TITLE", "OPTIONS_MENU_AUTO_DETECT_DESC", "options_display_revert", true, true,1)
end
function options_display_revert(result, action)
if result == 0 then
Setting_changed = true
Mouse_input_tracker:remove_all()
vint_dataresponder_request("options_display_pc_restore_defaults", "options_display_populate_current_settings", 0)
-- Rebuild the list
Data = {}
build_list()
-- Recreate mouse input tracking
List:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
function options_display_button_start(event, acceleration)
if Tween_done == true then
-- we still want to save the options?
pause_menu_accept_options()
menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim)
Input_tracker:subscribe(false)
-- stack is part of common, which is getting popped, so we don't update it.
menu_common_transition_pop(4) -- options_display, options_menu, pause_menu_top, menu_common
bg_saints_slide_out()
end
end
-- Mouse inputs
function pause_options_display_pc_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_display_button_b()
elseif hint_index == 2 then
options_display_button_x()
elseif hint_index == 3 then
options_display_apply()
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
options_display_button_a()
elseif List:is_left_arrow(target_handle) then
options_display_nav_left()
elseif List:is_right_arrow(target_handle) then
options_display_nav_right()
end
if new_index == ID_BRIGHTNESS then
Screen_id = ID_BRIGHTNESS
else
Screen_id = -1
end
end
function pause_options_display_pc_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)
enforce_dx9()
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 menu_item = Data[new_index]
pause_options_display_pc_set_tool_tip(menu_item.tool_tip_text)
enforce_dx9()
end
end
function pause_options_display_pc_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines)
if scroll_lines ~= 0 then
if List:get_scroll_region_handle() == target_handle then
List:scroll_list(scroll_lines * -1)
List:update_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
end
function pause_options_display_pc_mouse_drag(event, target_handle, mouse_x, mouse_y)
if List.scrollbar.tab.handle == target_handle then
local new_start_index = List.scrollbar:drag_scrolltab(mouse_y, List.num_buttons - (List.max_buttons - 1))
List:scroll_list(0, new_start_index)
end
end
-- Updates the mouse inputs for the list and snaps the scrolltab to the closest notch based on the visible index
--
function pause_options_display_pc_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
if List.scrollbar.tab.handle == target_handle then
local start_index = List:get_visible_indices()
List.scrollbar:release_scrolltab(start_index, List.num_buttons - (List.max_buttons - 1))
List:update_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
function pause_options_display_pc_set_tool_tip(new_tip_text)
local tool_tip_h = vint_object_find("tool_tip_text", 0, Display_pc_doc_handle)
vint_set_property(tool_tip_h, "text_tag", new_tip_text)
end
function display_mode_change_failure_callback()
-- Recreate mouse input tracking
Mouse_input_tracker:remove_all()
List:add_mouse_input("pause_options_display_pc", Mouse_input_tracker)
Hint_bar:add_mouse_input("pause_options_display_pc", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end