67 lines
1.6 KiB
Lua
67 lines
1.6 KiB
Lua
---@class WB_CommonWeaponList_C:UUserWidget
|
|
---@field ScrollBox_Weapons UScrollBox
|
|
--Edit Below--
|
|
local WB_CommonWeaponList = { bInitDoOnce = false }
|
|
|
|
WB_CommonWeaponList.Owner = nil;
|
|
WB_CommonWeaponList.Func = nil;
|
|
WB_CommonWeaponList.CurrItem = nil;
|
|
|
|
function WB_CommonWeaponList:Construct()
|
|
self:LuaInit();
|
|
end
|
|
|
|
function WB_CommonWeaponList:LuaInit()
|
|
if self.bInitDoOnce then return; end
|
|
|
|
self.bInitDoOnce = true;
|
|
end
|
|
|
|
function WB_CommonWeaponList:Init(InOwner, InFunc)
|
|
self.Owner = InOwner;
|
|
self.Func = InFunc;
|
|
end
|
|
|
|
function WB_CommonWeaponList:SetTypes(InTypes)
|
|
-- 只能是一个 Type
|
|
local Weapons = GetWeaponIdsByTypeNew(InTypes);
|
|
self:SetWeapons(Weapons);
|
|
end
|
|
|
|
--- 设置武器
|
|
function WB_CommonWeaponList:SetWeapons(InWeaponList)
|
|
UITool.AdaptChildren(self.ScrollBox_Weapons, table.getCount(InWeaponList), ObjectPath.WB_SelectWeaponItems, function(Widget, Index)
|
|
Widget:Init(self, self.OnClickItem);
|
|
end);
|
|
|
|
-- 开始赋值
|
|
UITool.ForeachAllChildren(self.ScrollBox_Weapons, function(index, Widget)
|
|
if InWeaponList[index] then
|
|
Widget:SetItemId(InWeaponList[index]);
|
|
Widget:SetVisibility(ESlateVisibility.Visible);
|
|
else
|
|
Widget:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
end);
|
|
end
|
|
|
|
function WB_CommonWeaponList:OnClickItem(ChildWidget)
|
|
if self.CurrItem ~= nil then
|
|
self.CurrItem:SetSelect(false);
|
|
self.CurrItem = nil;
|
|
end
|
|
self.CurrItem = ChildWidget;
|
|
self.CurrItem:SetSelect(true);
|
|
-- 提交给上面的
|
|
self.Func(self.Owner, self.CurrItem:GetItemId());
|
|
end
|
|
|
|
-- function WB_CommonWeaponList:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_CommonWeaponList:Destruct()
|
|
|
|
-- end
|
|
|
|
return WB_CommonWeaponList |