---@class WB_PlayerInfoItem_C:UUserWidget ---@field Button_AddFri UButton ---@field Image_HeadIcon UImage ---@field Image_No UImage ---@field Image_Self UImage ---@field Overlay_MVP UOverlay ---@field TextBlock_BodySize UTextBlock ---@field TextBlock_Damage UTextBlock ---@field TextBlock_KDA UTextBlock ---@field TextBlock_Kill UTextBlock ---@field TextBlock_No UTextBlock ---@field TextBlock_PlayerName UTextBlock ---@field WidgetSwitcher_0 UWidgetSwitcher --Edit Below-- ---@type WB_PlayerInfoItem_C local WB_PlayerInfoItem = { bInitDoOnce = false; }; WB_PlayerInfoItem.PlayerKey = 0; function WB_PlayerInfoItem:Construct() self:LuaInit(); end function WB_PlayerInfoItem:LuaInit() if self.bInitDoOnce then return; end self.Button_AddFri.OnClicked:Add(self.OnClickAddFriend, self) UITool.EnableButtonScroll(self.Button_AddFri) self.bInitDoOnce = true; end --function WB_PlayerInfoItem:SetAsTitle() -- self:SetIsMVP(false); -- self:IsSelf(false); -- --end function WB_PlayerInfoItem:SetIsMVP(IsMVP) if IsMVP then if not self.IsGaming then self.Overlay_MVP:SetVisibility(ESlateVisibility.SelfHitTestInvisible); end end end function WB_PlayerInfoItem:IsSelf(IsSelf) if IsSelf then self.Image_Self:SetVisibility(ESlateVisibility.SelfHitTestInvisible); if not self.IsGaming then self.Button_AddFri:SetVisibility(ESlateVisibility.Hidden); end end end function WB_PlayerInfoItem:SetPlayerInfo(Info, InOwner) UGCLogSystem.LogTree(string.format("[WB_PlayerInfoItem:SetPlayerInfo] Info ="), Info) self.PlayerKey = Info.PlayerKey; self:SetIsMVP(Info.No == 1); self:IsSelf(Info.IsSelf) self.TextBlock_No:SetText(tostring(Info.No)); self.TextBlock_PlayerName:SetText(Info.PlayerName); self.TextBlock_Damage:SetText(string.format("%0.f", Info.Damage)); self.TextBlock_Kill:SetText(tostring(Info.Kill)); self.TextBlock_KDA:SetText(string.format("%.1f", Info.KDA)); self.TextBlock_BodySize:SetText(string.format("%.1f", GameState:GetPlayerAttribute(self.PlayerKey, DefaultSettings.EPawnBenefitType.BodySize))); local Icon = InOwner.HeadIcons[self.PlayerKey]; if Icon then self.Image_HeadIcon:SetBrushFromTextureDynamic(Icon); else UITool.DownloadImage(Info.IconURL, function(Texture) UGCLogSystem.Log("[WB_PlayerInfoItem:SetPlayerInfo] 执行") self.Image_HeadIcon:SetBrushFromTextureDynamic(Texture); end, function() UGCLogSystem.Log("[WB_PlayerInfoItem:SetPlayerInfo] Failed") end) end end function WB_PlayerInfoItem:OnClickAddFriend() ---@type PlayerAccountInfo local AccountInfo = GameState.PlayerDatas.AccountInfo[self.PlayerKey]; UGCLogSystem.LogTree(string.format("[WB_PlayerInfoItem:OnClickAddFriend] AccountInfo ="), AccountInfo) if AccountInfo then UGCGameSystem.AddFriend(AccountInfo.UID); end end WB_PlayerInfoItem.IsGaming = false; function WB_PlayerInfoItem:SetInGaming() self.Overlay_MVP.SetVisibility(ESlateVisibility.Collapsed); self.Button_AddFri:SetVisibility(ESlateVisibility.Collapsed); --self.Overlay_Damage:SetVisibility(ESlateVisibility.Collapsed); self.IsGaming = true; end -- function WB_PlayerInfoItem:Tick(MyGeometry, InDeltaTime) -- end -- function WB_PlayerInfoItem:Destruct() -- end return WB_PlayerInfoItem;