--[[ 常驻弹幕 JWS-31188 增加 组队、势力 聊天频道弹幕 ]]-- local ChannelChatBulletScreen_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local COLON_FORMAT = "%s : %s" local LAST_LOGIN_TIME_KEY = "LAST_LOGIN_TIME" local GVG_LAST_BULLET_TIME_KEY = "GVG_LAST_BULLET_TIME" local GVG_LAST_BULLET_UUID_KEY = "GVG_LAST_BULLET_UUID" local TeamTitle = UIUtils.GetLocalizedTxt(Const_IDS.IDS_Chat_New_Duiwu) local GuildTitle = UIUtils.GetLocalizedTxt(Const_IDS.IDS_Chat_New_Juntuan) local MyBulletColor = DataSheetManager.ConstData:GetDataByID("MyBulletColor").StringValue -- 我的弹幕颜色 local OthersBulletColor = DataSheetManager.ConstData:GetDataByID("OthersBulletColor").StringValue -- 别人的弹幕颜色 local MyBulletTextSize = DataSheetManager.ConstData:GetDataByID("MyBulletTextSize").IntValue -- 我的弹幕字号 local OthersBulletTextSize = DataSheetManager.ConstData:GetDataByID("OthersBulletTextSize").IntValue -- 别人的弹幕字号 function ChannelChatBulletScreen_Controller.OnStartup() -- 1.5.000版本之后开启弹幕功能 if GameAppInfo.IsVersionGreaterThan15000() and not GameAppInfo.IsJapanesePackage() and not GameAppInfo.IsVietnamPackage() then EventSystem.Regist(EventID.UI_ChannelChat_BulletScreen, CTL.ChannelChatBulletScreen.OnReceivedBulletChannelMsg) end end function ChannelChatBulletScreen_Controller.OnReceivedBulletChannelMsg(chatData, msgData, isNewMsg) local chatCfgData = MDL.ChannelChat.GetChatCfgDataByChannelId(chatData.targetId) -- 日服不要聊天弹幕 if GameAppInfo.IsJapanesePackage() or GameAppInfo.IsVietnamPackage() then return end -- 观战状态不显示聊天频道弹幕 if BattleDataGetter.IsInLevelWatchBattle() then return end -- 过滤掉老消息 if chatCfgData.ID ~= MDL.ChannelChat.ChannelCfgId.GVGFight or not CTL.GVGFight.CanPlayGVGBullet() then local curTime = PersistentData.PlayerData:Get(LAST_LOGIN_TIME_KEY,0) if curTime > 0 and msgData.sendStamp < curTime then return end end -- 系统代发的模板消息 if msgData.templateInfo.params[1] and msgData.templateInfo.params[1].param.mapPointInfo.mapId == nil then return else if not string.isNilOrEmpty(msgData.templateInfo.idsTemplate) or msgData.templateInfo.templateId > 0 then return end end -- 系统消息跳过 if chatData.heroId == nil or chatData.heroId <= 0 then return end if MDL.ChannelChat.IsCommonBulletChannelByChannelId(chatData.targetId) then if chatCfgData.ID == MDL.ChannelChat.ChannelCfgId.Legion then local myGuildMemberInfo = MDL.Guild.GetMyGuildInfo() if msgData.sendStamp < myGuildMemberInfo.joinGuildTime then return end elseif chatCfgData.ID == MDL.ChannelChat.ChannelCfgId.Team then local myTeamMemberInfo = MDL.Team.GetSelfMemberInfo() if msgData.sendStamp < myTeamMemberInfo.memberJoinTime then return end end local isAutoPlay = MDL.ChannelChat.GetAutoPlayBulletScreenChannelState(chatCfgData.ID) if isAutoPlay then if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIBulletScreenPanel, true) then MDL.BulletScreen.OpenBulletScreen() end -- 攻城略地 增加弹幕配置 if chatCfgData.ID == MDL.ChannelChat.ChannelCfgId.GVGFight then if not MDL.Friend.IsPlayerBlack(msgData.fromId) then local index = nil if not isNewMsg then index = 1 end CTL.BulletScreen.AddMsg({ chatMsgData = chatData, content = private.CreateBulletChannelText(chatData), fontColor = msgData.fromId == BattleDataGetter.GetAcID() and "#" .. MyBulletColor or "#" .. OthersBulletColor, fontSize = msgData.fromId == BattleDataGetter.GetAcID() and MyBulletTextSize or OthersBulletTextSize, }, index) end else CTL.BulletScreen.AddMsg({ chatMsgData = chatData, content = private.CreateBulletChannelText(chatData), fontColor = nil }) end end end end function private.CreateBulletChannelText(msgData) local chatCfgData = MDL.ChannelChat.GetChatCfgDataByChannelId(msgData.targetId) local chatStr = string.format(COLON_FORMAT, msgData.senderName, msgData.content) if chatCfgData.ID == MDL.ChannelChat.ChannelCfgId.Team then if string.isNilOrEmpty(msgData.color) then chatStr = TeamTitle .. " " .. chatStr else chatStr = TeamTitle .. " " .. UTL.Color.GetColorfulText(msgData.color, chatStr) end elseif chatCfgData.ID == MDL.ChannelChat.ChannelCfgId.Legion then if string.isNilOrEmpty(msgData.color) then chatStr = GuildTitle .. " " .. chatStr else chatStr = GuildTitle .. " " .. UTL.Color.GetColorfulText(msgData.color, chatStr) end end return chatStr end return ChannelChatBulletScreen_Controller