local UIChannelChatMain = UIViewClass() --[[ UIPKRoomChatView 继承此界面 --]] local EventSystem = require('Event/EventSystem') local SuoNaBg_CrossServer = ConstAssetPathConfig.SuoNaBg_CrossServer local SuoNaBg_LocalServer = ConstAssetPathConfig.SuoNaBg_LocalServer local SuoNaBg_WarZone = ConstAssetPathConfig.SuoNaBg_WarZone local SelfChatBg = ConstAssetPathConfig.DefaultSelfQiPaoPath local OtherChatBg = ConstAssetPathConfig.DefaultOtherQiPaoPath local suonaTxtColor = "000000" local HEIGHT_CROSS_CHAT = -3.5 --跨服聊天UI高度 local SIZE_CROSS_CHAT = -231 local HEIGHT_GUILDWAR_CHAT = -49 --势力战聊天UI高度 local SIZE_GUILDWAR_CHAT = -427 local HEIGHT_Legion_CHAT = 9 --势力战聊天UI高度 local SIZE_Legion_CHAT = -208 local SWITCH_BG_OFFSET = 100 local HEIGHT_BULLET = -3.5 --弹幕频道UI高度 local SIZE_BULLET = -231 local SWITCH_BG_UNIT = 90 --拖动误差,拖动不超过此值,都认为cell在最底下,来新消息直接顶上去 local allowanceError = 0.95 local themeSelect = "" local isThemePanelOpen = false local isSendTeamInGuildWar = true --默认发送本方,否则是全体(军团战) local isSendTeamInDragonArtery = true --默认发送本方,否则是全体(龙脉战) function UIChannelChatMain:OnCreated() self.curLoadTopIndex = 1 self:SetUnReadShow(false, 0) self.maxQuickMsgLength = 600 self.scrollAnchoredPosX, self.scrollAnchoredPosY = self.obj_ScrollPanel.transform:GetAnchoredPosition() self.scrollSizeDeltaX, self.scrollSizeDeltaY = self.obj_ScrollPanel.transform:GetSizeDelta() self.chatLoopScrollContentTrans = self.obj_ScrollPanel.content.transform if self.obj_loading then UIUtils.SetActive(self.obj_loading.gameObject, false) end end function UIChannelChatMain:OnOpened(context) if context and context.subView then local viewCanvas = self.gameObject:GetComponent(typeof(UnityEngine.Canvas)) viewCanvas.overrideSorting = false end self:OnBaseOpened(context) end function UIChannelChatMain:OnBaseOpened(context) self.effectPlayDic = {} UIUtils.SetCanvasSortingOrderByMainCanvas(self.gameObject:GetComponent(typeof(UnityEngine.Canvas)), self.UpCanvas, CTL.Character.UpOrder.ChannelChat) self.state_Talk:SetState(0) if CTL.ChannelChat.IsEnableVoiceChat() then UIUtils.SetActive(self.event_Talk, true) UIUtils.SetActive(self.group_Sound, true) else UIUtils.SetActive(self.event_Talk, false) UIUtils.SetActive(self.group_Sound, false) end UIUtils.SetLabelText(self.lab_Talk, Const_IDS.IDS_AudioChat_Press) UIUtils.SetActive(self.mask_Talk, false) self:RegistTriggerEvent(self.btn_Talk, UIEventTriggerType.PointerExit) self:RegistTriggerEvent(self.btn_Talk, UIEventTriggerType.PointerDown) self:RegistTriggerEvent(self.btn_Talk, UIEventTriggerType.PointerUp) self:RegistTriggerEvent(self.btn_Talk, UIEventTriggerType.PointerEnter) self:RegistSystemEvent(EventID.UI_ChannelChat_OnRecordStartResult, self.OnStartRecordVoiceResult) self:RegistSystemEvent(EventID.UI_ChannelChat_FinishPlayVoice, self.OnRefreshPlayingVoice) self:RegistSystemEvent(EventID.UI_ChannelChat_StartPlayVoice, self.OnRefreshPlayingVoice) self:RegistSystemEvent(EventID.UI_ChannelChat_OnRecordTimeEnd, self.OnRecordTimeEnd) self:RegistSystemEvent(EventID.UI_KeyboardControl_Enter, self.OnPressEnterKey) self:InitInfo(context) EventSystem.Dispatch(EventID.UI_ChannelChat_OnChatViewOpen) end function UIChannelChatMain:InitInfo(context) self:RegistSystemEvent(EventID.ApplicationPause, self.SetDragToEndByApplicationPause) self:RegistSystemEvent(EventID.UI_ChannelChat_OnCloseWindow, self.OnCloseWindowByExternal) self:RegistSystemEvent(EventID.UI_ChannelChat_OnDrag, self.OnDragEvent) self:RegistSystemEvent(EventID.UI_ChannelChat_GetUnReadShow, self.GetUnReadShow) self:RegistSystemEvent(EventID.UI_ChannelChat_IsScrollBarInTheEnd, self.IsScrollBarInTheEnd) self:RegistSystemEvent(EventID.UI_ChannelChat_ClearInputField, self.ClearInputField) self:RegistSystemEvent(EventID.UI_ChannelChat_OnMainReceiveNewMsg, self.OnNewMsg) self:RegistSystemEvent(EventID.UI_ChannelChat_OnMainReceiveHistoryMsg,self.OnHistoryMsg) self:RegistSystemEvent(EventID.UI_ChannelChat_OnJoinChannel,self.OnJoinChannel) self:RegistSystemEvent(EventID.UI_ChannelChat_OnMainNotReadMsg,self.OnNotReadMsg) self:RegistSystemEvent(EventID.UI_ChannelChat_DisplaySendObj,self.IsDisplaySendObj) self:RegistSystemEvent(EventID.UI_ChannelChat_OpenFacePanel,self.IsOpenFacePanel) self:RegistSystemEvent(EventID.UI_ChannelChat_RefreshGuildWar,self.ShowGuildWarUI) self:RegistSystemEvent(EventID.UI_ChannelChat_ShowScoutViewBtn,self.ShowScoutViewBtn) self:RegistSystemEvent(EventID.UI_UpdateBlack,self.OnBanBlackMsg) self:RegistSystemEvent(EventID.UI_ChannelChat_ClickBack,self.OnClickBackBtn) self:RegistSystemEvent(EventID.UI_ChannelChat_RefreshVoiceChatInfo,self.RefreshChatUI) self:RegistSystemEvent(EventID.SDK_OnVoiceRoomStateChange,self.RefreshChatUI) self:RegistSystemEvent(EventID.UI_UpdateBuff_Town,self.RefreshLoopScroll) self:RegistSystemEvent(EventID.UI_ChannelChat_JumpToSpecifiedChannel, self.JumpToSpecifiedChannel) self:RegistSystemEvent(EventID.UI_ChannelChat_OpenSuoNa, self.OnClickSuoNaButton) self:RegistSystemEvent(EventID.UI_ChannelChat_TranslateUpdate, self.UpdateTranslationIndex) self:RegistSystemEvent(EventID.BagItem_Update, self.ShowGVGFightUI) self:RegistTriggerEvent(self.slider_Listen, UIEventTriggerType.EndDrag) self:RegistTriggerEvent(self.slider_Listen, UIEventTriggerType.BeginDrag) self.hasInitSetting = false self:CheckNeedJoinGuildWarChannel() self.IsOpenSuoNa = false -- self:RegistTriggerEvent(self.obj_ScrollPanel, UIEventTriggerType.EndDrag) self.QuickMsgCellTable = nil self.QuickMsgCellTableIndex = -1 self.EmojiIndex = 0 self.ChatHistoryIndex = 1 self.QuickMsgIndex = 2 self.obj_ThemePanel.gameObject:SetActive(false) self.ChatRoomMemberCount=0 self.Text_All.text=UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_MsgTarget_All) self.Text_Team.text=UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_MsgTarget_Allies) MDL.ChannelChat.SetChannelChatIsOpen(true) self:RefreshRedPoint() local defaultShowChatId = CTL.ChannelChat.GetDefaultSelectChannel(context.LastMsgChannelId) local selectIndex = 0 for i,v in ipairs(CTL.ChannelChat.GetShowChannelCfgData()) do self.channelScroll:AddData(v,0) if v.ID == defaultShowChatId then selectIndex = i end end self.channelScroll:SelectIndex(selectIndex>0 and selectIndex-1 or 0) self:CheckNeedSelectChannel() local notSendMsg = MDL.ChannelChat.GetNotSendMsg(); if notSendMsg ~= nil and #notSendMsg > 0 then self:SetInputTextAndMoveEnd(notSendMsg) end local roomType = self:GetEnteringVoiceRoomType() if roomType ~= MDL.VoiceRoom.VoiceRoomType.None then CTL.ChannelChat.AcquireCurVoiceListenCount(roomType) end self:RefreshChatUI() UIUtils.SetActive(self.event_Suona, MDL.Player.GetPublicSentimentUnLock()) end function UIChannelChatMain:UpdateTranslationIndex(isSuccess, index) local maxIndex = self.obj_ScrollPanel.Count - 1 if index > maxIndex then return end self.obj_ScrollPanel:UpdateIndex(index) if index == maxIndex then self.obj_ScrollPanel:MoveEnd() end if not isSuccess then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ChatTranslation_WrongHint) end end function UIChannelChatMain:CheckNeedSelectChannel() if CTL.ChannelChat.IsCanShowGuildWarChannel() then local index = MDL.ChannelChat.GetChatChanelTabIndexByCfgID(MDL.ChannelChat.ChannelCfgId.GuildWar) self.channelScroll:SelectIndex(index) elseif CTL.ChannelChat.IsCanShowGVGFightChannel() then local index = MDL.ChannelChat.GetChatChanelTabIndexByCfgID(MDL.ChannelChat.ChannelCfgId.GVGFight) self.channelScroll:SelectIndex(index) end end --动态加军团战频道 function UIChannelChatMain:CheckNeedJoinGuildWarChannel() if CTL.ChannelChat.IsCanShowGuildWarChannel() then MDL.ChannelChat.JoinGuildWarChannel() end end function UIChannelChatMain:GetChannelID() return MDL.ChannelChat.GetCurChannelID() end function UIChannelChatMain:OnScrollTop(comp, _isTop) local isTop = _isTop if comp == self.obj_ScrollPanel then if isTop then if self.curLoadTopIndex > 1 then self:RefreshLoopScroll(true) return end if self.obj_loading then UIUtils.SetActive(self.obj_loading.gameObject, true) end MDL.ChannelChat.GetHistoryInfos() if self.topLineMsgData then self.lastTopLineMsg = self.topLineMsgData self.lastTopLineOffset = self.topLineMsgOffset end end end end function UIChannelChatMain:SetDragToEndByApplicationPause() MDL.ChannelChat.SetIsDragToEnd(false) end function UIChannelChatMain:OnScrollBottom(comp, isBottom) local isEnd = isBottom MDL.ChannelChat.SetIsDragToEnd(isEnd) if not isEnd then self:IsDisplayNewMsgTips(true) else self:IsDisplayNewMsgTips(false) end end function UIChannelChatMain:OnBeginDrag(comp, eventData) --军团战收听状态 不足一秒时不能切换 if comp == self.slider_Listen then self.lab_Listen.gameObject:SetActive(false) self.lab_Close.gameObject:SetActive(false) if self.lastChangeListenTime == nil then self.lastChangeListenTime=UTL.Time.GetServerTimestamp() else local currentTime=UTL.Time.GetServerTimestamp() --1秒cd if (currentTime- self.lastChangeListenTime) >1 then self.lastChangeListenTime=currentTime end end end end --滑动列表是否上滑到顶部,滑动到顶部的时候请求历史消息 function UIChannelChatMain:OnEndDrag(comp, eventData) if comp == self.obj_ScrollPanel then local isTop = self.obj_ScrollPanel:IsDragToTop() local isEnd = self.obj_ScrollPanel:IsEnd() MDL.ChannelChat.SetIsDragToEnd(isEnd) if not isEnd then self:IsDisplayNewMsgTips(true) else self:IsDisplayNewMsgTips(false) end if isTop then MDL.ChannelChat.GetHistoryInfos() end --军团战收听状态 elseif comp == self.slider_Listen then local value=self.slider_Listen.value local isListening= value==1 if isListening then CTL.Tips.AddTipsMsg(Const_IDS.IDS_WarChannel_EnterListening) MDL.GuildWar.SendGuildWarListen(PlayerInfoManager.AcID) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_WarChannel_QuitListening) MDL.GuildWar.SendGuildWarCancelListen(PlayerInfoManager.AcID) end self.lab_Listen.gameObject:SetActive(isListening) self.lab_Close.gameObject:SetActive(not isListening) CTL.VoiceRoom.EnableListener(MDL.VoiceRoom.VoiceRoomType.GuildWar, isListening) end end function UIChannelChatMain:OnPressEnterKey() self:OnButtonClicked(self.event_Send) end function UIChannelChatMain:GetScrollByComp(comp) for _, btn in pairs(self.attackBtns) do if self.obj_ScrollPanel == comp then return btn end end end function UIChannelChatMain:OnDragEvent() if MDL.ChannelChat.GetChannelChatIsOpen() then local isShow = self:GetUnReadShow() if isShow then local isInTheEnd = self:IsScrollBarInTheEnd() if isInTheEnd then self:SetUnReadShow(false,"") end end end end function UIChannelChatMain:GetUnReadShow() return self.event_UnRead.gameObject.activeSelf end function UIChannelChatMain:OnCloseWindowByExternal() CTL.HomeMain.SetEnterTownRestoreView(Const_UI_Lua.UIEnum.UIChannelChatMain) self:OnClickClose() end function UIChannelChatMain:SetUnReadShow(show,count) UIUtils.SetActive(self.event_UnRead,show) if show then local txt = string.FormatByIdsId(Const_IDS.IDS_Chat_Unread, count) self.labLocal_UnReadText.text = txt end end function UIChannelChatMain:ClearInputField() self.obj_InputField.text = nil MDL.ChannelChat.SetNotSendMsg(""); end function UIChannelChatMain:OnBanBlackMsg() self:RefreshLoopScroll() end function UIChannelChatMain:GetChatMsgList() local channelID = MDL.ChannelChat.GetChannelIdByCfgID(self.CurrentChannelCfgID) local chatList = nil if MDL.ChannelChat.IsCurrentChannelByPrefix(channelID) then --当前频道数据单独获取 chatList = MDL.ChannelChat.GetCurrentChannelMsgList() elseif MDL.ChannelChat.IsMixtureChannelByCfgId(self.CurrentChannelCfgID) then chatList = MDL.ChannelChat.GetDlgMsgList() else chatList = MDL.ChannelChat.GetChannelChatList(channelID) end return chatList end function UIChannelChatMain:RefreshWarZoneShow() self:RefreshLoopScroll() end function UIChannelChatMain:RefreshLoopScroll(noNeedMoveEnd) local chatList = self:GetChatMsgList() self.obj_ScrollPanel:ClearCells() local chatDataCount = 0 if chatList == nil or #chatList <= 0 then chatDataCount = 0 else chatDataCount = #chatList end -- 判斷是否為空顯示 UIUtils.SetActive(self.group_Empty, chatDataCount == 0) self:DisplayInputField() --频道是否开启 local isOpen, unlockMsg = MDL.ChannelChat.IsChannelOpen(self.CurrentChannelCfgID) if not isOpen then --聊天下方显示解锁条件 self:IsDisplayLockTips(true, unlockMsg) else local silence = MDL.HomeMain.GetSilenceBuff() if silence ~= nil and MDL.ChannelChat.IsInSilenceChannelByCfgId(self.CurrentChannelCfgID) then --是否显示禁言 self:DisplayForbiddenWords(silence) else UIUtils.SetActive(self.lab_DuiwuNone, true) UIUtils.SetActive(self.lab_CountDown, false) if MDL.ChannelChat.IsTeamChannelByCfgId(self.CurrentChannelCfgID) then --队伍数据为空时,且没有队伍,则需要隐藏数据框,提示加入队伍 if not CTL.Team.IsInTeam() then self:IsDisplayTeamTips(true) end elseif MDL.ChannelChat.IsCanChatByCfgId(self.CurrentChannelCfgID) then self:IsDisplayCanNotInPutTips(true) elseif MDL.ChannelChat.IsLegionChannelByCfgId(self.CurrentChannelCfgID) then self:IsDisplayGuildTips(not MDL.Guild.IsHasGuild()) elseif MDL.ChannelChat.IsWarZoneChannelByCfgId(self.CurrentChannelCfgID) then local state, timeStr = CTL.WarZone.GetTimeState() local countDownTimestamp = timeStr and MDL.WarZone.GetTimeInfo().startTime - UTL.Time.GetServerTimestamp() or nil self:isDisplayWarZoneTips(countDownTimestamp ~= nil, countDownTimestamp) elseif MDL.ChannelChat.ChannelCfgId.Country == self.CurrentChannelCfgID then self:IsDisplayCountryTips(not MDL.Country.IsHasCountry()) end end end if chatDataCount <= 0 then if not noNeedMoveEnd then self.obj_ScrollPanel:MoveEnd() end return end local needFromIndex = 1 if chatDataCount>15 and noNeedMoveEnd and self.curLoadTopIndex == 1 then needFromIndex = chatDataCount-self:GetChannelPageCount() end for i=needFromIndex, chatDataCount do if not MDL.ChannelChat.IsMsgFromBlack(chatList[i]) and not chatList[i].hide then if chatList[i].isSelf then self.obj_ScrollPanel:AddData(chatList[i],0) elseif chatList[i].heroId == nil or chatList[i].heroId <= 0 then self.obj_ScrollPanel:AddData(chatList[i],2) else self.obj_ScrollPanel:AddData(chatList[i],1) end end end if not noNeedMoveEnd then self.obj_ScrollPanel:MoveEnd() elseif self.curLoadTopIndex>1 then self.obj_ScrollPanel:MoveIndex(self.curLoadTopIndex - 2) self.curLoadTopIndex=1 end self.curLoadTopIndex = needFromIndex if self.obj_loading then UIUtils.SetActive(self.obj_loading.gameObject, false) end end function UIChannelChatMain:GetChannelPageCount() if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.World then return 10 end if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Legion then return 10 end if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Cross then return 10 end if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Country then return 10 end if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.WarZone then return 10 end if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.ZhaoMu then return 6 end return 15 end function UIChannelChatMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.obj_ScrollPanel then if index == 0 then self.topLineMsgData = data local width, height = cellTable.cell.transform:GetSizeDelta() self.topLineMsgOffset = height end local isSelf = data.isSelf -- 设置频道(需要优先设置,以便首行空格) -- CurrentChannelCfgID 从1 开始 state从0开始所以减1 local curChannelId = nil if MDL.ChannelChat.IsMixtureChannelByCfgId(self.CurrentChannelCfgID) then curChannelId = data.ChatCfgId CTL.ChannelChat.SetMsgTitle(cellTable, self.CurrentChannelCfgID, data, isSelf, data.ChatCfgId) else curChannelId = self.CurrentChannelCfgID CTL.ChannelChat.SetMsgTitle(cellTable, self.CurrentChannelCfgID, data, isSelf, self.CurrentChannelCfgID) end if data.heroId == nil or data.heroId <= 0 then -- 设置频道文字空格(需要在设置text之前设置) cellTable.lab_Content.text = CTL.ChannelChat.GetChannelBlankSpace(curChannelId, data.serId, false) .. data.content -- 设置频道位置 if UIUtils.GetFirstLineHaveEmojiByEmojiText(cellTable.lab_Content) then UIUtils.SetRectPosition(cellTable.groupBG, 0, -37) else UIUtils.SetRectPosition(cellTable.groupBG, 0, 0) end else if isSelf then CTL.Character.SetSelfPortraitAndFrame(cellTable.UIHeroHead190, data.level) if data.bubble and data.bubble > 0 then UIUtils.SetImageByAssetBundle(cellTable.group_Content, DataSheetManager.DecorateAdditionalRes:GetDataByID(data.bubble).Resource1) else UIUtils.SetImageByAssetBundle(cellTable.group_Content, SelfChatBg) end else CTL.Character.SetPortraitAndFrame(cellTable.UIHeroHead190, data.portraitId, data.frameId, data.level) if data.bubble and data.bubble > 0 then UIUtils.SetImageByAssetBundle(cellTable.group_Content, DataSheetManager.DecorateAdditionalRes:GetDataByID(data.bubble).Resource2) else UIUtils.SetImageByAssetBundle(cellTable.group_Content, OtherChatBg) end end local roleId = data.heroId UTL.Item.SetHeroHeadTemplate(cellTable.UIHeroHead, roleId, UTL.Item.GetNobilityByTeamLevel(data.level, 2)) local trumpetType = data.trumpetType and data.trumpetType or -1 UIUtils.SetActive(cellTable.icon_Suona, trumpetType > 0) if trumpetType > 0 then local suonaTxt = UTL.Color.FormatTextByColor(suonaTxtColor, data.content) cellTable.lab_Content.text = suonaTxt if trumpetType == MDL.ChannelChat.TrumtType.Cross then cellTable.state_IconSuoNa:SetState(1) elseif trumpetType == MDL.ChannelChat.TrumtType.WarZone then cellTable.state_IconSuoNa:SetState(3) else cellTable.state_IconSuoNa:SetState(2) end else cellTable.lab_Content.text = data.content cellTable.state_IconSuoNa:SetState(0) end self:SetTitleColor(data.fromId, cellTable.lab_Name) if self:ProcessVoiceChatData(data, cellTable) == false then if not isSelf then --翻译相关 local pureText = MDL.Translate.GetPureText(data.uuid) local translateText = MDL.Translate.GetTranslateText(data.uuid) if not string.isNilOrEmpty(translateText) then UIUtils.SetActive(cellTable.btn_Translate, false) UIUtils.SetActive(cellTable.lab_Translation, true) cellTable.lab_Translation.text = translateText UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(cellTable.group_Content.transform) else UIUtils.SetActive(cellTable.btn_Translate, not string.isNilOrEmpty(pureText)) UIUtils.SetActive(cellTable.lab_Translation, false) end cellTable.anim_Translate:StopAnim(false) cellTable.anim_Translate.transform:SetLocalEulerAngles(nil, nil, 0) cellTable.btn_Translate:SetGray(false, true) end end end --荣誉印记 if cellTable.group_Signet then if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HonorSignet) then UIUtils.SetActive(cellTable.group_Signet.gameObject, true) local signetList = data.wearSignetId or {} for i, v in ipairs(cellTable.group_Signet) do local signetId = signetList[i] UIUtils.SetActive(v, signetId ~= nil) if signetId then UIUtils.SetImageByAssetBundle(v, DataSheetManager.AchievementHonorSignet:GetDataByID(signetId).HonorSignetIcon) end end else UIUtils.SetActive(cellTable.group_Signet.gameObject, false) end end elseif scrollRect == self.channelScroll then UIUtils.SetLabelText(cellTable.txt_Selected, Const_IDS[data.Name]) UIUtils.SetLabelText(cellTable.Text, Const_IDS[data.Name]) elseif scrollRect == self.chat_history_scroll then cellTable.txt_01.text = data elseif scrollRect == self.QuickMsgScroll then cellTable.objQuickMsg_InputField.characterLimit = DataSheetManager.ConstData:GetDataByID("ChatConvenientLimit").IntValue MDL.ChannelChat.ProcessQuickMsg(MDL.ChannelChat.GetQuickMsgByIndex(index + 1), cellTable.txt_01, self.maxQuickMsgLength) elseif scrollRect == self.loop_CrossChannel then if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Cross then UIUtils.SetActive(cellTable.img_Selected, data.Suffix == MDL.ChannelChat.GetCurCrossSubChannelSuffix()) UIUtils.SetLabelText(cellTable.txt_ChannelName, Const_IDS[data.RoomType]) end elseif scrollRect == self.Emoji_Condition then cellTable.txt_emoji.text = "[" .. data.ID .. "]" end end --处理语音聊天文本 function UIChannelChatMain:ProcessVoiceChatData(data, cellTable) cellTable.txt_Time:EndTimer() UIUtils.SetActive(cellTable.group_PlayVoice.gameObject, false) if data.voiceRecordPath and data.voiceDuration then UIUtils.SetActive(cellTable.btn_Translate, false) UIUtils.SetActive(cellTable.lab_Translation, false) UIUtils.SetActive(cellTable.img_VoiceBar, true) cellTable.img_VoiceBar:SetRedPoint(MDL.ChannelChat.HasAudioShowRed(data)) local passTime = CTL.ChannelChat.GetPlayingVoicePassedTime(data.voiceRecordPath) if (passTime == nil or passTime >= data.voiceDuration) then cellTable.txt_Time:SetCDLabel(data.voiceDuration .. "s") else cellTable.txt_Time:ResetAndBeginCustomTimer(false, data.voiceDuration - passTime, 0, "{0}s", 1) UIUtils.SetActive(cellTable.group_PlayVoice.gameObject, true) for i, v in ipairs(cellTable.group_PlayVoice) do v:PlayAnim() end end return true end UIUtils.SetActive(cellTable.img_VoiceBar, false) return false end function UIChannelChatMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.channelScroll then self.ChannelCfgId = data.ID self:ClickChannel(data) elseif scrollRect == self.chat_history_scroll then self:SendMsg(data, true) self:OnClickFace() elseif scrollRect == self.Emoji_Condition then self:OnCommonClickEmoji(data) elseif scrollRect == self.QuickMsgScroll then if self.QuickMsgCellTable ~= nil and self.QuickMsgCellTable ~= cellTable then self:Cell_OnDeselect(nil, nil) end if target.transform.name == "event_01" then if self.IsOpenSuoNa then EventSystem.Dispatch(EventID.UI_ChannelChat_SendSuoNaMsg, MDL.ChannelChat.GetQuickMsgByIndex(index + 1)) return end self:SendMsg(MDL.ChannelChat.GetQuickMsgByIndex(index + 1)) self:OnClickFace() elseif target.transform.name == "btn_Change01" then if self.QuickMsgCellTable == cellTable then self:Cell_OnDeselect(nil, nil) return end self.QuickMsgCellTableIndex = index self.QuickMsgCellTable = cellTable UIUtils.SetActive(self.QuickMsgCellTable.event_Mask, true) UIUtils.SetActive(cellTable.objQuickMsg_InputField, true) cellTable.objQuickMsg_InputField.text = MDL.ChannelChat.GetQuickMsgByIndex(index + 1) cellTable.objQuickMsg_InputField:ActivateInputField() self:RegistTriggerEvent(self.QuickMsgCellTable.objQuickMsg_InputField, UIEventTriggerType.Deselect) UIUtils.SetActive(cellTable.event_01, false) elseif target.transform.name == "event_Mask" then self:Cell_OnDeselect(nil, nil) end elseif scrollRect == self.obj_ScrollPanel then if target.transform.name == "img_PlayerAvatarBg" then CTL.PlayerInteract.OpenFriendInteractView(data.fromId, MDL.PlayerInteract.OccasionType.ChannelChat, {chatContent = data.content}) elseif target == cellTable.img_VoiceBar then self:PlayRecordVoice(data) elseif cellTable.btn_Translate and target == cellTable.btn_Translate then MDL.Translate.TranslateReq(data.uuid, index) cellTable.anim_Translate:PlayAnim() cellTable.btn_Translate:SetGray(true, false) else for i, v in ipairs(cellTable.group_Signet) do if target == v then CTL.HonorSignet.OpenEquipSignetDetail(i, data.wearSignetId, data.signetTimestamp) return end end end elseif scrollRect == self.loop_CrossChannel then if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Cross then if data.Suffix == MDL.ChannelChat.GetCurCrossSubChannelSuffix() then self:OnCloseSwitchSubChannel() else self:OnSwitchCross(data.Suffix, true) MDL.ChannelChat.SwitchCrossChannel(data.Suffix) end end CTL.Sound.PlayGameSound("UI_jineng") end end function UIChannelChatMain:PlayRecordVoice(data) CTL.ChannelChat.ManualPlayVoice(data) end function UIChannelChatMain:OnRefreshPlayingVoice() self.obj_ScrollPanel:RefreshCells() end function UIChannelChatMain:OnRecordTimeEnd() UIUtils.SetActive(self.mask_Talk, false) self.isRecordTimeEnd = true self.btn_Talk.enabled = false self.btn_Talk.transform:SetLocalScale(1, 1) self.btn_Talk.enabled = true UIUtils.SetLabelText(self.lab_Talk, Const_IDS.IDS_AudioChat_Press) end function UIChannelChatMain:OnPointerDown(comp, eventData) if comp == self.btn_Talk then self:StartRepeatFunc(self.OnRecordTimeEnd, 2, 1) UIUtils.SetLabelText(self.lab_Talk, Const_IDS.IDS_AudioChat_Release) self.isExitAudioPointer = false self.isRecordTimeEnd = false self:StartRecordVoice() end end function UIChannelChatMain:OnStartRecordVoiceResult(result) self:StopRepeatFunc(self.OnRecordTimeEnd) if result == "true" then UIUtils.SetActive(self.mask_Talk, true) end end function UIChannelChatMain:StartRecordVoice() CTL.ChannelChat.StartRecordVoice(self:GetChannelID(), false) end function UIChannelChatMain:OnPointerExit(comp, eventData) if comp == self.btn_Talk then self.isExitAudioPointer = true if self.isRecordTimeEnd == false then EventSystem.Dispatch(EventID.UI_ChannelChat_OnExitPress) end end end function UIChannelChatMain:OnPointerEnter(comp, eventData) if comp == self.btn_Talk then self.isExitAudioPointer = false if self.isRecordTimeEnd == false then EventSystem.Dispatch(EventID.UI_ChannelChat_OnEnterPress) end end end function UIChannelChatMain:OnPointerUp(comp, eventData) if comp == self.btn_Talk then UIUtils.SetLabelText(self.lab_Talk, Const_IDS.IDS_AudioChat_Press) UIUtils.SetActive(self.mask_Talk, false) if self.isRecordTimeEnd == false then if self.isExitAudioPointer then CTL.ChannelChat.CancelRecordVoice() else CTL.ChannelChat.StopRecordVoice() end end end end function UIChannelChatMain:Cell_OnDeselect(comp, eventData) if self.QuickMsgCellTable ~= nil then local newContent = self.QuickMsgCellTable.objQuickMsg_InputField.text MDL.ChannelChat.ProcessQuickMsg(newContent, self.QuickMsgCellTable.txt_01, self.maxQuickMsgLength) UIUtils.SetActive(self.QuickMsgCellTable.objQuickMsg_InputField, false) self:UnregistTriggerEvent(self.QuickMsgCellTable.objQuickMsg_InputField) UIUtils.SetActive(self.QuickMsgCellTable.event_01, true) UIUtils.SetActive(self.QuickMsgCellTable.event_Mask, false) MDL.ChannelChat.SaveQuickMsg(self.QuickMsgCellTableIndex + 1, newContent) self.QuickMsgCellTableIndex = -1 self.QuickMsgCellTable = nil end end function UIChannelChatMain:IsScrollBarInTheEnd() return self.obj_ScrollPanel:IsEnd() end function UIChannelChatMain:OnClosed() self:ResetEffectByCanvas() CTL.ChannelChat.CancelRecordVoice() CTL.ChannelChat.TryStopPlayingVoice(true) MDL.ChannelChat.SetChannelChatIsOpen(false) if self.ChannelCfgId then CTL.ChannelChat.SetLastSelectChannelChat(self.ChannelCfgId) end EventSystem.Dispatch(EventID.UI_ChannelChat_OnChatViewClose) end --以下为按钮点击事件 function UIChannelChatMain:OnClickUnRead() self.obj_ScrollPanel:MoveEnd() self:SetUnReadShow(false) MDL.ChannelChat.ResetNotReadMsgCount() MDL.ChannelChat.SetIsDragToEnd(true) end --点击左侧的聊天频道 function UIChannelChatMain:ClickChannel(channelData) if self.CurrentChannelCfgID ~= nil and self.CurrentChannelCfgID == channelData.ID then return end if CTL.ChannelChat.IsEnableVoiceChat() then self.state_Talk:SetState(0) end if self.CurrentChannelCfgID ~= nil and self.CurrentChannelCfgID ~= channelData.ID then self:IsDisplayNewMsgTips(false) end self.curCrossSuffix = nil self.CurrentChannelCfgID = channelData.ID self.obj_InputField.characterLimit = channelData.Limit local _channelId = MDL.ChannelChat.GetChannelIdByCfgID(channelData.ID) MDL.ChannelChat.SetCurChannelID(_channelId) EventSystem.Dispatch(EventID.UI_ChannelChat_OnSelectChannelChanged, self.CurrentChannelCfgID) self:RefreshChatUI() self.curLoadTopIndex=1 self:RefreshLoopScroll(true) self.group_Condition.gameObject:SetActive(false) self.group_Setting.gameObject:SetActive(false) --刷新斥候列表 local isShowGuildWar= CTL.ChannelChat.IsGuildWarChannel(self.CurrentChannelCfgID) if isShowGuildWar then MDL.GuildWar.SendGetGuildWarScoutsList() end --军团战新显示的UI self:ShowGuildWarUI() --设置弹幕频道特殊设置 self:RefreshBulletChannelUI() --跨服聊天UI self:RefreshCrossChatUI() --活动聊天UI self:RefreshSpecifiedActivityChatUI() --刷新聊天消息高度 self:RefreshChatUIHeight() -- 设置攻城略地UI self:ShowGVGFightUI() end function UIChannelChatMain:RefreshChatUIHeight() if CTL.ChannelChat.IsGuildWarChannel(self.CurrentChannelCfgID) then self.obj_ScrollPanel.transform:SetAnchoredPosition(self.scrollAnchoredPosX, HEIGHT_GUILDWAR_CHAT) self.obj_ScrollPanel.transform:SetSizeDelta(self.scrollSizeDeltaX, SIZE_GUILDWAR_CHAT) elseif MDL.ChannelChat.IsLegionChannelByCfgId(self.CurrentChannelCfgID) then self.obj_ScrollPanel.transform:SetAnchoredPosition(self.scrollAnchoredPosX, HEIGHT_Legion_CHAT) self.obj_ScrollPanel.transform:SetSizeDelta(self.scrollSizeDeltaX, SIZE_Legion_CHAT) elseif self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Cross then self.obj_ScrollPanel.transform:SetAnchoredPosition(self.scrollAnchoredPosX, HEIGHT_CROSS_CHAT) self.obj_ScrollPanel.transform:SetSizeDelta(self.scrollSizeDeltaX, SIZE_CROSS_CHAT) elseif self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Bullet then self.obj_ScrollPanel.transform:SetAnchoredPosition(self.scrollAnchoredPosX, HEIGHT_BULLET) self.obj_ScrollPanel.transform:SetSizeDelta(self.scrollSizeDeltaX, SIZE_BULLET) else self.obj_ScrollPanel.transform:SetAnchoredPosition(self.scrollAnchoredPosX, self.scrollAnchoredPosY) self.obj_ScrollPanel.transform:SetSizeDelta(self.scrollSizeDeltaX, self.scrollSizeDeltaY) end self.obj_ScrollPanel:MoveEnd() end function UIChannelChatMain:RefreshBulletChannelUI() UIUtils.SetActive(self.group_SubtitleSetting.gameObject, MDL.ChannelChat.IsBulletChannelByCfgId(self.CurrentChannelCfgID)) local isShow = CTL.WatchBattle.GetIsShowBullet() if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncUnfairSolo) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncFairSoloTournament) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncUnfairTeamPVP) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncTeamFairChampionship) then CTL.WatchBattle.SetIsShowBullet(isShow) end self.toggle_ShowSubtitle.isOn = isShow end ------------------------------攻城略地 UI相关 start------------------ function UIChannelChatMain:ShowGVGFightUI() if CTL.ChannelChat.IsGVGFightChannel(self.CurrentChannelCfgID) then if MDL.GVGFight.GetserverInfoCount() > 0 then self:IsDisplayLockTips(false) self.obj_SendState:SetState(0) UTL.Item.ItemSquareIcon(self.img_Cost, nil, CTL.GVGFight.GVGFightChatCostItem) local ownCount = UTL.Item.GetItemStockCount(CTL.GVGFight.GVGFightChatCostItem) if ownCount < CTL.GVGFight.GVGFightChatCostNum then UIUtils.SetLabel(self.txt_Cost, UTL.Color.FormatRedColor(CTL.GVGFight.GVGFightChatCostNum)) else UIUtils.SetLabel(self.txt_Cost, CTL.GVGFight.GVGFightChatCostNum) end else self:IsDisplayLockTips(true) end else self.obj_SendState:SetState(1) end end ------------------------------攻城略地 UI相关 end------------------ ------------------------------军团战场 UI相关 start------------------ function UIChannelChatMain:ShowGuildWarUI() local isShow= CTL.ChannelChat.IsGuildWarChannel(self.CurrentChannelCfgID) self.ViewPanel.gameObject:SetActive(isShow) self.event_SwitchAudience.gameObject:SetActive(isShow) --显示本方,全体按钮 self.event_Pos.gameObject:SetActive(not isShow) if isShow then --默认显示本方按钮 self.Text_All.gameObject:SetActive(false) self.Text_Team.gameObject:SetActive(true) local currentScoutsCount=CTL.ChannelChat.GetGuildWarScoutsCount() local maxScoutsCount=CTL.ChannelChat.GetGuildWarMaxScoutsCount() local listenCount =CTL.ChannelChat.GetGuildWarListenCount() local totalCount=CTL.ChannelChat.GetGuildWarTotalCount() --斥候 self.txt_ListenNum.text= string.FormatByIdsId(Const_IDS.IDS_WarChannel_ListeningPlayerNum,tostring(listenCount),tostring(totalCount)) self.txt_ScoutNum.text= string.FormatByIdsId(Const_IDS.IDS_WarChannel_ScoutNum,tostring(currentScoutsCount),tostring(maxScoutsCount)) self.txt_JobBoss.text=UIUtils.GetLocalizedTxt(Const_IDS.IDS_Guild_Leader) self.txt_JobBoss2.text=UIUtils.GetLocalizedTxt(Const_IDS.IDS_Guild_Commander3) --收听 local isListening=CTL.VoiceRoom.IsEnabledListener() if isListening and not self.sendListeningMsg then self.sendListeningMsg=true MDL.GuildWar.SendGuildWarListen(PlayerInfoManager.AcID) end self.slider_Listen.value=isListening and 1 or 0 self.lab_Listen.gameObject:SetActive(isListening) self.lab_Listen.text= UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_Listening) self.lab_Close.gameObject:SetActive(not isListening) self.lab_Close.text= UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_NotListening) --主公、太尉信息 local leaderName, leaderSex, leaderPortraitId, leaderFrameId =CTL.ChannelChat.GetGuildLeaderInfo() local elderName, elderSex, elderPortraitId, elderFrameId =CTL.ChannelChat.GetGuildJunshiElderInfo() self.txt_Player.text=leaderName self.txt_Player2.text=elderName CTL.Player.OperateGenderImage(self.img_Gender1, leaderSex) CTL.Character.SetPortraitAndFrame(self.UIHeroHead150Main, leaderPortraitId, leaderFrameId) --主公头像 if elderPortraitId then CTL.Character.SetPortraitAndFrame(self.UIHeroHead150Sub, elderPortraitId, elderFrameId) -- 太尉头像 CTL.Player.OperateGenderImage(self.img_Gender2, elderSex) UIUtils.SetActive(self.img_Gender2, true) else CTL.Character.SetHeadEmpty(self.UIHeroHead150Sub) UIUtils.SetActive(self.img_Gender2, false) end if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIChannelChatMember) then self.group_ScoutView.gameObject:SetActive(false) self.group_ScoutBack.gameObject:SetActive(true) else self.group_ScoutView.gameObject:SetActive(true) self.group_ScoutBack.gameObject:SetActive(false) end --刷新小地图的UI CTL.ChannelChat.RefreshGuildWarMapUI() end end ------------------------------军团战场 UI相关 end------------------ -- 刷新综合频道 function UIChannelChatMain:OnNewMsgByMixtureChannel() if not MDL.ChannelChat.IsMixtureChannelByCfgId(self.CurrentChannelCfgID) then return end self:OnNewMsg() end -- 刷新其他频道 function UIChannelChatMain:OnNewMsg() local _channelID = self:GetChannelID() local chatList = nil if MDL.ChannelChat.IsCurrentChannelByPrefix(_channelID) then --当前频道数据单独获取 chatList = MDL.ChannelChat.GetCurrentChannelMsgList() elseif MDL.ChannelChat.IsMixtureChannelByCfgId(self.CurrentChannelCfgID) then chatList = MDL.ChannelChat.GetDlgMsgList() else chatList = MDL.ChannelChat.GetChannelChatList(_channelID) end local v = chatList[#chatList] if v and not MDL.ChannelChat.IsMsgFromBlack(v) then if v.isSelf then self.obj_ScrollPanel:AddDynamicData(v,0) elseif v.heroId == nil or v.heroId <= 0 then self.obj_ScrollPanel:AddDynamicData(v,2) else self.obj_ScrollPanel:AddDynamicData(v,1) end self.obj_ScrollPanel:MoveEnd() UIUtils.SetActive(self.group_Empty, false) end end function UIChannelChatMain:OnHistoryMsg(isHistoryNil) if isHistoryNil then if self.obj_loading then UIUtils.SetActive(self.obj_loading.gameObject, false) end return end self:RefreshLoopScroll() --拉取消息之后,挪到上一次的位置,且只显示消息的一半 if self.lastTopLineMsg then local hasMoveTarget = false local chatMsgList = self:GetChatMsgList() for i, v in ipairs(chatMsgList) do if v == self.lastTopLineMsg then self.obj_ScrollPanel:MoveIndex(i - 2) hasMoveTarget = true break end end if hasMoveTarget then local oriX, oriY = self.chatLoopScrollContentTrans:GetAnchoredPosition() self.chatLoopScrollContentTrans:SetAnchoredPosition(oriX, oriY + self.lastTopLineOffset * 0.5) else self.obj_ScrollPanel:MoveBegin() end end self:UpdateSubChannelDesc() end function UIChannelChatMain:OnJoinChannel() self:UpdateSubChannelDesc() end function UIChannelChatMain:UpdateSubChannelDesc() if self.CurrentChannelCfgID then if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Cross then local curSuffix = MDL.ChannelChat.GetCurCrossSubChannelSuffix() if self.curCrossSuffix ~= curSuffix then self:OnSwitchCross(curSuffix, false) self.curCrossSuffix = curSuffix end end end end function UIChannelChatMain:OnSwitchCross(suffix, isClear) for i, v in MDL.OperationActivity.CrossServerChatRoom:GetEnumerator() do if suffix == v.Suffix then UIUtils.SetLabelText(self.txt_ChannelName, Const_IDS[v.RoomType]) break end end self:OnCloseSwitchSubChannel() if isClear then self.obj_ScrollPanel:ClearCells() else self:RefreshLoopScroll() end end function UIChannelChatMain:OnClickSuoNaButton() self:OnButtonClicked(self.event_Suona) end --喇叭 function UIChannelChatMain:OnClickTrumpet() local constLevel = DataSheetManager.ConstData:GetDataByID("ChatHornLevel").IntValue if MDL.Player.GetRoleLevel() < constLevel then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_Chat_HornLevel, constLevel)) return end if self.IsOpenSuoNa then return end self.IsOpenSuoNa = true UIUtils.SetActive(self.DownBtnPanel, false) if MDL.Player.GetPublicSentimentUnLock() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIChannelChatSendSuoNaMsg) end end function UIChannelChatMain:IsOutOfLengthWhenInsertContent(content) return not CTL.ChannelChat.IsOutOfLengthWhenInsertContent(content, self:GetChannelID()) end function UIChannelChatMain:OnCommonClickEmoji(data) local emojiShow = string.format("[%s]", UIUtils.GetLocalizedTxt(Const_IDS[data.EmojiName])) if self.IsOpenSuoNa then EventSystem.Dispatch(EventID.UI_ChannelChat_SendSuoNaMsg, emojiShow) return end local msg = self.obj_InputField.text if self:IsOutOfLengthWhenInsertContent(msg .. emojiShow) then msg = msg .. emojiShow self:SetInputTextAndMoveEnd(msg, true) end end --发送 function UIChannelChatMain:OnClickSend() if self.group_Condition.gameObject.activeSelf then self.group_Condition.gameObject:SetActive(false) end --军团战的话,消息要加前缀 --龙脉战同军团战,加前缀 if CTL.ChannelChat.IsGuildWarChannel(self.CurrentChannelCfgID) or (self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.SpecifiedActivity and BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArtery)) then if string.isNilOrEmpty(self.obj_InputField.text) then self:SendMsg("") else local content = self:GetSendContentWithAllPrefix(self.obj_InputField.text) self:SendMsg(content) end elseif CTL.ChannelChat.IsGVGFightChannel(self.CurrentChannelCfgID) then -- 攻城略地需要判断消耗 if UTL.Item.GetItemStockCount(CTL.GVGFight.GVGFightChatCostItem) < CTL.GVGFight.GVGFightChatCostNum then UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_Store_BuyButton, Const_IDS.IDS_GVGFight_ChatTips1, function() for _, v in MDL.OperationActivity.StoreGoodsData:GetEnumerator() do if v.ItemID == CTL.GVGFight.GVGFightChatCostItem then UTL.ItemTips.OpenQuickPurchaseView(v.ID) return end end end) else self:SendMsg(self.obj_InputField.text) end else --正常发,不需要前缀 self:SendMsg(self.obj_InputField.text) end end --表情 function UIChannelChatMain:OnClickFace(isOpenByExternal) if isOpenByExternal then self:ChangePos(true) else self:ChangePos(false) end if self.group_Condition.gameObject.activeSelf then self.group_Condition.gameObject:SetActive(false) else self.group_Condition.gameObject:SetActive(true) self.toggle_TopGroup:SelectIndex(self.EmojiIndex) end end --坐标 function UIChannelChatMain:OnClickPos() self:ClickBtnLocation() end function UIChannelChatMain:OnClickBackBtn() MDL.ChannelChat.SetCurChannelID("") self:CloseView() end function UIChannelChatMain:OnClickClose() MDL.ChannelChat.SetCurChannelID("") if self.context.subView then EventSystem.Dispatch(EventID.UI_ChannelChat_DeadCloseParentView) else self:CloseView() end MDL.ChannelChat.SetNotSendMsg(self.obj_InputField.text); EventSystem.Dispatch(EventID.UI_ChannelChat_CloseSuoNa) end function UIChannelChatMain:OnClickChangeChannel() if isThemePanelOpen then self.sprite_UpArrow.gameObject:SetActive(true) self.sprite_DownArrow.gameObject:SetActive(false) isThemePanelOpen = false self.obj_ThemePanel.gameObject:SetActive(false) else self.sprite_UpArrow.gameObject:SetActive(false) self.sprite_DownArrow.gameObject:SetActive(true) isThemePanelOpen = true self.obj_ThemePanel.gameObject:SetActive(true) end end function UIChannelChatMain:OnClickTheme1() self.sprite_UpArrow.gameObject:SetActive(true) self.sprite_DownArrow.gameObject:SetActive(false) isThemePanelOpen = false self.obj_ThemePanel.gameObject:SetActive(false) MDL.ChannelChat.SetCurChannelID(MDL.ChannelChat.ChannelID.BaGuaChannel) --修改主题名 UIUtils.SetLabelText(self.labLocal_ChangeChannel,Const_IDS.IDS_LiaoTian_Channelname7) --变更频道消息内容 self:RefreshLoopScroll() themeSelect = "1" end function UIChannelChatMain:OnClickTheme2() self.sprite_UpArrow.gameObject:SetActive(true) self.sprite_DownArrow.gameObject:SetActive(false) isThemePanelOpen = false self.obj_ThemePanel.gameObject:SetActive(false) MDL.ChannelChat.SetCurChannelID(MDL.ChannelChat.ChannelID.GongLueChannel) UIUtils.SetLabelText(self.labLocal_ChangeChannel,Const_IDS.IDS_LiaoTian_Channelname8) self:RefreshLoopScroll() themeSelect = "2" end function UIChannelChatMain:OnClickTheme3() self.sprite_UpArrow.gameObject:SetActive(true) self.sprite_DownArrow.gameObject:SetActive(false) isThemePanelOpen = false self.obj_ThemePanel.gameObject:SetActive(false) MDL.ChannelChat.SetCurChannelID(MDL.ChannelChat.ChannelID.MengMianChannel) UIUtils.SetLabelText(self.labLocal_ChangeChannel,Const_IDS.IDS_LiaoTian_Channelname9) self:RefreshLoopScroll() themeSelect = "3" end function UIChannelChatMain:OnClickTheme4() self.sprite_UpArrow.gameObject:SetActive(true) self.sprite_DownArrow.gameObject:SetActive(false) isThemePanelOpen = false self.obj_ThemePanel.gameObject:SetActive(false) MDL.ChannelChat.SetCurChannelID(MDL.ChannelChat.ChannelID.XiuChangChannel) UIUtils.SetLabelText(self.labLocal_ChangeChannel,Const_IDS.IDS_LiaoTian_Channelname10) self:RefreshLoopScroll() themeSelect = "4" end function UIChannelChatMain:HideAllSelectBtn() self.event_WorldSelect.gameObject:SetActive(false) self.event_TeamSelect.gameObject:SetActive(false) self.event_GuildSelect.gameObject:SetActive(false) self.event_ThemeSelect.gameObject:SetActive(false) self.event_SystemSelect.gameObject:SetActive(false) self.event_ZoneSelect.gameObject:SetActive(false) end function UIChannelChatMain:RefreshChannelRedPoint(channelID) if MDL.ChannelChat.IsWorldChannelByChannelId(channelID) then self.sprite_WorldRedPoint.gameObject:SetActive(true) end if MDL.ChannelChat.IsTeamChannelByChannelId(channelID) then self.sprite_TeamRedPoint.gameObject:SetActive(true) end end function UIChannelChatMain:RefreshRedPoint() if MDL.ChannelChat.GetWorldChannelNewMsg() then self.sprite_WorldRedPoint.gameObject:SetActive(true) end if MDL.ChannelChat.GetTeamChannelNewMsg() then self.sprite_TeamRedPoint.gameObject:SetActive(true) end end function UIChannelChatMain:OnClickTalk() local curState = self.state_Talk.CurState if curState == 0 then self.state_Talk:SetState(1) else self.state_Talk:SetState(0) UIUtils.SetLabelText(self.lab_Talk, Const_IDS.IDS_AudioChat_Press) end end function UIChannelChatMain:OnBackButtonPressed() self:OnButtonClicked(self.event_BgClose) end function UIChannelChatMain:OnButtonClicked(obj) if(obj==self.event_UnRead) then self:OnClickUnRead() elseif(obj==self.event_Suona) then self:HideFace() self:OnClickTrumpet() elseif(obj==self.event_Talk) then self:OnClickTalk() elseif(obj==self.event_Send) then --处于禁言状态 if MDL.HomeMain.GetSilenceBuff() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_OfficialPrivilege_FailInSend) self:RefreshLoopScroll() return elseif CTL.Country.IsShutUp(self.CurrentChannelCfgID) then return else self:OnClickSend() end elseif(obj==self.event_Face) then self:OnClickFace() elseif(obj==self.event_Pos) then self:OnClickPos() elseif(obj==self.event_Close) then self:OnClickClose() elseif(obj==self.event_BackBtn) then UIManager.CloseView(Const_UI_Lua.UIEnum.UIChannelChatMember) self:OnClickClose() elseif(obj==self.event_ChangeChannel) then self:OnClickChangeChannel() elseif(obj==self.event_Theme1) then self:OnClickTheme1() elseif(obj==self.event_Theme2) then self:OnClickTheme2() elseif(obj==self.event_Theme3) then self:OnClickTheme3() elseif(obj==self.event_Theme4) then self:OnClickTheme4() elseif obj == self.event_Setting then self:OnClickSetting() elseif obj == self.event_Setting_BackBtn then self:OnClickSetting() elseif obj == self.event_Condition_BackBtn then self:OnClickFace() elseif obj == self.BtnLocation then self:ClickBtnLocation() elseif obj== self.btn_Click then --保存快捷信息 self:Cell_OnDeselect(nil, nil) elseif obj==self.btn_View then self:OnClickView() elseif obj==self.event_SwitchAudience then --军团站本方 全体 if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.SpecifiedActivity and BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArtery) then self:OnClickDragonArteryTeam() else self:OnClickGuildWarTeam() end elseif obj==self.btn_JoinIn then self:OnClickJoinChatRooms() elseif obj==self.btn_Mic then self:OnClickMicrophone() elseif obj==self.btn_Jump2Guild then self:OnJump2GuildChannel() elseif obj == self.event_BgClose then self:OnClickClose() elseif obj == self.btn_SwitchCross then self:OpenSwitchSubChannel() elseif obj == self.mask_SwitchChannel then self:OnCloseSwitchSubChannel() elseif obj == self.btn_SubtitleSetting then -- 弹幕设置 UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1SubtitleSetting) end end function UIChannelChatMain:OnCloseSwitchSubChannel() self.loop_CrossChannel:ClearCells() UIUtils.SetActive(self.group_ChannelList, false) UIUtils.SetActive(self.mask_SwitchChannel, false) end function UIChannelChatMain:OnClickDragonArteryTeam() isSendTeamInDragonArtery = not isSendTeamInDragonArtery self:OnAudienceSwitch(isSendTeamInDragonArtery) end --切换发送 本方/全体 (军团战) function UIChannelChatMain:OnClickGuildWarTeam() isSendTeamInGuildWar = not isSendTeamInGuildWar self:OnAudienceSwitch(isSendTeamInGuildWar) end function UIChannelChatMain:OnAudienceSwitch(isTeam) UIUtils.SetActive(self.Text_All, not isTeam) UIUtils.SetActive(self.Text_Team, isTeam) end --发送内容带上【全体】前缀 function UIChannelChatMain:GetSendContentWithAllPrefix(content) if not isSendTeamInGuildWar or not isSendTeamInDragonArtery then content = UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_All_InChannel) .. content end return content end --设定标题颜色 function UIChannelChatMain:SetTitleColor(acid,labelTitle) local r,g,b=0,0,0 local isShowGuildWar= CTL.ChannelChat.IsGuildWarChannel(self.CurrentChannelCfgID) --军团战颜色特殊 if isShowGuildWar then local isMe = acid ==BattleDataGetter.GetAcID() local isMyGuild = MDL.Guild.IsMember(acid) if isMe then r,g,b=79/255,222/255,243/255--浅蓝色 elseif isMyGuild then r,g,b=128/255,169/255,245/255 --蓝色 else r=1 --红色 end else --其它频道白色 r,g,b=1,1,1 end UIUtils.SetLocalTextColor(labelTitle,r,g,b) end --查看斥候界面 function UIChannelChatMain:OnClickView() MDL.GuildWar.SendGetGuildWarScoutsList() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIChannelChatMember) then UIManager.CloseView(Const_UI_Lua.UIEnum.UIChannelChatMember) self.group_ScoutView.gameObject:SetActive(true) self.group_ScoutBack.gameObject:SetActive(false) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIChannelChatMember) self.group_ScoutView.gameObject:SetActive(false) self.group_ScoutBack.gameObject:SetActive(true) end end function UIChannelChatMain:ShowScoutViewBtn() self.group_ScoutView.gameObject:SetActive(true) self.group_ScoutBack.gameObject:SetActive(false) end --显示输入框 function UIChannelChatMain:DisplayInputField() -- 打开号角的时候 不能显示 DownBtnPanel 输入节点 UIUtils.SetActive(self.DownBtnPanel.gameObject, MDL.Player.GetPublicSentimentUnLock() and not self.IsOpenSuoNa) UIUtils.SetActive(self.group_None, false) UIUtils.SetActive(self.group_NotTalk, false) UIUtils.SetActive(self.group_Lock, false) UIUtils.SetActive(self.group_ForbiddenWords, false) end --是否隐藏输入框,没有队伍显示加队按钮 function UIChannelChatMain:IsDisplayTeamTips(isDisplay) if isDisplay then UIUtils.SetActive(self.group_None, true) UIUtils.SetActive(self.DownBtnPanel.gameObject, false) UIUtils.SetLabelText(self.lab_DuiwuNone,Const_IDS.IDS_Chat_ConditionTeam) else UIUtils.SetActive(self.group_None, false) end end function UIChannelChatMain:IsDisplayGuildTips(isDisplay) if isDisplay then UIUtils.SetActive(self.group_None, true) UIUtils.SetActive(self.DownBtnPanel.gameObject, false) UIUtils.SetLabelText(self.lab_DuiwuNone, Const_IDS.IDS_Chat_ConditionLegion) else UIUtils.SetActive(self.group_None, false) end end function UIChannelChatMain:IsDisplayCountryTips(isDisplay) if isDisplay then UIUtils.SetActive(self.group_None, true) UIUtils.SetActive(self.DownBtnPanel.gameObject, false) UIUtils.SetLabelText(self.lab_DuiwuNone, Const_IDS.IDS_Country_NotInCountryReminder) else UIUtils.SetActive(self.group_None, false) end end function UIChannelChatMain:isDisplayWarZoneTips(isDisplay, countDownTimestamp) if isDisplay then UIUtils.SetActive(self.group_None, true) UIUtils.SetActive(self.DownBtnPanel.gameObject, false) if countDownTimestamp then UIUtils.SetActive(self.lab_DuiwuNone, false) UIUtils.SetActive(self.lab_CountDown, true) self.lab_CountDown:SetDHMSStr( string.FormatByIdsId(Const_IDS["IDS_7DayActivityNew_Hint1"], UIUtils.GetLocalizedTxt(Const_IDS["IDS_PreviewTime1"])), string.FormatByIdsId(Const_IDS["IDS_7DayActivityNew_Hint1"], UIUtils.GetLocalizedTxt(Const_IDS["IDS_PreviewTime2"])), string.FormatByIdsId(Const_IDS["IDS_7DayActivityNew_Hint1"], UIUtils.GetLocalizedTxt(Const_IDS["IDS_PreviewTime3"])), string.FormatByIdsId(Const_IDS["IDS_7DayActivityNew_Hint1"], UIUtils.GetLocalizedTxt(Const_IDS["IDS_PreviewTime4"])) ) if countDownTimestamp <= UTL.Time.TotalSecondsOneHour then self:StartRepeatFunc(self.RefreshWarZoneShow, countDownTimestamp + 1, 1) end self.lab_CountDown:ResetAndBeginCustomTimer(false, countDownTimestamp, 0, nil, 1) end else UIUtils.SetActive(self.group_None, false) end end --是否隐藏输入框,显示当前频道不能 输入 function UIChannelChatMain:IsDisplayCanNotInPutTips(isDisplay) if isDisplay then UIUtils.SetActive(self.group_NotTalk, true) UIUtils.SetActive(self.DownBtnPanel.gameObject, false) else UIUtils.SetActive(self.group_NotTalk, false) end end --是否显示解锁条件 function UIChannelChatMain:IsDisplayLockTips(isDisplay, content) if isDisplay then UIUtils.SetActive(self.group_Lock, true) self.lab_LockCondition.text = content UIUtils.SetActive(self.DownBtnPanel.gameObject, false) else UIUtils.SetActive(self.group_Lock, false) end end --刷新跨服聊天UI function UIChannelChatMain:RefreshCrossChatUI() if self.CurrentChannelCfgID and self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Cross then UIUtils.SetActive(self.group_SwitchChannel, true) local curSuffix = MDL.ChannelChat.GetCurCrossSubChannelSuffix() for i,v in MDL.OperationActivity.CrossServerChatRoom:GetEnumerator() do if curSuffix == v.Suffix then UIUtils.SetLabelText(self.txt_ChannelName,Const_IDS[v.RoomType]) break end end self.curCrossSuffix = curSuffix else UIUtils.SetActive(self.group_SwitchChannel, false) UIUtils.SetActive(self.group_ChannelList, false) end end --活动聊天UI function UIChannelChatMain:RefreshSpecifiedActivityChatUI() if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.SpecifiedActivity and BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArtery) then --龙脉战需求:上方显示势力语音,下方显示频道切换 UIUtils.SetActive(self.event_SwitchAudience, true) else UIUtils.SetActive(self.event_SwitchAudience, false) end end function UIChannelChatMain:OpenSwitchSubChannel() UIUtils.SetActive(self.group_ChannelList, true) UIUtils.SetActive(self.mask_SwitchChannel, true) self.loop_CrossChannel:ClearCells() local index = 0 if self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.Cross then local dataList = {} for i, v in MDL.OperationActivity.CrossServerChatRoom:GetEnumerator() do table.insert(dataList,v) end table.sort(dataList,self.SortCrossServerChatRoom) for i,v in ipairs(dataList) do self.loop_CrossChannel:AddData(v, 0) index = index + 1 end end local line = math.ceil(index / 2) self.group_ChannelListBG.transform:SetSizeDelta(nil, SWITCH_BG_UNIT * (line - 1) + SWITCH_BG_OFFSET) end function UIChannelChatMain.SortCrossServerChatRoom(a,b) return a.Sort < b.Sort end --显示禁言 function UIChannelChatMain:DisplayForbiddenWords(content) UIUtils.SetActive(self.group_ForbiddenWords, true) UIUtils.SetActive(self.DownBtnPanel.gameObject, false) self.txt_NotTalk.text = string.FormatByIdsId(Const_IDS.IDS_OfficialPrivilege_Forbidden, content.optName) local offsetTime = content.endTime - UTL.Time.GetServerTimestamp() self.timer_NotTalk:SetDHMSStr(UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow), "{0}:{1}:{2}", "{0}:{1}", "{0}:{1}") self.timer_NotTalk:ResetAndBeginCustomTimer(false, offsetTime, 0, nil) end --未读消息显隐 function UIChannelChatMain:OnNotReadMsg() local count = MDL.ChannelChat:GetNotReadMsgCount() if count > 0 then --显示未读消息提示 self:SetUnReadShow(true, count) local chatList = {} if MDL.ChannelChat.IsCurrentChannelByPrefix(self:GetChannelID()) then -- 当前频道数据单独获取 chatList = MDL.ChannelChat.GetCurrentChannelMsgList() elseif MDL.ChannelChat.IsMixtureChannelByCfgId(self.CurrentChannelCfgID) then chatList = MDL.ChannelChat.GetDlgMsgList() else chatList = MDL.ChannelChat.GetChannelChatList(self:GetChannelID()) end local v = chatList[#chatList] if v.isSelf then self.obj_ScrollPanel:AddDynamicData(v, 0) self.obj_ScrollPanel:MoveEnd() self:SetUnReadShow(false) MDL.ChannelChat.ResetNotReadMsgCount() MDL.ChannelChat.SetIsDragToEnd(true) elseif v.heroId == nil or v.heroId <= 0 then self.obj_ScrollPanel:AddDynamicData(v,2) else self.obj_ScrollPanel:AddDynamicData(v, 1) end else --隐藏未读消息提示 self:SetUnReadShow(false, 0) end end --未读消息 function UIChannelChatMain:IsDisplayNewMsgTips(isDisplay) if isDisplay == false then self:SetUnReadShow(false) MDL.ChannelChat.ResetNotReadMsgCount() MDL.ChannelChat.SetIsDragToEnd(true) end end -- --region-----------Setting--------------------------------------------- function UIChannelChatMain:InitSetting() if self.hasInitSetting == true then return end -- 主界面聊天框 self.sortedSettingList = MDL.ChannelChat.GetSortedChatSettingList() for i, v in ipairs(self.sortedSettingList) do local toggleSet = self:InstantiateCollection(self.toggleSetCol, self.toggleSet.gameObject) UIUtils.SetActive(toggleSet.gameObject, true) UIUtils.SetLabelText(toggleSet.lab_toggle, Const_IDS[v.ChannelImgName]) toggleSet.toggle.isOn = MDL.ChannelChat.GetSettingValue(v.ID) end -- 语音自动播放开关 self.sortedAutoPlayVoiceSettings = MDL.ChannelChat.GetSortedAutoPlayVoiceSettings() for i, v in ipairs(self.sortedAutoPlayVoiceSettings) do local toggleSet = self:InstantiateCollection(self.toggleAutoPlayCol, self.toggleSet.gameObject) UIUtils.SetActive(toggleSet.gameObject, true) UIUtils.SetLabelText(toggleSet.lab_toggle,Const_IDS[v.ChannelImgName]) toggleSet.toggle.isOn = MDL.ChannelChat.GetAutoPlayVoiceChannelState(v.ID) end -- 弹幕频道开关 if GameAppInfo.IsJapanesePackage() or GameAppInfo.IsVietnamPackage() then UIUtils.SetActive(self.group_Barrage.gameObject, false) else self.sortedAutoPlayBulletScreenSettings = MDL.ChannelChat.GetSortedAutoPlayBulletScreenSettings() local isShowBullet = self.sortedAutoPlayBulletScreenSettings and #self.sortedAutoPlayBulletScreenSettings > 0 UIUtils.SetActive(self.group_Barrage.gameObject, isShowBullet and true or false) if isShowBullet then for i, v in ipairs(self.sortedAutoPlayBulletScreenSettings) do local toggleSet = self:InstantiateCollection(self.toggleBarrageCol, self.toggleSet.gameObject) UIUtils.SetActive(toggleSet.gameObject, true) UIUtils.SetLabelText(toggleSet.lab_toggle, Const_IDS[v.ChannelImgName]) toggleSet.toggle.isOn = MDL.ChannelChat.GetAutoPlayBulletScreenChannelState(v.ID) end end end self.hasInitSetting = true end function UIChannelChatMain:OnClickSetting() if self.group_Setting.gameObject.activeSelf then self.group_Setting.gameObject:SetActive(false) else self.group_Setting.gameObject:SetActive(true) self:InitSetting() end end function UIChannelChatMain:OnValueChanged(comp, value) if comp == self.toggle_TopGroup then self:SwitchCondition(value) elseif comp == self.obj_InputField then self.obj_InputField.text = string.gsub(self.obj_InputField.text, "\n", "") elseif comp == self.objQuickMsg_InputField then elseif comp == self.toggle_ShowSubtitle then CTL.WatchBattle.SetIsShowBullet(value) else local isAutoSet = false for i, v in ipairs(self.toggleAutoPlayCol) do if v.toggle == comp then local data = self.sortedAutoPlayVoiceSettings[i] MDL.ChannelChat.SetAutoPlayVoiceChannel(data.ID, value) isAutoSet = true break end end -- 弹幕开关设置 for i, v in ipairs(self.toggleBarrageCol) do if v.toggle == comp then local data = self.sortedAutoPlayBulletScreenSettings[i] MDL.ChannelChat.SetAutoPlayBulletScreenChannel(data.ID, value) isAutoSet = true break end end if isAutoSet == false then for i, v in ipairs(self.toggleSetCol) do if v.toggle == comp then local data = self.sortedSettingList[i] MDL.ChannelChat.SetSettingValue(data.ID, value) break end end end end end -- --end region-----------Setting--------------------------------------------- function UIChannelChatMain:IsDisplaySendObj(isDisplay) self.IsOpenSuoNa = not isDisplay local isOpen, unlockMsg = MDL.ChannelChat.IsChannelOpen(self.CurrentChannelCfgID) if not isOpen then return end self:HideFace() if self:IsCanSend() then UIUtils.SetActive(self.DownBtnPanel, MDL.Player.GetPublicSentimentUnLock() and isDisplay) end end function UIChannelChatMain:IsCanSend() local silence = MDL.HomeMain.GetSilenceBuff() if silence ~= nil and MDL.ChannelChat.IsInSilenceChannelByCfgId(self.CurrentChannelCfgID) then return false end if MDL.ChannelChat.IsMixtureChannelByCfgId(self.CurrentChannelCfgID) then return false elseif MDL.ChannelChat.IsSystemChannelByCfgId(self.CurrentChannelCfgID) then return false elseif MDL.ChannelChat.IsZhaoMuChannelByCfgId(self.CurrentChannelCfgID) then return false elseif MDL.ChannelChat.IsLegionChannelByCfgId(self.CurrentChannelCfgID) then return MDL.Guild.IsHasGuild() elseif MDL.ChannelChat.IsTeamChannelByCfgId(self.CurrentChannelCfgID) then return CTL.Team.IsInTeam() elseif MDL.ChannelChat.IsWarZoneChannelByCfgId(self.CurrentChannelCfgID) then return CTL.ChannelChat.CanJoinWarZoneChannel() end return true end function UIChannelChatMain:HideFace() self.group_Condition.gameObject:SetActive(false) end function UIChannelChatMain:IsOpenFacePanel(isDisplay) self:OnClickFace(true) end function UIChannelChatMain:ChangePos(isChange) local anchorPosX, anchorPosY = self.BtnLocation.transform:GetAnchoredPosition() if isChange then self.toggle_TopGroup:SetToggleActive(2, false) self.toggle_TopGroup:SetToggleActive(3, false) self.BtnLocation.transform:SetAnchoredPosition(130, nil) else self.toggle_TopGroup:SetToggleActive(2, true) self.toggle_TopGroup:SetToggleActive(3, true) self.BtnLocation.transform:SetAnchoredPosition(384, nil) end end function UIChannelChatMain:SwitchCondition(index) self.obj_state:SetState(index) self.CurrentConditionIndex = index if self.ChatHistoryIndex == index then self.chat_history_scroll:ClearCells() local historyDatas = MDL.ChannelChat.GetInputHistoryData() for i = 1, #historyDatas do self.chat_history_scroll:AddData(historyDatas[i], 0) end UIUtils.SetActive(self.lab_Empty, #historyDatas < 1) UIUtils.SetLabelText(self.lab_Empty, Const_IDS["IDS_Chat_ChatHistoryEmpty"]) elseif self.QuickMsgIndex == index then local quickDatas = MDL.ChannelChat.GetQuickMsgData() self.QuickMsgScroll:ReloadAll(quickDatas) elseif self.EmojiIndex == index then self.Emoji_Condition:ReloadAll(MDL.ChannelChat.GetSortedEmojiList()) end end function UIChannelChatMain:SendMsg(content, isHistory) if MDL.ChannelChat.CanSendMsg() then local msg = content if MDL.ChannelChat.IsJoinChannel(self.CurrentChannelCfgID) and not CTL.ChannelChat.IsOutOfLength(msg, self:GetChannelID()) then if MDL.ChannelChat.IsBulletChannelByCfgId(self.CurrentChannelCfgID) then -- 弹幕频道加上颜色 CTL.ChannelChat.SendTextMsg(msg, self:GetChannelID(), nil, nil, CTL.WatchBattle.GetBulletColor()) else CTL.ChannelChat.SendTextMsg(msg, self:GetChannelID(), isHistory) end end else CTL.Tips.AddTipsMsg(MDL.ChannelChat.GetForbiddenMsg()) end end --输入坐标 function UIChannelChatMain:ClickBtnLocation() local levelId = LevelManager.GetCurLevelID() if not CTL.ChannelChat.CanTransferByLocation(levelId, true) then return end local matchCount = 0 for i in string.gmatch(self.obj_InputField.text, CTL.ChannelChat.GetLocationHyperlinkPattern()) do matchCount = matchCount + 1 end if matchCount >= 1 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Chat_OneCoordinate) return end local posX, posY = FP.tonumberV2(BattleDataGetter.GetMainPlayerLastLogicPos()) local line = BattleDataGetter.GetCurLine() local content = CTL.ChannelChat.ComposeLocation(levelId, math.ceil(posX) , math.ceil(posY), line) if self.IsOpenSuoNa then EventSystem.Dispatch(EventID.UI_ChannelChat_SendSuoNaMsg, content) return end local tmp = self.obj_InputField.text .. content if self:IsOutOfLengthWhenInsertContent(tmp) then self:SetInputTextAndMoveEnd(tmp) end end function UIChannelChatMain:SetInputTextAndMoveEnd(txt, isHideMobileInput) self.obj_InputField.text = txt if not isHideMobileInput then self.obj_InputField:ActivateInputField() end --光标移动需要激活之后等一帧生效 self:StartRepeatFunc(function() self.obj_InputField:MoveTextEnd(false) end, 0.02, 1) end --------------------------势力实时语音相关----------Start---------------- function UIChannelChatMain:RefreshChatUI() if MDL.Guild.IsHasGuild() == false then UIUtils.SetActive(self.group_VoiceChat, false) return end if CTL.VoiceRoom.IsInVoiceRoom(MDL.VoiceRoom.VoiceRoomType.ChangAnSiege) then UIUtils.SetActive(self.group_VoiceChat, false) return end local isListening = CTL.VoiceRoom.IsEnabledListener() local isInVoiceChannel = false local roomType if MDL.ChannelChat.IsLegionChannelByCfgId(self.CurrentChannelCfgID) then isInVoiceChannel = true roomType = MDL.VoiceRoom.VoiceRoomType.Guild elseif self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.SpecifiedActivity and BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArtery) then isInVoiceChannel = true roomType = MDL.VoiceRoom.VoiceRoomType.DragonArtery end local curRoomType = MDL.VoiceRoom.VoiceRoomType.None if CTL.VoiceRoom.IsInVoiceRoom(MDL.VoiceRoom.VoiceRoomType.Guild) or CTL.VoiceRoom.IsInVoiceRoom(MDL.VoiceRoom.VoiceRoomType.DragonArtery) then curRoomType = CTL.VoiceRoom.GetCurRoomType() end if curRoomType == MDL.VoiceRoom.VoiceRoomType.None then curRoomType = roomType end if isInVoiceChannel then UIUtils.SetActive(self.group_VoiceChat, true) UIUtils.SetActive(self.btn_JoinIn, curRoomType == roomType) UIUtils.SetActive(self.btn_Mic, curRoomType == roomType) self:StopEffectByCanvas(self.effect_Bg) UIUtils.SetActive(self.btn_Jump2Guild, false) self.ListeningCount = CTL.ChannelChat.GetVoiceListenCount(curRoomType) --是否收听 if not isListening then self.state_BtnJoin:SetState(0) --是否有人 if self.ListeningCount > 0 then self.state_Lab:SetState(0) UIUtils.SetLabelText(self.lab_StatusText, CTL.ChannelChat.GetVoiceRoomWarnIDS(curRoomType, 1)) self.state_Mic:SetState(2) self:PlayEffectByCanvas(self.effect_InChat) else self.state_Lab:SetState(1) UIUtils.SetLabelText(self.lab_StatusText, CTL.ChannelChat.GetVoiceRoomWarnIDS(curRoomType, 1)) self:StopEffectByCanvas(self.effect_InChat) self.state_Mic:SetState(1) end else --开麦 self.state_BtnJoin:SetState(1) self.state_Mic:SetState(0) UIUtils.SetActive(self.btn_Mic, curRoomType == roomType) local isOpenMic = CTL.VoiceRoom.IsEnabledMicrophone() if isOpenMic then self.state_Lab:SetState(3) UIUtils.SetLabelText(self.lab_StatusText, CTL.ChannelChat.GetVoiceRoomWarnIDS(curRoomType, 3)) self.state_BtnMic:SetState(0) else self.state_Lab:SetState(2) UIUtils.SetLabelText(self.lab_StatusText, CTL.ChannelChat.GetVoiceRoomWarnIDS(curRoomType, 2)) self.state_BtnMic:SetState(1) end local str = string.FormatByIdsId(Const_IDS.IDS_GuildVoiceChat_PlayerNum, self.ListeningCount) UIUtils.SetActive(self.lab_ChatNum, true) self.lab_ChatNum.text = str end else if isListening then UIUtils.SetActive(self.group_VoiceChat, true) UIUtils.SetActive(self.btn_JoinIn, false) UIUtils.SetActive(self.btn_Mic, false) self.state_Lab:SetState(4) UIUtils.SetLabelText(self.lab_StatusText, CTL.ChannelChat.GetVoiceRoomWarnIDS(curRoomType, 4)) self:PlayEffectByCanvas(self.effect_Bg) UIUtils.SetActive(self.btn_Jump2Guild, true) UIUtils.SetActive(self.lab_ChatNum, false) else UIUtils.SetActive(self.group_VoiceChat, false) end end end --开闭麦 function UIChannelChatMain:OnClickMicrophone() local curRoomType = self:GetEnteringVoiceRoomType() if CTL.VoiceRoom.IsInVoiceRoom(curRoomType) then local isOpenMic=CTL.VoiceRoom.IsEnabledMicrophone() CTL.VoiceRoom.EnableMicrophone(curRoomType, not isOpenMic) self:RefreshChatUI() if not isOpenMic then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildVoiceChat_Tips_Speak) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildVoiceChat_Tips_Listen) end end CTL.ChannelChat.AcquireCurVoiceListenCount(curRoomType) end --获取当前要进入的语音房间 function UIChannelChatMain:GetEnteringVoiceRoomType() local curRoomType = CTL.VoiceRoom.GetCurRoomType() if curRoomType == MDL.VoiceRoom.VoiceRoomType.None then if MDL.ChannelChat.IsLegionChannelByCfgId(self.CurrentChannelCfgID) then curRoomType = MDL.VoiceRoom.VoiceRoomType.Guild elseif self.CurrentChannelCfgID == MDL.ChannelChat.ChannelCfgId.SpecifiedActivity and BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArtery) then curRoomType = MDL.VoiceRoom.VoiceRoomType.DragonArtery end end return curRoomType end --进出聊天室 function UIChannelChatMain:OnClickJoinChatRooms() local roomType = self:GetEnteringVoiceRoomType() if roomType == MDL.VoiceRoom.VoiceRoomType.Guild then if not BattleDataGetter.IsOnlineTownLevel() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_AudioChat_InCopyMap) return end if CTL.VoiceRoom.IsInVoiceRoom(MDL.VoiceRoom.VoiceRoomType.TeamFairChampionship) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_AudioChat_InCopyMap) return end if CTL.VoiceRoom.IsInVoiceRoom(MDL.VoiceRoom.VoiceRoomType.Room_3V3) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_AudioChat_InCopyMap) return end if CTL.ChannelChat.IsCanShowGuildWarChannel() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildVoiceChat_GuildWarVoiceChat) return end end if not CTL.VoiceRoom.IsInVoiceRoom(roomType) then MDL.ChannelChat.SendEnterVoiceRoom(roomType, CTL.VoiceRoom.GetPreEnterVoiceRoomID(roomType)) CTL.VoiceRoom.EnterVoiceRoom(roomType, CTL.VoiceRoom.GetPreEnterVoiceRoomID(roomType), true, false) else local warnIds if roomType == MDL.VoiceRoom.VoiceRoomType.Guild then warnIds = Const_IDS.IDS_GuildVoiceChat_QuitWindow_Tip else warnIds = Const_IDS.IDS_DragonArtey_QuitTalk end UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_GuildVoiceChat_QuitWindow_Title, warnIds, function() MDL.ChannelChat.SendQuitVoiceRoom(roomType, CTL.VoiceRoom.GetPreEnterVoiceRoomID(roomType)) CTL.VoiceRoom.ExitVoiceRoom(roomType) if roomType == MDL.VoiceRoom.VoiceRoomType.Guild then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildVoiceChat_Tips_Quit) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_DragonArtey_QuitTalk2) end UIUtils.SetActive(self.lab_ChatNum, false) self:RefreshChatUI() end, nil) end CTL.ChannelChat.AcquireCurVoiceListenCount(roomType) end function UIChannelChatMain:OnJump2GuildChannel() self:JumpToSpecifiedChannel(MDL.ChannelChat.ChannelCfgId.Legion) end function UIChannelChatMain:JumpToSpecifiedChannel(channelID) local curChannelId = self.ChannelCfgId local lastSelectIndex = 0 -- 这里切换一次防止服务器加入房间的时候 玩家UI不在这个房间导致聊天混乱 if channelID then for i,v in ipairs(CTL.ChannelChat.GetShowChannelCfgData()) do if channelID == v.ID then self.channelScroll:SelectIndex(i - 1) end if v.ID == curChannelId then lastSelectIndex = i end end end -- 保证加入聊天后可以正常显示回原来的聊天 self.channelScroll:SelectIndex(lastSelectIndex > 0 and lastSelectIndex - 1 or 0) end function UIChannelChatMain:PlayEffectByCanvas(effectTF) effectTF:PlayUIEffect() if self.effectPlayDic[effectTF] == nil then -- PlayUIEffect时 effect的SortingOrder 已经自增了 200 在设置的时候 需要建减掉 200 UIUtils.SetParticleRenderSortingOrder(effectTF, self.UpCanvas, -200 + 10) self.effectPlayDic[effectTF] = 1 end end function UIChannelChatMain:StopEffectByCanvas(effectTF) if self.effectPlayDic[effectTF] == 1 then local upCanvasSortingOrder = self.UpCanvas.sortingOrder -- 关闭之前 需要先恢复effect的SortingOrder, 没调用一次UIUtils.SetParticleRenderSortingOrder 方法 会增加 一次self.UpCanvas.sortingOrder -- 所以此处需要减掉2次,playuieffect 一次,这里一次 UIUtils.SetParticleRenderSortingOrder(effectTF, self.UpCanvas, 200 - 10 - (upCanvasSortingOrder * 2)) self.effectPlayDic[effectTF] = nil end effectTF:StopUIEffect() end function UIChannelChatMain:ResetEffectByCanvas() for effectTF, _ in pairs(self.effectPlayDic) do self:StopEffectByCanvas(effectTF) end end --------------------------势力实时语音相关----------End---------------- return UIChannelChatMain