local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) CoD.PrintModuleLoad( _NAME ) function SinglePlayerDisableFunction( f1_arg0, f1_arg1 ) return not Engine.IsMultiplayer() end function GetDisplay( f2_arg0 ) return Engine.GetBinding( f2_arg0 ) end function bindKey( f3_arg0 ) Engine.BindKey( f3_arg0 ) end function OptionsWindowRefresh( f4_arg0, f4_arg1 ) if f4_arg1.source_input == "button_action" or f4_arg1.source_input == "key_bound" then f4_arg0:processEvent( { name = "menu_refresh" } ) f4_arg0:processEvent( { name = "refresh_content" } ) end end function OptionsWindowTriggerRefresh( f5_arg0, f5_arg1 ) f5_arg0:dispatchEventToRoot( { name = "options_window_refresh", source_input = f5_arg1.name, immediate = true } ) end function ControlBindFactory( f6_arg0, f6_arg1 ) return { type = "UIGenericButton", id = "bind_" .. f6_arg1, properties = { variant = GenericButtonSettings.Variants.Info, button_text = Engine.Localize( f6_arg0 ), button_display_func = function ( f7_arg0, f7_arg1 ) return GetDisplay( f6_arg1 ) end , button_action_func = function ( f8_arg0, f8_arg1 ) Engine.BindKey( f6_arg1 ) OptionsWindowTriggerRefresh( f8_arg0, f8_arg1 ) end }, handlers = { element_refresh = MBh.EmitEvent( "content_refresh" ), key_bound = OptionsWindowTriggerRefresh } } end function OptionFactory( f9_arg0, f9_arg1, f9_arg2 ) local f9_local0 = nil local f9_local1 = 1 local f9_local2 = Engine.GetDvarType( f9_arg0 ) if f9_local2 == DvarTypeTable.DvarString then f9_local0 = Engine.GetDvarString( f9_arg0 ) elseif f9_local2 == DvarTypeTable.DvarInt then f9_local0 = Engine.GetDvarInt( f9_arg0 ) elseif f9_local2 == DvarTypeTable.DvarBool then f9_local0 = Engine.GetDvarBool( f9_arg0 ) end for f9_local6, f9_local7 in pairs( f9_arg2 ) do if f9_local7.value == f9_local0 then f9_local1 = f9_local6 break end end f9_local3 = function ( f10_arg0, f10_arg1 ) if f9_arg0 == "ui_mousePitch" then if Engine.GetDvarBool( f9_arg0 ) then Engine.SetDvarFloat( "m_pitch", MousePitchTable.PitchFloat ) else Engine.SetDvarFloat( "m_pitch", -MousePitchTable.PitchFloat ) end end if f9_local2 == DvarTypeTable.DvarString then Engine.SetDvarString( f9_arg0, f9_arg2[f9_local1].value ) elseif f9_local2 == DvarTypeTable.DvarInt then Engine.SetDvarInt( f9_arg0, f9_arg2[f9_local1].value ) elseif f9_local2 == DvarTypeTable.DvarBool then Engine.SetDvarBool( f9_arg0, f9_arg2[f9_local1].value ) end end return { type = "UIGenericButton", id = "option_" .. f9_arg0, properties = { variant = GenericButtonSettings.Variants.Select, button_text = Engine.Localize( f9_arg1 ), button_display_func = function ( f11_arg0, f11_arg1 ) return Engine.Localize( f9_arg2[f9_local1].text ) end , button_left_func = function ( f12_arg0, f12_arg1 ) f9_local1 = 1 + (#f9_arg2 + f9_local1 - 1 - 1) % #f9_arg2 f9_local3( f12_arg0, f12_arg1 ) end , button_right_func = function ( f13_arg0, f13_arg1 ) f9_local1 = 1 + (f9_local1 - 1 + 1) % #f9_arg2 f9_local3( f13_arg0, f13_arg1 ) end } } end function SliderOptionFactory( f14_arg0, f14_arg1, f14_arg2, f14_arg3, f14_arg4, f14_arg5, f14_arg6 ) local f14_local0 = function ( f15_arg0, f15_arg1, f15_arg2 ) Engine.SetDvarFloat( f14_arg0, math.min( f15_arg1, math.max( f15_arg0, Engine.GetDvarFloat( f14_arg0 ) + f15_arg2 ) ) ) Engine.ExecNow( "profile_menuDvarsFinish" ) end return { type = "UIGenericButton", id = "options_" .. f14_arg0, properties = { button_text = Engine.Localize( f14_arg1 ), variant = GenericButtonSettings.Variants.Slider, button_display_func = function ( f16_arg0, f16_arg1 ) return (Engine.GetDvarFloat( f14_arg0 ) - f14_arg2) / (f14_arg3 - f14_arg2) end , button_left_func = function ( f17_arg0, f17_arg1 ) f14_local0( f14_arg2, f14_arg3, -f14_arg4 ) end , button_right_func = function ( f18_arg0, f18_arg1 ) f14_local0( f14_arg2, f14_arg3, f14_arg4 ) end , button_over_func = MBh.EmitEventToRoot( "brightness_over" ), button_up_func = MBh.EmitEventToRoot( "brightness_up" ) } } end function OptionsFeeder( f19_arg0 ) local f19_local0 = {} local f19_local1 = {} Engine.ExecNow( "profile_menuDvarsSetup" ) f19_local0[#f19_local0 + 1] = SliderOptionFactory( "sensitivity", "@MENU_MOUSE_SENSITIVITY", SliderBounds.MouseSensitivity.Min, SliderBounds.MouseSensitivity.Max, SliderBounds.MouseSensitivity.Step ) if SinglePlayerDisableFunction() then f19_local1 = { { text = "@LUA_MENU_YES", value = true }, { text = "@LUA_MENU_NO", value = false } } else f19_local1 = { { text = "@LUA_MENU_YES", value = "1" }, { text = "@LUA_MENU_NO", value = "0" } } end f19_local0[#f19_local0 + 1] = OptionFactory( "ui_mousePitch", "@MENU_INVERT_MOUSE", f19_local1 ) f19_local0[#f19_local0 + 1] = OptionFactory( "m_filter", "@MENU_SMOOTH_MOUSE", { { text = "@LUA_MENU_YES", value = true }, { text = "@LUA_MENU_NO", value = false } } ) f19_local0[#f19_local0 + 1] = OptionFactory( "cl_freelook", "@MENU_FREE_LOOK", { { text = "@LUA_MENU_YES", value = true }, { text = "@LUA_MENU_NO", value = false } } ) f19_local0[#f19_local0 + 1] = ControlBindFactory( "@MENU_LOOK_UP", "+lookup" ) f19_local0[#f19_local0 + 1] = ControlBindFactory( "@MENU_LOOK_DOWN", "+lookdown" ) f19_local0[#f19_local0 + 1] = ControlBindFactory( "@MENU_HOLD_MOUSE_LOOK", "+mlook" ) f19_local0[#f19_local0 + 1] = ControlBindFactory( "@MENU_CENTER_VIEW", "centerview" ) return f19_local0 end function OptionsMainCreate( f20_arg0, f20_arg1 ) f20_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addBackButton ) end function OptionsMainClose( f21_arg0, f21_arg1 ) Engine.ExecNow( "profile_menuDvarsFinish" ) Engine.Exec( "updategamerprofile" ) end function look_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 = { options_window_refresh = OptionsWindowRefresh } } end function look_controls() return { type = "UIElement", id = "look_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 }, 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_LOOK" ) } }, { type = "look_controls_vlist", id = "look_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( "look_controls_vlist", look_controls_vlist ) LUI.MenuBuilder.registerDef( "look_controls", look_controls ) LockTable( _M )