58 lines
2.2 KiB
Lua
58 lines
2.2 KiB
Lua
|
---@class WB_TeamSettlementItem_C:UUserWidget
|
||
|
---@field Button_Result_AddFriend UButton
|
||
|
---@field Image_PlayerIcon UImage
|
||
|
---@field TextBlock_Damage UTextBlock
|
||
|
---@field TextBlock_Fen UTextBlock
|
||
|
---@field TextBlock_KDA UTextBlock
|
||
|
---@field TextBlock_PlayerName UTextBlock
|
||
|
---@field TextBlock_RankNum UTextBlock
|
||
|
---@field WidgetSwitcher_IsLocalPlayer UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
---@type WB_TeamSettlementItem_C
|
||
|
local WB_TeamSettlementItem = {
|
||
|
bInitDoOnce = false;
|
||
|
PlayerKey = -1;
|
||
|
};
|
||
|
|
||
|
function WB_TeamSettlementItem:LuaInit()
|
||
|
if self.bInitDoOnce then
|
||
|
return ;
|
||
|
end
|
||
|
UITool.BindButtonClicked(self.Button_Result_AddFriend, self.AddFriend, self)
|
||
|
self.bInitDoOnce = true;
|
||
|
end
|
||
|
|
||
|
function WB_TeamSettlementItem:SetTeam(TeamType)
|
||
|
local TeamColor = TeamConfig.TeamColor[TeamType]
|
||
|
-- 设置队伍颜色
|
||
|
if TeamColor then
|
||
|
self.TextBlock_RankNum:SetColorAndOpacity({ SpecifiedColor = TeamColor, ColorUseRule = 0 })
|
||
|
self.TextBlock_PlayerName:SetColorAndOpacity({ SpecifiedColor = TeamColor, ColorUseRule = 0 })
|
||
|
self.TextBlock_KDA:SetColorAndOpacity({ SpecifiedColor = TeamColor, ColorUseRule = 0 })
|
||
|
else
|
||
|
UGCLogSystem.LogError("[WB_TeamRankItem_SetTeam] TeamType:%s, TeamColorType: %s", tostring(TeamType), type(TeamColor))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_TeamSettlementItem:AddFriend()
|
||
|
local TargetPlayerData = UGCGameSystem.GameState.PlayerAccountInfoMap[self.PlayerKey];
|
||
|
if TargetPlayerData ~= nil then
|
||
|
UGCGameSystem.AddFriend(TargetPlayerData.UID)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_TeamSettlementItem:ShowSettlementItem(Vis)
|
||
|
self.Button_Result_AddFriend:SetVisibility(Vis);
|
||
|
end
|
||
|
|
||
|
function WB_TeamSettlementItem:SetRankData(RankNum, Data)
|
||
|
self.PlayerKey = Data.PlayerKey;
|
||
|
self.TextBlock_KDA:SetText(string.format('%0.1f', Data.KDA));
|
||
|
self.TextBlock_Damage:SetText(string.format('%0.f', Data.Damage));
|
||
|
self.TextBlock_PlayerName:SetText(UGCGameSystem.GameState.PlayerAccountInfoMap[Data.PlayerKey].PlayerName);
|
||
|
self.TextBlock_RankNum:SetText(RankNum);
|
||
|
UGCSystemLibrary.DownloadImageToUImage(self.Image_PlayerIcon, UGCGameSystem.GameState:GetHeadIconByPlayerKey(self.PlayerKey));
|
||
|
self.WidgetSwitcher_IsLocalPlayer:SetActiveWidgetIndex(LocalPlayerKey == self.PlayerKey and 1 or 0);
|
||
|
end
|
||
|
|
||
|
return WB_TeamSettlementItem;
|