145 lines
4.9 KiB
Lua
145 lines
4.9 KiB
Lua
|
---@class WB_SelectIncrease_C:UAEUserWidget
|
|||
|
---@field CanvasPanel_SelectMenu UCanvasPanel
|
|||
|
---@field HorizontalBox_Buffs UHorizontalBox
|
|||
|
---@field Image_0 UImage
|
|||
|
---@field Image_CD UImage
|
|||
|
---@field NewButton_AutoSelect UNewButton
|
|||
|
---@field TextBlock_AddCount UTextBlock
|
|||
|
---@field WidgetSwitcher_AutoSelect UWidgetSwitcher
|
|||
|
---@field WidgetSwitcher_ChangeAutoSelect UWidgetSwitcher
|
|||
|
--Edit Below--
|
|||
|
local WB_SelectIncrease = {
|
|||
|
bInitDoOnce = false;
|
|||
|
IsAutoSelect = false;
|
|||
|
CanObtainIncreaseCount = 0;
|
|||
|
};
|
|||
|
|
|||
|
function WB_SelectIncrease:Construct()
|
|||
|
UGCLogSystem.Log("[WB_SelectIncrease_Construct]")
|
|||
|
-- 校验选择的Item数量
|
|||
|
self:CheckSelectItemCount()
|
|||
|
WidgetLibrary.BindButtonClicked(self.NewButton_AutoSelect, self.ChangeAutoSelect, self)
|
|||
|
UGCEventSystem.AddListener(EventEnum.UpdateCanObtainIncreaseCount, self.UpdateCanObtainIncreaseCount, self)
|
|||
|
UGCEventSystem.AddListener(EventEnum.UpdateNowCanSelectIncrease, self.UpdateSelectBuffBox, self)
|
|||
|
UGCEventSystem.SetTimerLoop(self, self.CheckUpdateIncrease, 1)
|
|||
|
end
|
|||
|
|
|||
|
function WB_SelectIncrease:UpdateCanObtainIncreaseCount(PC, Count)
|
|||
|
UGCLogSystem.Log("[WB_SelectIncrease_UpdateCanObtainIncreaseCount]Count:%s", tostring(Count))
|
|||
|
|
|||
|
if Count > 0 then
|
|||
|
--WidgetManager:ShowPanel(WidgetConfig.EUIType.SelectBuff, false)
|
|||
|
self.CanvasPanel_SelectMenu:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|||
|
self:AutoSelect()
|
|||
|
else
|
|||
|
--WidgetManager:ClosePanel(WidgetConfig.EUIType.SelectBuff)
|
|||
|
self.CanvasPanel_SelectMenu:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
end
|
|||
|
if Count > 1 then
|
|||
|
self.TextBlock_AddCount:SetVisibility(ESlateVisibility.HitTestInvisible)
|
|||
|
self.TextBlock_AddCount:SetText("×" .. Count)
|
|||
|
else
|
|||
|
self.TextBlock_AddCount:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
end
|
|||
|
self.CanObtainIncreaseCount = Count
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
function WB_SelectIncrease:ChangeAutoSelect()
|
|||
|
self.IsAutoSelect = not self.IsAutoSelect
|
|||
|
if self.IsAutoSelect then
|
|||
|
self.WidgetSwitcher_AutoSelect:SetActiveWidgetIndex(1)
|
|||
|
self.WidgetSwitcher_ChangeAutoSelect:SetActiveWidgetIndex(1)
|
|||
|
if self.CanObtainIncreaseCount > 0 then
|
|||
|
self:AutoSelect()
|
|||
|
end
|
|||
|
else
|
|||
|
self.WidgetSwitcher_AutoSelect:SetActiveWidgetIndex(0)
|
|||
|
self.WidgetSwitcher_ChangeAutoSelect:SetActiveWidgetIndex(0)
|
|||
|
if self.AutoSelectHandle then
|
|||
|
UGCEventSystem.StopTimer(self.AutoSelectHandle)
|
|||
|
self.AutoSelectHandle = nil
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WB_SelectIncrease:AutoSelect()
|
|||
|
if self.IsAutoSelect then
|
|||
|
if self.AutoSelectHandle == nil then
|
|||
|
self.AutoSelectHandle = UGCEventSystem.SetTimer(self, function()
|
|||
|
if self.CanObtainIncreaseCount > 0 then
|
|||
|
self:SelectIncrease(1)
|
|||
|
end
|
|||
|
self.AutoSelectHandle = nil
|
|||
|
end, 1)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--- 校验子项数量是否正确
|
|||
|
function WB_SelectIncrease:CheckSelectItemCount()
|
|||
|
for i = 1, math.max(self.HorizontalBox_Buffs:GetChildrenCount(), GodOfWarConfig.CanSelectIncreaseCount) do
|
|||
|
local Item = self.HorizontalBox_Buffs:GetChildAt(i - 1)
|
|||
|
if Item == nil then
|
|||
|
UGCLogSystem.Log("[WB_SelectIncrease_CheckSelectItemCount] Add")
|
|||
|
Item = UserWidget.NewWidgetObjectBP(UGCSystemLibrary.GetLocalPlayerController(), self:GetChildClass())
|
|||
|
self.HorizontalBox_Buffs:AddChild(Item)
|
|||
|
end
|
|||
|
if i > GodOfWarConfig.CanSelectIncreaseCount then
|
|||
|
Item:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
else
|
|||
|
Item:SetIndex(i)
|
|||
|
Item:BindClickSelect(self.SelectIncrease, self)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WB_SelectIncrease:GetChildClass()
|
|||
|
if self.ChildClass == nil then
|
|||
|
self.ChildClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectBuff/WB_BuffSelectItem.WB_BuffSelectItem_C'))
|
|||
|
end
|
|||
|
return self.ChildClass
|
|||
|
end
|
|||
|
|
|||
|
--- 校验增益选择
|
|||
|
function WB_SelectIncrease:CheckUpdateIncrease()
|
|||
|
local PC = UGCSystemLibrary.GetLocalPlayerController()
|
|||
|
|
|||
|
self:UpdateCanObtainIncreaseCount(PC, PC:GetCanObtainIncreaseCount())
|
|||
|
self:UpdateSelectBuffBox(PC, PC:GetNowCanSelectIncrease())
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
function WB_SelectIncrease:UpdateSelectBuffBox(PC, InNowCanSelectIncrease)
|
|||
|
|
|||
|
for i, v in pairs(InNowCanSelectIncrease) do
|
|||
|
local Item = self.HorizontalBox_Buffs:GetChildAt(i - 1)
|
|||
|
if Item then
|
|||
|
Item:UpdateIncreaseType(v)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
function WB_SelectIncrease:SelectIncrease(SelectIndex)
|
|||
|
UGCLogSystem.Log("[WB_SelectIncrease_SelectIncrease]SelectIndex:%s", tostring(SelectIndex))
|
|||
|
if SelectIndex then
|
|||
|
UGCSendRPCSystem.ActorRPCNotify(nil, UGCSystemLibrary.GetLocalPlayerController(), "PlayerSelectIncrease", SelectIndex)
|
|||
|
UGCLogSystem.Log("[WB_SelectIncrease_SelectIncrease] Succeed")
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
-- function WB_SelectIncrease:Tick(MyGeometry, InDeltaTime)
|
|||
|
|
|||
|
-- end
|
|||
|
|
|||
|
-- function WB_SelectIncrease:Destruct()
|
|||
|
|
|||
|
-- end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
return WB_SelectIncrease;
|