233 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			233 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
local f0_local0 = module
 | 
						|
local f0_local1, f0_local2 = ...
 | 
						|
f0_local0( f0_local1, package.seeall )
 | 
						|
CoD.PrintModuleLoad( _NAME )
 | 
						|
function GetDisplay( f1_arg0 )
 | 
						|
	return Engine.GetBinding( f1_arg0 )
 | 
						|
end
 | 
						|
 | 
						|
function bindKey( f2_arg0 )
 | 
						|
	Engine.BindKey( f2_arg0 )
 | 
						|
end
 | 
						|
 | 
						|
function OptionsWindowRefresh( f3_arg0, f3_arg1 )
 | 
						|
	if f3_arg1.source_input == "button_action" or f3_arg1.source_input == "key_bound" then
 | 
						|
		f3_arg0:processEvent( {
 | 
						|
			name = "menu_refresh"
 | 
						|
		} )
 | 
						|
		f3_arg0:processEvent( {
 | 
						|
			name = "refresh_content"
 | 
						|
		} )
 | 
						|
	end
 | 
						|
end
 | 
						|
 | 
						|
function OptionsWindowTriggerRefresh( f4_arg0, f4_arg1 )
 | 
						|
	f4_arg0:dispatchEventToRoot( {
 | 
						|
		name = "options_window_refresh",
 | 
						|
		source_input = f4_arg1.name,
 | 
						|
		immediate = true
 | 
						|
	} )
 | 
						|
end
 | 
						|
 | 
						|
function SinglePlayerDisableFunction( f5_arg0, f5_arg1 )
 | 
						|
	return not Engine.IsMultiplayer()
 | 
						|
end
 | 
						|
 | 
						|
function ControlBindFactory( f6_arg0, f6_arg1, f6_arg2 )
 | 
						|
	return {
 | 
						|
		type = "UIGenericButton",
 | 
						|
		id = "bind_" .. f6_arg0,
 | 
						|
		disabledFunc = f6_arg2 or function ()
 | 
						|
			return false
 | 
						|
		end
 | 
						|
		,
 | 
						|
		properties = {
 | 
						|
			variant = GenericButtonSettings.Variants.Info,
 | 
						|
			button_text = Engine.Localize( f6_arg0 ),
 | 
						|
			button_display_func = function ( f8_arg0, f8_arg1 )
 | 
						|
				return GetDisplay( f6_arg1 )
 | 
						|
			end
 | 
						|
			,
 | 
						|
			button_action_func = function ( f9_arg0, f9_arg1 )
 | 
						|
				Engine.BindKey( f6_arg1 )
 | 
						|
				OptionsWindowTriggerRefresh( f9_arg0, f9_arg1 )
 | 
						|
			end
 | 
						|
			
 | 
						|
		},
 | 
						|
		handlers = {
 | 
						|
			element_refresh = MBh.EmitEvent( "content_refresh" ),
 | 
						|
			key_bound = OptionsWindowTriggerRefresh
 | 
						|
		}
 | 
						|
	}
 | 
						|
end
 | 
						|
 | 
						|
function OptionFactoryProfileData( f10_arg0, f10_arg1, f10_arg2, f10_arg3, f10_arg4, f10_arg5 )
 | 
						|
	local f10_local0 = Engine.GetProfileData( f10_arg0 )
 | 
						|
	local f10_local1 = 1
 | 
						|
	for f10_local5, f10_local6 in pairs( f10_arg3 ) do
 | 
						|
		if f10_local6.value == f10_local0 then
 | 
						|
			f10_local1 = f10_local5
 | 
						|
			break
 | 
						|
		end
 | 
						|
	end
 | 
						|
	f10_local2 = function ( f11_arg0, f11_arg1 )
 | 
						|
		Engine.ExecNow( f10_arg1 )
 | 
						|
		Engine.ExecNow( "profile_menuDvarsFinish" )
 | 
						|
		OptionsWindowTriggerRefresh( f11_arg0, f11_arg1 )
 | 
						|
	end
 | 
						|
	
 | 
						|
	f10_local3 = {
 | 
						|
		type = "UIGenericButton",
 | 
						|
		id = "option_" .. f10_arg0,
 | 
						|
		disabledFunc = f10_arg4 or function ()
 | 
						|
			return false
 | 
						|
		end
 | 
						|
		
 | 
						|
	}
 | 
						|
	f10_local4 = {
 | 
						|
		variant = GenericButtonSettings.Variants.Select
 | 
						|
	}
 | 
						|
	if f10_arg5 then
 | 
						|
		local f10_local7 = f10_arg2
 | 
						|
	end
 | 
						|
	f10_local4.button_text = f10_local7 or Engine.Localize( f10_arg2 )
 | 
						|
	f10_local4.button_display_func = function ( f13_arg0, f13_arg1 )
 | 
						|
		return Engine.Localize( f10_arg3[f10_local1].text )
 | 
						|
	end
 | 
						|
	
 | 
						|
	f10_local4.button_left_func = function ( f14_arg0, f14_arg1 )
 | 
						|
		f10_local1 = 1 + (#f10_arg3 + f10_local1 - 1 - 1) % #f10_arg3
 | 
						|
		f10_local2( f14_arg0, f14_arg1 )
 | 
						|
	end
 | 
						|
	
 | 
						|
	f10_local4.button_right_func = function ( f15_arg0, f15_arg1 )
 | 
						|
		f10_local1 = 1 + (f10_local1 - 1 + 1) % #f10_arg3
 | 
						|
		f10_local2( f15_arg0, f15_arg1 )
 | 
						|
	end
 | 
						|
	
 | 
						|
	f10_local3.properties = f10_local4
 | 
						|
	f10_local3.handlers = {
 | 
						|
		element_refresh = MBh.EmitEvent( "content_refresh" )
 | 
						|
	}
 | 
						|
	return f10_local3
 | 
						|
end
 | 
						|
 | 
						|
function OptionsFeeder( f16_arg0 )
 | 
						|
	local f16_local0 = {}
 | 
						|
	Engine.ExecNow( "profile_menuDvarsSetup" )
 | 
						|
	f16_local0[#f16_local0 + 1] = OptionFactoryProfileData( "leanEnabled", "profile_toggleLean", "@LUA_MENU_LEAN_TOGGLE", {
 | 
						|
		{
 | 
						|
			text = "@LUA_MENU_ENABLED",
 | 
						|
			value = true
 | 
						|
		},
 | 
						|
		{
 | 
						|
			text = "@LUA_MENU_DISABLED",
 | 
						|
			value = false
 | 
						|
		}
 | 
						|
	} )
 | 
						|
	f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_FIRE_WEAPON", "+attack" )
 | 
						|
	f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_AIM_DOWN_THE_SIGHT", "+toggleads_throw" )
 | 
						|
	f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_HOLD_AIM_DOWN_SIGHT", "+speed_throw" )
 | 
						|
	f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_RELOAD_WEAPON", "+reload" )
 | 
						|
	f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_SWITCH_WEAPON", "weapnext" )
 | 
						|
	f16_local0[#f16_local0 + 1] = ControlBindFactory( "@PLATFORM_MELEEZOOM", "+melee_zoom" )
 | 
						|
	f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_USE", "+activate" )
 | 
						|
	f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_FRAG_EQUIPMENT", "+frag" )
 | 
						|
	f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_THROW_SPECIAL_GRENADE", "+smoke" )
 | 
						|
	if SinglePlayerDisableFunction() then
 | 
						|
		f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_WEAPON_ATTACHMENT", "+actionslot 3" )
 | 
						|
		f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_INVENTORY_KILLSTREAK", "+actionslot 4" )
 | 
						|
		f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_NVG_WATCH", "+actionslot 1" )
 | 
						|
	else
 | 
						|
		f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_KILLSTREAK_REWARD_SLOT_1", "+actionslot 4" )
 | 
						|
		f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_KILLSTREAK_REWARD_SLOT_2", "+actionslot 5" )
 | 
						|
		f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_KILLSTREAK_REWARD_SLOT_3", "+actionslot 6" )
 | 
						|
		f16_local0[#f16_local0 + 1] = ControlBindFactory( "@MENU_KILLSTREAK_REWARD_SLOT_4", "+actionslot 7" )
 | 
						|
		f16_local0[#f16_local0 + 1] = ControlBindFactory( Engine.IsAliensMode() and "ALIENS_UPGRADE_ABILITIES" or "@PLATFORM_UI_SHOW_SCORES", "togglescores" )
 | 
						|
	end
 | 
						|
	return f16_local0
 | 
						|
end
 | 
						|
 | 
						|
function OptionsMainCreate( f17_arg0, f17_arg1 )
 | 
						|
	f17_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addBackButton )
 | 
						|
end
 | 
						|
 | 
						|
function actions_controls_vlist()
 | 
						|
	return {
 | 
						|
		type = "UIScrollingVerticalList",
 | 
						|
		childrenFeeder = OptionsFeeder,
 | 
						|
		properties = {
 | 
						|
			use_arrows = true,
 | 
						|
			sendScrollEvents = true,
 | 
						|
			exclusiveController = MBh.Property( "exclusiveController" )
 | 
						|
		},
 | 
						|
		states = {
 | 
						|
			default = {
 | 
						|
				leftAnchor = true,
 | 
						|
				rightAnchor = false,
 | 
						|
				topAnchor = true,
 | 
						|
				bottomAnchor = false,
 | 
						|
				top = OptionsListDims.menu_top,
 | 
						|
				bottom = OptionsListDims.menu_bottom,
 | 
						|
				left = OptionsListDims.menu_left,
 | 
						|
				right = OptionsListDims.menu_right
 | 
						|
			}
 | 
						|
		},
 | 
						|
		handlers = {
 | 
						|
			options_window_refresh = OptionsWindowRefresh
 | 
						|
		}
 | 
						|
	}
 | 
						|
end
 | 
						|
 | 
						|
function actions_controls()
 | 
						|
	return {
 | 
						|
		type = "UIElement",
 | 
						|
		id = "actions_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 = function ( f20_arg0, f20_arg1 )
 | 
						|
				Engine.Exec( "updategamerprofile" )
 | 
						|
			end
 | 
						|
			
 | 
						|
		},
 | 
						|
		children = {
 | 
						|
			{
 | 
						|
				type = "generic_menu_title",
 | 
						|
				properties = {
 | 
						|
					menu_title = Engine.Localize( "@LUA_MENU_ACTIONS" )
 | 
						|
				}
 | 
						|
			},
 | 
						|
			{
 | 
						|
				type = "actions_controls_vlist",
 | 
						|
				id = "actions_cotnrols_vlist_id"
 | 
						|
			},
 | 
						|
			{
 | 
						|
				type = "button_helper_text_main",
 | 
						|
				id = "button_helper_text_id"
 | 
						|
			},
 | 
						|
			{
 | 
						|
				type = "UIBindButton",
 | 
						|
				handlers = {
 | 
						|
					button_secondary = MBh.LeaveMenu()
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
end
 | 
						|
 | 
						|
LUI.MenuBuilder.registerDef( "actions_controls_vlist", actions_controls_vlist )
 | 
						|
LUI.MenuBuilder.registerDef( "actions_controls", actions_controls )
 | 
						|
LockTable( _M )
 |