local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) DebugPrint( "Registering " .. _NAME ) AlienPurchasableItems = { File = "mp/alien/alien_purchasable_items.csv", Cols = { Idx = 0, Ref = 1, Name = 2, Desc = 3, Cost = 4, ReqiredMapPack = 5, AltDesc = 6 }, MaxItems = 32 } CLASSIFIED_PACK_THRESHOLD = 4 SHOW_CLASSIFIED_UPGRADES = true function UsingExtinctionTokens() local f1_local0 = Engine.GetDvarInt( "extinction_tokens_enabled" ) return f1_local0 and f1_local0 > 0 end function PurchasableItem_GetRef( f2_arg0 ) return Engine.TableLookup( AlienPurchasableItems.File, AlienPurchasableItems.Cols.Idx, tostring( f2_arg0 ), AlienPurchasableItems.Cols.Ref ) end function PurchasableItem_GetIdx( f3_arg0 ) return Engine.TableLookup( AlienPurchasableItems.File, AlienPurchasableItems.Cols.Ref, f3_arg0, AlienPurchasableItems.Cols.Idx ) end function PurchasableItem_GetCost( f4_arg0 ) return Engine.TableLookup( AlienPurchasableItems.File, AlienPurchasableItems.Cols.Ref, f4_arg0, AlienPurchasableItems.Cols.Cost ) end function PurchasableItem_GetName( f5_arg0 ) return Engine.TableLookup( AlienPurchasableItems.File, AlienPurchasableItems.Cols.Ref, f5_arg0, AlienPurchasableItems.Cols.Name ) end function PurchasableItem_GetDesc( f6_arg0 ) return Engine.TableLookup( AlienPurchasableItems.File, AlienPurchasableItems.Cols.Ref, f6_arg0, AlienPurchasableItems.Cols.Desc ) end function PurchasableItem_GetAltDesc( f7_arg0 ) return Engine.TableLookup( AlienPurchasableItems.File, AlienPurchasableItems.Cols.Ref, f7_arg0, AlienPurchasableItems.Cols.AltDesc ) end function PurchasableItem_GetRequiredMapPack( f8_arg0 ) return Engine.TableLookup( AlienPurchasableItems.File, AlienPurchasableItems.Cols.Ref, f8_arg0, AlienPurchasableItems.Cols.ReqiredMapPack ) end function PurchasableItems_IsRestricted( f9_arg0 ) local f9_local0 = tonumber( PurchasableItem_GetRequiredMapPack( f9_arg0 ) ) if f9_local0 and f9_local0 >= 1 and f9_local0 <= 4 then if f9_local0 == 1 and Engine.AnyoneHasAliensDLC1() then return false elseif f9_local0 == 2 and Engine.AnyoneHasAliensDLC2() then return false elseif f9_local0 == 3 and Engine.AnyoneHasAliensDLC3() then return false elseif f9_local0 == 4 and Engine.AnyoneHasAliensDLC4() then return false else return true end elseif f9_local0 and f9_local0 > CLASSIFIED_PACK_THRESHOLD then return true else return false end end function PurchasableItems_IsClassified( f10_arg0 ) if PurchasableItems_IsRestricted( f10_arg0 ) and tonumber( PurchasableItem_GetRequiredMapPack( f10_arg0 ) ) > CLASSIFIED_PACK_THRESHOLD then return true else return false end end function GetPlayerTokens( f11_arg0 ) return Engine.GetPlayerDataReservedInt( f11_arg0, CoD.StatsGroup.Coop, "extinction_tokens" ) or 0 end function SetPlayerTokens( f12_arg0, f12_arg1 ) Engine.SetPlayerDataReservedInt( f12_arg0, CoD.StatsGroup.Coop, "extinction_tokens", f12_arg1 ) end function CheckCanAfford( f13_arg0, f13_arg1 ) return f13_arg1 <= GetPlayerTokens( f13_arg0 ) end function AliensSetIsUpgradeEnabledWrapper( f14_arg0, f14_arg1, f14_arg2 ) Engine.AliensSetIsUpgradeEnabled( f14_arg0, f14_arg1, f14_arg2 ) if f14_arg1 == "multi_class" and f14_arg2 then LUI.mp_menus.Aliens.setDefaultSecondaryClass( f14_arg0 ) end if f14_arg1 == "combined_ammo_upgrade" and not f14_arg2 then if LUI.mp_menus.Aliens.GetAlienAbility( f14_arg0, "munition" ) == "dpad_placeholder_ammo_2" then LUI.mp_menus.Aliens.SetAlienAbility( f14_arg0, "munition", "dpad_team_ammo_reg" ) end elseif f14_arg1 == "combined_ammo_upgrade" and f14_arg2 then LUI.mp_menus.Aliens.SetAlienAbility( f14_arg0, "munition", "dpad_placeholder_ammo_2" ) end end if Engine.InFrontend() then function OpenTokenStore( f15_arg0, f15_arg1 ) if UsingExtinctionTokens() then LUI.FlowManager.RequestPopupMenu( f15_arg0, "alien_purchasables_main", true, f15_arg1.controller, false, {} ) end end function TryOneTimePrestigeAward( f16_arg0 ) if not UsingExtinctionTokens() then return elseif Engine.GetPlayerDataReservedInt( f16_arg0, CoD.StatsGroup.Coop, "awarded_prestige_tokens" ) == 0 then Engine.SetPlayerDataReservedInt( f16_arg0, CoD.StatsGroup.Coop, "awarded_prestige_tokens", 1 ) local f16_local0 = LUI.mp_menus.Aliens.getAliensPrestigeLevel( f16_arg0 ) if f16_local0 and f16_local0 > 0 then local f16_local1 = f16_local0 SetPlayerTokens( f16_arg0, GetPlayerTokens( f16_arg0 ) + f16_local1 ) local f16_local2 = {} if f16_local1 > 1 then f16_local2.message_text = Engine.Localize( "ALIENS_PRESTIGE_TOKENS_AWARD", tostring( f16_local1 ), tostring( f16_local0 ) ) else f16_local2.message_text = Engine.Localize( "ALIENS_PRESTIGE_TOKEN_AWARD", tostring( f16_local1 ), tostring( f16_local0 ) ) end LUI.FlowManager.RequestPopupMenu( nil, "aliens_gift_tokens_popup", true, f16_arg0, false, f16_local2 ) end end end function PurchasablesFeeder( f17_arg0 ) local f17_local0 = f17_arg0.exclusiveController if not f17_local0 then f17_local0 = Engine.GetFirstActiveController() end local f17_local1 = {} for f17_local2 = 0, AlienPurchasableItems.MaxItems - 1, 1 do local f17_local5 = Engine.TableLookup( AlienPurchasableItems.File, AlienPurchasableItems.Cols.Idx, tostring( f17_local2 ), AlienPurchasableItems.Cols.Ref ) if f17_local5 == "" then break end local f17_local6 = { type = "alien_purchasable_button", id = "purchase_btn_" .. tostring( f17_local2 ), properties = { controller = f17_local0, itemRef = f17_local5 } } local f17_local7 = PurchasableItems_IsClassified( f17_local5 ) if not f17_local7 then f17_local1[#f17_local1 + 1] = f17_local6 end if f17_local7 and SHOW_CLASSIFIED_UPGRADES then f17_local1[#f17_local1 + 1] = f17_local6 end end table.sort( f17_local1, function ( f18_arg0, f18_arg1 ) if PurchasableItem_GetRequiredMapPack( f18_arg0.properties.itemRef ) < PurchasableItem_GetRequiredMapPack( f18_arg1.properties.itemRef ) then return true else return false end end ) return f17_local1 end function alien_purchasables_main( f19_arg0, f19_arg1, f19_arg2 ) local self = LUI.UIElement.new() self.id = "alien_purchasables_root_menu" self:registerAnimationState( "default", { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = 0, top = 0, bottom = 0 } ) self:registerEventHandler( "menu_create", function ( element, event ) element:dispatchEventToRoot( { name = "hide_tip", immediate = true } ) element:dispatchEventToRoot( { name = "dim_all", immediate = true } ) if Engine.GetDvarBool( "extinction_cac_enabled" ) then element:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_alt1", helper_text = "", side = "left", clickable = true } ) end TryOneTimePrestigeAward( element.properties.exclusiveController ) end ) self:registerEventHandler( "menu_close", function ( element, event ) element:dispatchEventToRoot( { name = "show_all", immediate = true } ) element:dispatchEventToRoot( { name = "show_tip", immediate = true } ) if Engine.GetDvarBool( "extinction_cac_enabled" ) then element:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_alt1", helper_text = Engine.Localize( "@LUA_MENU_CUSTOMIZE_CHAR" ), side = "left", clickable = true } ) end end ) self:animateToState( "default" ) local f19_local1 = LUI.UIElement.new() f19_local1.id = "scrolling_menu_group" f19_local1:registerAnimationState( "default", { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 600, width = 555, top = 145, height = 276 } ) f19_local1:animateToState( "default" ) self:addElement( f19_local1 ) f19_local1:addElement( LUI.MenuGenerics.generic_menu_titlebar( nil, { title_bar_text = Engine.Localize( "@LUA_MENU_MP_ARMORY_CAPS" ), font = CoD.TextSettings.BoldFont, title_bar_text_indent = 25, title_bar_alignment = LUI.Alignment.Left } ) ) f19_local1:addElement( LUI.MenuGenerics.generic_menu_background_withfade( {}, {} ) ) local f19_local2 = { use_arrows = false, use_scrollbar = true, bar_width = 7 } local f19_local3 if f19_arg1 then f19_local3 = f19_arg1.exclusiveController if not f19_local3 then else f19_local2.exclusiveController = f19_local3 f19_local3 = LUI.UIScrollingVerticalList.new( { childrenFeeder = PurchasablesFeeder }, f19_local2 ) f19_local3:registerAnimationState( "default", { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = GenericTitleBarDims.TitleBarHeight + 4, bottom = 0, left = 4, right = -7, spacing = 4 } ) f19_local3:animateToState( "default" ) f19_local1:addElement( f19_local3 ) local f19_local4 = LUI.MenuGenerics.generic_menu_background_withfade( {}, { top_offset = 0 } ) f19_local4.id = "alien_purchasables_desc_window" f19_local4:registerAnimationState( "default", { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 600, width = 555, top = 429, height = 200 } ) f19_local4:animateToState( "default" ) self:addElement( f19_local4 ) local f19_local5 = LUI.UIText.new() f19_local5.id = "nameLabelId" f19_local5:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Right, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 0, right = 100, top = 15, height = CoD.TextSettings.NormalFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } ) f19_local5:setText( Engine.Localize( "@LUA_MENU_MP_PURCHASABLE_NAME" ) ) f19_local5:animateToState( "default" ) f19_local4:addElement( f19_local5 ) local f19_local6 = LUI.UIText.new() f19_local6.id = "nameTextId" f19_local6:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 5, right = 430, top = 0, bottom = 0, red = 1, green = 1, blue = 1 } ) f19_local6:registerAnimationState( "classified", { red = Colors.alien_frontend_hilite.r, green = Colors.alien_frontend_hilite.g, blue = Colors.alien_frontend_hilite.b } ) f19_local6:registerEventHandler( "update_purchasable_item_desc", function ( element, event ) element:setText( event.newName ) if event.isClassified then element:animateToState( "classified" ) element:setTextStyle( CoD.TextStyle.Outlined ) else element:animateToState( "default" ) element:setTextStyle( CoD.TextStyle.None ) end end ) f19_local6:animateToState( "default" ) f19_local5:addElement( f19_local6 ) local f19_local7 = LUI.UIText.new() f19_local7.id = "costLabelId" f19_local7:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Right, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 0, right = 100, top = 15 + CoD.TextSettings.NormalFont.Height + 2, height = CoD.TextSettings.NormalFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } ) f19_local7:setText( Engine.Localize( "@LUA_MENU_MP_PURCHASABLE_COST" ) ) f19_local7:animateToState( "default" ) f19_local4:addElement( f19_local7 ) local f19_local8 = LUI.UIImage.new( { material = RegisterMaterial( "alien_icon_tooth" ), leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 5, right = 22, top = 0, bottom = 0, alpha = 1 } ) f19_local8:registerAnimationState( "hidden", { alpha = 0 } ) f19_local8.id = "tokens_icon_id" f19_local8:registerEventHandler( "update_purchasable_item_desc", function ( element, event ) if event.isClassified or event.isRestricted then element:animateToState( "hidden" ) else element:animateToState( "default" ) end end ) f19_local7:addElement( f19_local8 ) local f19_local9 = LUI.UIText.new() f19_local9.id = "costTextId" f19_local9:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 25, right = 430, top = 0, bottom = 0, red = 1, green = 1, blue = 1 } ) f19_local9:registerAnimationState( "classified", { leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 5, right = 430, top = 0, bottom = 0, red = Colors.alien_frontend_hilite.r, green = Colors.alien_frontend_hilite.g, blue = Colors.alien_frontend_hilite.b } ) f19_local9:registerEventHandler( "update_purchasable_item_desc", function ( element, event ) element:setText( event.newCost ) if event.isClassified or event.isRestricted then element:animateToState( "classified" ) element:setTextStyle( CoD.TextStyle.Outlined ) else element:animateToState( "default" ) element:setTextStyle( CoD.TextStyle.None ) end end ) f19_local9:animateToState( "default" ) f19_local7:addElement( f19_local9 ) local f19_local10 = LUI.UIText.new() f19_local10.id = "descLabelId" f19_local10:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Right, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 0, right = 100, top = 15 + 2 * CoD.TextSettings.NormalFont.Height + 4, height = CoD.TextSettings.NormalFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } ) f19_local10:setText( Engine.Localize( "@LUA_MENU_MP_PURCHASABLE_UPGRADE" ) ) f19_local10:animateToState( "default" ) f19_local4:addElement( f19_local10 ) local f19_local11 = LUI.UIText.new() f19_local11.id = "descTextId" f19_local11:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 5, right = 430, top = 0, bottom = 0, red = 1, green = 1, blue = 1 } ) f19_local11:registerAnimationState( "classified", { red = Colors.alien_frontend_hilite.r, green = Colors.alien_frontend_hilite.g, blue = Colors.alien_frontend_hilite.b } ) f19_local11:registerEventHandler( "update_purchasable_item_desc", function ( element, event ) element:setText( event.newDesc ) if event.isClassified then element:animateToState( "classified" ) element:setTextStyle( CoD.TextStyle.Outlined ) else element:animateToState( "default" ) element:setTextStyle( CoD.TextStyle.None ) end end ) f19_local11:animateToState( "default" ) f19_local10:addElement( f19_local11 ) local f19_local12 = LUI.UIBindButton.new() f19_local12.id = "purchase_menu_bind_button_id" f19_local12.m_ownerController = f19_arg1.exclusiveController f19_local12:registerEventHandler( "button_secondary", MBh.LeaveMenu() ) self:addElement( f19_local12 ) return self end end f19_local3 = Engine.GetFirstActiveController() end function alien_purchasable_button( f26_arg0, f26_arg1, f26_arg2 ) local f26_local0 = 30 local f26_local1 = 7 local f26_local2 = 35 local f26_local3 = f26_arg1.controller if not f26_local3 then f26_local3 = Engine.GetFirstActiveController() end local f26_local4 = f26_arg1.itemRef or nil local f26_local5 = tonumber( PurchasableItem_GetCost( f26_local4 ) ) local f26_local6 = Engine.Localize( PurchasableItem_GetName( f26_local4 ) ) local f26_local7 = nil if Engine.IsConsoleGame() or Engine.IsGamepadEnabled() == 1 then f26_local7 = Engine.Localize( PurchasableItem_GetDesc( f26_local4 ) ) else local f26_local8 = PurchasableItem_GetAltDesc( f26_local4 ) if f26_local8 ~= "" then f26_local7 = Engine.Localize( f26_local8 ) else f26_local7 = Engine.Localize( PurchasableItem_GetDesc( f26_local4 ) ) end end local f26_local8 = Engine.AliensCheckIsItemPurchased( f26_local3, f26_local4 ) local f26_local9 = Engine.AliensCheckIsUpgradeEnabled( f26_local3, f26_local4 ) local f26_local10 = PurchasableItems_IsRestricted( f26_local4 ) local f26_local11 = PurchasableItems_IsClassified( f26_local4 ) if f26_local11 then local self = PurchasableItem_GetRequiredMapPack( f26_local4 ) f26_local5 = Engine.Localize( "@ALIENS_UPGRADE_CLASSIFIED_CAPS" ) f26_local6 = Engine.Localize( "@ALIENS_UPGRADE_CLASSIFIED_CAPS" ) f26_local7 = Engine.Localize( "@ALIENS_NEXT_EPISODE" ) elseif f26_local10 then f26_local5 = Engine.Localize( "@ALIENS_UPGRADE_REQ_DLC", Engine.Localize( "DLC_MAP_PACK_" .. PurchasableItem_GetRequiredMapPack( f26_local4 ) ) ) end local self = LUI.UIButton.new() self.id = "alien_purchasable_id" self:registerAnimationState( "default", { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = 0, bottom = f26_local0 } ) self:registerEventHandler( "button_action", function ( element, event ) local f27_local0 = Engine.AliensCheckIsItemPurchased( f26_local3, f26_local4 ) if f26_local11 then elseif f26_local10 then if Engine.UserCanAccessStore( event.controller ) then OpenStorePrompt( event.controller, Engine.Localize( "DLC_MAP_PACK_" .. PurchasableItem_GetRequiredMapPack( f26_local4 ) ) ) end elseif f27_local0 then AliensSetIsUpgradeEnabledWrapper( f26_local3, f26_local4, not Engine.AliensCheckIsUpgradeEnabled( f26_local3, f26_local4 ) ) element:processEvent( { name = "refresh_enabled_state" } ) element:dispatchEventToRoot( { name = "refresh_cac_menu_buttons", controller = event.controller, immediate = true } ) else TryConfirmPurchase( element, f26_local3, f26_local4, f26_local5 ) end end ) self:registerEventHandler( "menu_create", function ( element, event ) element:processEvent( { name = "refresh_purchased_state" } ) end ) self:registerEventHandler( "button_over", function ( element, event ) element:dispatchEventToRoot( { name = "update_purchasable_item_desc", newDesc = f26_local7, newCost = tostring( f26_local5 ), newName = f26_local6, isClassified = f26_local11, isRestricted = f26_local10 } ) end ) self:animateToState( "default" ) local f26_local13 = LUI.UIImage.new() f26_local13.id = "btn_background_id" f26_local13:registerAnimationState( "default", { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = 0, top = 0, bottom = 0, alpha = 0 } ) f26_local13:registerAnimationState( "dimmed", { alpha = 0.5 } ) f26_local13:registerAnimationState( "focus", { alpha = 0.8 } ) f26_local13:registerEventHandler( "button_over", MBh.AnimateLoop( { { "focus", 0, true, true }, { "focus", 350, true, true }, { "dimmed", 750, true, true }, { "focus", 750, true, true } } ) ) f26_local13:registerEventHandler( "button_up", MBh.AnimateToState( "default", 0 ) ) f26_local13:animateToState( "default" ) self:addElement( f26_local13 ) local f26_local14 = LUI.UIText.new() f26_local14.id = "main_text" local f26_local15 = f26_local14 local f26_local16 = f26_local14.registerAnimationState local f26_local17 = "default" local f26_local18 = { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = true, topAnchor = false, bottomAnchor = false, left = f26_local1, right = 0, top = -CoD.TextSettings.NormalFont.Height / 2, bottom = CoD.TextSettings.NormalFont.Height / 2 } local f26_local19 if f26_local11 then f26_local19 = Colors.alien_frontend_hilite.r if not f26_local19 then else f26_local18.red = f26_local19 if f26_local11 then f26_local19 = Colors.alien_frontend_hilite.g if not f26_local19 then else f26_local18.green = f26_local19 if f26_local11 then f26_local19 = Colors.alien_frontend_hilite.b if not f26_local19 then else f26_local18.blue = f26_local19 f26_local18.alpha = 1 f26_local16( f26_local15, f26_local17, f26_local18 ) f26_local15 = f26_local14 f26_local16 = f26_local14.registerAnimationState f26_local17 = "focus" f26_local18 = {} if f26_local11 then f26_local19 = Colors.alien_frontend_hilite.r if not f26_local19 then else f26_local18.red = f26_local19 if f26_local11 then f26_local19 = Colors.alien_frontend_hilite.g if not f26_local19 then else f26_local18.green = f26_local19 if f26_local11 then f26_local19 = Colors.alien_frontend_hilite.b if not f26_local19 then else f26_local18.blue = f26_local19 f26_local16( f26_local15, f26_local17, f26_local18 ) f26_local14:registerEventHandler( "button_over", MBh.AnimateToState( "focus", 0 ) ) f26_local14:registerEventHandler( "button_up", MBh.AnimateToState( "default", 0 ) ) f26_local14:setText( f26_local6 ) if f26_local11 then f26_local14:setTextStyle( CoD.TextStyle.Outlined ) end f26_local14:animateToState( "default" ) self:addElement( f26_local14 ) f26_local16 = 8 f26_local15 = LUI.UIImage.new() f26_local15.id = "restricted_icon" f26_local15:registerAnimationState( "default", { material = RegisterMaterial( "icon_unlock_active" ), topAnchor = false, bottomAnchor = false, leftAnchor = false, rightAnchor = true, top = -8, bottom = 8, left = -f26_local16 - 16, right = -f26_local16, alpha = 1 } ) f26_local15:registerAnimationState( "hidden", { material = RegisterMaterial( "icon_unlock_active" ), topAnchor = false, bottomAnchor = false, leftAnchor = false, rightAnchor = true, top = -8, bottom = 8, left = -f26_local16 - 16, right = -f26_local16, alpha = 0 } ) f26_local15:registerEventHandler( "refresh_purchased_state", function ( element, event ) local f30_local0 = Engine.AliensCheckIsItemPurchased( f26_local3, f26_local4 ) local f30_local1 = element local f30_local2 = element.animateToState local f30_local3 if f30_local0 then f30_local3 = "hidden" if not f30_local3 then else f30_local2( f30_local1, f30_local3, 0 ) end end f30_local3 = "default" end ) self:addElement( f26_local15 ) f26_local17 = 10 f26_local18 = LUI.UIImage.new() f26_local18.id = "checkbox" f26_local18:registerAnimationState( "default", { material = RegisterMaterial( "box_empty" ), topAnchor = false, bottomAnchor = false, leftAnchor = false, rightAnchor = true, top = -6, bottom = 6, left = -f26_local17 - 12, right = -f26_local17, alpha = 1 } ) f26_local18:registerAnimationState( "hidden", { material = RegisterMaterial( "box_empty" ), topAnchor = false, bottomAnchor = false, leftAnchor = false, rightAnchor = true, top = -6, bottom = 6, left = -f26_local17 - 12, right = -f26_local17, alpha = 0 } ) f26_local18:registerEventHandler( "refresh_purchased_state", function ( element, event ) local f31_local0 = Engine.AliensCheckIsItemPurchased( f26_local3, f26_local4 ) local f31_local1 = element local f31_local2 = element.animateToState local f31_local3 if f31_local0 then f31_local3 = "default" if not f31_local3 then else f31_local2( f31_local1, f31_local3, 0 ) end end f31_local3 = "hidden" end ) self:addElement( f26_local18 ) f26_local19 = LUI.UIImage.new( { material = RegisterMaterial( "white" ), red = Colors.alien_frontend_hilite.r, green = Colors.alien_frontend_hilite.g, blue = Colors.alien_frontend_hilite.b, topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 2, bottom = -2, left = 2, right = -2, alpha = 0 } ) f26_local19.id = "checkmark" f26_local19:registerAnimationState( "checked", { alpha = 1 } ) f26_local19:registerEventHandler( "refresh_enabled_state", function ( element, event ) local f32_local0 = Engine.AliensCheckIsUpgradeEnabled( f26_local3, f26_local4 ) local f32_local1 = element local f32_local2 = element.animateToState local f32_local3 if f32_local0 then f32_local3 = "checked" if not f32_local3 then else f32_local2( f32_local1, f32_local3, 0 ) end end f32_local3 = "default" end ) f26_local18:addElement( f26_local19 ) if f26_local9 then f26_local19:animateToState( "checked" ) else f26_local19:animateToState( "default" ) end if f26_local11 or f26_local10 or not f26_local8 then f26_local15:animateToState( "default" ) f26_local18:animateToState( "hidden" ) else f26_local15:animateToState( "hidden" ) f26_local18:animateToState( "default" ) end return self end end f26_local19 = 0.2 end end f26_local19 = 0.2 end end f26_local19 = 0.2 end end f26_local19 = Colors.primary_text_color.b end end f26_local19 = Colors.primary_text_color.g end end f26_local19 = Colors.primary_text_color.r end function TryConfirmPurchase( f33_arg0, f33_arg1, f33_arg2, f33_arg3 ) local f33_local0 = {} if CheckCanAfford( f33_arg1, f33_arg3 ) then f33_local0.yes_action = function ( f34_arg0, f34_arg1 ) ConfirmPurchase( f33_arg0, f33_arg1, f33_arg2, f33_arg3 ) end f33_local0.message_text = Engine.Localize( "LUA_MENU_MP_PURCHASE_CONFIRM", Engine.Localize( PurchasableItem_GetName( f33_arg2 ) ), tostring( f33_arg3 ) ) LUI.FlowManager.RequestPopupMenu( self, "aliens_confirm_purchase_popup", true, f33_arg1, false, f33_local0 ) else f33_local0.message_text = Engine.Localize( "LUA_MENU_MP_PUCRCHASE_DENIED", tostring( f33_arg3 ) ) LUI.FlowManager.RequestPopupMenu( self, "aliens_cannot_purchase_popup", true, f33_arg1, false, f33_local0 ) end end function ConfirmPurchase( f35_arg0, f35_arg1, f35_arg2, f35_arg3 ) if CheckCanAfford( f35_arg1, f35_arg3 ) then SetPlayerTokens( f35_arg1, GetPlayerTokens( f35_arg1 ) - f35_arg3 ) Engine.AliensSetIsItemPurchased( f35_arg1, f35_arg2, true ) AliensSetIsUpgradeEnabledWrapper( f35_arg1, f35_arg2, true ) f35_arg0:processEvent( { name = "refresh_purchased_state", immediate = true } ) f35_arg0:processEvent( { name = "refresh_enabled_state", immediate = true } ) f35_arg0:dispatchEventToRoot( { name = "refresh_cac_menu_buttons", controller = f35_arg1, immediate = true } ) end end function aliens_confirm_purchase_popup() return { type = "generic_yesno_popup", id = "confirm_purchase_popup_id", properties = { popup_title = Engine.Localize( "@LUA_MENU_PURCHASE_CAPS" ), yes_text = Engine.Localize( "@MENU_YES" ), no_text = Engine.Localize( "@LUA_MENU_CANCEL" ) } } end function aliens_cannot_purchase_popup() return { type = "generic_confirmation_popup", id = "aliens_cannot_purchase_popup_id", properties = { popup_title = Engine.Localize( "@MENU_ERROR" ), button_text = Engine.Localize( "@MENU_OK" ) } } end function aliens_gift_tokens_popup() return { type = "generic_confirmation_popup", id = "aliens_cannot_purchase_popup_id", properties = { popup_title = Engine.Localize( "@LUA_MENU_ALIENS" ), button_text = Engine.Localize( "@MENU_OK" ) } } end function OpenStorePrompt( f39_arg0, f39_arg1 ) if Engine.UserCanAccessStore( f39_arg0 ) then LUI.FlowManager.RequestPopupMenu( self, "aliens_prompt_to_real_money_store", true, f39_arg0, false, { message_text = Engine.Localize( "@ALIENS_UPGRADE_REQ_DLC_PROMPT", f39_arg1 ) } ) end end function GoToStore( f40_arg0, f40_arg1 ) if Engine.UserCanAccessStore( f40_arg1.controller ) then LUI.FlowManager.RequestLeaveMenu( f40_arg0 ) Engine.SetDvarBool( "ui_onlineRequired", true ) if not Sns.OpenStoreMenu( f40_arg1.controller, "extinction_armory", false, "dlc3" ) then Engine.SetDvarBool( "ui_onlineRequired", false ) else LUI.FlowManager.RequestLeaveMenuByName( "alien_purchasables_main" ) end end end function aliens_prompt_to_real_money_store() return { type = "generic_yesno_popup", id = "aliens_prompt_to_real_money_store", properties = { popup_title = Engine.Localize( "@LUA_MENU_ALIENS" ), yes_text = Engine.Localize( "@MENU_YES" ), yes_action = GoToStore, no_text = Engine.Localize( "@LUA_MENU_CANCEL" ) } } end function aliens_cac_armory_button() local f42_local0 = CoD.TextSettings.NormalFont.Height + 10 local f42_local1 = 120 local f42_local2 = 110 local f42_local3 = CoD.TextSettings.NormalFont local f42_local4 = Engine.Localize( "@LUA_MENU_MP_ARMORY_CAPS" ) local f42_local5, f42_local6, f42_local7, f42_local8 = GetTextDimensions( f42_local4, f42_local3.Font, f42_local3.Height ) local f42_local9 = f42_local7 - f42_local5 + f42_local1 + 10 local self = LUI.UIButton.new() self.id = "armory_button_id" self:registerAnimationState( "default", { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = 0, bottom = f42_local0 } ) self:registerEventHandler( "button_action", function ( element, event ) element:dispatchEventToRoot( { name = "hide_tip", immediate = true } ) element:dispatchEventToRoot( { name = "dim_all", immediate = true } ) element:dispatchEventToChildren( { name = "button_locked", immediate = true } ) OpenTokenStore( element, event ) end ) self:registerEventHandler( "button_over", function ( element, event ) element:dispatchEventToRoot( { name = "show_all", immediate = true } ) element:dispatchEventToRoot( { name = "update_tip", immediate = true, new_Text = Engine.Localize( "@LUA_MENU_MP_ARMORY_DESC" ) } ) element:dispatchEventToRoot( { name = "show_tip", immediate = true } ) element:dispatchEventToRoot( { name = "selection_info_set_header_text", newText = Engine.Localize( "@LUA_MENU_MP_ARMORY_CAPS" ), disabled_in_chaos = true } ) element:dispatchEventToRoot( { name = "show_bonus_pool", immediate = true } ) end ) self:registerEventHandler( "button_up", function ( element, event ) element:dispatchEventToRoot( { name = "hide_bonus_pool", immediate = true } ) end ) self:animateToState( "default", 0 ) local f42_local11 = LUI.UIImage.new() f42_local11.id = "btn_divider_id" f42_local11:registerAnimationState( "default", { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = true, topAnchor = false, bottomAnchor = true, left = 0, right = 0, top = 0, bottom = 1, alpha = 0.1 } ) f42_local11:animateToState( "default" ) self:addElement( f42_local11 ) local f42_local12 = LUI.UIImage.new() f42_local12.id = "armory_button_background" f42_local12:registerAnimationState( "default", { material = RegisterMaterial( "btn_alien_loadout_rtcap_f" ), leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = 0, top = 0, bottom = 10, red = 1, green = 1, blue = 1, alpha = 0 } ) f42_local12:registerAnimationState( "dim", { red = 1, green = 1, blue = 1, alpha = 0.5 } ) f42_local12:registerAnimationState( "focus", { red = 1, green = 1, blue = 1, alpha = 0.8 } ) f42_local12:registerAnimationState( "locked", { red = Colors.frontend_hilite.r, green = Colors.frontend_hilite.g, blue = Colors.frontend_hilite.b, alpha = 1 } ) f42_local12:registerEventHandler( "button_over", MBh.AnimateLoop( { { "focus", 0 }, { "dim", 750 }, { "focus", 750 } } ) ) f42_local12:registerEventHandler( "button_up", MBh.AnimateToState( "default", 0 ) ) f42_local12:registerEventHandler( "button_locked", MBh.AnimateToState( "focus", 0 ) ) f42_local12:animateToState( "default" ) self:addElement( f42_local12 ) local f42_local13 = LUI.UIText.new() f42_local13.id = "button_lable" f42_local13:registerAnimationState( "default", { font = f42_local3.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = f42_local1, right = 0, top = 5, bottom = 5 + f42_local3.Height, red = 0.7, green = 0.7, blue = 0.7, alpha = 1 } ) f42_local13:registerAnimationState( "focus", { red = 0, green = 0, blue = 0 } ) f42_local13:registerEventHandler( "button_over", MBh.AnimateToState( "focus" ) ) f42_local13:registerEventHandler( "button_up", MBh.AnimateToState( "default" ) ) f42_local13:registerEventHandler( "button_locked", MBh.AnimateToState( "focus" ) ) f42_local13:animateToState( "default" ) f42_local13:setText( f42_local4 ) self:addElement( f42_local13 ) local f42_local14 = LUI.UIText.new() f42_local14.id = "button_subtext" f42_local14:registerAnimationState( "default", { font = CoD.TextSettings.BoldFont.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = f42_local9, right = 0, top = 5, bottom = 5 + CoD.TextSettings.BoldFont.Height, red = 1, green = 1, blue = 1, alpha = 1 } ) f42_local14:registerAnimationState( "focus", { red = 0, green = 0, blue = 0 } ) f42_local14:registerEventHandler( "button_over", MBh.AnimateToState( "focus" ) ) f42_local14:registerEventHandler( "button_up", MBh.AnimateToState( "default" ) ) f42_local14:registerEventHandler( "button_locked", MBh.AnimateToState( "focus" ) ) f42_local14:animateToState( "default" ) f42_local14:setText( Engine.Localize( "@LUA_MENU_MP_ARMORY_SUBTEXT" ) ) self:addElement( f42_local14 ) return self end function weekly_bonus_widget( f46_arg0, f46_arg1, f46_arg2 ) local f46_local0 = f46_arg1 or {} local f46_local1 = f46_local0.controller if not f46_local1 then f46_local1 = Engine.GetFirstActiveController() end local f46_local2 = f46_local0.xPos or 0 local f46_local3 = f46_local0.yPos or 0 local self = LUI.UIElement.new() self.id = "weekly_bonus_widget" self:registerAnimationState( "default", { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = f46_local2, right = 0, top = f46_local3, bottom = 0, alpha = 0 } ) self:registerAnimationState( "visible", { alpha = 1 } ) self:registerEventHandler( "show_bonus_pool", MBh.AnimateToState( "visible" ) ) self:registerEventHandler( "hide_bonus_pool", MBh.AnimateToState( "default" ) ) self:animateToState( "default" ) if UsingExtinctionTokens() and IsOnlineMatch() then local f46_local5 = LUI.UIHorizontalList.new() f46_local5.id = "TextLineOneId" f46_local5:registerAnimationState( "default", { alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = 0, bottom = CoD.TextSettings.NormalFont.Height } ) f46_local5:animateToState( "default" ) self:addElement( f46_local5 ) local f46_local6 = Engine.Localize( "@ALIENS_BONUS_POOL" ) local f46_local7, f46_local8, f46_local9, f46_local10 = GetTextDimensions( f46_local6, CoD.TextSettings.NormalFont.Font, CoD.TextSettings.NormalFont.Height ) local f46_local11 = f46_local9 - f46_local7 + 5 local f46_local12 = LUI.UIText.new() f46_local12.id = "title_text" f46_local12:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = true, left = 0, right = f46_local11, top = 0, bottom = 0, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } ) f46_local12:setText( f46_local6 ) f46_local12:animateToState( "default" ) f46_local5:addElement( f46_local12 ) local f46_local13 = tostring( Engine.GetPlayerDataReservedInt( f46_local1, CoD.StatsGroup.Coop, "bonus_pool_size" ) or 0 ) local f46_local14, f46_local15, f46_local16, f46_local17 = GetTextDimensions( f46_local13, CoD.TextSettings.NormalFont.Font, CoD.TextSettings.NormalFont.Height ) f46_local10 = f46_local17 f46_local9 = f46_local16 f46_local8 = f46_local15 f46_local14 = f46_local9 - f46_local14 + 2 f46_local15 = LUI.UIText.new() f46_local15.id = "pool_text" f46_local15:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = true, left = 0, right = f46_local14, top = 0, bottom = 0, red = Colors.alien_frontend_hilite.r, green = Colors.alien_frontend_hilite.g, blue = Colors.alien_frontend_hilite.b } ) f46_local15:setTextStyle( CoD.TextStyle.Outlined ) f46_local15:setText( f46_local13 ) f46_local15:animateToState( "default" ) f46_local5:addElement( f46_local15 ) f46_local16 = LUI.UIImage.new() f46_local16.id = "tokens_icon_id" f46_local16:registerAnimationState( "default", { material = RegisterMaterial( "alien_icon_tooth" ), leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = true, left = 0, right = CoD.TextSettings.NormalFont.Height, top = 0, bottom = 0 } ) f46_local16:animateToState( "default" ) f46_local5:addElement( f46_local16 ) f46_local17 = LUI.UIText.new() f46_local17.id = "timer_text" f46_local17:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = CoD.TextSettings.NormalFont.Height, bottom = 2 * CoD.TextSettings.NormalFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } ) local f46_local18, f46_local19, f46_local20, f46_local21 = Engine.GetExtinctionBonusDeadline( f46_local1 ) f46_local17:setText( Engine.Localize( "LUA_MENU_DAYS_HOURS_MINUTES_SECONDS", f46_local18, f46_local19, f46_local20, f46_local21 ) ) f46_local17:registerEventHandler( "set_countdown_time", function ( element, event ) local f47_local0, f47_local1, f47_local2, f47_local3 = Engine.GetExtinctionBonusDeadline( f46_local1 ) element:setText( Engine.Localize( "LUA_MENU_DAYS_HOURS_MINUTES_SECONDS", f47_local0, f47_local1, f47_local2, f47_local3 ) ) Engine.UpdateExtinctionBonusDeadline( f46_local1 ) end ) f46_local17:animateToState( "default" ) self:addElement( f46_local17 ) local f46_local22 = LUI.UITimer.new( 500, "set_countdown_time", nil, false, false, false, false ) f46_local22.id = "bonus_countdown_timer" f46_local17:addElement( f46_local22 ) local f46_local23 = LUI.UIText.new() f46_local23.id = "subText1" f46_local23:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = 2 * CoD.TextSettings.NormalFont.Height, bottom = 3 * CoD.TextSettings.NormalFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } ) f46_local23:setText( Engine.Localize( "@ALIENS_BONUS_POOL_TIP" ) ) f46_local23:animateToState( "default" ) self:addElement( f46_local23 ) local f46_local24 = LUI.UIText.new() f46_local24.id = "subText2" f46_local24:registerAnimationState( "default", { font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = 3 * CoD.TextSettings.NormalFont.Height, bottom = 4 * CoD.TextSettings.NormalFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } ) f46_local24:setText( Engine.Localize( "@ALIENS_BONUS_POOL_DESC" ) ) f46_local24:animateToState( "default" ) self:addElement( f46_local24 ) end return self end LUI.MenuBuilder.registerType( "alien_purchasables_main", alien_purchasables_main ) LUI.MenuBuilder.registerType( "alien_purchasable_button", alien_purchasable_button ) LUI.MenuBuilder.registerType( "aliens_cac_armory_button", aliens_cac_armory_button ) LUI.MenuBuilder.registerDef( "aliens_confirm_purchase_popup", aliens_confirm_purchase_popup ) LUI.MenuBuilder.registerDef( "aliens_cannot_purchase_popup", aliens_cannot_purchase_popup ) LUI.MenuBuilder.registerDef( "aliens_gift_tokens_popup", aliens_gift_tokens_popup ) LUI.MenuBuilder.registerDef( "aliens_prompt_to_real_money_store", aliens_prompt_to_real_money_store ) LUI.MenuBuilder.registerType( "weekly_bonus_widget", weekly_bonus_widget ) end function alien_tokens_widget( f48_arg0, f48_arg1, f48_arg2 ) local f48_local0 = f48_arg1.controller if not f48_local0 then f48_local0 = Engine.GetFirstActiveController() end local f48_local1 = GetPlayerTokens( f48_local0 ) local f48_local2 = f48_arg1.xPos or 300 local f48_local3 = f48_arg1.yPos or 100 local f48_local4 = CoD.TextSettings.NormalFont local f48_local5 = f48_local4.Height local f48_local6 = 44 local f48_local7 = 6 local f48_local8 = 100 local self = LUI.UIElement.new() self.id = "tokens_widget_id" self:registerAnimationState( "default", { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = f48_local2, top = f48_local3, height = f48_local5, width = f48_local8 } ) self:animateToState( "default" ) if UsingExtinctionTokens() then local f48_local10 = LUI.UIImage.new() f48_local10.id = "bgIcon_id" f48_local10:registerAnimationState( "default", { material = RegisterMaterial( "alien_icon_tooth_bg" ), leftAnchor = true, rightAnchor = false, topAnchor = false, bottomAnchor = true, right = 58, bottom = 50, width = 128, height = 128 } ) f48_local10:animateToState( "default" ) self:addElement( f48_local10 ) local f48_local11 = LUI.UIText.new() f48_local11.id = "cost_text" f48_local11:registerAnimationState( "default", { font = f48_local4.Font, alignment = LUI.Alignment.Left, leftAnchor = true, rightAnchor = true, topAnchor = false, bottomAnchor = false, left = -3, right = -3, top = -f48_local4.Height / 2 - 3, bottom = f48_local4.Height / 2 - 3, red = 1, green = 1, blue = 1, alpha = 1 } ) f48_local11:setTextStyle( CoD.TextStyle.Outlined ) f48_local11:registerEventHandler( "refresh_bank", function ( element, event ) element:setText( tostring( GetPlayerTokens( f48_local0 ) ) ) end ) f48_local11:setText( tostring( f48_local1 ) ) f48_local11:animateToState( "default" ) self:addElement( f48_local11 ) local f48_local12 = LUI.UIImage.new() f48_local12.id = "tokens_icon_id" f48_local12:registerAnimationState( "default", { material = RegisterMaterial( "alien_icon_tooth" ), leftAnchor = true, rightAnchor = false, topAnchor = false, bottomAnchor = true, right = 0, bottom = 10, width = 32, height = 44 } ) f48_local12:animateToState( "default" ) self:addElement( f48_local12 ) self:addElement( LUI.UITimer.new( 200, "refresh_bank", nil, false, false, false, false ) ) end return self end LUI.MenuBuilder.registerType( "alien_tokens_widget", alien_tokens_widget ) LockTable( _M )