选配件

This commit is contained in:
lantiannb 2025-01-15 03:21:37 +08:00
parent 46cce4421a
commit cea0dae0bf
8 changed files with 343 additions and 3 deletions

View File

@ -104,12 +104,13 @@ function UGCPlayerController:OnRespawnPawn()
end end
end end
else else
if GlobalMiniMode.ModeType ~= GameModeConfig.EGameModeType.DefaultMode then -- 在这里修改 这里改了,改成全部都显示这个按键
--if GlobalMiniMode.ModeType ~= GameModeConfig.EGameModeType.DefaultMode then
UGCLogSystem.Log("[UGCPlayerController:OnRespawnPawn] 显示按钮") UGCLogSystem.Log("[UGCPlayerController:OnRespawnPawn] 显示按钮")
WidgetManager:GetPanel(WidgetConfig.EUIType.Main, function(Widget) WidgetManager:GetPanel(WidgetConfig.EUIType.Main, function(Widget)
table.func(Widget, "ShowCustomSelectWeaponBtn", true); table.func(Widget, "ShowCustomSelectWeaponBtn", true);
end) end)
end --end
end end
end end

View File

@ -21,6 +21,7 @@ WidgetConfig.EUIType = {
TipSlidingTackle = 1002, TipSlidingTackle = 1002,
SelectWeaponNew = 1003, SelectWeaponNew = 1003,
SecondaryConfirmation = 1004, SecondaryConfirmation = 1004,
WeaponConfiguration = 1005,
} }
if not UE_SERVER then if not UE_SERVER then
@ -243,6 +244,15 @@ if not UE_SERVER then
bShowOnce = false, bShowOnce = false,
Layer = WidgetConfig.EUILayerGroup.High, Layer = WidgetConfig.EUILayerGroup.High,
}, },
[WidgetConfig.EUIType.WeaponConfiguration] = {
Path = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectWeapons/WeaponConfiguration/WB_WeaponConfiguration.WB_WeaponConfiguration_C'),
-- 是否仅显示一次
bShowOnce = false,
Layer = WidgetConfig.EUILayerGroup.High,
},
} }
end end

View File

@ -1,6 +1,8 @@
---@class WB_ReselectWeaponBtn_C:UUserWidget ---@class WB_ReselectWeaponBtn_C:UUserWidget
---@field Button_ReselectWeapon UButton ---@field Button_ReselectWeapon UButton
---@field Image_CD UImage ---@field Image_CD UImage
---@field Image_CD_ClassicMode UImage
---@field WidgetSwitcher_ClassicMode UWidgetSwitcher
--Edit Below-- --Edit Below--
---@type WB_ReselectWeaponBtn_C ---@type WB_ReselectWeaponBtn_C
local WB_ReselectWeaponBtn = { local WB_ReselectWeaponBtn = {
@ -15,6 +17,10 @@ function WB_ReselectWeaponBtn:LuaInit()
self.bInitDoOnce = true; self.bInitDoOnce = true;
UITool.BindButtonClicked(self.Button_ReselectWeapon, self.ClickBtn, self) UITool.BindButtonClicked(self.Button_ReselectWeapon, self.ClickBtn, self)
-- 在这里修改 检查一下这里判断模式的方式是否正确
UGCEventSystem.AddListener(EventTypes.UpdateModeType, self.SetIsGangUpMode, self);
self:SetIsGangUpMode(GlobalModeType)
end end
function WB_ReselectWeaponBtn:OnTick() function WB_ReselectWeaponBtn:OnTick()
@ -55,12 +61,26 @@ function WB_ReselectWeaponBtn:UpdateCooling()
local Material = self.Image_CD:GetDynamicMaterial(); local Material = self.Image_CD:GetDynamicMaterial();
local Percent = 1 - (NowTime - self.StartShowTime) / self.ShowTime local Percent = 1 - (NowTime - self.StartShowTime) / self.ShowTime
Material:SetScalarParameterValue("Mask_Percent", Percent); Material:SetScalarParameterValue("Mask_Percent", Percent);
local Material_ClassicMode = self.Image_CD_ClassicMode:GetDynamicMaterial();
local Percent_ClassicMode = 1 - (NowTime - self.StartShowTime) / self.ShowTime
Material_ClassicMode:SetScalarParameterValue("Mask_Percent", Percent_ClassicMode);
-- UGCLogSystem.Log("[WB_ReselectWeaponBtn_UpdateCooling] " 1 - (NowTime - self.StartShowTime) / self.ShowTime) -- UGCLogSystem.Log("[WB_ReselectWeaponBtn_UpdateCooling] " 1 - (NowTime - self.StartShowTime) / self.ShowTime)
end end
function WB_ReselectWeaponBtn:ClickBtn() function WB_ReselectWeaponBtn:ClickBtn()
self:CloseBtn() self:CloseBtn()
if GlobalModeType == GameModeConfig.EGameModeType.DefaultMode then
WidgetManager:ShowPanel(WidgetConfig.EUIType.WeaponConfiguration)
else
WidgetManager:ShowPanel(WidgetConfig.EUIType.SelectWeaponNew) WidgetManager:ShowPanel(WidgetConfig.EUIType.SelectWeaponNew)
end
end
function WB_ReselectWeaponBtn:SetIsGangUpMode(ModeType)
if GlobalModeType then
self.WidgetSwitcher_ClassicMode:SetActiveWidgetIndex(ModeType == GameModeConfig.EGameModeType.DefaultMode and 1 or 0);
end
end end
return WB_ReselectWeaponBtn; return WB_ReselectWeaponBtn;

View File

@ -0,0 +1,90 @@
---@class WB_WeaponConfigPartItem_C:UUserWidget
---@field Image_5 UImage
---@field Image_PartIcon UImage
---@field NewButton_ChangePart UNewButton
---@field WidgetSwitcher_IsNilPart UWidgetSwitcher
---@field WidgetSwitcher_IsSelect UWidgetSwitcher
---@field WidgetSwitcher_IsSelect_OLD UWidgetSwitcher
---@field WidgetSwitcher_SelectStyle UWidgetSwitcher
--Edit Below--
local WB_WeaponConfigPartItem = {
bInitDoOnce = false;
};
--[==[ Construct
function WB_WeaponConfigPartItem:Construct()
end
-- Construct ]==]
-- function WB_WeaponConfigPartItem:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_WeaponConfigPartItem:Destruct()
-- end
function WB_WeaponConfigPartItem:LuaInit()
if self.bInitDoOnce then return end
self.bInitDoOnce = true
WidgetLibrary.BindButtonClicked(self.NewButton_ChangePart, self.ClickCallBack, self)
end
function WB_WeaponConfigPartItem:ClickCallBack()
if self.SelectCallBackFunc then
if self.SelectCallBackObj then
self.SelectCallBackFunc(self.SelectCallBackObj, self:GetItemID(), self:GetPartType())
else
self.SelectCallBackFunc(self:GetItemID(), self:GetPartType())
end
end
end
function WB_WeaponConfigPartItem:BindSelectCallBack(InFunc, InObj)
self.SelectCallBackFunc = InFunc
self.SelectCallBackObj = InObj
end
WB_WeaponConfigPartItem.PartID = -1
function WB_WeaponConfigPartItem:SetItemID(InPartID)
if self.PartID ~= InPartID then
self.PartID = InPartID
if self.PartID and self.PartID >= 0 then
self:SetVisibility(ESlateVisibility.Visible)
if self.PartID == 0 then
self.WidgetSwitcher_IsNilPart:SetActiveWidgetIndex(1)
else
self.WidgetSwitcher_IsNilPart:SetActiveWidgetIndex(0)
MyWeaponSystem.AsyncLoadItemSmallIconToBrush(self.PartID, self.Image_PartIcon)
end
else
self:SetVisibility(ESlateVisibility.Collapsed)
end
end
end
function WB_WeaponConfigPartItem:GetItemID()
return self.PartID
end
function WB_WeaponConfigPartItem:SetPartType(InType)
self:LuaInit()
self.PartType = InType
end
function WB_WeaponConfigPartItem:GetPartType()
return self.PartType
end
function WB_WeaponConfigPartItem:SetIsSelect(InIsSelect)
self.WidgetSwitcher_IsSelect:SetActiveWidgetIndex(InIsSelect and 1 or 0)
end
function WB_WeaponConfigPartItem:SetSelectStyle(StyleIndex)
self.WidgetSwitcher_SelectStyle:SetActiveWidgetIndex(StyleIndex)
end
return WB_WeaponConfigPartItem;

View File

@ -0,0 +1,219 @@
---@class WB_WeaponConfiguration_C:UUserWidget
---@field CanvasPanel_WeaponInfo UCanvasPanel
---@field Image_WeaponIcon UImage
---@field NewButton_Close UNewButton
---@field NewButton_Close_Old UNewButton
---@field NewButton_Save UNewButton
---@field PartItem_ButtStock UWB_WeaponConfigPartItem_C
---@field PartItem_Grip UWB_WeaponConfigPartItem_C
---@field PartItem_Magazine UWB_WeaponConfigPartItem_C
---@field PartItem_Muzzle UWB_WeaponConfigPartItem_C
---@field PartItem_SubTelescope UWB_WeaponConfigPartItem_C
---@field PartItem_Telescope UWB_WeaponConfigPartItem_C
---@field ScrollBox_SelectParts UScrollBox
---@field TextBlock_WeaponName UTextBlock
--Edit Below--
local WB_WeaponConfiguration = {
bInitDoOnce = false;
PartTypeToPartItem = {};
};
function WB_WeaponConfiguration:Construct()
self:LuaInit()
end
-- function WB_WeaponConfiguration:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_WeaponConfiguration:Destruct()
-- end
function WB_WeaponConfiguration:OnShowPanel(WeaponID)
UGCLogSystem.Log("[WB_WeaponConfiguration_OnShowPanel]")
if WeaponID then
self:SetWeaponID(WeaponID)
end
end
function WB_WeaponConfiguration:LuaInit()
if self.bInitDoOnce then
return;
end
self.bInitDoOnce = true;
WidgetLibrary.BindButtonClicked(self.NewButton_Save, self.ClickSave, self)
WidgetLibrary.BindButtonClicked(self.NewButton_Close, self.CloseSelf, self)
self.PartTypeToPartItem = {
[EWeaponPartType.Telescope] = self.PartItem_Telescope,
[EWeaponPartType.Muzzle] = self.PartItem_Muzzle,
[EWeaponPartType.Magazine] = self.PartItem_Magazine,
[EWeaponPartType.Grip] = self.PartItem_Grip,
[EWeaponPartType.ButtStock] = self.PartItem_ButtStock,
[EWeaponPartType.SubTelescope] = self.PartItem_SubTelescope,
}
-- 在这里修改 这里是经典模式,新的回合武器改变后发送的通知 这个绑定的事件有问题需要替换
UGCEventSystem.AddListener(EventTypes.UpdateCurrWeapon, self.UpdateCurrWeapon, self)
-- 设置配件类型
for PartType, Item in pairs(self.PartTypeToPartItem) do
Item:LuaInit()
Item:SetPartType(PartType)
Item:BindSelectCallBack(self.ClickPart, self)
end
for i = 1, self.ScrollBox_SelectParts:GetChildrenCount() do
local Item = self.ScrollBox_SelectParts:GetChildAt(i - 1)
Item:LuaInit()
Item:SetSelectStyle(1)
Item:BindSelectCallBack(self.ClickSelectPart, self)
end
-- 在这里修改 测试
self:SetWeaponID(101005)
end
function WB_WeaponConfiguration:CloseSelf()
WidgetManager:ClosePanel(WidgetConfig.EUIType.WeaponConfiguration)
end
function WB_WeaponConfiguration:ClickSave()
local WeaponParts = self:GetAllParts()
local WeaponID = self.WeaponID
-- 在这里修改 发送RPC到DS设置配件
-- 关闭该UI
self:CloseSelf()
end
function WB_WeaponConfiguration:GetWeaponID()
return self.WeaponID
end
function WB_WeaponConfiguration:SetWeaponID(WeaponID)
if self.WeaponID ~= WeaponID then
self.WeaponID = WeaponID
local WeaponParts = MyWeaponSystem.GetWeaponBastParts(self.WeaponID)
-- 在这里修改 获取存档中的武器配件存档 CustomWeaponParts = {[WeaponID] = {PartID, PartID, PartID, ...}, ...}
-- local CustomWeaponParts = ArchiveDataConfig.GetPlayerArchiveDataFromType(UGCSystemLibrary.GetLocalPlayerKey(), ArchiveDataConfig.EArchiveType.CustomWeaponParts)
local CustomWeaponParts = nil
if CustomWeaponParts and CustomWeaponParts[self.WeaponID] then
WeaponParts = CustomWeaponParts[self.WeaponID]
end
UGCLogSystem.LogTree("[WB_WeaponConfiguration_SetWeaponID]", WeaponParts)
local WeaponPartsMap = MyWeaponSystem.PartListToPartMap(WeaponParts)
local UpdateSelectPartsOnce = false
for PartType, Item in pairs(self.PartTypeToPartItem) do
local ItemID = WeaponPartsMap[PartType]
Item:SetItemID(ItemID)
--UGCLogSystem.Log("[WB_WeaponConfiguration_SetWeaponID] ItemID:" .. tostring(ItemID))
-- 设置当前默认选择的Part
if ItemID and not UpdateSelectPartsOnce then
UpdateSelectPartsOnce = true
self:SetSelectPartType(PartType)
end
end
if not UpdateSelectPartsOnce then
self:SetSelectPartType(nil)
end
--MyWeaponSystem.AsyncLoadItemBigIconToBrush(self.WeaponID, self.Image_WeaponIcon)
MyWeaponSystem.AsyncLoadItemWhiteIconToBrush(self.WeaponID, self.Image_WeaponIcon)
self.TextBlock_WeaponName:SetText(MyWeaponSystem.GetItemName(self.WeaponID))
end
end
function WB_WeaponConfiguration:ClickPart(PartID, PartType)
-- local PartType = MyWeaponSystem.GetPartType(PartID)
self:SetSelectPartType(PartType)
end
--- 设置选择修改的类型
function WB_WeaponConfiguration:SetSelectPartType(InPartType)
UGCLogSystem.Log("[WB_WeaponConfiguration_SetSelectPartType] InPartType:%s", tostring(InPartType))
self.SelectPartType = InPartType
local ItemID = -1
if self.PartTypeToPartItem[InPartType] then
ItemID = self.PartTypeToPartItem[InPartType]:GetItemID()
end
local Parts = MyWeaponSystem.GetWeaponCanUsePartFromPartType(self.WeaponID, InPartType)
for i = 1, self.ScrollBox_SelectParts:GetChildrenCount() do
local Item = self.ScrollBox_SelectParts:GetChildAt(i - 1)
if i == 1 then
-- 在这里修改 这里默认取消配件为 0就是不装这个配件 不能改成负数
Item:SetItemID(0)
Item:SetIsSelect(ItemID == 0)
else
Item:SetItemID(Parts[i - 1])
Item:SetIsSelect(ItemID == Parts[i - 1])
end
end
for PartType, Item in pairs(self.PartTypeToPartItem) do
Item:SetIsSelect(InPartType == PartType)
end
end
--- 修改显示的配件
function WB_WeaponConfiguration:ClickSelectPart(PartID)
UGCLogSystem.Log("[WB_WeaponConfiguration_ClickSelectPart] PartID:%s, PartType:%s", tostring(PartID), tostring(PartType))
--local PartType = MyWeaponSystem.GetPartType(PartID)
local PartItem = self.PartTypeToPartItem[self.SelectPartType]
if PartItem then
PartItem:SetItemID(PartID)
-- 设置已选择
for i = 1, self.ScrollBox_SelectParts:GetChildrenCount() do
local Item = self.ScrollBox_SelectParts:GetChildAt(i - 1)
Item:SetIsSelect(PartID == Item:GetItemID())
end
end
end
--- 获取当前修改后的配件信息
function WB_WeaponConfiguration:GetAllParts()
local Res = {}
for PartType, Item in pairs(self.PartTypeToPartItem) do
local ItemID = Item:GetItemID()
if ItemID and MyWeaponSystem.IsWeaponPartValid(ItemID) then
Res[#Res + 1] = ItemID
end
end
return Res
end
function WB_WeaponConfiguration:UpdateCurrWeapon(WeaponIDs)
UGCLogSystem.LogTree("[WB_WeaponConfiguration_UpdateCurrWeapon]", WeaponIDs)
-- 在这里修改,刷新武器显示
if WeaponIDs[1] then
self:SetWeaponID(WeaponIDs[1])
end
end
return WB_WeaponConfiguration;