2025-01-04 23:00:19 +08:00
|
|
|
---@class WB_WeaponSelectItem_C:UUserWidget
|
|
|
|
---@field Button_Select UNewButton
|
|
|
|
---@field Image_IsSelect UImage
|
|
|
|
---@field TextBlock_TextName UTextBlock
|
|
|
|
---@field WeaponInfo1 UWB_WeaponItem_C
|
|
|
|
---@field WeaponInfo2 UWB_WeaponItem_C
|
|
|
|
--Edit Below--
|
|
|
|
local WB_WeaponSelectItem = {
|
2025-01-21 11:29:14 +08:00
|
|
|
bInitDoOnce = false;
|
|
|
|
bIsSelect = false;
|
|
|
|
ItemID = 0;
|
|
|
|
Weapons = nil;
|
2025-01-04 23:00:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
--[==[ Construct
|
|
|
|
function WB_WeaponSelectItem:Construct()
|
|
|
|
|
|
|
|
end
|
|
|
|
-- Construct ]==]
|
|
|
|
|
|
|
|
-- function WB_WeaponSelectItem:Tick(MyGeometry, InDeltaTime)
|
|
|
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
-- function WB_WeaponSelectItem:Destruct()
|
|
|
|
|
|
|
|
-- end
|
|
|
|
function WB_WeaponSelectItem:LuaInit()
|
2025-01-21 11:29:14 +08:00
|
|
|
if self.bInitDoOnce then return; end
|
|
|
|
self.bInitDoOnce = true;
|
|
|
|
WidgetLibrary.BindButtonClicked(self.Button_Select, self.SelectWeaponCombination, self)
|
|
|
|
-- 在这里修改 这里加双武器武器配置存档修改的监听
|
|
|
|
-- UGCEventSystem.AddListener(ArchiveDataConfig.GetParamNotifyEvent(ArchiveDataConfig.EArchiveType.WeaponCombs), self.UpdateWeaponComb, self)
|
|
|
|
|
|
|
|
self.Button_Select:SetTouchMethod(EButtonTouchMethod.PreciseTap)
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelectItem:Init(InCombinationIndex)
|
2025-01-21 11:29:14 +08:00
|
|
|
self:LuaInit()
|
|
|
|
|
|
|
|
self.CombinationIndex = InCombinationIndex
|
|
|
|
UGCLogSystem.Log("[WB_WeaponSelectItem:Init] InCombinationIndex = " .. InCombinationIndex);
|
|
|
|
self.TextBlock_TextName:SetText("配置" .. self.CombinationIndex)
|
|
|
|
|
|
|
|
local SavedWeaponComb = nil
|
|
|
|
if ArchiveTable[LocalPlayerKey] and not table.isEmpty(ArchiveTable[LocalPlayerKey].EnterWeapons) then
|
|
|
|
SavedWeaponComb = ArchiveTable[LocalPlayerKey].EnterWeapons;
|
|
|
|
end
|
|
|
|
|
|
|
|
local CombinationList = WeaponSelectionCombinationConfig.WeaponCombinationList.Weapon;
|
|
|
|
|
|
|
|
if SavedWeaponComb and SavedWeaponComb[self.CombinationIndex] then
|
|
|
|
self:UpdateWeapons(SavedWeaponComb[self.CombinationIndex])
|
|
|
|
elseif CombinationList and CombinationList[self.CombinationIndex] then
|
|
|
|
self:UpdateWeapons(CombinationList[self.CombinationIndex]);
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelectItem:UpdateWeaponComb()
|
2025-01-21 11:29:14 +08:00
|
|
|
local EnterWeapons = UE.GetLocalArchiveData("EnterWeapons");
|
|
|
|
local Weapons = TableHelper.DeepCopyTable(WeaponSelectionCombinationConfig.WeaponCombinationList.Weapon);
|
|
|
|
if EnterWeapons then
|
|
|
|
for i, v in pairs(Weapons) do
|
|
|
|
if EnterWeapons[i] then Weapons[i] = EnterWeapons[i]; end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if Weapons and Weapons[self.CombinationIndex] then
|
|
|
|
local TargetWeaponComb = Weapons[self.CombinationIndex]
|
|
|
|
if self.Weapons == nil or TargetWeaponComb[1] ~= self.Weapons[1] or TargetWeaponComb[2] ~= self.Weapons[2] then
|
|
|
|
self:UpdateWeapons(TargetWeaponComb)
|
|
|
|
end
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelectItem:UpdateWeapons(InWeapons)
|
2025-01-21 11:29:14 +08:00
|
|
|
self.Weapons = table.DeepCopy(InWeapons)
|
|
|
|
if self.Weapons then
|
|
|
|
self.WeaponInfo1:SetWeaponID(self.Weapons[1])
|
|
|
|
if self.Weapons[2] then
|
|
|
|
self.WeaponInfo2:SetWeaponID(self.Weapons[2])
|
|
|
|
self.WeaponInfo2:SetVisWeaponInfo(true)
|
|
|
|
else
|
|
|
|
self.WeaponInfo2:SetVisWeaponInfo(false)
|
|
|
|
end
|
|
|
|
self:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
|
|
else
|
|
|
|
self:SetVisibility(ESlateVisibility.Collapsed)
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelectItem:GetCombinationIndex()
|
2025-01-21 11:29:14 +08:00
|
|
|
return self.CombinationIndex
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelectItem:SelectWeaponCombination()
|
2025-01-21 11:29:14 +08:00
|
|
|
if self.SelectCallBackFunc then
|
|
|
|
if self.SelectCallBackObj then
|
|
|
|
self.SelectCallBackFunc(self.SelectCallBackObj, self:GetCombinationIndex())
|
|
|
|
else
|
|
|
|
self.SelectCallBackFunc(self:GetCombinationIndex())
|
|
|
|
end
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelectItem:BindSelectCallBack(InFunc, InObj)
|
2025-01-21 11:29:14 +08:00
|
|
|
self.SelectCallBackFunc = InFunc
|
|
|
|
self.SelectCallBackObj = InObj
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function WB_WeaponSelectItem:SetSelect(IsSelect)
|
2025-01-21 11:29:14 +08:00
|
|
|
if IsSelect then
|
|
|
|
self.Image_IsSelect:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
|
|
else
|
|
|
|
self.Image_IsSelect:SetVisibility(ESlateVisibility.Collapsed)
|
|
|
|
end
|
2025-01-04 23:00:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return WB_WeaponSelectItem;
|