2025-01-04 23:00:19 +08:00
|
|
|
---@class WB_WeaponSelect_C:UUserWidget
|
|
|
|
---@field Button_Custom UNewButton
|
|
|
|
---@field Button_Select UNewButton
|
|
|
|
---@field ScrollBox_Weapons UScrollBox
|
|
|
|
---@field TextBlock_Time UTextBlock
|
|
|
|
---@field UniformGridPanel_OtherParts UUniformGridPanel
|
|
|
|
--Edit Below--
|
|
|
|
local WB_WeaponSelect_New = {
|
2025-01-21 11:29:14 +08:00
|
|
|
bInitDoOnce = false;
|
|
|
|
CombinationType = 1;
|
|
|
|
ShowTime = 0;
|
|
|
|
SelectWeaponIndex = 1;
|
|
|
|
OtherPartsItemColNum = 6;
|
|
|
|
|
|
|
|
SelectTime = 15;
|
2025-01-04 23:00:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
function WB_WeaponSelect_New:Construct()
|
2025-01-21 11:29:14 +08:00
|
|
|
WidgetLibrary.BindButtonClicked(self.Button_Select, self.SelectWeapon, self)
|
|
|
|
UGCEventSystem.AddListener(EventTypes.UpdateArchiveData, self.LoadArchiveTable, self);
|
|
|
|
UGCEventSystem.AddListener(EventTypes.UpdateEnterWeapons, self.LoadArchiveTable, self);
|
2025-01-21 16:14:19 +08:00
|
|
|
UGCEventSystem.AddListener(EventTypes.UpdateWeapons, self.UpdateWeaponCombination, self);
|
2025-01-21 11:29:14 +08:00
|
|
|
self:LoadArchiveTable();
|
|
|
|
-- 判断是否可以修改配置
|
|
|
|
WidgetLibrary.BindButtonClicked(self.Button_Custom, self.CustomWeaponComb, self)
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
|
2025-01-21 11:29:14 +08:00
|
|
|
function WB_WeaponSelect_New:LoadArchiveTable()
|
|
|
|
local EnterWeapons = UE.GetLocalArchiveData("EnterWeapons");
|
|
|
|
if EnterWeapons then
|
|
|
|
for Index, Config in pairs(EnterWeapons) do
|
|
|
|
WeaponSelectionCombinationConfig.WeaponCombinationList.Weapon[Index] = Config;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
self:UpdateWeaponCombination();
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelect_New:OnShowPanel()
|
2025-01-21 11:29:14 +08:00
|
|
|
if self.SelectTimeHandle then
|
|
|
|
UGCEventSystem.StopTimer(self.SelectTimeHandle)
|
|
|
|
end
|
|
|
|
self.ShowTime = self.SelectTime
|
|
|
|
self.TextBlock_Time:SetText(self.ShowTime)
|
|
|
|
self.SelectTimeHandle = UGCEventSystem.SetTimerLoop(self, self.SelectTimeClock, 1)
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelect_New:SelectTimeClock()
|
2025-01-21 11:29:14 +08:00
|
|
|
self.ShowTime = self.ShowTime - 1
|
|
|
|
if self.ShowTime <= 0 then
|
|
|
|
UGCEventSystem.StopTimer(self.SelectTimeHandle)
|
|
|
|
self.SelectTimeHandle = nil
|
|
|
|
WidgetManager:ClosePanel(WidgetConfig.EUIType.SelectWeaponNew)
|
|
|
|
else
|
|
|
|
self.TextBlock_Time:SetText(self.ShowTime)
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelect_New:GetWeaponItemClass()
|
2025-01-21 11:29:14 +08:00
|
|
|
if self.ItemClass == nil then
|
|
|
|
self.ItemClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectWeapons/Item/WB_WeaponSelectItem.WB_WeaponSelectItem_C'))
|
|
|
|
end
|
|
|
|
return self.ItemClass
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelect_New:GetOtherPartItemClass()
|
2025-01-21 11:29:14 +08:00
|
|
|
if self.OtherItemClass == nil then
|
|
|
|
self.OtherItemClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectWeapons/Item/WB_OtherPartItem.WB_OtherPartItem_C'))
|
|
|
|
end
|
|
|
|
return self.OtherItemClass
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelect_New:UpdateWeaponCombination()
|
2025-01-21 11:29:14 +08:00
|
|
|
local WeaponCombinationInfo = WeaponSelectionCombinationConfig.WeaponCombinationList
|
|
|
|
for i = 1, self.ScrollBox_Weapons:GetChildrenCount() do
|
|
|
|
local Item = self.ScrollBox_Weapons:GetChildAt(i - 1)
|
|
|
|
Item:Init(i)
|
|
|
|
Item:BindSelectCallBack(self.SelectWeaponItem, self);
|
|
|
|
end
|
|
|
|
-- 针对多余添加
|
|
|
|
for i = self.ScrollBox_Weapons:GetChildrenCount() + 1, #WeaponCombinationInfo.Weapon do
|
|
|
|
local Item = UserWidget.NewWidgetObjectBP(LocalPlayerController, self:GetWeaponItemClass());
|
|
|
|
if Item then
|
|
|
|
self.ScrollBox_Weapons:AddChild(Item)
|
|
|
|
Item:Init(i)
|
|
|
|
Item:BindSelectCallBack(self.SelectWeaponItem, self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--for i = #WeaponCombinationInfo.Weapon, self.ScrollBox_Weapons:GetChildrenCount() - 1 do
|
|
|
|
-- local Item = self.ScrollBox_Weapons:GetChildAt(i)
|
|
|
|
-- Item:SetVisibility(ESlateVisibility.Collapsed)
|
|
|
|
--end
|
|
|
|
|
|
|
|
for i, ItemInfo in pairs(WeaponCombinationInfo.OtherParts) do
|
|
|
|
local Item
|
|
|
|
if self.UniformGridPanel_OtherParts:GetChildrenCount() < i then
|
|
|
|
Item = UserWidget.NewWidgetObjectBP(LocalPlayerController, self:GetOtherPartItemClass());
|
|
|
|
self.UniformGridPanel_OtherParts:AddChild(Item)
|
|
|
|
local TargetUniformGridSlot = WidgetLayoutLibrary.SlotAsUniformGridSlot(Item)
|
|
|
|
-- 居中
|
|
|
|
TargetUniformGridSlot:SetVerticalAlignment(EVerticalAlignment.VAlign_Center)
|
|
|
|
TargetUniformGridSlot:SetHorizontalAlignment(EHorizontalAlignment.HAlign_Center)
|
|
|
|
-- 设置索引
|
|
|
|
TargetUniformGridSlot:SetColumn((i - 1) % self.OtherPartsItemColNum)
|
|
|
|
TargetUniformGridSlot:SetRow((i - 1) // self.OtherPartsItemColNum)
|
|
|
|
else
|
|
|
|
Item = self.UniformGridPanel_OtherParts:GetChildAt(i - 1)
|
|
|
|
Item:SetVisibility(ESlateVisibility.HitTestInvisible)
|
|
|
|
end
|
|
|
|
if Item then
|
|
|
|
Item:SetItemID(ItemInfo.ItemID, ItemInfo.Count);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for i = #WeaponCombinationInfo.OtherParts, self.UniformGridPanel_OtherParts:GetChildrenCount() - 1 do
|
|
|
|
local Item = self.UniformGridPanel_OtherParts:GetChildAt(i)
|
|
|
|
Item:SetVisibility(ESlateVisibility.Collapsed)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- 获取 EnterWeaponIndex
|
|
|
|
self:SelectWeaponItem(UE.GetLocalArchiveData("EnterWeaponIndex") or 1);
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelect_New:SelectWeaponItem(InIndex)
|
2025-01-21 11:29:14 +08:00
|
|
|
self.SelectWeaponIndex = InIndex;
|
|
|
|
for i = 1, self.ScrollBox_Weapons:GetChildrenCount() do
|
|
|
|
local Item = self.ScrollBox_Weapons:GetChildAt(i - 1)
|
|
|
|
Item:SetSelect(Item:GetCombinationIndex() == InIndex)
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelect_New:SelectWeapon()
|
2025-01-21 11:29:14 +08:00
|
|
|
GameState:SendMiniGameRPC("SelectWeaponIndex", LocalPlayerKey, self.SelectWeaponIndex);
|
|
|
|
WidgetManager:ClosePanel(WidgetConfig.EUIType.SelectWeaponNew)
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelect_New:CustomWeaponComb()
|
2025-01-21 11:29:14 +08:00
|
|
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.CustomSelectWeapon, false, self.SelectWeaponIndex)
|
|
|
|
WidgetManager:ClosePanel(WidgetConfig.EUIType.SelectWeaponNew)
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
-- function WB_WeaponSelect_New:Tick(MyGeometry, InDeltaTime)
|
|
|
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
-- function WB_WeaponSelect_New:Destruct()
|
|
|
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
return WB_WeaponSelect_New;
|