---@class WB_ShowBuff_C:UUserWidget ---@field NewButton_Show UNewButton ---@field UniformGridPanel_Buff UUniformGridPanel ---@field VerticalBox_OtherBuff UVerticalBox ---@field WidgetSwitcher_DetailedInformation UWidgetSwitcher ---@field WidgetSwitcher_DetailedInformationText UWidgetSwitcher --Edit Below-- local WB_ShowBuff = { SmallItemRaw = 4; bInitDoOnce = false; bIsExpand = false; IsGod = false; }; function WB_ShowBuff:Construct() WidgetLibrary.BindButtonClicked(self.NewButton_Show, self.Expand, self) UGCEventSystem.AddListener(EventEnum.UpdateOwnedIncrease, self.UpdateShowBuff, self) UGCEventSystem.AddListener(EventEnum.UpdateToGodSchedule, self.UpdateShowBuff, self) self:InitBuffList() -- 校验 self:UpdateShowBuff() UGCEventSystem.SetTimerLoop(self, function() self:UpdateShowBuff() end, 3 ) end function WB_ShowBuff:GetShowBuffItemClass() if self.ShowBuffItemClass == nil then self.ShowBuffItemClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/StatusUI/FightPanel/ShowBuff/WB_ShowBuffItem.WB_ShowBuffItem_C')) end return self.ShowBuffItemClass end function WB_ShowBuff:GetShowBuffSmallItemClass() if self.ShowBuffSmallItemClass == nil then self.ShowBuffSmallItemClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/StatusUI/FightPanel/ShowBuff/WB_ShowBuffSmallItem.WB_ShowBuffSmallItem_C')) end return self.ShowBuffSmallItemClass end function WB_ShowBuff:InitBuffList() local LocalPC = UGCSystemLibrary.GetLocalPlayerController() local Count = table.getCount(GodOfWarConfig.EIncreaseType) for i = 0, Count do local ShowBuffItem = UserWidget.NewWidgetObjectBP(LocalPC, self:GetShowBuffItemClass()); if ShowBuffItem then self.VerticalBox_OtherBuff:AddChild(ShowBuffItem) ShowBuffItem:UpdateInfo((i == 0), i, 1, false) end local ShowBuffSmallItem = UserWidget.NewWidgetObjectBP(LocalPC, self:GetShowBuffSmallItemClass()); if ShowBuffSmallItem then self.UniformGridPanel_Buff:AddChild(ShowBuffSmallItem) ShowBuffSmallItem:UpdateInfo((i == 0), i, 1, false) local TargetUniformGridSlot = WidgetLayoutLibrary.SlotAsUniformGridSlot(ShowBuffSmallItem) -- 居中 TargetUniformGridSlot:SetVerticalAlignment(EVerticalAlignment.VAlign_Center) TargetUniformGridSlot:SetHorizontalAlignment(EHorizontalAlignment.HAlign_Center) -- 设置索引 TargetUniformGridSlot:SetColumn(i % self.SmallItemRaw) TargetUniformGridSlot:SetRow(i // self.SmallItemRaw) end end end function WB_ShowBuff:Expand() self.bIsExpand = not self.bIsExpand if self.bIsExpand then self.WidgetSwitcher_DetailedInformation:SetActiveWidgetIndex(0) self.WidgetSwitcher_DetailedInformationText:SetActiveWidgetIndex(1) else self.WidgetSwitcher_DetailedInformation:SetActiveWidgetIndex(1) self.WidgetSwitcher_DetailedInformationText:SetActiveWidgetIndex(0) end end function WB_ShowBuff:UpdateShowBuff() --UGCLogSystem.Log("[WB_ShowBuff_UpdateShowBuff]") local LocalPC = UGCSystemLibrary.GetLocalPlayerController() --UGCLogSystem.Log("[WB_ShowBuff_UpdateShowBuff] 1") local IsGod = LocalPC:PlayerIsGod() self.IsGod = IsGod local OwnedIncrease = LocalPC:GetAllOwnedIncreaseLevel() --UGCLogSystem.Log("[WB_ShowBuff_UpdateShowBuff] isGod:%s", tostring(self.IsGod)) --UGCLogSystem.LogTree("[WB_ShowBuff_UpdateShowBuff]OwnedIncrease:", OwnedIncrease) for i = 0, self.VerticalBox_OtherBuff:GetChildrenCount() - 1 do local Item = self.VerticalBox_OtherBuff:GetChildAt(i) if i == 0 then if self.IsGod then Item:SetVisibility(ESlateVisibility.HitTestInvisible) else Item:SetVisibility(ESlateVisibility.Collapsed) end else local IncreaseType = Item:GetIncreaseType() local Level = OwnedIncrease[IncreaseType] --UGCLogSystem.Log("[WB_ShowBuff_UpdateShowBuff] IncreaseType:%s", tostring(IncreaseType)) if Level then Item:SetVisibility(ESlateVisibility.HitTestInvisible) Item:UpdateLevel(Level, Level >= #GodOfWarConfig.BuffList[IncreaseType]) else Item:SetVisibility(ESlateVisibility.Collapsed) end end end local ShowIndex = 0; for i = 0, self.UniformGridPanel_Buff:GetChildrenCount() - 1 do local SmallItem = self.UniformGridPanel_Buff:GetChildAt(i) if i == 0 then if self.IsGod then ShowIndex = ShowIndex + 1 SmallItem:SetVisibility(ESlateVisibility.HitTestInvisible) else SmallItem:SetVisibility(ESlateVisibility.Collapsed) end else local IncreaseType = SmallItem:GetIncreaseType() local Level = OwnedIncrease[IncreaseType] --UGCLogSystem.Log("[WB_ShowBuff_UpdateShowBuff] IncreaseType2:%s", tostring(IncreaseType)) if Level then SmallItem:SetVisibility(ESlateVisibility.HitTestInvisible) SmallItem:UpdateLevel(Level, Level >= #GodOfWarConfig.BuffList[IncreaseType]) local TargetUniformGridSlot = WidgetLayoutLibrary.SlotAsUniformGridSlot(SmallItem) -- 设置索引 TargetUniformGridSlot:SetColumn(ShowIndex % self.SmallItemRaw) TargetUniformGridSlot:SetRow(ShowIndex // self.SmallItemRaw) ShowIndex = ShowIndex + 1 else SmallItem:SetVisibility(ESlateVisibility.Collapsed) end end end end -- function WB_ShowBuff:Tick(MyGeometry, InDeltaTime) -- end -- function WB_ShowBuff:Destruct() -- end return WB_ShowBuff;