ChatModel = ChatModel or BaseClass(BaseModel)
|
|
ChatModel.SELECT_CHAT_VIEW_TARBAR = "SELECT_CHAT_VIEW_TARBAR"
|
|
ChatModel.SELECT_FACE_ITEM = "SELECT_FACE_ITEM"
|
|
ChatModel.SELECT_TEXT_FACE_ITEM = "SELECT_TEXT_FACE_ITEM"
|
|
ChatModel.SELECT_HISTROY_ITEM = "SELECT_HISTROY_ITEM"
|
|
ChatModel.SELECT_GOOD_ITEM = "SELECT_GOOD_ITEM"
|
|
ChatModel.SELECT_PARTNER_ITEM = "SELECT_PARTNER_ITEM"
|
|
ChatModel.SELECT_COORD_ITEM = "SELECT_COORD_ITEM"
|
|
ChatModel.DELETE_CECRET_CHAT_ITEM = "DELETE_CECRET_CHAT_ITEM"
|
|
ChatModel.SELECT_OTHER_PLAYER = "ChatModel.SELECT_OTHER_PLAYER" -- 算中其他玩家item
|
|
ChatModel.SEND_MSG = "ChatModel.SEND_MSG" --发送消息
|
|
ChatModel.ADD_NEW_MSG = "ADD_NEW_MSG"
|
|
ChatModel.SHOW_TAB_RED_POINT = "ChatModel.SHOW_TAB_RED_POINT" -- 显示标签红点
|
|
ChatModel.CHANGE_CHANNEL_SEND_INTERVAL = "ChatModel.CHANGE_CHANNEL_SEND_INTERVAL" -- 改变发送间隔
|
|
ChatModel.UPDATE_SEND_TIME = "UPDATE_SEND_TIME"
|
|
ChatModel.REFRESH_FRIEND = "REFRESH_FRIEND"
|
|
ChatModel.REFRESH_MEMBER = "REFRESH_MEMBER"
|
|
ChatModel.CLEAR_DATA = "CLEAR_DATA"
|
|
ChatModel.SHOW_LINE_TIME = 60 * 30 --说话间隔大于该时间 就要添加横线时间显示项
|
|
ChatModel.PLAY_VOICE = "PLAY_VOICE"--语音播放事件
|
|
ChatModel.UPDATE_INDIVID_VIEW = "ChatModel.UPDATE_INDIVID_VIEW" --表情界面更新
|
|
ChatModel.SEND_MSG_IN_VIEW = "ChatModel.SEND_MSG_IN_VIEW" --通过聊天界面发送内容
|
|
ChatModel.UPDATE_HORNTV_NUM = "ChatModel.UPDATE_HORNTV_NUM" --更新喇叭排队数量
|
|
ChatModel.SHOW_BAG_SELECT_BG = "ChatModel.SHOW_BAG_SELECT_BG" --显示背包选中图片
|
|
ChatModel.REFRESH_VIEW = "ChatModel.REFRESH_VIEW" --刷新界面
|
|
ChatModel.DEL_CHAT_ITEM = "ChatModel.DEL_CHAT_ITEM" --删除聊天
|
|
ChatModel.DEL_NOTICE_CHAT_ITEM = "ChatModel.DEL_NOTICE_CHAT_ITEM" --删除公告聊天
|
|
ChatModel.CROSS_HORN_HAS_CHANGE = "ChatModel.CROSS_HORN_HAS_CHANGE" --跨服喇叭数量变化
|
|
ChatModel.HORN_HAS_CHANGE = "ChatModel.HORN_HAS_CHANGE" --喇叭数量变化
|
|
ChatModel.SAVE_CHAT_HISTORY_INFO = "ChatModel.SAVE_CHAT_HISTORY_INFO" --保存历史输入
|
|
ChatModel.SELECT_HISTORY_TEXT_ITEM = "ChatModel.SELECT_HISTORY_TEXT_ITEM" --点击历史item
|
|
ChatModel.SAVE_MAINUI_CHAT_HISTORY_INFO = "ChatModel.SAVE_MAINUI_CHAT_HISTORY_INFO" --主界面UI聊天记录
|
|
ChatModel.CLICK_POS_BTN = "ChatModel.CLICK_POS_BTN" --点击坐标按钮
|
|
ChatModel.HIDE_MIAN_UI_CHAT_VIEW = "ChatModel.HIDE_MIAN_UI_CHAT_VIEW" --关闭打开聊天主界面的 处理表情包bug
|
|
ChatModel.INIT_FIRST_GAME_CHAT_DATA = "ChatModel.INIT_FIRST_GAME_CHAT_DATA"
|
|
ChatModel.SEND_PROTOCAL = "ChatModel.SEND_PROTOCAL" --发送协议
|
|
ChatModel.CHANGE_HEIGHT = "ChatModel.CHANGE_HEIGHT" --高度计算用
|
|
ChatModel.Update_MAINUI_GUILD_MSG_RED = "ChatModel.Update_MAINUI_GUILD_MSG_RED" -- 更新主界面社团红点
|
|
--ChatModel.MIAN_UI_CHAT_VIEW_LOADED = "ChatModel.MIAN_UI_CHAT_VIEW_LOADED" --左下加载完毕
|
|
|
|
--如果这边键值对改变的话 MainUIModel.VoiceType 这边也要对应调整
|
|
ChatModel.CHANNEL_GENERAL = 99 --综合频道
|
|
ChatModel.CHANNEL_SYSTEM = 10 --系统
|
|
ChatModel.CHANNEL_WORLD = 1 --世界
|
|
ChatModel.CHANNEL_HORN = 2 --喇叭
|
|
ChatModel.CHANNEL_NEAR = 3 --区域
|
|
ChatModel.CHANNEL_GUILD = 4 --社团
|
|
ChatModel.CHANNEL_TEAM = 5 --队伍
|
|
ChatModel.CHANNEL_CECRET = 6 --私聊频道
|
|
ChatModel.CHANNEL_INVITE = 11 --组队(招募)频道(用于发布组队邀请)
|
|
ChatModel.CHANNEL_BARRAGE = 12--弹幕聊天(只针对活动场景的聊天)
|
|
ChatModel.CHANNEL_CROSS = 13 --跨服聊天
|
|
ChatModel.CHANNEL_REPLY = 14 --答题频道
|
|
ChatModel.CHANNEL_3V3_TEAM = 15 --3v3
|
|
ChatModel.CHANNEL_1VN = 16 --1vN频道
|
|
ChatModel.CHANNEL_BEACH = 17 --温泉
|
|
ChatModel.CHANNEL_GUILDTV = 19 --跑马弹幕频道
|
|
ChatModel.CHANNEL_GUARDIAN_THREE = 20 --绝地守卫频道
|
|
ChatModel.CHANNEL_COUNTRY = 21 -- 本国跨服频道
|
|
ChatModel.ALL = 90 -- 显示“世界” “招募” “社团” “队伍”
|
|
|
|
ChatModel.CHANNEL_NONE = 0 --无
|
|
|
|
--把频道放进列表,主界面顺序滑动切换(暂时弃用)
|
|
ChatModel.CHANNEL_MAINUI_SHOW =
|
|
{
|
|
[1] = ChatModel.ALL,
|
|
[2] = ChatModel.CHANNEL_WORLD,
|
|
[3] = ChatModel.CHANNEL_GUILD,
|
|
[4] = ChatModel.CHANNEL_INVITE,
|
|
[5] = ChatModel.CHANNEL_TEAM,
|
|
[6] = ChatModel.CHANNEL_SYSTEM
|
|
-- [7] = ChatModel.CHANNEL_CROSS
|
|
}
|
|
|
|
-- info 里的 chuanwen_type (后端是这样定的)
|
|
-- 1:传闻跑马灯飘(屏幕上方)、2:频道普通消息、
|
|
-- 3:传闻跑马灯中部(屏幕中部)、4:玩法活动横幅
|
|
ChatModel.CHUANWEN_TYPE = {
|
|
UP_CHUANWEN = 1,
|
|
NORMAL = 2,
|
|
MIDDLE_CHUANWEN = 3,
|
|
ACTIVITY_CHUANWEN = 4,
|
|
}
|
|
|
|
--11001--is_mySelf_send
|
|
ChatModel.CHAT_COMMON_TYPE = {
|
|
COMMON = 0,
|
|
SYSTEM = 1,
|
|
}
|
|
|
|
ChatModel.INDIVIDUATION_FACE = 1
|
|
ChatModel.INDIVIDUATION_TEXT = 3
|
|
ChatModel.INDIVIDUATION_ITEM = 5
|
|
ChatModel.INDIVIDUATION_PARTNER = 2
|
|
ChatModel.INDIVIDUATION_POS = 4
|
|
ChatModel.INDIVIDUATION_HISTROY = 6
|
|
|
|
ChatModel.REQUEST_CCMD_EVENT = "ChatModel.REQUEST_CCMD_EVENT"--请求协议
|
|
ChatModel.REQUEST_CACHE_EVENT = "ChatModel.REQUEST_CACHE_EVENT"--请求缓存协议
|
|
ChatModel.ON_RESULT_OF_SPEECH = "ChatModel.ON_RESULT_OF_SPEECH"--语音SDK识别结果返回
|
|
ChatModel.ON_END_OF_SPEECH = "ChatModel.ON_END_OF_SPEECH"--语音SDK录制结果返回
|
|
ChatModel.BROADCAST_VOICE_TEXT = "ChatModel.BROADCAST_VOICE_TEXT"--广播语音文字
|
|
ChatModel.WORLD_CHAT_ITEM_ID = 240202--世界聊天消耗的道具
|
|
ChatModel.STOP_VOICE_PLAY = "ChatModel.STOP_VOICE_PLAY"
|
|
ChatModel.CHANGE_LIMIT_WAY = "ChatModel.CHANGE_LIMIT_WAY" --改变频道屏蔽选项
|
|
ChatModel.ADD_MAINUI_WELCOME_HORN = "ChatModel.ADD_MAINUI_WELCOME_HORN" --主界面喇叭显示用语添加
|
|
|
|
ChatModel.Bubble = 1 --气泡
|
|
ChatModel.Photo = 2 --相框
|
|
|
|
ChatModel.MAX_LEN_LIST =
|
|
{
|
|
[ChatModel.CHANNEL_GENERAL] = 30,
|
|
[ChatModel.CHANNEL_SYSTEM] = 30,
|
|
[ChatModel.CHANNEL_WORLD] = 30,
|
|
[ChatModel.CHANNEL_GUILD] = 30,
|
|
[ChatModel.CHANNEL_TEAM] = 30,
|
|
[ChatModel.CHANNEL_CECRET] = 20,
|
|
[ChatModel.CHANNEL_HORN] = 30,
|
|
[ChatModel.CHANNEL_NEAR] = 30,
|
|
[ChatModel.CHANNEL_INVITE] = 30,
|
|
[ChatModel.CHANNEL_CROSS] = 30,
|
|
[ChatModel.CHANNEL_COUNTRY] = 30,
|
|
[ChatModel.CHANNEL_REPLY] = 30,
|
|
[ChatModel.CHANNEL_3V3_TEAM] = 30,
|
|
[ChatModel.CHANNEL_1VN] = 30,
|
|
[ChatModel.CHANNEL_GUILDTV] = 20,
|
|
[ChatModel.CHANNEL_BEACH] = 20,
|
|
[ChatModel.CHANNEL_GUARDIAN_THREE] = 20,
|
|
}
|
|
|
|
ChatModel.MSG_TYPE = {
|
|
TEXT = 1,
|
|
VOICE = 2,
|
|
}
|
|
|
|
ChatModel.LIMIY_WAY = {
|
|
CHAT = 1,
|
|
BABY = 2,
|
|
RECRUIT = 3 --招募
|
|
}
|
|
ChatModel.LIMIY_WAY_NAME = {
|
|
[1] = "屏蔽聊天",
|
|
[2] = "屏蔽晒娃",
|
|
[3] = "屏蔽招募"
|
|
} --玩家屏蔽频道列表
|
|
|
|
ChatModel.RedPointType = { -- 11016协议的红点类型
|
|
GUILD_APPLY_LIST = 1,
|
|
}
|
|
|
|
function ChatModel:__init()
|
|
ChatModel.Instance = self
|
|
self.tv_state = true
|
|
self.tv_list = {}
|
|
self.selected_chatView_tabbar_item = nil
|
|
self.selected_histroy_item = nil
|
|
self.selected_textface_item = nil
|
|
self.selected_face_item = nil
|
|
self.selected_partner_item = nil
|
|
self.selected_good_item = nil
|
|
self.clicked_item = nil --点击超链接item(包括mainui)
|
|
self.clicked_role_item = nil --点击人物菜单
|
|
self.main_role_chat_list = ChatModel:GetAllMainRoleContent() or {} --缓存玩家聊天记录 --最大20条
|
|
self.send_timer_list = {} --用来缓存所有发送时间间隔Timer
|
|
self.send_start_time_list = {} --用来缓存所有频道的发送时间间隔
|
|
self.request_cache = false -- 是否已经请求缓存信息
|
|
self.curr_channel = 0 --当前频道 -- 这个是玩家选择tab后更新的
|
|
self.chating_key_id = 0 -- 当前密聊玩家的值
|
|
self.pre_bar_index = 0 --上一个tabbar的索引
|
|
self.curr_bar_index = ChatModel.CHANNEL_WORLD -- 当前tabbar的索引 -- 这个curr_bar_index是外边主界面传进来的,这个为主
|
|
self.world_chat_method = 0 -- 世界聊天发言的方式,可能通过次数或者道具 0 次数 1 道具
|
|
self.chat_args_dic = {} --当前聊天内容所需发送的参数列表 [类型,列表[参数]]
|
|
self.chick_hyperlink_mark = false
|
|
self.curr_individuation_bar_index = 1
|
|
self.reg_channel = 0
|
|
self.voice_id = 0
|
|
self.voice_path = 0
|
|
self.cecret_chat_list = {} --密聊列表
|
|
self.all_chat_list = {} -- 用来记录每个频道的数据
|
|
self.all_chat_list_count = {} -- 用来记录每个频道收到的消息的数量,用来显示红点
|
|
self.check_timer_list = {}
|
|
self.delay_timer_list = {}
|
|
self.gonggao_vo = nil
|
|
self.delay_horn_list = {}
|
|
self.say_cache = nil
|
|
self.need_feast_chat = false
|
|
self.chat_bag_view_is_open = false
|
|
self.last_Gg_list = {} --用来记录上一次的公告数据
|
|
self.require_11010_times = 4
|
|
self.limit_way_list = {} --频道屏蔽
|
|
self.chat_priate_info = {}
|
|
self.welcomeList = {} -- 新主界面欢迎喇叭显示文本列表
|
|
self.welcomeListIndex = 1 --显示的index
|
|
self.has_new_guild_red = 0 -- 未读社团消息数量
|
|
end
|
|
|
|
function ChatModel:Clear()
|
|
self.tv_state = true
|
|
self.tv_list = {}
|
|
self.selected_chatView_tabbar_item = nil
|
|
self.selected_histroy_item = nil
|
|
self.selected_textface_item = nil
|
|
self.selected_face_item = nil
|
|
self.selected_partner_item = nil
|
|
self.selected_good_item = nil
|
|
self.clicked_item = nil
|
|
self.clicked_role_item = nil
|
|
|
|
self.main_role_chat_list = ChatModel:GetAllMainRoleContent() or {}
|
|
self.send_timer_list = {}
|
|
self.send_start_time_list = {}
|
|
self.request_cache = false
|
|
self.curr_channel = 0
|
|
self.chating_key_id = 0
|
|
self.pre_bar_index = 0
|
|
self.curr_bar_index = ChatModel.CHANNEL_WORLD--CHANNEL_SYSTEM
|
|
self.world_chat_method = 0
|
|
self.chat_args_dic = {}
|
|
self.chick_hyperlink_mark = false
|
|
self.curr_individuation_bar_index = 1
|
|
self.reg_channel = 0
|
|
self.voice_id = 0
|
|
self.voice_path = 0
|
|
self.reg_txt = nil
|
|
self.loading_voice = nil
|
|
|
|
self.cecret_chat_list = {}
|
|
self.all_chat_list = {}
|
|
self.all_chat_list_count = {}
|
|
self.limit_way_list = {}
|
|
self:ClearGongGaoTimer()
|
|
|
|
self.get_chat = false
|
|
self.chatMessage = nil
|
|
self.chat_priate_info = {}
|
|
end
|
|
|
|
--计算每种频道收到的信息数量
|
|
function ChatModel:CaclulationMsgCount(info)
|
|
if info then
|
|
--不记录自己发的信息
|
|
local main_role_id = RoleManager.Instance:GetMainRoleId()
|
|
|
|
if info.player_id == main_role_id then return end
|
|
|
|
if info.channel == ChatModel.CHANNEL_CECRET then
|
|
local cur_list = self.all_chat_list_count[info.channel]
|
|
|
|
if cur_list == nil then
|
|
cur_list = {}
|
|
end
|
|
|
|
self.all_chat_list_count[info.channel] = cur_list
|
|
|
|
local len = TableSize(info.player_list)
|
|
|
|
if len == 2 then
|
|
local key_id = info.player_list[1].player_id == main_role_id and info.player_list[2].player_id or info.player_list[1].player_id
|
|
|
|
local condition_1 = key_id ~= self.chating_key_id
|
|
if condition_1 then
|
|
if cur_list[key_id] == nil then
|
|
cur_list[key_id] = 0
|
|
end
|
|
cur_list[key_id] = cur_list[key_id] + 1
|
|
|
|
self:Fire(ChatModel.SHOW_TAB_RED_POINT, self.all_chat_list_count)
|
|
end
|
|
end
|
|
elseif info.channel ~= ChatModel.CHANNEL_SYSTEM then
|
|
local channel = info.channel --== ChatModel.CHANNEL_HORN and ChatModel.CHANNEL_WORLD or info.channel
|
|
if self.curr_channel ~= channel then
|
|
if channel == ChatModel.CHANNEL_HORN then
|
|
if self.curr_channel ~= ChatModel.CHANNEL_WORLD then
|
|
if self.all_chat_list_count[ChatModel.CHANNEL_WORLD] == nil then
|
|
self.all_chat_list_count[ChatModel.CHANNEL_WORLD] = 0
|
|
end
|
|
self.all_chat_list_count[ChatModel.CHANNEL_WORLD] = self.all_chat_list_count[ChatModel.CHANNEL_WORLD] + 1
|
|
end
|
|
end
|
|
if self.all_chat_list_count[channel] == nil then
|
|
self.all_chat_list_count[channel] = 0
|
|
end
|
|
self.all_chat_list_count[channel] = self.all_chat_list_count[channel] + 1
|
|
self:Fire(ChatModel.SHOW_TAB_RED_POINT, self.all_chat_list_count)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--获取需要私聊的id
|
|
function ChatModel:GetNeedChatKey()
|
|
local cur_list = self.all_chat_list_count[ChatModel.CHANNEL_CECRET]
|
|
if cur_list ~= nil then
|
|
for k, v in pairs(cur_list) do
|
|
if v > 0 then
|
|
return k
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChatModel:AddMsg(info)
|
|
-- 以下频道发言有次数限制 需要协议获取
|
|
if info.channel == ChatModel.CHANNEL_CROSS then
|
|
self:Fire(ChatModel.REQUEST_CCMD_EVENT, 11011, ChatModel.CHANNEL_CROSS)
|
|
-- elseif info.channel == ChatModel.CHANNEL_COUNTRY then
|
|
-- self:Fire(ChatModel.REQUEST_CCMD_EVENT, 11011, ChatModel.CHANNEL_COUNTRY)
|
|
end
|
|
-- 历史聊天记录
|
|
if info.player_id == RoleManager:getInstance():GetMainRoleVo().role_id then
|
|
if info.channel ~= ChatModel.CHANNEL_INVITE then --非组队邀请信息
|
|
local s, e = string.find(info.msg, "<a@.+></a>")
|
|
local args = false
|
|
local save_str = ""
|
|
if s == 1 then
|
|
args = Split(info.msg, "@")
|
|
end
|
|
if args then
|
|
save_str = string.format("<%s>", GoodsModel:getInstance():getGoodsName(tonumber(args[3])))
|
|
else
|
|
save_str = info.msg
|
|
end
|
|
local count
|
|
local c_list = {}--保存color标签的所有数据
|
|
if save_str then
|
|
p1, p2, color_str, content_str = string.find(save_str, "%<color%=([^%>^/.]-)%>([^%>^/.]-)%<%/color")
|
|
count = 1
|
|
while p1 do
|
|
c_list[count] = {}
|
|
c_list[count].color = color_str
|
|
c_list[count].text = content_str
|
|
c_list[count].start_pos = p1
|
|
p1, p2, color_str, content_str = string.find(save_str, "%<color%=([^%>^/.]-)%>([^%>^/.]-)%<%/color", p1 + 1)
|
|
count = count + 1
|
|
end
|
|
end
|
|
if #c_list > 0 then
|
|
save_str = ""
|
|
for i,v in ipairs(c_list) do
|
|
save_str = save_str..v.text
|
|
end
|
|
end
|
|
local cookie = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, ChatModel.SAVE_CHAT_HISTORY_INFO)
|
|
cookie = cookie or {}
|
|
local has_same_str = false
|
|
for i, v in ipairs(cookie) do
|
|
if v == save_str then
|
|
has_same_str = true
|
|
break
|
|
end
|
|
end
|
|
if not has_same_str then
|
|
table.insert(cookie, 1, save_str)
|
|
for i = Config.ConfigChat.custom_history_num + 1, #cookie do
|
|
table.remove(cookie, Config.ConfigChat.custom_history_num + 1)
|
|
end
|
|
CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, ChatModel.SAVE_CHAT_HISTORY_INFO, cookie)
|
|
end
|
|
end
|
|
end
|
|
|
|
if info and info.channel ~= ChatModel.CHANNEL_NONE then
|
|
if self:MsgNeedFilter(info) then
|
|
return false
|
|
end
|
|
if self:IsPlayerInBlack(info) then
|
|
return false
|
|
end
|
|
if info.channel == ChatModel.CHANNEL_CECRET then
|
|
self:DealWithCerectSystemMsg(info)
|
|
elseif info.channel == ChatModel.CHANNEL_HORN then
|
|
self:DealWithHornSystemMsg(info)
|
|
elseif info.channel == ChatModel.CHANNEL_REPLY then
|
|
elseif info.channel == ChatModel.CHANNEL_1VN then
|
|
|
|
else
|
|
self:DealWithOtherSystemMsg(info)
|
|
end
|
|
|
|
--记录当前世界聊天剩余的次数
|
|
if info.channel == ChatModel.CHANNEL_WORLD then
|
|
info.world_chat_method = self.world_chat_method
|
|
end
|
|
--判断是否是答题频道
|
|
--[[
|
|
if info.channel == ChatModel.CHANNEL_1VN then
|
|
info.channel = ChatModel.CHANNEL_CROSS --消息发到队伍频道里去
|
|
CSOnevNModel:getInstance():SetOnevNChatInfo(info) --设置1vn
|
|
CSOnevNModel:getInstance():Fire(BattleFieldDefine.CSOnevN.Event.UPDATE_CHAT_MSG, info)
|
|
elseif info.channel == ChatModel.CHANNEL_INVITE then
|
|
CSPvPModel.GetInstance():SetMessageEnlist(info)
|
|
EventSystem.Fire(GlobalEventSystem,CSPvPEvent.REFRESH_TALK_DATA,ChatModel.CHANNEL_INVITE,info.msg,info)--3v3
|
|
elseif info.channel == ChatModel.CHANNEL_3V3_TEAM then
|
|
info.channel = ChatModel.CHANNEL_TEAM --消息发到队伍频道里去
|
|
EventSystem.Fire(GlobalEventSystem,CSPvPEvent.REFRESH_TALK_DATA,ChatModel.CHANNEL_3V3_TEAM,info.msg,info)--3v3
|
|
elseif info.channel == ChatModel.CHANNEL_GUILD or info.channel == ChatModel.CHANNEL_WORLD then
|
|
if info.is_pvp_enlist then
|
|
CSPvPModel.GetInstance():SetMessageEnlist(info)
|
|
EventSystem.Fire(GlobalEventSystem,CSPvPEvent.REFRESH_TALK_DATA,ChatModel.CHANNEL_INVITE,info.msg,info)
|
|
end
|
|
end
|
|
]]
|
|
|
|
-- 社团消息需要记录未读的消息数目
|
|
if info.channel == ChatModel.CHANNEL_GUILD and info.player_id then
|
|
local is_old_msg = not (self.login_time_cache and info.time - self.login_time_cache >= 0) -- 刚登陆拿的历史消息不管
|
|
local role_id = RoleManager.Instance:GetMainRoleId()
|
|
local is_self = info.player_id == role_id -- 自己的消息不算
|
|
if not is_old_msg and not is_self then
|
|
self:SetGuildChannelRedDot(true)
|
|
end
|
|
end
|
|
|
|
self:CaclulationMsgCount(info)
|
|
self:Fire(ChatModel.ADD_NEW_MSG, info)
|
|
end
|
|
return true
|
|
end
|
|
|
|
--获得正在聊天的玩家名字
|
|
function ChatModel:GetChatingRoleName(key_id)
|
|
local len = #self.cecret_chat_list
|
|
local vo = nil
|
|
for i = 1, len do
|
|
vo = self.cecret_chat_list[i]
|
|
if vo.key_id == key_id then
|
|
return vo.name
|
|
end
|
|
end
|
|
return "玩家名字"
|
|
end
|
|
|
|
--打包指定频道的时间信息 目的是为了添加一项横线时间显示
|
|
function ChatModel:PackChatInfo(channel, time, key_id)
|
|
local info = {}
|
|
info.channel = channel
|
|
info.time = time
|
|
info.key_id = key_id
|
|
info.is_line = true
|
|
return info
|
|
end
|
|
|
|
--通过聊天界面的tabbar索引来获取当前频道值
|
|
function ChatModel:GetChannelWithId(id)
|
|
for k, v in pairs(Config.ConfigChat.channel_level) do
|
|
if v.channel == id then
|
|
return v
|
|
end
|
|
end
|
|
end
|
|
|
|
--根据频道获取Icon
|
|
function ChatModel:GetChannelIconWithChannel(channel)
|
|
local vo = nil
|
|
for k,v in pairs(Config.ConfigChat.channel_level) do
|
|
if v.channel == channel then
|
|
return v.channel_icon
|
|
end
|
|
end
|
|
return "chat_channel_1"
|
|
end
|
|
|
|
--根据频道获取name 包括颜色
|
|
function ChatModel:GetChannelNameWithChannel(channel)
|
|
local vo = nil
|
|
for i = 1, #Config.ConfigChat.channel_level do
|
|
vo = Config.ConfigChat.channel_level[i]
|
|
if vo.channel == channel then
|
|
if not vo.color2 then return end
|
|
local name = "<color="..vo.color2..">".."["..vo.name.."]".."</color>"
|
|
-- if vo.channel == ChatModel.CHANNEL_SYSTEM then --这会综合频道变成系统
|
|
-- name = "<color="..vo.color2..">".."[系统]".."</color>"
|
|
-- end
|
|
return (name)
|
|
end
|
|
end
|
|
if channel == ChatModel.ALL then
|
|
return string.format("<color=%s>[所有]</color>", ColorUtil.ORANGE)
|
|
end
|
|
return "[未知]"
|
|
end
|
|
|
|
--根据频道获取Icon
|
|
function ChatModel:GetChannelColorWithChannel(channel)
|
|
local vo = nil
|
|
for i = 1, #Config.ConfigChat.channel_level do
|
|
vo = Config.ConfigChat.channel_level[i]
|
|
if vo.channel == channel then
|
|
return vo.color
|
|
end
|
|
end
|
|
|
|
return "#848484"
|
|
end
|
|
|
|
function ChatModel:GetTipWithShowType(showtype)
|
|
local vo = nil
|
|
for i = 1, #Config.ConfigChat.tips do
|
|
vo = Config.ConfigChat.tips[i]
|
|
if vo.type == showtype then
|
|
return vo.icon, vo.color
|
|
end
|
|
end
|
|
return "chat_channel_1", "#333c4e" --"#848484"
|
|
end
|
|
|
|
function ChatModel:getInstance()
|
|
if ChatModel.Instance == nil then
|
|
ChatModel.New()
|
|
end
|
|
return ChatModel.Instance
|
|
end
|
|
|
|
function ChatModel:SeletedChatViewTabbar(item, not_fire_event)
|
|
if self.selected_chatView_tabbar_item == item then
|
|
return
|
|
end
|
|
if self.selected_chatView_tabbar_item then
|
|
self.selected_chatView_tabbar_item:SetSelect(false)
|
|
end
|
|
self.selected_chatView_tabbar_item = item
|
|
if self.selected_chatView_tabbar_item then
|
|
self.selected_chatView_tabbar_item:SetSelect(true)
|
|
if not not_fire_event then
|
|
self:Fire(ChatModel.SELECT_CHAT_VIEW_TARBAR, self.selected_chatView_tabbar_item)
|
|
end
|
|
end
|
|
end
|
|
function ChatModel:SeletedTextFaceItem(item)
|
|
if self.selected_textface_item then
|
|
self.selected_textface_item:SetSelect(false)
|
|
end
|
|
self.selected_textface_item = item
|
|
if self.selected_textface_item then
|
|
self.selected_textface_item:SetSelect(true)
|
|
self:Fire(ChatModel.SELECT_TEXT_FACE_ITEM, self.selected_textface_item)
|
|
end
|
|
end
|
|
function ChatModel:SeletedHistroyItem(item)
|
|
if self.selected_histroy_item then
|
|
self.selected_histroy_item:SetSelect(false)
|
|
end
|
|
self.selected_histroy_item = item
|
|
if self.selected_histroy_item then
|
|
self.selected_histroy_item:SetSelect(true)
|
|
self:Fire(ChatModel.SELECT_HISTROY_ITEM, self.selected_histroy_item)
|
|
end
|
|
end
|
|
|
|
function ChatModel:SeletedFaceItem(item)
|
|
if self.selected_face_item then
|
|
self.selected_face_item:SetSelect(false)
|
|
end
|
|
self.selected_face_item = item
|
|
if self.selected_face_item then
|
|
self.selected_face_item:SetSelect(true)
|
|
self:Fire(ChatModel.SELECT_FACE_ITEM, self.selected_face_item)
|
|
end
|
|
end
|
|
|
|
function ChatModel:SeletedHistoryTextItem(item)
|
|
if self.selected_history_text_item then
|
|
self.selected_history_text_item:SetSelect(false)
|
|
end
|
|
self.selected_history_text_item = item
|
|
if self.selected_history_text_item then
|
|
self.selected_history_text_item:SetSelect(true)
|
|
self:Fire(ChatModel.SELECT_HISTORY_TEXT_ITEM, self.selected_history_text_item.str)
|
|
end
|
|
end
|
|
|
|
function ChatModel:SelectedPartnerItem(item)
|
|
if self.selected_partner_item == item then return end
|
|
if self.selected_partner_item then
|
|
self.selected_partner_item:SetSelect(false)
|
|
end
|
|
self.selected_partner_item = item
|
|
if self.selected_partner_item then
|
|
self.selected_partner_item:SetSelect(true)
|
|
self:Fire(ChatModel.SELECT_PARTNER_ITEM, self.selected_partner_item.vo)
|
|
end
|
|
end
|
|
|
|
function ChatModel:SelectedGoodItem(item)
|
|
if self.selected_good_item == item then return end
|
|
if self.selected_good_item then
|
|
self.selected_good_item:SetSelect(false)
|
|
end
|
|
self.selected_good_item = item
|
|
if self.selected_good_item then
|
|
self.selected_good_item:SetSelect(true)
|
|
self:Fire(ChatModel.SELECT_GOOD_ITEM, self.selected_good_item.vo)
|
|
end
|
|
end
|
|
|
|
function ChatModel:GetTVList()
|
|
return self.tv_list
|
|
end
|
|
|
|
--处理不需要特殊处理的信息
|
|
function ChatModel:DealWithOtherSystemMsg(info)
|
|
local curr_list = self.all_chat_list[info.channel]
|
|
if curr_list == nil then
|
|
curr_list = {}
|
|
self.all_chat_list[info.channel] = curr_list
|
|
end
|
|
|
|
table.insert(curr_list, info)
|
|
if #curr_list > ChatModel.MAX_LEN_LIST[info.channel] then
|
|
table.remove(curr_list, 1)
|
|
end
|
|
end
|
|
|
|
--根据频道删除玩家聊天信息
|
|
function ChatModel:DelMsgInChannelById(channel, id)
|
|
local index_tb = {}
|
|
local channel_list = self.all_chat_list[channel]
|
|
if channel_list then
|
|
if channel == ChatModel.CHANNEL_CECRET then
|
|
self:ClearChannelMessageNum(ChatModel.CHANNEL_CECRET, id)
|
|
CookieWrapper.Instance:DeleteChatHistroyFile(id)
|
|
else
|
|
for k, v in pairs(channel_list) do
|
|
if v.player_id == id then
|
|
table.insert(index_tb, k)
|
|
end
|
|
end
|
|
local del = 0
|
|
local num = 0
|
|
for k, v in ipairs(index_tb) do
|
|
del = v - num
|
|
table.remove(channel_list, del)
|
|
num = num + 1
|
|
if self.all_chat_list_count[channel] and self.all_chat_list_count[channel] > 0 then
|
|
self.all_chat_list_count[channel] = self.all_chat_list_count[channel] - 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChatModel:DelMsgInNoticeChannelById( notice_id )
|
|
local index_tb = {}
|
|
if self.all_chat_list[ChatModel.CHANNEL_SYSTEM] then
|
|
for k, v in pairs(self.all_chat_list[ChatModel.CHANNEL_SYSTEM]) do
|
|
if v.notice_id == notice_id then
|
|
table.insert(index_tb, k)
|
|
end
|
|
end
|
|
local del = 0
|
|
local num = 0
|
|
for k, v in ipairs(index_tb) do
|
|
del = v - num
|
|
table.remove(self.all_chat_list[ChatModel.CHANNEL_SYSTEM], del)
|
|
num = num + 1
|
|
if self.all_chat_list_count[ChatModel.CHANNEL_SYSTEM] and self.all_chat_list_count[ChatModel.CHANNEL_SYSTEM] > 0 then
|
|
self.all_chat_list_count[ChatModel.CHANNEL_SYSTEM] = self.all_chat_list_count[ChatModel.CHANNEL_SYSTEM] - 1
|
|
end
|
|
end
|
|
end
|
|
self:Fire(ChatModel.SHOW_TAB_RED_POINT, self.all_chat_list_count)
|
|
end
|
|
|
|
--处理喇叭信息 gg_flag --只发滚屏而且频道不是 CHANNEL_WORLD CHANNEL_HORN 就要设为ture
|
|
function ChatModel:DealWithHornSystemMsg(info, front,gg_flag)
|
|
|
|
--插入喇叭延迟列表
|
|
info.gm = 0
|
|
table.insert(self.delay_horn_list, info)
|
|
--触发喇叭滚动
|
|
SysInfoCtrl.Instance:AppendMsg(SysInfoCtrl.SysInfoType.HORN)
|
|
|
|
if gg_flag then return end
|
|
|
|
local curr_list = self.all_chat_list[ChatModel.CHANNEL_WORLD]
|
|
local horn_list = self.all_chat_list[ChatModel.CHANNEL_HORN]
|
|
if curr_list == nil then
|
|
curr_list = {}
|
|
self.all_chat_list[ChatModel.CHANNEL_WORLD] = curr_list
|
|
end
|
|
if horn_list == nil then
|
|
horn_list = {}
|
|
self.all_chat_list[ChatModel.CHANNEL_HORN] = horn_list
|
|
end
|
|
if front then --插入到最前面
|
|
table.insert(curr_list, 1, info)
|
|
else
|
|
table.insert(curr_list, info)
|
|
end
|
|
-- print("ChatModel:DealWithHornSystemMsg", curr_list[#curr_list].msg)
|
|
table.insert(horn_list, info)
|
|
if #curr_list > ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_WORLD] then
|
|
table.remove(curr_list, 1)
|
|
end
|
|
|
|
if #horn_list > ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_HORN] then
|
|
table.remove(horn_list, 1)
|
|
end
|
|
|
|
|
|
end
|
|
|
|
--移除喇叭延迟列表
|
|
function ChatModel:RemoveDelayHorn()
|
|
local info = table.remove(self.delay_horn_list, 1)
|
|
self:Fire(ChatModel.UPDATE_HORNTV_NUM)
|
|
return info
|
|
end
|
|
|
|
--获取喇叭延迟列表数量
|
|
function ChatModel:GetDelayHornNum()
|
|
return #self.delay_horn_list
|
|
end
|
|
|
|
--添加gm喇叭
|
|
function ChatModel:AddGmHorn(scmd)
|
|
local vo = {name = "系统", channel = scmd.channel, time = TimeUtil:getServerTime(), msg = scmd.msg, showtype = ChatModel.CHANNEL_HORN,
|
|
lastTime = scmd.time, gm = scmd.gm}
|
|
--插入喇叭延迟列表
|
|
table.insert(self.delay_horn_list, vo)
|
|
--排序
|
|
local arg = {"gm", "time"}
|
|
local condition = {Array.UPPER, Array.LOWER}
|
|
SortTools.MoreKeysSorter(self.delay_horn_list, arg, condition)
|
|
self:Fire(ChatModel.ADD_NEW_MSG, vo)
|
|
--触发喇叭滚动
|
|
SysInfoCtrl.Instance:AppendMsg(SysInfoCtrl.SysInfoType.HORN)
|
|
end
|
|
|
|
--处理私聊信息
|
|
function ChatModel:DealWithCerectSystemMsg(info)
|
|
--取私聊对象id作为key
|
|
local curr_list = self.all_chat_list[info.channel]
|
|
|
|
if curr_list == nil then
|
|
--原先的祖传代码获取离线消息时根本就不读cookie直接创了个空表覆盖了,这里一定要拿一下缓存才行
|
|
curr_list = CookieWrapper.Instance:GetChatHistroy(info.player_list[1].player_id,true)--根据id获取聊天缓存
|
|
self.all_chat_list[info.channel] = curr_list
|
|
end
|
|
|
|
local len = TableSize(info.player_list)
|
|
if string.find(info.msg,"<color@") then
|
|
info.msg = ChuanWenManager:getInstance():FormatColorTag(info.msg)
|
|
end
|
|
|
|
if len == 2 then
|
|
local role_id = RoleManager.Instance:GetMainRoleId()
|
|
if role_id == info.player_list[1].player_id then
|
|
info.key_id = info.player_list[2].player_id
|
|
else
|
|
info.key_id = info.player_list[1].player_id
|
|
end
|
|
|
|
--为了跟之前的结构匹配,对于私聊的信息,添加了以下几个信息
|
|
info.name = info.player_list[1].name
|
|
info.player_id = info.player_list[1].player_id
|
|
info.level = info.player_list[1].level
|
|
info.career = info.player_list[1].career
|
|
info.dress_list = info.player_list[1].dress_list
|
|
info.guild_id = info.player_list[1].guild_id
|
|
info.sex = info.player_list[1].sex
|
|
info.vip_flag = info.player_list[1].vip_flag
|
|
info.sup_vip_type = info.player_list[1].sup_vip_type
|
|
info.turn = info.player_list[1].turn
|
|
info.ser_id = info.player_list[1].ser_id
|
|
info.ser_num = info.player_list[1].ser_num
|
|
info.ser_name = info.player_list[1].ser_name
|
|
info.picture_ver = info.player_list[1].picture_ver
|
|
info.picture = info.player_list[1].picture
|
|
info.profile_photo_id = info.player_list[1].profile_photo_id
|
|
info.GM = info.player_list[1].GM
|
|
|
|
local key_id = tostring(info.key_id)
|
|
local curr_player_list = curr_list[key_id]
|
|
if curr_player_list == nil then
|
|
curr_player_list = {}
|
|
curr_list[key_id] = curr_player_list
|
|
end
|
|
|
|
table.insert(curr_player_list, info)
|
|
--添加密聊消息
|
|
local list = self:GetSimpleHistroyInfoSave(curr_player_list)
|
|
CookieWrapper.Instance:SaveChatHistroy(key_id, CookieTimeType.TYPE_ALWAYS, list)
|
|
|
|
--保存聊天记录
|
|
CookieWrapper.Instance:WriteChatHistroy()
|
|
|
|
if #curr_player_list > ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_CECRET] then
|
|
table.remove(curr_player_list, 1)
|
|
end
|
|
|
|
local len = #self.cecret_chat_list
|
|
local hasCache = false --是否是已有的密聊玩家
|
|
local vo = nil
|
|
for i = 1, len do
|
|
vo = self.cecret_chat_list[i]
|
|
if vo.key_id == tonumber(key_id) then
|
|
--有可能上线缓存的信息 发过来
|
|
if vo.time < info.time then
|
|
vo.time = info.time
|
|
end
|
|
hasCache = true
|
|
break
|
|
end
|
|
end
|
|
|
|
if not hasCache then
|
|
if #self.cecret_chat_list > 5 then
|
|
table.remove(self.cecret_chat_list, 5)
|
|
end
|
|
table.insert(self.cecret_chat_list, DeepCopy(info))
|
|
local function sort_func(v1, v2)
|
|
return v1.time > v2.time
|
|
end
|
|
table.sort(self.cecret_chat_list, sort_func)
|
|
self:GetSimpleCecretInfoSave()
|
|
end
|
|
end
|
|
end
|
|
|
|
--处理缓存信息, 私聊的缓存不需要处理
|
|
function ChatModel:DealWithCacheMsg(info)
|
|
if info.channel == ChatModel.CHANNEL_CECRET then return end
|
|
|
|
local curr_list = self.all_chat_list[info.channel]
|
|
if curr_list == nil then
|
|
curr_list = {}
|
|
self.all_chat_list[info.channel] = curr_list
|
|
end
|
|
|
|
local len = TableSize(info.player_list)
|
|
if len > 0 then
|
|
--为了跟之前的结构匹配,对于缓存的信息,添加了以下几个信息
|
|
info.name = info.player_list[1].name
|
|
info.player_id = info.player_list[1].player_id
|
|
info.level = info.player_list[1].level
|
|
info.career = info.player_list[1].career
|
|
info.dress_list = info.player_list[1].dress_list
|
|
info.guild_id = info.player_list[1].guild_id
|
|
info.sex = info.player_list[1].sex
|
|
info.turn = info.player_list[1].turn
|
|
info.vip_flag = info.player_list[1].vip_flag
|
|
info.sup_vip_type = info.player_list[1].sup_vip_type
|
|
info.picture = info.player_list[1].picture
|
|
info.picture_ver = info.player_list[1].picture_ver
|
|
info.ser_id = info.player_list[1].ser_id
|
|
info.ser_num = info.player_list[1].ser_num
|
|
info.ser_name = info.player_list[1].ser_name
|
|
info.profile_photo_id = info.player_list[1].profile_photo_id
|
|
info.GM = info.player_list[1].GM
|
|
if info.auto_id ~= 0 then --语音的
|
|
info.voice_id = info.auto_id
|
|
info.data_ver = info.client_ver
|
|
info.iType = ChatModel.MSG_TYPE.VOICE
|
|
info.length = info.voice_msg_time
|
|
end
|
|
-- print("=============>>> YiRan:ChatModel [start:830]info ------------------------------------------")
|
|
-- PrintTable(info)
|
|
-- print("=============>>> YiRan:ChatModel [end] ------------------------------------------")
|
|
end
|
|
end
|
|
|
|
function ChatModel:GetSimpleHistroyInfoSave(chatlist)
|
|
local list = {}
|
|
for i, info in ipairs(chatlist) do
|
|
--控制一下聊天记录数量,超过限制数量就不要加入转化了
|
|
if #chatlist - i <= ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_CECRET] then
|
|
--构造最基本信息
|
|
info.msg = string.gsub(info.msg, '(["])', "")
|
|
local vo = {
|
|
channel = info.channel,
|
|
msg = info.msg,
|
|
time = info.time,
|
|
player_id = info.player_id,
|
|
key_id = info.key_id,
|
|
level = info.level,
|
|
name = info.name,
|
|
career = info.career,
|
|
dress_list = info.dress_list,
|
|
guild_id = info.guild_id,
|
|
iType = info.iType,
|
|
length = info.length,
|
|
voice_id = info.voice_id,
|
|
data_ver = info.data_ver,
|
|
sex = info.sex,
|
|
turn = info.turn,
|
|
vip_flag = info.vip_flag,
|
|
sup_vip_type = info.sup_vip_type,
|
|
ser_id = info.ser_id,
|
|
ser_num = info.ser_num,
|
|
ser_name = info.ser_name,
|
|
GM = info.GM,
|
|
profile_photo_id = info.profile_photo_id
|
|
}
|
|
table.insert(list, vo)
|
|
end
|
|
end
|
|
return list
|
|
end
|
|
|
|
function ChatModel:GetSimpleCecretInfoSave()
|
|
local list = {}
|
|
for i, info in ipairs(self.cecret_chat_list) do
|
|
--构造最基本信息
|
|
local v = {}
|
|
if info.key_id == info.player_list[1].player_id then
|
|
v = info.player_list[1]
|
|
else
|
|
v = info.player_list[2]
|
|
end
|
|
local vo = {
|
|
time = info.time,
|
|
key_id = info.key_id,
|
|
player_list = {
|
|
[1] = {
|
|
player_id = v.player_id,
|
|
name = v.name,
|
|
level = v.level,
|
|
career = v.career,
|
|
vip_flag = v.vip_flag,
|
|
sup_vip_type = v.sup_vip_type,
|
|
touxian = v.touxian,
|
|
guild_id = v.guild_id,
|
|
ser_id = v.ser_id,
|
|
ser_num = v.ser_num,
|
|
ser_name = v.ser_name,
|
|
},
|
|
},
|
|
}
|
|
table.insert(list, vo)
|
|
end
|
|
--密聊列表最大5个,只在有新的人才会保存信息。但这里可以再做优化
|
|
CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.CECRET_HISTROY, list)
|
|
end
|
|
|
|
--获取喇叭需要的配置信息
|
|
function ChatModel:GetHornVo()
|
|
local vo = nil
|
|
for i = 1, #Config.ConfigChat.channel_level do
|
|
vo = Config.ConfigChat.channel_level[i]
|
|
if vo.channel == ChatModel.CHANNEL_HORN then
|
|
return vo
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
--获取当前所在频道所需等级
|
|
function ChatModel:GetCurChannelNeedLevel()
|
|
return Config.ConfigChat.channel_level[self.curr_bar_index].level
|
|
end
|
|
|
|
--获取私聊需要的等级
|
|
function ChatModel:GetCecretNeedLevel()
|
|
local vo = nil
|
|
for i = 1, #Config.ConfigChat.channel_level do
|
|
vo = Config.ConfigChat.channel_level[i]
|
|
if vo.channel == ChatModel.CHANNEL_CECRET then
|
|
return vo.level
|
|
end
|
|
end
|
|
return 1
|
|
end
|
|
|
|
--根据频道获取频道所在的index
|
|
function ChatModel:GetTabIndexWithChannel(channel)
|
|
local vo = nil
|
|
for i = 1, #Config.ConfigChat.channel_level do
|
|
vo = Config.ConfigChat.channel_level[i]
|
|
if vo.channel == channel then
|
|
return i
|
|
end
|
|
end
|
|
return 1
|
|
end
|
|
--检查当前时间是否能发送
|
|
function ChatModel:CheckCurrentTimeCanSend(channel, send_interval)
|
|
if self.send_start_time_list[channel] == nil or Status.NowTime - self.send_start_time_list[channel] >= send_interval then
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
|
|
function ChatModel:GetPassTimeFromSend(channel, send_interval)
|
|
if self.send_start_time_list[channel] == nil then
|
|
return - 1
|
|
else
|
|
return send_interval - (Status.NowTime - self.send_start_time_list[channel])
|
|
end
|
|
end
|
|
|
|
--改变频道的发送时间
|
|
function ChatModel:ChangeChannelSendStartTime(vo, time)
|
|
local main_role_id = RoleManager.Instance:GetMainRoleId()
|
|
if vo.player_id == main_role_id then
|
|
self.send_start_time_list[vo.channel] = time
|
|
end
|
|
end
|
|
|
|
--是否需要显示私聊Item的红点
|
|
function ChatModel:NeedShowCecretItemRedPoint(key_id)
|
|
|
|
local cur_list = self.all_chat_list_count[ChatModel.CHANNEL_CECRET]
|
|
if cur_list == nil then return false end
|
|
|
|
if cur_list[key_id] ~= nil and cur_list[key_id] > 0 then
|
|
return true, cur_list[key_id]
|
|
end
|
|
|
|
return false
|
|
end
|
|
--清除消息记录的条数
|
|
function ChatModel:ClearChannelMessageNum(channel, key_id)
|
|
if channel == ChatModel.CHANNEL_CECRET then
|
|
local cur_list = self.all_chat_list_count[channel]
|
|
if cur_list ~= nil and cur_list[key_id] ~= nil then
|
|
cur_list[key_id] = nil
|
|
end
|
|
else
|
|
self.all_chat_list_count[channel] = nil
|
|
end
|
|
end
|
|
|
|
--是否黑名单玩家
|
|
function ChatModel:IsPlayerInBlack(info)
|
|
return SocialityModel:getInstance():GetVoById(Config.ConfigSocial.RelativeType.black, info.player_id)
|
|
end
|
|
|
|
--判断频道信息是否需要屏蔽
|
|
function ChatModel:MsgNeedFilter(info)
|
|
local channel = info.channel
|
|
local setting_type = SettingModel.TYPE.TEXT--info.iType 语音随文字的 就这样写
|
|
--如果是自己则不屏蔽
|
|
local main_role_id = RoleManager.Instance:GetMainRoleId()
|
|
if channel == ChatModel.CHANNEL_CECRET then
|
|
local len = TableSize(info.player_list)
|
|
if len == 2 then
|
|
if main_role_id == info.player_list[1].player_id then
|
|
return false
|
|
end
|
|
end
|
|
else
|
|
if main_role_id == info.player_id then
|
|
return false
|
|
end
|
|
end
|
|
|
|
local subtype = SettingModel.C2T[channel]
|
|
if subtype then
|
|
return SettingModel:getInstance():GetSettingInfo(setting_type, subtype) == 0
|
|
else
|
|
return false
|
|
end
|
|
|
|
end
|
|
|
|
function ChatModel:AddArgs(key, t)
|
|
--只能保存一个
|
|
-- if not IsTableEmpty(self.chat_args_dic) then
|
|
-- self.chat_args_dic = {}
|
|
-- end
|
|
self.chat_args_dic[key] = t
|
|
end
|
|
|
|
function ChatModel:IsHasArgs(str)
|
|
for w in string.gmatch(str, "<.->") do
|
|
if self.chat_args_dic[w] ~= nil then
|
|
return w
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
function ChatModel:GetAllArgsText(str)
|
|
--目前能保存多个key,每次替换Input<>内容,遍历dic与<>内容作比较,有则发送参数,可用于发送多个道具信息
|
|
--只发送一个则可以只保存单个参数,不需要用到dic结构(对比优化)
|
|
local text = ""
|
|
for w in string.gmatch(str, "<.->") do
|
|
if self.chat_args_dic[w] ~= nil then
|
|
text = text .. self.chat_args_dic[w][1] .. ","
|
|
end
|
|
end
|
|
text = string.sub(text, 1, -2)
|
|
return "[" .. text .. "]"
|
|
end
|
|
|
|
function ChatModel:GetHyperlinkText(str)
|
|
local text = ""
|
|
for w in string.gmatch(str, "<.->") do
|
|
if self.chat_args_dic[w] ~= nil then
|
|
text = LanguageFilter.ConvPartten(w)
|
|
str = string.gsub(str, text, self.chat_args_dic[w][2])
|
|
end
|
|
end
|
|
return str
|
|
end
|
|
|
|
function ChatModel:AddMainRoleChatContent(content, player_id)
|
|
if player_id ~= RoleManager.Instance:GetMainRoleId() then return end
|
|
if #self.main_role_chat_list >= 20 then
|
|
table.remove(self.main_role_chat_list, 1)
|
|
end
|
|
content = PackageSpecialTab(content)
|
|
content = self:DeleteSpecialSign(content)
|
|
table.insert(self.main_role_chat_list, content)
|
|
CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.CHAT_HISTROY, self.main_role_chat_list)
|
|
end
|
|
|
|
function ChatModel:GetAllMainRoleContent()
|
|
return CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.CHAT_HISTROY)
|
|
end
|
|
|
|
function ChatModel:DeleteSpecialSign(content)
|
|
content = string.gsub(content, "<a.->", "")
|
|
content = string.gsub(content, "</a>", "")
|
|
content = string.gsub(content, "<color.->", "")
|
|
content = string.gsub(content, "</color>", "")
|
|
content = string.gsub(content, "<u.->", "")
|
|
content = string.gsub(content, "</u>", "")
|
|
content = string.gsub(content, '(["])', "")
|
|
return content
|
|
end
|
|
|
|
function ChatModel:ShowGoodTips(vo)
|
|
if not self.clicked_item or not self.clicked_item.transform then
|
|
--协议返回后,界面已销毁
|
|
self.chick_hyperlink_mark = false
|
|
return
|
|
end
|
|
local t = ConfigItemMgr.Instance:GetGoodItem(vo.type_id) --
|
|
if t.type then
|
|
local pos = self.clicked_item.transform.localPosition
|
|
GoodsModel:getInstance():SetBaseInfo(vo)
|
|
if t.type == GoodsModel.TYPE.EQUIP then
|
|
-- UIToolTipMgr:getInstance():AppendEquipTips(vo.type_id, pos.x, pos.y, vo,nil,true)
|
|
local equip_cfg = EquipModel:getInstance():GetEquipmentCfg(vo.type_id)
|
|
if equip_cfg then
|
|
local equip_pos = equip_cfg.equip_type
|
|
local series = equip_cfg.series
|
|
vo.equip_suit_type = equip_pos
|
|
local stren_data = EquipModel:getInstance():GetBagEquipAwaraItemInfo(vo)
|
|
stren_data.key_value = "other_show"
|
|
UIToolTipMgr:getInstance():AppendEquipTips(vo.type_id, pos.x, pos.y,stren_data and stren_data.goods_vo,nil,nil,nil,stren_data and stren_data.key_value)
|
|
else
|
|
-- Message.show("没有装备配置哦")
|
|
end
|
|
elseif t.type == 39 then
|
|
UIToolTipMgr:getInstance():AppendBeastShowTips(vo, pos.x, pos.y)
|
|
else
|
|
UIToolTipMgr:getInstance():AppendGoodsTips(vo.type_id, pos.x, pos.y, vo)
|
|
end
|
|
end
|
|
self.chick_hyperlink_mark = false
|
|
self.clicked_item = nil
|
|
end
|
|
|
|
function ChatModel:FireSpecialTab(param_list,x,y)
|
|
if param_list[1] == "goods3" then --请求刷新装备数据
|
|
local type_id = tonumber(param_list[2])
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
|
|
if basic and (basic.type == GoodsModel.TYPE.EQUIP or basic.type == 39) then
|
|
local rating = tonumber(param_list[3])
|
|
local intro = StrToTable(param_list[4]) or {}
|
|
local vo = SCMD15001.New()
|
|
vo.equip_extra_attr = intro
|
|
vo.rating = rating
|
|
vo.type_id = type_id
|
|
vo.color = basic.color
|
|
vo.overall_rating = rating
|
|
GoodsModel:getInstance():AddDynamic(vo)
|
|
|
|
if basic.type == GoodsModel.TYPE.EQUIP then
|
|
ChatModel:getInstance():ShowGoodTips(vo)
|
|
elseif basic.type == 39 then
|
|
UIToolTipMgr:getInstance():AppendBeastShowTips(vo)
|
|
end
|
|
else
|
|
UIToolTipMgr:getInstance():AppendGoodsTips(tonumber(param_list[2]),x,y)
|
|
end
|
|
self.chick_hyperlink_mark = false
|
|
self.clicked_item = nil
|
|
elseif param_list[1] == "goods6" then
|
|
--goods3是后台填传闻用到,收到协议后进行特殊解析
|
|
--goods6是客户端用的,无需解析,直接把极品属性字符串转成table
|
|
local type_id = tonumber(param_list[2])
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
|
|
if basic and (basic.type == GoodsModel.TYPE.EQUIP or basic.type == 39) then
|
|
local rating = tonumber(param_list[3])
|
|
local intro = StrToTable(param_list[4])
|
|
local vo = SCMD15001.New()
|
|
vo.equip_extra_attr = intro
|
|
vo.rating = rating
|
|
vo.type_id = type_id
|
|
vo.color = basic.color
|
|
vo.overall_rating = rating
|
|
GoodsModel:getInstance():AddDynamic(vo)
|
|
if basic.type == GoodsModel.TYPE.EQUIP then
|
|
ChatModel:getInstance():ShowGoodTips(vo)
|
|
elseif basic.type == 39 then
|
|
UIToolTipMgr:getInstance():AppendBeastShowTips(vo)
|
|
end
|
|
else
|
|
UIToolTipMgr:getInstance():AppendGoodsTips(tonumber(param_list[2]))
|
|
end
|
|
self.chick_hyperlink_mark = false
|
|
self.clicked_item = nil
|
|
elseif param_list[1] == "goods8" then
|
|
local type_id = tonumber(param_list[2])
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
|
|
if basic and (basic.type == GoodsModel.TYPE.EQUIP or basic.type == 39) then
|
|
local rating = tonumber(param_list[3])
|
|
local intro = StrToTable(param_list[4])
|
|
local vo = SCMD15001.New()
|
|
vo.equip_extra_attr = intro
|
|
vo.rating = rating
|
|
vo.type_id = type_id
|
|
vo.color = basic.color
|
|
vo.overall_rating = rating
|
|
GoodsModel:getInstance():AddDynamic(vo)
|
|
if basic.type == GoodsModel.TYPE.EQUIP then
|
|
ChatModel:getInstance():ShowGoodTips(vo)
|
|
elseif basic.type == 39 then
|
|
UIToolTipMgr:getInstance():AppendBeastShowTips(vo)
|
|
end
|
|
else
|
|
UIToolTipMgr:getInstance():AppendGoodsTips(tonumber(param_list[2]))
|
|
end
|
|
self.chick_hyperlink_mark = false
|
|
self.clicked_item = nil
|
|
elseif param_list[1] == "goods4" then --请求刷新物品数据
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(tonumber(param_list[2]))
|
|
if basic and basic.type == GoodsModel.TYPE.EQUIP then
|
|
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_GOODS_DYNAMIC, tonumber(param_list[3]), tonumber(param_list[4]))
|
|
else
|
|
UIToolTipMgr:getInstance():AppendGoodsTips(tonumber(param_list[2]))
|
|
self.chick_hyperlink_mark = false
|
|
self.clicked_item = nil
|
|
end
|
|
elseif param_list[1] == "team" then --进入组队
|
|
local teamInfo = TeamModel:getInstance():GetTeamInfoByID( tonumber(param_list[2]) )
|
|
if teamInfo and teamInfo.need_password and teamInfo.need_password ~= "" then
|
|
GlobalEventSystem:Fire(EventName.OPEN_TEAM_PASSWORD_VIEW, teamInfo.team_id)
|
|
return
|
|
end
|
|
GlobalEventSystem:Fire(TeamModel.APPLY_JOIN_TEAM, param_list[2])
|
|
elseif param_list[1] == "race_act" then
|
|
local subtype = LimitTimeRankModel:getInstance():GetSubTypeByType(tonumber(param_list[2]))
|
|
if subtype then
|
|
LimitTimeRankModel:getInstance():Fire(LimitTimeRankDefine.OPEN_LIMIT_TIME_RANK_VIEW, tonumber(param_list[2]), subtype)
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChatModel:AddInfoToChatView(content, channel, tip) -- tip 为小喇叭弹出,记得其他模块没特殊要求别填1
|
|
--和传闻事件基本相似,除了系统频道外,都会隐藏红色背景
|
|
if not content or not channel then return end
|
|
local vo = {channel = channel, time = TimeUtil:getServerTime(), msg = content, showtype = ChatModel.CHANNEL_SYSTEM, tip = tip}
|
|
self:AddMsg(vo)
|
|
end
|
|
|
|
function ChatModel:GetErrorCode(code, strParam)
|
|
local tmp = Config.Errorcode[code]
|
|
local str = "未知返回码" .. code
|
|
if tmp then
|
|
str = Config.Errorcode[code].about
|
|
if strParam then
|
|
local args = Split(strParam, ",")
|
|
for i, v in ipairs(args) do
|
|
str = string.gsub(str, "{"..i.."}", v)
|
|
end
|
|
end
|
|
end
|
|
return str
|
|
end
|
|
|
|
function ChatModel:StartGongGaoList(vo)
|
|
|
|
if not vo then return end
|
|
for i,data in pairs(self.last_Gg_list) do --遍历旧表 如果新的公告记录表里面有旧表的数据就不做操作 没有的话就删除记录
|
|
local boo = false --判断标志 是否有记录
|
|
for i,v in ipairs(vo.notice_list) do
|
|
if data.id == v.id then --如果有记录 标志为true
|
|
boo = true
|
|
end
|
|
end
|
|
if not boo then --没有记录就做删除
|
|
ChatModel:getInstance():Fire(ChatModel.DEL_NOTICE_CHAT_ITEM,data.id)
|
|
ChatModel:getInstance():DelMsgInNoticeChannelById(data.id)
|
|
end
|
|
end
|
|
|
|
for i,v in ipairs(vo.notice_list) do --每次都缓存新的公告记录
|
|
self.last_Gg_list[v.id] = v
|
|
end
|
|
self:ClearGongGaoTimer()
|
|
if #vo.notice_list < 1 then return end
|
|
|
|
--self:ClearGongGaoTimer()
|
|
self.gonggao_vo = vo
|
|
local count = 0
|
|
for k, v in pairs(vo.notice_list) do
|
|
local tb = Split(v.source, ",")
|
|
for m, n in pairs(tb) do
|
|
if n == ClientConfig.plat_name or n == "" then
|
|
local ser_time = TimeUtil:getServerTime()
|
|
local time = v.start_time - ser_time
|
|
|
|
if time <= 0 then --超过时间, 就按照顺序隔180秒播放
|
|
count = count + 1
|
|
v.start_time = TimeUtil:getServerTime() + count * 180
|
|
end
|
|
self:GongGaoTimer(v)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChatModel:GongGaoTimer(vo)
|
|
if not vo then return end
|
|
if TimeUtil:getServerTime() > vo.end_time then return end
|
|
if vo.state == 0 then
|
|
ChatModel:getInstance():Fire(ChatModel.DEL_NOTICE_CHAT_ITEM,vo.id)
|
|
ChatModel:getInstance():DelMsgInNoticeChannelById(vo.id)
|
|
return
|
|
end
|
|
local ser_time = TimeUtil:getServerTime()
|
|
local time = vo.start_time - ser_time
|
|
vo.content = "<color="..vo.color..">"..vo.content.."</color>"
|
|
local count = 0
|
|
local check_time_id, delay_time_id = nil, nil
|
|
--数据开始时间>现在时间,马上发送
|
|
local function onCheck()
|
|
local cfg, scmd = {subtype = ChatModel.CHANNEL_SYSTEM} ,{url = vo.url,notice_id = vo.id}
|
|
if vo.type == 0 then
|
|
self:DealWithHornSystemMsg({name = "公告", msg = vo.content}, true,true)
|
|
elseif vo.type == 1 then
|
|
GlobalEventSystem:Fire(EventName.SHOW_CHUANWEN, vo.content, cfg, scmd)
|
|
elseif vo.type == 2 then
|
|
self:DealWithHornSystemMsg({name = "公告", msg = vo.content}, true,true)
|
|
GlobalEventSystem:Fire(EventName.SHOW_CHUANWEN, vo.content, cfg, scmd)
|
|
end
|
|
count = count + 1
|
|
if (vo.send_count ~= 0 and vo.send_count <= count) or TimeUtil:getServerTime() > vo.end_time then
|
|
GlobalTimerQuest:CancelQuest(check_time_id)
|
|
check_time_id = nil
|
|
end
|
|
end
|
|
local function onDelay()
|
|
check_time_id = GlobalTimerQuest:AddPeriodQuest(onCheck, vo.send_gap, -1)
|
|
table.insert(self.check_timer_list, check_time_id)
|
|
GlobalTimerQuest:CancelQuest(delay_time_id)
|
|
delay_time_id = nil
|
|
end
|
|
if vo.send_gap > 3 then --不能小于3 间隔太小,定时器有问题
|
|
if time > 0 then
|
|
delay_time_id = GlobalTimerQuest:AddDelayQuest(onDelay, time) --时间大于0 就延迟发送
|
|
table.insert(self.delay_timer_list, delay_time_id)
|
|
else
|
|
|
|
check_time_id = GlobalTimerQuest:AddPeriodQuest(onCheck, vo.send_gap, -1) --不大于0 立马发送
|
|
table.insert(self.check_timer_list, check_time_id)
|
|
end
|
|
end
|
|
onCheck()--修改后立马要发送一条 然后其他按间隔来
|
|
end
|
|
|
|
function ChatModel:ClearGongGaoTimer()
|
|
for i, v in ipairs(self.delay_timer_list) do
|
|
GlobalTimerQuest:CancelQuest(v)
|
|
end
|
|
for i, v in ipairs(self.check_timer_list) do
|
|
GlobalTimerQuest:CancelQuest(v)
|
|
end
|
|
self.delay_timer_list = {}
|
|
self.check_timer_list = {}
|
|
end
|
|
|
|
function ChatModel:UpdateRegText(scmd)
|
|
local check_list = self.all_chat_list[scmd.channel]
|
|
if check_list then
|
|
for k, v in pairs(check_list) do
|
|
if v.voice_id == scmd.auto_id then
|
|
v.msg = scmd.voice_text
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--argStr 格式是 "@A@B@C"
|
|
function ChatModel:GetSpecFindStr()
|
|
local key, argStr = "", ""
|
|
if SceneManager:getInstance():IsValhallaFightScene() then
|
|
key = "valhallapk"
|
|
argStr = "@"..ValhallaModel:GetInstance().pk_id
|
|
end
|
|
return key, argStr
|
|
end
|
|
|
|
function ChatModel:GetDressIdByType(dress_list, dress_type)
|
|
if dress_list then
|
|
for i, v in ipairs(dress_list) do
|
|
--1气泡 2相框
|
|
if v.dress_type == dress_type then
|
|
return v.dress_id
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChatModel:SetCrossChatTime(count)
|
|
-- print("ChatModel:SetCrossChatTime", count)
|
|
self.crossChatTime = count
|
|
self:Fire(ChatModel.CROSS_HORN_HAS_CHANGE, count)
|
|
end
|
|
|
|
function ChatModel:GoodChange()
|
|
self:Fire(ChatModel.HORN_HAS_CHANGE)
|
|
end
|
|
|
|
function ChatModel:SetChannelGennealList(channelID)
|
|
if channelID ~= ChatModel.CHANNEL_GENERAL then return end --只在需要设置综合频道才使用
|
|
local all_chat_list = self.all_chat_list
|
|
local channelGeneralList = {}
|
|
if all_chat_list then
|
|
for channel,list in pairs(all_chat_list) do
|
|
if channel ~= ChatModel.CHANNEL_GENERAL and channel ~= ChatModel.CHANNEL_HORN and channel ~= ChatModel.CHANNEL_CECRET then --喇叭会加入世界频道····可能祖传代码就要这样做
|
|
for k,v in pairs(list) do
|
|
table.insert(channelGeneralList,v)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
local sort_func = function ( a, b ) --生成是倒序
|
|
return a.time < b.time
|
|
end
|
|
table.sort(channelGeneralList, sort_func)
|
|
local cutNum = #channelGeneralList - ChatModel.MAX_LEN_LIST[ChatModel.CHANNEL_GENERAL]
|
|
if cutNum > 0 then
|
|
for i=1,cutNum do
|
|
table.remove(channelGeneralList,1)
|
|
end
|
|
end
|
|
all_chat_list[ChatModel.CHANNEL_GENERAL] = channelGeneralList
|
|
--Message.show(#self.all_chat_list[ChatModel.CHANNEL_GENERAL])
|
|
end
|
|
|
|
--存储未读私聊消息
|
|
function ChatModel:SetPriateChatInfo(info)
|
|
if not info then return end
|
|
local len = TableSize(info.player_list)
|
|
|
|
if len == 2 then
|
|
local role_id = RoleManager.Instance:GetMainRoleId()
|
|
if role_id == info.player_list[1].player_id then
|
|
info.key_id = info.player_list[2].player_id
|
|
else
|
|
info.key_id = info.player_list[1].player_id
|
|
end
|
|
info.name = info.player_list[1].name
|
|
self.chat_priate_info[info.key_id] = {}
|
|
self.chat_priate_info[info.key_id] = info.player_list[1].player_id
|
|
end
|
|
end
|
|
|
|
--获取未读私聊消息
|
|
function ChatModel:GetPriateChatInfo( )
|
|
return self.chat_priate_info
|
|
end
|
|
|
|
--更新未读私聊消息
|
|
function ChatModel:UpdatePriateChatInfo(id)
|
|
if not id then return end
|
|
for k,v in pairs(self.chat_priate_info) do
|
|
if k == id then
|
|
self.chat_priate_info[k] = nil
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChatModel:SetChatInfo( info,vo )
|
|
self.get_chat = info
|
|
self.chatMessage = vo
|
|
end
|
|
|
|
function ChatModel:GetChatInfo( )
|
|
return self.get_chat,self.chatMessage
|
|
|
|
end
|
|
|
|
function ChatModel:SetConfigLangExtraWelcomeList( )
|
|
local config_language_extra = Config.Languageextra
|
|
self.welcomeList = {}
|
|
|
|
for k,v in pairs(config_language_extra) do
|
|
if v.module_id == 110 then
|
|
--if v.id ~= 1 then --开始显示第一条
|
|
--if v.tip == 1 then -- tip 为1的才加
|
|
local str = Trim( ChuanWenManager:getInstance():FormatColorTag2(v.content, true) )
|
|
table.insert(self.welcomeList,str)
|
|
--end
|
|
--end
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChatModel:StopWelcomeHorn( )
|
|
if self.play_welcom_horn_id then
|
|
GlobalTimerQuest:CancelQuest(self.play_welcom_horn_id)
|
|
self.play_welcom_horn_id = nil
|
|
end
|
|
end
|
|
function ChatModel:StartMainUIWelcomeHorn( )
|
|
self:StopWelcomeHorn( )
|
|
local function onTimer( )
|
|
local new_index = math.random(1, #self.welcomeList)
|
|
if new_index == self.welcomeListIndex then
|
|
self.welcomeListIndex = self.welcomeListIndex + 1
|
|
if self.welcomeListIndex > #self.welcomeList then
|
|
self.welcomeListIndex = 1
|
|
end
|
|
else
|
|
self.welcomeListIndex = new_index
|
|
end
|
|
welcomeShowTxt = self.welcomeList[self.welcomeListIndex]
|
|
|
|
self:Fire(ChatModel.ADD_MAINUI_WELCOME_HORN, welcomeShowTxt)
|
|
end
|
|
self.play_welcom_horn_id = GlobalTimerQuest:AddPeriodQuest(onTimer,Config.ConfigChat.MainUIWelcomeHornTime)
|
|
onTimer() -- 先调一次
|
|
end
|
|
function ChatModel:GetGoodsTipNum( )--11060协议专用小喇叭显示,后端无法传只得前端写死读
|
|
local config_language_extra = Config.Languageextra
|
|
return config_language_extra["0@2"].tip
|
|
end
|
|
function ChatModel:SetVo11023(vo)
|
|
self.vo11023 = vo
|
|
end
|
|
function ChatModel:GetVo11023( )
|
|
return self.vo11023
|
|
end
|
|
function ChatModel:GetAiMsgList( )
|
|
if not self:GetVo11023( ) or not self:GetVo11023( ).cache_list then return end
|
|
--print("=============>>> YiRan:ChatModel [start:1459] self:GetVo11023( ).cache_list ------------------------------------------")
|
|
--PrintTable(self:GetVo11023( ).cache_list)
|
|
--print("=============>>> YiRan:ChatModel [end] ------------------------------------------")
|
|
local role_id = RoleManager.Instance:GetMainRoleId()
|
|
local server_id = RoleManager.Instance.mainRoleInfo.server_id
|
|
local creatMsg =
|
|
{
|
|
["args"] = {},
|
|
["result"] = 0,
|
|
["auto_id"] = 0,
|
|
["player_list"] =
|
|
{
|
|
[1] =
|
|
{
|
|
["GM"] = 0,
|
|
["guild_name"] = "",
|
|
["vip_flag"] = 0,
|
|
["profile_photo_id"] = 0,
|
|
["realm"] = 0,
|
|
["player_id"] = 0,
|
|
["ser_num"] = 666,
|
|
["sex"] = 1,
|
|
["role_id"] = role_id,
|
|
["touxian"] = 0,
|
|
["picture_ver"] = 0,
|
|
["turn_stage"] = 0,
|
|
["grade_id"] = 0,
|
|
-- ["deity_id"] = 0,
|
|
-- ["image_id"] = 0,
|
|
-- ["marriage_id"] = 0,
|
|
-- ["is_marriage"] = 0,
|
|
["picture"] = 0,
|
|
["sup_vip_type"] = 0,
|
|
-- ["escort_state"] = 0,
|
|
-- ["marriage_name"] = "",
|
|
["level"] = "",
|
|
["god_id"] = 0,
|
|
["star_soul_id"] = 0,
|
|
["ser_id"] = 125,
|
|
["position_name"] = "",
|
|
["turn"] = 0,
|
|
["career"] = 0,
|
|
["position"] = 0,
|
|
["guild_id"] = 0,
|
|
["dsgt_id"] = 0,
|
|
["sprite_id"] = 607001,
|
|
["name"] = "信息自定义",
|
|
["ser_name"] = "one server",
|
|
["ser_id"] = server_id,
|
|
}
|
|
},
|
|
["channel"] = 1,
|
|
["voice_msg_time"] = 0,
|
|
["time"] = 1579058986,
|
|
["msg"] = "模拟信息自定义~~~~",
|
|
["client_ver"] = 0,
|
|
}
|
|
local transf_cache_list = {}
|
|
|
|
for k,v in pairs(self:GetVo11023( ).cache_list) do
|
|
transf_cache_list[k] = DeepCopy(creatMsg)
|
|
transf_cache_list[k].msg = v.msg
|
|
transf_cache_list[k].player_list[1].profile_photo_id = v.picture
|
|
transf_cache_list[k].player_list[1].sex = v.sex
|
|
transf_cache_list[k].player_list[1].vip_flag = v.vip --暂时没有vip
|
|
transf_cache_list[k].player_list[1].lv = v.lv
|
|
transf_cache_list[k].player_list[1].name = v.name
|
|
transf_cache_list[k].time = v.time
|
|
end
|
|
return transf_cache_list
|
|
-- self:AddMsg(msgVo)
|
|
|
|
end
|
|
|
|
function ChatModel:IsCrossServerChannel( channel_id )
|
|
return channel_id == ChatModel.CHANNEL_CROSS or
|
|
channel_id == ChatModel.CHANNEL_BEACH or
|
|
channel_id == ChatModel.CHANNEL_COUNTRY
|
|
end
|
|
|
|
-- 根据频道channel清除聊天缓存和聊天内容条目数量
|
|
function ChatModel:ClearAllMsgDataByChannel(channel)
|
|
if not channel then return end
|
|
self.all_chat_list[channel] = nil
|
|
self.all_chat_list_count[channel] = nil
|
|
end
|
|
|
|
----------主界面聊天社团图标红点-start---------
|
|
function ChatModel:SetGuildChannelRedDot( bool )
|
|
if self.has_new_guild_red == nil then
|
|
self.has_new_guild_red = 0
|
|
end
|
|
if bool then
|
|
self.has_new_guild_red = self.has_new_guild_red + 1
|
|
else
|
|
self.has_new_guild_red = 0
|
|
end
|
|
self:Fire(ChatModel.Update_MAINUI_GUILD_MSG_RED)
|
|
end
|
|
|
|
function ChatModel:GetGuildChannelRedDot( )
|
|
return self.has_new_guild_red or 0
|
|
end
|
|
|
|
-- 初始化登陆时间(用来区别历史消息)
|
|
function ChatModel:InitLoginTime( )
|
|
self.login_time_cache = TimeUtil:getServerTime()
|
|
self:SetGuildChannelRedDot( false )
|
|
end
|
|
----------主界面聊天社团图标红点-end-----------
|
|
|
|
--版本更新的提示
|
|
function ChatModel:SetClientUpdateInfo( vo )
|
|
self.client_update_info = vo
|
|
end
|
|
|
|
function ChatModel:GetClientUpdateInfo( )
|
|
return self.client_update_info
|
|
end
|