121 lines
3.5 KiB
Lua
121 lines
3.5 KiB
Lua
|
---@class WB_PlayerInfoItem_Small_C:UUserWidget
|
||
|
---@field Button_AddFri UButton
|
||
|
---@field Image_HeadIcon UImage
|
||
|
---@field Image_No UImage
|
||
|
---@field Image_WeaponIcon UImage
|
||
|
---@field Overlay_Damage UOverlay
|
||
|
---@field Overlay_MVP UOverlay
|
||
|
---@field TextBlock_BodySize UTextBlock
|
||
|
---@field TextBlock_Damage UTextBlock
|
||
|
---@field TextBlock_KDA UTextBlock
|
||
|
---@field TextBlock_No UTextBlock
|
||
|
---@field TextBlock_PlayerName UTextBlock
|
||
|
---@field TextBlock_Weapon UTextBlock
|
||
|
---@field WidgetSwitcher_0 UWidgetSwitcher
|
||
|
---@field WidgetSwitcher_IsSelf UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
---@type WB_PlayerInfoItem_Small_C
|
||
|
local WB_PlayerInfoItem_Small = { bInitDoOnce = false; };
|
||
|
|
||
|
WB_PlayerInfoItem_Small.PlayerKey = 0;
|
||
|
|
||
|
function WB_PlayerInfoItem_Small:Construct()
|
||
|
self:LuaInit();
|
||
|
end
|
||
|
|
||
|
function WB_PlayerInfoItem_Small: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_Small:SetAsTitle()
|
||
|
-- self:SetIsMVP(false);
|
||
|
-- self:IsSelf(false);
|
||
|
--
|
||
|
--end
|
||
|
|
||
|
function WB_PlayerInfoItem_Small:SetIsMVP(IsMVP)
|
||
|
if IsMVP then
|
||
|
if not self.IsGaming then
|
||
|
self.Overlay_MVP:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_PlayerInfoItem_Small:IsSelf(IsSelf)
|
||
|
if IsSelf then
|
||
|
if not self.IsGaming then
|
||
|
self.Button_AddFri:SetVisibility(ESlateVisibility.Hidden);
|
||
|
end
|
||
|
|
||
|
self.WidgetSwitcher_IsSelf:SetActiveWidgetIndex(1)
|
||
|
else
|
||
|
self.WidgetSwitcher_IsSelf:SetActiveWidgetIndex(0)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_PlayerInfoItem_Small:OnClickAddFriend()
|
||
|
---@type PlayerAccountInfo
|
||
|
local AccountInfo = UE.GetAccountInfo(self.PlayerKey);
|
||
|
UGCLogSystem.LogTree(string.format("[WB_PlayerInfoItem_Small:OnClickAddFriend] AccountInfo ="), AccountInfo)
|
||
|
if AccountInfo then
|
||
|
UGCGameSystem.AddFriend(AccountInfo.UID);
|
||
|
end
|
||
|
end
|
||
|
|
||
|
WB_PlayerInfoItem_Small.IsGaming = false;
|
||
|
|
||
|
function WB_PlayerInfoItem_Small:SetInGaming()
|
||
|
self.Overlay_MVP:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
self.Button_AddFri:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
self.IsGaming = true;
|
||
|
end
|
||
|
|
||
|
function WB_PlayerInfoItem_Small:SetRoundInfo(Index, RoundInfo)
|
||
|
UGCLogSystem.LogTree(string.format("[WB_PlayerInfoItem_Small:SetRoundInfo] RoundInfo ="), RoundInfo)
|
||
|
self.TextBlock_No:SetText(tostring(Index));
|
||
|
|
||
|
if RoundInfo.Time then
|
||
|
if RoundInfo.Time > 100 then
|
||
|
self.TextBlock_Damage:SetText(string.format('%0.0f', RoundInfo.Time));
|
||
|
else
|
||
|
self.TextBlock_Damage:SetText(string.format('%0.1f', RoundInfo.Time));
|
||
|
end
|
||
|
end
|
||
|
self:IsSelf(PlayerKey == LocalPlayerKey);
|
||
|
|
||
|
if RoundInfo.Weapon then
|
||
|
local WeaponInfo = UGCItemSystem.GetItemData(RoundInfo.Weapon);
|
||
|
self.TextBlock_Weapon:SetText(WeaponInfo.ItemName);
|
||
|
UE.AsyncLoadObject_Cached(WeaponInfo.ItemWhiteIcon_n, function(TargetObject)
|
||
|
self.Image_WeaponIcon:SetBrushFromTexture(TargetObject);
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
local PlayerKey = RoundInfo.Winner;
|
||
|
if PlayerKey then
|
||
|
---@type PlayerAccountInfo
|
||
|
local Info = UE.GetAccountInfo(PlayerKey);
|
||
|
if Info then
|
||
|
self.TextBlock_PlayerName:SetText(Info.PlayerName);
|
||
|
UITool.DownloadImage(Info.IconURL, function(Texture)
|
||
|
self.Image_HeadIcon:SetBrushFromTextureDynamic(Texture);
|
||
|
end);
|
||
|
end
|
||
|
else
|
||
|
self.Image_HeadIcon:SetVisibility(ESlateVisibility.Hidden);
|
||
|
self.TextBlock_PlayerName:SetText("--");
|
||
|
end
|
||
|
end
|
||
|
|
||
|
-- function WB_PlayerInfoItem_Small_Small:Tick(MyGeometry, InDeltaTime)
|
||
|
|
||
|
-- end
|
||
|
|
||
|
-- function WB_PlayerInfoItem_Small_Small:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
return WB_PlayerInfoItem_Small;
|