UGCProjects/SoloKing/Script/UI/SelectWeapons/Child/WB_Spectator_SelectWeaponItem.lua
2025-01-04 23:00:19 +08:00

68 lines
2.1 KiB
Lua

---@class WB_Spectator_SelectWeaponItem_C:UUserWidget
---@field Image_Icon UImage
---@field ScrollBox_SelfWeapons UScrollBox
---@field TextBlock_PlayerSelect UTextBlock
---@field WB_Disables UWB_Disables_C
--Edit Below--
---@type WB_Spectator_SelectWeaponItem_C
local WB_Spectator_SelectWeaponItem = { bInitDoOnce = false }
WB_Spectator_SelectWeaponItem.PlayerKey = nil;
function WB_Spectator_SelectWeaponItem:Construct()
self:LuaInit();
end
function WB_Spectator_SelectWeaponItem:LuaInit()
if self.bInitDoOnce then return ; end
self.bInitDoOnce = true;
UITool.HideAllChildren(self.ScrollBox_SelfWeapons);
table.func(self.WB_Disables, "LuaInit");
end
function WB_Spectator_SelectWeaponItem:SetPlayerKey(InPlayerKey)
self.PlayerKey = InPlayerKey;
-- 加载
UGCLogSystem.Log("[WB_Spectator_SelectWeaponItem:SetPlayerKey] PlayerKey = %s", tostring(InPlayerKey));
self.TextBlock_PlayerSelect:SetText(UE.GetPlayerName(InPlayerKey) .. '选择');
UITool.DownloadImage(UE.GetPlayerIconURL(InPlayerKey), function(Texture)
self.Image_Icon:SetBrushFromTextureDynamic(Texture);
end);
end
function WB_Spectator_SelectWeaponItem:GetPlayerKey()
return self.PlayerKey;
end
function WB_Spectator_SelectWeaponItem:OnPlayerDisable(Disables)
self.WB_Disables:OnPlayerDisable(Disables);
end
function WB_Spectator_SelectWeaponItem:OnUpdateSelectWeapons(InList)
UITool.HideAllChildren(self.ScrollBox_SelfWeapons);
if table.isEmpty(InList) then return ; end
UITool.ForeachAllChildren(self.ScrollBox_SelfWeapons, function(index, Widget)
if InList[index] then
UGCLogSystem.Log("[WB_Spectator_SelectWeaponItem:OnUpdateSelectWeapons] Item = %d", InList[index])
Widget:SetItemId(InList[index]);
Widget:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
else
Widget:SetVisibility(ESlateVisibility.Collapsed);
end
end)
end
-- function WB_Spectator_SelectWeaponItem:Tick(MyGeometry, InDeltaTime)
-- end
--- 清空对应的 Class
function WB_Spectator_SelectWeaponItem:Destruct()
ObjectPath.WB_AllWeapon_Type = nil;
ObjectPath.WB_AllWeapon_Item = nil;
ObjectPath.WB_SelectWeaponItems = nil;
end
return WB_Spectator_SelectWeaponItem