iw6-lui/lui/mp_hud/ingameadvancedvideo.dec.lua
2024-09-12 17:25:45 +02:00

733 lines
18 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function BackButtonAction( f1_arg0, f1_arg1 )
local f1_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f1_arg0 )
f1_arg0:dispatchEventToRoot( {
name = "check_show_apply",
immediate = true
} )
if f1_local0.showApplySettings then
if Engine.ShowLowTextureResolutionWarning() then
if f1_local0.vidRestart then
LUI.FlowManager.RequestPopupMenu( f1_arg0, "show_low_texture_res_warning_restart_popmenu", false, f1_arg1.controller, false )
else
LUI.FlowManager.RequestPopupMenu( f1_arg0, "show_low_texture_res_warning_popmenu", false, f1_arg1.controller, false )
end
elseif f1_local0.vidRestart then
LUI.FlowManager.RequestPopupMenu( f1_arg0, "apply_settings_restart_popmenu", false, f1_arg1.controller, false )
else
LUI.FlowManager.RequestPopupMenu( f1_arg0, "apply_settings_popmenu", false, f1_arg1.controller, false )
end
end
LUI.FlowManager.RequestLeaveMenu( f1_arg0 )
end
function InGameDisabledFunc( f2_arg0, f2_arg1 )
return not Engine.CanVidRestart()
end
function PicmipDisabledFunc()
local f3_local0 = InGameDisabledFunc()
if not f3_local0 then
f3_local0 = Engine.GetDvarInt( "ui_r_picmip_manual" ) == 0
end
return f3_local0
end
f0_local0 = nil
function NVidiaButtonOver( f4_arg0, f4_arg1 )
f0_local0 = f4_arg0.id
f4_arg0:dispatchEventToRoot( {
name = "show_nvidia_subtitle",
immediate = true
} )
end
function NVidiaButtonUp( f5_arg0, f5_arg1 )
if f0_local0 == f5_arg0.id then
f0_local0 = nil
f5_arg0:dispatchEventToRoot( {
name = "hide_nvidia_subtitle",
immediate = true
} )
end
end
function OptionsWindowRefresh( f6_arg0, f6_arg1 )
if f6_arg1.source_input == "button_action" or f6_arg1.source_input == "key_bound" or f6_arg1.source_input == "button_right" or f6_arg1.source_input == "button_left" then
f6_arg0:processEvent( {
name = "menu_refresh"
} )
f6_arg0:processEvent( {
name = "refresh_content"
} )
end
end
function OptionsWindowTriggerRefresh( f7_arg0, f7_arg1 )
f7_arg0:dispatchEventToRoot( {
name = "options_window_refresh",
source_input = f7_arg1.name,
immediate = true
} )
end
function GetFOV( f8_arg0 )
return (Engine.GetDvarFloat( "ui_cg_fov" ) - f8_arg0.Min) / (f8_arg0.Max - f8_arg0.Min)
end
function SliderChange( f9_arg0, f9_arg1, f9_arg2, f9_arg3 )
Engine.SetDvarFloat( f9_arg3, math.min( f9_arg1, math.max( f9_arg0, Engine.GetDvarFloat( f9_arg3 ) + f9_arg2 ) ) )
end
function OptionFactory( f10_arg0, f10_arg1, f10_arg2, f10_arg3, f10_arg4, f10_arg5, f10_arg6, f10_arg7, f10_arg8, f10_arg9, f10_arg10, f10_arg11 )
local f10_local0 = nil
local f10_local1 = 1
local f10_local2 = Engine.GetDvarType( f10_arg0 )
local f10_local3 = nil
if f10_arg9 then
f10_local3 = {
variant = GenericButtonSettings.Variants.Slider,
button_text = Engine.Localize( f10_arg1 ),
button_display_func = function ( f11_arg0, f11_arg1 )
return f10_arg11( f10_arg10 )
end,
button_left_func = function ( f12_arg0, f12_arg1 )
SliderChange( f10_arg10.Min, f10_arg10.Max, -f10_arg10.Step, f10_arg0 )
end,
button_right_func = function ( f13_arg0, f13_arg1 )
SliderChange( f10_arg10.Min, f10_arg10.Max, f10_arg10.Step, f10_arg0 )
end
}
else
if f10_local2 == DvarTypeTable.DvarString or f10_local2 == DvarTypeTable.DvarEnum then
f10_local0 = Engine.GetDvarString( f10_arg0 )
elseif f10_local2 == DvarTypeTable.DvarInt then
f10_local0 = Engine.GetDvarInt( f10_arg0 )
elseif f10_local2 == DvarTypeTable.DvarBool then
f10_local0 = Engine.GetDvarBool( f10_arg0 )
end
for f10_local7, f10_local8 in pairs( f10_arg2 ) do
if f10_local8.value == f10_local0 then
f10_local1 = f10_local7
break
end
end
f10_local4 = function ( f14_arg0, f14_arg1 )
if f10_local2 == DvarTypeTable.DvarString or f10_local2 == DvarTypeTable.DvarEnum then
Engine.SetDvarString( f10_arg0, f10_arg2[f10_local1].value )
elseif f10_local2 == DvarTypeTable.DvarInt then
Engine.SetDvarInt( f10_arg0, f10_arg2[f10_local1].value )
elseif f10_local2 == DvarTypeTable.DvarBool then
Engine.SetDvarBool( f10_arg0, f10_arg2[f10_local1].value )
end
OptionsWindowTriggerRefresh( f14_arg0, f14_arg1 )
end
f10_local3 = {
variant = GenericButtonSettings.Variants.Select,
button_text = Engine.Localize( f10_arg1 ),
button_display_func = function ( f15_arg0, f15_arg1 )
return f10_arg6 and f10_arg2[f10_local1].text or Engine.Localize( f10_arg2[f10_local1].text )
end,
button_left_func = function ( f16_arg0, f16_arg1 )
f10_local1 = 1 + (#f10_arg2 + f10_local1 - 1 - 1) % #f10_arg2
f10_local4( f16_arg0, f16_arg1 )
end,
button_right_func = function ( f17_arg0, f17_arg1 )
f10_local1 = 1 + (f10_local1 - 1 + 1) % #f10_arg2
f10_local4( f17_arg0, f17_arg1 )
end,
button_over_func = f10_arg7,
button_up_func = f10_arg8
}
end
return {
type = "UIGenericButton",
id = "option_" .. f10_arg0,
disabledFunc = f10_arg4 or function ()
return false
end
,
states = {
default = {
alpha = 1
},
invisible = {
alpha = 0
}
},
properties = f10_local3,
handlers = {
check_show_apply = function ( f19_arg0, f19_arg1 )
if f10_arg3 then
if f10_arg9 then
local f19_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f19_arg0 )
if Engine.GetDvarFloat( f10_arg3 ) ~= Engine.GetDvarFloat( f10_arg0 ) then
f19_local0.showApplySettings = true
if f10_arg5 then
f19_local0.vidRestart = true
end
end
else
local f19_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f19_arg0 )
local f19_local1 = nil
local f19_local2 = Engine.GetDvarType( f10_arg3 )
if f19_local2 == DvarTypeTable.DvarString or f19_local2 == DvarTypeTable.DvarEnum then
f19_local1 = Engine.GetDvarString( f10_arg3 )
elseif f19_local2 == DvarTypeTable.DvarInt then
f19_local1 = tostring( Engine.GetDvarInt( f10_arg3 ) )
elseif f19_local2 == DvarTypeTable.DvarBool then
if Engine.GetDvarBool( f10_arg3 ) then
local f19_local3 = "1"
end
f19_local1 = f19_local3 or "0"
elseif f19_local2 == DvarTypeTable.DvarFloat then
f19_local1 = tostring( Engine.GetDvarFloat( f10_arg3 ) )
end
if f19_local1 ~= f10_arg2[f10_local1].value then
f19_local0.showApplySettings = true
if f10_arg5 then
f19_local0.vidRestart = true
end
end
end
end
end
}
}
end
function OptionsFeeder( f20_arg0 )
local f20_local0 = {
[#f20_local0 + 1] = OptionFactory( "ui_r_aspectratio", "@MENU_ASPECT_RATIO", {
{
text = "@MENU_AUTO",
value = "auto"
},
{
text = "@MENU_STANDARD_4_3",
value = "standard"
},
{
text = "@MENU_WIDE_16_10",
value = "wide 16:10"
},
{
text = "MENU_WIDE_16_9",
value = "wide 16:9"
}
}, "r_aspectratio", InGameDisabledFunc, true )
}
local f20_local1 = {}
for f20_local5, f20_local6 in pairs( Engine.GetDvarEnumList( "r_displayRefresh" ) ) do
f20_local1[#f20_local1 + 1] = {
text = f20_local6,
value = f20_local6
}
end
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_displayRefresh", "@MENU_SCREEN_REFRESH_RATE", f20_local1, "r_displayRefresh", InGameDisabledFunc, true )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_vsync", "@MENU_SYNC_EVERY_FRAME", {
{
text = "@LUA_MENU_YES",
value = "1"
},
{
text = "@LUA_MENU_NO",
value = "0"
}
}, "r_vsync", InGameDisabledFunc, true )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_imageQuality", "@PLATFORM_UI_IMAGE_QUALITY", {
{
text = "@MENU_VERY_LOW",
value = "1"
},
{
text = "@MENU_LOW",
value = "2"
},
{
text = "@MENU_NORMAL",
value = "3"
},
{
text = "@MENU_HIGH",
value = "4"
},
{
text = "@MENU_EXTRA",
value = "0"
}
}, "r_imageQuality", InGameDisabledFunc, true )
if Engine.IsMultiplayer() then
f20_local2 = {}
f20_local3 = SliderBounds.FOV.Max - SliderBounds.FOV.Min
for f20_local4 = 0, f20_local3, 1 do
local f20_local7 = tostring( SliderBounds.FOV.Min + f20_local4 )
f20_local2[f20_local4 + 1] = {
text = Engine.MarkLocalized( f20_local7 ),
value = f20_local7
}
end
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_cg_fov", "@MENU_FOV", f20_local2, "cg_fov", nil, false, true, function ( f21_arg0, f21_arg1 )
f21_arg0:dispatchEventToRoot( {
name = "show_fov_subtitle",
immediate = true
} )
end, function ( f22_arg0, f22_arg1 )
f22_arg0:dispatchEventToRoot( {
name = "hide_fov_subtitle",
immediate = true
} )
end, false, false, false )
end
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_dof_enable", "@MENU_DOF", {
{
text = "@LUA_MENU_YES",
value = "1"
},
{
text = "@LUA_MENU_NO",
value = "0"
}
}, "r_dof_enable", nil, false )
if Engine.HBAOAvailable() then
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_ssao", "@PLATFORM_SSAO", {
{
text = "@MENU_OFF",
value = "0_Off"
},
{
text = "@PLATFORM_LOW_QUALITY",
value = "1_Low"
},
{
text = "@PLATFORM_HIGH_QUALITY",
value = "2_High"
},
{
text = "@PLATFORM_HBAO",
value = "3_HBAO"
}
}, "r_ssao", InGameDisabledFunc, true )
else
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_ssao", "@PLATFORM_SSAO", {
{
text = "@MENU_OFF",
value = "0_Off"
},
{
text = "@PLATFORM_LOW_QUALITY",
value = "1_Low"
},
{
text = "@PLATFORM_HIGH_QUALITY",
value = "2_High"
}
}, "r_ssao", InGameDisabledFunc, true )
end
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_tessellation", "@MENU_TESSELLATION", {
{
text = "@MENU_OFF",
value = "0_Off"
},
{
text = "@MENU_NORMAL",
value = "1_Near"
},
{
text = "@MENU_EXTRA",
value = "2_All"
}
}, "r_tessellation", nil, false )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_texFilterAnisoMin", "@LUA_MENU_ANISOTROPIC_FILTERING", {
{
text = "@MENU_LOW",
value = "1"
},
{
text = "@MENU_NORMAL",
value = "8"
},
{
text = "@MENU_HIGH",
value = "16"
}
}, "r_texFilterAnisoMin", InGameDisabledFunc, true )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_mbEnableA", "@MENU_MOTION_BLUR", {
{
text = "@LUA_MENU_YES",
value = "1"
},
{
text = "@LUA_MENU_NO",
value = "0"
}
}, "r_mbEnableA", InGameDisabledFunc, true )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_distortion", "@MENU_DISTORTION", {
{
text = "@LUA_MENU_YES",
value = "1"
},
{
text = "@LUA_MENU_NO",
value = "0"
}
}, "r_distortion", nil, false )
if Engine.TXAAAvailable() then
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_aaMode", "@MENU_ANTIALIASING", {
{
text = "@MENU_OFF",
value = "Off"
},
{
text = "@MENU_FXAA",
value = "FXAA"
},
{
text = "@MENU_2X_MSAA",
value = "2xMSAA"
},
{
text = "@MENU_4X_MSAA",
value = "4xMSAA"
},
{
text = "@MENU_SMAA",
value = "SMAA"
},
{
text = "@MENU_2X_TXAA",
value = "2xTXAA"
},
{
text = "@MENU_4X_TXAA",
value = "4xTXAA"
}
}, "r_aaMode", InGameDisabledFunc, true )
else
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_aaMode", "@MENU_ANTIALIASING", {
{
text = "@MENU_OFF",
value = "Off"
},
{
text = "@MENU_FXAA",
value = "FXAA"
},
{
text = "@MENU_2X_MSAA",
value = "2xMSAA"
},
{
text = "@MENU_4X_MSAA",
value = "4xMSAA"
},
{
text = "@MENU_SMAA",
value = "SMAA"
}
}, "r_aaMode", InGameDisabledFunc, true )
end
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_sm_enable", "@MENU_SHADOWS", {
{
text = "@LUA_MENU_YES",
value = "1"
},
{
text = "@LUA_MENU_NO",
value = "0"
}
}, "sm_enable", InGameDisabledFunc, true )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_picmip_manual", "@MENU_TEXTURE_QUALITY", {
{
text = "@MENU_AUTOMATIC",
value = "0"
},
{
text = "@MENU_MANUAL",
value = "1"
}
}, "r_picmip_manual", InGameDisabledFunc, true )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_picmip", "@MENU_TEXTURE_RESOLUTION", {
{
text = "@MENU_LOW",
value = "3"
},
{
text = "@MENU_NORMAL",
value = "2"
},
{
text = "@MENU_HIGH",
value = "1"
},
{
text = "@MENU_EXTRA",
value = "0"
}
}, "r_picmip", PicmipDisabledFunc, true )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_picmip_bump", "@MENU_NORMAL_MAP_RESOLUTION", {
{
text = "@MENU_LOW",
value = "3"
},
{
text = "@MENU_NORMAL",
value = "2"
},
{
text = "@MENU_HIGH",
value = "1"
},
{
text = "@MENU_EXTRA",
value = "0"
}
}, "r_picmip_bump", PicmipDisabledFunc, true )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_picmip_spec", "@MENU_SPECULAR_MAP_RESOLUTION", {
{
text = "@MENU_LOW",
value = "3"
},
{
text = "@MENU_NORMAL",
value = "2"
},
{
text = "@MENU_HIGH",
value = "1"
},
{
text = "@MENU_EXTRA",
value = "0"
}
}, "r_picmip_spec", PicmipDisabledFunc, true )
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_picmip_water", "@MENU_WATER_MAP_RESOLUTION", {
{
text = "@MENU_LOW",
value = "1"
},
{
text = "@MENU_HIGH",
value = "0"
}
}, "r_picmip_water", PicmipDisabledFunc, true )
if Engine.FurShaderAvailable() then
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_fur_shader", "@MENU_FUR_SHADER", {
{
text = "@MENU_OFF",
value = "0"
},
{
text = "@MENU_LOW",
value = "1"
},
{
text = "@MENU_HIGH",
value = "2"
}
}, "r_fur_shader", InGameDisabledFunc, true, nil, NVidiaButtonOver, NVidiaButtonUp )
end
if Engine.APEXTurbulenceAvailable() then
f20_local0[#f20_local0 + 1] = OptionFactory( "ui_r_apex_turbulence", "@MENU_APEX_TURBULENCE", {
{
text = "@MENU_ON",
value = "1"
},
{
text = "@MENU_OFF",
value = "0"
}
}, "r_apex_turbulence", InGameDisabledFunc, true, nil, NVidiaButtonOver, NVidiaButtonUp )
end
return f20_local0
end
function OptionsMainCreate( f23_arg0, f23_arg1 )
Engine.ExecNow( "profile_menuDvarsSetup" )
f23_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addBackButton )
end
function OptionsMainClose( f24_arg0, f24_arg1 )
Engine.ExecNow( "profile_menuDvarsFinish" )
if Engine.GetDvarString( "r_lodScaleRigid" ) == "2" then
Engine.SetDvarString( "r_lodScaleSkinned", "4" )
Engine.SetDvarString( "r_lodBiasSkinned", "-200" )
Engine.SetDvarString( "r_lodBiasRigid", "-100" )
end
if Engine.GetDvarString( "r_lodScaleRigid" ) == "1" then
Engine.SetDvarString( "r_lodScaleSkinned", "1" )
Engine.SetDvarString( "r_lodBiasSkinned", "0" )
Engine.SetDvarString( "r_lodBiasRigid", "0" )
end
end
function advanced_video_vlist()
return {
type = "UIStencil",
children = {
{
type = "UIVerticalList",
childrenFeeder = OptionsFeeder,
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = -25,
top = 0,
bottom = 0
}
}
}
},
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = GenericMenuDims.menu_left,
right = GenericMenuDims.menu_right_wide,
top = GenericMenuDims.menu_top,
bottom = GenericMenuDims.menu_bottom
}
}
}
end
function advanced_video()
return {
type = "UIElement",
id = "advanced_video_id",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 0,
right = 0
}
},
handlers = {
menu_create = OptionsMainCreate,
menu_close = OptionsMainClose,
options_window_refresh = OptionsWindowRefresh
},
children = {
{
type = "UIWorldBlur",
id = "world_blur_id",
states = {
default = {
worldBlur = 5
}
}
},
{
type = "UIImage",
id = "options_background",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 0,
right = 0,
alpha = 0.5,
material = RegisterMaterial( "black" )
}
}
},
{
type = "generic_menu_title",
properties = {
menu_title = Engine.Localize( "@LUA_MENU_ADVANCED_VIDEO" )
}
},
{
type = "advanced_video_vlist",
id = "advanced_video_vlist_id"
},
{
type = "button_helper_text_main",
id = "button_helper_text_id"
},
{
type = "UIMarqueeText",
id = "nvidia_option_subtitle",
properties = {
text = Engine.Localize( "@MENU_NVIDIA_OPTION_SUB" )
},
states = {
default = {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = false,
top = OptionsListDims.menu_bottom,
bottom = OptionsListDims.menu_bottom + CoD.TextSettings.TinyFont.Height,
left = 10,
right = OptionsListDims.menu_right - 110,
font = CoD.TextSettings.TinyFont.Font,
alignment = LUI.Alignment.Right,
red = 0.7,
green = 0.7,
blue = 0.7,
alpha = 0
},
show_me = {
alpha = 1
},
hide_me = {
alpha = 0
}
},
handlers = {
show_nvidia_subtitle = function ( f27_arg0, f27_arg1 )
f27_arg0:setText( Engine.Localize( "@MENU_NVIDIA_OPTION_SUB" ) )
f27_arg0:animateToState( "show_me", 0 )
end
,
hide_nvidia_subtitle = function ( f28_arg0, f28_arg1 )
f28_arg0:animateToState( "hide_me", 0 )
end
,
show_fov_subtitle = function ( f29_arg0, f29_arg1 )
f29_arg0:setText( Engine.Localize( "@LUA_MENU_MP_FOV_OPTION_SUB" ) )
f29_arg0:animateToState( "show_me", 0 )
end
,
hide_fov_subtitle = function ( f30_arg0, f30_arg1 )
f30_arg0:animateToState( "hide_me", 0 )
end
}
},
{
type = "UIBindButton",
id = "back_button",
handlers = {
button_secondary = BackButtonAction
}
}
}
}
end
LUI.MenuBuilder.registerDef( "advanced_video_vlist", advanced_video_vlist )
LUI.MenuBuilder.registerDef( "advanced_video", advanced_video )
LockTable( _M )