local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) CoD.PrintModuleLoad( _NAME ) function AILoadoutIconHandler( f1_arg0, f1_arg1, f1_arg2, f1_arg3, f1_arg4 ) if Engine.GetPlayerDataEx( f1_arg0.properties.controller, CoD.GetStatsGroupForGameMode(), f1_arg0.properties.squadLocation, Cac.GetEditSquadMember(), "ai_loadout" ) == f1_arg0.properties.slot then f1_arg0:animateToState( f1_arg1, f1_arg2 ) else f1_arg0:animateToState( f1_arg3, f1_arg4 ) end end function SetLoadoutIsFocused() local f2_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) f2_local0.isLoadoutFocused = true end function SetLoadoutNotFocused() local f3_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) f3_local0.isLoadoutFocused = false end function cac_purchase_loadout_popup() local f4_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) local f4_local1 = Cac.GetSquadMemberLoadoutUnlockCost( f4_local0.slot ) return { type = "generic_yesno_popup", properties = { popup_title = Engine.Localize( "@LUA_MENU_PURCHASE_CAPS" ), message_text = Engine.Localize( "@LUA_MENU_PURCHASE_LOADOUT", f4_local1 ), yes_action = function ( f5_arg0, f5_arg1 ) Cac.SetClassInUse( f5_arg1.controller, f4_local0.squadLocation, f4_local0.squadMemberIndex, f4_local0.classLocation, f4_local0.slot ) Cac.SetCurrency( f5_arg1.controller, Cac.GetCurrency( f5_arg1.controller ) - f4_local1 ) f5_arg0:dispatchEventToRoot( { name = "cac_update_currency_text" } ) f5_arg0:dispatchEventToRoot( { name = "cac_update_default_text_color", controller = f5_arg1.controller } ) Engine.PlaySound( CoD.SFX.CacSpendPoints ) LUI.FlowManager.RequestLeaveMenu( f5_arg0 ) end , no_action = MBh.LeaveMenu() } } end function cac_cant_purchase_loadout_popup() local f6_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) return { type = "generic_confirmation_popup", properties = { popup_title = Engine.Localize( "@LUA_MENU_PURCHASE_CAPS" ), message_text = Engine.Localize( "@LUA_MENU_UNABLE_TO_PURCHASE_LOADOUT", Cac.GetSquadMemberLoadoutUnlockCost( f6_local0.slot ) ), button_text = Engine.Localize( "@MENU_OK" ), confirmation_action = MBh.LeaveMenu() } } end function CacSlotButtonChildrenFeeder( f7_arg0 ) local f7_local0 = {} if SvS.IsSvS() and not Cac.IsDefaultClass( f7_arg0.classLocation ) then f7_local0[#f7_local0 + 1] = { type = "UIImage", id = "ai_loadout_image", properties = { slot = f7_arg0.slot, controller = f7_arg0.controller, squadLocation = f7_arg0.squadLocation }, states = { default = { material = RegisterMaterial( "icon_ai_loadout" ), leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 32, top = 0, bottom = 32, alpha = 0 }, button_up = { leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 32, top = 0, bottom = 32, alpha = 1 }, button_over = { leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 40, right = 72, top = 0, bottom = 32, alpha = 1 }, popped = { leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 32, right = 80, top = -8, bottom = 40, alpha = 1 } }, handlers = { menu_create = function ( f8_arg0, f8_arg1 ) AILoadoutIconHandler( f8_arg0, "button_up", 0, "default", 0 ) end, button_over = function ( f9_arg0, f9_arg1 ) AILoadoutIconHandler( f9_arg0, "button_over", 100, "default", 0 ) end, button_up = function ( f10_arg0, f10_arg1 ) AILoadoutIconHandler( f10_arg0, "button_up", 0, "default", 0 ) end, button_update_ai_loadout = function ( f11_arg0, f11_arg1 ) if f11_arg0:getParent() == f11_arg1.newActiveButton then Engine.SetPlayerDataEx( f11_arg1.controller, CoD.GetStatsGroupForGameMode(), f7_arg0.squadLocation, Cac.GetEditSquadMember(), "ai_loadout", f11_arg0.properties.slot ) local f11_local0 = MBh.AnimateSequence( { { "button_over", 0 }, { "popped", 50 }, { "button_over", 50 } } ) f11_local0( f11_arg0, f11_arg1 ) else f11_arg0:animateToState( "default", 0 ) end end } } end if Cac.IsDefaultClass( f7_arg0.classLocation ) then f7_local0[#f7_local0 + 1] = { type = "UIImage", id = "default_classes_selected_icon", states = Cac.GetActiveCharacterImageStates(), properties = f7_arg0, handlers = { update_class_in_use = function ( f12_arg0, f12_arg1 ) if f12_arg1.classLocation == f12_arg0.properties.classLocation and f12_arg1.slot == f12_arg0.properties.slot then if f12_arg1.inUse then local f12_local0 = MBh.AnimateSequence( { { "button_over", 0 }, { "popped", 50 }, { "button_over", 50 } } ) f12_local0( f12_arg0, f12_arg1 ) else f12_arg0:animateToState( "default" ) end end end, menu_create = function ( f13_arg0, f13_arg1 ) if Cac.IsClassInUse( f13_arg1.controller, f13_arg0.properties.squadLocation, f13_arg0.properties.squadMemberIndex, f13_arg0.properties.classLocation, f13_arg0.properties.slot ) then f13_arg0:animateToState( "button_up" ) else f13_arg0:animateToState( "default" ) end end, button_over = function ( f14_arg0, f14_arg1 ) local f14_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f14_arg0 ) if Cac.IsClassInUse( f14_arg1.controller, f14_arg0.properties.squadLocation, f14_arg0.properties.squadMemberIndex, f14_arg0.properties.classLocation, f14_arg0.properties.slot ) then f14_arg0:animateToState( "button_over" ) end end, button_up = function ( f15_arg0, f15_arg1 ) local f15_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f15_arg0 ) if Cac.IsClassInUse( f15_arg1.controller, f15_arg0.properties.squadLocation, f15_arg0.properties.squadMemberIndex, f15_arg0.properties.classLocation, f15_arg0.properties.slot ) then f15_arg0:animateToState( "button_up" ) end end } } end if MatchRules.AllowCustomClasses( f7_arg0.classLocation ) then f7_local0[#f7_local0 + 1] = { type = "UIImage", id = "weapon_restriction_icon", states = { default = { rightAnchor = true, leftAnchor = false, topAnchor = false, bottomAnchor = true, right = 32, bottom = -7, width = 32, height = 32, material = RegisterMaterial( "icon_new_3" ), alpha = 0 }, visible = { alpha = 1 } }, properties = f7_arg0, handlers = { hide_restrictions_icon = HideRestrictionsIcon, show_restrictions_icon = UpdateRestrictionsIcon, menu_create = UpdateRestrictionsIcon } } end if f7_arg0.slot >= Cac.Settings.DataLoc.loadouts.baseClassSlots and Cac.IsCaCSlotLocked( f7_arg0.controller, f7_arg0.squadLocation, f7_arg0.squadMemberIndex, f7_arg0.classLocation, f7_arg0.slot ) and not Cac.IsDefaultClass( f7_arg0.classLocation ) then local f7_local1, f7_local2, f7_local3, f7_local4 = GetTextDimensions( Cac.GetLoadoutName( f7_arg0.controller, f7_arg0.squadLocation, f7_arg0.squadMemberIndex, f7_arg0.classLocation, f7_arg0.slot ), CoD.TextSettings.NormalFont.Font, CoD.TextSettings.NormalFont.Height ) f7_local0[#f7_local0 + 1] = { type = "UIImage", id = "mdlc", states = { default = { material = RegisterMaterial( "icon_dlc" ), topAnchor = true, bottomAnchor = false, leftAnchor = false, rightAnchor = true, top = 7, height = 24, right = -(f7_local3 - f7_local1) - 60, width = 24, alpha = 0 }, visible = { alpha = 1 } }, handlers = { menu_create = MBh.AnimateSequence( { { "default", 200 }, { "visible", 150 } } ) } } end return f7_local0 end function UpdateRestrictionsIcon( f16_arg0, f16_arg1 ) local f16_local0 = f16_arg0:getParent() if MatchRules.AllowCustomClasses( f16_arg0.properties.classLocation ) then if MatchRules.CustomClassIsRestricted( f16_arg0.properties.controller, CoD.GetStatsGroupForGameMode(), f16_arg0.properties.squadLocation, f16_arg0.properties.squadMemberIndex, f16_arg0.properties.classLocation, f16_arg0.properties.slot ) then f16_arg0:animateToState( "visible" ) else f16_arg0:animateToState( "default" ) end end end function HideRestrictionsIcon( f17_arg0, f17_arg1 ) if MatchRules.AllowCustomClasses( f17_arg0.properties.classLocation ) then if MatchRules.CustomClassIsRestricted( f17_arg0.properties.controller, CoD.GetStatsGroupForGameMode(), f17_arg0.properties.squadLocation, f17_arg0.properties.squadMemberIndex, f17_arg0.properties.classLocation, f17_arg0.properties.slot ) then f17_arg0:dispatchEventToRoot( { name = "show_class_restrictions_warning", immediate = true } ) else f17_arg0:dispatchEventToRoot( { name = "hide_class_restrictions_warning", immediate = true } ) end f17_arg0:animateToState( "default" ) end end function LoadoutButtonUp( f18_arg0, f18_arg1 ) if not Cac.IsCaCSlotLocked( f18_arg0.properties.controller, f18_arg0.properties.squadLocation, f18_arg0.properties.squadMemberIndex, f18_arg0.properties.classLocation, f18_arg0.properties.slot ) then f18_arg0:processEvent( { name = "hide_new_icon" } ) end if MatchRules.AllowCustomClasses( f18_arg0.properties.classLocation ) then f18_arg0:processEvent( { name = "show_restrictions_icon" } ) end end function LoadoutButtonOver( f19_arg0, f19_arg1 ) local f19_local0 = f19_arg0.properties.controller local f19_local1 = LUI.FlowManager.GetMenuScopedDataFromElement( f19_arg0 ) SetLoadoutIsFocused() f19_local1.classLocation = f19_arg0.properties.classLocation f19_local1.currSlot = f19_arg0.properties.slot f19_arg0:dispatchEventToRoot( { name = "cac_set_slot", slot = f19_arg0.properties.slot, controller = f19_local0, dispatchChildren = true, classLocation = f19_arg0.properties.classLocation, immediate = true } ) f19_arg0:dispatchEventToRoot( { name = "update_cac_info_panel", controller = f19_local0, dispatchChildren = true, classLocation = f19_arg0.properties.classLocation } ) f19_arg0:dispatchEventToRoot( { name = "refresh_specialist_abilities_recap", controller = f19_local0, specialistType = Cac.GetPerk( f19_local0, f19_arg0.properties.squadLocation, f19_arg0.properties.squadMemberIndex, f19_arg0.properties.classLocation, f19_arg0.properties.slot, Cac.Indices.StreakType ) == "streaktype_specialist", selected = false, immediate = true } ) local f19_local2 = not Cac.IsCaCSlotLocked( f19_arg0.properties.controller, f19_arg0.properties.squadLocation, f19_arg0.properties.squadMemberIndex, f19_arg0.properties.classLocation, f19_arg0.properties.slot ) if f19_local2 then AddLoadoutSpecificButtonHelpers( f19_arg0, f19_arg1 ) else RemoveLoadoutSpecificButtonHelpers( f19_arg0, f19_arg1 ) end if f19_arg0.disabled and f19_local2 and not Cac.IsCaCSlotRestricted( f19_local0, f19_arg0.properties.squadLocation, f19_arg0.properties.squadMemberIndex, f19_arg0.properties.classLocation, f19_arg0.properties.slot ) then f19_arg0:processEvent( { name = "enable" } ) end if MatchRules.AllowCustomClasses( f19_arg0.properties.classLocation ) then f19_arg0:processEvent( { name = "hide_restrictions_icon" } ) end if f19_arg0.properties.slot >= Cac.Settings.DataLoc.loadouts.baseClassSlots then Cac.MarkItemNoMoreNewIcon( f19_local0, tostring( f19_arg0.properties.slot - Cac.Settings.DataLoc.loadouts.baseClassSlots + 1 ), "LoadoutSlot" ) f19_arg0:processEvent( { name = "hide_new_icon" } ) end if f19_local2 then if Cac.AnyUnseenMDLCItems( f19_local0, { "Camo", "Weapon_Primary", "Weapon_Secondary" } ) then f19_arg0:processEvent( { name = "show_new_icon" } ) end else f19_arg0:processEvent( { name = "hide_new_icon" } ) end local f19_local3 = Cac.GetSquadMemberLoadoutUnlockCost( f19_arg0.properties.slot ) if f19_local2 or f19_local3 <= 0 then f19_arg0:dispatchEventToRoot( { name = "hide_loadout_purchase_text", immediate = true } ) else f19_arg0:dispatchEventToRoot( { name = "show_loadout_purchase_text", immediate = true, cost = f19_local3 } ) end if SvS.IsSvS() then if f19_arg0.properties.slot > SvS.MaxAILoadoutIndex then f19_arg0:dispatchEventToRoot( { name = "show_extended_loadout_warning" } ) else f19_arg0:dispatchEventToRoot( { name = "hide_extended_loadout_warning" } ) end end end function CacSlotListChildrenFeeder( f20_arg0 ) local f20_local0 = {} local f20_local1 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) local f20_local2 = f20_arg0.exclusiveController if not f20_local2 then DebugPrint( "[WARNING] CAC: using controller index 0, this is only ok if you are editing a menu" ) f20_local2 = 0 end local f20_local3 = 1 local f20_local4 = 1 local f20_local5 = false if Cac.IsDefaultClass( f20_arg0.classLocation ) then f20_local5 = true f20_local4 = 2 + 1 end local f20_local6 = f20_arg0.classLocation local f20_local7 = f20_arg0.squadLocation local f20_local8 = f20_arg0.squadMemberIndex repeat if f20_local5 then f20_local4 = f20_local4 - 1 local f20_local9 = Cac.AddTeamName( "defaultClassesTeam" .. f20_local4, f20_local4 ) if f20_local9 ~= nil then f20_local0[#f20_local0 + 1] = f20_local9 end end for f20_local9 = 0, Cac.GetNumCustomSlots( f20_local2, f20_local6 ) - 1, 1 do local f20_local12 = f20_local9 if Cac.IsCaCSlotLocked( f20_local2, f20_local7, f20_local8, f20_local6, f20_local12 ) and f20_local12 >= Cac.Settings.DataLoc.loadouts.baseClassSlots and Engine.HasExtendedLoadouts( f20_local2 ) then Cac.SetClassInUse( f20_local2, f20_local7, f20_local8, f20_local6, f20_local12 ) local f20_local13 = false end local f20_local14 = function () local f21_local0 = Cac.GetLoadoutName( f20_local2, f20_local7, f20_local8, f20_local6, f20_local12 ) if (GetCurrentGameType() == "sd" or GetCurrentGameType() == "sr") and f20_local12 == 5 and f20_local5 then f21_local0 = Engine.Localize( "LUA_MENU_BOMB_CARRIER" ) end if GetCurrentGameType() == "infect" and f20_local12 == 1 and f20_local5 and f20_local4 == Teams.axis then f21_local0 = Engine.Localize( "LUA_MENU_INFECT_SPECIAL_CLASS" ) end return f21_local0 end local f20_local15 = f20_local14( class ) local f20_local16 = function () return Cac.IsCaCSlotLocked( f20_local2, f20_local7, f20_local8, f20_local6, f20_local12 ) or Cac.IsCaCSlotRestricted( f20_local2, f20_local7, f20_local8, f20_local6, f20_local12 ) end local f20_local17 if f20_local12 ~= f20_local1.slot or f20_local6 ~= f20_local1.classLocation then f20_local17 = false else f20_local17 = true end f20_local0[#f20_local0 + 1] = { type = "UIGenericButton", id = "class_" .. f20_local4 .. "_" .. f20_local12, disabled = f20_local16(), listDefaultFocus = f20_local17, properties = { isLoadoutButton = true, controller = f20_local2, button_text = f20_local15, allowDisabledAction = true, button_over_func = LoadoutButtonOver, button_over_disable_func = LoadoutButtonOver, button_up_func = LoadoutButtonUp, button_disable_func = LoadoutButtonUp, squadLocation = f20_local7, squadMemberIndex = f20_local8, classLocation = f20_local6, slot = f20_local12, currentTeam = f20_local4 }, handlers = { refresh_new_icons = function ( f23_arg0, f23_arg1 ) local f23_local0 = f23_arg0.properties local f23_local1 = f23_local0.slot >= Cac.Settings.DataLoc.loadouts.baseClassSlots local f23_local2 = Cac.IsCaCSlotLocked( f23_local0.controller, f23_local0.squadLocation, f23_local0.squadMemberIndex, f23_local0.classLocation, f23_local0.slot ) if f23_local1 and Cac.ItemHasNewIcon( f23_local0.controller, tostring( f23_arg0.properties.slot - Cac.Settings.DataLoc.loadouts.baseClassSlots + 1 ), "LoadoutSlot" ) then f23_arg0:processEvent( { name = "flash_new_icon" } ) end end, update_loadout_name = function ( f24_arg0, f24_arg1 ) if f24_arg1.loadoutIndex == f20_local12 and f24_arg1.classLocation == f24_arg0.properties.classLocation then f24_arg0:setText( f24_arg1.newName ) end end, focus_loadout = function ( f25_arg0, f25_arg1 ) f25_arg0.listDefaultFocus = f25_arg1.loadoutIndex == f20_local12 end }, childrenFeeder = CacSlotButtonChildrenFeeder, properties = function ( f26_arg0, f26_arg1 ) local f26_local0 = Cac.GetCurrency( f26_arg1.controller ) if Cac.Settings.DataLoc[f26_arg0.properties.classLocation].baseClassSlots <= f26_arg0.properties.slot then if Engine.IsPC() then Sns.OpenStoreMenu( f26_arg1.controller ) else Sns.OpenStoreLinkConfirmPopup( f26_arg1.controller, Engine.TableLookup( UnlockTable.File, UnlockTable.Cols.ItemId, "extraslots", UnlockTable.Cols.DLCOffer ) ) end elseif f26_local0 < Cac.GetSquadMemberLoadoutUnlockCost( f26_arg0.properties.slot ) then LUI.FlowManager.RequestPopupMenu( f26_arg0, "cac_cant_purchase_loadout_popup", true, f26_arg1.controller, false, f20_arg0 ) else LUI.FlowManager.RequestPopupMenu( f26_arg0, "cac_purchase_loadout_popup", true, f26_arg1.controller, false, f20_arg0 ) end end, properties = function ( f27_arg0, f27_arg1 ) local f27_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) f27_local0.currTeam = f27_arg0.properties.currentTeam local f27_local1 = f27_arg0:getParent() f27_local1:processEvent( { name = "disable" } ) f27_arg0:dispatchEventToRoot( { name = "cac_recap_slide_left", immediate = true } ) f27_arg0:dispatchEventToRoot( { name = "squad_move_left", immediate = true } ) f27_arg0:dispatchEventToRoot( { name = "update_header_text", string = f20_local14( f27_arg0 ), immediate = true } ) f27_arg0:dispatchEventToRoot( { name = "cac_update_currency_text", immediate = true } ) end } if GetCurrentGameType() == "infect" and Cac.IsDefaultClass( f20_local6 ) and (not (f20_local4 ~= Teams.allies or f20_local12 ~= 0) or f20_local4 == Teams.axis and f20_local12 == 1) then break end end if not IsCurrentGameTypeteamBased() then else end until not f20_local5 or f20_local5 and f20_local4 == 1 if not Cac.IsDefaultClass( f20_arg0.classLocation ) then local f20_local9, f20_local10, f20_local11, f20_local12 = GetTextDimensions( Engine.Localize( "@LUA_MENU_PURCHASE_COLON" ), CoD.TextSettings.NormalFont.Font, CoD.TextSettings.NormalFont.Height ) local f20_local13 = 16 local f20_local14 = 16 local f20_local15 = 32 local f20_local16 = 8 local f20_local17 = 10 f20_local0[#f20_local0 + 1] = { type = "UIElement", id = "button_spacer", states = { default = { topAnchor = true, leftAnchor = true, bottomAnchor = false, rightAnchor = false, top = 0, left = 0, height = 10, width = 100 } } } f20_local0[#f20_local0 + 1] = { type = "UIHorizontalList", id = "loadout_locked_for_purchase_hl", states = { default = { topAnchor = true, leftAnchor = true, bottomAnchor = false, rightAnchor = false, top = 0, left = 100, height = CoD.TextSettings.NormalFont.Height, width = 300, alpha = 0 }, visible = { alpha = 1 } }, handlers = { show_loadout_purchase_text = function ( f28_arg0, f28_arg1 ) local f28_local0 = f28_arg0:getChildById( "loadout_locked_for_purchase_cost_text" ) f28_local0:setText( f28_arg1.cost ) f28_arg0:animateToState( "visible" ) end, hide_loadout_purchase_text = function ( f29_arg0, f29_arg1 ) f29_arg0:animateToState( "default" ) end }, children = { { type = "UIImage", id = "left_bullet_point", states = { default = { topAnchor = true, leftAnchor = true, bottomAnchor = false, rightAnchor = false, top = 3, left = 100, height = 13, width = 5, material = RegisterMaterial( "white" ), alpha = 0.6 } } }, { type = "UIElement", id = "loadout_locked_for_purchase_spacer1", states = { default = { topAnchor = true, leftAnchor = true, bottomAnchor = true, rightAnchor = false, top = 0, left = 0, width = f20_local16 } } }, { type = "UIText", id = "loadout_locked_for_purchase_text", properties = { text = Engine.Localize( "@LUA_MENU_PURCHASE_COLON" ) }, states = { default = { topAnchor = true, leftAnchor = false, bottomAnchor = true, rightAnchor = true, top = 0, right = 0, width = f20_local11 - f20_local9, font = CoD.TextSettings.NormalFont.Font, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b, alignment = LUI.Alignment.Right } } }, { type = "UIElement", id = "loadout_locked_for_purchase_spacer2", states = { default = { topAnchor = true, leftAnchor = true, bottomAnchor = true, rightAnchor = false, top = 0, left = 0, width = f20_local17 } } }, { type = "UIImage", id = "loadout_locked_for_purchase_image", states = { default = { topAnchor = false, leftAnchor = false, bottomAnchor = false, rightAnchor = false, top = -f20_local13 * 0.5, left = -f20_local14 * 0.5, height = f20_local13, width = f20_local14, material = RegisterMaterial( "icon_unlock_token_active" ) } } }, { type = "UIText", id = "loadout_locked_for_purchase_cost_text", properties = { text = "" }, states = { default = { topAnchor = true, leftAnchor = false, bottomAnchor = true, rightAnchor = true, top = 0, right = 0, width = f20_local15, font = CoD.TextSettings.NormalFont.Font, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b, alignment = LUI.Alignment.Left } } } } } if SvS.IsSvS() then f20_local0[#f20_local0 + 1] = { type = "UIElement", id = "loadout_locked_for_ai_spacer", states = { default = { topAnchor = true, leftAnchor = true, bottomAnchor = false, rightAnchor = true, top = 0, right = 0, height = 10 } } } f20_local0[#f20_local0 + 1] = { type = "UIElement", id = "loadout_locked_for_ai_container", states = { default = { material = RegisterMaterial( "white" ), topAnchor = true, leftAnchor = true, bottomAnchor = false, rightAnchor = true, top = 0, left = 0, right = 0, height = 32, alpha = 0 }, visible = { alpha = 1 } }, handlers = { show_extended_loadout_warning = function ( f30_arg0, f30_arg1 ) f30_arg0:animateToState( "visible" ) end, hide_extended_loadout_warning = function ( f31_arg0, f31_arg1 ) f31_arg0:animateToState( "default" ) end }, children = { { type = "UIImage", id = "loadout_locked_for_ai_icon", states = { default = { material = RegisterMaterial( "icon_new" ), topAnchor = true, leftAnchor = true, bottomAnchor = false, rightAnchor = false, top = -6, left = 93, height = 32, width = 32 } } }, { type = "UIText", id = "loadout_locked_for_ai_text", properties = { text = Engine.Localize( "PATCH_MENU_EXTRA_LOADOUT_NO_AI" ) }, states = { default = { topAnchor = true, leftAnchor = true, bottomAnchor = false, rightAnchor = false, top = 0, left = 125, width = 300, height = CoD.TextSettings.NormalFont.Height, font = CoD.TextSettings.NormalFont.Font, red = Cac.Swatches.warning_text.r, green = Cac.Swatches.warning_text.g, blue = Cac.Swatches.warning_text.b, alignment = LUI.Alignment.Left } } } } } end end return f20_local0 end function IsLoadoutFocused() local f32_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) return f32_local0.isLoadoutFocused end function ChangeNameAction( f33_arg0, f33_arg1 ) if not IsLoadoutFocused() then return end local f33_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) local f33_local1 = f33_arg0:getParent() local f33_local2 = f33_local1.properties.exclusiveController local f33_local3 = f33_local1.properties.squadLocation local f33_local4 = f33_local1.properties.squadMemberIndex local f33_local5 = f33_local1.properties.classLocation if f33_local0 and f33_local0.slot then if Cac.IsCaCSlotLocked( f33_local2, f33_local3, f33_local4, f33_local5, f33_local0.slot ) then Engine.PlaySound( CoD.SFX.DenySelect ) else Engine.PlaySound( CoD.SFX.MouseClick ) local f33_local6 = Cac.GetLoadoutName( f33_local2, f33_local3, f33_local1.properties.squadMemberIndex, f33_local0.classLocation, f33_local0.slot ) LUI.UIRoot.BlockButtonInput( Engine.GetLuiRoot(), true, "OpenKeyboard" ) local f33_local7 = Engine.OpenScreenKeyboard local f33_local8 = f33_local2 local f33_local9 = Engine.Localize( "@LUA_MENU_ENTER_NAME" ) local f33_local10 = f33_local6 or "" local f33_local11 = 15 local f33_local12 = true local f33_local13 = IsOnlineMatch() if f33_local13 then f33_local13 = Cac.IsDefaultClass( f33_local0.classLocation ) end f33_local7( f33_local8, f33_local9, f33_local10, f33_local11, f33_local12, f33_local13 ) end end end function CopyLoadoutAction( f34_arg0, f34_arg1 ) if not IsLoadoutFocused() then return end local f34_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) local f34_local1 = {} local f34_local2 = f34_arg0:getParent() f34_local1.controller = f34_arg1.controller f34_local1.squadLocation = f34_local2.properties.squadLocation f34_local1.squadMemberIndex = f34_local2.properties.squadMemberIndex f34_local1.classLocation = f34_local0.classLocation f34_local1.slot = f34_local0.slot local f34_local3 = not Cac.IsCaCSlotLocked( f34_local1.controller, f34_local1.squadLocation, f34_local1.squadMemberIndex, f34_local1.classLocation, f34_local1.slot ) if GetCurrentGameType() == "infect" and Cac.IsDefaultClass( f34_local1.classLocation ) then return elseif not f34_local3 then Engine.PlaySound( CoD.SFX.DenySelect ) else LUI.FlowManager.RequestPopupMenu( f34_arg0, "copy_loadout_popup", true, f34_arg1.controller, false, f34_local1 ) end end function OnNameChangeComplete( f35_arg0, f35_arg1 ) local f35_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) local f35_local1 = f35_arg0:getParent() local f35_local2 = f35_arg1.text LUI.UIRoot.BlockButtonInput( Engine.GetLuiRoot(), false, "CloseKeyboard" ) if f35_local0 and f35_local0.slot and f35_local2 then if Cac.IsDefaultClass( f35_local1.properties.classLocation ) then MatchRules.SetData( "defaultClasses", Cac.Settings.DataLoc[f35_local0.classLocation].teamName, f35_local0.slot, "class", "name", f35_local2 ) else Cac.SetCacConfig( f35_local1.properties.exclusiveController, f35_local1.properties.squadLocation, f35_local1.properties.squadMemberIndex, f35_local0.classLocation, f35_local0.slot, "name", f35_local2 ) end f35_arg0:dispatchEventToRoot( { name = "update_loadout_name", newName = f35_local2, loadoutIndex = f35_local0.slot, classLocation = f35_local0.classLocation, immediate = true } ) end end function OnSelectSquadMemberAction( f36_arg0, f36_arg1 ) local f36_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_main" ) if f36_local0.allowMemberSwap then f36_arg0:dispatchEventToRoot( { name = "switch_to_member_select", immediate = true, controller = f36_arg1.controller } ) end end function cac_class_vlist() return { type = "UIVerticalList", focusable = true, states = { default = { alignment = LUI.Alignment.Top, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = GenericMenuDims.menu_left, right = GenericMenuDims.menu_right, top = GenericMenuDims.menu_top, bottom = GenericMenuDims.menu_bottom + 90 } } } end function AltButtonAction( f38_arg0, f38_arg1 ) local f38_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f38_arg0 ) local f38_local1 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) if not Cac.IsDefaultClass( f38_local0.classLocation ) then local f38_local2 = f38_arg0:getParent() f38_local2.properties.alternateCacMenus = not f38_local2.properties.alternateCacMenus LUI.FlowManager.RequestAddMenu( f38_arg0, "cac_customize_main", true, f38_arg1.controller, false, { squadLocation = f38_local2.properties.squadLocation, classLocation = f38_local2.properties.classLocation, squadMemberIndex = f38_local2.properties.squadMemberIndex, alternateCacMenus = f38_local2.properties.alternateCacMenus, allowMemberSwap = f38_local2.properties.allowMemberSwap, loadout_slot = f38_local1.slot } ) LUI.FlowManager.RequestLeaveMenuByName( "cac_main" ) LUI.FlowManager.RequestLeaveMenuByName( "cac_edit_main" ) else local f38_local2 = not Cac.IsClassInUse( f38_arg1.controller, f38_local0.squadLocation, f38_local0.squadMemberIndex, f38_local0.classLocation, f38_local0.currSlot ) Cac.SetClassInUse( f38_arg1.controller, f38_local0.squadLocation, f38_local0.squadMemberIndex, f38_local0.classLocation, f38_local0.currSlot, f38_local2 ) local f38_local3 = f38_arg0:getParent() f38_local3:processEvent( { name = "update_class_in_use", classLocation = f38_local0.classLocation, slot = f38_local0.currSlot, inUse = f38_local2 } ) end end function cac_customize_char_btn_handlers() return { type = "UIBindButton", id = "customize_char_button", states = { default = { leftAnchor = false, rightAnchor = true, topAnchor = false, bottomAnchor = true, left = -200, right = 0, top = -50, bottom = 0 } }, handlers = { button_alt1 = AltButtonAction, button_alt2 = OnSelectSquadMemberAction, button_shoulderr = ChangeNameAction, button_shoulderl = CopyLoadoutAction, text_input_complete = OnNameChangeComplete, button_start = function ( f40_arg0, f40_arg1 ) if not IsLoadoutFocused() then return end local f40_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_main" ) if SvS.IsSvS() and not Cac.IsDefaultClass( f40_local0.classLocation ) then local f40_local1 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_main" ) if Cac.IsCaCSlotLocked( f40_arg1.controller, f40_local0.squadLocation, f40_local0.squadMemberIndex, f40_local0.classLocation, f40_local1.slot ) or f40_local1.slot > SvS.MaxAILoadoutIndex then Engine.PlaySound( CoD.SFX.DenySelect ) else Engine.PlaySound( CoD.SFX.CacSetAILoadout ) local f40_local2 = f40_arg0:getParent() f40_local2:processEvent( { name = "update_ai_loadout", controller = f40_arg1.controller } ) end end end } } end function AddLoadoutSpecificButtonHelpers( f41_arg0, f41_arg1 ) local f41_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_main" ) local f41_local1 = Cac.IsDefaultClass( f41_arg0.properties.classLocation ) if not f41_local1 or GetCurrentGameType() ~= "infect" then f41_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_shoulderl", helper_text = Engine.Localize( "@LUA_MENU_COPY" ), side = "left", clickable = true, immediate = true } ) end f41_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_shoulderr", helper_text = Engine.Localize( "@LUA_MENU_EDIT_LOADOUT_NAME" ), side = "left", clickable = true, immediate = true } ) if SvS.IsSvS() and not f41_local1 then if f41_arg0.properties.slot > SvS.MaxAILoadoutIndex then f41_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_start", helper_text = "", side = "left", immediate = true } ) else f41_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_start", helper_text = Engine.Localize( "@LUA_MENU_SET_AI_LOADOUT" ), side = "left", clickable = true, immediate = true } ) end end end function RemoveLoadoutSpecificButtonHelpers( f42_arg0, f42_arg1 ) f42_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_shoulderl", helper_text = "", side = "left", immediate = true } ) f42_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_shoulderr", helper_text = "", side = "left", immediate = true } ) f42_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_start", helper_text = "", side = "left", immediate = true } ) end function SquadListOnCreate( f43_arg0, f43_arg1 ) local f43_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_main" ) f43_local0.allowMemberSwap = f43_arg0.properties.allowMemberSwap f43_arg0:processEvent( { name = "squad_move_right" } ) f43_arg0:processEvent( { name = "refresh_new_icons", immediate = true } ) f43_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_alt2", helper_text = "", side = "left", immediate = true } ) f43_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_alt1", helper_text = "", side = "left", immediate = true } ) f43_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_shoulderl", helper_text = "", side = "left", immediate = true } ) f43_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_shoulderr", helper_text = "", side = "left", immediate = true } ) f43_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_start", helper_text = "", side = "left", immediate = true } ) f43_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_secondary", helper_text = Engine.Localize( "@LUA_MENU_BACK" ), side = "left", clickable = true, immediate = true, ignorePopups = true } ) if not Cac.IsDefaultClass( f43_local0.classLocation ) then f43_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_alt1", helper_text = Engine.Localize( "@LUA_MENU_CUSTOMIZE_CHAR" ), side = "left", clickable = true, immediate = true } ) if f43_local0.allowMemberSwap then f43_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_alt2", helper_text = Engine.Localize( "@LUA_MENU_SELECT_SQUAD_MEMBER" ), side = "left", clickable = true, immediate = true } ) end else f43_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_alt1", helper_text = Engine.Localize( "PATCH_MENU_TOGGLE_DEFAULT_LOADOUT" ), side = "left", clickable = true, immediate = true } ) end AddLoadoutSpecificButtonHelpers( f43_arg0 ) end function SquadListOnClose( f44_arg0, f44_arg1 ) f44_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_alt2", helper_text = "", side = "left", immediate = true } ) f44_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_alt1", helper_text = "", side = "left", immediate = true, clickable = true } ) f44_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_shoulderl", helper_text = "", side = "left", immediate = true } ) f44_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_shoulderr", helper_text = "", side = "left", immediate = true } ) f44_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_start", helper_text = "", side = "left", immediate = true } ) end function CacExitFunction( f45_arg0, f45_arg1 ) if f45_arg0.properties.alternateCacMenus then LUI.FlowManager.RequestAddMenu( f45_arg0, "cac_customize_main", true, f45_arg1.controller, true, { squadLocation = f45_arg0.properties.squadLocation, classLocation = f45_arg0.properties.classLocation, squadMemberIndex = f45_arg0.properties.squadMemberIndex } ) else LUI.FlowManager.RequestLeaveMenu( f45_arg0, true ) end end function cac_main() return { type = "UIElement", id = "cac_root", states = { default = { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = -600, right = -600 }, onScreen = { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = 0, right = 0 }, hiddenLeft = { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = -600, right = -600 } }, properties = { slot = 0, classLocation = "loadouts", alternateCacMenus = false, squadLocation = "privateMatchSquadMembers", squadMemberIndex = 0, allowMemberSwap = false }, handlers = { cac_exit = CacExitFunction, squad_move_left = MBh.AnimateToStateWithEvent( "hiddenLeft", 125 ), squad_move_right = MBh.AnimateToState( "onScreen", 125 ), transition_complete_hiddenLeft = MBh.LeaveMenu( false ), menu_create = SquadListOnCreate, menu_close = SquadListOnClose, focus_loadout = function ( f47_arg0, f47_arg1 ) f47_arg0:clearSavedState() end }, children = { { type = "cac_class_vlist", id = "create_squad_list", properties = { slot = MBh.Property( "slot" ), classLocation = MBh.Property( "classLocation" ), alternateCacMenus = MBh.Property( "alternateCacMenus" ), squadLocation = MBh.Property( "squadLocation" ), squadMemberIndex = MBh.Property( "squadMemberIndex" ) }, handlers = { update_ai_loadout = function ( f48_arg0, f48_arg1 ) local f48_local0 = f48_arg0:getFirstChild() while f48_local0 do if f48_local0.properties.isLoadoutButton and f48_local0:isInFocus() then f48_arg0:dispatchEventToChildren( { name = "button_update_ai_loadout", controller = f48_arg1.controller, newActiveButton = f48_local0 } ) break end f48_local0 = f48_local0:getNextSibling() end end }, childrenFeeder = CacSlotListChildrenFeeder }, { type = "cac_customize_warning", states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 5, right = 0, top = 610, bottom = 0, alpha = 0 }, visible = { alpha = 1 } }, properties = { text_offset = 6, additional_handlers = { menu_create = function ( f49_arg0, f49_arg1 ) local f49_local0 = f49_arg0:getParent() f49_local0 = f49_local0.properties.exclusiveController if not f49_local0 then f49_local0 = Engine.GetFirstActiveController() end local f49_local1 = {} for f49_local5, f49_local6 in ipairs( Cac.Customization.Fields ) do if f49_local6.UnlockType then table.insert( f49_local1, f49_local6.UnlockType ) end end if Cac.AnyUnseenMDLCItems( f49_local0, f49_local1 ) then f49_arg0:processEvent( { name = "show_warning", text = Engine.Localize( "LUA_MENU_NEW_ITEM_AVAILABLE" ), style = 2 } ) end end } } }, { type = "UIBindButton", id = "back_button_to_old_menu", handlers = { button_secondary = MBh.EmitEventToRoot( { name = "cac_exit", dispatchChildren = true } ) } }, { type = "cac_customize_char_btn_handlers", id = "button_handlers_id" } } } end LUI.MenuBuilder.registerDef( "cac_main", cac_main ) LUI.MenuBuilder.registerDef( "cac_class_vlist", cac_class_vlist ) LUI.MenuBuilder.registerDef( "cac_customize_char_btn_handlers", cac_customize_char_btn_handlers ) LUI.MenuBuilder.registerDef( "cac_purchase_loadout_popup", cac_purchase_loadout_popup ) LUI.MenuBuilder.registerDef( "cac_cant_purchase_loadout_popup", cac_cant_purchase_loadout_popup ) LockTable( _M )