iw6-lui/lui/mp_menus/motdutils.dec.lua
2024-09-12 17:25:45 +02:00

319 lines
10 KiB
Lua

function TryForceOpenMOTD()
if Lobby.IsInPrivateParty() and not Lobby.IsPrivatePartyHost() then
return
end
local f1_local0 = Engine.GetFirstActiveController()
if not Engine.IsProfileSignedIn( f1_local0 ) then
return false
elseif not CanReadReserveData( f1_local0 ) then
return false
end
local f1_local1 = {}
local f1_local2 = 2
if HasSeenMOTDToday( f1_local0 ) and Engine.GetDvarString( "alwaysShowMOTD" ) ~= "1" then
return false
elseif Engine.HasSpeechFeature() and LUI.MenuAutoNav.IsRunning() then
return false
end
SetHasSeenMOTDToday( f1_local0 )
local f1_local3 = GetWelcomeScreenType( f1_local0 )
if f1_local3 then
table.insert( f1_local1, f1_local3 )
end
if #f1_local1 < f1_local2 and ShouldShowCodAnywherePrompt( f1_local0 ) then
table.insert( f1_local1, "codAnywhereUpsell" )
end
if Engine.GetDvarString( "motd" ) ~= "" then
table.insert( f1_local1, "motd" )
end
local f1_local4 = GetVotingLayout( f1_local0 )
if f1_local4 then
StartVoteImageDownload( f1_local0 )
table.insert( f1_local1, f1_local4 )
end
if #f1_local1 < f1_local2 and ShouldShowFestivePackUpsell( f1_local0 ) then
table.insert( f1_local1, "festiveUpsell" )
end
if #f1_local1 < f1_local2 and ShouldShowWolfPackUpsell( f1_local0 ) then
table.insert( f1_local1, "wolfpackUpsell" )
end
if #f1_local1 < f1_local2 and ShouldShowSeasonPassUpsell( f1_local0 ) then
table.insert( f1_local1, "seasonPassUpsell" )
end
if #f1_local1 < f1_local2 and ShouldShowDownloadReminder( f1_local0 ) then
table.insert( f1_local1, "downloadReminder" )
end
if #f1_local1 > 0 then
LUI.FlowManager.RequestPopupMenu( self, "motd_main", false, f1_local0, false, {
layoutQueue = f1_local1
}, nil, nil, false )
return true
end
return false
end
function CanReadReserveData( f2_arg0 )
if Engine.GetPlayerDataReservedInt( f2_arg0, CoD.StatsGroup.Common, "welcome_screen_count" ) then
return true
else
return false
end
end
function ResetMOTDCounters( f3_arg0 )
Engine.SetPlayerDataReservedInt( f3_arg0, CoD.StatsGroup.Common, "welcome_screen_count", 0 )
Engine.SetPlayerDataReservedInt( f3_arg0, CoD.StatsGroup.Common, "cod_anywhere_screen_count", 0 )
Engine.SetPlayerDataReservedInt( f3_arg0, CoD.StatsGroup.Common, "season_pass_upsell_count", 0 )
Engine.SetPlayerDataReservedInt( f3_arg0, CoD.StatsGroup.Common, "motd_today_day", 0 )
Engine.SetPlayerDataReservedInt( f3_arg0, CoD.StatsGroup.Common, "motd_today_month", 0 )
end
function HasSeenWelcomeScreen( f4_arg0 )
return Engine.GetPlayerDataReservedInt( f4_arg0, CoD.StatsGroup.Common, "welcome_screen_count" ) >= 1
end
function SetHasSeenWelcomeScreen( f5_arg0 )
Engine.SetPlayerDataReservedInt( f5_arg0, CoD.StatsGroup.Common, "welcome_screen_count", 1 )
end
function HasPlayedBlops2( f6_arg0 )
return Engine.GetPlayerDataEx( f6_arg0, CoD.StatsGroup.Common, "pastTitleData", "playedblackops2" )
end
function Blops2Prestige( f7_arg0 )
return Engine.GetPlayerDataEx( f7_arg0, CoD.StatsGroup.Common, "pastTitleData", "blackops2prestige" )
end
function HasPlayedMW3( f8_arg0 )
return Engine.GetPlayerDataEx( f8_arg0, CoD.StatsGroup.Common, "pastTitleData", "playedmw3" )
end
function MW3Prestige( f9_arg0 )
return Engine.GetPlayerDataEx( f9_arg0, CoD.StatsGroup.Common, "pastTitleData", "mw3prestige" )
end
function GetWelcomeScreenType( f10_arg0 )
if not HasSeenWelcomeScreen( f10_arg0 ) then
local f10_local0 = false
local f10_local1 = HasPlayedMW3( f10_arg0 )
if not f10_local1 then
f10_local1 = HasPlayedBlops2( f10_arg0 )
end
SetHasSeenWelcomeScreen( f10_arg0 )
if f10_local0 then
return "welcomeFounder"
elseif f10_local1 then
return "welcomeSoldier"
else
return "welcomeNoob"
end
else
return nil
end
end
function HasSeenMOTDToday( f11_arg0 )
local f11_local0 = Engine.GetRawMonthDayYear()
if f11_local0 then
if f11_local0.day ~= Engine.GetPlayerDataReservedInt( f11_arg0, CoD.StatsGroup.Common, "motd_today_day" ) then
return false
elseif f11_local0.month ~= Engine.GetPlayerDataReservedInt( f11_arg0, CoD.StatsGroup.Common, "motd_today_month" ) then
return false
end
end
return true
end
function SetHasSeenMOTDToday( f12_arg0 )
local f12_local0 = Engine.GetRawMonthDayYear()
if f12_local0 and f12_local0.day and f12_local0.month then
Engine.SetPlayerDataReservedInt( f12_arg0, CoD.StatsGroup.Common, "motd_today_day", f12_local0.day )
Engine.SetPlayerDataReservedInt( f12_arg0, CoD.StatsGroup.Common, "motd_today_month", f12_local0.month )
end
end
function GetNumTimesSeenSeasonPassUpsell( f13_arg0 )
return Engine.GetPlayerDataReservedInt( f13_arg0, CoD.StatsGroup.Common, "season_pass_upsell_count" )
end
function GetNumTimesPlayerShouldSeeSeasonPassUpsell()
return 6
end
function IncNumTimesPlayerHasSeenSeasonPassUpsell( f15_arg0 )
Engine.SetPlayerDataReservedInt( f15_arg0, CoD.StatsGroup.Common, "season_pass_upsell_count", Engine.GetPlayerDataReservedInt( f15_arg0, CoD.StatsGroup.Common, "season_pass_upsell_count" ) + 1 )
end
function ShouldShowSeasonPassUpsell( f16_arg0 )
if not Engine.AnyoneHasSeasonPass() and GetNumTimesSeenSeasonPassUpsell( f16_arg0 ) < GetNumTimesPlayerShouldSeeSeasonPassUpsell() then
IncNumTimesPlayerHasSeenSeasonPassUpsell( f16_arg0 )
return true
else
return false
end
end
function GetNumTimesSeenCodAnywherePrompt( f17_arg0 )
return Engine.GetPlayerDataReservedInt( f17_arg0, CoD.StatsGroup.Common, "cod_anywhere_screen_count" )
end
function GetNumTimesPlayerShouldSeeCodAnywherePrompt()
return 3
end
function IncNumTimesPlayerHasSeenCodAnywherePrompt( f19_arg0 )
Engine.SetPlayerDataReservedInt( f19_arg0, CoD.StatsGroup.Common, "cod_anywhere_screen_count", Engine.GetPlayerDataReservedInt( f19_arg0, CoD.StatsGroup.Common, "cod_anywhere_screen_count" ) + 1 )
end
function ShouldShowCodAnywherePrompt( f20_arg0 )
local f20_local0 = true
if CoDAnywhere.ShouldShowLinkCreatePopup( f20_arg0, true ) == true then
f20_local0 = false
end
if not f20_local0 and GetNumTimesSeenCodAnywherePrompt( f20_arg0 ) < GetNumTimesPlayerShouldSeeCodAnywherePrompt() then
IncNumTimesPlayerHasSeenCodAnywherePrompt( f20_arg0 )
return true
else
return false
end
end
function GetNumTimesSeenFestivePackUpsell( f21_arg0 )
return Engine.GetPlayerDataReservedInt( f21_arg0, CoD.StatsGroup.Common, "mp_upsell_holiday_count" )
end
function GetNumTimesPlayerShouldSeeFestivePackUpsell()
return 4
end
function IncNumTimesPlayerHasSeenFestivePackUpsell( f23_arg0 )
Engine.SetPlayerDataReservedInt( f23_arg0, CoD.StatsGroup.Common, "mp_upsell_holiday_count", Engine.GetPlayerDataReservedInt( f23_arg0, CoD.StatsGroup.Common, "mp_upsell_holiday_count" ) + 1 )
end
function ShouldShowFestivePackUpsell( f24_arg0 )
if not Cac.IsCustomizationItemUnlocked( f24_arg0, Cac.Customization.Fields[Cac.Customization.FieldIndexes.Patch], 574 ) and GetNumTimesSeenFestivePackUpsell( f24_arg0 ) < GetNumTimesPlayerShouldSeeFestivePackUpsell() then
IncNumTimesPlayerHasSeenFestivePackUpsell( f24_arg0 )
return true
else
return false
end
end
function GetNumTimesSeenWolfPackUpsell( f25_arg0 )
return Engine.GetPlayerDataReservedInt( f25_arg0, CoD.StatsGroup.Common, "mp_upsell_wolfpack_count" )
end
function GetNumTimesPlayerShouldSeeWolfPackUpsell()
return 4
end
function IncNumTimesPlayerHasSeenWolfPackUpsell( f27_arg0 )
Engine.SetPlayerDataReservedInt( f27_arg0, CoD.StatsGroup.Common, "mp_upsell_wolfpack_count", Engine.GetPlayerDataReservedInt( f27_arg0, CoD.StatsGroup.Common, "mp_upsell_wolfpack_count" ) + 1 )
end
function ShouldShowWolfPackUpsell( f28_arg0 )
if not (1 == Engine.GetDvarInt( "igs_swp" )) then
return false
elseif not Lobby.IsItemOfTypeUnlocked( f28_arg0, "wolf", "DLC" ) and GetNumTimesSeenWolfPackUpsell( f28_arg0 ) < GetNumTimesPlayerShouldSeeWolfPackUpsell() then
IncNumTimesPlayerHasSeenWolfPackUpsell( f28_arg0 )
return true
else
return false
end
end
function GetVotingLayout( f29_arg0 )
if ShouldDisplayVoteScreen( f29_arg0 ) then
return "voting"
else
return nil
end
end
function GetVotingImageFileID( f30_arg0 )
local f30_local0 = 0
if f30_arg0 == 0 then
f30_local0 = 347
else
f30_local0 = 348
end
return f30_local0
end
function GetVotingPageHeader()
return Engine.MarkLocalized( Engine.GetVotingHeader( GetActiveVoteIndex() ) )
end
function GetVotingItemHeader( f32_arg0 )
local f32_local0 = ""
if Engine.GetActiveVotes() == 1 then
f32_local0 = Engine.GetVoteItemText( 0, f32_arg0 )
end
return Engine.MarkLocalized( f32_local0 )
end
function GetNumberOfImagesForVote()
local f33_local0 = 0
if Engine.GetActiveVotes() == 1 then
f33_local0 = Engine.GetNumberOfImagesForVote( 0 )
end
return f33_local0
end
function CastVoteForItem( f34_arg0, f34_arg1 )
if Engine.GetActiveVotes() == 1 then
Engine.VoteForDLCItem( f34_arg0, GetActiveVoteIndex(), f34_arg1 )
Engine.SetPlayerDataReservedShort( f34_arg0, CoD.StatsGroup.Common, "common_last_vote_base_counter", Engine.GetVotingID( GetActiveVoteIndex() ) )
end
end
function ShouldDisplayVoteScreen( f35_arg0 )
if Engine.GetActiveVotes() > 0 then
local f35_local0 = Engine.GetPlayerDataReservedShort( f35_arg0, CoD.StatsGroup.Common, "common_last_vote_base_counter" )
local f35_local1 = Engine.GetVotingID( GetActiveVoteIndex() )
if f35_local1 > -1 and f35_local1 ~= f35_local0 then
return true
end
end
return false
end
function StartVoteImageDownload( f36_arg0 )
Engine.StartVoteImageDownload( f36_arg0 )
end
function IsVoteImageDownloaded( f37_arg0 )
return Engine.IsVoteImageDownloaded( f37_arg0 )
end
function GetActiveVoteIndex()
return 0
end
function ShouldShowDownloadReminder( f39_arg0 )
return #GetMapPacksUserCanDownloadViaSeasonPass() > 0
end
function GetMapPacksUserCanDownloadViaSeasonPass()
local f40_local0 = {}
if not Engine.AnyoneHasSeasonPass() then
return f40_local0
end
local f40_local1 = Engine.GetDvarInt( "num_available_map_packs" )
for f40_local2 = 1, f40_local1, 1 do
if not Engine.AnyoneHasSpecificDLCPack( "dlc" .. 2 + f40_local2 ) then
table.insert( f40_local0, f40_local2 )
end
end
return f40_local0
end
function GetDownloadReminderMessage()
local f41_local0 = Engine.Localize( "LUA_MENU_MP_MOTD_DOWNLOAD_PURCHASED_DLC" )
for f41_local4, f41_local5 in ipairs( GetMapPacksUserCanDownloadViaSeasonPass() ) do
f41_local0 = f41_local0 .. "\n - " .. Engine.Localize( "DLC_MAP_PACK_" .. f41_local5 )
end
return f41_local0
end