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

334 lines
9.0 KiB
Lua

NewsType = {
News = 0,
Item = 1
}
FeedCategory = {
MOTD = 0,
News = 1,
Clans = 2,
Squads = 3,
Social = 4
}
FeedSubCategory = {
{
News = 0,
Event = 1,
NewItems = 2,
Sale = 3
},
{
GettingStarted = 0,
Invite = 1,
ClanWarUpdate = 2
},
{
Default = 0
},
{
AverageScore = 0,
GamesPlayed = 1,
TimePlayed = 2,
Wins = 3,
WinStreak = 4,
KDRatio = 5,
Kills = 6,
KillStreak = 7
}
}
StoreCategory = {
SeasonPass = 0,
MapPacks = 1,
Personalization = 2,
Customization = 3,
ExtraSlots = 4,
AnnouncerVoices = 5,
AdditionalItems = 6,
Avatar = 7,
Crossgame = 8
}
Sns = {
Dims = {
Thumbnail = {
width = 160,
height = 80
},
DefaultArticleImage = {
width = 320,
height = 320,
maxWidth = 370,
maxHeight = 340
}
},
MaxVisibleArticles = 4,
MaxPrefetchArticles = 4,
HListOffset = 10,
HListSpacing = 25,
TickerCategory = FeedCategory.News,
TickerIndex = 0,
TickerScrollSpeed = 1000,
TickerUpdateInterval = 12000
}
function CrossGameHackVisual( f1_arg0 )
local f1_local0
if not Engine.IsXbox360() and not Engine.IsXB3() and not Engine.IsPS3() then
f1_local0 = Engine.IsPS4()
if f1_local0 then
else
return f1_local0
end
end
f1_local0 = f1_arg0 == StoreCategory.Crossgame
end
function CrossGameHackData( f2_arg0 )
local f2_local0
if not Engine.IsXbox360() and not Engine.IsXB3() then
f2_local0 = Engine.IsPS4()
if f2_local0 then
else
return f2_local0
end
end
f2_local0 = f2_arg0 == StoreCategory.Crossgame
end
Sns.UpdateScopedArticleInfo = function ( f3_arg0, f3_arg1 )
local f3_local0 = f3_arg1 or LUI.FlowManager.GetMenuScopedDataFromElement( f3_arg0 )
local f3_local1 = CrossGameHackData( f3_local0.category )
local f3_local2, f3_local3 = nil
if f3_local1 then
f3_local2 = {
title = Engine.Localize( "LUA_MENU_STORE_CROSS_GAME" ),
details = Engine.Localize( "LUA_MENU_STORE_CROSS_GAME_DESC" ),
image = "",
thumbName = "",
cost = -1,
sale = 0
}
else
f3_local2 = Store.GetCompleteItemInfoByIndex( f3_local0.category, f3_local0.articleIndex )
f3_local3 = Store.IsItemPurchasedByIndex( f3_local0.category, f3_local0.articleIndex )
DebugPrint( "Proper image info " .. tostring( f3_local2.image ) .. " " .. tostring( f3_local2.thumbName ) )
end
local f3_local4 = {
itemId = f3_local0.articleId
}
local f3_local5 = f3_local2.title
if not f3_local5 then
f3_local5 = "Content " .. itemId .. " has no title"
end
f3_local4.title = f3_local5
f3_local5 = f3_local2.details
if not f3_local5 then
f3_local5 = "Content " .. itemId .. " has no text"
end
f3_local4.details = f3_local5
f3_local4.image = f3_local2.image
f3_local4.thumbName = f3_local2.thumbName
f3_local4.cost = f3_local2.cost
f3_local4.sale = f3_local2.sale
f3_local4.endTime = 0
f3_local4.purchased = f3_local3
f3_local0.articleInfo = f3_local4
f3_local0.articleInfo.details = f3_local0.articleInfo.details .. "\n"
end
Sns.GetScopedArticleInfo = function ( f4_arg0, f4_arg1 )
local f4_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f4_arg0 )
if f4_arg1 and f4_local0.articleInfo then
return f4_local0.articleInfo[f4_arg1]
else
return f4_local0.articleInfo
end
end
Sns.IsRedeemCodeDisabled = function ()
return Engine.GetDvarInt( "ui_disableTokenRedemption" ) == 1
end
Sns.IsStoreDisabled = function ()
return Engine.GetDvarInt( "ui_disableInGameStore" ) == 1
end
Sns.SetContextualMenuLocation = function ( f7_arg0 )
Engine.SetStoreEnterTimestamp()
if f7_arg0 then
Engine.SetDvarString( "ui_contextualMenuLocation", f7_arg0 )
else
Engine.SetDvarString( "ui_contextualMenuLocation", "store" )
end
end
Sns.OpenStoreLinkConfirmPopup = function ( f8_arg0, f8_arg1 )
local f8_local0 = {
callback_params = {
dlcName = f8_arg1
}
}
if Engine.IsXbox360() and Engine.GetCurrentLanguage() ~= 5 and Engine.GetCurrentLanguage() ~= 10 then
Sns.SetContextualMenuLocation( "cac" )
Store.ShowSystemOffer( f8_arg0, f8_arg1 )
else
LUI.FlowManager.RequestPopupMenu( self, "goto_store", true, f8_arg0, false, f8_local0 )
end
end
Sns.OpenStoreMenu = function ( f9_arg0, f9_arg1, f9_arg2, f9_arg3 )
local f9_local0 = assert
local f9_local1 = Engine.GetDvarBool( "onlinegame" )
if not f9_local1 then
f9_local1 = Engine.GetDvarBool( "ui_onlineRequired" )
end
f9_local0( f9_local1 )
if Engine.IsConsoleGame() then
if Sns.IsStoreDisabled() then
LUI.FlowManager.RequestPopupMenu( self, "store_disabled_error", false, f9_arg0, false )
elseif Engine.UserIsGuest( f9_arg0 ) then
LUI.FlowManager.RequestPopupMenu( self, "store_noguests_error", false, f9_arg0, false )
elseif Engine.IsPS3() and f9_arg0 ~= 0 then
LUI.FlowManager.RequestPopupMenu( self, "mp_wrong_controller_popup", false, f9_arg0, false )
else
Store.ClearContentCache( f9_arg0 )
Sns.SetContextualMenuLocation( f9_arg1 )
Engine.ExecNow( "incnosplitscreencontrol menu_STORE" )
f9_local0 = {
initialDlcName = f9_arg3
}
if Engine.GetDvarInt( "igs_sosp" ) == 1 or Engine.IsXbox360() == false then
LUI.FlowManager.RequestAddMenu( self, "store_main", true, f9_arg0, f9_arg2, f9_local0 )
else
LUI.FlowManager.RequestPopupMenu( self, "finding_player_purchases", true, f9_arg0, false, {
storeData = f9_local0
} )
end
return true
end
else
Engine.Exec( "xshowmarketplace" )
end
return false
end
Sns.GetTickerHeader = function ( f10_arg0, f10_arg1 )
if f10_arg0 == FeedCategory.Squads then
local f10_local0 = SvS.GetSquadReportData( Engine.GetControllerForLocalClient( 0 ), f10_arg1 )
return Engine.Localize( "SOCIALFEED_SQUAD_HEADER", Engine.MarkLocalized( f10_local0.enemyName ) )
else
return SocialFeed.GetArticleHeader( f10_arg0, f10_arg1 )
end
end
function RefreshThumbnails( f11_arg0, f11_arg1 )
f11_arg0:closeChildren()
f11_arg0:clearSavedState()
f11_arg0:processEvent( {
name = "menu_refresh"
} )
if LUI.FlowManager.IsMenuTopmost( Engine.GetLuiRoot(), "store_main" ) then
f11_arg0:processEvent( {
name = "gain_focus"
} )
end
f11_arg0:processEvent( {
name = "update_sale_banners"
} )
f11_arg0:processEvent( {
name = "update_purchase_checkboxes"
} )
f11_arg0:processEvent( {
name = "update_hack_banner"
} )
end
Sns.OpenStore = function ( f12_arg0, f12_arg1 )
local f12_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f12_arg0 )
LUI.FlowManager.RequestAddMenu( f12_arg0, "store_main", true, f12_local0.exclusiveController, false, {
reqiestedItem = f12_arg1
} )
end
Sns.OpenSocialFeed = function ( f13_arg0, f13_arg1, f13_arg2 )
if Engine.IsUserAGuest( f13_arg1 ) then
LUI.FlowManager.RequestPopupMenu( f13_arg0, "mp_no_guest_popup", false, f13_arg1, false )
else
Squad.UpdateReportPlayerCardCache( f13_arg1 )
LUI.FlowManager.RequestAddMenu( f13_arg0, "social_feed_main", true, f13_arg1, false, {
fromLobby = f13_arg2 or false
} )
end
end
Sns.SocialFeedEnabled = function ()
local f14_local0 = false
if Engine.GetDvarInt( "social_feed_motd_active" ) == 1 then
f14_local0 = true
elseif Engine.GetDvarInt( "social_feed_news_active" ) == 1 then
f14_local0 = true
elseif Engine.GetDvarInt( "social_feed_clans_active" ) == 1 then
f14_local0 = true
elseif Engine.GetDvarInt( "social_feed_squads_active" ) == 1 then
f14_local0 = true
elseif Engine.GetDvarInt( "social_feed_social_active" ) == 1 then
f14_local0 = true
end
return f14_local0
end
Sns.ChangeTickerStory = function ( f15_arg0, f15_arg1 )
local f15_local0 = Engine.GetControllerForLocalClient( 0 )
local f15_local1 = SocialFeed.GetArticleCount( f15_local0, Sns.TickerCategory )
Sns.TickerIndex = Sns.TickerIndex + 1
if f15_local1 <= Sns.TickerIndex then
local f15_local2 = Sns.TickerCategory
repeat
f15_local2 = f15_local2 + 1
if f15_local2 > FeedCategory.Social then
f15_local2 = FeedCategory.News
end
if SocialFeed.GetArticleCount( f15_local0, f15_local2 ) > 0 then
Sns.TickerCategory = f15_local2
break
else
end
until f15_local2 == Sns.TickerCategory
Sns.TickerIndex = 0
end
if f15_arg0.tickerText and f15_local1 > Sns.TickerIndex then
f15_arg0.nextText:setText( Sns.GetTickerHeader( Sns.TickerCategory, Sns.TickerIndex ) )
f15_arg0.tickerText:animateToState( "transition_to_next", Sns.TickerScrollSpeed )
f15_arg0.nextText:animateToState( "transition_to_next", Sns.TickerScrollSpeed )
end
end
Sns.TickerScrollEnded = function ( f16_arg0, f16_arg1 )
f16_arg0.tickerText:setText( Sns.GetTickerHeader( Sns.TickerCategory, Sns.TickerIndex ) )
f16_arg0.tickerText:animateToState( "default", 0 )
f16_arg0.nextText:animateToState( "default", 0 )
end
Sns.GetArticleImageDims = function ( f17_arg0, f17_arg1 )
local f17_local0 = Sns.Dims.DefaultArticleImage.width
local f17_local1 = Sns.Dims.DefaultArticleImage.height
if f17_arg0 then
f17_local0 = math.min( f17_arg0, Sns.Dims.DefaultArticleImage.maxWidth )
end
if f17_arg1 then
f17_local1 = math.min( f17_arg1, Sns.Dims.DefaultArticleImage.maxHeight )
end
return f17_local0, f17_local1
end
Sns.IsSeasonPassAccessible = function ()
local f18_local0
if Engine.GetCurrentLanguage() == 5 or Engine.GetCurrentLanguage() == 10 then
f18_local0 = false
else
f18_local0 = true
end
return f18_local0
end