local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) CoD.PrintModuleLoad( _NAME ) function BarrackLeaderboardsAction( f1_arg0, f1_arg1 ) if Engine.IsWaitingForOnlineServices( f1_arg1.controller ) then Engine.Exec( "xopenonlineservicesdialog", f1_arg1.controller ) else LUI.FlowManager.RequestAddMenu( f1_arg0, "leaderboards", true, f1_arg1.controller ) end end function BarrackOperationsAction( f2_arg0, f2_arg1 ) LUI.FlowManager.RequestAddMenu( f2_arg0, "operations_main_menu", true, f2_arg1.controller ) end function BarrackCreateClanAction( f3_arg0, f3_arg1 ) if CoDAnywhere.ShouldShowLinkCreatePopup( f3_arg1.controller, true ) == true then LUI.FlowManager.RequestPopupMenu( f3_arg0, "cod_anywhere_popup_menu", true, f3_arg1.controller ) elseif CoDAnywhere.ShouldShowLinkUCDPopup( f3_arg1.controller, true ) == true and Engine.GetDvarInt( "ca_intra_only" ) == 0 then LUI.FlowManager.RequestPopupMenu( f3_arg0, "cod_anywhere_link_ucd_popup_menu", true, f3_arg1.controller ) else Clan.Create( f3_arg1.controller ) end end function BarrackClanDetailsAction( f4_arg0, f4_arg1 ) if Clan.AlreadyMember( f4_arg1.controller ) then LUI.FlowManager.RequestAddMenu( f4_arg0, "clan_details_main", true, f4_arg1.controller ) end end function BarrackClanInviteAction( f5_arg0, f5_arg1 ) if Clan.CanAcceptInvites( f5_arg1.controller ) == false then LUI.FlowManager.RequestPopupMenu( f5_arg0, "user_generated_content_restriction_popup", true, f5_arg1.controller ) else LUI.FlowManager.RequestAddMenu( f5_arg0, "clan_invites", true, f5_arg1.controller ) end end function BarrackCoDAnywhereAction( f6_arg0, f6_arg1 ) if CoDAnywhere.ServiceAvailable( f6_arg1.controller ) then OpenCoDAnywhere( f6_arg1.controller ) else LUI.FlowManager.RequestPopupMenu( f6_arg0, "generic_confirmation_popup", true, f6_arg1.controller, false, { popup_title = Engine.Localize( "MENU_ERROR" ), message_text = Engine.Localize( "@LUA_MENU_COD_ANYWHERE_ERROR_SERVICE" ) } ) end end function BarrackPrestigeResetStatsAction( f7_arg0, f7_arg1 ) LUI.FlowManager.RequestAddMenu( f7_arg0, "prestige_reset", true, f7_arg1.controller ) end function BarracksOptionsFeeder( f8_arg0 ) local f8_local0 = Engine.IsAliensMode() local f8_local1 = not f8_arg0.is_offline_barracks local f8_local2 = Engine.InLobby() local f8_local3 = f8_arg0.exclusiveController if not f8_local3 then DebugPrint( "[WARNING] Barracks: using controller index 0, this is only ok if you are editing a menu" ) f8_local3 = Engine.GetFirstActiveController() end local f8_local4 = {} if f8_local1 then f8_local4[#f8_local4 + 1] = { type = "UIGenericButton", id = "leaderboard_button_id", properties = { button_text = Engine.Localize( "@LUA_MENU_LEADERBOARDS_CAPS" ), button_action_func = BarrackLeaderboardsAction, desc_text = Engine.Localize( "@LUA_MENU_DESC_LEADERBOARDS" ) } } end if not f8_local0 and IsPublicMatch() then if Clan.IsEnabled() then local f8_local5 = #f8_local4 + 1 local f8_local6 = { type = "UIGenericButton", id = "create_clan_button_id" } local f8_local7 = Engine.IsUserAGuest( f8_local3 ) if not f8_local7 then f8_local7 = Clan.AlreadyMember( f8_local3 ) if not f8_local7 then f8_local7 = not CoDAnywhere.ServiceAvailable( f8_local3 ) end end f8_local6.disabled = f8_local7 f8_local6.properties = { button_text = Engine.Localize( "@LUA_MENU_CREATE_CLAN_CAPS" ), button_action_func = BarrackCreateClanAction, desc_text = Engine.Localize( "@LUA_MENU_DESC_CREATE_CLAN" ) } f8_local6.handlers = { element_refresh = function ( f9_arg0, f9_arg1 ) local f9_local0 = Engine.IsUserAGuest( f8_local3 ) if not f9_local0 then f9_local0 = Clan.AlreadyMember( f8_local3 ) if not f9_local0 then f9_local0 = not CoDAnywhere.ServiceAvailable( f8_local3 ) end end local f9_local1 = f9_arg0 local f9_local2 = f9_arg0.processEvent local f9_local3 = {} local f9_local4 if f9_local0 then f9_local4 = "disable" if not f9_local4 then else f9_local3.name = f9_local4 f9_local2( f9_local1, f9_local3 ) end end f9_local4 = "enable" end } f8_local4[f8_local5] = f8_local6 f8_local5 = #f8_local4 + 1 f8_local6 = { type = "UIGenericButton", id = "clan_details_button_id" } f8_local7 = Engine.IsUserAGuest( f8_local3 ) if not f8_local7 then if Clan.AlreadyMember( f8_local3 ) then f8_local7 = Clan.IsDownloadingData( f8_local3 ) else f8_local7 = true end end f8_local6.disabled = f8_local7 f8_local6.properties = { button_text = Engine.Localize( "@CLANS_CLAN_DETAILS_CAPS" ), button_action_func = BarrackClanDetailsAction, desc_text = Engine.Localize( "@CLANS_CLAN_DETAILS_DESC_TEXT" ) } f8_local6.handlers = { element_refresh = function ( f10_arg0, f10_arg1 ) local f10_local0 = Engine.IsUserAGuest( f8_local3 ) if not f10_local0 then if Clan.AlreadyMember( f8_local3 ) then f10_local0 = Clan.IsDownloadingData( f8_local3 ) else f10_local0 = true end end local f10_local1 = f10_arg0 local f10_local2 = f10_arg0.processEvent local f10_local3 = {} local f10_local4 if f10_local0 then f10_local4 = "disable" if not f10_local4 then else f10_local3.name = f10_local4 f10_local2( f10_local1, f10_local3 ) end end f10_local4 = "enable" end } f8_local4[f8_local5] = f8_local6 f8_local5 = #f8_local4 + 1 f8_local6 = { type = "UIGenericButton", id = "clan_invite_button_id" } f8_local7 = Engine.IsUserAGuest( f8_local3 ) if not f8_local7 then f8_local7 = Clan.GetNumProposals( f8_local3 ) == 0 end f8_local6.disabled = f8_local7 f8_local6.properties = { button_text = Engine.Localize( "@LUA_MENU_CLAN_CLAN_INVITES_CAPS" ), button_action_func = BarrackClanInviteAction, desc_text = Engine.Localize( "@LUA_MENU_CLAN_CLAN_INVITES_DESC" ) } f8_local6.handlers = { element_refresh = function ( f11_arg0, f11_arg1 ) local f11_local0 = Engine.IsUserAGuest( f8_local3 ) if not f11_local0 then f11_local0 = Clan.GetNumProposals( f8_local3 ) == 0 end local f11_local1 = f11_arg0 local f11_local2 = f11_arg0.processEvent local f11_local3 = {} local f11_local4 if f11_local0 then f11_local4 = "disable" if not f11_local4 then else f11_local3.name = f11_local4 f11_local2( f11_local1, f11_local3 ) end end f11_local4 = "enable" end } f8_local4[f8_local5] = f8_local6 end if Engine.GetDvarInt( "allow_cod_anywhere" ) == 1 then f8_local4[#f8_local4 + 1] = { type = "UIGenericButton", id = "cod_anywhere_button_id", disabled = Engine.IsUserAGuest( f8_local3 ), properties = { button_text = Engine.Localize( "@LUA_MENU_COD_ANYWHERE_CAPS" ), button_action_func = BarrackCoDAnywhereAction, desc_text = Engine.Localize( "@LUA_MENU_COD_ANYWHERE_DESC" ) } } end if not f8_local2 then local f8_local5 = #f8_local4 + 1 local f8_local6 = { type = "UIGenericButton", id = "reset_stats_button_id" } local f8_local7 if Cac.GetPrestigeLevel( f8_local3, Cac.GetSquadLoc() ) == 10 then f8_local7 = Engine.IsUserAGuest( f8_local3 ) else f8_local7 = true end f8_local6.disabled = f8_local7 f8_local6.properties = { button_text = Engine.Localize( "@LUA_MENU_MP_RESET_STATS_CAPS" ), button_action_func = BarrackPrestigeResetStatsAction, desc_text = Engine.Localize( "@LUA_MENU_MP_RESET_STATS_DESC" ) } f8_local6.handlers = { element_refresh = function ( f12_arg0, f12_arg1 ) local f12_local0 if Cac.GetPrestigeLevel( f8_local3, Cac.GetSquadLoc() ) == 10 then f12_local0 = Engine.IsUserAGuest( f8_local3 ) else f12_local0 = true end local f12_local1 = f12_arg0 local f12_local2 = f12_arg0.processEvent local f12_local3 = {} local f12_local4 if f12_local0 then f12_local4 = "disable" if not f12_local4 then else f12_local3.name = f12_local4 f12_local2( f12_local1, f12_local3 ) end end f12_local4 = "enable" end } f8_local4[f8_local5] = f8_local6 end end f8_local4[#f8_local4 + 1] = { type = "button_desc_text", id = "barracks_button_description_id" } return f8_local4 end function BarracksButtonHelper( f13_arg0, f13_arg1 ) Engine.ExecNow( "eliteclan_refresh", f13_arg0.properties.exclusiveController ) f13_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addBackButton ) end function menu_barracks() return { type = "UIElement", id = "menu_barracks_root", states = { default = { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = 0, right = 0 } }, properties = { is_offline_barracks = false }, handlers = { menu_create = BarracksButtonHelper, refresh_clan_data = function ( f15_arg0, f15_arg1 ) Engine.ExecNow( "eliteclan_refresh", f15_arg0.properties.exclusiveController ) end }, children = { { type = "generic_menu_title", id = "barracks_title_text_id", properties = { menu_title = Engine.Localize( "@LUA_MENU_BARRACKS_CAPS" ) } }, { type = "UIText", id = "clan_details_downloading", properties = { text = Engine.Localize( "LUA_MENU_DOWNLOADING_CLAN" ) }, states = { default = CoD.ColorizeState( Colors.white, { leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = false, right = -140, top = 59, width = 300, height = CoD.TextSettings.NormalFont.Height, font = CoD.TextSettings.NormalFont.Font, alpha = 0 } ), visible = CoD.ColorizeState( Colors.white, { alpha = 1 } ), dark = CoD.ColorizeState( Colors.secondary_text_color, { alpha = 1 } ) }, handlers = { update_downloading_text = function ( f16_arg0, f16_arg1 ) if Clan.IsDownloadingData( f16_arg0.properties.exclusiveController ) then if not f16_arg0.properties.animating then local f16_local0 = MBh.AnimateLoop( { { "visible", 400 }, { "dark", 400 } } ) f16_local0( f16_arg0 ) f16_arg0.properties.animating = true end else f16_arg0.properties.animating = false f16_arg0:animateToState( "default" ) end end , menu_create = MBh.EmitEvent( { name = "update_downloading_text" } ) }, children = { { type = "UITimer", id = "downloading_text_timer", properties = { event = "update_downloading_text", interval = 100, disposable = false, broadcastToRoot = false } } } }, { type = "UIVerticalList", id = "barracks_options_vlist_id", 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 } }, childrenFeeder = BarracksOptionsFeeder }, { type = "button_helper_text_main", id = "barracks_button_helper_text_id" }, { type = "online_friends_widget", id = "online_friends_widget_id" }, { type = "UIBindButton", id = "barracks_bind_buttons_id", handlers = { button_secondary = MBh.LeaveMenu() } }, { type = "UITimer", id = "button_refresh_timer", properties = { event = { name = "element_refresh" }, interval = 1000 } }, { type = "UITimer", id = "clan_refresh_timer", properties = { event = { name = "refresh_clan_data" }, interval = 60000 } } } } end function barracks_options_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 } } } end LUI.MenuBuilder.registerDef( "menu_barracks", menu_barracks ) LUI.MenuBuilder.registerDef( "barracks_options_vlist", barracks_options_vlist ) LockTable( _M )