local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) CoD.PrintModuleLoad( _NAME ) f0_local0 = function ( f1_arg0, f1_arg1 ) local f1_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_weapon_attach_choose_main" ) local f1_local1 = f1_local0.attachName unlockItem( f1_arg1.controller, Cac.GetAttachmentUnlockName( f1_local1, Cac.GetWeapon( f1_arg1.controller, f1_local0.squadLocation, f1_local0.squadMemberIndex, f1_local0.classLocation, f1_local0.slot, f1_local0.weaponIndex ) ) ) Engine.PlaySound( CoD.SFX.CacSpendPoints ) f1_arg0:dispatchEventToRoot( { name = "cac_update_currency_text", immediate = true } ) f1_arg0:dispatchEventToRoot( { name = "update_cac_info_panel", controller = f1_arg1.controller, dispatchChildren = true, immediate = true } ) local f1_local2 = Cac.GetAttachments( f1_arg1.controller, f1_local0.squadLocation, f1_local0.squadMemberIndex, f1_local0.classLocation, f1_local0.slot, f1_local0.weaponIndex ) if Cac.AreAttachmentsCompatible( f1_local2[1], f1_local1 ) and Cac.AreAttachmentsCompatible( f1_local2[2], f1_local1 ) and Cac.AreAttachmentsCompatible( f1_local2[3], f1_local1 ) then setAttachment( f1_arg0, f1_arg1 ) else local f1_local3 = Cac.GetAttachmentClassInUse( f1_arg1.controller, f1_local0.squadLocation, f1_local0.squadMemberIndex, f1_local0.classLocation, f1_local0.slot, f1_local0.weaponIndex, Cac.GetAttachmentType( f1_local1 ) ) if f1_local3 then setAttachment( f1_arg0, f1_arg1, f1_local3 ) end end LUI.FlowManager.RequestLeaveMenu( f1_arg0, true ) end f0_local1 = function ( f2_arg0, f2_arg1 ) LUI.FlowManager.RequestLeaveMenu( f2_arg0 ) end function cac_cant_purchase_attach_popup() local f3_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_weapon_attach_choose_main" ) local f3_local1 = Cac.GetWeapon( f3_local0.controller, f3_local0.squadLocation, f3_local0.squadMemberIndex, f3_local0.classLocation, f3_local0.slot, f3_local0.weaponIndex ) local f3_local2 = Cac.GetAttachmentName( f3_local0.attachName, f3_local1 ) local f3_local3 = Cac.GetAttachmentImage( f3_local0.attachName, f3_local1 ) local f3_local4 = Cac.GetWeaponName( f3_local1 ) local f3_local5 = Engine.Localize( "@LUA_MENU_UNABLE_TO_PURCHASE_N", f3_local2 ) local f3_local6 = f3_local0.cost local f3_local7 = RegisterMaterial( "icon_unlock_token_active" ) return { type = "generic_yesno_with_image_popup", properties = { popup_title = Engine.Localize( "@LUA_MENU_PURCHASE_CAPS" ), message_image = RegisterMaterial( f3_local3 ), message_image_top = -15, message_image_left = 35, message_cost_text = Engine.Localize( "@LUA_MENU_COST" ), message_cost_image = f3_local7, message_cost = f3_local6, message_squad_points_text = Engine.Localize( "@LUA_MENU_CAC_COMMENDATIONS" ), message_squad_points_image = f3_local7, message_squad_points = f3_local0.currency, no_text = f3_local5, no_action = f0_local1 } } end function cac_purchase_attach_popup() local f4_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_weapon_attach_choose_main" ) local f4_local1 = Cac.GetWeapon( f4_local0.controller, f4_local0.squadLocation, f4_local0.squadMemberIndex, f4_local0.classLocation, f4_local0.slot, f4_local0.weaponIndex ) local f4_local2 = Cac.GetAttachmentName( f4_local0.attachName, f4_local1 ) local f4_local3 = Cac.GetAttachmentImage( f4_local0.attachName, f4_local1 ) local f4_local4 = Cac.GetWeaponName( f4_local1 ) local f4_local5 = Engine.Localize( "@LUA_MENU_PURCHASE_N", f4_local2 ) local f4_local6 = f4_local0.cost local f4_local7 = RegisterMaterial( "icon_unlock_token_active" ) return { type = "generic_yesno_with_image_popup", properties = { popup_title = Engine.Localize( "@LUA_MENU_PURCHASE_CAPS" ), message_image = RegisterMaterial( f4_local3 ), message_image_top = -15, message_image_left = 35, message_cost_text = Engine.Localize( "@LUA_MENU_COST" ), message_cost_image = f4_local7, message_cost = f4_local6, message_squad_points_text = Engine.Localize( "@LUA_MENU_CAC_COMMENDATIONS" ), message_squad_points_image = f4_local7, message_squad_points = f4_local0.currency, yes_text = f4_local5, no_text = Engine.Localize( "@LUA_MENU_CANCEL" ), yes_action = f0_local0, no_action = f0_local1 }, additional_handlers = { menu_create = function ( f5_arg0, f5_arg1 ) f5_arg0:setText( f5_arg0.properties.weapon ) end } } end function setAttachment( f6_arg0, f6_arg1, f6_arg2 ) local f6_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_weapon_attach_choose_main" ) local f6_local1 = Cac.AttachmentHasReticles( f6_local0.attachName ) local f6_local2 = Cac.GetReticleDefault( f6_local0.attachName ) local f6_local3 = Cac.GetFirstOpenAttachment( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex ) if f6_arg2 then Engine.PlaySound( CoD.SFX.MouseClick ) local f6_local4 = Cac.GetAttachment( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex, f6_arg2 ) local f6_local5 = f6_local4 == f6_local0.attachName if f6_local5 then Cac.SetAttachment( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex, f6_arg2, "none" ) else Cac.SetAttachment( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex, f6_arg2, f6_local0.attachName ) end if f6_local1 == true and not f6_local5 then Cac.ValidateReticle( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex ) elseif Cac.AttachmentHasReticles( f6_local4 ) then Cac.SetWeaponReticle( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex, Cac.Reticles.None ) end elseif f6_local3 then Engine.PlaySound( CoD.SFX.MouseClick ) Cac.SetAttachment( f6_arg1.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex, f6_local3, f6_local0.attachName ) if f6_local1 == true and Cac.GetReticle( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex ) == "none" then Cac.SetWeaponReticle( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex, f6_local2 ) end else Engine.PlaySound( CoD.SFX.DenySelect ) end Cac.ShuffleAttachmentsDown( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex, 0 ) f6_arg0:dispatchEventToRoot( { name = "change_attachment_lock", weaponIndex = f6_local0.weaponIndex, attachIndex = Cac.GetAttachmentClassInUse( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot, f6_local0.weaponIndex, Cac.GetAttachmentType( f6_local0.attachName ) ) } ) if f6_local0.weaponIndex == 0 then f6_arg0:dispatchEventToRoot( { name = "update_squad_member_window_weapon", weapon = Cac.BuildPrimaryWeaponName( f6_arg1.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot ) } ) elseif f6_local0.weaponIndex == 1 then f6_arg0:dispatchEventToRoot( { name = "update_squad_member_window_stowed_weapon", weapon = Cac.BuildSecondaryWeaponName( f6_arg1.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot ) } ) end local f6_local5 if f6_local0.attachName ~= "shotgun" and f6_local0.attachName ~= "gl" then f6_local5 = false else f6_local5 = true end if f6_arg2 or f6_local3 then f6_arg0:dispatchEventToRoot( { name = "update_cac_info_panel", controller = f6_arg1.controller, dispatchChildren = true, attachConflict = f6_local5 } ) end if (f6_local5 or Cac.GetAttachmentType( f6_local0.attachName ) == "undermount") and (f6_local3 or f6_arg2) then local f6_local6 = f6_arg0 local f6_local7 = f6_arg0.dispatchEventToRoot local f6_local8 = { name = "refresh_abilities_recap", controller = f6_arg1.controller, specialistType = false } local f6_local9 if Cac.GetPrimaryGrenade( f6_local0.controller, f6_local0.squadLocation, f6_local0.squadMemberIndex, f6_local0.classLocation, f6_local0.slot ) == "specialty_null" then f6_local9 = f6_local0.attachName else f6_local9 = false end f6_local8.item = f6_local9 f6_local7( f6_local6, f6_local8 ) end f6_arg0:dispatchEventToRoot( { name = "element_refresh", dispatchChildren = true } ) end function CacEditWeaponAttachChoose( f7_arg0, f7_arg1 ) local f7_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f7_arg0 ) local f7_local1 = f7_arg0.properties local f7_local2 = f7_local1.attachItem local f7_local3 = Cac.getAttachmentCost( f7_local2, f7_local1.weaponName ) local f7_local4 = Cac.GetCurrency( f7_arg1.controller ) f7_local0.cost = f7_local3 f7_local0.currency = f7_local4 local f7_local5 = Cac.GetAttachments( f7_arg1.controller, f7_local0.squadLocation, f7_local0.squadMemberIndex, f7_local0.classLocation, f7_local0.slot, f7_local0.weaponIndex ) local f7_local6 = Cac.AreAttachmentsCompatible( f7_local5[1], f7_local2 ) local f7_local7 = Cac.AreAttachmentsCompatible( f7_local5[2], f7_local2 ) local f7_local8 = Cac.AreAttachmentsCompatible( f7_local5[3], f7_local2 ) local f7_local9 = Cac.IsAttachmentUnlocked( f7_arg1.controller, f7_local0.squadLocation, f7_local0.squadMemberIndex, f7_local0.classLocation, f7_local0.slot, f7_local0.weaponIndex, f7_local2 ) f7_local0.attachName = f7_local2 if not f7_local9 then if f7_local3 <= f7_local4 then LUI.FlowManager.RequestPopupMenu( f7_arg0, "cac_purchase_attach_popup", true, f7_arg1.controller, false, f7_local1 ) else LUI.FlowManager.RequestPopupMenu( f7_arg0, "cac_cant_purchase_attach_popup", true, f7_arg1.controller, false, f7_local1 ) end return elseif f7_local6 and f7_local7 and f7_local8 then setAttachment( f7_arg0, f7_arg1 ) else local f7_local10 = Cac.GetAttachmentClassInUse( f7_arg1.controller, f7_local0.squadLocation, f7_local0.squadMemberIndex, f7_local0.classLocation, f7_local0.slot, f7_local0.weaponIndex, Cac.GetAttachmentType( f7_local2 ) ) if f7_local10 then setAttachment( f7_arg0, f7_arg1, f7_local10 ) else Engine.PlaySound( CoD.SFX.DenySelect ) end end end function CacEditWeaponAttachButtonOver( f8_arg0, f8_arg1 ) local f8_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f8_arg0 ) local f8_local1 = f8_arg0.properties local f8_local2 = f8_local0.controller assert( f8_local2, "Cac: No controller specified, something went wrong" ) local f8_local3 = f8_local0.squadLocation assert( f8_local3, "Cac: No squad location specified, something went wrong" ) local f8_local4 = f8_local0.classLocation assert( f8_local4, "Cac: No class location specified, something went wrong" ) local f8_local5 = f8_local0.slot if not f8_local5 then DebugPrint( "[WARNING] CAC: using cac slot index 0, this is only ok if you are editing a menu" ) f8_local5 = 0 end local f8_local6 = f8_local0.squadMemberIndex if not f8_local6 then DebugPrint( "[WARNING] CAC: using squad member index 0, this is only ok if you are editing a menu" ) f8_local6 = 0 end local f8_local7 = f8_local0.weaponIndex if not f8_local7 then DebugPrint( "[WARNING] CAC: using weapon index 0, this is only ok if you are editing a menu" ) f8_local7 = 0 end assert( f8_local0.attachIndex, "Cac: No attach index specified, something went wrong" ) f8_local0.attachmentOver = f8_local1.attachItem local f8_local8 = Cac.GetAttachments( f8_local0.controller, f8_local0.squadLocation, f8_local0.squadMemberIndex, f8_local0.classLocation, f8_local0.slot, f8_local0.weaponIndex ) local f8_local9 = Cac.GetAttachmentClassInUse( f8_local0.controller, f8_local0.squadLocation, f8_local0.squadMemberIndex, f8_local0.classLocation, f8_local0.slot, f8_local0.weaponIndex, Cac.GetAttachmentType( f8_local1.attachItem ) ) f8_arg0:dispatchEventToRoot( { name = "change_attachment_lock", weaponIndex = f8_local7, attachIndex = f8_local9, immediate = true } ) local f8_local10 = {} local f8_local11 = false local f8_local12 = Cac.GetAttachmentNumber( f8_local0.controller, f8_local0.squadLocation, f8_local0.squadMemberIndex, f8_local0.classLocation, f8_local0.slot, f8_local0.weaponIndex ) for f8_local13 = 1, f8_local12, 1 do if f8_local13 - 1 == f8_local9 then f8_local10[f8_local13] = f8_local1.attachItem f8_local11 = true end if f8_local8[f8_local13] == "none" and not f8_local11 then f8_local10[f8_local13] = f8_local1.attachItem break end f8_local10[f8_local13] = f8_local8[f8_local13] end f8_arg0:dispatchEventToRoot( { name = "refresh_info_pane", controller = f8_local2, classLocation = f8_local4, squadLocation = f8_local3, squadMemberIndex = f8_local6, slot = f8_local5, weaponIndex = f8_local7, viewingAttach0 = f8_local10[1], viewingAttach1 = f8_local10[2], viewingAttach2 = f8_local10[3], dispatchChildren = true, immediate = true } ) end function UpdateAttachmentButton( f9_arg0, f9_arg1 ) local f9_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f9_arg0 ) local f9_local1 = Cac.GetAttachment( f9_local0.controller, f9_local0.squadLocation, f9_local0.squadMemberIndex, f9_local0.classLocation, f9_local0.slot, f9_local0.weaponIndex, f9_local0.attachIndex ) local f9_local2 = Cac.IsAttachmentUnlocked( f9_local0.controller, f9_local0.squadLocation, f9_local0.squadMemberIndex, f9_local0.classLocation, f9_local0.slot, f9_local0.weaponIndex, f9_arg0.properties.attachItem ) local f9_local3 = Cac.GetAttachments( f9_local0.controller, f9_local0.squadLocation, f9_local0.squadMemberIndex, f9_local0.classLocation, f9_local0.slot, f9_local0.weaponIndex ) f9_arg0.properties.sameCategory = false if Cac.GetAttachmentClassInUse( f9_local0.controller, f9_local0.squadLocation, f9_local0.squadMemberIndex, f9_local0.classLocation, f9_local0.slot, f9_local0.weaponIndex, Cac.GetAttachmentType( f9_arg0.properties.attachItem ) ) then f9_arg0.properties.sameCategory = true end local f9_local4 if f9_local3[1] ~= f9_arg0.properties.attachItem and f9_arg0.properties.attachItem ~= f9_local3[2] and f9_arg0.properties.attachItem ~= f9_local3[3] then f9_local4 = false else f9_local4 = true end f9_arg0.properties.attachCompatible = Cac.AreAttachmentsCompatible( f9_local3[2], f9_arg0.properties.attachItem ) and Cac.AreAttachmentsCompatible( f9_local3[1], f9_arg0.properties.attachItem ) and Cac.AreAttachmentsCompatible( f9_local3[3], f9_arg0.properties.attachItem ) local f9_local5 = Cac.GetFirstOpenAttachment( f9_local0.controller, f9_local0.squadLocation, f9_local0.squadMemberIndex, f9_local0.classLocation, f9_local0.slot, f9_local0.weaponIndex ) if f9_local4 then f9_arg0:dispatchEventToChildren( { name = "button_unlocked" } ) f9_arg0:dispatchEventToChildren( { name = "button_tab_selected" } ) if f9_local0.attachmentOver == f9_arg0.properties.attachItem then f9_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.outline_over.a } ) else f9_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.outline_up.a } ) end f9_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", alpha = 0 } ) elseif not (not (not f9_arg0.properties.attachCompatible or not f9_local5) or f9_arg0.properties.sameCategory) or not f9_local2 then if not f9_local2 then f9_arg0:dispatchEventToChildren( { name = "button_locked" } ) else f9_arg0:dispatchEventToChildren( { name = "button_unlocked" } ) end f9_arg0:dispatchEventToChildren( { name = "button_icon_unfocused" } ) if (not f9_arg0.properties.attachCompatible or not f9_local5) and not f9_arg0.properties.sameCategory then if f9_local0.attachmentOver == f9_arg0.properties.attachItem then f9_arg0:dispatchEventToChildren( { name = "button_tab_focused_disabled" } ) f9_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.outline_over.a } ) else f9_arg0:dispatchEventToChildren( { name = "button_tab_unfocused_disabled" } ) f9_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.outline_up.a } ) end f9_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", alpha = 0 } ) else f9_arg0:dispatchEventToChildren( { name = "button_tab_unfocused" } ) f9_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.background_up.a } ) f9_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", alpha = 0 } ) end else f9_arg0:dispatchEventToChildren( { name = "button_unlocked" } ) f9_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", alpha = 0 } ) if f9_arg0:isInFocus() then f9_arg0:dispatchEventToChildren( { name = "button_tab_focused" } ) f9_arg0:dispatchEventToChildren( { name = "button_icon_focused" } ) f9_arg0:dispatchEventToChildren( { name = "button_bg_focused" } ) f9_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.background_over.a } ) else f9_arg0:dispatchEventToChildren( { name = "button_tab_unfocused" } ) f9_arg0:dispatchEventToChildren( { name = "button_icon_unfocused" } ) f9_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.background_up.a } ) end end end function HandleAttachmentButtonOver( f10_arg0, f10_arg1 ) local f10_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f10_arg0 ) local f10_local1 = Cac.GetAttachment( f10_local0.controller, f10_local0.squadLocation, f10_local0.squadMemberIndex, f10_local0.classLocation, f10_local0.slot, f10_local0.weaponIndex, f10_local0.attachIndex ) local f10_local2 = Cac.IsAttachmentUnlocked( f10_local0.controller, f10_local0.squadLocation, f10_local0.squadMemberIndex, f10_local0.classLocation, f10_local0.slot, f10_local0.weaponIndex, f10_arg0.properties.attachItem ) local f10_local3 if f10_local1 ~= f10_arg0.properties.attachItem and f10_arg0.properties.attachItem ~= Cac.GetAttachment( f10_local0.controller, f10_local0.squadLocation, f10_local0.squadMemberIndex, f10_local0.classLocation, f10_local0.slot, f10_local0.weaponIndex, (f10_local0.attachIndex + 1) % 3 ) and f10_arg0.properties.attachItem ~= Cac.GetAttachment( f10_local0.controller, f10_local0.squadLocation, f10_local0.squadMemberIndex, f10_local0.classLocation, f10_local0.slot, f10_local0.weaponIndex, (f10_local0.attachIndex + 2) % 3 ) then f10_local3 = false else f10_local3 = true end local f10_local4 = f10_arg0.properties.attachCompatible local f10_local5 = f10_arg0.properties.sameCategory local f10_local6 = Cac.GetFirstOpenAttachment( f10_local0.controller, f10_local0.squadLocation, f10_local0.squadMemberIndex, f10_local0.classLocation, f10_local0.slot, f10_local0.weaponIndex ) if f10_local3 then f10_arg0:dispatchEventToChildren( { name = "button_icon_focused" } ) f10_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.outline_over.a } ) f10_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", alpha = 0 } ) else f10_arg0:dispatchEventToChildren( { name = "button_icon_focused" } ) if (not f10_local4 or not f10_local6) and not f10_local5 then f10_arg0:dispatchEventToChildren( { name = "button_tab_focused_disabled" } ) f10_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.outline_over.a } ) f10_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", alpha = 0 } ) else f10_arg0:dispatchEventToChildren( { name = "button_tab_focused" } ) f10_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", alpha = 0 } ) f10_arg0:dispatchEventToChildren( { name = "button_bg_focused" } ) f10_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.background_over.a } ) end end if MatchRules.AllowCustomClasses( f10_local0.classLocation ) then if f10_arg0.restricted or f10_arg0.classRestricted then f10_arg0:dispatchEventToRoot( { name = "show_class_restrictions_warning", immediate = true } ) else f10_arg0:dispatchEventToRoot( { name = "hide_class_restrictions_warning", immediate = true } ) end end end function HandleAttachmentButtonUp( f11_arg0, f11_arg1 ) local f11_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f11_arg0 ) local f11_local1 = Cac.GetAttachment( f11_local0.controller, f11_local0.squadLocation, f11_local0.squadMemberIndex, f11_local0.classLocation, f11_local0.slot, f11_local0.weaponIndex, f11_local0.attachIndex ) local f11_local2 = Cac.IsAttachmentUnlocked( f11_local0.controller, f11_local0.squadLocation, f11_local0.squadMemberIndex, f11_local0.classLocation, f11_local0.slot, f11_local0.weaponIndex, f11_arg0.properties.attachItem ) local f11_local3 if f11_local1 ~= f11_arg0.properties.attachItem and f11_arg0.properties.attachItem ~= Cac.GetAttachment( f11_local0.controller, f11_local0.squadLocation, f11_local0.squadMemberIndex, f11_local0.classLocation, f11_local0.slot, f11_local0.weaponIndex, (f11_local0.attachIndex + 1) % 3 ) and f11_arg0.properties.attachItem ~= Cac.GetAttachment( f11_local0.controller, f11_local0.squadLocation, f11_local0.squadMemberIndex, f11_local0.classLocation, f11_local0.slot, f11_local0.weaponIndex, (f11_local0.attachIndex + 2) % 3 ) then f11_local3 = false else f11_local3 = true end local f11_local4 = f11_arg0.properties.attachCompatible local f11_local5 = f11_arg0.properties.sameCategory local f11_local6 = Cac.GetFirstOpenAttachment( f11_local0.controller, f11_local0.squadLocation, f11_local0.squadMemberIndex, f11_local0.classLocation, f11_local0.slot, f11_local0.weaponIndex ) if f11_local3 then f11_arg0:dispatchEventToChildren( { name = "button_icon_unfocused" } ) f11_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.outline_up.a } ) else f11_arg0:dispatchEventToChildren( { name = "button_icon_unfocused" } ) if (not f11_local4 or not f11_local6) and not f11_local5 then f11_arg0:dispatchEventToChildren( { name = "button_tab_unfocused_disabled" } ) f11_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.outline_up.a } ) f11_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", alpha = 0 } ) else f11_arg0:dispatchEventToChildren( { name = "button_tab_unfocused" } ) f11_arg0:dispatchEventToChildren( { name = "updateBackgroundOutlineColor", alpha = 0 } ) f11_arg0:dispatchEventToChildren( { name = "button_bg_unfocused" } ) f11_arg0:dispatchEventToChildren( { name = "updateBackgroundColor", red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = Cac.Selection.background_up.a } ) end end end function UpdateAttachmentText( f12_arg0, f12_arg1 ) f12_arg0:dispatchEventToRoot( { name = "update_attachment_text", attachment_name = Cac.GetAttachmentName( f12_arg0.properties.attachItem, f12_arg0.properties.weaponName ), attachment_desc = Cac.GetAttachmentDesc( f12_arg0.properties.attachItem, f12_arg0.properties.weaponName ), immediate = true } ) f12_arg0:dispatchEventToRoot( { name = "update_warning_text", attachment = f12_arg0.properties.attachItem, immediate = true } ) end function cac_attachment_button( menu, controller ) local self = LUI.UIButton.new() self.id = "generic_id" self.audio = { button_over = CoD.SFX.SubMenuMouseOver } self.properties = controller self:registerAnimationState( "default", { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 0, right = Cac.Layout.AttachmentChooseDims.SelectButton.width, top = 0, bottom = Cac.Layout.AttachmentChooseDims.SelectButton.height } ) self:animateToState( "default" ) self:registerEventHandler( "button_over", MBh.DoMultiple( { HandleAttachmentButtonOver, UpdateAttachmentText } ) ) self:registerEventHandler( "button_up", HandleAttachmentButtonUp ) self:registerEventHandler( "menu_create", function ( element, event ) UpdateAttachmentButton( element, event ) local f14_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( element ) if MatchRules.AllowCustomClasses( f14_local0.classLocation ) then local f14_local1, f14_local2 = Cac.SafeGetMatchRule( "commonOption", "attachmentRestricted", element.properties.attachItem ) if f14_local1 and f14_local2 then local f14_local3 = Cac.GetRestrictIcon( 0, 2, 28 ) f14_local3.id = "restrict_icon" .. element.properties.attachItem element:addElement( f14_local3 ) element.restricted = true else element.restricted = false end local f14_local3, f14_local4 = Cac.SafeGetMatchRule( "commonOption", "attachmentClassRestricted", Cac.GetAttachmentType( element.properties.attachItem ) ) if f14_local3 and f14_local4 then element.classRestricted = true else element.classRestricted = false end end end ) self:registerEventHandler( "element_refresh", UpdateAttachmentButton ) local f13_local1 = LUI.UIElement.new() f13_local1:registerAnimationState( "default", { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = 0, right = 0, alpha = 1 } ) f13_local1:registerAnimationState( "dim", { alpha = 0.8 } ) f13_local1:animateToState( "default" ) f13_local1:registerEventHandler( "button_bg_focused", MBh.AnimateLoop( { { "dim", 750, true, true }, { "default", 750 } } ) ) f13_local1:registerEventHandler( "button_bg_unfocused", MBh.AnimateToState( "default", 0 ) ) f13_local1:addElement( LUI.mp_menus.CacEditChooseImagePopup.cac_edit_choose_image_button_background( nil, { alpha = 0 } ) ) self:addElement( f13_local1 ) self:addElement( LUI.mp_menus.CacEditChooseImagePopup.cac_edit_choose_image_button_background_outline( nil, { alpha = 0 } ) ) local f13_local2 = LUI.UIImage.new() f13_local2:registerAnimationState( "default", { topAnchor = true, bottomAnchor = false, leftAnchor = true, rightAnchor = false, top = 0, bottom = 16, left = 0, right = 16, material = RegisterMaterial( "widg_triangle" ), alpha = 0 } ) f13_local2:registerAnimationState( "focused", { red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = 1 } ) f13_local2:registerAnimationState( "unfocused", { red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = 0 } ) f13_local2:registerAnimationState( "selected", { red = Colors.frontend_hilite.r, green = Colors.frontend_hilite.g, blue = Colors.frontend_hilite.b, alpha = 1 } ) f13_local2:registerAnimationState( "unselected", { red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = 0 } ) f13_local2:registerAnimationState( "focused_disabled", { material = RegisterMaterial( "widg_triangle_outline" ), alpha = Cac.Selection.outline_over.a } ) f13_local2:registerAnimationState( "unfocused_disabled", { material = RegisterMaterial( "widg_triangle" ), alpha = 0 } ) f13_local2:animateToState( "default" ) f13_local2:registerEventHandler( "button_tab_selected", MBh.AnimateToState( "selected", 0 ) ) f13_local2:registerEventHandler( "button_tab_unselected", MBh.AnimateToState( "unselected", 0 ) ) f13_local2:registerEventHandler( "button_tab_focused", MBh.AnimateToState( "focused", 0 ) ) f13_local2:registerEventHandler( "button_tab_unfocused", MBh.AnimateToState( "unfocused", 0 ) ) f13_local2:registerEventHandler( "button_tab_focused_disabled", MBh.AnimateToState( "focused_disabled", 0 ) ) f13_local2:registerEventHandler( "button_tab_unfocused_disabled", MBh.AnimateToState( "unfocused_disabled", 0 ) ) self:addElement( f13_local2 ) local f13_local3 = LUI.UIImage.new() f13_local3.id = "attachment_icon" local f13_local4 = { topAnchor = false, bottomAnchor = false, leftAnchor = false, rightAnchor = false, material = controller.image, width = 48, height = 48, alpha = 1 } f13_local3:registerAnimationState( "default", f13_local4 ) f13_local3:registerAnimationState( "selected", f13_local4 ) f13_local4.scale = 0.1 f13_local3:registerAnimationState( "focused", f13_local4 ) f13_local4.scale = 0 f13_local3:registerAnimationState( "unfocused", f13_local4 ) f13_local3:registerAnimationState( "focused_blocked", { alpha = 0.75 } ) f13_local3:registerAnimationState( "unfocused_blocked", { alpha = 0.25 } ) f13_local3:animateToState( "default" ) f13_local3:registerEventHandler( "button_icon_selected", MBh.AnimateToState( "selected", 0 ) ) f13_local3:registerEventHandler( "button_icon_focused", MBh.AnimateSequence( { { "unfocused", 0 }, { "focused", 100 }, { "unfocused", 100 } } ) ) f13_local3:registerEventHandler( "button_icon_unfocused", MBh.AnimateToState( "unfocused", 0 ) ) f13_local3:registerEventHandler( "button_icon_focused_blocked", MBh.AnimateToState( "focused_blocked", 0 ) ) f13_local3:registerEventHandler( "button_icon_unfocused_blocked", MBh.AnimateToState( "unfocused_blocked", 0 ) ) self:addElement( f13_local3 ) local f13_local5 = LUI.UIElement.new() f13_local5:registerAnimationState( "default", { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = 0, right = 0, alpha = 0 } ) f13_local5:registerAnimationState( "locked", { alpha = 1 } ) f13_local5:registerAnimationState( "unlocked", { alpha = 0 } ) f13_local5:animateToState( "default" ) f13_local5:registerEventHandler( "button_locked", MBh.AnimateToState( "locked", 0 ) ) f13_local5:registerEventHandler( "button_unlocked", MBh.AnimateToState( "unlocked", 0 ) ) local f13_local6 = LUI.UIElement.new() f13_local6:registerAnimationState( "default", { topAnchor = false, bottomAnchor = true, leftAnchor = true, rightAnchor = true, bottom = 0, left = 2, right = 0, height = 20, alpha = 1 } ) f13_local6:animateToState( "default" ) local f13_local7 = LUI.UIImage.new() f13_local7:registerAnimationState( "default", { topAnchor = false, bottomAnchor = false, leftAnchor = true, rightAnchor = false, material = RegisterMaterial( "icon_unlock_token_active" ), left = 0, width = 16, height = 16 } ) f13_local7:animateToState( "default" ) f13_local6:addElement( f13_local7 ) local f13_local8 = LUI.UIText.new() f13_local8:setText( tostring( controller.unlockCost ) ) f13_local8:registerAnimationState( "default", CoD.ColorizeState( Colors.white, { topAnchor = false, bottomAnchor = false, leftAnchor = true, rightAnchor = true, left = 16, right = 0, height = CoD.TextSettings.TinyFont.Height, font = CoD.TextSettings.SmallFont.Font, alignment = LUI.Alignment.Left } ) ) f13_local8:animateToState( "default" ) f13_local6:addElement( f13_local8 ) f13_local5:addElement( f13_local6 ) self:addElement( f13_local5 ) return self end function attachment_decription() local f15_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_weapon_attach_choose_main" ) return { type = "UIElement", id = "attachment_decription_id", states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 460, right = 0, top = 480, bottom = 0 } }, children = { { type = "UIText", id = "window_title", properties = { text = "" }, states = { default = { font = CoD.TextSettings.BigFont.Font, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = -CoD.TextSettings.BigFont.Height / 2, bottom = CoD.TextSettings.BigFont.Height / 2 } }, handlers = { update_attachment_text = function ( f16_arg0, f16_arg1 ) f16_arg0:setText( f16_arg1.attachment_name ) end } }, { type = "UIText", id = "description_text", properties = { text = "" }, states = { default = { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 0, right = 300, top = GenericTitleBarDims.TitleBarHeight, bottom = GenericTitleBarDims.TitleBarHeight + CoD.TextSettings.NormalFont.Height, red = Colors.cac_border.r, green = Colors.cac_border.g, blue = Colors.cac_border.b } }, handlers = { update_attachment_text = function ( f17_arg0, f17_arg1 ) f17_arg0:setText( f17_arg1.attachment_desc ) end } }, { type = "UIImage", id = "warning_exclamation", states = { default = { topAnchor = true, bottomAnchor = false, leftAnchor = true, rightAnchor = false, top = GenericTitleBarDims.TitleBarHeight + CoD.TextSettings.NormalFont.Height * 4, left = -18, width = 32, height = 32, material = RegisterMaterial( "icon_new" ), alpha = 0 } }, handlers = { update_warning_text = function ( f18_arg0, f18_arg1 ) local f18_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f18_arg0 ) if (f18_arg1.attachment == "shotgun" or f18_arg1.attachment == "gl") and Cac.GetPrimaryGrenade( f18_local0.controller, f18_local0.squadLocation, f18_local0.squadMemberIndex, f18_local0.classLocation, f18_local0.slot ) ~= "specialty_null" then local f18_local1 = f18_arg0:getParent() f18_local1 = f18_local1:getChildById( "description_text" ) local f18_local2, f18_local3 = f18_local1:getElementTextDims() f18_arg0:registerAnimationState( "visible", { topAnchor = true, bottomAnchor = false, leftAnchor = true, rightAnchor = false, top = GenericTitleBarDims.TitleBarHeight + f18_local3 + 9, left = -18, width = 32, height = 32, alpha = 1 } ) f18_arg0:animateToState( "visible" ) else f18_arg0:animateToState( "default" ) end end } }, { type = "UIText", id = "warning_text", properties = { text = Engine.Localize( "@LUA_MENU_UNDER_BARREL_WARNING" ) }, states = { default = CoD.ColorizeState( Cac.Swatches.warning_text, { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 20, right = 300, top = GenericTitleBarDims.TitleBarHeight + CoD.TextSettings.NormalFont.Height * 4, bottom = GenericTitleBarDims.TitleBarHeight + CoD.TextSettings.NormalFont.Height * 5, alpha = 0 } ) }, handlers = { update_warning_text = function ( f19_arg0, f19_arg1 ) local f19_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f19_arg0 ) if (f19_arg1.attachment == "shotgun" or f19_arg1.attachment == "gl") and Cac.GetPrimaryGrenade( f19_local0.controller, f19_local0.squadLocation, f19_local0.squadMemberIndex, f19_local0.classLocation, f19_local0.slot ) ~= "specialty_null" then local f19_local1 = f19_arg0:getParent() f19_local1 = f19_local1:getChildById( "description_text" ) local f19_local2, f19_local3 = f19_local1:getElementTextDims() f19_arg0:registerAnimationState( "visible", { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 20, right = 300, top = GenericTitleBarDims.TitleBarHeight + f19_local3 + 5, bottom = GenericTitleBarDims.TitleBarHeight + f19_local3 + CoD.TextSettings.NormalFont.Height + 5, alpha = 1 } ) f19_arg0:animateToState( "visible" ) else f19_arg0:animateToState( "default" ) end end } } } } end function AttachmentGridShadeFeeder( f20_arg0 ) local f20_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_weapon_attach_choose_main" ) local f20_local1 = {} for f20_local2 = 1, 4, 1 do local f20_local5 = 0 if #f20_local1 % 2 == 0 then f20_local5 = 0.1 end f20_local1[#f20_local1 + 1] = { type = "UIImage", id = "dark_film_id_" .. f20_local2, states = { default = { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 1, right = -1, top = 0, red = 0, green = 0, blue = 0, height = 80, alpha = f20_local5 } } } end return f20_local1 end function AttachmentGridTextFeeder( f21_arg0 ) local f21_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_weapon_attach_choose_main" ) local f21_local1 = Cac.GetAttachmentTypeList( Cac.GetWeapon( f21_local0.controller, f21_local0.squadLocation, f21_local0.squadMemberIndex, f21_local0.classLocation, f21_local0.slot, f21_local0.weaponIndex ) ) local f21_local2 = {} for f21_local6, f21_local7 in ipairs( f21_local1 ) do f21_local2[#f21_local2 + 1] = { type = "UIText", id = "attachment_category_name_" .. f21_local7, properties = { text = Cac.AttachmentTypes.Strings[f21_local7] }, states = { default = { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Right, leftAnchor = true, rightAnchor = false, topAnchor = false, bottomAnchor = false, left = 0, right = 122, top = -CoD.TextSettings.NormalFont.Height / 2, bottom = CoD.TextSettings.NormalFont.Height / 2, red = 1, green = 1, blue = 1 } }, handlers = { menu_create = function ( f22_arg0, f22_arg1 ) local f22_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f22_arg0 ) if MatchRules.AllowCustomClasses( f22_local0.classLocation ) then local f22_local1, f22_local2 = Cac.SafeGetMatchRule( "commonOption", "attachmentClassRestricted", f21_local7 ) if f22_local1 and f22_local2 then local self = LUI.UIImage.new() self.id = "restrict_icon" .. f21_local7 self:registerAnimationState( "default", { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 85, top = CoD.TextSettings.NormalFont.Height, width = 28, height = 28, material = RegisterMaterial( "icon_new_3" ), alpha = 1 } ) self:animateToState( "default" ) f22_arg0:addElement( self ) end end end } } end return f21_local2 end function AttachmentSelectionFeeder( f23_arg0 ) local f23_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_weapon_attach_choose_main" ) local f23_local1 = Cac.GetWeapon( f23_local0.controller, f23_local0.squadLocation, f23_local0.squadMemberIndex, f23_local0.classLocation, f23_local0.slot, f23_local0.weaponIndex ) local f23_local2 = Cac.GetAttachmentTypeList( f23_local1 ) local f23_local3 = Cac.GetAttachment( f23_local0.controller, f23_local0.squadLocation, f23_local0.squadMemberIndex, f23_local0.classLocation, f23_local0.slot, f23_local0.weaponIndex, f23_local0.attachIndex ) local f23_local4 = {} for f23_local11, f23_local12 in ipairs( f23_local2 ) do local f23_local13 = Cac.GetAttachmentListByType( f23_local1, f23_local12 ) for f23_local10 = 1, f23_arg0.elementsPerRow, 1 do local f23_local8 = {} if #f23_local13 < f23_local10 then f23_local8 = { type = "UIImage", id = "attachment_selection_spacer_at_" .. f23_local10 + f23_local11 - 1 * f23_arg0.elementsPerRow, states = { default = { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 0, right = 70, top = 0, bottom = 70, red = 0.1, green = 0.1, blue = 0.1, alpha = 0 } } } else local f23_local9 = f23_local13[f23_local10] f23_local8 = { type = "cac_attachment_button", id = "attachment_selections_button_id_" .. f23_local10 + f23_local11 - 1 * f23_arg0.elementsPerRow, listDefaultFocus = f23_local3 == f23_local9, properties = { image = RegisterMaterial( Cac.GetAttachmentImage( f23_local9, f23_local1 ) ), attachItem = f23_local9, weaponName = f23_local1, unlockCost = Cac.getAttachmentCost( f23_local9, f23_local1 ), currentAttachment = f23_local3, muteAction = true, additional_handlers = { button_action = CacEditWeaponAttachChoose, button_over = CacEditWeaponAttachButtonOver, element_refresh = MBh.EmitEvent( "content_refresh" ) } } } end f23_local4[#f23_local4 + 1] = f23_local8 end end return f23_local4 end function attachment_grid() local f24_local0 = LUI.FlowManager.GetMenuScopedDataByMenuName( "cac_edit_weapon_attach_choose_main" ) local f24_local1 = Engine.Localize( "@LUA_MENU_ATTACHMENT_ONE_CAPS" ) if f24_local0.attachIndex == 1 then f24_local1 = Engine.Localize( "@LUA_MENU_ATTACHMENT_TWO_CAPS" ) elseif f24_local0.attachIndex == 2 then f24_local1 = Engine.Localize( "@LUA_MENU_ATTACHMENT_THREE_CAPS" ) end return { type = "UIElement", id = "abilities_grid_container", states = { default = { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = Cac.Layout.AttachmentChooseDims.Grid.menu_left, width = 675, top = Cac.Layout.AttachmentChooseDims.Grid.menu_top, bottom = 452 } }, children = { { type = "generic_drop_shadow", properties = { offset_shadow = 0 }, states = { default = { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = 0, right = 0, alpha = Cac.Swatches.Alphas.cac_panel_background_shadow } } }, { type = "generic_menu_titlebar", id = "window_title", properties = { font = CoD.TextSettings.BoldFont, title_bar_text = f24_local1, title_bar_text_indent = GenericTitleBarDims.TitleBarLCapWidth, title_bar_alignment = LUI.Alignment.Left, fill_alpha = 1 } }, { type = "generic_menu_background", id = "window_background", properties = { fill_alpha = 1 } }, { type = "UIVerticalList", id = "attachments_grid_shades", states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = 0, top = GenericTitleBarDims.TitleBarHeight, bottom = 0 } }, childrenFeeder = AttachmentGridShadeFeeder }, { type = "UIVerticalList", id = "attachments_grid_text", states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = 0, top = GenericTitleBarDims.TitleBarHeight + 30, bottom = 0, spacing = Cac.Layout.AttachmentChooseDims.Grid.row_height - CoD.TextSettings.NormalFont.Height } }, childrenFeeder = AttachmentGridTextFeeder }, { type = "UIGrid", id = "attachment_selection_grid_id", focusable = true, states = { default = { topAnchor = true, bottomAnchor = false, leftAnchor = true, rightAnchor = false, top = 37, left = Cac.Layout.AttachmentChooseDims.Grid.text_space, width = 430, height = 330 } }, properties = { elementsPerRow = 6, hSpacing = Cac.Layout.AttachmentChooseDims.Grid.horizontal_spacing, rowHeight = Cac.Layout.AttachmentChooseDims.Grid.row_height, hAlign = LUI.Alignment.Left, vAlign = LUI.Alignment.Top }, childrenFeeder = AttachmentSelectionFeeder } } } end function CacEditWeaponAttachLeave( f25_arg0, f25_arg1 ) local f25_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f25_arg0 ) local f25_local1 = Cac.GetAttachment( f25_local0.controller, f25_local0.squadLocation, f25_local0.squadMemberIndex, f25_local0.classLocation, f25_local0.slot, f25_local0.weaponIndex, f25_local0.attachIndex ) Cac.ValidateReticle( f25_local0.controller, f25_local0.squadLocation, f25_local0.squadMemberIndex, f25_local0.classLocation, f25_local0.slot, f25_local0.weaponIndex ) f25_arg0:dispatchEventToRoot( { name = "update_cac_info_panel", controller = f25_local0.controller, dispatchChildren = true } ) end function cac_edit_weapon_attach_choose_main() return { type = "UIElement", id = "cac_edit_weapon_attach_choose_main_id", properties = { squadLocation = "privateMatchSquadMembers", squadMemberIndex = 0, slot = 0, classLocation = "loadouts", weaponIndex = 0, attachIndex = 0 }, states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = 0, top = 0, bottom = 0 } }, handlers = { menu_close = CacEditWeaponAttachLeave, open_reticle_popup = function ( f27_arg0, f27_arg1 ) LUI.FlowManager.RequestPopupMenu( f27_arg0, "cac_edit_choose_image_popup", true, f27_arg1.controller, true, f27_arg1.data, nil, nil, false ) end }, children = { attachment_grid(), attachment_decription(), { type = "generic_back_button", handlers = { button_secondary = function ( f28_arg0, f28_arg1 ) local f28_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f28_arg0 ) f28_arg0:dispatchEventToRoot( { name = "unlock_attachments", weaponIndex = f28_local0.weaponIndex } ) LUI.FlowManager.RequestLeaveMenu( f28_arg0 ) end } } } } end LUI.MenuBuilder.registerDef( "cac_edit_weapon_attach_choose_main", cac_edit_weapon_attach_choose_main ) LUI.MenuBuilder.registerType( "cac_attachment_button", cac_attachment_button ) LUI.MenuBuilder.registerDef( "cac_purchase_attach_popup", cac_purchase_attach_popup ) LUI.MenuBuilder.registerDef( "cac_cant_purchase_attach_popup", cac_cant_purchase_attach_popup ) LockTable( _M )