local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) CoD.PrintModuleLoad( _NAME ) function GamepadDisabledFunc( f1_arg0, f1_arg1 ) return not Engine.GetProfileData( "gpadEnabled" ) end function OptionsWindowRefresh( f2_arg0, f2_arg1 ) if f2_arg1.source_input == "button_action" or f2_arg1.source_input == "key_bound" or f2_arg1.source_input == "button_right" or f2_arg1.source_input == "button_left" then f2_arg0:processEvent( { name = "menu_refresh" } ) f2_arg0:processEvent( { name = "refresh_content" } ) end end function SinglePlayerDisableFunction( f3_arg0, f3_arg1 ) return not Engine.IsMultiplayer() end function OptionsWindowTriggerRefresh( f4_arg0, f4_arg1 ) f4_arg0:dispatchEventToRoot( { name = "options_window_refresh", source_input = f4_arg1.name, immediate = true } ) end function OptionFactoryProfileData( f5_arg0, f5_arg1, f5_arg2, f5_arg3, f5_arg4, f5_arg5, f5_arg6 ) local f5_local0 = Engine.GetProfileData( f5_arg0 ) local f5_local1 = 1 for f5_local5, f5_local6 in pairs( f5_arg3 ) do if f5_local6.value == f5_local0 then f5_local1 = f5_local5 break end end f5_local2 = function ( f6_arg0, f6_arg1 ) Engine.ExecNow( f5_arg1 ) Engine.ExecNow( "profile_menuDvarsFinish" ) OptionsWindowTriggerRefresh( f6_arg0, f6_arg1 ) if f5_arg6 and type( f5_arg6 ) == "function" then f5_arg6( f6_arg0 ) end end f5_local3 = { type = "UIGenericButton", id = "option_" .. f5_arg0, disabledFunc = f5_arg4 or function () return false end } f5_local4 = { variant = GenericButtonSettings.Variants.Select } if f5_arg5 then local f5_local7 = f5_arg2 end f5_local4.button_text = f5_local7 or Engine.Localize( f5_arg2 ) f5_local4.button_display_func = function ( f8_arg0, f8_arg1 ) return Engine.Localize( f5_arg3[f5_local1].text ) end f5_local4.button_left_func = function ( f9_arg0, f9_arg1 ) f5_local1 = 1 + (#f5_arg3 + f5_local1 - 1 - 1) % #f5_arg3 f5_local2( f9_arg0, f9_arg1 ) end f5_local4.button_right_func = function ( f10_arg0, f10_arg1 ) f5_local1 = 1 + (f5_local1 - 1 + 1) % #f5_arg3 f5_local2( f10_arg0, f10_arg1 ) end f5_local3.properties = f5_local4 f5_local3.handlers = { element_refresh = MBh.EmitEvent( "content_refresh" ) } return f5_local3 end function SliderOptionFactory( f11_arg0, f11_arg1, f11_arg2, f11_arg3, f11_arg4, f11_arg5 ) local f11_local0 = function ( f12_arg0, f12_arg1, f12_arg2, f12_arg3, f12_arg4 ) Engine.SetDvarFloat( f11_arg0, math.min( f12_arg1, math.max( f12_arg0, Engine.GetDvarFloat( f11_arg0 ) + f12_arg2 ) ) ) Engine.ExecNow( "profile_menuDvarsFinish" ) OptionsWindowTriggerRefresh( f12_arg3, f12_arg4 ) end return { type = "UIGenericButton", id = "options_" .. f11_arg0, disabledFunc = f11_arg5 or function () return false end , properties = { button_text = Engine.Localize( f11_arg1 ), variant = GenericButtonSettings.Variants.Slider, button_display_func = function ( f14_arg0, f14_arg1 ) return (Engine.GetDvarFloat( f11_arg0 ) - f11_arg2) / (f11_arg3 - f11_arg2) end , button_left_func = function ( f15_arg0, f15_arg1 ) f11_local0( f11_arg2, f11_arg3, -f11_arg4, f15_arg0, f15_arg1 ) end , button_right_func = function ( f16_arg0, f16_arg1 ) f11_local0( f11_arg2, f11_arg3, f11_arg4, f16_arg0, f16_arg1 ) end }, handlers = { element_refresh = MBh.EmitEvent( "content_refresh" ) } } end function GetButtonsLayoutName() local f17_local0 = Engine.GetProfileData( "gpadButtonsConfig" ) if f17_local0 == "buttons_default" then return Engine.Localize( "@MENU_DEFAULT" ) elseif f17_local0 == "buttons_tactical" then return Engine.Localize( "@MENU_TACTICAL" ) elseif f17_local0 == "buttons_lefty" then return Engine.Localize( "@MENU_LEFTY" ) elseif f17_local0 == "buttons_nomad" then return Engine.Localize( "@MENU_NOMAD" ) elseif f17_local0 == "buttons_nomad_tactical" then return Engine.Localize( "@MENU_NOMAD_TACTICAL" ) elseif f17_local0 == "buttons_default_alt" then return Engine.Localize( "@MENU_DEFAULT_ALT" ) elseif f17_local0 == "buttons_tactical_alt" then return Engine.Localize( "@MENU_TACTICAL_ALT" ) elseif f17_local0 == "buttons_lefty_alt" then return Engine.Localize( "@MENU_LEFTY_ALT" ) elseif f17_local0 == "buttons_nomad_alt" then return Engine.Localize( "@MENU_NOMAD_ALT" ) else return Engine.Localize( "@MENU_NOMAD_TACTICAL_ALT" ) end end function ButtonsLayoutAction( f18_arg0, f18_arg1 ) LUI.FlowManager.RequestAddMenu( f18_arg0, "buttons", true, f18_arg1.controller, false ) end function GetSticksLayoutName() local f19_local0 = Engine.GetProfileData( "gpadSticksConfig" ) if f19_local0 == "thumbstick_default" then return Engine.Localize( "@MENU_DEFAULT" ) elseif f19_local0 == "thumbstick_southpaw" then return Engine.Localize( "@MENU_SOUTHPAW" ) elseif f19_local0 == "thumbstick_legacy" then return Engine.Localize( "@MENU_LEGACY" ) elseif f19_local0 == "thumbstick_southpaw_ns" then return Engine.Localize( "@MENU_SOUTHPAW_NS" ) elseif f19_local0 == "thumbstick_legacysouthpaw_ns" then return Engine.Localize( "@MENU_LEGACY_SOUTHPAW_NS" ) else return Engine.Localize( "@MENU_LEGACY_SOUTHPAW" ) end end function SticksLayoutAction( f20_arg0, f20_arg1 ) LUI.FlowManager.RequestAddMenu( f20_arg0, "thumbstick", true, f20_arg1.controller, false ) end function GetSensitivityText() local f21_local0 = Engine.GetDvarFloat( "profileMenuOption_sensitivity" ) if f21_local0 == 1 then return Engine.Localize( "@MENU_LOW" ) .. " " .. f21_local0 elseif f21_local0 == 3 then return Engine.Localize( "@MENU_MEDIUM" ) .. " " .. f21_local0 elseif f21_local0 == 7 then return Engine.Localize( "@MENU_HIGH" ) .. " " .. f21_local0 elseif f21_local0 == 13 then return Engine.Localize( "@MENU_VERY_HIGH" ) .. " " .. f21_local0 elseif f21_local0 == 20 then return Engine.Localize( "@MENU_INSANE" ) .. " " .. f21_local0 else return f21_local0 .. "" end end function SensitivityChange( f22_arg0, f22_arg1 ) Engine.SetDvarFloat( "profileMenuOption_sensitivity", math.min( 20, math.max( 1, Engine.GetDvarFloat( "profileMenuOption_sensitivity" ) + f22_arg1 ) ) ) Engine.MenuDvarsFinish( f22_arg0 ) end function OnToggleGPadEnabled( f23_arg0 ) LUI.FlowManager.tryAddMouseCursor( Engine.GetLuiRoot() ) Engine.Exec( "updategamerprofile" ) f23_arg0:dispatchEventToRoot( { name = "refresh_button_helper", dispatchChildren = true } ) end function OptionsFeeder( f24_arg0 ) local f24_local0 = {} Engine.ExecNow( "profile_menuDvarsSetup" ) f24_local0[#f24_local0 + 1] = OptionFactoryProfileData( "gpadEnabled", "profile_toggleEnableGamepad", "LUA_MENU_GAMEPAD", { { text = "@LUA_MENU_DISABLED", value = false }, { text = "@LUA_MENU_ENABLED", value = true } }, nil, nil, OnToggleGPadEnabled ) f24_local0[#f24_local0 + 1] = { type = "UIGenericButton", id = "stick_layout_button_id", disabledFunc = GamepadDisabledFunc, properties = { variant = GenericButtonSettings.Variants.Info, button_text = Engine.Localize( "MENU_THUMBSTICK_LAYOUT" ), button_display_func = GetSticksLayoutName, button_action_func = SticksLayoutAction } } f24_local0[#f24_local0 + 1] = { type = "UIGenericButton", id = "buttons_layout_button_id", disabledFunc = GamepadDisabledFunc, properties = { variant = GenericButtonSettings.Variants.Info, button_text = Engine.Localize( "MENU_BUTTON_LAYOUT" ), button_display_func = GetButtonsLayoutName, button_action_func = ButtonsLayoutAction } } f24_local0[#f24_local0 + 1] = OptionFactoryProfileData( "invertedPitch", "profile_toggleInvertedPitch", "MENU_LOOK_INVERSION", { { text = "@LUA_MENU_DISABLED", value = false }, { text = "@LUA_MENU_ENABLED", value = true } }, GamepadDisabledFunc ) f24_local0[#f24_local0 + 1] = { type = "UIGenericButton", id = "sensitivity_button_id", disabledFunc = GamepadDisabledFunc, properties = { variant = GenericButtonSettings.Variants.Select, button_text = Engine.Localize( "MENU_LOOK_SENSITIVITY" ), button_display_func = GetSensitivityText, button_left_func = function ( f25_arg0, f25_arg1 ) return SensitivityChange( f24_arg0.exclusiveController, -1 ) end, button_right_func = function ( f26_arg0, f26_arg1 ) return SensitivityChange( f24_arg0.exclusiveController, 1 ) end } } f24_local0[#f24_local0 + 1] = OptionFactoryProfileData( "rumble", "profile_toggleRumble", "MENU_CONTROLLER_VIBRATION", { { text = "@LUA_MENU_DISABLED", value = false }, { text = "@LUA_MENU_ENABLED", value = true } }, GamepadDisabledFunc ) if SinglePlayerDisableFunction() then f24_local0[#f24_local0 + 1] = OptionFactoryProfileData( "autoAim", "profile_toggleAutoAim", "MENU_AIM_ASSIST", { { text = "@LUA_MENU_DISABLED", value = false }, { text = "@LUA_MENU_ENABLED", value = true } }, GamepadDisabledFunc ) end f24_local0[#f24_local0 + 1] = OptionFactoryProfileData( "leanEnabled", "profile_toggleLean", "LUA_MENU_LEAN_TOGGLE", { { text = "@LUA_MENU_ENABLED", value = true }, { text = "@LUA_MENU_DISABLED", value = false } }, GamepadDisabledFunc ) if Engine.IsDevelopmentBuild() then f24_local0[#f24_local0 + 1] = OptionFactoryProfileData( "useDevKeyboard", "profile_toggleDevKeyboard", "DEBUG_KEYBOARD", { { text = "@LUA_MENU_DISABLED", value = false }, { text = "@LUA_MENU_ENABLED", value = true } }, GamepadDisabledFunc, true ) end return f24_local0 end function OptionsMainCreate( f27_arg0, f27_arg1 ) f27_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addBackButton ) end function OptionsMainClose( f28_arg0, f28_arg1 ) Engine.Exec( "updategamerprofile" ) end function gamepad_controls_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 } }, handlers = {} } end function gamepad_controls() return { type = "UIElement", id = "gamepad_controls_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_GAMEPAD" ) } }, { type = "gamepad_controls_vlist", id = "gamepad_controls_vlist_id" }, { type = "button_helper_text_main", id = "button_helper_text_id" }, { type = "UIBindButton", id = "back_button", handlers = { button_secondary = MBh.LeaveMenu() } } } } end LUI.MenuBuilder.registerDef( "gamepad_controls_vlist", gamepad_controls_vlist ) LUI.MenuBuilder.registerDef( "gamepad_controls", gamepad_controls ) LockTable( _M )