104 lines
2.8 KiB
Lua
104 lines
2.8 KiB
Lua
---@class WB_WeaponList_C:UUserWidget
|
|
---@field HorizontalBox_Items UHorizontalBox
|
|
---@field Overlay_Lock UOverlay
|
|
---@field ScrollBox_0 UScrollBox
|
|
---@field TextBlock_KillNum UTextBlock
|
|
---@field TextBlock_Kills UTextBlock
|
|
--Edit Below--
|
|
---@type WB_WeaponList_C
|
|
local WB_WeaponList = { bInitDoOnce = false }
|
|
|
|
--[==[ Construct
|
|
function WB_WeaponList:Construct()
|
|
|
|
end
|
|
-- Construct ]==]
|
|
|
|
-- function WB_WeaponList:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_WeaponList:Destruct()
|
|
|
|
-- end
|
|
|
|
WB_WeaponList.OwnerWid = nil;
|
|
WB_WeaponList.Func = nil;
|
|
WB_WeaponList.IsLock = false;
|
|
WB_WeaponList.KillNum = 0;
|
|
WB_WeaponList.WeaponWidgets = {};
|
|
|
|
function WB_WeaponList:Init(OwnerWid, Func)
|
|
self.OwnerWid = OwnerWid;
|
|
self.Func = Func;
|
|
end
|
|
|
|
function WB_WeaponList:GetItemWidgetByItemID(ItemID)
|
|
if self.WeaponWidgets[ItemID] then
|
|
return self.WeaponWidgets[ItemID];
|
|
end
|
|
UITool.ForeachAllChildren(self.HorizontalBox_Items, function(index, Widget)
|
|
if Widget:GetItemID() == ItemID then
|
|
self.WeaponWidgets[ItemID] = Widget;
|
|
return;
|
|
end
|
|
end)
|
|
return self.WeaponWidgets[ItemID];
|
|
end
|
|
|
|
function WB_WeaponList:SetList(Count, List)
|
|
self.KillNum = Count;
|
|
self.TextBlock_KillNum:SetText(Count);
|
|
self:SetLock(Count > 0)
|
|
self.TextBlock_Kills:SetText(string.format('%d/%d', self.CurrKill, self.KillNum));
|
|
UGCLogSystem.LogTree(string.format("[WB_WeaponList:SetList] List ="), List)
|
|
local Weapons = {};
|
|
for i, v in pairs(List) do
|
|
table.insert(Weapons, {
|
|
Weapon = v,
|
|
});
|
|
end
|
|
table.sort(Weapons, function(a, b) return a.Weapon < b.Weapon end)
|
|
UITool.ForeachAllChildren(self.HorizontalBox_Items, function(index, Widget)
|
|
if Weapons[index] then
|
|
local WeaponID = Weapons[index].Weapon;
|
|
self.WeaponWidgets[WeaponID] = Widget;
|
|
Widget:Init(self.OwnerWid, self.Func);
|
|
Widget:SetItemID(WeaponID);
|
|
Widget:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
else
|
|
Widget:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
end)
|
|
end
|
|
|
|
WB_WeaponList.HadSetPop = {};
|
|
WB_WeaponList.CurrKill = 0;
|
|
|
|
function WB_WeaponList:SetCurrKill(InNum)
|
|
if InNum >= self.KillNum then
|
|
self:SetLock(false)
|
|
if InNum == self.KillNum and InNum ~= 0 then
|
|
if self.HadSetPop[self.KillNum] == nil then
|
|
UGCLogSystem.Log("[WB_WeaponList:SetCurrKill] KillNum = %d", self.KillNum)
|
|
UGCWidgetManagerSystem.ShowTipsUI(string.format('有新的武器可以选择!!!'))
|
|
self.HadSetPop[self.KillNum] = 1;
|
|
end
|
|
end
|
|
else
|
|
self:SetLock(true);
|
|
end
|
|
self.CurrKill = InNum;
|
|
self.TextBlock_Kills:SetText(string.format('%d/%d', self.CurrKill, self.KillNum));
|
|
end
|
|
|
|
function WB_WeaponList:SetLock(IsLock)
|
|
self.IsLock = IsLock;
|
|
if IsLock then
|
|
self.Overlay_Lock:SetVisibility(ESlateVisibility.Visible);
|
|
else
|
|
self.Overlay_Lock:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
end
|
|
|
|
return WB_WeaponList |