local BulletScreen_Controller = {} local private = {} local EventSystem = require("Event/EventSystem") BulletScreen_Controller.OperateEnum = { Add = 1, Hide = 2, Show = 3, ClearScreen = 4, ChangeSpeed = 5, Pause = 6, Resume = 7, ClearChannel = 8, -- 清除指定频道弹幕 } function BulletScreen_Controller.OnStartup() EventSystem.Regist(EventID.Timeline_OnStart, private.OnTimelineStart) EventSystem.Regist(EventID.Timeline_OnPause, private.OnTimelinePause) EventSystem.Regist(EventID.Timeline_OnFinish, private.OnTimelineFinish) end function private.OnTimelineStart(timelinePath) local timelineId = CTL.Cutscene.GetIDByTimelinePath(timelinePath) MDL.BulletScreen.GetBulletScreenTimeLineReq(timelineId) end function private.OnTimelinePause(isPause) if isPause then BulletScreen_Controller.Pause() else BulletScreen_Controller.Resume() end end function private.OnTimelineFinish() MDL.BulletScreen.CloseTLBulletScreen() end --region 操作弹幕相关方法 --添加弹幕 ---@param msg 可以是一个msg或者一个由msg组成的list ---@param index 不传默认添加到最后,传入视为插入的索引位置 function BulletScreen_Controller.AddMsg(msg, index) EventSystem.Dispatch(EventID.UI_BulletScreen_Operate, BulletScreen_Controller.OperateEnum.Add, msg, index) end --隐藏弹幕 function BulletScreen_Controller.Hide() EventSystem.Dispatch(EventID.UI_BulletScreen_Operate, BulletScreen_Controller.OperateEnum.Hide) end --显示弹幕 function BulletScreen_Controller.Show() EventSystem.Dispatch(EventID.UI_BulletScreen_Operate, BulletScreen_Controller.OperateEnum.Show) end --清空正在播放的所有弹幕(可搭配Show一起使用) function BulletScreen_Controller.ClearScreen() EventSystem.Dispatch(EventID.UI_BulletScreen_Operate, BulletScreen_Controller.OperateEnum.ClearScreen) end --清空正在播放的指定频道弹幕 function BulletScreen_Controller.ClearChannelScreen(channelID) EventSystem.Dispatch(EventID.UI_BulletScreen_Operate, BulletScreen_Controller.OperateEnum.ClearChannel, channelID) end --实时修改后续弹幕的速度(已播放出来的弹幕不受影响) function BulletScreen_Controller.ChangeSpeed(lowSpeed, highSpeed) EventSystem.Dispatch(EventID.UI_BulletScreen_Operate, BulletScreen_Controller.OperateEnum.ChangeSpeed, lowSpeed, highSpeed) end function BulletScreen_Controller.Pause() EventSystem.Dispatch(EventID.UI_BulletScreen_Operate, BulletScreen_Controller.OperateEnum.Pause) end function BulletScreen_Controller.Resume() EventSystem.Dispatch(EventID.UI_BulletScreen_Operate, BulletScreen_Controller.OperateEnum.Resume) end --endregion function BulletScreen_Controller.IsOutOfLengthWhenInsertContent(input, limit) local length = UTL.String.GetStrLen(input) if length > limit then CTL.Tips.AddSpecialTipsMsg(Const_IDS.IDS_Chat_New_UpperLimit) return true end return false end function BulletScreen_Controller.IsOutOfLength(input, limit) local length = UTL.String.GetStrLen(input) if length == 0 then CTL.Tips.AddSpecialTipsMsg(Const_IDS.IDS_StoryTL_Hint_1) return true end if length > limit then CTL.Tips.AddSpecialTipsMsg(Const_IDS.IDS_Friend_ChatLimit) return true end return false end return BulletScreen_Controller