UGCProjects/SoldierWar/Script/UI/WB_PlayerInfo.lua

76 lines
2.2 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
---@class WB_PlayerInfo_C:UUserWidget
---@field HorizontalBox_Title UHorizontalBox
---@field Overlay_Tile_AddFriend UOverlay
---@field ScrollBox_Items UScrollBox
---@field TextBlock_Assist UTextBlock
---@field TextBlock_Damage UTextBlock
---@field TextBlock_Dead UTextBlock
---@field TextBlock_Kill UTextBlock
---@field TextBlock_PlayerName UTextBlock
--Edit Below--
---@type WB_PlayerInfo_C
local WB_PlayerInfo = { bInitDoOnce = false; };
function WB_PlayerInfo:Construct()
self:LuaInit();
end
WB_PlayerInfo.HeadIcons = {};
function WB_PlayerInfo:LuaInit()
if self.bInitDoOnce then return ; end
--UGCEventSystem.AddListener(EventTypes.UpdateRoundWinners, self.OnUpdateRoundWinners, self);
UGCEventSystem.AddListener(EventTypes.UpdatePlayerKDAs, self.UpdatePlayerKDAs, self);
UITool.ForeachAllChildren(self.ScrollBox_Items, function(index, Widget)
Widget:LuaInit();
end)
--UITool.HideAllChildren(self.ScrollBox_Items);
self.bInitDoOnce = true;
end
---@param InInfo table<int32, PlayerKDA_DamageItem> 支持排序功能
function WB_PlayerInfo:SetInfos(InInfo)
local Num = table.getCount(InInfo);
UITool.AdaptChildren(self.ScrollBox_Items, Num, ObjectPath.WB_PlayerInfoItem);
for i = 1, Num do
local Item = self.ScrollBox_Items:GetChildAt(i - 1);
Item:SetPlayerInfo(InInfo[i], self);
end
end
function WB_PlayerInfo:OnUpdateRoundWinners(Rounds)
-- 先清空
if table.isEmpty(Rounds) then return ; end
UGCLogSystem.LogTree(string.format("[WB_PlayerInfo:OnUpdateRoundWinners] RoundInfo ="), Rounds)
UITool.ForeachAllChildren(self.ScrollBox_Items, function(index, Widget)
local Item = Rounds[index]
if Item ~= nil then
Widget:SetItemInfo(index, Item);
Widget:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
else
Widget:SetVisibility(ESlateVisibility.Collapsed);
end
end);
end
function WB_PlayerInfo:SetKDAItems(InItems)
UITool.ForeachAllChildren(self.ScrollBox_Items, function(index, Widget)
if InItems[index] then
Widget:SetKDAItem(InItems[index]);
Widget:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
else
Widget:SetVisibility(ESlateVisibility.Collapsed);
end
end)
end
-- function WB_PlayerInfo:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_PlayerInfo:Destruct()
-- end
return WB_PlayerInfo;