426 lines
15 KiB
Lua
426 lines
15 KiB
Lua
local f0_local0 = module
|
|
local f0_local1, f0_local2 = ...
|
|
f0_local0( f0_local1, package.seeall )
|
|
CoD.PrintModuleLoad( _NAME )
|
|
LUI.Playercard = {}
|
|
XP_BAR_WIDTH = 212
|
|
LUI.Playercard.new = function ( f1_arg0, f1_arg1, f1_arg2 )
|
|
local f1_local0 = 130
|
|
local self = LUI.UIElement.new()
|
|
self:registerAnimationState( "default", {
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
top = 0,
|
|
left = 0,
|
|
height = 128,
|
|
width = 512,
|
|
alpha = 1
|
|
} )
|
|
self:registerAnimationState( "hidden", {
|
|
alpha = 0
|
|
} )
|
|
self:animateToState( "default" )
|
|
self.card = LUI.UIElement.new()
|
|
local f1_local2 = self.card
|
|
self:addElement( f1_local2 )
|
|
f1_local2.id = "playercard" .. (f1_arg1.gamertag and "_" .. f1_arg1.gamertag or "")
|
|
f1_local2:registerAnimationState( "default", {
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
top = -18,
|
|
left = -12,
|
|
height = 128,
|
|
width = 512
|
|
} )
|
|
f1_local2:animateToState( "default" )
|
|
local f1_local3 = LUI.UIImage.new()
|
|
f1_local3.id = "mainBG"
|
|
f1_local3:registerAnimationState( "default", {
|
|
material = RegisterMaterial( "card_bg" ),
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
top = 0,
|
|
bottom = 0,
|
|
left = 0,
|
|
right = 0
|
|
} )
|
|
f1_local3:animateToState( "default" )
|
|
f1_local2:addElement( f1_local3 )
|
|
f1_local2.playerBG = LUI.UIImage.new()
|
|
f1_local2.playerBG.id = "playerBG"
|
|
f1_local2.playerBG:animateToState( "default" )
|
|
f1_local2:addElement( f1_local2.playerBG )
|
|
f1_local2.playerBGdarken = LUI.UIImage.new()
|
|
f1_local2.playerBGdarken.id = "playerBGdarken"
|
|
f1_local2.playerBGdarken:registerAnimationState( "default", {
|
|
topAnchor = false,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
width = 399,
|
|
height = 64,
|
|
bottom = -24,
|
|
left = 53,
|
|
alpha = 0.85
|
|
} )
|
|
f1_local2.playerBGdarken:animateToState( "default" )
|
|
f1_local2.playerBGdarken:setImage( RegisterMaterial( "card_image_darken" ) )
|
|
f1_local2:addElement( f1_local2.playerBGdarken )
|
|
f1_local2.gamertag = LUI.UIMarqueeText.new()
|
|
f1_local2.gamertag.id = "gamertag"
|
|
f1_local2.gamertag:registerAnimationState( "default", {
|
|
alignment = LUI.Alignment.Left,
|
|
font = CoD.TextSettings.NormalFont.Font,
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
left = f1_local0,
|
|
right = -60,
|
|
top = 18,
|
|
height = CoD.TextSettings.NormalFont.Height
|
|
} )
|
|
f1_local2.gamertag:animateToState( "default" )
|
|
f1_local2:addElement( f1_local2.gamertag )
|
|
f1_local2.slogan = LUI.UIMarqueeText.new()
|
|
f1_local2.slogan.id = "slogan"
|
|
f1_local2.slogan:setTextStyle( CoD.TextStyle.OutlinedMore )
|
|
f1_local2.slogan:registerAnimationState( "default", {
|
|
alignment = LUI.Alignment.Left,
|
|
font = CoD.TextSettings.NormalFont.Font,
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
left = f1_local0,
|
|
right = -60,
|
|
top = 40,
|
|
height = CoD.TextSettings.NormalFont.Height,
|
|
red = 1,
|
|
green = 1,
|
|
blue = 1
|
|
} )
|
|
f1_local2.slogan:animateToState( "default" )
|
|
f1_local2:addElement( f1_local2.slogan )
|
|
f1_local2.clantag = LUI.UIText.new()
|
|
f1_local2.clantag.id = "clantag"
|
|
f1_local2.clantag.m_textStyle = CoD.TextStyle.OutlinedMore
|
|
f1_local2.clantag:registerAnimationState( "default", {
|
|
alignment = LUI.Alignment.Left,
|
|
font = CoD.TextSettings.NormalFont.Font,
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
left = f1_local0,
|
|
right = -60,
|
|
top = 80,
|
|
height = CoD.TextSettings.NormalFont.Height,
|
|
red = Colors.primary_text_color.r,
|
|
green = Colors.primary_text_color.g,
|
|
blue = Colors.primary_text_color.b
|
|
} )
|
|
f1_local2.clantag:animateToState( "default" )
|
|
f1_local2:addElement( f1_local2.clantag )
|
|
if not (not IsPublicMatch or not IsPublicMatch()) or Engine.IsAliensMode() or f1_arg1.force_show_rank then
|
|
f1_local2.rankIcon = LUI.UIImage.new()
|
|
f1_local2.rankIcon.id = "rankIcon"
|
|
f1_local2:addElement( f1_local2.rankIcon )
|
|
f1_local2.rankNum = LUI.UIText.new()
|
|
f1_local2.rankNum.id = "rankNum"
|
|
f1_local2.rankNum.m_textStyle = CoD.TextStyle.ShadowedMore
|
|
f1_local2.rankNum:registerAnimationState( "default", {
|
|
alignment = LUI.Alignment.Right,
|
|
font = CoD.TextSettings.BigFont.Font,
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
leftAnchor = false,
|
|
rightAnchor = true,
|
|
left = -165,
|
|
right = -65,
|
|
top = 58,
|
|
height = CoD.TextSettings.BigFont.MaxHeight
|
|
} )
|
|
f1_local2.rankNum:animateToState( "default" )
|
|
f1_local2:addElement( f1_local2.rankNum )
|
|
end
|
|
if f1_arg1.use_level_progress then
|
|
LUI.Playercard.AddLevelProgressBar( f1_local2 )
|
|
end
|
|
f1_local2.patchShape = LUI.UIImage.new()
|
|
f1_local2.patchShape.id = "patchShape"
|
|
f1_local2:addElement( f1_local2.patchShape )
|
|
f1_local2.patchEmblem = LUI.UIImage.new()
|
|
f1_local2.patchEmblem.id = "patchEmblem"
|
|
f1_local2.patchEmblem:animateToState( "default" )
|
|
f1_local2.patchEmblem.scale = f1_arg1.patchScale or 0
|
|
f1_local2:addElement( f1_local2.patchEmblem )
|
|
self.feedContent = LUI.Playercard.FeedContent
|
|
self:registerEventHandler( "update_playercard", function ( element, event )
|
|
element:feedContent( event )
|
|
end )
|
|
self:registerEventHandler( "hide_playercard", function ( element, event )
|
|
element:animateToState( "hidden", event.fade or 0 )
|
|
end )
|
|
self:registerEventHandler( "show_playercard", function ( element, event )
|
|
element:animateToState( "default", event.fade or 0 )
|
|
end )
|
|
self:feedContent( f1_arg1 )
|
|
return self
|
|
end
|
|
|
|
LUI.Playercard.AddLevelProgressBar = function ( f5_arg0 )
|
|
local f5_local0 = 0
|
|
local f5_local1 = 140
|
|
local f5_local2 = -50
|
|
local f5_local3 = 150
|
|
local f5_local4 = CoD.TextSettings.SmallFont.Height
|
|
|
|
local levelProgressContainer = LUI.UIElement.new( CoD.CreateState( 45, -22, -58, 0, CoD.AnchorTypes.BottomLeftRight ) )
|
|
levelProgressContainer.id = "playercard_level_bar_container_id"
|
|
local f5_local6 = CoD.CreateState( 0, 0, f5_local3, 0, CoD.AnchorTypes.TopBottomLeft )
|
|
CoD.ColorizeState( Colors.black, f5_local6 )
|
|
f5_local6.material = RegisterMaterial( "box_white_gradient_fade_rt" )
|
|
f5_arg0.bgFade = LUI.UIImage.new( f5_local6 )
|
|
levelProgressContainer:addElement( f5_arg0.bgFade )
|
|
f5_local6 = CoD.CreateState( f5_local3, 0, 0, 0, CoD.AnchorTypes.All )
|
|
CoD.ColorizeState( Colors.black, f5_local6 )
|
|
f5_local6.material = RegisterMaterial( "white" )
|
|
f5_arg0.bgFill = LUI.UIImage.new( f5_local6 )
|
|
levelProgressContainer:addElement( f5_arg0.bgFill )
|
|
f5_local6 = CoD.CreateState( f5_local1, 6, f5_local1 + XP_BAR_WIDTH, -6, CoD.AnchorTypes.TopBottomLeft )
|
|
CoD.ColorizeState( Colors.grey_2, f5_local6 )
|
|
f5_arg0.xpBar = LUI.UIImage.new( f5_local6 )
|
|
f5_arg0.xpBar.id = "playercard_level_bar_bg_id"
|
|
levelProgressContainer:addElement( f5_arg0.xpBar )
|
|
f5_local6 = CoD.CreateState( 0, 0, 0, 0, CoD.AnchorTypes.TopBottomLeft )
|
|
f5_local6.material = RegisterMaterial( "btn_cas_fill_f" )
|
|
f5_arg0.xpFillBar = LUI.UIImage.new( {
|
|
f5_local6
|
|
} )
|
|
f5_arg0.xpFillBar.id = "playercard_level_bar_id"
|
|
f5_arg0.xpBar:addElement( f5_arg0.xpFillBar )
|
|
f5_arg0.currentRankIcon = LUI.UIImage.new( CoD.CreateState( f5_local1 - 26, f5_local0, f5_local1 - 6, f5_local0 + f5_local4, CoD.AnchorTypes.TopLeft ) )
|
|
f5_arg0.currentRankIcon.id = "playercard_current_rank_icon_id"
|
|
f5_local6 = CoD.CreateState( 0, f5_local0, f5_local1 - 32, f5_local0 + f5_local4, CoD.AnchorTypes.TopLeft )
|
|
f5_local6.font = CoD.TextSettings.SmallFont.Font
|
|
f5_local6.alignment = LUI.Alignment.Right
|
|
CoD.ColorizeState( Colors.md_grey, f5_local6 )
|
|
f5_arg0.currentRankText = LUI.UIText.new( f5_local6 )
|
|
f5_arg0.currentRankText.id = "playercard_current_rank_id"
|
|
f5_arg0.nextRankIcon = LUI.UIImage.new( CoD.CreateState( f5_local2, f5_local0, f5_local2 + 20, f5_local0 + f5_local4, CoD.AnchorTypes.TopRight ) )
|
|
f5_arg0.nextRankIcon.id = "playercard_next_rank_icon_id"
|
|
f5_local6 = CoD.CreateState( f5_local2 + 25, f5_local0, 0, f5_local0 + f5_local4, CoD.AnchorTypes.TopRight )
|
|
f5_local6.font = CoD.TextSettings.SmallFont.Font
|
|
f5_local6.alignment = LUI.Alignment.Left
|
|
CoD.ColorizeState( Colors.md_grey, f5_local6 )
|
|
f5_arg0.nextRankText = LUI.UIText.new( f5_local6 )
|
|
f5_arg0.nextRankText.id = "playercard_next_rank_id"
|
|
levelProgressContainer:addElement( f5_arg0.currentRankIcon )
|
|
levelProgressContainer:addElement( f5_arg0.currentRankText )
|
|
levelProgressContainer:addElement( f5_arg0.nextRankIcon )
|
|
levelProgressContainer:addElement( f5_arg0.nextRankText )
|
|
f5_arg0:addElement( levelProgressContainer )
|
|
f5_arg0.levelProgressContainer = levelProgressContainer
|
|
|
|
end
|
|
|
|
LUI.Playercard.FeedContent = function ( f6_arg0, f6_arg1 )
|
|
local f6_local0 = f6_arg0.card
|
|
if f6_arg1.gamertag then
|
|
f6_local0.gamertag:setText( f6_arg1.gamertag )
|
|
end
|
|
if f6_arg1.clantag then
|
|
local f6_local1 = f6_arg1.clantag
|
|
if f6_arg1.clantag ~= "" then
|
|
if not string.find( f6_arg1.clantag, "[", nil, true ) then
|
|
f6_local1 = "[" .. f6_local1
|
|
end
|
|
if not string.find( f6_arg1.clantag, "]", nil, true ) then
|
|
f6_local1 = f6_local1 .. "]"
|
|
end
|
|
end
|
|
f6_local0.clantag:setText( f6_local1 )
|
|
end
|
|
if f6_arg1.background then
|
|
local f6_local1 = RegisterMaterial( Cac.Customization.Fields[Cac.Customization.FieldIndexes.Background].GetUIMaterial( f6_arg1.background ) )
|
|
if f6_local1 then
|
|
f6_local0.playerBG:setImage( f6_local1 )
|
|
f6_local0.playerBG:registerAnimationState( "default", {
|
|
topAnchor = false,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
width = 399,
|
|
height = 64,
|
|
bottom = -24,
|
|
left = 53
|
|
} )
|
|
f6_local0.playerBG:animateToState( "default" )
|
|
end
|
|
end
|
|
if f6_local0.rankIcon and f6_local0.rankNum and f6_arg1.rank and f6_arg1.prestige then
|
|
local f6_local1 = Engine.IsAliensMode() and CoD.PlayMode.Aliens or CoD.PlayMode.Core
|
|
local f6_local2 = Rank.GetRankDisplay( f6_arg1.rank, f6_local1 )
|
|
f6_local0.rankNum:setText( f6_local2 )
|
|
local f6_local3 = RegisterMaterial( Rank.GetRankIcon( f6_arg1.rank, f6_arg1.prestige, f6_local1 ) )
|
|
if f6_local3 then
|
|
local f6_local4 = f6_arg1.prestige > 0
|
|
local f6_local5
|
|
if f6_local4 then
|
|
f6_local5 = 46
|
|
if not f6_local5 then
|
|
|
|
else
|
|
local f6_local6
|
|
if f6_local4 then
|
|
f6_local6 = 61
|
|
if not f6_local6 then
|
|
|
|
else
|
|
local f6_local7, f6_local8, f6_local9, f6_local10 = GetTextDimensions( f6_local2, CoD.TextSettings.BigFont.Font, CoD.TextSettings.BigFont.MaxHeight )
|
|
local f6_local11 = f6_local9 - f6_local7
|
|
f6_local0.rankIcon:setImage( f6_local3 )
|
|
f6_local0.rankIcon:registerAnimationState( "default", {
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
leftAnchor = false,
|
|
rightAnchor = true,
|
|
top = f6_local6,
|
|
right = -70 - f6_local11,
|
|
width = f6_local5,
|
|
height = f6_local5
|
|
} )
|
|
f6_local0.rankIcon:animateToState( "default" )
|
|
end
|
|
end
|
|
f6_local6 = 63
|
|
end
|
|
end
|
|
f6_local5 = 40
|
|
end
|
|
end
|
|
if f6_arg1.patchShape then
|
|
local f6_local1 = RegisterMaterial( Cac.Customization.Fields[Cac.Customization.FieldIndexes.Patchbacking].GetUIMaterial( f6_arg1.patchShape ) )
|
|
if f6_local1 then
|
|
f6_local0.patchShape:setImage( f6_local1 )
|
|
f6_local0.patchShape:registerAnimationState( "default", {
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
top = 0,
|
|
left = 0,
|
|
width = 128,
|
|
height = 128
|
|
} )
|
|
f6_local0.patchShape:animateToState( "default" )
|
|
end
|
|
end
|
|
if f6_arg1.patchEmblem then
|
|
local f6_local1 = RegisterMaterial( Cac.Customization.Fields[Cac.Customization.FieldIndexes.Patch].GetUIMaterial( f6_arg1.patchEmblem ) )
|
|
if f6_local1 then
|
|
f6_local0.patchEmblem:setImage( f6_local1 )
|
|
f6_local0.patchEmblem:registerAnimationState( "default", {
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
top = 0,
|
|
left = 0,
|
|
width = 128,
|
|
height = 128,
|
|
red = 1,
|
|
green = 1,
|
|
blue = 1,
|
|
alpha = 1,
|
|
scale = f6_local0.patchEmblem.scale
|
|
} )
|
|
f6_local0.patchEmblem:animateToState( "default" )
|
|
end
|
|
local f6_local2 = Cac.Customization.Fields[Cac.Customization.FieldIndexes.Patch]
|
|
if f6_local2 and f6_local2.GetQuip then
|
|
local f6_local3 = f6_local2.GetQuip( f6_arg1.patchEmblem )
|
|
if f6_local3 then
|
|
f6_local0.slogan:setText( Engine.Localize( f6_local3 ) )
|
|
end
|
|
end
|
|
end
|
|
if f6_arg1.experience and f6_arg1.prestige and f6_local0.levelProgressContainer then
|
|
local f6_local1 = Engine.GetCurrentCoDPlayMode()
|
|
local f6_local2 = Rank.GetMaxRank( f6_local1 )
|
|
local f6_local3 = Engine.IsAliensMode() and Lobby.GetAlienRankForXP( f6_arg1.experience ) or Lobby.GetRankForXP( f6_arg1.experience )
|
|
local f6_local4
|
|
if f6_local3 < f6_local2 then
|
|
f6_local4 = f6_local3 + 1
|
|
if not f6_local4 then
|
|
|
|
else
|
|
local f6_local5 = Engine.IsAliensMode() and LUI.mp_menus.Aliens.AlienRanks.MaxPrestige or Lobby.GetMaxPrestigeLevel()
|
|
local f6_local6 = Rank.GetRankMaxXP( f6_local2 ) <= f6_arg1.experience
|
|
f6_local0.currentRankText:setText( Rank.GetRankDisplay( f6_local3 ) )
|
|
local f6_local7 = RegisterMaterial( Rank.GetRankIcon( f6_local3, f6_arg1.prestige, f6_local1 ) )
|
|
if f6_local7 then
|
|
f6_local0.currentRankIcon:setImage( f6_local7 )
|
|
end
|
|
local f6_local8 = false
|
|
if not Engine.IsAliensMode() and f6_local3 == f6_local4 and not f6_local6 and f6_arg1.prestige < f6_local5 then
|
|
f6_local8 = true
|
|
end
|
|
if Engine.IsAliensMode() and f6_local3 == LUI.mp_menus.Aliens.AlienRanks.MaxLevel and f6_arg1.prestige < f6_local5 then
|
|
f6_local8 = true
|
|
f6_local4 = 0
|
|
end
|
|
f6_local0.nextRankText:setText( Rank.GetRankDisplay( f6_local4, f6_local1 ) )
|
|
local f6_local9 = RegisterMaterial
|
|
local f6_local10 = Rank.GetRankIcon
|
|
local f6_local11 = f6_local4
|
|
local f6_local12
|
|
if f6_local8 then
|
|
f6_local12 = f6_arg1.prestige + 1
|
|
if not f6_local12 then
|
|
|
|
else
|
|
f6_local7 = f6_local9( f6_local10( f6_local11, f6_local12, f6_local1 ) )
|
|
if f6_local7 then
|
|
f6_local0.nextRankIcon:setImage( f6_local7 )
|
|
end
|
|
f6_local9 = Rank.GetRankMinXP( f6_local3, f6_local1 )
|
|
f6_local10 = Rank.GetRankMinXP( f6_local4, f6_local1 )
|
|
f6_local11 = Rank.GetRankXPToNext( f6_local3, f6_local1 )
|
|
if f6_local11 == nil or f6_local11 == 0 then
|
|
f6_local11 = 1
|
|
end
|
|
f6_local12 = math.min( (f6_arg1.experience - f6_local9) / f6_local11, 1 )
|
|
if Engine.IsAliensMode() and f6_local3 == LUI.mp_menus.Aliens.AlienRanks.SuperMaxLevel then
|
|
f6_local12 = 1
|
|
end
|
|
f6_local0.xpFillBar:registerAnimationState( "default", {
|
|
top = 0,
|
|
bottom = 0,
|
|
left = 0,
|
|
right = f6_local12 * XP_BAR_WIDTH,
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = false
|
|
} )
|
|
f6_local0.xpFillBar:animateToState( "default", 0 )
|
|
end
|
|
end
|
|
f6_local12 = f6_arg1.prestige
|
|
end
|
|
end
|
|
f6_local4 = f6_local3
|
|
end
|
|
end
|
|
|
|
LUI.MenuBuilder.registerType( "playercard", LUI.Playercard.new )
|
|
LockTable( _M )
|