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

1160 lines
33 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function ButtonMenuAction( f1_arg0, f1_arg1 )
LUI.FlowManager.RequestAddMenu( f1_arg0, f1_arg0.properties.menu, true, f1_arg1.controller, false )
end
function ChatDisableFunc( f2_arg0, f2_arg1 )
local f2_local0 = SinglePlayerDisabled( f2_arg0, f2_arg1 )
if not f2_local0 then
f2_local0 = GamepadDisabledFunc( f2_arg0, f2_arg1 )
end
return f2_local0
end
function GamepadDisabledFunc( f3_arg0, f3_arg1 )
return Engine.IsGamepadEnabled() == 1
end
function LeaveGameSetupOptionsMenu( f4_arg0, f4_arg1 )
local f4_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f4_arg0 )
if Engine.GetDvarString( "r_mode" ) ~= Engine.GetDvarString( "ui_r_mode" ) or Engine.GetDvarString( "r_displayMode" ) ~= Engine.GetDvarString( "ui_r_displayMode" ) then
LUI.FlowManager.RequestPopupMenu( f4_arg0, "apply_settings_restart_popmenu", false, f4_arg1.controller, false )
end
LUI.FlowManager.RequestLeaveMenu( f4_arg0 )
end
function GetLeaveOptionsWindowFunctionForButton( f5_arg0 )
return function ( f6_arg0, f6_arg1 )
local f6_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "pc_controls" )
f6_local0.currentBackButtonAction = LeaveGameSetupOptionsMenu
Engine.PlaySound( CoD.SFX.SelectBack )
f6_arg0:dispatchEventToRoot( {
name = "button_unlock",
immediate = true
} )
f6_arg0:dispatchEventToRoot( {
name = "options_window_unfocus",
immediate = true
} )
f6_arg0:dispatchEventToRoot( {
name = "options_categories_window_focus",
immediate = true
} )
if f5_arg0 then
f5_arg0:processEvent( {
name = "gain_focus",
immediate = true
} )
end
end
end
function BackButtonAction( f7_arg0, f7_arg1 )
local f7_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f7_arg0 )
if not f7_local0.currentBackButtonAction then
f7_local0.currentBackButtonAction = LeaveGameSetupOptionsMenu
end
f7_local0.currentBackButtonAction( f7_arg0, f7_arg1 )
end
function LockCurrentButton( f8_arg0, f8_arg1 )
local f8_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f8_arg0 )
local f8_local1 = f8_arg0:getChildById( f8_local0.currentOptionsCategory )
if f8_local1 then
f8_local1:processEvent( {
name = "button_lock",
immediate = true
} )
f8_local0.unlocked = true
end
end
function optimal_notice()
return {
type = "generic_yesno_popup",
properties = {
popup_title = Engine.Localize( "@MENU_RESET_SYSTEM_DEFAULTS" ),
message_text = Engine.Localize( "@MENU_RESTORE_DEFAULTS" ),
yes_action = function ( f10_arg0, f10_arg1 )
Engine.SetRecommended()
Engine.Exec( "wait; wait; r_applyPicmip;" )
end
,
no_action = function ( f11_arg0, f11_arg1 )
DebugPrint( "Running generic_onfirmation_popup no action" )
end
,
yes_text = Engine.Localize( "@LUA_MENU_YES" ),
no_text = Engine.Localize( "@LUA_MENU_NO" )
}
}
end
function OptionCategoryButtonAction( f12_arg0, f12_arg1 )
local f12_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f12_arg0 )
OptionsWindowTriggerRefresh( f12_arg0, f12_arg1 )
local f12_local1 = f12_arg0:getParent()
f12_local1:dispatchEventToChildren( {
name = "button_unlock",
immediate = true
} )
if not f12_arg1.mouse then
f12_local1 = LUI.FlowManager.GetMenuScopedDataFromElement( f12_arg0 )
f12_local1.currentBackButtonAction = GetLeaveOptionsWindowFunctionForButton( f12_arg0 )
f12_arg0:dispatchEventToRoot( {
name = "options_window_focus",
immediate = true
} )
f12_arg0:dispatchEventToRoot( {
name = "options_categories_window_unfocus",
immediate = true
} )
end
f12_arg0:processEvent( {
name = "button_lock",
immediate = true
} )
f12_local0.unlocked = false
f12_local1 = f12_arg0:getParent()
f12_local1:dispatchEventToChildren( {
name = "sp_voice_disable",
immediate = true
} )
end
function OptionCategoryButtonOver( f13_arg0, f13_arg1 )
local f13_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f13_arg0 )
if f13_arg1.focusType ~= FocusType.MenuFlow then
f13_local0.currentBackButtonAction = LeaveGameSetupOptionsMenu
end
local f13_local1 = OptionsWindowTriggerRefresh
local f13_local2 = f13_arg0
local f13_local3 = f13_arg1
local f13_local4
if f13_arg1.focusType ~= FocusType.MenuFlow or Engine.IsGamepadEnabled() ~= 0 then
f13_local4 = false
else
f13_local4 = true
end
f13_local1( f13_local2, f13_local3, f13_local4 )
end
function OptionFactory( f14_arg0, f14_arg1, f14_arg2, f14_arg3, f14_arg4, f14_arg5 )
local f14_local0 = nil
local f14_local1 = 1
local f14_local2 = Engine.GetDvarType( f14_arg0 )
if f14_local2 == DvarTypeTable.DvarString then
f14_local0 = Engine.GetDvarString( f14_arg0 )
elseif f14_local2 == DvarTypeTable.DvarInt then
f14_local0 = Engine.GetDvarInt( f14_arg0 )
elseif f14_local2 == DvarTypeTable.DvarBool then
f14_local0 = Engine.GetDvarBool( f14_arg0 )
end
for f14_local6, f14_local7 in pairs( f14_arg2 ) do
if f14_local7.value == f14_local0 then
f14_local1 = f14_local6
break
end
end
f14_local3 = function ( f15_arg0, f15_arg1 )
if f14_local2 == DvarTypeTable.DvarString then
Engine.SetDvarString( f14_arg0, f14_arg2[f14_local1].value )
elseif f14_local2 == DvarTypeTable.DvarInt then
Engine.SetDvarInt( f14_arg0, f14_arg2[f14_local1].value )
elseif f14_local2 == DvarTypeTable.DvarBool then
Engine.SetDvarBool( f14_arg0, f14_arg2[f14_local1].value )
end
if f14_arg4 then
local f15_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f15_arg0 )
f15_local0.showApplySettings = true
end
OptionsWindowTriggerPartialRefresh( f15_arg0, f15_arg1 )
end
return {
type = "UIGenericButton",
id = "option_" .. f14_arg0,
disabledFunc = f14_arg3 or function ()
return false
end
,
properties = {
style = GenericButtonSettings.Styles.GlassButton,
substyle = GenericButtonSettings.Styles.GlassButton.SubStyles.SubMenu,
variant = GenericButtonSettings.Variants.Select,
button_text = Engine.Localize( f14_arg1 ),
text_padding_with_content = 10,
text_align_with_content = LUI.Alignment.Left,
button_display_func = function ( f17_arg0, f17_arg1 )
local f17_local0
if not f14_arg5 then
f17_local0 = Engine.Localize( f14_arg2[f14_local1].text )
if not f17_local0 then
else
return f17_local0
end
end
f17_local0 = f14_arg2[f14_local1].text
end
,
button_left_func = function ( f18_arg0, f18_arg1 )
f14_local1 = 1 + (#f14_arg2 + f14_local1 - 1 - 1) % #f14_arg2
f14_local3( f18_arg0, f18_arg1 )
end
,
button_right_func = function ( f19_arg0, f19_arg1 )
f14_local1 = 1 + (f14_local1 - 1 + 1) % #f14_arg2
f14_local3( f19_arg0, f19_arg1 )
end
},
handlers = {
element_refresh = MBh.EmitEvent( "content_refresh" )
}
}
end
function OptionFactoryProfileData( f20_arg0, f20_arg1, f20_arg2, f20_arg3, f20_arg4 )
local f20_local0 = Engine.GetProfileData( f20_arg0 )
local f20_local1 = 1
for f20_local5, f20_local6 in pairs( f20_arg3 ) do
if f20_local6.value == f20_local0 then
f20_local1 = f20_local5
break
end
end
f20_local2 = function ( f21_arg0, f21_arg1 )
Engine.Exec( f20_arg1 )
OptionsWindowTriggerPartialRefresh( f21_arg0, f21_arg1 )
end
return {
type = "UIGenericButton",
id = "option_" .. f20_arg0,
disabledFunc = f20_arg4 or function ()
return false
end
,
properties = {
style = GenericButtonSettings.Styles.GlassButton,
variant = GenericButtonSettings.Variants.Select,
button_text = Engine.Localize( f20_arg2 ),
text_padding_with_content = 10,
text_align_with_content = LUI.Alignment.Left,
button_display_func = function ( f23_arg0, f23_arg1 )
return Engine.Localize( f20_arg3[f20_local1].text )
end
,
button_left_func = function ( f24_arg0, f24_arg1 )
f20_local1 = 1 + (#f20_arg3 + f20_local1 - 1 - 1) % #f20_arg3
f20_local2( f24_arg0, f24_arg1 )
end
,
button_right_func = function ( f25_arg0, f25_arg1 )
f20_local1 = 1 + (f20_local1 - 1 + 1) % #f20_arg3
f20_local2( f25_arg0, f25_arg1 )
end
},
handlers = {
element_refresh = MBh.EmitEvent( "content_refresh" )
}
}
end
function PCOptionsMainCreate( f26_arg0, f26_arg1 )
local f26_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f26_arg0 )
if not f26_local0.currentBackButtonAction or Engine.IsGamepadEnabled() == 0 then
f26_local0.currentBackButtonAction = LeaveGameSetupOptionsMenu
end
Engine.ExecNow( "profile_menuDvarsSetup" )
f26_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addBackButton )
if not f26_local0.showApplySettings and not f26_local0.picmipApplySettings then
Engine.ExecNow( "exec options_graphics.cfg" )
end
if Engine.IsGamepadEnabled() == 1 and f26_local0.currentOptionsCategory then
f26_local0.currentBackButtonAction = GetLeaveOptionsWindowFunctionForButton( f26_arg0:getFirstDescendentById( f26_local0.currentOptionsCategory ) )
end
if f26_local0.currentOptionsCategory then
local f26_local1 = f26_arg0:getFirstDescendentById( f26_local0.currentOptionsCategory .. "_id" )
if f26_local1 then
f26_local1:processEvent( {
name = "button_lock",
immediate = false
} )
f26_local0.unlocked = false
end
end
if not f26_local0.currentOptionsCategory then
f26_local0.currentOptionsCategory = "video_options"
end
OptionsWindowTriggerRefresh( f26_arg0, f26_arg1, true )
end
function SliderOptionFactory( f27_arg0, f27_arg1, f27_arg2, f27_arg3, f27_arg4, f27_arg5, f27_arg6, f27_arg7, f27_arg8, f27_arg9 )
local f27_local0 = function ( f28_arg0, f28_arg1, f28_arg2, f28_arg3, f28_arg4 )
local f28_local0 = Engine.GetDvarFloat( f27_arg0 )
if f28_local0 then
Engine.SetDvarFloat( f27_arg0, math.min( f28_arg3, math.max( f28_arg2, f28_local0 + f28_arg4 ) ) )
if f27_arg9 ~= nil then
f28_arg0:dispatchEventToRoot( {
name = f27_arg9,
immediate = true
} )
end
end
Engine.MenuDvarsFinish( f28_arg1.controller )
end
return {
type = "UIGenericButton",
id = "options_" .. f27_arg0,
disabledFunc = f27_arg8 or function ()
return false
end
,
properties = {
style = GenericButtonSettings.Styles.GlassButton,
substyle = GenericButtonSettings.Styles.GlassButton.SubStyles.SubMenu,
variant = GenericButtonSettings.Variants.Slider,
button_text = Engine.Localize( f27_arg1 ),
text_padding_with_content = 10,
text_align_with_content = LUI.Alignment.Left,
button_display_func = function ( f30_arg0, f30_arg1 )
local f30_local0 = Engine.GetDvarFloat( f27_arg0 )
if f30_local0 then
local f30_local1 = (f30_local0 - f27_arg2) / (f27_arg3 - f27_arg2)
if f27_arg7 then
f30_local1 = 1 - f30_local1
end
return f30_local1
else
end
end
,
button_left_func = function ( f31_arg0, f31_arg1 )
f27_local0( f31_arg0, f31_arg1, f27_arg2, f27_arg3, -f27_arg4 )
end
,
button_right_func = function ( f32_arg0, f32_arg1 )
f27_local0( f32_arg0, f32_arg1, f27_arg2, f27_arg3, f27_arg4 )
end
,
button_over_func = f27_arg5,
button_up_func = f27_arg6
}
}
end
function OptionsFeeder()
local f33_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "pc_controls" )
local f33_local1 = f33_local0.currentOptionsCategory
if f33_local1 == "video_options" then
return VideoOptionsFeeder()
elseif f33_local1 == "audio_options" then
return AudioOptionsFeeder()
elseif f33_local1 == "voice_options" then
return VoiceOptionsFeeder()
elseif f33_local1 == "control_options" then
return ControlOptionsFeeder()
else
return VideoOptionsFeeder()
end
end
function PCOptionsMainClose( f34_arg0, f34_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
Engine.Exec( "updategamerprofile" )
end
function OptionsWindowBGResize( f35_arg0, f35_arg1 )
f35_arg0:registerAnimationState( "current", {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = true,
top = GenericTitleBarDims.TitleBarHeight,
bottom = GenericTitleBarDims.TitleBarHeight + CountFields( f35_arg1.options ) * (GenericButtonSettings.Styles.GlassButton.SubStyles.Default.height + PCOptionsMenuDimensions.Spacing) + 2 * PCOptionsMenuDimensions.Padding,
left = 0,
right = 0
} )
f35_arg0:animateToState( "current", 0 )
end
function OptionsWindowRefresh( f36_arg0, f36_arg1 )
if f36_arg1.source_input == "button_action" or f36_arg1.source_input == "menu_create" or f36_arg1.source_input == "button_over" and f36_arg1.focusType ~= FocusType.MouseOver then
local f36_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f36_arg0 )
local f36_local1 = f36_arg0
local f36_local2 = f36_arg0.processEvent
local f36_local3 = {
name = "pre_menu_refresh"
}
local f36_local4
if not f36_arg1.noCategoryChange then
f36_local4 = f36_arg1.options_category
if not f36_local4 then
else
f36_local3.options_category = f36_local4
f36_local2( f36_local1, f36_local3 )
f36_arg0:processEvent( {
name = "menu_refresh"
} )
OptionsWindowResize( f36_arg0, f36_arg1 )
OptionsWindowTitleUpdate( f36_arg0, f36_arg1 )
if not f36_local0.unlocked and f36_arg1.source_input ~= "menu_create" then
f36_local0.unlocked = true
f36_arg0:dispatchEventToRoot( {
name = "button_unlock",
immediate = true
} )
f36_arg1.source_button:processEvent( {
name = "gain_focus",
immediate = true
} )
end
end
end
f36_local4 = nil
end
end
function OptionsWindowPartialRefresh( f37_arg0, f37_arg1 )
if not Engine.IsConsoleGame() and (f37_arg1.source_input == "button_action" or f37_arg1.source_input == "button_left" or f37_arg1.source_input == "button_right") then
f37_arg0:processEvent( {
name = "menu_refresh"
} )
end
end
function OptionsWindowResize( f38_arg0, f38_arg1 )
local f38_local0 = f38_arg0
local f38_local1 = f38_arg0.processEvent
local f38_local2 = {
name = "window_resize"
}
local f38_local3 = f38_arg0:getChildById( "pc_controls_window_content" )
f38_local2.options = f38_local3.childRecord
f38_local1( f38_local0, f38_local2 )
end
function OptionsWindowShadowResize( f39_arg0, f39_arg1 )
f39_arg0:registerAnimationState( "current", {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = true,
top = 0,
left = 0,
right = 0,
bottom = GenericTitleBarDims.TitleBarHeight + CountFields( f39_arg1.options ) * (GenericButtonSettings.Styles.GlassButton.SubStyles.Default.height + PCOptionsMenuDimensions.Spacing) + 2 * PCOptionsMenuDimensions.Padding
} )
f39_arg0:animateToState( "current", 0 )
end
function OptionsWindowTitleUpdate( f40_arg0, f40_arg1 )
local f40_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f40_arg0 )
local f40_local1 = f40_local0.currentOptionsCategory
local f40_local2 = ""
if f40_local1 then
if f40_local1 == "video_options" then
f40_local2 = Engine.Localize( "@LUA_MENU_VIDEO_OPTIONS_CAPS" )
elseif f40_local1 == "audio_options" then
f40_local2 = Engine.Localize( "@LUA_MENU_AUDIO_OPTIONS_CAPS" )
elseif f40_local1 == "control_options" then
f40_local2 = Engine.Localize( "@LUA_MENU_CONTROL_OPTIONS_CAPS" )
elseif f40_local1 == "voice_options" then
f40_local2 = Engine.Localize( "@LUA_MENU_VOICE_OPTIONS_CAPS" )
else
f40_local2 = Engine.Localize( "@LUA_MENU_VIDEO_OPTIONS_CAPS" )
end
else
f40_local2 = Engine.Localize( "@LUA_MENU_VIDEO_OPTIONS_CAPS" )
end
f40_arg0:processEvent( {
name = "update_title",
title_text = f40_local2
} )
end
function OptionsWindowTriggerRefresh( f41_arg0, f41_arg1, f41_arg2 )
local f41_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f41_arg0 )
f41_arg0:dispatchEventToRoot( {
name = "options_window_refresh",
source_input = f41_arg1.name,
options_category = f41_arg0.properties.options_category,
focusType = f41_arg1.focusType,
noCategoryChange = f41_arg2,
source_button = f41_arg0,
immediate = true
} )
end
function OptionsWindowTriggerPartialRefresh( f42_arg0, f42_arg1 )
f42_arg0:dispatchEventToRoot( {
name = "options_window_partial_refresh",
source_input = f42_arg1.name,
options_category = f42_arg0.properties.options_category,
immediate = true
} )
end
function PrepareMenuRefresh( f43_arg0, f43_arg1 )
f43_arg0:closeChildren()
f43_arg0:clearSavedState()
local f43_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f43_arg0 )
if f43_arg1.options_category then
f43_local0.currentOptionsCategory = f43_arg1.options_category
end
end
function PrepareMenuPartialRefresh( f44_arg0, f44_arg1 )
f44_arg0:closeChildren()
f44_arg0:clearSavedState()
end
function ResolutionDisabledFunc( f45_arg0, f45_arg1 )
return Engine.GetDvarString( "ui_r_displayMode" ) == "windowed (no border)"
end
function BrightnessOverFunc( f46_arg0, f46_arg1 )
if f46_arg1.focusType ~= FocusType.MenuFlow then
f46_arg0:dispatchEventToRoot( {
name = "brightness_over"
} )
end
end
function VideoOptionsFeeder()
local f47_local0 = {}
local f47_local1 = {}
for f47_local5, f47_local6 in pairs( Engine.GetDvarEnumList( "r_mode" ) ) do
f47_local1[#f47_local1 + 1] = {
text = f47_local6,
value = f47_local6
}
end
f47_local0[#f47_local0 + 1] = OptionFactory( "ui_r_mode", "@LUA_MENU_VIDEO_MODE", f47_local1, ResolutionDisabledFunc, true, true )
f47_local0[#f47_local0 + 1] = OptionFactory( "ui_r_displayMode", "@LUA_MENU_DISPLAY_MODE", {
{
text = "@LUA_MENU_MODE_FULLSCREEN",
value = "fullscreen"
},
{
text = "@LUA_MENU_MODE_WINDOWED_NO_BORDER",
value = "windowed (no border)"
},
{
text = "@LUA_MENU_MODE_WINDOWED",
value = "windowed"
}
}, nil, true )
f47_local0[#f47_local0 + 1] = SliderOptionFactory( "profileMenuOption_blacklevel", "@MENU_BRIGHTNESS", SliderBounds.PCBrightness.Min, SliderBounds.PCBrightness.Max, SliderBounds.PCBrightness.Step, BrightnessOverFunc, MBh.EmitEventToRoot( {
name = "brightness_up"
} ), true, nil, "brightness_updated" )
f47_local0[#f47_local0 + 1] = OptionFactoryProfileData( "renderColorBlind", "profile_toggleRenderColorBlind", "@LUA_MENU_COLORBLIND_FILTER", {
{
text = "@LUA_MENU_ENABLED",
value = true
},
{
text = "@LUA_MENU_DISABLED",
value = false
}
} )
f47_local0[#f47_local0 + 1] = {
type = "UIGenericButton",
id = "option_advanced_video",
properties = {
style = GenericButtonSettings.Styles.GlassButton,
button_text = Engine.Localize( "@LUA_MENU_ADVANCED_VIDEO" ),
button_action_func = ButtonMenuAction,
text_align_without_content = LUI.Alignment.Left,
menu = "advanced_video"
}
}
return f47_local0
end
function AudioOptionsFeeder()
local f48_local0 = {
[#f48_local0 + 1] = SliderOptionFactory( "profileMenuOption_volume", "@MENU_MASTER_VOLUME", SliderBounds.Volume.Min, SliderBounds.Volume.Max, SliderBounds.Volume.PCStep )
}
if Engine.GetCurrentLanguage() ~= 6 and SinglePlayerDisabled() then
f48_local0[#f48_local0 + 1] = OptionFactoryProfileData( "subtitles", "profile_toggleSubtitles", "@LUA_MENU_SUBTITLES", {
{
text = "@LUA_MENU_ENABLED",
value = true
},
{
text = "@LUA_MENU_DISABLED",
value = false
}
} )
end
return f48_local0
end
function ControlOptionsFeeder()
local f49_local0 = {
[#f49_local0 + 1] = {
type = "UIGenericButton",
id = "option_movement_controls",
disabledFunc = GamepadDisabledFunc,
properties = {
style = GenericButtonSettings.Styles.GlassButton,
substyle = GenericButtonSettings.Styles.GlassButton.SubStyles.SubMenu,
button_text = Engine.Localize( "@LUA_MENU_MOVEMENT" ),
button_action_func = ButtonMenuAction,
text_align_without_content = LUI.Alignment.Left,
menu = "movement_controls"
}
},
[#f49_local0 + 1] = {
type = "UIGenericButton",
id = "option_actions_controls",
disabledFunc = GamepadDisabledFunc,
properties = {
style = GenericButtonSettings.Styles.GlassButton,
substyle = GenericButtonSettings.Styles.GlassButton.SubStyles.SubMenu,
button_text = Engine.Localize( "@LUA_MENU_ACTIONS" ),
button_action_func = ButtonMenuAction,
text_align_without_content = LUI.Alignment.Left,
menu = "actions_controls"
}
},
[#f49_local0 + 1] = {
type = "UIGenericButton",
id = "option_look_controls",
disabledFunc = GamepadDisabledFunc,
properties = {
style = GenericButtonSettings.Styles.GlassButton,
substyle = GenericButtonSettings.Styles.GlassButton.SubStyles.SubMenu,
button_text = Engine.Localize( "@LUA_MENU_LOOK" ),
button_action_func = ButtonMenuAction,
text_align_without_content = LUI.Alignment.Left,
menu = "look_controls"
}
},
[#f49_local0 + 1] = {
type = "UIGenericButton",
id = "option_chat_controls",
disabledFunc = ChatDisableFunc,
properties = {
style = GenericButtonSettings.Styles.GlassButton,
substyle = GenericButtonSettings.Styles.GlassButton.SubStyles.SubMenu,
button_text = Engine.Localize( "@LUA_MENU_CHAT" ),
button_action_func = ButtonMenuAction,
text_align_without_content = LUI.Alignment.Left,
menu = "chat_controls"
}
},
[#f49_local0 + 1] = {
type = "UIGenericButton",
id = "option_gamepad_controls",
properties = {
style = GenericButtonSettings.Styles.GlassButton,
substyle = GenericButtonSettings.Styles.GlassButton.SubStyles.SubMenu,
button_text = Engine.Localize( "@LUA_MENU_GAMEPAD" ),
button_action_func = ButtonMenuAction,
text_align_without_content = LUI.Alignment.Left,
menu = "gamepad_controls"
}
},
[#f49_local0 + 1] = {
type = "UIGenericButton",
id = "option_restore_controls",
properties = {
style = GenericButtonSettings.Styles.GlassButton,
substyle = GenericButtonSettings.Styles.GlassButton.SubStyles.SubMenu,
button_text = Engine.Localize( "@LUA_MENU_RESTORE_DEFAULT_CONTROLS" ),
button_action_func = MBh.PopupMenu( "reset_controls", false, false ),
text_align_without_content = LUI.Alignment.Left
}
}
}
return f49_local0
end
function SinglePlayerDisabled( f50_arg0, f50_arg1 )
return not Engine.IsMultiplayer()
end
function SinglePlayerVoiceDisable( f51_arg0, f51_arg1 )
if SinglePlayerDisabled( f51_arg0, f51_arg1 ) then
f51_arg0:processEvent( {
name = "disable"
} )
end
end
function MicThreshDisable()
return Engine.GetDvarBool( "cl_pushToTalk" )
end
function VoiceOptionsFeeder()
local f53_local0 = {
[#f53_local0 + 1] = SliderOptionFactory( "winvoice_mic_reclevel", "@LUA_MENU_VOICECHAT_RECORD_LEVEL", SliderBounds.VoiceRecord.Min, SliderBounds.VoiceRecord.Max, SliderBounds.VoiceRecord.Step ),
[#f53_local0 + 1] = {
type = "UIGenericButton",
id = "option_voice_indicator_button",
disabled = true,
properties = {
style = GenericButtonSettings.Styles.GlassButton,
variant = GenericButtonSettings.Variants.Info,
button_text = Engine.Localize( "@LUA_MENU_VOICECHAT_LEVEL_INDICATOR" ),
text_padding_with_content = 10,
text_align_with_content = LUI.Alignment.Left,
button_display_func = function ()
return ""
end,
disable_padlock = true
},
children = {
{
type = "UIOwnerdraw",
id = "indicator_owner_draw",
properties = {
ownerDraw = CoD.Ownerdraw.UIRecordLevel
},
states = {
default = {
leftAnchor = false,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = -212,
right = -64,
top = 8,
bottom = -5,
alpha = 1
}
}
}
}
},
[#f53_local0 + 1] = SliderOptionFactory( "winvoice_mic_threshold", "@LUA_MENU_PICKUP_THRESHOLD", SliderBounds.VoiceThreshold.Min, SliderBounds.VoiceThreshold.Max, SliderBounds.VoiceThreshold.Step, nil, nil, nil, MicThreshDisable ),
[#f53_local0 + 1] = OptionFactory( "cl_pushToTalk", "@LUA_MENU_PUSH_TO_TALK", {
{
text = "@LUA_MENU_NO",
value = false
},
{
text = "@LUA_MENU_YES",
value = true
}
} ),
[#f53_local0 + 1] = OptionFactory( "cl_voice", "@LUA_MENU_USE_VOICE_COMMUNICATIONS", {
{
text = "@LUA_MENU_NO",
value = false
},
{
text = "@LUA_MENU_YES",
value = true
}
} ),
[#f53_local0 + 1] = OptionFactory( "cl_textChatEnabled", "@LUA_MENU_TEXTCHATENABLED", {
{
text = "@LUA_MENU_YES",
value = true
},
{
text = "@LUA_MENU_NO",
value = false
}
} )
}
return f53_local0
end
function ResetControlsYesAction( f55_arg0, f55_arg1 )
Engine.ExecNow( "profile_toggleLean 1", f55_arg1.controller )
if Engine.IsGamepadEnabled() == 1 then
Engine.ExecNow( "profile_setSticksConfig thumbstick_default", f55_arg1.controller )
Engine.ExecNow( "profile_setButtonsConfig buttons_default", f55_arg1.controller )
Engine.ExecNow( "profile_toggleInvertedPitch 0", f55_arg1.controller )
Engine.ExecNow( "profile_toggleRumble 1", f55_arg1.controller )
Engine.ExecNow( "profile_toggleAutoAim 1", f55_arg1.controller )
Engine.SetDvarFloat( "profileMenuOption_sensitivity", 3 )
else
Engine.Exec( "exec default_smp_controls.cfg" )
end
end
function reset_controls()
return {
type = "generic_yesno_popup",
properties = {
popup_title = Engine.Localize( "@LUA_MENU_SET_DEFAULT_CONTROLS" ),
message_text = Engine.Localize( "@LUA_MENU_RESTORE_EACH_SETTING" ),
yes_action = ResetControlsYesAction,
no_action = function ( f57_arg0, f57_arg1 )
DebugPrint( "Running generic_confirmation_popup no action" )
end
,
yes_text = Engine.Localize( "@LUA_MENU_YES" ),
no_text = Engine.Localize( "@LUA_MENU_CANCEL" )
}
}
end
function pc_controls_window()
return {
type = "UIElement",
id = "pc_controls_window_id",
states = {
default = {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = false,
top = 120,
bottom = 219,
left = 460,
right = 940
}
},
handlers = {
options_window_force_resize = OptionsWindowResize,
menu_create = OptionsWindowResize,
options_window_title_update = OptionsWindowTitleUpdate,
options_window_refresh = OptionsWindowRefresh,
options_window_partial_refresh = OptionsWindowPartialRefresh,
options_window_focus = MBh.EmitEvent( "gain_focus" ),
options_window_unfocus = MBh.EmitEvent( "lose_focus" )
},
children = {
{
type = "generic_drop_shadow",
id = "pc_controls_window_shadow_id",
properties = {
offset_shadow = 0
},
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0,
alpha = 0.75
}
},
handlers = {
window_resize = OptionsWindowShadowResize
}
},
{
type = "generic_menu_titlebar",
id = "pc_controls_window_title_id",
properties = {
font = CoD.TextSettings.BoldFont,
title_bar_text = "",
title_bar_text_indent = GenericTitleBarDims.TitleBarLCapWidth,
title_bar_alignment = LUI.Alignment.Left,
fill_alpha = 1,
border_alpha = 1
},
handlers = {
menu_create = MBh.EmitEventToParent( "options_window_title_update" )
}
},
{
type = "generic_menu_background",
id = "pc_controls_window_background_id",
properties = {
fill_alpha = 1,
border_alpha = 1
},
handlers = {
window_resize = OptionsWindowBGResize
}
},
{
type = "UIVerticalList",
id = "pc_controls_window_content",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = GenericTitleBarDims.TitleBarHeight + PCOptionsMenuDimensions.Padding,
bottom = 600,
left = PCOptionsMenuDimensions.Padding,
right = -PCOptionsMenuDimensions.Padding,
spacing = PCOptionsMenuDimensions.Spacing
}
},
handlers = {
pre_menu_refresh = PrepareMenuRefresh,
pre_menu_partial_refresh = PrepareMenuPartialRefresh
},
childrenFeeder = OptionsFeeder
}
}
}
end
function pc_controls_categories()
local f59_local0 = {
[#f59_local0 + 1] = {
type = "UIGenericButton",
id = "video_options_id",
properties = {
style = GenericButtonSettings.Styles.FlatButton,
button_text = Engine.Localize( "@LUA_MENU_VIDEO_OPTIONS_CAPS" ),
options_category = "video_options"
},
handlers = {
button_over = OptionCategoryButtonOver,
button_action = OptionCategoryButtonAction
}
},
[#f59_local0 + 1] = {
type = "UIGenericButton",
id = "audio_options_id",
properties = {
style = GenericButtonSettings.Styles.FlatButton,
button_text = Engine.Localize( "@LUA_MENU_AUDIO_OPTIONS_CAPS" ),
options_category = "audio_options"
},
handlers = {
button_over = OptionCategoryButtonOver,
button_action = OptionCategoryButtonAction
}
},
[#f59_local0 + 1] = {
type = "UIGenericButton",
id = "control_options_id",
properties = {
style = GenericButtonSettings.Styles.FlatButton,
button_text = Engine.Localize( "@LUA_MENU_CONTROL_OPTIONS_CAPS" ),
options_category = "control_options"
},
handlers = {
button_over = OptionCategoryButtonOver,
button_action = OptionCategoryButtonAction
}
}
}
if Engine.IsMultiplayer() then
f59_local0[#f59_local0 + 1] = {
type = "UIGenericButton",
id = "voice_options_id",
disabledFunc = SinglePlayerDisabled,
properties = {
style = GenericButtonSettings.Styles.FlatButton,
button_text = Engine.Localize( "@LUA_MENU_VOICE_OPTIONS_CAPS" ),
options_category = "voice_options"
},
handlers = {
button_over = OptionCategoryButtonOver,
button_action = OptionCategoryButtonAction,
sp_voice_disable = SinglePlayerVoiceDisable
}
}
end
f59_local0[#f59_local0 + 1] = {
type = "UIGenericButton",
id = "optimal_video_and_audio_button_id",
properties = {
style = GenericButtonSettings.Styles.FlatButton,
button_text = Engine.Localize( "@LUA_MENU_OPTIMAL_VIDEO_AUDIO_CAPS" ),
options_category = "optimal_video_and_audio_button"
},
handlers = {
button_over = OptionCategoryButtonOver,
button_action = MBh.PopupMenu( "optimal_notice", false, false )
}
}
f59_local0[#f59_local0 + 1] = {
type = "UIGenericButton",
id = "manual_button_id",
properties = {
style = GenericButtonSettings.Styles.FlatButton,
button_text = Engine.Localize( "@LUA_MENU_GAME_MANUAL_CAPS" )
},
handlers = {
button_over = OptionCategoryButtonOver,
button_action = function ( f60_arg0, f60_arg1 )
local f60_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f60_arg0 )
f60_local0.currentOptionsCategory = nil
LUI.FlowManager.RequestAddMenu( f60_arg0, "game_manual", true, f60_arg1.controller, false )
end
}
}
return {
type = "UIElement",
id = "pc_controls_categories_id",
states = {
default = {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = false,
top = 120,
bottom = 620,
left = 130,
right = 420
}
},
handlers = {
options_categories_window_focus = MBh.EmitEvent( {
name = "gain_focus"
} ),
options_categories_window_unfocus = MBh.EmitEvent( "lose_focus" )
},
children = {
{
type = "generic_menu_background_withfade",
properties = {
top_offset = 0,
fill_alpha = 1,
border_alpha = 1
}
},
{
type = "UIElement",
id = "padding_id",
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
top = 6,
bottom = -6,
left = 6,
right = -6
}
},
children = {
{
type = "UIVerticalList",
id = "options_categories_vlist_id",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0,
spacing = 6
}
},
handlers = {
menu_create = LockCurrentButton
},
children = f59_local0
}
}
}
}
}
end
function pc_controls()
return {
type = "UIElement",
id = "pc_controls_id",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 0,
right = 0
}
},
handlers = {
menu_create = PCOptionsMainCreate,
menu_close = PCOptionsMainClose
},
children = {
{
type = "generic_menu_title",
id = "options_menu_title_id",
properties = {
menu_title = Engine.Localize( "@LUA_MENU_OPTIONS_CAPS" )
}
},
{
type = "pc_controls_window",
id = "pc_controls_window_id"
},
{
type = "pc_controls_categories",
id = "pc_controls_categories_id"
},
{
type = "button_helper_text_main",
id = "button_helper_text_id"
},
{
type = "brightness_guide",
id = "brightness_guide_id",
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
top = 330,
left = 575,
width = 255,
height = 255,
alpha = 0
},
visible = {
alpha = 1
}
},
properties = {
band_height = 85
}
},
{
type = "UIBindButton",
id = "back_button",
handlers = {
button_secondary = BackButtonAction
}
}
}
}
end
LUI.MenuBuilder.registerDef( "optimal_notice", optimal_notice )
LUI.MenuBuilder.registerDef( "reset_controls", reset_controls )
LUI.MenuBuilder.registerDef( "pc_controls", pc_controls )
LUI.MenuBuilder.registerDef( "pc_controls_categories", pc_controls_categories )
LUI.MenuBuilder.registerDef( "pc_controls_window", pc_controls_window )
LockTable( _M )