---@class WBP_RollingNoticePanel_C:UUserWidget ---@field VerticalBox_Notice UVerticalBox ---@field WBP_RollingNotice UWBP_RollingNotice_C ---@field WBP_RollingNotice_0 UWBP_RollingNotice_C ---@field WBP_RollingNotice_2 UWBP_RollingNotice_C ---@field WBP_RollingNotice_3 UWBP_RollingNotice_C ---@field WBP_RollingNotice_4 UWBP_RollingNotice_C ---@field WBP_RollingNotice_5 UWBP_RollingNotice_C --Edit Below-- local WBP_RollingNoticePanel = { bInitDoOnce = false, NoticeItemWidgetClass = nil, NoticeMap = {}, NoticeNumLimit = 6, }; function WBP_RollingNoticePanel:Construct() self.bCanEverTick = true self.NoticeMap = {} self.VerticalBox_Notice:ClearChildren() self.NoticeItemWidgetClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Notice/WBP_RollingNotice.WBP_RollingNotice_C')) EventSystem:AddListener(EventType.ShowRollingNotice, WBP_RollingNoticePanel.OnReceiveRollingNoticeData, self) end function WBP_RollingNoticePanel:Destruct() EventSystem:RemoveListener(EventType.ShowRollingNotice, WBP_RollingNoticePanel.OnReceiveRollingNoticeData, self) self.NoticeMap = nil end function WBP_RollingNoticePanel:Tick(MyGeometry, InDeltaTime) if table.getCount(self.NoticeMap) > 0 then local NoticeNow = self.NoticeMap[1] NoticeNow.Duration = NoticeNow.Duration + InDeltaTime if NoticeNow.Duration >= NoticeNow.ShowTime then local NoticeNowWidget = self.VerticalBox_Notice:GetChildAt(0) if UE.IsValid(NoticeNowWidget) then NoticeNowWidget:DefaultClose() table.remove(self.NoticeMap, 1) end end end end ---接收滚动提示 ---@param NoticeData table table{Text, Color, Num} (Color, Num可选) ---@param NoticeType ERollingNoticeType 滚动提示类型(可选) ---@param ShowTime number 该词条显示时间(可选) function WBP_RollingNoticePanel:OnReceiveRollingNoticeData(NoticeData, NoticeType, ShowTime) if type(NoticeData) ~= 'table' or NoticeData.Text == nil then return end local RollingNoticeData = { ShowTime = ShowTime and ShowTime + 0.1 or 0.5, Duration = 0, Params = { Type = NoticeType or ERollingNoticeType.None, Text = NoticeData.Text, Color = NoticeData.Color or "FFFFFFFF", Num = NoticeData.Num or 0, } } self:ShowRollingNotice(RollingNoticeData) end function WBP_RollingNoticePanel:ShowRollingNotice(InNoticeData) if self.VerticalBox_Notice:GetChildrenCount() < self.NoticeNumLimit then self:CreateNewNotice(InNoticeData) end table.insert(self.NoticeMap, InNoticeData) end function WBP_RollingNoticePanel:CreateNewNotice(NoticeData) local NoticeWidget = UserWidget.NewWidgetObjectBP(self, self.NoticeItemWidgetClass) self.VerticalBox_Notice:AddChild(NoticeWidget) NoticeWidget:InitNoticeFromParam(NoticeData.Params) NoticeWidget:SetParentWidget(self) NoticeWidget:ShowEnterAnimation() return NoticeWidget end function WBP_RollingNoticePanel:RequestPopup() self.VerticalBox_Notice:RemoveChildAt(0) local RemainNoticeNum = table.getCount(self.NoticeMap) local Count = self.VerticalBox_Notice:GetChildrenCount() if RemainNoticeNum > Count and Count < self.NoticeNumLimit then local NoticeData = self.NoticeMap[Count + 1] self:CreateNewNotice(NoticeData) end end return WBP_RollingNoticePanel;