UGCProjects/SoloKing/Script/UI/SelectWeapons/Child/WB_SelectWeaponItem.lua

43 lines
1.3 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
---@class WB_SelectWeaponItem_C:UUserWidget
---@field HorizontalBox_Part UHorizontalBox
---@field Image_WeaponIcon UImage
---@field TextBlock_WeaponName UTextBlock
--Edit Below--
---@type WB_SelectWeaponItem_C
local WB_SelectWeaponItem = { bInitDoOnce = false; };
--[==[ Construct
function WB_SelectWeaponItem:Construct()
end
-- Construct ]==]
-- function WB_SelectWeaponItem:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_SelectWeaponItem:Destruct()
-- end
function WB_SelectWeaponItem:SetItemId(InItemId)
local Info = UGCItemSystem.GetItemData(InItemId);
self.TextBlock_WeaponName:SetText(Info.ItemName);
UE.AsyncLoadObject_Cached(Info.ItemBigIcon_n, function(TargetObject)
self.Image_WeaponIcon:SetBrushFromTexture(TargetObject);
end);
-- 设置子类
UITool.HideAllChildren(self.HorizontalBox_Part);
if table.isEmpty(WeaponSuits[InItemId]) then return; end
local Best = WeaponSuits[InItemId][EWeaponPartType.Best];
if table.isEmpty(Best) then return; end
UITool.AdaptChildren(self.HorizontalBox_Part, table.getCount(Best[1]), nil);
for i = 1, table.getCount(Best[1]) do
local Item = self.HorizontalBox_Part:GetChildAt(i - 1)
Item:SetItemId(Best[1][i]);
Item:SetVisibility(ESlateVisibility.HitTestInvisible);
end
end
return WB_SelectWeaponItem;