|
|
- ChatItem = ChatItem or BaseClass(BaseItem)
- local ChatItem = ChatItem
-
- local Config = Config
- local co = co
- local RoleManager = RoleManager
- local ChatModel = ChatModel
- local lua_resM = lua_resM
- local GlobalTimerQuest = GlobalTimerQuest
- local GlobalEventSystem = GlobalEventSystem
-
- local SetSizeDeltaX = SetSizeDeltaX
- local SetInlineText = SetInlineText
-
- function ChatItem:__init(parent_wnd,prefab_asset,layer_name,delay_callback,not_delay)
- self.base_file = "chat"
- self.layout_file = "chatItem"
- -- self.use_local_view = true
- self.is_chat = true
- self.is_delay_callback = true
- if not_delay then
- self.is_delay_callback = false
- end
-
- self.mainRoleVo = RoleManager:getInstance():GetMainRoleVo()
- self.show_type = 1 -- 1系统样式 2横线时间样式 3 显示世界聊天剩余次数 4 非主玩家说话样式 5 主角说话
- self.height = 0
- -- self.use_local_view = true
- self.role_text_width = 360
- self.role_text_offset = co.TableXY(75, 0)
-
- self.player_chatBg_offset = co.TableXY(90, -50)
- self.main_role_chatBg_offset = co.TableXY(-92, -42)
-
- self.player_text_offset = co.TableXY(41+1, -0)--(28-8+2, -3) --有气泡的时候调整
- self.player_default_text_offset = co.TableXY(41+1, 0)--无气泡的时候调整
- self.main_role_text_offset = co.TableXY(-40-1, 0) ---31+10+2, -3-8) --有气泡的时候调整
- self.main_role_default_text_offset = co.TableXY(-40-1, 0) --无气泡的时候调整
-
- self.role_bg_add_size = co.TableXY(50, 39)
- self.dress_bubble_role_bg_add_size = co.TableXY(50, 39)
- self.role_bg_min_size = co.TableXY(20, 56)
- self.voice_text_offset = co.TableXY(3 + 38, 14.6 + 5)
- self.voice_bg_add_size = co.TableXY(50 , 10)
- self.dress_bubble_color = "#f0b30e" --有气泡时候字体颜色
- self.dress_bubble_color_value = Color(240 / 255, 179 / 255, 14 / 255, 1) --有气泡时候字体颜色
- self.default_bubble_color_value = Color(169 / 255, 193 / 255, 225 / 255, 1)
- -- self.voice_bg_min_size = Vector2(135,0)
-
- self.beach_scale = 0.8 --海滩的等比例缩小
-
- self.assist_award_item_list = {}--小助手的聊天物品item列表
-
- self.model = ChatModel:getInstance()
- self:Load()
- end
-
- function ChatItem:Load_callback()
- -- 尽量用这种方式加新节点
- self.nodes = {
- "playerCon/nameCon/player_military_rank_icon:obj:img", -- 跨服军衔
- "mainRoleCon/nameCon/mainrole_military_rank_icon:obj:img", -- 跨服军衔
- "playerCon/nameCon/playerCon_voteBtn:obj", -- 温泉聊天 投标按钮
- "playerCon/assistAwardCon:obj",--小助手聊天中的物品item容器
- }
- self:GetChildren(self.nodes)
-
- self.player_btnVoice = self:GetChild("playerCon/btnVoice").gameObject
- self.player_img_voice1 = self:GetChild("playerCon/btnVoice/image1").gameObject
- self.player_img_voice2 = self:GetChild("playerCon/btnVoice/image2").gameObject
- self.player_img_voice3 = self:GetChild("playerCon/btnVoice/image3").gameObject
- self.playerCon = self:GetChild("playerCon").gameObject
- self.btnGift = self:GetChild("playerCon/nameCon/btnGift").gameObject
- self.player_vipCon = self:GetChild("playerCon/nameCon/vipCon").gameObject
- self.mainRoleCon_btnVoice = self:GetChild("mainRoleCon/btnVoice").gameObject
- self.mainRoleCon_img_voice1 = self:GetChild("mainRoleCon/btnVoice/image1").gameObject
- self.mainRoleCon_img_voice2 = self:GetChild("mainRoleCon/btnVoice/image2").gameObject
- self.mainRoleCon_img_voice3 = self:GetChild("mainRoleCon/btnVoice/image3").gameObject
- self.mainRole_vipCon = self:GetChild("mainRoleCon/nameCon/vipCon").gameObject
- self.systemCon = self:GetChild("systemCon").gameObject
- self.lineCon = self:GetChild("lineCon").gameObject
- self.speakCon = self:GetChild("SpeakCon").gameObject
- self.mainRoleCon = self:GetChild("mainRoleCon").gameObject
- self.player_gm_dot = self:GetChild("playerCon/nameCon/GMDot").gameObject
- self.player_gm_img_go = self:GetChild("playerCon/nameCon/GMImg").gameObject
- self.mainRole_gm_dot = self:GetChild("mainRoleCon/nameCon/GMDot").gameObject
- self.mainRole_gm_img_go = self:GetChild("mainRoleCon/nameCon/GMImg").gameObject
- self.player_zdy_dot = self:GetChild("playerCon/nameCon/ZDYDot").gameObject
- self.player_zdy_img_go = self:GetChild("playerCon/nameCon/ZDYImg").gameObject
- self.mainRole_zdy_dot = self:GetChild("mainRoleCon/nameCon/ZDYDot").gameObject
- self.mainRole_zdy_img_go = self:GetChild("mainRoleCon/nameCon/ZDYImg").gameObject
- self.mainRole_voiceClick = self:GetChild("mainRoleCon/voiceClick").gameObject
- self.player_voiceClick = self:GetChild("playerCon/voiceClick").gameObject
-
- self.playerHeadCon = self:GetChild("playerCon/headCon")
- self.playerNameCon = self:GetChild("playerCon/nameCon/nameText")
- self.player_vipIcon = self:GetChild("playerCon/nameCon/vipCon/vipIcon")
- self.player_sexIcon = self:GetChild("playerCon/nameCon/sexIcon")
- self.player_chatBg = self:GetChild("playerCon/chatBg")
- self.playerGuildDescrb = self:GetChild("playerCon/guild_descrb")
- self.mainRoleHeadCon = self:GetChild("mainRoleCon/headCon")
- self.mainRoleGuildDescrb = self:GetChild("mainRoleCon/guild_descrb")
- self.mainRole_pos = self:GetChild("mainRoleCon/nameCon/posIcon")
- self.mainRole_vipIcon = self:GetChild("mainRoleCon/nameCon/vipCon/vipIcon")
- self.mainRole_sexIcon = self:GetChild("mainRoleCon/nameCon/sexIcon")
- self.mainRole_chatBg = self:GetChild("mainRoleCon/chatBg")
- self.system_bg = self:GetChild("systemCon/bg")
- self.system_beach_bg = self:GetChild("systemCon/bg_beach")
- self.system_contentText_tr = self:GetChild("systemCon/bg/contentText")
- self.system_beachText_tr = self:GetChild("systemCon/beachText")
- self.system_channelIcon_tr = self:GetChild("systemCon/channelIcon")
- self.player_contentText = self:GetChild("playerCon/contentText")
- self.mainRole_contentText = self:GetChild("mainRoleCon/contentText")
- self.mainRole_nameCon = self:GetChild("mainRoleCon/nameCon/nameText")
- self.mainRole_voiceClick_tr = self:GetChild("mainRoleCon/voiceClick")
- self.player_voiceClick_tr = self:GetChild("playerCon/voiceClick")
- self.mainRoleCon_tr = self:GetChild("mainRoleCon")
- self.playerCon_tr = self:GetChild("playerCon")
- self.lineCon_tr = self:GetChild("lineCon")
-
- self.system_img_bg = self:GetChild("systemCon/bg/bg")
- self.system_contentText2_tr = self:GetChild("systemCon/contentText") -- 系统消息用的文本 主要是对齐方式与不用
-
- self.player_chatBg_img = self:GetChild("playerCon/chatBg"):GetComponent("Image")
- self.mainRole_posIcon = self:GetChild("mainRoleCon/nameCon/posIcon"):GetComponent("Image")
- self.mainRole_chatBg_img = self:GetChild("mainRoleCon/chatBg"):GetComponent("Image")
- self.system_channelIcon = self:GetChild("systemCon/channelIcon"):GetComponent("Image")
- self.mainRole_headBoard_img = self:GetChild("mainRoleCon/mainRole_head_board"):GetComponent("Image")
- self.player_headBoard_img = self:GetChild("playerCon/player_head_board"):GetComponent("Image")
- self.player_rank_icon_img = self:GetChild("playerCon/nameCon/rank_txt_icon"):GetComponent("Image")
- self.mainRole_rank_icon_img = self:GetChild("mainRoleCon/nameCon/rank_txt_icon"):GetComponent("Image")
-
- self.player_voiceText = self:GetChild("playerCon/btnVoice/value"):GetComponent("Text")
- self.player_nameText = self:GetChild("playerCon/nameCon/nameText"):GetComponent("Text")
- self.player_contentText_t = self:GetChild("playerCon/contentText"):GetComponent("Text")
- self.player_addressText = self:GetChild("playerCon/addressText"):GetComponent("Text")
- self.mainRoleCon_voiceText = self:GetChild("mainRoleCon/btnVoice/value"):GetComponent("Text")
- self.mainRole_nameText = self:GetChild("mainRoleCon/nameCon/nameText"):GetComponent("Text")
- self.mainRole_contentText_t = self:GetChild("mainRoleCon/contentText"):GetComponent("Text")
- self.mainRole_addressText = self:GetChild("mainRoleCon/addressText"):GetComponent("Text")
- self.system_contentText = self:GetChild("systemCon/bg/contentText"):GetComponent("Text")
- self.system_contentText2 = self:GetChild("systemCon/contentText"):GetComponent("Text")
- self.system_beachText = self:GetChild("systemCon/beachText"):GetComponent("Text")
- self.line_timeText = self:GetChild("lineCon/timeText"):GetComponent("TextMeshProUGUI")
- self.chat_numText = self:GetChild("SpeakCon/amountText"):GetComponent("Text")
- self.playerGuild_txt = self:GetChild("playerCon/guild_descrb/text"):GetComponent("Text")
- self.mainRoleGuild_txt = self:GetChild("mainRoleCon/guild_descrb/text"):GetComponent("Text")
- -- self:GetChild("playerCon/contentText1").gameObject:SetActive(false)--先屏蔽
- local x = Config.ConfigChat.ChatItem.playerVoiceBtnPos.x
- local y = Config.ConfigChat.ChatItem.playerVoiceBtnPos.y
- self.player_btnVoice.transform.anchoredPosition = Vector2(x,y)
-
- x = Config.ConfigChat.ChatItem.mainRoleVoiceBtnPos.x
- y = Config.ConfigChat.ChatItem.mainRoleVoiceBtnPos.y
- self.mainRoleCon_btnVoice.transform.anchoredPosition = Vector2(x,y)
-
- -------------------------
- self.pos_x_systemCon, self.pos_y_systemCon = GetAnchoredPosition( self.systemCon.transform )
- -------------------------
-
- -- 调整消息间距
- SetAnchoredPositionX(self.mainRoleCon_tr, Config.ConfigChat.RIGHT_PLAYER_POSX)
- SetAnchoredPositionX(self.playerCon_tr, Config.ConfigChat.LEFT_PLAYER_POSX)
-
- -- self.mainRole_pos_pos = self.mainRole_pos.localPosition
- local function onPlayPlayerVoice( ... )
- if self.info and self.info.iType == ChatModel.MSG_TYPE.VOICE and self.info.voice_id then
- ChatVoiceManager:getInstance():SetVoiceVersion(self.info.voice_id, self.info.data_ver)
- local voice_vo = ChatVoiceManager:getInstance():GetVoice(self.info.voice_id)
- if voice_vo then
- ChatVoiceManager:getInstance():PlayVoice(self.info.voice_id)
- else
- ChatVoiceManager:getInstance():ClickPlay(self.info.voice_id)
- self.model:Fire(ChatModel.REQUEST_CCMD_EVENT, 11004, self.info.voice_id, self.info.player_id, self.info.time)
- end
- end
- end
- AddClickEvent(self.player_btnVoice, onPlayPlayerVoice)
- AddClickEvent(self.player_voiceClick, onPlayPlayerVoice)
-
- local function onPlayMainRoleVoice()
- if self.info and self.info.iType == ChatModel.MSG_TYPE.VOICE and self.info.voice_id then
- ChatVoiceManager:getInstance():SetVoiceVersion(self.info.voice_id, self.info.data_ver)
- local voice_vo = ChatVoiceManager:getInstance():GetVoice(self.info.voice_id)
- if voice_vo then
- ChatVoiceManager:getInstance():PlayVoice(self.info.voice_id)
- else
- ChatVoiceManager:getInstance():ClickPlay(self.info.voice_id)
- self.model:Fire(ChatModel.REQUEST_CCMD_EVENT, 11004, self.info.voice_id, self.info.player_id, self.info.time)
- end
- end
- end
- AddClickEvent(self.mainRoleCon_btnVoice, onPlayMainRoleVoice)
- AddClickEvent(self.mainRole_voiceClick, onPlayMainRoleVoice)
-
- -- 必须先设为false 不然表情会显示不出来
- self.mainRoleCon:SetActive(false)
- self.playerCon:SetActive(false)
-
- if self.need_refreshData then
- self:SetData(self.info,self.layout_height)
- self:SetItemSize(self.size_x,self.size_y)
- end
- if self.color_cache then
- self.color_cache = false
- self:SetLineTimeColor(self.line_color)
- end
- if self.set_line_size_cache then
- self.set_line_size_cache = false
- self:SetLineSize(self.line_width ,self.line_bg_width)
- end
- end
- --删除了上面的item 自己也要改变位置
- function ChatItem:ReLayout(off_height)
- if self.transform then
- self.transform.localPosition = Vector3(0, self.transform.localPosition.y + off_height, 0)
- end
- end
-
- function ChatItem:SetData(info, layout_height)
- self.info = info
- self.layout_height = layout_height
- if self.wait_set_local_y then
- self:SetLocalPositionY(self.wait_set_local_y)
- else
- self:SetAnchoredPosition(0,-layout_height,0)
- end
- if not self.is_loaded then
- self.need_refreshData = true
- return
- end
- if not self.transform then return end
- self.info = info
- -- self.transform.localPosition = Vector3(0, -layout_height, 0)
- self:SetVisible(true)
- self.height = 0
- --local channel_icon = self.info.channel_icon or self.info.channel
- -- local text_color = self.info.channel == ChatModel.CHANNEL_HORN and "#FF3A00" or "#323232"
-
- -- local icon = nil
- -- local color = nil
- -- if self.info.tip and self.info.tip ~= 0 then
- -- icon,color = self.model:GetTipWithShowType(self.info.tip)
- -- else
- -- icon = self.model:GetChannelIconWithChannel(self.info.channel)
- -- color = self.model:GetChannelColorWithChannel(self.info.channel)
- -- end
- --根据subtype(showtype)来控制chatitem的样式
-
- --在聊天栏部分颜色需要进行一次转换
- channel = self.info.showtype == nil and self.info.channel or self.info.showtype
- local chat_color_is_chat_view = channel and channel ~= ChatModel.CHANNEL_SYSTEM and channel ~= ChatModel.CHANNEL_GENERAL and channel ~= ChatModel.CHANNEL_HORN
- local text_color = "#f3fcff" --channel == ChatModel.CHANNEL_HORN and ColorUtil.YELLOW or ColorUtil.WHITE
- -- print("ChatItem:SetData 说了啥", self.info.msg)
- if self.info.msg then
- self.info.msg = Util.SetNonBreakSpaceText(self.info.msg)
- end
- local call_fun = function (param_list)
- self:CilckContentHandle(param_list)
- end
-
- if self.type_id and string.find(self.type_id,"beachChat") then
- if channel == ChatModel.CHANNEL_SYSTEM then
- SetAnchoredPosition( self.systemCon.transform, self.pos_x_systemCon+15, self.pos_y_systemCon+8 )
- else
- SetAnchoredPosition( self.systemCon.transform, self.pos_x_systemCon, self.pos_y_systemCon )
- end
- end
- -------------------------
- if channel == ChatModel.CHANNEL_SYSTEM then
- self.show_type = 1
- self.playerCon:SetActive(false)
- self.systemCon:SetActive(true)
- self.lineCon:SetActive(false)
- self.mainRoleCon:SetActive(false)
- self.speakCon:SetActive(false)
-
- -- local icon = nilf self.info.tip and self.info.tip ~= 0 then
- -- -- --增加飘字
- -- -- Message.show(self.info.msg)
- -- icon, text_color = self.model:GetTipWithShowType(self.info.tip)
- -- self.system_contentText.text = "<color="..text_color..">"..self.info.msg.."</color>"
- -- else
- -- print("=============>>> YiRan:ChatItem [start:295] self.info ------------------------------------------")
- -- PrintTable(self.info)
- -- print("=============>>> YiRan:ChatItem [end] ------------------------------------------")
- local icon = "chat_channel_20"
- --self.system_bg.gameObject:SetActive(false)
- self.system_img_bg.gameObject:SetActive(false)
- self.system_beach_bg.gameObject:SetActive(false)
- self.system_contentText.text = ""
- self.system_beachText.text = ""
- self.system_contentText2.text = ""
-
- local is_chuanwen = false
- if self.info.chuanwen_type and self.info.chuanwen_type == ChatModel.CHUANWEN_TYPE.UP_CHUANWEN then
- --如果是传闻类型
- icon = "chat_channel_20"
- is_chuanwen = true
- -- if self.info.tip and self.info.type == 1 then --这个字段用来加框
- --self.system_bg.gameObject:SetActive(true)
- self.system_img_bg.gameObject:SetActive(true)
- -- Message.show("self.info",self.info.msg)
- -- end
- else
- icon = self.model:GetChannelIconWithChannel(self.info.channel)
- end
-
- local fitHeight = 0
- local text_size = 0
- -------------------------
- if self.type_id and string.find(self.type_id,"beachChat") then
- --温泉要特殊表现
- local content_str = "<color=#a9c1e1>"..self.info.msg.."</color>"
- self.system_beachText.text = content_str
- SetInlineText(self.system_beachText, content_str,self.info.url,chat_color_is_chat_view)
- AddUnderLineAndClick(self, self.system_beachText_tr, call_fun)
- self.system_channelIcon_tr.gameObject:SetActive(false)
- fitHeight = 23 + self.system_beachText.preferredHeight
- text_size = Vector2(421.3, fitHeight)
- self.system_beachText_tr.sizeDelta = text_size
- self.system_beach_bg.gameObject:SetActive(true)
- self.system_bg.gameObject:SetActive(false)
- else
- -------------------------
- -- 传闻有特殊样式 不需要显示
- local content
- local content_tr
- self.system_contentText_tr.gameObject:SetActive(false)
- self.system_contentText2_tr.gameObject:SetActive(false)
- if is_chuanwen then
- content = self.system_contentText
- content_tr = self.system_contentText_tr
- self.system_channelIcon_tr.gameObject:SetActive(false)
- else
- content = self.system_contentText2
- content_tr = self.system_contentText2_tr
- self.system_channelIcon_tr.gameObject:SetActive(true)
- end
- content_tr.gameObject:SetActive(true)
- local content_str = "<color="..text_color..">"..self.info.msg.."</color>"
- content.color = self.default_bubble_color_value
- content.text = content_str
-
- lua_resM:setImageSprite(self, self.system_channelIcon, "mainUI_asset", icon) --设置图标
- SetInlineText(content, content_str,self.info.url, chat_color_is_chat_view)
- AddUnderLineAndClick(self, content_tr, call_fun)
-
- fitHeight = 19 + content.preferredHeight
- text_size = Vector2(421.3, fitHeight)
- content_tr.sizeDelta = text_size
- if is_chuanwen and content.preferredHeight > 20 then -- 超过一行的话 挪一下位置
- SetAnchoredPositionY(content_tr, 11.5)
- elseif is_chuanwen then
- SetAnchoredPositionY(content_tr, 21)
- end
-
- self.system_bg.gameObject:SetActive(true)
- end
- -------------------------
- fitHeight = fitHeight < Config.ConfigChat.Chuanwen_space and Config.ConfigChat.Chuanwen_space or fitHeight
- --终于找到= =。 巨坑这里, 文本高度的判断最终在chatview,chatview预制物体里自带了几个text框来找preferredHeight再扔回chatitem~~~!!!!
- --self.height = Config.ConfigChat.Sys_item_space + fitHeight -- 这个height不起效~~@@@!!!
-
- self.system_bg.sizeDelta = Vector2(512, fitHeight)
- self.height = 20
- elseif self.info.is_line then
- self.show_type = 2
- self.playerCon:SetActive(false)
- self.systemCon:SetActive(false)
- self.lineCon:SetActive(true)
- self.mainRoleCon:SetActive(false)
- self.speakCon:SetActive(false)
- self.line_timeText.text = TimeUtil:timeConversion(self.info.time, "mm-dd hh-MM")
- self.height = 30
-
- if channel == ChatModel.CHANNEL_CECRET then--重置,为了私聊好友界面的主角坐标设置
- self.lineCon_tr.anchoredPosition = Vector2(40,-13)
- else
- self.lineCon_tr.anchoredPosition = Vector2(-23,-13)
- end
-
- elseif self.info.show_num then
- self.show_type = 3
- self.playerCon:SetActive(false)
- self.systemCon:SetActive(false)
- self.lineCon:SetActive(false)
- self.mainRoleCon:SetActive(false)
- self.speakCon:SetActive(true)
- if self.info.chat_method == 0 then
- self.chat_numText.text = "您在世界聊天的次数剩余<color=#73AC44FF>" .. info.amount .. "</color>次"
- else
- self.chat_numText.text = "您使用世界发言凭证发言<color=#73AC44FF>1</color>次"
- end
- self.height = 30
- elseif self.info.player_id ~= RoleManager.Instance:GetMainRoleId() then
- self.show_type = 4
- self.playerCon:SetActive(true)
- self.systemCon:SetActive(false)
- self.lineCon:SetActive(false)
- self.mainRoleCon:SetActive(false)
- self.speakCon:SetActive(false)
- local function is_cs_chat( )
- return (self.info.ser_id ~= RoleManager.Instance:GetMainRoleServerId()) or self.model:IsCrossServerChannel( channel )
- end
- --local name_color = string.find(self.type_id or "","beachChat") and '#ffffff' or '#f3fcff'
- local name_color = '#ffffff'
- self.player_nameText.text = HtmlColorTxt( is_cs_chat() and GetCSLongName( self.info.name, self.info.ser_num ) or self.info.name ,name_color )
- self.player_addressText.text = "<color=#FFD797>(广东·深圳)</color>"
- self.player_gm_dot:SetActive(info.GM == 1)
- self.player_gm_img_go:SetActive(info.GM == 1)
- self.player_zdy_dot:SetActive(info.GM == 2)
- self.player_zdy_img_go:SetActive(info.GM == 2)
- --[[if string.find(self.info.msg,"<a@redenvelopes>") then --红包链接要加上红包图片
- if not self.img_player_red_packet then
- self.img_player_red_packet = UiFactory.createChild(self.playerCon.transform,UIType.Image,"Image")
- end
- self.img_player_red_packet:SetActive(true)
- lua_resM:setImageSprite(self, self.img_player_red_packet:GetComponent("Image"), "mainUI_asset", "mainui_red", true)
- self.img_player_red_packet.transform.anchoredPosition = Vector2(-90,-24)
- self.info.msg = "\n\n\n"..Trim(self.info.msg)
- AddClickEvent(self.img_player_red_packet, function()
- GlobalEventSystem:Fire(EventName.OPEN_GUILD_MAIN_VIEW,1,4)
- end)
- elseif self.img_player_red_packet then
- self.img_player_red_packet:SetActive(false)
- end]]
-
- --[[if string.find(self.info.msg,"<a@actredenvelopes>") then --活动红包链接要加上红包图片
- if not self.img_player_red_packet then
- self.img_player_red_packet = UiFactory.createChild(self.playerCon.transform,UIType.Image,"Image")
- end
- self.img_player_red_packet:SetActive(true)
- lua_resM:setImageSprite(self, self.img_player_red_packet:GetComponent("Image"), "mainUI_asset", "mainui_red", true)
- self.img_player_red_packet.transform.anchoredPosition = Vector2(-90,-24)
- self.info.msg = "\n\n\n"..Trim(self.info.msg)
- AddClickEvent(self.img_player_red_packet, function()
- local act = CustomActivityModel:getInstance():getActList(CustomActivityModel.CustomActBaseType.ACT_RED_BAG)
- if act ~= nil then
- GlobalEventSystem:Fire(EventName.OPEN_OPERATION_ACTIVITY_VIEW,act.base_type,act.sub_type)
- else
- Message.show("活动未开启")
- end
- end)
- elseif self.img_player_red_packet then
- self.img_player_red_packet:SetActive(false)
- end--]]
-
- --社团名字
- if self.mainRoleVo.level < Config.Modulesub["110@2"].open_lv then --等级不够不显示
- self.playerGuildDescrb.gameObject:SetActive(false)
- else
- self.playerGuildDescrb.gameObject:SetActive(true)
- local player_guild_name = ""
- self.playerGuild_txt.text = player_guild_name
- if info.guild_name and info.guild_name ~= "" then
- player_guild_name = info.guild_name
- elseif info.player_list and info.player_list[1].guild_name and info.player_list[1].guild_name ~= "" then
- player_guild_name = info.player_list[1].guild_name
- else
- self.playerGuildDescrb.gameObject:SetActive(false)
- end
- self.playerGuild_txt.text = player_guild_name
- --
- SetSizeDeltaX(self.playerGuildDescrb, self.playerGuild_txt.preferredWidth + 10)
- --
- end
-
- lua_resM:setImageSprite(self, self.player_chatBg_img, "chat_asset", "tyui_chat", false)-- "chat_asset", "chat_default_bg", false)--"common_asset", "tyui_qp1_1", false)--
- local player_dress_bubble = false
- if info.dress_list then
- for i, v in ipairs(info.dress_list) do
- --1气泡 2相框
- if v.dress_id ~= 0 then
- local icon_name = v.dress_id
- if v.dress_type == 2 then
- info.dress_board = icon_name
- -- if icon_name and icon_name~= 0 then
- -- lua_resM:setOutsideImageSprite(self, self.player_headBoard_img, GameResPath.GetChatDressIcon(icon_name), false)
- -- self.player_headBoard_img.gameObject:SetActive(true)
- -- else
- -- self.player_headBoard_img.gameObject:SetActive(false)
- -- end
- elseif v.dress_type == 1 then
- player_dress_bubble = Trim(icon_name)
- -- Message.show("icon_name:",icon_name)
- if icon_name and icon_name~= 0 then
- lua_resM:setOutsideImageSprite(self, self.player_chatBg_img, GameResPath.GetChatDressIcon(player_dress_bubble), false)
- end
- end
- end
- end
- else
- self.player_headBoard_img.gameObject:SetActive(false)
- end
-
- if main_role_dress_bubble ~= false and Config.ConfigChatTextColor[player_dress_bubble] then
- self.player_contentText_t.color = Config.ConfigChatTextColor[player_dress_bubble]
- else
- self.player_contentText_t.color = self.default_bubble_color_value
- end
-
- --添加超链接
- self.player_contentText.sizeDelta = Vector2(self.role_text_width, 0)
- self.assistAwardCon_obj:SetActive(false)
- if self.info.msg == "" then --语音信息有时候为空
- self.player_contentText_t.text = ""
- else
- --小助手部分聊天内容不存全部信息到cookies,改成代号转化前端配置
- if self.info.player_id == 1 then
- local assist_final_msg = ""
- if Config.AssistantChat.AssistChatCode[self.info.msg] then
- --如果是笑话,要随机选择一个
- if Config.AssistantChat.AssistChatCode[self.info.msg].is_joke then
- local random_num = math.random(1, TableSize(Config.AssistantChat.AssistChatCode[self.info.msg].joke_list))
- assist_final_msg = ChuanWenManager:FormatColorTag(Config.AssistantChat.AssistChatCode[self.info.msg].joke_list[random_num])
- else
- assist_final_msg = ChuanWenManager:FormatColorTag(Config.AssistantChat.AssistChatCode[self.info.msg].msg)
- end
- --展示物品
- if Config.AssistantChat.AssistChatCode[self.info.msg].show_goods_id then
- self.assistAwardCon_obj:SetActive(true)
- for k,v in pairs(self.assist_award_item_list) do
- v:SetVisible(false)
- end
- for i,v in ipairs(Config.AssistantChat.AssistChatCode[self.info.msg].show_goods_id) do
- local item = self.assist_award_item_list[i]
- if not item then
- item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.assistAwardCon)
- self.assist_award_item_list[i] = item
- end
- item:SetItemSize(62, 62)
- item:SetVisible(true)
- local goods_type_id = v
- item:SetData(goods_type_id)
- --如果需要对物品item单独进行坐标设置,这个值必传,否则就默认排列物品
- if Config.AssistantChat.AssistChatCode[self.info.msg].show_goods_pos then
- local pos_x = Config.AssistantChat.AssistChatCode[self.info.msg].show_goods_pos[i][1]
- local pos_y = Config.AssistantChat.AssistChatCode[self.info.msg].show_goods_pos[i][2]
- item:SetAnchoredPosition(pos_x,pos_y)
- else
- item:SetAnchoredPosition((62+20)*(i-1),-28)
- end
- end
- end
- else
- assist_final_msg = self.info.msg
- end
- SetInlineText(self.player_contentText_t, assist_final_msg,nil,chat_color_is_chat_view)
- else
- SetInlineText(self.player_contentText_t, self.info.msg,nil,chat_color_is_chat_view)
- end
- end
- -- SetInlineText(self.player_contentText_t, "<color="..text_color..">"..self.info.msg.."</color>")
- AddUnderLineAndClick(self, self.player_contentText, call_fun)
-
- if not self.playHeadItem then
- self.playHeadItem = HeadRoleItem.New(self.playerHeadCon)
- self.playHeadItem:SetItemSize(70,70)
- end
- local head_data = { --把info传进去好辨认是否外服 + 生成 operationview
- vo = {
- info = info,
- id = info.player_id,
- use_bg = 3,
- career = 0 ,
- server_id = info.ser_id,
- sex = info.sex,
- turn = info.turn,
- board = info.dress_board,
- picture_ver = info.picture_ver,
- picture = info.picture,
- profile_photo_id = info.profile_photo_id,
- dress_board_id = info.dress_board,
- },
- }-- level = info.level,
- self.playHeadItem:SetData(head_data)
- local long_click_call_back = function ()
- self.model:Fire(ChatModel.SELECT_OTHER_PLAYER, info.name)
- end
- self.playHeadItem:SetLongClickCall(long_click_call_back)
-
- local text_size = co.TableXY(math.min(self.role_text_width, self.player_contentText_t.preferredWidth), self.player_contentText_t.preferredHeight)
- self.player_contentText.sizeDelta = text_size--Vector2(self.role_text_width, text_size.y)
-
-
- --self.playerHeadCon.anchoredPosition = Vector2(-195,-text_size.y+22.5 -6.9)
- -- self.playerGuildDescrb.anchoredPosition = Vector2(-195,-text_size.y+22.5 -49.3)
- --对方
- local bg_size = player_dress_bubble and self.dress_bubble_role_bg_add_size or self.role_bg_add_size
- local text_offset = player_dress_bubble and self.player_text_offset or self.player_default_text_offset
- if player_dress_bubble and Config.ConfigChatDress.Pos[player_dress_bubble] then
- local addTable = Config.ConfigChatDress.Pos[player_dress_bubble]
- text_offset = co.AddXY(text_offset,co.TableXY(addTable.pos_x,addTable.pos_y)) --+ Vector2(addTable.pos_x,addTable.pos_y)
- bg_size = co.AddXY(bg_size,co.TableXY(addTable.size_x,addTable.size_y))
- end
-
- if info.iType == ChatModel.MSG_TYPE.VOICE then
- local voiceVo = ChatVoiceManager:getInstance():GetVoice(info.voice_id)
- if voiceVo then
- local leftTime = voiceVo:IsPlaying()
- if leftTime then
- self:PlayAnim(leftTime)
- else
- self:SetPlayState(3)
- end
- else
- self:SetPlayState(3)
- end
- self.player_voiceText.text = info.length.."''"
- self.player_btnVoice:SetActive(true)
- self.player_voiceClick:SetActive(true)
- local text_size_x = math.max(65,text_size.x) --最少要50
- self.player_chatBg.sizeDelta = Vector2(bg_size.x + text_size_x, bg_size.y + text_size.y + self.voice_bg_add_size.y)
- self.player_chatBg.anchoredPosition = Vector2(self.player_chatBg_offset.x, self.player_chatBg_offset.y)
- self.player_contentText.anchoredPosition = Vector3(self.role_text_offset.x + text_size_x/ 2 + text_offset.x, self.player_chatBg.localPosition.y - self.player_chatBg.sizeDelta.y + text_size.y / 2 + self.voice_text_offset.y)
- self.player_voiceClick_tr.sizeDelta = self.player_chatBg.sizeDelta
- self.player_voiceClick_tr.anchoredPosition = self.player_chatBg.anchoredPosition
- else
- self.player_btnVoice:SetActive(false)
- self.player_voiceClick:SetActive(false)
- self.player_chatBg.sizeDelta = Vector2(bg_size.x + text_size.x, math.max(bg_size.y + text_size.y, self.role_bg_min_size.y))
- -- self.player_chatBg.anchoredPosition = Vector2(90,-33)
- self.player_chatBg.anchoredPosition = Vector2(self.player_chatBg_offset.x, self.player_chatBg_offset.y)
- self.player_contentText.anchoredPosition = Vector3(self.role_text_offset.x + text_size.x / 2 + text_offset.x, self.player_chatBg.localPosition.y - self.player_chatBg.sizeDelta.y / 2 + self.role_text_offset.y + text_offset.y)
- end
-
- self.speakCon:SetActive(false)
- self.height = self.player_chatBg.sizeDelta.y + 30
- self.height = math.max(self.height, 95)
-
- local namepos = self.playerNameCon.localPosition
- -- 2021/3/13 ===策划说不要显示性别===
- -- if info.sex and info.sex == 1 then
- -- lua_resM:setImageSprite(self, self.player_sexIcon:GetComponent("Image"), "common_asset", "com_boy", true)
- -- else
- -- lua_resM:setImageSprite(self, self.player_sexIcon:GetComponent("Image"), "common_asset", "com_girl", true)
- -- end
-
- -- print("=============>>> YiRan:ChatItem [start:524]info ------------------------------------------")
- -- PrintTable(info)
- --print("=============>>> YiRan:ChatItem [end] ------------------------------------------")
- if not self.player_vip_item then
- self.player_vip_item = RoleVipItem.New(self.player_vipIcon)
- end
- --如果是Ai助手
- if self.info.player_id == 1 then
- lua_resM:setImageSprite(self,self.player_vipIcon:GetComponent("Image"), "sociality_asset", "sociality_asistant_icon",true)
- self.player_vip_item:SetData(0, 0)
- else
- -- 如果vip等级为零 则不空出vip的图标位置
- if (info.vip_flag and info.vip_flag == 0) or not info.vip_flag then
- self.player_vipCon:GetComponent("Text").text = ""
- else
- self.player_vipCon:GetComponent("Text").text = " "
- end
- -- 设置vip图标数据
- lua_resM:setImageSprite(self,self.player_vipIcon:GetComponent("Image"), "uiComponent_asset", "com_empty")
- self.player_vip_item:SetData(info.vip_flag, info.sup_vip_type)
- end
-
- --排行icon显示
- if (self.info.player_list and self.info.player_list[1] and self.info.player_list[1].is_overlord and self.info.player_list[1].is_overlord > 0) or (self.info.is_overlord and self.info.is_overlord > 0) then
- if self.info.is_overlord then
- lua_resM:setImageSprite(self,self.player_rank_icon_img, "chat_asset","chat_overlord"..self.info.is_overlord.."_pointfilter",true)
- else
- lua_resM:setImageSprite(self,self.player_rank_icon_img, "chat_asset","chat_overlord"..self.info.player_list[1].is_overlord.."_pointfilter",true)
- end
- self.player_rank_icon_img.gameObject:SetActive(true)
- else
- local res_rank_name = self:GetRankIconResName(self.info.player_id)
- if not res_rank_name then
- res_rank_name = self:GetRankIconResName2(self.info.lv_rank, self.info.combat_rank)
- end
- if res_rank_name then
- lua_resM:setImageSprite(self,self.player_rank_icon_img, "chat_asset",res_rank_name,true)
- self.player_rank_icon_img.gameObject:SetActive(true)
- else
- self.player_rank_icon_img.gameObject:SetActive(false)
- end
- end
- ------------------------
- -- 跨国团战 军衔
- local player_data = nil
- if self.info.player_list and self.info.player_list[1] then
- player_data = self.info.player_list[1]
- end
- if (player_data and player_data.military_ranks and player_data.military_ranks > 0) or
- (self.info.military_ranks and self.info.military_ranks > 0) then
- local m_rank = self.info.military_ranks and
- self.info.military_ranks or
- player_data.military_ranks
- lua_resM:setOutsideImageSprite(self, self.player_military_rank_icon_img,
- GameResPath.GetMilitaryImage("military_ranks_"..m_rank), true)
- self.player_military_rank_icon_obj:SetActive(true)
- else
- self.player_military_rank_icon_obj:SetActive(false)
- end
- -------------------------
- local is_beach_chat = self.type_id and string.find(self.type_id, "beachChat")
- self.playerCon_voteBtn_obj:SetActive(is_beach_chat ~= nil)
- if (not is_beach_chat) then
- SetLocalScale(self.playerCon_tr, 1,1,1)
- RemoveClickEvent(self.playerCon_voteBtn_obj)
- else
- SetLocalScale(self.playerCon_tr, self.beach_scale,self.beach_scale,self.beach_scale)
- -- 添加点击投票事件
- local function on_click_vote( ... )
- local beach_model = BeachModel:GetInstance()
- local cur_time = TimeUtil:getServerTimeMs()
- if beach_model.vote_clock and (beach_model.vote_clock > cur_time) then
- return
- end
- -------------------------
- local num = 0
- local data = beach_model:GetMyInfo( )
- if data then
- num = data.vote_times or 0
- end
- if num > 0 then
- local name_str = GetCSLongName( self.info.name, info.ser_id )
- beach_model:VoteToOher(name_str, self.info.player_id)
- else
- beach_model:Fire(BeachConst.OPEN_BUY_VOTE)
- end
- end
- AddClickEvent(self.playerCon_voteBtn_obj, on_click_vote)
- end
- elseif self.info.player_id == RoleManager.Instance:GetMainRoleId() then
- self.show_type = 5
- self.playerCon:SetActive(false)
- self.systemCon:SetActive(false)
- self.lineCon:SetActive(false)
- self.mainRoleCon:SetActive(true)
- self.speakCon:SetActive(false)
-
- local function is_cs_chat( )
- return (self.info.ser_id ~= RoleManager.Instance:GetMainRoleServerId()) or self.model:IsCrossServerChannel( channel )
- end
- --local name_color = string.find(self.type_id or "","beachChat") and '#ffffff' or '#ffffff'
- local name_color = '#ffffff'
- self.mainRole_nameText.text = HtmlColorTxt( is_cs_chat() and GetCSLongName( info.name, self.info.ser_num ) or info.name , name_color)
- self.mainRole_addressText.text = "<color=#FFD797>(广东·广州)</color>"
- self.mainRole_gm_dot:SetActive(info.GM == 1)
- self.mainRole_gm_img_go:SetActive(info.GM == 1)
- self.mainRole_zdy_dot:SetActive(info.GM == 2)
- self.mainRole_zdy_img_go:SetActive(info.GM == 2)
-
- if channel == ChatModel.CHANNEL_CECRET then--重置,为了私聊好友界面的主角坐标设置
- SetAnchoredPositionY(self.mainRoleCon_tr,-10)
- else
- SetAnchoredPositionY(self.mainRoleCon_tr,0)
- end
- --[[if string.find(self.info.msg,"<a@redenvelopes>") then --红包链接要加上红包图片
- if not self.img_mainrole_red_packet then
- self.img_mainrole_red_packet = UiFactory.createChild(self.mainRoleCon.transform,UIType.Image,"Image")
- end
- self.img_mainrole_red_packet:SetActive(true)
- lua_resM:setImageSprite(self, self.img_mainrole_red_packet:GetComponent("Image"), "mainUI_asset", "mainui_red", true)
- self.img_mainrole_red_packet.transform.anchoredPosition = Vector2(90,-20)
- self.info.msg = "\n\n\n"..Trim(self.info.msg)
- AddClickEvent(self.img_mainrole_red_packet, function()
- GlobalEventSystem:Fire(EventName.OPEN_GUILD_MAIN_VIEW,1,4)
- end)
- elseif self.img_mainrole_red_packet then
- self.img_mainrole_red_packet:SetActive(false)
- end]]
-
- --[[if string.find(self.info.msg,"<a@actredenvelopes>") then --活动红包链接要加上红包图片
- if not self.img_mainrole_red_packet then
- self.img_mainrole_red_packet = UiFactory.createChild(self.mainRoleCon.transform,UIType.Image,"Image")
- end
- self.img_mainrole_red_packet:SetActive(true)
- lua_resM:setImageSprite(self, self.img_mainrole_red_packet:GetComponent("Image"), "mainUI_asset", "mainui_red", true)
- self.img_mainrole_red_packet.transform.anchoredPosition = Vector2(90,-20)
- self.info.msg = "\n\n\n"..Trim(self.info.msg)
- AddClickEvent(self.img_mainrole_red_packet, function()
- local act = CustomActivityModel:getInstance():getActList(CustomActivityModel.CustomActBaseType.ACT_RED_BAG)
- if act ~= nil then
- GlobalEventSystem:Fire(EventName.OPEN_OPERATION_ACTIVITY_VIEW,act.base_type,act.sub_type)
- else
- Message.show("活动未开启")
- end
- end)
- elseif self.img_mainrole_red_packet then
- self.img_mainrole_red_packet:SetActive(false)
- end--]]
-
- if self.mainRoleVo.level < Config.Modulesub["110@2"].open_lv then --等级不够不显示
- self.mainRoleGuildDescrb.gameObject:SetActive(false)
- else
- --社团名字
- self.mainRoleGuildDescrb.gameObject:SetActive(true)
- local main_role_guild_name = ""
- self.playerGuild_txt.text = main_role_guild_name
- if info.guild_name and info.guild_name ~= "" then
- main_role_guild_name = info.guild_name
- elseif info.player_list and info.player_list[1].guild_name and info.player_list[1].guild_name ~= "" then
- main_role_guild_name = info.player_list[1].guild_name
- else -- 无社团
- self.mainRoleGuildDescrb.gameObject:SetActive(false)
- end
- self.mainRoleGuild_txt.text = main_role_guild_name
- end
-
- SetSizeDeltaX(self.mainRoleGuildDescrb, self.mainRoleGuild_txt.preferredWidth + 10)
-
- --
- --"common_asset", "tyui_qp1_1", false)-- "chat_asset", "chat_default_bg", false)--tyui_chat
- local main_role_dress_bubble = 425001--气泡类型
- if info.dress_list then
- for i, v in ipairs(info.dress_list) do
- --1气泡 2相框
- if v.dress_id ~= 0 then
- local icon_name = v.dress_id
- if v.dress_type == 2 then
- info.dress_board = icon_name
- -- if info.dress_board and info.dress_board ~= 0 then
- -- lua_resM:setOutsideImageSprite(self, self.mainRole_headBoard_img, GameResPath.GetChatDressIcon(info.dress_board), false)
- -- self.mainRole_headBoard_img.gameObject:SetActive(true)
- -- else
- -- self.mainRole_headBoard_img.gameObject:SetActive(false)
- -- end
- elseif v.dress_type == 1 then
- main_role_dress_bubble = Trim(icon_name)
- if main_role_dress_bubble and main_role_dress_bubble ~= 0 then
- lua_resM:setOutsideImageSprite(self, self.mainRole_chatBg_img, GameResPath.GetChatDressIcon(main_role_dress_bubble), false)
- end
- end
- end
- end
- end
-
- if main_role_dress_bubble ~= false and Config.ConfigChatTextColor[main_role_dress_bubble] then
- self.mainRole_contentText_t.color = Config.ConfigChatTextColor[main_role_dress_bubble]
- else
- self.mainRole_contentText_t.color = self.default_bubble_color_value
- end
-
- --添加超链接
- self.mainRole_contentText.sizeDelta = Vector2(self.role_text_width, 0)
- if self.info.msg == "" then --语音信息有时候为空
- self.mainRole_contentText_t.text = ""
- else
- SetInlineText(self.mainRole_contentText_t, self.info.msg,nil,chat_color_is_chat_view)
- end
- -- SetInlineText(self.mainRole_contentText_t, "<color="..text_color..">"..self.info.msg.."</color>")
- AddUnderLineAndClick(self, self.mainRole_contentText, call_fun)
-
- -- ===2021/3/13 策划说不要显示性别====
- -- if info.sex == 1 then
- -- lua_resM:setImageSprite(self, self.mainRole_sexIcon:GetComponent("Image"), "common_asset", "com_boy", true)
- -- else
- -- lua_resM:setImageSprite(self, self.mainRole_sexIcon:GetComponent("Image"), "common_asset", "com_girl", true)
- -- end
-
- if not self.mainRole_vip_item then
- self.mainRole_vip_item = RoleVipItem.New(self.mainRole_vipIcon)
- end
- self.mainRole_vip_item:SetData(info.vip_flag,info.sup_vip_type)
-
- ---
- --排行icon显示
- local player_data = nil
- if self.info.player_list and self.info.player_list[1] then
- player_data = self.info.player_list[1]
- end
-
- -- 战力第一/等级第一/霸主 等头衔显示
- if (player_data and player_data.is_overlord and player_data.is_overlord > 0) or
- (self.info.is_overlord and self.info.is_overlord > 0) then
- if self.info.is_overlord then
- lua_resM:setImageSprite(self,self.mainRole_rank_icon_img, "chat_asset","chat_overlord"..self.info.is_overlord.."_pointfilter",true)
- else
- lua_resM:setImageSprite(self,self.mainRole_rank_icon_img, "chat_asset","chat_overlord".. player_data.is_overlord.."_pointfilter",true)
- end
- self.mainRole_rank_icon_img.gameObject:SetActive(true)
- else
- local res_rank_name = self:GetRankIconResName(self.info.player_id)
- if res_rank_name then
- lua_resM:setImageSprite(self,self.mainRole_rank_icon_img, "chat_asset",res_rank_name,true)
- self.mainRole_rank_icon_img.gameObject:SetActive(true)
- else
- self.mainRole_rank_icon_img.gameObject:SetActive(false)
- end
- end
-
- -- 跨国团战 军衔
- if (player_data and player_data.military_ranks and player_data.military_ranks > 0) or
- (self.info.military_ranks and self.info.military_ranks > 0) then
- local m_rank = self.info.military_ranks and
- self.info.military_ranks or
- player_data.military_ranks
- lua_resM:setOutsideImageSprite(self, self.mainrole_military_rank_icon_img,
- GameResPath.GetMilitaryImage("military_ranks_"..m_rank), true)
- self.mainrole_military_rank_icon_obj:SetActive(true)
- else
- self.mainrole_military_rank_icon_obj:SetActive(false)
- end
-
-
- local is_beach_chat = self.type_id and string.find(self.type_id,"beachChat")
- if (not is_beach_chat) then
- SetLocalScale(self.mainRoleCon_tr, 1,1,1)
- else
- SetLocalScale(self.mainRoleCon_tr, self.beach_scale,self.beach_scale,self.beach_scale)
- end
-
- if not self.mainRoleHeadItem then
- self.mainRoleHeadItem = HeadRoleItem.New(self.mainRoleHeadCon)
- self.mainRoleHeadItem:SetItemSize(70,70)
- end
- local head_data = { --career = info.career
- vo = {
- id = info.player_id,
- use_bg = 3,
- career = 0,
- sex = info.sex,
- turn = info.turn,
- board = info.dress_board,
- picture_ver = info.picture_ver,
- picture = info.picture,
- profile_photo_id = info.profile_photo_id,
- dress_board_id = info.dress_board,
- },
- }--level = info.level,
- self.mainRoleHeadItem:SetData(head_data)
-
- local text_size = co.TableXY(math.min(self.role_text_width, self.mainRole_contentText_t.preferredWidth), self.mainRole_contentText_t.preferredHeight)
- self.mainRole_contentText.sizeDelta = text_size --Vector2(self.role_text_width, text_size.y)
- --self.mainRoleHeadCon.anchoredPosition = Vector2(195,text_size.y) -- 头像跟随气泡箭头位移
- -- self.mainRoleHeadCon.anchoredPosition = Vector2(195,-text_size.y+22.5)
- -- self.mainRoleGuildDescrb.anchoredPosition = Vector2(195,-text_size.y+22.5 -43.3)
-
- --主角
- local text_offset = main_role_dress_bubble and self.main_role_text_offset or self.main_role_default_text_offset
- local bg_add_size = main_role_dress_bubble and self.dress_bubble_role_bg_add_size or self.role_bg_add_size
- if main_role_dress_bubble and Config.ConfigChatDress.Pos[main_role_dress_bubble] then
- local addTable = Config.ConfigChatDress.Pos[main_role_dress_bubble]
- text_offset = co.AddXY(text_offset,co.TableXY(addTable.pos_x,addTable.pos_y)) --+ Vector2(addTable.pos_x,addTable.pos_y)
- bg_add_size = co.AddXY(bg_add_size,co.TableXY(addTable.size_x,addTable.size_y))
- end
- if info.iType == ChatModel.MSG_TYPE.VOICE then
- local voiceVo = ChatVoiceManager:getInstance():GetVoice(info.voice_id)
- if voiceVo then
- local leftTime = voiceVo:IsPlaying()
- if leftTime then
- self:PlayAnim(leftTime)
- else
- -- if not voiceVo.last_play_start_time then
- -- self.mainRole_voice_hot:SetActive(true)
- -- end
- self:SetPlayState(3)
- end
- else
- self:SetPlayState(3)
- end
- self.mainRoleCon_voiceText.text = info.length.."''"
- self.mainRoleCon_btnVoice:SetActive(true)
- self.mainRole_voiceClick:SetActive(true)
- local text_size_x = math.max(65,text_size.x) --最少要90
- self.mainRole_chatBg.sizeDelta = Vector2(bg_add_size.x + text_size_x, bg_add_size.y + text_size.y + self.voice_bg_add_size.y)
- self.mainRole_chatBg.anchoredPosition = Vector3(self.main_role_chatBg_offset.x, self.main_role_chatBg_offset.y)
- self.mainRole_contentText.anchoredPosition = Vector3(-self.role_text_offset.x - text_size_x / 2 + text_offset.x, self.mainRole_chatBg.localPosition.y - self.mainRole_chatBg.sizeDelta.y + text_size.y / 2 + self.voice_text_offset.y)
-
- self.mainRole_voiceClick_tr.anchoredPosition = self.mainRole_chatBg.anchoredPosition
- self.mainRole_voiceClick_tr.sizeDelta = self.mainRole_chatBg.sizeDelta
-
- else
- self.mainRoleCon_btnVoice:SetActive(false)
- self.mainRole_voiceClick:SetActive(false)
- self.mainRole_chatBg.sizeDelta = Vector2(bg_add_size.x + text_size.x, math.max(bg_add_size.y + text_size.y, self.role_bg_min_size.y))
- self.mainRole_chatBg.anchoredPosition = Vector3(self.main_role_chatBg_offset.x, self.main_role_chatBg_offset.y)
- self.mainRole_contentText.anchoredPosition = Vector3(-self.role_text_offset.x - text_size.x / 2 + text_offset.x, self.mainRole_chatBg.localPosition.y - self.mainRole_chatBg.sizeDelta.y / 2 + self.role_text_offset.y + text_offset.y)
- end
- self.height = self.mainRole_chatBg.sizeDelta.y + 30
- self.height = math.max(self.height, 95)
-
- end
- -----上面的height 都是独立的
- if SceneManager:getInstance():IsBeachScene() and channel == ChatModel.CHANNEL_NEAR then
- if self.info.player_id == RoleManager.Instance:GetMainRoleId() then
- self.btnGift:SetActive(false)
- else
- self.btnGift:SetActive(true)
- -- AddClickEvent(self.btnGift, function()
- -- BeachModel:getInstance():Fire(BeachModel.OPEN_GIFT_VIEW, {role_id = self.info.player_id, name = self.info.name})
- -- end)
- end
- else
- self.btnGift:SetActive(false)
- end
-
- self.bind_play_voice = GlobalEventSystem:Bind(ChatModel.PLAY_VOICE, function(voice_id, voice_clip)
- if self.info and self.info.voice_id == voice_id then
- if self.anim_play_voice then
- return
- end
- self:PlayAnim(voice_clip.length)
- end
- end)
- self.bind_stop_voice = self.model:Bind(ChatModel.STOP_VOICE_PLAY, function(voice_id)
- if self.info and self.info.voice_id == voice_id then
- if self.timer_cancel_anim then
- GlobalTimerQuest:CancelQuest(self.timer_cancel_anim)
- self.timer_cancel_anim = nil
- end
- if self.anim_play_voice then
- GlobalTimerQuest:CancelQuest(self.anim_play_voice)
- self.anim_play_voice = nil
- end
- self:SetPlayState(3)
- end
- end)
- self.height = self.height + 20
- -------------------------
- --用于其它地方用到了item计算高度
- local special_tag = self.info.msg or ""
- if channel ~= ChatModel.CHANNEL_SYSTEM and (not self.info.is_line) and (not self.info.show_num) then
- if self.type_id and string.find(self.type_id,"beachChat") then
- self.height = self.height * self.beach_scale
- end
- end
- self.model:Fire(ChatModel.CHANGE_HEIGHT,self.type_id,self.height,special_tag)
- --用于其它地方用到了item计算高度
- return self.height
- end
-
- function ChatItem:PlayAnim(leftTime)
- local playState = 0
- self:SetPlayState(1)
- self.anim_play_voice = GlobalTimerQuest:AddPeriodQuest(function()
- playState = (playState + 1) % 3
- self:SetPlayState(playState + 1)
- end, 0.5, -1)
- self.timer_cancel_anim = GlobalTimerQuest:AddPeriodQuest(function()
- GlobalTimerQuest:CancelQuest(self.anim_play_voice)
- self.anim_play_voice = nil
- self.timer_cancel_anim = nil
- self:SetPlayState(3)
- end, leftTime, 1)
- end
-
- function ChatItem:SetRegText(scmd)
- local text_size
- if self.info.player_id == RoleManager.Instance:GetMainRoleId() then
- self.mainRole_contentText.sizeDelta = Vector2(self.role_text_width, 0)
- self.mainRole_contentText_t.text = "<color=#323232>"..scmd.voice_text.."</color>"
- text_size = Vector2(math.min(self.role_text_width, self.mainRole_contentText_t.preferredWidth), self.mainRole_contentText_t.preferredHeight)
- self.mainRole_contentText.sizeDelta = text_size --Vector2(self.role_text_width, text_size.y)
- -- self.mainRole_chatBg.sizeDelta = Vector2(math.max(self.voice_bg_add_size.x + self.mainRoleCon_voiceText.preferredWidth, 40 + text_size.x),self.voice_bg_add_size.y + text_size.y + (text_size.y > 0 and 10 or 0))
- -- self.mainRole_contentText.anchoredPosition = Vector3(-118 - text_size.x / 2,self.mainRole_chatBg.localPosition.y - self.mainRole_chatBg.sizeDelta.y + text_size.y / 2 + 14.6)
- self.mainRole_chatBg.sizeDelta = Vector2(math.max(self.voice_bg_add_size.x + self.mainRoleCon_voiceText.preferredWidth, self.role_bg_add_size.x + text_size.x), self.voice_bg_add_size.y + text_size.y + (text_size.y > 0 and 10 or 10))
- self.mainRole_contentText.anchoredPosition = Vector3(-self.role_text_offset.x - text_size.x / 2, self.mainRole_chatBg.localPosition.y - self.mainRole_chatBg.sizeDelta.y + text_size.y / 2 + self.voice_text_offset.y)
- self.height = self.mainRole_chatBg.sizeDelta.y + 30
- self.height = math.max(self.height, 95)
- else
- self.mainRole_contentText.sizeDelta = Vector2(self.role_text_width, 0)
- self.player_contentText_t.text = "<color=#323232>"..scmd.voice_text.."</color>"
- text_size = Vector2(math.min(self.role_text_width, self.player_contentText_t.preferredWidth), self.player_contentText_t.preferredHeight)
- self.player_contentText.sizeDelta = text_size--Vector2(self.role_text_width, text_size.y)
- -- self.player_chatBg.sizeDelta = Vector2(math.max(self.voice_bg_add_size.x + self.player_voiceText.preferredWidth, 40 + text_size.x), self.voice_bg_add_size.y + text_size.y + (text_size.y > 0 and 10 or 0))
- self.player_chatBg.sizeDelta = Vector2(math.max(self.voice_bg_add_size.x + self.player_voiceText.preferredWidth, self.role_bg_add_size.x + text_size.x), self.voice_bg_add_size.y + text_size.y + (text_size.y > 0 and 10 or 10))
- self.player_contentText.anchoredPosition = Vector3(self.role_text_offset.x + text_size.x / 2, self.player_chatBg.localPosition.y - self.player_chatBg.sizeDelta.y + text_size.y / 2 + self.voice_text_offset.y)
- self.height = self.mainRole_chatBg.sizeDelta.y + 30
- self.height = math.max(self.height, 95)
- end
- return text_size.y
- end
-
- function ChatItem:GetHeight()
- return self.height
- end
-
- function ChatItem:IsLineItem()
- return self.info and self.info.is_line
- end
-
- function ChatItem:SetLineSize(width, bgWidth)
- self.line_width = width
- self.line_bg_width = bgWidth
- if self.is_loaded then
- self.lineCon.transform.sizeDelta = Vector2(width or 560, 23)
- -- self.lineImg.transform.sizeDelta = Vector2(bgWidth or 196, 22)
- else
- self.set_line_size_cache = true
- end
-
- end
-
- function ChatItem:CilckContentHandle(param_list)
- self.model.clicked_item = self
- self.model.chick_hyperlink_mark = true
- self.model:FireSpecialTab(param_list)
- end
-
- function ChatItem:SetVisible(state,force_hide)
- BaseItem.SetVisible(self, state,force_hide)
- if not state then
- self:ClearAnimEvent()
- end
- end
-
- function ChatItem:SetPlayState(state)
- if not self.info then
- return
- end
- local s1, s2, s3
- if self.info.player_id == RoleManager.Instance:GetMainRoleId() then
- s1 = self.mainRoleCon_img_voice1
- s2 = self.mainRoleCon_img_voice2
- s3 = self.mainRoleCon_img_voice3
- else
- s1 = self.player_img_voice1
- s2 = self.player_img_voice2
- s3 = self.player_img_voice3
- end
- if not IsNull(s1) and not IsNull(s2) and not IsNull(s3) then
- s1:SetActive(state == 1)
- s2:SetActive(state == 2)
- s3:SetActive(state == 3)
- end
- end
-
- function ChatItem:ClearAnimEvent()
- if self.bind_play_voice then
- GlobalEventSystem:UnBind(self.bind_play_voice)
- self.bind_play_voice = nil
- end
- if self.anim_play_voice then
- GlobalTimerQuest:CancelQuest(self.anim_play_voice)
- self.anim_play_voice = nil
- end
- if self.timer_cancel_anim then
- GlobalTimerQuest:CancelQuest(self.timer_cancel_anim)
- self.timer_cancel_anim = nil
- end
- if self.bind_stop_voice then
- self.model:UnBind(self.bind_stop_voice)
- self.bind_stop_voice = nil
- end
- end
-
- function ChatItem:__delete()
- self:ClearAnimEvent()
- if self.mainRoleHeadItem then
- self.mainRoleHeadItem:DeleteMe()
- self.mainRoleHeadItem = nil
- end
- if self.playHeadItem then
- self.playHeadItem:DeleteMe()
- self.playHeadItem = nil
- end
- if self.player_vip_item then
- self.player_vip_item:DeleteMe()
- self.player_vip_item = nil
- end
- if self.mainRole_vip_item then
- self.mainRole_vip_item:DeleteMe()
- self.mainRole_vip_item = nil
- end
-
- for k,v in pairs(self.assist_award_item_list) do
- UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem,v)
- end
- self.assist_award_item_list = {}
- end
-
- function ChatItem:SetLineTimeColor(color)
- self.line_color = color
- if self.is_loaded then
- -- self.line_timeText.color = Color(221 / 255, 223 / 255, 231 / 255, 1)--ColorUtil:GetGoodsColor(color)
- else
- self.color_cache = true
- end
- end
-
- function ChatItem:ResetText( )
- self.player_contentText_t.text = ""
- self.mainRole_contentText_t.text = ""
- self.system_contentText.text = ""
- end
-
- function ChatItem:GetRankIconResName( playId )
- local fight_rank_num = nil
- local level_rank_num = nil
- local rankList = RankModel:getInstance():GetRankChatList()
- if not rankList or not rankList.fight_list then return end
- for k,v in pairs(rankList.fight_list) do
- if playId == v.player_id then
-
- fight_rank_num = v.rank
- end
- end
-
- for k,v in pairs(rankList.level_list) do
- if playId == v.player_id then
- level_rank_num = v.rank
- end
- end
- local res_rank_name = nil
- if fight_rank_num and fight_rank_num < 4 then
- res_rank_name = "chat_fight_rank"..fight_rank_num.."_pointfilter"
- elseif level_rank_num and level_rank_num < 4 then
- res_rank_name = "chat_level_rank"..level_rank_num.."_pointfilter"
- elseif fight_rank_num and fight_rank_num >= 4 and fight_rank_num <= 10 then
- res_rank_name = "chat_fight_rank4_pointfilter"
- elseif level_rank_num and level_rank_num >= 4 and level_rank_num <= 10 then
- res_level_name = "chat_level_rank4_pointfilter"
- else
- res_rank_name = nil
- end
- return res_rank_name
-
- end
-
- -- 跨服频道 根据后端传的玩家原本服务器排名来拿
- function ChatItem:GetRankIconResName2( level_rank_num, fight_rank_num )
- local res_rank_name = nil
- if fight_rank_num and fight_rank_num < 4 and fight_rank_num ~= 0 then
- res_rank_name = "chat_fight_rank"..fight_rank_num.."_pointfilter"
- elseif level_rank_num and level_rank_num < 4 and level_rank_num ~= 0 then
- res_rank_name = "chat_level_rank"..level_rank_num.."_pointfilter"
- elseif fight_rank_num and fight_rank_num >= 4 and fight_rank_num <= 10 and fight_rank_num ~= 0 then
- res_rank_name = "chat_fight_rank4_pointfilter"
- elseif level_rank_num and level_rank_num >= 4 and level_rank_num <= 10 and level_rank_num ~= 0 then
- res_level_name = "chat_level_rank4_pointfilter"
- else
- res_rank_name = nil
- end
- return res_rank_name
- end
-
- function ChatItem:SetItemSize(x,y)
- self.size_x = self.size_x or x
- self.size_y = self.size_y or y
- if self.transform then
- self.size_x = x or self.transform.sizeDelta.x
- self.size_y = y or self.transform.sizeDelta.y
- self.transform.sizeDelta = Vector3(self.size_x,self.size_y,0)
- end
- end
-
- function ChatItem:SetLocalPositionY(pos)
- --快速创建多个的时候pos都是0会挤在一起,所以需要创建的时候及时存储相应位置,ReLayoutScroll的时候再次定义位置
- self.wait_set_local_y = nil
- if pos and self.transform and self.transform.localPosition then
- self.transform.localPosition = Vector3(0,pos,0)
- else
- self.wait_set_local_y = pos
- end
- end
-
- function ChatItem:SetTypeId( type_id )
- self.type_id = type_id
- end
|