local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) CoD.PrintModuleLoad( _NAME ) function ShowHistory() local f1_local0 if not Engine.IsAliensMode() then f1_local0 = not SvS.IsSvS() else f1_local0 = false end return f1_local0 end function LobbyPlayerStatsGetPlayerInfo( f2_arg0, f2_arg1, f2_arg2, f2_arg3, f2_arg4 ) local f2_local0 = {} local f2_local1 = f2_arg2 local f2_local2 = f2_arg3 if f2_arg0 then assert( f2_arg4 ) if f2_arg1 == Lobby.MemberListStates.Teams and Lobby.GetLocalPlayerTeam then f2_local2 = Lobby.GetLocalPlayerTeam( f2_arg1, f2_arg4 ) end local f2_local3 = Lobby.GetMemberCount( f2_arg1, f2_local2 ) for f2_local4 = 1, f2_local3, 1 do if Lobby.GetMemberControllerIndex( f2_arg1, f2_local4 - 1, f2_local2 ) == f2_arg4 then f2_local1 = f2_local4 - 1 break end end end f2_local0.gamertag = Lobby.GetMemberName( f2_arg1, f2_local1, f2_local2 ) if Engine.IsAliensMode() then f2_local0.memberPrestige = Lobby.GetMemberAlienPrestigeLevel( f2_arg1, f2_local1, f2_local2 ) f2_local0.memberRank = Lobby.GetMemberAlienRank( f2_arg1, f2_local1, f2_local2 ) else f2_local0.memberPrestige = Lobby.GetMemberPrestigeLevel( f2_arg1, f2_local1, f2_local2 ) f2_local0.memberRank = Lobby.GetMemberRank( f2_arg1, f2_local1, f2_local2 ) end f2_local0.clantag = "" if Lobby.HasMemberClanTag( f2_arg1, f2_local1, f2_local2 ) then f2_local0.clantag = Lobby.GetMemberClanTag( f2_arg1, f2_local1, f2_local2 ) end f2_local0.patch = Lobby.GetMemberPatch and Lobby.GetMemberPatch( f2_arg1, f2_local1, f2_local2 ) or 0 f2_local0.patchBG = Lobby.GetMemberPatchbacking and Lobby.GetMemberPatchbacking( f2_arg1, f2_local1, f2_local2 ) or 0 f2_local0.background = Lobby.GetMemberBackground and Lobby.GetMemberBackground( f2_arg1, f2_local1, f2_local2 ) or 0 f2_local0.memberSlot = f2_local1 f2_local0.memberTeam = f2_local2 return f2_local0 end function LobbyPlayerHistoryGetPoints( f3_arg0, f3_arg1, f3_arg2, f3_arg3 ) local f3_local0 = Lobby.GetMemberKDHistory( f3_arg1.memberListState, f3_arg0.memberSlot, f3_arg0.memberTeam, f3_arg1.controller ) if f3_local0 == nil then f3_local0 = { 0, 0, 0, 0, 0 } end local f3_local1 = 5 for f3_local2 = 1, #f3_local0, 1 do if f3_local1 < f3_local0[f3_local2] then f3_local1 = f3_local0[f3_local2] end end local f3_local2 = function ( f4_arg0 ) local f4_local0 = f3_arg3 * 1 / (#f3_local0 - 1) * (f4_arg0 - 1) local f4_local1 = nil if 1 < f3_local0[f4_arg0] then f4_local1 = f3_arg2 * 0.5 * (1 - f3_local0[f4_arg0] / f3_local1) else f4_local1 = f3_arg2 * 0.5 + f3_arg2 * 0.5 * (1 - f3_local0[f4_arg0]) end return { x = f4_local0, y = f4_local1 } end local f3_local3 = {} for f3_local4 = 1, #f3_local0, 1 do f3_local3[#f3_local3 + 1] = f3_local2( f3_local4 ) end return f3_local3 end function LobbyPlayerHistoryFactory( f5_arg0, f5_arg1, f5_arg2 ) local f5_local0 = f5_arg2.bottom - f5_arg2.top - f5_arg2.header - f5_arg2.footer local f5_local1 = f5_arg2.width - f5_arg2.left + f5_arg2.right local f5_local2, f5_local3, f5_local4 = Lobby.GetMemberKDHistory( f5_arg1.memberListState, f5_arg0.memberSlot, f5_arg0.memberTeam, f5_arg1.controller ) if f5_local2 == nil or #f5_local2 <= 1 then return end local f5_local5 = 1 / (#f5_local2 - 1) local f5_local6 = LobbyPlayerHistoryGetPoints( f5_arg0, f5_arg1, f5_local0, f5_local1 ) local f5_local7 = { type = "UIElement", id = "lobby_player_history_graph", states = { default = { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = true, left = 0, right = f5_local1, top = f5_arg2.header, bottom = -1 * f5_arg2.footer } }, children = { { type = "UIImage", id = "lobby_player_history_zero_line", states = { default = { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = f5_local0 * 0.5 - 1, bottom = f5_local0 * 0.5 + 1, red = 0, green = 0, blue = 0 } } }, { type = "UIImage", id = "lobby_player_history_bg", states = { default = { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = 0, top = 0, bottom = 0, red = 1, green = 1, blue = 1, alpha = 0.1 } } } } } local f5_local8 = { type = "UIElement", id = "lobby_player_history", states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = f5_arg2.left, right = f5_arg2.right, top = f5_arg2.top, bottom = f5_arg2.bottom } }, children = { f5_local7, { type = "UIText", id = "lobby_player_history_title", properties = { text = Engine.Localize( "LUA_MENU_MP_KILL_DEATH_RATIO", #f5_local2 ) }, states = { default = { alignment = LUI.Alignment.Center, font = CoD.TextSettings.SmallFont.Font, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = 0, bottom = CoD.TextSettings.SmallFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } } } } } for f5_local9 = 2, #f5_local2 - 1, 1 do f5_local7.children[#f5_local7.children + 1] = { type = "UIImage", id = "lobby_player_history_" .. f5_local9 .. "_line", states = { default = { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = true, left = f5_local1 * f5_local5 * (f5_local9 - 1) - 1, right = f5_local1 * f5_local5 * (f5_local9 - 1) + 1, top = 0, bottom = 0, red = 0, green = 0, blue = 0 } } } end for f5_local9 = 2, #f5_local2, 1 do local f5_local12 = f5_local6[f5_local9].x - f5_local6[f5_local9 - 1].x local f5_local13 = f5_local6[f5_local9].y - f5_local6[f5_local9 - 1].y local f5_local14 = math.sqrt( f5_local12 * f5_local12 + f5_local13 * f5_local13 ) local f5_local15 = f5_local6[f5_local9 - 1].x + f5_local12 * 0.5 local f5_local16 = f5_local6[f5_local9 - 1].y + f5_local13 * 0.5 f5_local7.children[#f5_local7.children + 1] = { type = "UIImage", id = "lobby_player_history_connect_" .. f5_local9, states = { default = { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = f5_local6[f5_local9 - 1].x - (f5_local14 - f5_local12) / 2, right = f5_local6[f5_local9 - 1].x + f5_local14 - (f5_local14 - f5_local12) / 2, top = f5_local6[f5_local9 - 1].y + f5_local13 / 2 - 1, bottom = f5_local6[f5_local9 - 1].y + f5_local13 / 2 + 1, zRot = -1 * math.deg( math.atan( f5_local13 / f5_local12 ) ), red = 1, green = 1, blue = 1, alpha = 0.5 } } } end for f5_local9 = 1, #f5_local2, 1 do local f5_local12 = { red = 0, green = 0, blue = 0 } if f5_local2[f5_local9] >= 1 then f5_local12.green = 0.75 else f5_local12.red = 0.75 end f5_local7.children[#f5_local7.children + 1] = { type = "UIImage", id = "lobby_player_history_point_" .. f5_local9, states = { default = { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = f5_local6[f5_local9].x - 3, right = f5_local6[f5_local9].x + 3, top = f5_local6[f5_local9].y - 3, bottom = f5_local6[f5_local9].y + 3, red = f5_local12.red, green = f5_local12.green, blue = f5_local12.blue, alpha = 1 } } } end for f5_local9 = 1, #f5_local2, 1 do f5_local7.children[#f5_local7.children + 1] = { type = "UIText", id = "lobby_player_history_value_" .. f5_local9, properties = { text = string.format( "%.2f", f5_local2[f5_local9] ) }, states = { default = { alignment = LUI.Alignment.Center, font = CoD.TextSettings.SmallFont.Font, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = f5_local6[f5_local9].x, right = f5_local6[f5_local9].x, top = f5_local0, bottom = f5_local0 + CoD.TextSettings.SmallFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } } } end return f5_local8 end function LobbyPlayerStatsFeeder( f6_arg0 ) local f6_local0 = {} local f6_local1 = LobbyPlayerStatsGetPlayerInfo( f6_arg0.isComparison, f6_arg0.memberListState, f6_arg0.memberSlot, f6_arg0.team, f6_arg0.controller ) local f6_local2 = 0 f6_local0[#f6_local0 + 1] = { type = "playercard", id = "lobby_basic_playercard_id", properties = { gamertag = f6_local1.gamertag, clantag = f6_local1.clantag, rank = f6_local1.memberRank, prestige = f6_local1.memberPrestige, background = f6_local1.background, patchShape = f6_local1.patchBG, patchEmblem = f6_local1.patch }, states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 55, right = -55, top = 130, bottom = 200 } } } if not Engine.IsAliensMode() or Engine.GetDvarBool( "extinction_cac_enabled" ) then if ShowHistory() then f6_local2 = 85 + CoD.TextSettings.SmallFont.Height + CoD.TextSettings.SmallFont.Height end local f6_local3 = {} local f6_local4 = 25 local f6_local5 = { material = RegisterMaterial( "white" ), leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = -150, right = 0, top = 0, bottom = 0, red = 1, green = 1, blue = 1, alpha = 0.1 } local f6_local6 = { material = RegisterMaterial( "box_angle_rtcap" ), leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = -150, right = -182, top = 0, bottom = 0, red = 1, green = 1, blue = 1, alpha = 0.1 } local f6_local7 = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 6, right = -150, top = 2, bottom = 2 + CoD.TextSettings.SmallFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b, alignment = LUI.Alignment.Left, font = CoD.TextSettings.SmallFont.Font } local f6_local8 = { leftAnchor = false, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = -150, right = -6, top = 2, bottom = 2 + CoD.TextSettings.SmallFont.Height, red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alignment = LUI.Alignment.Left, font = CoD.TextSettings.SmallFont.Font } if f6_arg0.isComparison then f6_local5 = { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = true, left = 0, right = 150, top = 0, bottom = 0, red = 1, green = 1, blue = 1, alpha = 0.1 } f6_local6 = { material = RegisterMaterial( "box_angle_ltcap" ), leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = true, left = 182, right = 150, top = 0, bottom = 0, red = 1, green = 1, blue = 1, alpha = 0.1 } f6_local7 = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 150, right = -6, top = 2, bottom = 2 + CoD.TextSettings.SmallFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b, alignment = LUI.Alignment.Right, font = CoD.TextSettings.SmallFont.Font } f6_local8 = { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = 6, right = 150, top = 2, bottom = 2 + CoD.TextSettings.SmallFont.Height, red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alignment = LUI.Alignment.Right, font = CoD.TextSettings.SmallFont.Font } end local f6_local9 = nil if SvS.IsSvS() then f6_local9 = Lobby.SquadsPlayerStatsCategories elseif Engine.IsAliensMode() then f6_local9 = Lobby.AliensPlayerStatsCategories else f6_local9 = Lobby.PlayerStatsCategories end for f6_local10 = 1, #f6_local9, 1 do if f6_local9[f6_local10].Visible == nil or f6_local9[f6_local10].Visible( f6_arg0.memberListState, f6_local1.memberSlot, f6_local1.memberTeam ) then local f6_local13 = "---" if Lobby.GetMemberStat then local f6_local14 = tonumber( Lobby.GetMemberStat( f6_arg0.memberListState, f6_local1.memberSlot, f6_local1.memberTeam, Lobby.MemberStatTypes.GamesPlayed ) ) if f6_local9[f6_local10].Getter then f6_local13 = f6_local9[f6_local10].Getter( f6_arg0.memberListState, f6_local1.memberSlot, f6_local1.memberTeam ) elseif f6_local9[f6_local10].Type and (not (f6_local14 == nil or f6_local14 <= 0) or SvS.IsSvS() or Engine.IsAliensMode()) then f6_local13 = Lobby.GetMemberStat( f6_arg0.memberListState, f6_local1.memberSlot, f6_local1.memberTeam, f6_local9[f6_local10].Type ) or "" end end f6_local3[#f6_local3 + 1] = { type = "UIElement", id = "lobby_player_stat_" .. f6_local10 .. "_id", states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = 0, bottom = f6_local4 } }, children = { { type = "UIImage", id = "lobby_player_stat_bg_title", states = { default = { material = RegisterMaterial( "white" ), leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = 0, top = 0, bottom = 0, red = Colors.very_dark_cyan.r, green = Colors.very_dark_cyan.g, blue = Colors.very_dark_cyan.b, alpha = 0.5 } } }, { type = "UIImage", id = "lobby_player_stat_bg_value", states = { default = f6_local5 } }, { type = "UIImage", id = "lobby_player_stat_bg_cap", states = { default = f6_local6 } }, { type = "UIText", id = "lobby_player_stat_text_title", properties = { text = Engine.Localize( f6_local9[f6_local10].Title ) }, states = { default = f6_local7 } }, { type = "UIMarqueeText", id = "lobby_player_stat_text_value", properties = { text = f6_local13 }, states = { default = f6_local8 } } } } end end f6_local0[#f6_local0 + 1] = { type = "UIVerticalList", id = "lobby_player_stats_list_id", states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 40, right = -40, top = 250 + f6_local2 + 10, bottom = 250 + f6_local2 + 20 + #Lobby.PlayerStatsCategories * (f6_local4 + 2), spacing = 3 } }, children = f6_local3 } if f6_arg0.isComparison then f6_local0[#f6_local0 + 1] = { type = "UIText", id = "lobby_player_stat_text_value", properties = { text = Engine.Localize( "@LUA_MENU_VERSUS" ) }, states = { default = { alignment = LUI.Alignment.Center, font = CoD.TextSettings.ExtraBigFont.Font, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = -20, right = 20, top = 205, bottom = 205 + CoD.TextSettings.ExtraBigFont.Height, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b }, shown = { alpha = 1 }, hidden = { alpha = 0 } }, handlers = { lobby_page_enter = function ( f7_arg0, f7_arg1 ) f7_arg0:animateToState( "shown", f7_arg1.animTime or 0, true ) end, lobby_page_leave = function ( f8_arg0, f8_arg1 ) f8_arg0:animateToState( "hidden", f8_arg1.animTime or 0, true ) end } } end if ShouldShowEliteIcon( f6_arg0.memberListState, f6_local1.memberSlot, f6_local1.memberTeam ) then local f6_local10 = 300 + #f6_local9 * (f6_local4 + 2) + f6_local4 + 2 f6_local0[#f6_local0 + 1] = { type = "UIHorizontalList", id = "lobby_player_mobile_app_info_id", states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 64, right = -54, top = f6_local10, bottom = f6_local10 + f6_local4 + 2, spacing = 8 } }, children = { { type = "UIImage", id = "lobby_player_mobile_app_icon_id", states = { default = { material = RegisterMaterial( "widg_arrow_dn" ), leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, top = 7, bottom = 19, left = 3, right = 29, red = 0.33, green = 0.71, blue = 0.23 } } }, { type = "UIText", id = "lobby_player_mobile_app_text_id", properties = { text = Engine.Localize( "@LUA_MENU_MOBILE_APP_RUNNING" ) }, states = { default = { alignment = LUI.Alignment.Left, font = CoD.TextSettings.SmallFont.Font, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 20, right = -14, top = 2, bottom = f6_local4, red = Colors.secondary_text_color.r, green = Colors.secondary_text_color.g, blue = Colors.secondary_text_color.b } } } } } end end return f6_local0 end function LobbyPlayerStatsUpdateProps( f9_arg0, f9_arg1 ) assert( f9_arg1.memberListState ) assert( f9_arg1.memberSlot ) assert( f9_arg1.team ) local f9_local0 = f9_arg0.properties local f9_local1 = f9_arg1.memberListState if not f9_local1 then f9_local1 = Lobby.MemberListStates.None end f9_local0.memberListState = f9_local1 f9_arg0.properties.memberSlot = f9_arg1.memberSlot or 0 f9_arg0.properties.team = f9_arg1.team or 1 end function LobbyPlayerStatsEnter( f10_arg0, f10_arg1 ) local f10_local0 = f10_arg0.properties local f10_local1 = f10_arg0.properties local f10_local2 = f10_arg1.controller if not f10_local2 then f10_local2 = Engine.GetFirstActiveController() end f10_local1.controller = f10_local2 if f10_local0.isComparison then f10_arg0:processEvent( { name = "menu_refresh" } ) end f10_local1 = LobbyPlayerStatsGetPlayerInfo( f10_local0.isComparison, f10_local0.memberListState, f10_local0.memberSlot, f10_local0.team, f10_arg0.properties.controller ) f10_arg0:processEvent( { name = "update_playercard", gamertag = f10_local1.gamertag, clantag = f10_local1.clantag, rank = f10_local1.memberRank, prestige = f10_local1.memberPrestige, background = f10_local1.background, patchShape = f10_local1.patchBG, patchEmblem = f10_local1.patch } ) end function sendPlayerCardUpdate( f11_arg0, f11_arg1 ) if Engine.IsAliensMode() then local f11_local0 = LobbyPlayerStatsGetPlayerInfo( false, f11_arg1.memberListState, f11_arg1.memberSlot, f11_arg1.team, f11_arg1.controller ) f11_arg0:processEvent( { name = "update_playercard", gamertag = f11_local0.gamertag, clantag = f11_local0.clantag, rank = f11_local0.memberRank, prestige = f11_local0.memberPrestige, background = f11_local0.background, patchShape = f11_local0.patchBG, patchEmblem = f11_local0.patch } ) end end function LobbyPlayerStatsBuildHistory( f12_arg0, f12_arg1 ) if ShowHistory() then local f12_local0 = f12_arg0:getFirstDescendentById( "lobby_player_history" ) local f12_local1 = f12_arg0.properties if f12_local0 then f12_local0:close() end local f12_local2 = LobbyPlayerHistoryFactory( LobbyPlayerStatsGetPlayerInfo( f12_local1.isComparison, f12_local1.memberListState, f12_local1.memberSlot, f12_local1.team, f12_arg0.properties.controller ), f12_local1, { left = 40, right = -40, top = 250, width = 550, bottom = 250 + 85 + CoD.TextSettings.SmallFont.Height + CoD.TextSettings.SmallFont.Height, footer = CoD.TextSettings.SmallFont.Height, header = CoD.TextSettings.SmallFont.Height } ) if f12_local2 ~= nil then LUI.MenuBuilder.BuildAddChild( f12_arg0, f12_local2 ) end end end function lobby_player_stats() return { type = "UIElement", id = "lobby_player_stats_id", focusable = true, properties = { memberListState = Lobby.MemberListStates.Lobby, memberSlot = 0, team = Teams.free, isComparison = false, controller = Engine.GetFirstActiveController(), should_disable_slide_right_func = function ( f14_arg0, f14_arg1 ) local f14_local0 = f14_arg0.properties if not f14_local0.isComparison then if (Lobby.GetMemberControllerIndex and Lobby.GetMemberControllerIndex( f14_local0.memberListState, f14_local0.memberSlot, f14_local0.team ) or 0) == f14_arg1 then return true elseif not Engine.IsConsoleGame() and Lobby.IsMemberALocalPlayer( f14_local0.memberListState, f14_local0.memberSlot, f14_local0.team ) then return true end end return false end }, states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = 0, top = 0, bottom = 0 } }, handlers = { lobby_detail_update = function ( f15_arg0, f15_arg1 ) LobbyPlayerStatsUpdateProps( f15_arg0, f15_arg1 ) sendPlayerCardUpdate( f15_arg0, f15_arg1 ) f15_arg0:processEvent( { name = "menu_refresh" } ) LobbyPlayerStatsBuildHistory( f15_arg0, f15_arg1 ) end , lobby_page_enter = function ( f16_arg0, f16_arg1 ) LobbyPlayerStatsEnter( f16_arg0, f16_arg1 ) LobbyPlayerStatsBuildHistory( f16_arg0, f16_arg1 ) end }, childrenFeeder = LobbyPlayerStatsFeeder } end LUI.MenuBuilder.registerDef( "lobby_player_stats", lobby_player_stats ) LockTable( _M )