---@class WB_KDAInfoItem_C:UUserWidget ---@field Image_Icon UImage ---@field NewButton_AddFriend UNewButton ---@field TextBlock_Assist UTextBlock ---@field TextBlock_Dead UTextBlock ---@field TextBlock_Kill UTextBlock ---@field TextBlock_No UTextBlock ---@field TextBlock_PlayerName UTextBlock ---@field WidgetSwitcher_BG UWidgetSwitcher --Edit Below-- ---@type WB_KDAInfoItem_C local WB_KDAInfoItem = { bInitDoOnce = false; }; function WB_KDAInfoItem:Construct() self:LuaInit(); end function WB_KDAInfoItem:LuaInit() if self.bInitDoOnce then return ; end self:SetKDA(); UITool.BindButtonClicked(self.NewButton_AddFriend, self.OnAddFriend, self) self.bInitDoOnce = true; end function WB_KDAInfoItem:SetKDA(InVal) if InVal ~= nil then self.TextBlock_Kill:SetText(InVal.Kill == nil and 0 or InVal.Kill); self.TextBlock_Dead:SetText(InVal.Dead == nil and 0 or InVal.Dead); else self.TextBlock_Kill:SetText(0); self.TextBlock_Dead:SetText(0); end end function WB_KDAInfoItem:SetPlayerKey(InPlayerKey) self.PlayerKey = InPlayerKey; self:SetSelf(InPlayerKey == LocalPlayerKey) UGCLogSystem.Log("[WB_KDAInfoItem:SetPlayerKey] InPlayerKey = %s", tostring(InPlayerKey)); self.TextBlock_PlayerName:SetText(UE.GetPlayerName(InPlayerKey)); UITool.DownloadImage(UE.GetPlayerIconURL(InPlayerKey), function(Texture) self.Image_Icon:SetBrushFromTextureDynamic(Texture); end) end function WB_KDAInfoItem:SetSelf(IsSelf) if IsSelf then self.NewButton_AddFriend:SetVisibility(ESlateVisibility.Hidden); self.WidgetSwitcher_BG:SetActiveWidgetIndex(1); else self.NewButton_AddFriend:SetVisibility(ESlateVisibility.Visible); self.WidgetSwitcher_BG:SetActiveWidgetIndex(0); end end function WB_KDAInfoItem:OnAddFriend() if self.PlayerKey == nil then return ; end UGCLogSystem.Log("[WB_KDAInfoItem:OnAddFriend] 执行") local UID = UE.GetPlayerUID(self.PlayerKey) UGCGameSystem.AddFriend(UID); end function WB_KDAInfoItem:SetKDAInfo(Info) UGCLogSystem.LogTree(string.format("[WB_KDAInfoItem:SetKDAInfo] Info ="), Info) self:SetKDA(Info or nil); self.TextBlock_No:SetText(Info.No); self:SetPlayerKey(Info.PlayerKey); end -- function WB_KDAInfoItem:Tick(MyGeometry, InDeltaTime) -- end -- function WB_KDAInfoItem:Destruct() -- end return WB_KDAInfoItem;