源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1090 lines
44 KiB

  1. require("game.proto.110.Require110")
  2. require("game.chat.ChatModel")
  3. require("game.chat.TV")
  4. require("game.chat.ChatView")
  5. require("game.chat.ChatItem")
  6. require("game.chat.ChatBarBtn")
  7. require("game.chat.HornView")
  8. require("game.chat.IndividuationView")
  9. require("game.chat.ChannelSettingView")
  10. require("game.chat.VoiceVo")
  11. require("game.chat.ChatVoiceManager")
  12. require("game.chat.CecretView")
  13. require("game.chat.FaceItem")
  14. require("game.chat.TextFaceItem")
  15. require("game.chat.CecretChatItem")
  16. require("game.chat.HistroyItem")
  17. require("game.chat.PartnerShowItem")
  18. require("game.chat.EquipShowItem")
  19. require("game.chat.CecretShowItem")
  20. require("game.chat.ChatBagView")
  21. require("game.chat.ChatCustomTextView")
  22. require("game.chat.HistoryTextItem")
  23. require("game.chat.ChatChannelToggleItem")
  24. ChatController = ChatController or BaseClass(BaseController)
  25. local table_insert = table.insert
  26. function ChatController:__init()
  27. ChatController.Instance = self
  28. self.model = ChatModel:getInstance()
  29. self:RegisterProtocals()
  30. self:InitEvent()
  31. end
  32. function ChatController:RegisterProtocals()
  33. self:RegisterProtocal(11000, "on11000")
  34. self:RegisterProtocal(11001, "on11001")
  35. self:RegisterProtocal(11002, "on11002")
  36. self:RegisterProtocal(11102, "on11102")
  37. self:RegisterProtocal(11003, "on11003")
  38. self:RegisterProtocal(11004, "on11004")
  39. self:RegisterProtocal(11005, "on11005")
  40. self:RegisterProtocal(11010, "on11010")
  41. self:RegisterProtocal(11011, "on11011")
  42. self:RegisterProtocal(11013, "on11013")
  43. self:RegisterProtocal(11016, "on11016")
  44. self:RegisterProtocal(11017, "on11017")
  45. self:RegisterProtocal(11020, "on11020")
  46. self:RegisterProtocal(11021, "on11021")
  47. self:RegisterProtocal(11050, "on11050")
  48. self:RegisterProtocal(11014, "on11014")
  49. self:RegisterProtocal(11060, "on11060")
  50. self:RegisterProtocal(11061, "on11061")
  51. self:RegisterProtocal(11063, "on11063")
  52. self:RegisterProtocal(11022, "on11022") --社团求助
  53. self:RegisterProtocal(11046, "on11046")
  54. self:RegisterProtocal(11064, "on11064")--通用怪物AI警戒传闻
  55. self:RegisterProtocal(11066, "on11066")--屏蔽操作
  56. self:RegisterProtocal(11065, "on11065")--屏蔽列表
  57. self:RegisterProtocal(11067, "on11067")-- 剧情气泡推送
  58. self:RegisterProtocal(11023, "on11023") --模拟聊天缓存
  59. self:RegisterProtocal(11091, "on11091") --更新通知
  60. end
  61. --公告
  62. function ChatController:on11050()
  63. local vo = SCMD11050.New(true)
  64. self.model:StartGongGaoList(vo)
  65. end
  66. --物品不够的错误码
  67. function ChatController:on11000()
  68. local vo = SCMD11000.New(true)
  69. if vo then
  70. ErrorCodeShow(vo.error_code)
  71. end
  72. end
  73. --通用文字聊天
  74. function ChatController:on11001()
  75. local vo = SCMD11001.New(true)
  76. --if vo.result == 2 then return end -- 有些tips各种格式都有,先开出
  77. local is_in_shield_list = SocialityModel:getInstance():IsRelaviveType(vo.player_id,Config.ConfigSocial.RelativeType.black)
  78. if is_in_shield_list then--屏蔽掉
  79. return
  80. end
  81. for k,v in pairs(self.model.limit_way_list) do
  82. if v == ChatModel.LIMIY_WAY.BABY then-- and vo.channel == ChatModel.CHANNEL_CSCITY then
  83. local x_s,x_end = string.find(vo.msg,"@showbaby@")
  84. if x_end and x_end > 0 then
  85. return
  86. end
  87. end
  88. if v == ChatModel.LIMIY_WAY.CHAT then--then--and vo.channel == ChatModel.CHANNEL_CSCITY then
  89. local showbaby_s,showbaby_end = string.find(vo.msg,"@showbaby@")
  90. local team_s,team_end = string.find(vo.msg,"@team@")
  91. if not showbaby_s and not team_s then
  92. return
  93. end
  94. end
  95. if v == ChatModel.LIMIY_WAY.RECRUIT then--and vo.channel == ChatModel.CHANNEL_CSCITY then
  96. local team_s,team_end = string.find(vo.msg,"@team@")
  97. -- print("============>>> YiRan:ChatController [start:95]team_end:", team_end,"team_s:",team_s)
  98. if team_end and team_end > 0 then
  99. return
  100. end
  101. end
  102. end
  103. if vo.channel == ChatModel.CHANNEL_BARRAGE then--弹幕不走聊天框
  104. SpiritWarModel:getInstance():TryAddDanMu(vo)
  105. DiamondFightModel:getInstance():TryAddDanMu(vo)
  106. else
  107. if vo.channel == ChatModel.CHANNEL_GUILDTV then--如果是跑马频道的消息 要先做个拼接
  108. vo.guild_txt = vo.name..""..vo.msg
  109. vo.length = CalStringTrueLength(vo.guild_txt) + 0.5--算出字符长度(固定有个0.5占位的中文冒号,应该当中文字符)
  110. --以下加入弹幕中
  111. if GuildTVModel:GetInstance().can_fire_TV_barrage then--打开了弹幕界面才能开始发弹幕
  112. local data = {
  113. name = vo.name,
  114. id = vo.role_id,
  115. time = vo.time,
  116. }
  117. data.content = vo.msg
  118. GuildTVModel:GetInstance():AddGuildTVBarrageMessage(data)
  119. end
  120. end
  121. vo.iType = ChatModel.MSG_TYPE.TEXT --信息的种类是消息非语音
  122. self.model:AddMsg(vo) --
  123. self.model:Fire(ChatModel.CHANGE_CHANNEL_SEND_INTERVAL, vo)
  124. self.model:Fire(ChatModel.UPDATE_SEND_TIME)
  125. self.model:AddMainRoleChatContent(vo.msg, vo.player_id)
  126. end
  127. end
  128. --通用文字私聊
  129. function ChatController:on11003()
  130. --[[
  131. channel:int8 //
  132. role_id:int64 // id
  133. figure:rec_figure //
  134. auto_id:int32 // id
  135. receive_id:int32 // id
  136. voice_text:string //
  137. voice_msg_time:int16 // ()
  138. ]]
  139. local scmd = {}
  140. local channel = self:ReadFmt("c")
  141. local ser_id = UserMsgAdapter.ReadFmt("h")
  142. local ser_num = UserMsgAdapter.ReadFmt("h")
  143. local ser_name = UserMsgAdapter.ReadFmt("s")
  144. -- if role_id == RoleManager:getInstance():GetMainRoleVo().role_id then
  145. -- return
  146. -- end
  147. scmd.player_list = {}
  148. local figure = {}
  149. local alength = self:ReadFmt("h")
  150. for i = 1, alength do
  151. local data = {player_id = self:ReadFmt("l")}
  152. FigureProtoVo.ReadFmt(data)
  153. table.insert(scmd.player_list, data)
  154. end
  155. local data_ver, voice_id, receive_id, voice_text, voice_msg_time, send_time = self:ReadFmt("lllshi")
  156. local lv_rank, combat_rank = self:ReadFmt("cc")
  157. local mainRoleVo = RoleManager:getInstance():GetMainRoleVo()
  158. scmd.iType = ChatModel.MSG_TYPE.VOICE
  159. scmd.voice_id = voice_id
  160. scmd.length = voice_msg_time
  161. scmd.channel = channel
  162. scmd.ser_id = ser_id
  163. scmd.ser_name = ser_name
  164. scmd.player_id = scmd.player_list[1].player_id
  165. scmd.msg = voice_text or ""
  166. scmd.args = ""
  167. scmd.result = 0
  168. scmd.time = send_time
  169. scmd.data_ver = data_ver
  170. scmd.ser_num = ser_num
  171. scmd.lv_rank = lv_rank
  172. scmd.combat_rank = combat_rank
  173. if receive_id == 0 then
  174. setmetatable(scmd, {__index = scmd.player_list[1]})
  175. end
  176. local engine_version = tonumber(AppConst.EnglineVer)
  177. if engine_version < scmd.data_ver and scmd.data_ver < 34 then
  178. return
  179. else
  180. ChatVoiceManager:getInstance():SetVoiceVersion(scmd.voice_id, scmd.data_ver)
  181. end
  182. local is_in_shield_list = SocialityModel:getInstance():IsRelaviveType(scmd.player_id,Config.ConfigSocial.RelativeType.black)
  183. if is_in_shield_list then--黑名单屏蔽掉
  184. return
  185. end
  186. local catch = not self.model:AddMsg(scmd)
  187. self.model:Fire(ChatModel.CHANGE_CHANNEL_SEND_INTERVAL, scmd)
  188. self.model:Fire(ChatModel.UPDATE_SEND_TIME)
  189. self.model:AddMainRoleChatContent(scmd.msg, scmd.player_id)
  190. if catch then return end
  191. local subType = SettingModel.C2T[channel]
  192. local autoPlay = (subType == nil) or (SettingModel:getInstance():GetSettingInfo(SettingModel.TYPE.VOICE, subType) == 1)
  193. -- local key = GameSettingManager.blockChannel[channel]
  194. -- local has_block = GameSettingManager:getInstance():GetBlockProperty(key) -- 检查语音自动播放屏蔽
  195. local has_block = (lua_settingM:GetBlockProperty("chatVoice") == true) -- 检查语音自动播放屏蔽
  196. if autoPlay and not has_block then
  197. if SettingModel:getInstance():GetSettingInfo(SettingModel.TYPE.VOICE, SettingModel.SUBTYPE.AUTOPLAY) == 1 then
  198. local wifiState = Application.internetReachability == UnityEngine.NetworkReachability.IntToEnum(2)
  199. if wifiState then
  200. if not ChatVoiceManager:getInstance():GetVoice(scmd.voice_id) then
  201. self.model:Fire(ChatModel.REQUEST_CCMD_EVENT, 11004, scmd.voice_id, scmd.player_id, scmd.time, "")
  202. else
  203. ChatVoiceManager:getInstance():PlayVoice(scmd.voice_id)
  204. end
  205. end
  206. else
  207. if not ChatVoiceManager:getInstance():GetVoice(scmd.voice_id) then
  208. self.model:Fire(ChatModel.REQUEST_CCMD_EVENT, 11004, scmd.voice_id, scmd.player_id, scmd.time, "")
  209. else
  210. ChatVoiceManager:getInstance():PlayVoice(scmd.voice_id)
  211. end
  212. end
  213. end
  214. -- self.model:AddMsg(scmd)
  215. --print("channel, role_id, voice_msg_time, math.floor(tk_time), ticket =" , channel, role_id, math.floor(voice_msg_time), voice_text, voice_id)
  216. end
  217. --发送语音和语音文字信息
  218. function ChatController:on11004()
  219. --[[
  220. auto_id:int32 // id
  221. data_send:byte32 //
  222. ]]
  223. local erroCode = self:ReadFmt("i")
  224. local voice_id = self:ReadFmt("l")
  225. local voice_data = self:ReadFmt("B")
  226. if erroCode ~= 1 then
  227. ErrorCodeShow(erroCode)
  228. return
  229. end
  230. ChatVoiceManager:getInstance():AddVoiceData(voice_id, voice_data)
  231. ChatVoiceManager:getInstance():PushPlay(voice_id)
  232. end
  233. function ChatController:on11005()
  234. local scmd = SCMD11005.New(true)
  235. if scmd.error_code ~= 1 then
  236. ErrorCodeShow(scmd.error_code)
  237. end
  238. end
  239. --缓存
  240. function ChatController:on11010()
  241. local vo = SCMD11010.New(true)
  242. if vo and vo.cache_list and vo.cache_list[1] then
  243. self.model.all_chat_list[vo.cache_list[1].channel] = nil
  244. end
  245. if vo and vo.cache_list and #vo.cache_list > 0 then --在这防止多次添加
  246. if vo.cache_list[1].channel == 1 then -- 世界频道的话需要插入缓存的假数据
  247. local list = self.model:GetAiMsgList() --插入模拟对话的
  248. if list then
  249. -- print("============>>> YiRan:ChatController [start:255] #vo.cache_list[1]:",#vo.cache_list,"#lis:t",#list)
  250. for k,v in pairs(list) do
  251. table.insert(vo.cache_list,v)
  252. end
  253. --print("============>>> YiRan:ChatController [start:255] #vo.cache_list[1]:",#vo.cache_list,"#lis:t",#list)
  254. end
  255. end
  256. local function sort_func(a, b)
  257. return a.time > b.time
  258. end
  259. table.sort( vo.cache_list, sort_func )
  260. end
  261. for i = 1, #vo.cache_list do
  262. if vo.cache_list[i].result ~= 2 then
  263. ------陌生人离线私聊的特殊处理
  264. if vo.cache_list[i].channel == 6 then
  265. --如果是私聊并且对方不在黑名单中不在最近联系人列表中时候,先把他加到最近联系人列表
  266. if vo.cache_list[i].player_list[1].player_id ~= RoleManager.Instance.mainRoleInfo.role_id and
  267. not SocialityModel:getInstance():IsRelaviveType(vo.cache_list[i].player_list[1].player_id,Config.ConfigSocial.RelativeType.recent) and
  268. not SocialityModel:getInstance():IsRelaviveType(vo.cache_list[i].player_list[1].player_id,Config.ConfigSocial.RelativeType.black) then
  269. SocialityModel:getInstance():Fire(SocialityModel.REQUEST_CCMD_EVENT,14020,vo.cache_list[i].player_list[1].player_id)
  270. end
  271. self.model:SetPriateChatInfo(vo.cache_list[i])--存储私聊对象的消息
  272. end
  273. ------
  274. vo.cache_list[i].iType = ChatModel.MSG_TYPE.TEXT
  275. self.model:DealWithCacheMsg(vo.cache_list[i])
  276. end
  277. end
  278. --添加进聊天框的顺序要反过来
  279. if self.cache_msg_list == nil then
  280. self.cache_msg_list = {}
  281. end
  282. for i = #vo.cache_list, 1, -1 do
  283. if vo.cache_list[i].result ~= 2 then
  284. -- self.model:AddMsg(vo.cache_list[i])
  285. local is_in_shield_list = SocialityModel:getInstance():IsRelaviveType(vo.cache_list[i].player_list[1].player_id,Config.ConfigSocial.RelativeType.black)
  286. if not is_in_shield_list then--屏蔽的不需要缓存
  287. self.model:AddMsg(vo.cache_list[i])
  288. end
  289. end
  290. end
  291. self.model.require_11010_times = self.model.require_11010_times - 1
  292. if self.model.require_11010_times <= 0 then
  293. self.model:Fire(ChatModel.INIT_FIRST_GAME_CHAT_DATA)
  294. end
  295. end
  296. function ChatController:on11011()
  297. local vo = SCMD11011.New(true)
  298. self.model:SetCrossChatTime(vo.count)
  299. end
  300. --更新通知
  301. function ChatController:on11091( )
  302. local scmd = SCMD11091.New(true)
  303. self.model:SetClientUpdateInfo(scmd)
  304. local tb = {type = Config.ConfigMainIcon.TipType.client_update}
  305. MsgManager:getInstance():Add(tb)
  306. end
  307. function ChatController:on11022()
  308. local vo = SCMD11022.New(true)
  309. end
  310. --私聊的多加了一个figure,私聊会发送到这里
  311. function ChatController:on11002(vo)
  312. local vo = SCMD11002.New(true)
  313. local is_in_shield_list = SocialityModel:getInstance():IsRelaviveType(vo.player_list[1].player_id,Config.ConfigSocial.RelativeType.black)
  314. if is_in_shield_list then--屏蔽掉
  315. return
  316. end
  317. --不在最近联系人列表中人发来消息时加入最近联系人列表
  318. if vo.player_list[1].player_id ~= RoleManager.Instance.mainRoleInfo.role_id and
  319. not SocialityModel:getInstance():IsRelaviveType(vo.player_list[1].player_id,Config.ConfigSocial.RelativeType.recent) then
  320. SocialityModel:getInstance():Fire(SocialityModel.REQUEST_CCMD_EVENT,14020,vo.player_list[1].player_id)
  321. end
  322. vo.iType = ChatModel.MSG_TYPE.TEXT
  323. self.model:AddMsg(vo)
  324. self.model:Fire(ChatModel.CHANGE_CHANNEL_SEND_INTERVAL, vo)
  325. self.model:Fire(ChatModel.UPDATE_SEND_TIME)
  326. self.model:AddMainRoleChatContent(vo.msg, vo.player_id)
  327. local player_id = vo.player_list[1].player_id --取出私聊对象的id
  328. if player_id ~= RoleManager.Instance.mainRoleInfo.role_id then
  329. --收到私聊消息后更新和该好友的最后私聊时间
  330. SocialityModel:getInstance():UpdateLastChatTime(player_id,vo.time)
  331. self.model:SetChatInfo(true,vo)
  332. self.model:SetPriateChatInfo(vo)--存储私聊对象的消息
  333. SocialityModel:getInstance():Fire(SocialityModel.REFRESH_SUB_BTN_RED)--刷新subBtn红点
  334. GlobalEventSystem:Fire(EventName.REFRESH_SOCIAL_RED_DOT)--更新外部红点
  335. end
  336. end
  337. --½ÓÊÕϵͳÐÅÏ¢
  338. function ChatController:on11060()
  339. local scmd = SCMD11060.New(true)
  340. if scmd.type == 2 then
  341. if EmpowerModel:GetInstance():GetIsShowingGameView() and not EmpowerModel:GetInstance():GetIsShowingShopView() then
  342. return
  343. end
  344. if GoodsModel:getInstance():CheckCanFlyGood() then--检查飞道具图标的条件
  345. MainUIModel:getInstance():AddFloatInfo(scmd.goods_list)
  346. if SceneManager:getInstance():IsExpDun() then--如果是经验副本并且是经验值道具
  347. local goods_list = {}
  348. for i,v in ipairs(scmd.goods_list) do
  349. if v.goods_type_id == 100007 then
  350. goods_list[#goods_list + 1] = v.goods_type_id
  351. end
  352. end
  353. if #goods_list > 0 then
  354. MainUIModel:getInstance():PlayGoodsFlyList(goods_list)
  355. end
  356. end
  357. end
  358. end
  359. local function show(str)
  360. if scmd.type == 1 then
  361. if not GiftModel:getInstance():getIsOpenView() then--and not TreasureHuntModel:getInstance().bool_hunting
  362. -- and not CustomActivityModel:getInstance():getIsThrowEgg() then--礼包界面|寻宝过程|砸蛋过程中不显示提示
  363. -- Message.show(str)
  364. end
  365. elseif scmd.type == 2 then
  366. ChatModel:getInstance():AddInfoToChatView(str, ChatModel.CHANNEL_SYSTEM, self.model:GetGoodsTipNum() or 0)
  367. elseif scmd.type == 3 then
  368. -- Message.show(str)
  369. ChatModel:getInstance():AddInfoToChatView(str, ChatModel.CHANNEL_SYSTEM, self.model:GetGoodsTipNum() or 0)
  370. end
  371. end
  372. local gvo = nil
  373. for i, v in ipairs(scmd.goods_list) do
  374. gvo = GoodsModel:getInstance():GetGoodsBasicByTypeId(v.goods_type_id)
  375. if gvo then
  376. local name = gvo.goods_name
  377. if gvo.type == 11 and (gvo.subtype == 10 or gvo.subtype == 11) then
  378. local type_id, _name, icon = EquipModel:getInstance():GetIdentifyGoodsNameAndIcon(gvo.type_id, RoleManager.Instance.mainRoleInfo.career, gvo.color)
  379. name = _name
  380. end
  381. -- str = "获得 <color="..WordManager.GetGoodsColor(gvo.color) .. ">" .. name .. "x" .. v.num .. "</color>"
  382. local str = "获得 <color="..WordManager.GetGoodsColor(gvo.color) .. ">" .. name .. "x" .. v.num .. "</color>" --改成用传闻面板特殊的颜色
  383. show(str)
  384. -- Message.show(str)
  385. -- ChatModel:getInstance():AddInfoToChatView(str,ChatModel.CHANNEL_SYSTEM,1)
  386. end
  387. end
  388. -- GoodsModel:getInstance():Fire(GoodsModel.GET_A_GOODS)
  389. end
  390. --获得物品显示信息在右下角提示框内
  391. function ChatController:on11061()
  392. local scmd = SCMD11061.New(true)
  393. local gvo = nil
  394. for i, v in ipairs(scmd.goods_list) do
  395. -- local typeId = v.typeId
  396. -- if v.style ~= 0 then
  397. -- typeId = GoodsModel:getInstance():GetMappingTypeId(v.style)
  398. -- end
  399. local typeId, lock = GoodsModel:getInstance():GetMappingTypeId(tonumber(v.style), tonumber(v.typeId))
  400. gvo = GoodsModel:getInstance():GetGoodsBasicByTypeId(typeId)
  401. if gvo then
  402. local name = gvo.goods_name
  403. if gvo.type == 11 and (gvo.subtype == 10 or gvo.subtype == 11) then
  404. local type_id, _name, icon = EquipModel:getInstance():GetIdentifyGoodsNameAndIcon(gvo.type_id, RoleManager.Instance.mainRoleInfo.career, gvo.color)
  405. name = _name
  406. end
  407. local str = ""
  408. if v.count > 1 then
  409. str = "获得 <color='#"..WordManager.GetGoodsColor(gvo.color) .. "'>" .. name .. "x" .. v.count .. "</color>"
  410. else
  411. str = "获得 <color='#"..WordManager.GetGoodsColor(gvo.color) .. "'>" .. name .. "</color>"
  412. end
  413. Message.show(str)
  414. end
  415. end
  416. -- GoodsModel:getInstance():Fire(GoodsModel.GET_A_GOODS)
  417. end
  418. --获得物品显示信息在右下角提示框内
  419. function ChatController:on11016()
  420. local vo = SCMD11016.New(true)
  421. if vo then
  422. --社团申请列表状态
  423. if vo.module_id == 400 and vo.type == ChatModel.RedPointType.GUILD_APPLY_LIST then
  424. -- vo.num 在社团类型中对应【申请的职位】,0代表入团,其他代表职位
  425. GuildModel:getInstance():SetApplyRedPointState(vo.num)
  426. -- GuildModel:getInstance():CheckGuildRedDot(Config.ConfigGuild.TabId.List, true)
  427. -- GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 400, GuildModel:getInstance():CheckGuildRedDot())
  428. -- elseif vo.module_id == 400 and vo.type == 2 then
  429. -- GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 400, true)
  430. elseif vo.module_id == 339 and vo.type == 1 then
  431. -- local tb = {}
  432. -- tb.type = Config.ConfigMainIcon.TipType.guild_redpacket
  433. -- tb.zoom = true
  434. -- MsgManager:getInstance():Add(tb)
  435. elseif vo.module_id == 223 and vo.type == 1 then --鲜花
  436. local tb = {}
  437. tb.type = Config.ConfigMainIcon.TipType.flower
  438. MsgManager:getInstance():Add(tb)
  439. GlobalEventSystem:Fire(EventName.REFRESH_SOCIAL_RED_DOT)
  440. elseif vo.module_id == 441 then --激活图鉴
  441. GlobalEventSystem:Fire(EventName.SET_ACTIVE_PIC, vo.type, vo.num)
  442. end
  443. GlobalEventSystem:Fire(EventName.BROADCAST_RED_POINT_STATE, vo)
  444. end
  445. end
  446. --聊天频道的错误码消息
  447. function ChatController:on11017()
  448. local vo = SCMD11017.New(true)
  449. --type 1只飘字 2只聊天框 3飘字加聊天框
  450. -- PrintTable(vo)
  451. local str = self.model:GetErrorCode(vo.error_code, vo.error_code_args)
  452. if vo.type == 1 then
  453. if vo.error_code == 1500098 then --返回礼包模块去处理
  454. GiftModel:getInstance():handleGiftShowAll(vo.error_code_args)
  455. else
  456. Message.show(str)
  457. end
  458. elseif vo.type == 2 then
  459. if vo.error_code == 6100035 then
  460. if SceneManager.Instance:IsOutdoorScene() then
  461. local scene_id = SceneManager.Instance:GetSceneId()
  462. local birth_x, birth_y = SceneManager.Instance:GetSceneBirthPos()
  463. local findVo = {type = FindVo.SCENE, sceneId = scene_id, id = 0, x = math.ceil(birth_x / SceneObj.LogicRealRatio.x), y = math.ceil(birth_y / SceneObj.LogicRealRatio.y)}
  464. local scene_name = SceneManager.Instance:GetSceneName()
  465. local content = string.format("<a@scene2@%s@%s@%s></a>", findVo.sceneId, findVo.x, findVo.y)
  466. str = str .. " " .. content
  467. end
  468. end
  469. self.model:AddInfoToChatView(str, ChatModel.CHANNEL_TEAM)
  470. elseif vo.type == 3 then
  471. Message.show(str)
  472. self.model:AddInfoToChatView(str, ChatModel.CHANNEL_TEAM)
  473. end
  474. end
  475. function ChatController:on11014()
  476. local vo = SCMD11014.New(true)
  477. if vo then
  478. Message.show("发送频率过快,请销后再试...", "fault")
  479. end
  480. end
  481. --广播语音文字
  482. function ChatController:on11013()
  483. local scmd = SCMD11013.New(true)
  484. self.model:UpdateRegText(scmd)
  485. if self.model.curr_channel == scmd.channel then
  486. self.model:Fire(ChatModel.BROADCAST_VOICE_TEXT, scmd)
  487. end
  488. end
  489. function ChatController:on11020()
  490. local scmd = SCMD11020.New(true)
  491. Message.show(scmd.content)
  492. end
  493. function ChatController:on11021()
  494. local scmd = SCMD11021.New(true)
  495. self.model:AddGmHorn(scmd)
  496. end
  497. function ChatController:on11046()
  498. local scmd = SCMD11046.New(true)
  499. for k, v in pairs(scmd.list) do
  500. if RoleManager.Instance.mainRoleInfo.role_id ~= v.role_id then
  501. for channel, _ in pairs(self.model.all_chat_list) do
  502. self.model:DelMsgInChannelById(channel, v.role_id)
  503. end
  504. self.model:Fire(ChatModel.DEL_CHAT_ITEM, v.role_id)
  505. end
  506. end
  507. --更新界面
  508. self.model:Fire(ChatModel.REFRESH_VIEW)
  509. self.model:Fire(ChatModel.SHOW_TAB_RED_POINT, self.model.all_chat_list_count)
  510. SocialityModel:getInstance():Fire(SocialityModel.UPDATE_SOCIALITY_VIEW)
  511. end
  512. --通用播放特效
  513. function ChatController:on11063()
  514. local scmd = SCMD11063.New(true)
  515. local tb = {}
  516. tb.effect = scmd.effect
  517. SocialityModel:getInstance():PlayFlowerEffect(tb)
  518. end
  519. --通用怪物AI警戒传闻
  520. function ChatController:on11064()
  521. local scmd = SCMD11064.New(true)
  522. local config = Config.Languageextra
  523. local key = scmd.module_id .. "@" .. scmd.id
  524. if config[key] and config[key].content then
  525. local str = ChuanWenManager:getInstance():FormatColorTag2(config[key].content, true)
  526. local data =
  527. {
  528. head_type = 1000,
  529. desc = str,
  530. head_name = scmd.name or "",
  531. hide_time = 8,
  532. dalay_time = 1,
  533. is_task_type = true,
  534. }
  535. GlobalEventSystem:Fire(EventName.SHOW_COM_DIALOGUE_SHOW_VIEW,data)
  536. end
  537. end
  538. function ChatController:on11065( )--屏蔽列表
  539. local scmd = SCMD11065.New(true)
  540. for k,v in pairs(scmd.figure_list) do
  541. v.role_name = v.name
  542. v.vip = v.vip_flag
  543. v.lv = v.level
  544. end
  545. SocialityModel:getInstance():SetRelativeInfo(Config.ConfigSocial.RelativeType.black,scmd.figure_list)
  546. -- if not self.model.request_cache then--检测聊天缓存
  547. -- self.model.request_cache = true
  548. -- if RoleManager.Instance.mainRoleInfo.guild_id > 0 then
  549. -- self.model:Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_GUILD)
  550. -- end
  551. -- self.model:Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_WORLD)
  552. -- self.model:Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_CECRET)
  553. -- end
  554. end
  555. function ChatController:on11067( )--屏蔽列表
  556. local scmd = SCMD11067.New(true)
  557. SocialityModel:getInstance():Fire(SocialityModel.BROADCAST_MIDDLE_MESSAGE, scmd.module_id, scmd.id)
  558. end
  559. function ChatController:on11066( )--屏蔽操作
  560. local scmd = SCMD11066.New(true)
  561. if scmd.errcode == 1 then
  562. Message.show("操作成功", "success")
  563. scmd.role_name = scmd.name
  564. scmd.vip = scmd.vip_flag
  565. scmd.lv = scmd.level
  566. SocialityModel:getInstance():UpdateShieldList(scmd.type,scmd)
  567. SocialityModel:getInstance():Fire(SocialityModel.REQUEST_SOCIAL_LIST)
  568. else
  569. ErrorCodeShow(scmd.errcode)
  570. end
  571. end
  572. --########### 模拟聊天缓存 ##############
  573. --protocol=11023
  574. --{
  575. -- s2c{
  576. -- cache_list:array{
  577. -- name:string
  578. -- sex:int8
  579. -- vip:int8
  580. -- picture:int32
  581. -- msg:string // 数据
  582. -- time:int32 // 服务器时间戳
  583. -- }
  584. -- }
  585. --}
  586. function ChatController:on11023( )--
  587. local scmd = SCMD11023.New(true)
  588. -- if scmd.errcode == 1 then
  589. -- print("=============>>> YiRan:ChatController [start:537] SCMD11023------------------------------------------")
  590. -- PrintTable(scmd)
  591. -- print("=============>>> YiRan:ChatController [end] ------------------------------------------")
  592. self.model:SetVo11023(scmd)
  593. -- else
  594. -- ErrorCodeShow(scmd.errcode)
  595. ----end
  596. end
  597. function ChatController:InitEvent()
  598. local onChangeAccount = function ()
  599. self.model:ClearGongGaoTimer()
  600. self:StopLearnHorn()
  601. self.model:Fire(ChatModel.CLEAR_DATA)--清除主聊天界面的item
  602. self.model:InitLoginTime()
  603. end
  604. GlobalEventSystem:Bind(EventName.CHANGE_ACCOUNT, onChangeAccount)
  605. GlobalEventSystem:Bind(EventName.CHANGE_ROLE, onChangeAccount)
  606. local function onChangeLevel( )
  607. local role_lv = RoleManager.Instance:GetMainRoleLevel2()
  608. --if self.need_reset_lv_list[role_lv] then
  609. -- self:StarPlayTeachingHorn()
  610. --end
  611. end
  612. RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onChangeLevel)
  613. --切换账号
  614. local gameStartHandler = function ()
  615. self.model:Fire(ChatModel.CLEAR_DATA)--清除主聊天界面的item
  616. if self.ChatView then
  617. self.ChatView:Close()
  618. end
  619. self.model:Clear()
  620. self.cache_msg_list = {}
  621. -- lua_settingM:LoadChatVoiceSetting()
  622. self:SendFmtToGame(11050)--请求11050
  623. self:SendFmtToGame(11065)--请求屏蔽列表
  624. --self:StarPlayTeachingHorn()
  625. self.model:InitLoginTime()
  626. end
  627. GlobalEventSystem:Bind(EventName.GAME_START, gameStartHandler)
  628. local function onSendMsgHandler(channel, content, target_id, args, is_mySelf_send)--is_mySelf_send是否是玩家自己发的如果是就是1
  629. -- print('Cat:ChatController.lua[484] channel, content, target_id, args', channel, content, target_id, args)
  630. is_mySelf_send = is_mySelf_send or ChatModel.CHAT_COMMON_TYPE.COMMON--默认发0告诉服务端是玩家正常发言
  631. self.model:Fire(ChatModel.REQUEST_CCMD_EVENT, 11001, channel, content, target_id, args, is_mySelf_send)
  632. end
  633. self.model:Bind(ChatModel.SEND_MSG, onSendMsgHandler)
  634. local function onShowGonggaoHandler(info)
  635. if info then
  636. local vo = {channel = ChatModel.CHANNEL_SYSTEM, time = Status.NowTime, msg = info.content}
  637. vo.iType = ChatModel.MSG_TYPE.TEXT
  638. self.model:AddMsg(vo)
  639. end
  640. end
  641. GlobalEventSystem:Bind(EventName.SHOW_GONGGAO, onShowGonggaoHandler)
  642. local function onShowChuanwenHandler(content, chuanwen_cfg, scmd)
  643. if chuanwen_cfg.subtype ~= 0 and content then
  644. -- local tmpChannel = Config.ConfigChat.channel_level[chuanwen_cfg.subtype].channel
  645. -- local vo = {channel = ChatModel.CHANNEL_SYSTEM,time = Status.NowTime,msg = content}
  646. -- channel = tmpChannel
  647. -- local vo = {channel=chuanwen_cfg.subtype, time=Status.NowTime, msg=content,showtype=ChatModel.CHANNEL_SYSTEM, tip=chuanwen_cfg.tip}
  648. -- self.model:AddMsg(vo)
  649. scmd.channel = chuanwen_cfg.subtype
  650. -- scmd.time = Status.NowTime
  651. scmd.time = TimeUtil:getServerTime()
  652. scmd.msg = content
  653. if not scmd.type or scmd.type == 11015 then
  654. scmd.showtype = ChatModel.CHANNEL_SYSTEM
  655. end
  656. -- scmd.tip = chuanwen_cfg.tip -- 这会增添了自己的tip
  657. scmd.iType = ChatModel.MSG_TYPE.TEXT
  658. self.model:AddMsg(scmd)
  659. end
  660. end
  661. GlobalEventSystem:Bind(EventName.SHOW_CHUANWEN, onShowChuanwenHandler)
  662. --通用聊天
  663. local function onRequestHandler(...)
  664. local args_list = {...}
  665. if args_list[1] == 11001 then
  666. local channel = args_list[2]
  667. local receiveId = args_list[4] or 0
  668. local data = args_list[3]
  669. local args = args_list[5] or ""
  670. local tk_time = Status.NowTime
  671. local ticket = "ticket"
  672. local is_mySelf_send = args_list[6] or ChatModel.CHAT_COMMON_TYPE.COMMON
  673. self:SendFmtToGame(11001, "clssisc", channel, receiveId, data, args, math.floor(tk_time), ticket, is_mySelf_send)
  674. print("发送聊天:", channel, receiveId, data, args, math.floor(tk_time), ticket, is_mySelf_send)
  675. elseif args_list[1] == 11003 then
  676. --[[
  677. channel:int8 //
  678. receive_id:int64 // id
  679. voice_msg_time:int32 // ()
  680. tk_time:int32 //
  681. ticket:string //
  682. data_send:byte32 //
  683. voice_text:string //
  684. auto_id:int32 // id
  685. is_end:int8 // 12CMD11012返回1后继续发送语音剩余部分
  686. ]]
  687. local channel = args_list[2]
  688. local receive_id = args_list[3] or 0
  689. local voice_msg_time = args_list[4]
  690. local tk_time = Status.NowTime
  691. local ticket = "ticket"
  692. local data_send = args_list[5]
  693. local voice_text = args_list[6] or ""
  694. local auto_id = args_list[7]
  695. local is_end = 0
  696. local voiceLength = 0
  697. for i = 0, data_send.Length - 1 do
  698. if i == data_send.Length - 1 then is_end = 1 end
  699. UserMsgAdapter.WriteBegin(11003)
  700. UserMsgAdapter.WriteFMT("cliis", channel, receive_id, math.floor(voice_msg_time), math.floor(tk_time), ticket)
  701. UserMsgAdapter.WriteFMT("B", data_send[i])
  702. UserMsgAdapter.WriteFMT("slc", voice_text, auto_id, is_end)
  703. UserMsgAdapter.SendToGame()
  704. voiceLength = voiceLength + data_send[i].Length
  705. end
  706. Debugger.Log("Voice Data Size is "..voiceLength)
  707. --print("channel, receive_id, voice_msg_time, math.floor(tk_time), ticket =" , channel, receive_id, math.floor(voice_msg_time), math.floor(tk_time), ticket, voice_text, auto_id, is_end, data_send.Length)
  708. elseif args_list[1] == 11004 then
  709. --[[
  710. auto_id:int32 // id
  711. player_id:int64 // id
  712. tk_time:int32 // unix时间戳
  713. ticket:string //
  714. ]]
  715. local auto_id = args_list[2]
  716. local player_id = args_list[3]
  717. local voice_msg_time = args_list[4]
  718. local ticket = "ticket"
  719. UserMsgAdapter.WriteBegin(11004)
  720. UserMsgAdapter.WriteFMT("llis", auto_id, player_id, math.floor(voice_msg_time), ticket)
  721. UserMsgAdapter.SendToGame()
  722. --print("auto_id, player_id, voice_msg_time, ticket =" , auto_id, player_id, math.floor(voice_msg_time),ticket)
  723. elseif args_list[1] == 11005 then
  724. self:SendFmtToGame(11005, "clls", args_list[2], args_list[3], args_list[4], args_list[5])
  725. elseif args_list[1] == 11022 then
  726. self:SendFmtToGame(args_list[1], "cls", args_list[2], args_list[3], args_list[4])
  727. elseif args_list[1] == 11011 then
  728. self:SendFmtToGame(args_list[1], "c", args_list[2])
  729. end
  730. end
  731. self.model:Bind(ChatModel.REQUEST_CCMD_EVENT, onRequestHandler)
  732. local function onOpenChatView(channel)
  733. if self.ChatView == nil then
  734. self.ChatView = ChatView.New()
  735. end
  736. if not self.ChatView:HasOpen() then
  737. self.ChatView:Open(channel)
  738. end
  739. end
  740. GlobalEventSystem:Bind(EventName.OPEN_CHAT_VIEW, onOpenChatView)
  741. local function onCloseChatView()
  742. if self.ChatView and self.ChatView:HasOpen() then
  743. self.ChatView:Close()
  744. end
  745. end
  746. GlobalEventSystem:Bind(EventName.CLOSE_CHAT_VIEW, onCloseChatView)
  747. --打开私聊一对一 用于从其他模块进入聊天
  748. local function onOpenCecretChannel(key_id, name)
  749. if self.ChatView == nil then
  750. self.ChatView = ChatView.New()
  751. local index = self.model:GetTabIndexWithChannel(ChatModel.CHANNEL_CECRET)
  752. self.ChatView:Open(index)
  753. end
  754. if not self.ChatView.is_moving and not self.ChatView:HasOpen() then
  755. local index = self.model:GetTabIndexWithChannel(ChatModel.CHANNEL_CECRET)
  756. self.ChatView:Open(index)
  757. end
  758. self.ChatView:OpenCecretChannel(key_id, name)
  759. end
  760. GlobalEventSystem:Bind(EventName.OPEN_CHAT_CECRET_CHANNEL, onOpenCecretChannel)
  761. local function onOpenHornView()
  762. if self.HornView == nil then
  763. self.HornView = HornView.New()
  764. end
  765. if self.HornView:HasOpen() then
  766. self.HornView:Close()
  767. else
  768. self.HornView:Open()
  769. end
  770. end
  771. GlobalEventSystem:Bind(EventName.OPEN_HORN_VIEW, onOpenHornView)
  772. local function onOpenIndividuationView(bar_index, pos_x, pos_y, is_close_after_sendpos, chating_key_id,is_reset_anchor, scale_num)
  773. if self.IndividuationView == nil then
  774. self.IndividuationView = IndividuationView.New()
  775. end
  776. if self.IndividuationView:HasOpen() then
  777. self.IndividuationView:Close()
  778. else
  779. self.IndividuationView:Open(bar_index, pos_x, pos_y, is_close_after_sendpos, chating_key_id, is_reset_anchor, scale_num)
  780. end
  781. end
  782. GlobalEventSystem:Bind(EventName.OPEN_INDIVIDUATION_VIEW, onOpenIndividuationView)
  783. local function onCloseIndividuationView()
  784. if self.IndividuationView and self.IndividuationView:HasOpen() then
  785. self.IndividuationView:Close()
  786. end
  787. end
  788. GlobalEventSystem:Bind(EventName.CLOSE_INDIVIDUATION_VIEW, onCloseIndividuationView)
  789. local function onOpenChatBagView()
  790. if self.ChatBagView == nil then
  791. self.ChatBagView = ChatBagView.New()
  792. end
  793. self.ChatBagView:Open()
  794. -- if self.ChatBagView:HasOpen() then
  795. -- self.ChatBagView:Close()
  796. -- else
  797. -- self.ChatBagView:Open()
  798. -- end
  799. end
  800. GlobalEventSystem:Bind(EventName.OPEN_CHAT_BAG_VIEW, onOpenChatBagView)
  801. local function onCloseChatBagView()
  802. if self.ChatBagView and self.ChatBagView:HasOpen() then
  803. self.ChatBagView:Close()
  804. end
  805. end
  806. GlobalEventSystem:Bind(EventName.CLOSE_CHAT_BAG_VIEW, onCloseChatBagView)
  807. local function onOpenChatCustomTextView(index)
  808. if self.ChatCustomTextView == nil then
  809. self.ChatCustomTextView = ChatCustomTextView.New()
  810. end
  811. if self.ChatCustomTextView:HasOpen() then
  812. self.ChatCustomTextView:Close()
  813. else
  814. self.ChatCustomTextView:Open(index)
  815. end
  816. end
  817. GlobalEventSystem:Bind(EventName.OPEN_CHAT_CUSTOM_TEXT_VIEW, onOpenChatCustomTextView)
  818. -- local function onOpenChannelSettingView()
  819. -- if self.ChannelSettingView == nil then
  820. -- self.ChannelSettingView = ChannelSettingView.New()
  821. -- end
  822. -- if self.ChannelSettingView:HasOpen() then
  823. -- self.ChannelSettingView:Close()
  824. -- else
  825. -- self.ChannelSettingView:Open()
  826. -- end
  827. -- end
  828. -- GlobalEventSystem:Bind(EventName.OPEN_CHANNELSETTING_VIEW, onOpenChannelSettingView)
  829. local function onRequestCacheMsg(channel)
  830. self:SendFmtToGame(11010, "c", channel)
  831. end
  832. self.model:Bind(ChatModel.REQUEST_CACHE_EVENT, onRequestCacheMsg)
  833. local function onChangeChannelSendStartTime(vo)
  834. self.model:ChangeChannelSendStartTime(vo, Status.NowTime)
  835. end
  836. self.model:Bind(ChatModel.CHANGE_CHANNEL_SEND_INTERVAL, onChangeChannelSendStartTime)
  837. -- local function onRequestWorldChatNum()
  838. -- --请求缓存
  839. -- if not self.model.request_cache then
  840. -- self.model.request_cache = true
  841. -- self.model:Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_WORLD)
  842. -- if RoleManager.Instance.mainRoleInfo.guild_id > 0 then
  843. -- self.model:Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_GUILD)
  844. -- end
  845. -- end
  846. -- end
  847. -- GlobalEventSystem:Bind(EventName.GAME_START, onRequestWorldChatNum)
  848. local function onRequestRedPointState(module_id, type)
  849. self:SendFmtToGame(11016, "hh", module_id, type)
  850. end
  851. GlobalEventSystem:Bind(EventName.REQUEST_RED_POINT_STATE, onRequestRedPointState)
  852. --处理屏蔽功能11066协议的发送
  853. local function ON_SEND_PROTOCAL( ... )
  854. local args = {...}
  855. if args[1] == 11065 then
  856. elseif args[1] == 11066 then
  857. self:SendFmtToGame(args[1], "cl", args[2],args[3])
  858. else
  859. self:SendFmtToGame(args[1])
  860. end
  861. end
  862. self.model:Bind(ChatModel.SEND_PROTOCAL, ON_SEND_PROTOCAL)
  863. GlobalEventSystem:Bind(ChatModel.ON_RESULT_OF_SPEECH, function(reg_txt)
  864. reg_txt = LanguageFilter.FilterMsg(reg_txt)
  865. self.model.reg_txt = reg_txt
  866. if not self.model.loading_voice then
  867. if SettingModel:getInstance():GetSettingInfo(SettingModel.TYPE.VOICE, SettingModel.SUBTYPE.TEXTONLY) == 1 then
  868. self.model:Fire(ChatModel.REQUEST_CCMD_EVENT, 11001, self.model.reg_channel, reg_txt, self.model.chating_key_id or 0, "", nil, "")
  869. else
  870. if self.model.sendAlready then
  871. self.model:Fire(ChatModel.REQUEST_CCMD_EVENT, 11005, self.model.reg_channel, self.model.reg_receive_id, self.model.voice_id, reg_txt)
  872. else
  873. self:SendVoice()
  874. end
  875. end
  876. -- local scmd = {auto_id = self.model.voice_id, channel = self.model.reg_channel, voice_text = reg_txt}
  877. -- self.model:UpdateRegText(scmd)
  878. -- self.model:Fire(ChatModel.BROADCAST_VOICE_TEXT, scmd)
  879. end
  880. end)
  881. GlobalEventSystem:Bind(ChatModel.ON_END_OF_SPEECH, function(data)
  882. if self.model.end_speech_data then
  883. if data ~= "" then
  884. Message.show(data)
  885. end
  886. self.model.end_speech_data = nil
  887. else
  888. self.model.end_speech_data = data
  889. end
  890. if not self.model.loading_voice and not self.model.sendAlready then
  891. print("tanar: ChatController [910] Bind ON_END_OF_SPEECH")
  892. self:SendVoice()
  893. end
  894. end)
  895. GlobalEventSystem:Bind(EventName.CHANGE_ACCOUNT, function()
  896. self.model.voice_id = nil
  897. self.model.reg_channel = nil
  898. self.model.loading_voice = nil
  899. self.model.end_speech_data = nil
  900. ChatVoiceManager:getInstance():Reset()
  901. end)
  902. GlobalEventSystem:Bind(EventName.CHANGE_ROLE, function()
  903. self.model.voice_id = nil
  904. self.model.reg_channel = nil
  905. self.model.loading_voice = nil
  906. self.model.end_speech_data = nil
  907. ChatVoiceManager:getInstance():Reset()
  908. end)
  909. local function onGuildChange()
  910. local guild_id = RoleManager.Instance:GetMainRoleVo().guild_id
  911. if not guild_id or guild_id == 0 then
  912. self.model.all_chat_list[ChatModel.CHANNEL_GUILD] = nil
  913. end
  914. end
  915. RoleManager:getInstance():GetMainRoleVo():BindOne("guild_id", onGuildChange)
  916. local function onOpenLockScreenView( )
  917. --进入省电模式关闭聊天界面
  918. if self.ChatView then
  919. self.ChatView:Close()
  920. end
  921. end
  922. GlobalEventSystem:Bind(SceneEventType.SCREEN_BRIGHT_DEL_EVENT, onOpenLockScreenView)
  923. end
  924. function ChatController:SendVoice()
  925. print("tanar: ChatController [949] =========== SendVoice")
  926. print("tanar: [ChatController 950]=> self.model.voice_id: ",self.model.voice_id)
  927. if self.model.voice_id and SettingModel:getInstance():GetSettingInfo(SettingModel.TYPE.VOICE, SettingModel.SUBTYPE.TEXTONLY) == 0 then
  928. ChatVoiceManager:getInstance():AddMainRoleVoicePath(self.model.voice_id, self.model.voice_path)
  929. local sendId = self.model.voice_id
  930. local function onLoadCallback(voice_data, time_len)
  931. print("tanar: [ChatController 956]=> onLoadCallback: ",self.model.reg_channel)
  932. print("tanar: [ChatController 957]=> self.model.voice_id == sendId: ",self.model.voice_id == sendId)
  933. if self.model.voice_id == sendId and self.model.reg_channel then
  934. local channel = self.model.reg_channel
  935. local receive_id = self.model.chating_key_id or 0
  936. local voice_msg_time = math.max(1, math.floor(time_len + 0.5))
  937. local data_send = voice_data
  938. local voice_text
  939. local auto_id = self.model.voice_id
  940. if self.model.reg_txt then
  941. voice_text = self.model.reg_txt
  942. self.model.reg_txt = nil
  943. else
  944. voice_text = ""
  945. self.model.reg_receive_id = receive_id
  946. end
  947. self.model.reg_txt = nil
  948. self.model:Fire(ChatModel.REQUEST_CCMD_EVENT, 11003, channel, receive_id, voice_msg_time, data_send, voice_text, auto_id)
  949. self.model.sendAlready = true
  950. end
  951. end
  952. self.model.loading_voice = true
  953. self.model.sendAlready = nil
  954. ChatVoiceManager:getInstance():LoadMainRoleVoiceData(self.model.voice_id, onLoadCallback)
  955. end
  956. end
  957. function ChatController:StopLearnHorn( )
  958. if self.play_learn_id then
  959. GlobalTimerQuest:CancelQuest(self.play_learn_id)
  960. self.play_learn_id = nil
  961. end
  962. SysInfoCtrl.Instance:HideHornView(true)
  963. end
  964. function ChatController:StarPlayTeachingHorn( )
  965. self.need_reset_lv_list = {} --到特定等级需要刷新
  966. if self.play_learn_id then
  967. GlobalTimerQuest:CancelQuest(self.play_learn_id)
  968. self.play_learn_id = nil
  969. end
  970. local chuanwen_list = {}
  971. local role_lv = RoleManager.Instance:GetMainRoleLevel2()
  972. for _,v in pairs(Config.ConfigChat.teaching) do
  973. if role_lv < v.start_lv then
  974. self.need_reset_lv_list[v.start_lv] = true
  975. end
  976. if role_lv < v.end_lv + 1 then
  977. self.need_reset_lv_list[v.end_lv+1] = true
  978. end
  979. if role_lv >= v.start_lv and role_lv <= v.end_lv then
  980. for _,vo in pairs(v.msg_list) do
  981. table_insert(chuanwen_list,vo)
  982. end
  983. end
  984. end
  985. local index = 1
  986. local chuanwen_len = #chuanwen_list
  987. if chuanwen_len > 0 then
  988. local function onTimer( )
  989. local cfg, scmd = {subtype = ChatModel.CHANNEL_SYSTEM} ,{}
  990. if index > chuanwen_len then
  991. index = 1
  992. end
  993. local msg = chuanwen_list[index].msg or ""
  994. msg = Trim(msg)
  995. index = index + 1
  996. if msg ~= "" then
  997. ChatModel:getInstance():DealWithHornSystemMsg({name = "系统", msg = msg,is_teaching = true}, true,true)
  998. GlobalEventSystem:Fire(EventName.SHOW_CHUANWEN, msg, cfg, scmd)
  999. end
  1000. end
  1001. self.play_learn_id = GlobalTimerQuest:AddPeriodQuest(onTimer,Config.ConfigChat.teachingTime)
  1002. setTimeout(onTimer,5)
  1003. end
  1004. end