2025-01-16 13:35:17 +08:00
|
|
|
|
---@class WB_CustomWeapon_New_C:UUserWidget
|
2025-01-04 23:00:19 +08:00
|
|
|
|
---@field HorizontalBox_WeaponType UHorizontalBox
|
|
|
|
|
---@field NewButton_Close UNewButton
|
|
|
|
|
---@field NewButton_Save UNewButton
|
2025-01-18 21:26:02 +08:00
|
|
|
|
---@field NewButton_SelectParts UNewButton
|
|
|
|
|
---@field SaveMeleeWeaponItem UWB_SaveOtherWeaponItem_C
|
|
|
|
|
---@field SaveSubWeaponItem UWB_SaveOtherWeaponItem_C
|
|
|
|
|
---@field SaveWeaponItem1 UWB_SaveWeaponItem_C
|
|
|
|
|
---@field SaveWeaponItem2 UWB_SaveWeaponItem_C
|
2025-01-04 23:00:19 +08:00
|
|
|
|
---@field UniformGridPanel_SelectWeapon UUniformGridPanel
|
2025-01-18 21:26:02 +08:00
|
|
|
|
---@field VerticalBox_OtherWeapons UVerticalBox
|
2025-01-04 23:00:19 +08:00
|
|
|
|
---@field VerticalBox_WeaponSocket UVerticalBox
|
2025-01-18 21:26:02 +08:00
|
|
|
|
---@field WidgetSwitcher_WeaponSocket_Type UWidgetSwitcher
|
2025-01-04 23:00:19 +08:00
|
|
|
|
--Edit Below--
|
|
|
|
|
local WB_CustomWeapon_New = {
|
2025-01-14 15:37:16 +08:00
|
|
|
|
bInitDoOnce = false;
|
|
|
|
|
WeaponComb = {}; -- {WeaponID1, WeaponID2
|
|
|
|
|
SelectSaveWeaponItemCol = 4;
|
|
|
|
|
WeaponSocketItems = {};
|
|
|
|
|
IsChange = false;
|
2025-01-18 21:26:02 +08:00
|
|
|
|
SelectWeaponSocketID = 1;
|
2025-01-04 23:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function WB_CustomWeapon_New:Construct()
|
2025-01-14 15:37:16 +08:00
|
|
|
|
self:LuaInit()
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function WB_CustomWeapon_New:LuaInit()
|
2025-01-21 11:29:14 +08:00
|
|
|
|
if self.bInitDoOnce then return ; end
|
2025-01-14 15:37:16 +08:00
|
|
|
|
self.bInitDoOnce = true;
|
2025-01-04 23:00:19 +08:00
|
|
|
|
|
2025-01-14 15:37:16 +08:00
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_LuaInit]")
|
2025-01-04 23:00:19 +08:00
|
|
|
|
|
2025-01-14 15:37:16 +08:00
|
|
|
|
-- 按键初始化
|
2025-01-18 21:26:02 +08:00
|
|
|
|
--WidgetLibrary.BindButtonClicked(self.NewButton_Reset, self.ResetWeaponComb, self)
|
2025-01-14 15:37:16 +08:00
|
|
|
|
WidgetLibrary.BindButtonClicked(self.NewButton_Save, self.SaveWeaponComb, self)
|
2025-01-21 11:29:14 +08:00
|
|
|
|
--WidgetLibrary.BindButtonClicked(self.NewButton_Close, self.ClickClose, self)
|
2025-01-18 21:26:02 +08:00
|
|
|
|
WidgetLibrary.BindButtonClicked(self.NewButton_SelectParts, self.OnClickSetParts, self)
|
2025-01-04 23:00:19 +08:00
|
|
|
|
|
2025-01-14 15:37:16 +08:00
|
|
|
|
-- 初始化Item
|
|
|
|
|
self:InitItem()
|
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_LuaInit] Finish")
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function WB_CustomWeapon_New:OnShowPanel(ProgrammeIndex)
|
2025-01-14 15:37:16 +08:00
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_OnShowPanel]")
|
|
|
|
|
-- 设置配置索引
|
|
|
|
|
self:SetProgrammeIndex(ProgrammeIndex)
|
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_OnShowPanel] Finish")
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function WB_CustomWeapon_New:InitItem()
|
2025-01-14 15:37:16 +08:00
|
|
|
|
-- 武器类型中最大可选择的的武器数量
|
|
|
|
|
local MaxSelectItemCount = 0
|
|
|
|
|
|
|
|
|
|
-- 武器类型选择的Item在水平框中的对齐方式
|
|
|
|
|
local WeaponTypeSlateChildSize = UE.CreateStruct("SlateChildSize");
|
|
|
|
|
WeaponTypeSlateChildSize.SizeRule = ESlateSizeRule.Fill
|
|
|
|
|
|
|
|
|
|
for i, v in pairs(WeaponSelectionCombinationConfig.PlayerCustomWeapon) do
|
|
|
|
|
-- 设置一下最大的选择武器Item数量
|
|
|
|
|
MaxSelectItemCount = math.max(MaxSelectItemCount, #v.WeaponIDs)
|
|
|
|
|
-- 加载图片
|
|
|
|
|
for _, WeaponID in pairs(v.WeaponIDs) do
|
|
|
|
|
-- 加载剪影
|
|
|
|
|
MyWeaponSystem.AsyncLoadItemWhiteIconToBrush(WeaponID)
|
|
|
|
|
-- 加载大图
|
|
|
|
|
MyWeaponSystem.AsyncLoadItemBigIconToBrush(WeaponID)
|
|
|
|
|
end
|
|
|
|
|
-- 初始化武器类型
|
|
|
|
|
local WeaponTypeItem = nil
|
|
|
|
|
if self.HorizontalBox_WeaponType:GetChildrenCount() < i then
|
2025-01-21 11:29:14 +08:00
|
|
|
|
WeaponTypeItem = UserWidget.NewWidgetObjectBP(LocalPlayerController, self:GetWeaponTypeItemClass());
|
2025-01-14 15:37:16 +08:00
|
|
|
|
self.HorizontalBox_WeaponType:AddChild(WeaponTypeItem)
|
|
|
|
|
-- 设置对齐方式
|
|
|
|
|
local TargetHorizontalBoxSlot = WidgetLayoutLibrary.SlotAsHorizontalBoxSlot(WeaponTypeItem)
|
|
|
|
|
TargetHorizontalBoxSlot:SetSize(WeaponTypeSlateChildSize)
|
|
|
|
|
else
|
|
|
|
|
WeaponTypeItem = self.HorizontalBox_WeaponType:GetChildAt(i - 1)
|
|
|
|
|
end
|
|
|
|
|
WeaponTypeItem:SetIndex(i)
|
|
|
|
|
WeaponTypeItem:BindClickSelect(self.SelectWeaponType, self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 初始化武器槽UI
|
2025-01-18 21:26:02 +08:00
|
|
|
|
self.WeaponSocketItems = {
|
|
|
|
|
self.SaveWeaponItem1,
|
|
|
|
|
self.SaveWeaponItem2,
|
|
|
|
|
self.SaveSubWeaponItem,
|
|
|
|
|
self.SaveMeleeWeaponItem,
|
|
|
|
|
}
|
|
|
|
|
for i, Item in pairs(self.WeaponSocketItems) do
|
2025-01-14 15:37:16 +08:00
|
|
|
|
Item:SetIndex(i)
|
|
|
|
|
Item:BindClickSelect(self.SelectWeaponSocket, self)
|
|
|
|
|
end
|
2025-01-18 21:26:02 +08:00
|
|
|
|
|
|
|
|
|
MaxSelectItemCount = math.max(MaxSelectItemCount, #WeaponSelectionCombinationConfig.PlayerCustomMeleeWeapon, #WeaponSelectionCombinationConfig.PlayerCustomMeleeWeapon)
|
|
|
|
|
|
2025-01-14 15:37:16 +08:00
|
|
|
|
-- 初始化武器选择Item
|
|
|
|
|
for i = 1, MaxSelectItemCount do
|
|
|
|
|
local Item = nil;
|
|
|
|
|
if self.UniformGridPanel_SelectWeapon:GetChildrenCount() < i then
|
2025-01-21 11:29:14 +08:00
|
|
|
|
Item = UserWidget.NewWidgetObjectBP(LocalPlayerController, self:GetSelectSaveWeaponItemClass());
|
2025-01-14 15:37:16 +08:00
|
|
|
|
self.UniformGridPanel_SelectWeapon:AddChild(Item)
|
|
|
|
|
local TargetUniformGridSlot = WidgetLayoutLibrary.SlotAsUniformGridSlot(Item)
|
|
|
|
|
-- 居中
|
|
|
|
|
TargetUniformGridSlot:SetVerticalAlignment(EVerticalAlignment.VAlign_Center)
|
|
|
|
|
TargetUniformGridSlot:SetHorizontalAlignment(EHorizontalAlignment.HAlign_Center)
|
|
|
|
|
-- 设置索引
|
|
|
|
|
TargetUniformGridSlot:SetColumn((i - 1) % self.SelectSaveWeaponItemCol)
|
|
|
|
|
TargetUniformGridSlot:SetRow((i - 1) // self.SelectSaveWeaponItemCol)
|
|
|
|
|
else
|
|
|
|
|
Item = self.UniformGridPanel_SelectWeapon:GetChildAt(i - 1)
|
|
|
|
|
Item:SetVisibility(ESlateVisibility.HitTestInvisible)
|
|
|
|
|
end
|
|
|
|
|
Item:SetIndex(i)
|
|
|
|
|
Item:BindClickSelect(self.ClickSelectSaveWeapon, self)
|
|
|
|
|
end
|
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_InitItem] Finish")
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function WB_CustomWeapon_New:GetSelectSaveWeaponItemClass()
|
2025-01-14 15:37:16 +08:00
|
|
|
|
if self.SelectSaveWeaponClass == nil then
|
|
|
|
|
self.SelectSaveWeaponClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectWeapons/SaveCustomWeaponItem/WB_SelectSaveWeapon.WB_SelectSaveWeapon_C'))
|
|
|
|
|
end
|
|
|
|
|
return self.SelectSaveWeaponClass
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function WB_CustomWeapon_New:GetWeaponTypeItemClass()
|
2025-01-14 15:37:16 +08:00
|
|
|
|
if self.WeaponTypeItemClass == nil then
|
|
|
|
|
self.WeaponTypeItemClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectWeapons/SaveCustomWeaponItem/WB_WeaponType.WB_WeaponType_C'))
|
|
|
|
|
end
|
|
|
|
|
return self.WeaponTypeItemClass
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 设置配置ID
|
|
|
|
|
function WB_CustomWeapon_New:SetProgrammeIndex(InProgrammeIndex)
|
2025-01-14 15:37:16 +08:00
|
|
|
|
self.ProgrammeIndex = InProgrammeIndex
|
|
|
|
|
local SavedWeaponComb = nil
|
|
|
|
|
|
|
|
|
|
if SavedWeaponComb and SavedWeaponComb[self.ProgrammeIndex] then
|
|
|
|
|
self.WeaponComb = SavedWeaponComb[self.ProgrammeIndex]
|
|
|
|
|
else
|
|
|
|
|
local CombinationList = WeaponSelectionCombinationConfig.WeaponCombinationList.Weapon
|
|
|
|
|
if CombinationList and CombinationList[self.ProgrammeIndex] then
|
|
|
|
|
self.WeaponComb = CombinationList[self.ProgrammeIndex]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
for i = #self.WeaponComb, 1, -1 do
|
2025-01-21 11:29:14 +08:00
|
|
|
|
self:SetSelectWeapon(i, self.WeaponComb[i], (i == 1));
|
2025-01-14 15:37:16 +08:00
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 点击选择插槽
|
|
|
|
|
function WB_CustomWeapon_New:SelectWeaponSocket(Index)
|
2025-01-14 15:37:16 +08:00
|
|
|
|
if self.SelectWeaponSocketID ~= Index then
|
|
|
|
|
self.SelectWeaponSocketID = Index
|
|
|
|
|
local WeaponSocketItem = self.WeaponSocketItems[self.SelectWeaponSocketID]
|
|
|
|
|
if WeaponSocketItem then
|
|
|
|
|
self:SetSelectWeapon(self.SelectWeaponSocketID, WeaponSocketItem:GetWeaponID(), true)
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
--- 点击选择武器类型
|
|
|
|
|
function WB_CustomWeapon_New:SelectWeaponType(Index)
|
2025-01-18 21:26:02 +08:00
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New_SelectWeaponType] Index:%s", tostring(Index))
|
2025-01-18 23:19:35 +08:00
|
|
|
|
|
|
|
|
|
local CustomWeaponIDs = {}
|
|
|
|
|
-- 判断武器插槽分类
|
|
|
|
|
if self.SelectWeaponSocketID <= 2 then
|
|
|
|
|
-- 两个主武器
|
|
|
|
|
self.WeaponTypeIndex = Index
|
|
|
|
|
for i = 1, self.HorizontalBox_WeaponType:GetChildrenCount() do
|
|
|
|
|
local WeaponTypeItem = self.HorizontalBox_WeaponType:GetChildAt(i - 1)
|
|
|
|
|
WeaponTypeItem:SetSelect(i == self.WeaponTypeIndex)
|
2025-01-14 15:37:16 +08:00
|
|
|
|
end
|
2025-01-18 23:19:35 +08:00
|
|
|
|
local CustomWeaponInfo = WeaponSelectionCombinationConfig.PlayerCustomWeapon[self.WeaponTypeIndex]
|
|
|
|
|
if CustomWeaponInfo then
|
|
|
|
|
CustomWeaponIDs = CustomWeaponInfo.WeaponIDs
|
|
|
|
|
end
|
|
|
|
|
elseif self.SelectWeaponSocketID == 3 then
|
|
|
|
|
-- 副武器
|
|
|
|
|
CustomWeaponIDs = WeaponSelectionCombinationConfig.PlayerCustomSubWeapon
|
|
|
|
|
else
|
|
|
|
|
-- 近战武器
|
|
|
|
|
CustomWeaponIDs = WeaponSelectionCombinationConfig.PlayerCustomMeleeWeapon
|
|
|
|
|
end
|
|
|
|
|
local SocketWeaponID = -1
|
|
|
|
|
local WeaponSocketItem = self.WeaponSocketItems[self.SelectWeaponSocketID]
|
|
|
|
|
if WeaponSocketItem then
|
|
|
|
|
SocketWeaponID = WeaponSocketItem:GetWeaponID()
|
|
|
|
|
end
|
|
|
|
|
if CustomWeaponIDs then
|
|
|
|
|
for i = 1, self.UniformGridPanel_SelectWeapon:GetChildrenCount() do
|
|
|
|
|
local WeaponID = CustomWeaponIDs[i]
|
|
|
|
|
local WeaponItem = self.UniformGridPanel_SelectWeapon:GetChildAt(i - 1)
|
|
|
|
|
if WeaponID then
|
|
|
|
|
WeaponItem:SetWeaponID(WeaponID)
|
|
|
|
|
WeaponItem:SetSelect(SocketWeaponID == WeaponID)
|
|
|
|
|
WeaponItem:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
|
|
|
else
|
|
|
|
|
WeaponItem:SetVisibility(ESlateVisibility.Collapsed)
|
2025-01-14 15:37:16 +08:00
|
|
|
|
end
|
2025-01-18 23:19:35 +08:00
|
|
|
|
end
|
2025-01-14 15:37:16 +08:00
|
|
|
|
end
|
2025-01-18 23:19:35 +08:00
|
|
|
|
|
|
|
|
|
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
--- 点击选择武器
|
|
|
|
|
function WB_CustomWeapon_New:ClickSelectSaveWeapon(Index)
|
2025-01-14 15:37:16 +08:00
|
|
|
|
self.IsChange = true
|
|
|
|
|
self:SelectSaveWeapon(Index)
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
function WB_CustomWeapon_New:SelectSaveWeapon(Index)
|
2025-01-18 21:26:02 +08:00
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New_SelectSaveWeapon] Index:%s", tostring(Index))
|
2025-01-14 15:37:16 +08:00
|
|
|
|
local WeaponItem = self.UniformGridPanel_SelectWeapon:GetChildAt(Index - 1)
|
|
|
|
|
local WeaponID = WeaponItem:GetWeaponID()
|
|
|
|
|
for i = 1, self.UniformGridPanel_SelectWeapon:GetChildrenCount() do
|
|
|
|
|
local TempWeaponItem = self.UniformGridPanel_SelectWeapon:GetChildAt(i - 1)
|
|
|
|
|
TempWeaponItem:SetSelect(Index == i)
|
|
|
|
|
end
|
|
|
|
|
self:SetSelectWeapon(self.SelectWeaponSocketID, WeaponID, false)
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 设置插槽内的武器
|
|
|
|
|
---@param SocketID uint 插槽的索引 只有1和2
|
|
|
|
|
---@param bUpdateSelectWeaponBar bool 是否更新武器选择栏
|
|
|
|
|
function WB_CustomWeapon_New:SetSelectWeapon(SocketID, WeaponID, bUpdateSelectWeaponBar)
|
2025-01-18 21:26:02 +08:00
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New_SetSelectWeapon] SocketID:%s, WeaponID:%s, bUpdateSelectWeaponBar:%s", tostring(SocketID), tostring(WeaponID), tostring(bUpdateSelectWeaponBar))
|
2025-01-18 23:19:35 +08:00
|
|
|
|
-- 设置插槽页签
|
|
|
|
|
if SocketID <= 2 then
|
|
|
|
|
self.WidgetSwitcher_WeaponSocket_Type:SetActiveWidgetIndex(0)
|
|
|
|
|
elseif SocketID == 3 then
|
|
|
|
|
self.WidgetSwitcher_WeaponSocket_Type:SetActiveWidgetIndex(1)
|
|
|
|
|
else
|
|
|
|
|
self.WidgetSwitcher_WeaponSocket_Type:SetActiveWidgetIndex(2)
|
|
|
|
|
end
|
2025-01-14 15:37:16 +08:00
|
|
|
|
if bUpdateSelectWeaponBar then
|
|
|
|
|
self.SelectWeaponSocketID = SocketID
|
|
|
|
|
for i, v in pairs(self.WeaponSocketItems) do
|
|
|
|
|
v:SetSelect(i == SocketID)
|
|
|
|
|
end
|
|
|
|
|
local CustomWeaponTypeIndex = -1
|
|
|
|
|
local CustomWeaponIndex = -1;
|
2025-01-18 21:26:02 +08:00
|
|
|
|
if self.SelectWeaponSocketID <= 2 then
|
|
|
|
|
-- 获取武器ID类型和索引
|
|
|
|
|
|
|
|
|
|
for WeaponTypeIndex, v in pairs(WeaponSelectionCombinationConfig.PlayerCustomWeapon) do
|
|
|
|
|
for WeaponIndex, TempWeaponID in pairs(v.WeaponIDs) do
|
|
|
|
|
if TempWeaponID == WeaponID then
|
|
|
|
|
CustomWeaponIndex = WeaponIndex
|
|
|
|
|
CustomWeaponTypeIndex = WeaponTypeIndex
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if CustomWeaponTypeIndex > 0 then
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif self.SelectWeaponSocketID == 3 then
|
|
|
|
|
-- 设置插槽页签
|
|
|
|
|
self.WidgetSwitcher_WeaponSocket_Type:SetActiveWidgetIndex(1)
|
|
|
|
|
CustomWeaponTypeIndex = -1
|
|
|
|
|
for WeaponIndex, TempWeaponID in pairs(WeaponSelectionCombinationConfig.PlayerCustomSubWeapon) do
|
2025-01-14 15:37:16 +08:00
|
|
|
|
if TempWeaponID == WeaponID then
|
|
|
|
|
CustomWeaponIndex = WeaponIndex
|
2025-01-18 23:19:35 +08:00
|
|
|
|
break
|
2025-01-14 15:37:16 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2025-01-18 21:26:02 +08:00
|
|
|
|
else
|
|
|
|
|
-- 设置插槽页签
|
|
|
|
|
self.WidgetSwitcher_WeaponSocket_Type:SetActiveWidgetIndex(2)
|
|
|
|
|
CustomWeaponTypeIndex = -2
|
|
|
|
|
for WeaponIndex, TempWeaponID in pairs(WeaponSelectionCombinationConfig.PlayerCustomMeleeWeapon) do
|
|
|
|
|
if TempWeaponID == WeaponID then
|
|
|
|
|
CustomWeaponIndex = WeaponIndex
|
2025-01-18 23:19:35 +08:00
|
|
|
|
break
|
2025-01-18 21:26:02 +08:00
|
|
|
|
end
|
2025-01-14 15:37:16 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- 更新选择栏
|
|
|
|
|
self:SelectWeaponType(CustomWeaponTypeIndex)
|
|
|
|
|
self:SelectSaveWeapon(CustomWeaponIndex)
|
2025-01-18 21:26:02 +08:00
|
|
|
|
|
2025-01-14 15:37:16 +08:00
|
|
|
|
else
|
|
|
|
|
local SocketItem = self.WeaponSocketItems[SocketID]
|
|
|
|
|
if SocketItem then
|
|
|
|
|
SocketItem:SetWeaponID(WeaponID)
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-01-18 21:14:32 +08:00
|
|
|
|
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 重置武器配置
|
|
|
|
|
function WB_CustomWeapon_New:ResetWeaponComb()
|
2025-01-14 15:37:16 +08:00
|
|
|
|
local CombinationList = WeaponSelectionCombinationConfig.Weapon
|
|
|
|
|
if CombinationList and CombinationList[self.ProgrammeIndex] then
|
|
|
|
|
local Comb = CombinationList[self.ProgrammeIndex]
|
|
|
|
|
for i = #Comb, 1, -1 do
|
|
|
|
|
self:SetSelectWeapon(i, Comb[i], (i == 1))
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function WB_CustomWeapon_New:SaveWeaponComb()
|
2025-01-14 15:37:16 +08:00
|
|
|
|
local WeaponComb = {}
|
|
|
|
|
local PartsComb = {}
|
|
|
|
|
for i, v in pairs(self.WeaponSocketItems) do
|
|
|
|
|
WeaponComb[i] = v:GetWeaponID()
|
|
|
|
|
-- 传入武器ID,并保存
|
|
|
|
|
PartsComb[v:GetWeaponID()] = v:GetAllParts()
|
|
|
|
|
end
|
|
|
|
|
UGCLogSystem.LogTree("[WB_CustomWeapon_SaveWeaponComb]WeaponComb:", WeaponComb)
|
2025-01-21 11:29:14 +08:00
|
|
|
|
GameState:SendMiniGameRPC("PlayerSelectWeapons", LocalPlayerKey, self.ProgrammeIndex, WeaponComb);
|
2025-01-14 15:37:16 +08:00
|
|
|
|
-- 关闭UI
|
|
|
|
|
self:CloseSelf()
|
2025-01-21 11:29:14 +08:00
|
|
|
|
-- 通知父类
|
|
|
|
|
ArchiveTable[LocalPlayerKey].EnterWeapons[self.ProgrammeIndex] = TableHelper.DeepCopyTable(WeaponComb);
|
|
|
|
|
UGCEventSystem.SendEvent(EventTypes.UpdateEnterWeapons);
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function WB_CustomWeapon_New:ClickClose()
|
2025-01-21 11:29:14 +08:00
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New:ClickClose] 执行")
|
2025-01-14 15:37:16 +08:00
|
|
|
|
if self.IsChange then
|
2025-01-21 11:29:14 +08:00
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New:ClickClose] 关闭界面进行二次确认")
|
|
|
|
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.TwoConfirm, false)
|
|
|
|
|
WidgetManager:GetPanel(WidgetConfig.EUIType.TwoConfirm, function(Widget1)
|
|
|
|
|
Widget1:SetTextInfo("该配置还未保存,是否保存后关闭页面?", "关闭", "保存");
|
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New:ClickClose] 111")
|
|
|
|
|
Widget1:BindCancellationCallBack(self.CloseSelf, self);
|
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New:ClickClose] 222")
|
|
|
|
|
Widget1:BindConfirmCallBack(self.SaveWeaponComb, self);
|
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New:ClickClose] 333")
|
|
|
|
|
end);
|
2025-01-14 15:37:16 +08:00
|
|
|
|
else
|
2025-01-21 11:29:14 +08:00
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New:ClickClose] 关闭自身")
|
2025-01-14 15:37:16 +08:00
|
|
|
|
self:CloseSelf()
|
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function WB_CustomWeapon_New:CloseSelf()
|
2025-01-14 15:37:16 +08:00
|
|
|
|
WidgetManager:ClosePanel(WidgetConfig.EUIType.CustomSelectWeapon)
|
|
|
|
|
self.IsChange = false
|
2025-01-04 23:00:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
2025-01-16 13:35:17 +08:00
|
|
|
|
--- 拿到当前点击的武器ID
|
|
|
|
|
function WB_CustomWeapon_New:OnClickSetParts()
|
|
|
|
|
local WeaponSocketItem = self.WeaponSocketItems[self.SelectWeaponSocketID or 1];
|
|
|
|
|
if WeaponSocketItem then
|
|
|
|
|
local WeaponID = WeaponSocketItem:GetWeaponID()
|
|
|
|
|
if WeaponID then
|
2025-01-21 11:29:14 +08:00
|
|
|
|
UGCLogSystem.Log("[WB_CustomWeapon_New:OnClickSetParts] WeaponID = ", tostring(WeaponID));
|
|
|
|
|
WidgetManager:GetPanel(WidgetConfig.EUIType.WeaponConfiguration, function(Widget)
|
|
|
|
|
Widget:SetWeaponID(WeaponID);
|
|
|
|
|
end)
|
2025-01-16 13:35:17 +08:00
|
|
|
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.WeaponConfiguration, true, WeaponID);
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-01-04 23:00:19 +08:00
|
|
|
|
|
|
|
|
|
-- function WB_CustomWeapon_New:Tick(MyGeometry, InDeltaTime)
|
|
|
|
|
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
-- function WB_CustomWeapon_New:Destruct()
|
|
|
|
|
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
return WB_CustomWeapon_New
|