local UIBattleShortcutMsg = UIViewClass() local COLOR_BLUE = "7292c2" function UIBattleShortcutMsg:OnOpened(content) UIUtils.SetActive(self.btn_Mask, false) UIUtils.SetActive(self.loop_ShortcutMsg, false) UIUtils.SetActive(self.group_Info1.gameObject, false) UIUtils.SetActive(self.group_Info2.gameObject, false) self.minShowTime = DataSheetManager.ConstData:GetDataByID("ThreeOnThreeLowerLimit").IntValue self.maxShowTime = DataSheetManager.ConstData:GetDataByID("ThreeOnThreeUpperLimit").IntValue self.showTimestamp = nil self.msgContentDict = {} self.atkMsgList = {} self.defMsgList = {} for i, v in DataSheetManager.BattleQuickChat:GetEnumerator() do self.msgContentDict[UIUtils.GetLocalizedTxt(Const_IDS[v.Name])] = 1 if v.ChatType == 1 then table.insert(self.atkMsgList, v) elseif v.ChatType == 2 then table.insert(self.defMsgList, v) end end self.msgQueue = {} self:RegistSystemEvent(EventID.UI_ChannelChat_OnReceiveNewMsg, self.OnShowShortcutMsg) end function UIBattleShortcutMsg:OnShowShortcutMsg(chatDlgMsg) if self.msgContentDict[chatDlgMsg.content] then self:UpdateShortcutShow(chatDlgMsg) end end function UIBattleShortcutMsg:UpdateShortcutShow(chatDlgMsg) if self.showTimestamp == nil then self:SetShortcutInfo(self.group_Info1, chatDlgMsg) self.showTimestamp = UTL.Time.GetServerTimestamp() self:StartRepeatFunc(self.OnChangeNextShortcut, self.maxShowTime, 1) else table.insert(self.msgQueue, chatDlgMsg) if self.group_Info2.gameObject.activeSelf == false then self:SetShortcutInfo(self.group_Info2, chatDlgMsg) else if UTL.Time.GetServerTimestamp() - self.showTimestamp >= self.minShowTime then self:OnChangeNextShortcut() end end end end function UIBattleShortcutMsg:OnChangeNextShortcut() self:StopRepeatFunc(self.OnChangeNextShortcut) self.showTimestamp = nil local data = table.remove(self.msgQueue, 1) if data then self:UpdateShortcutShow(data) if #self.msgQueue > 0 then self:SetShortcutInfo(self.group_Info2, self.msgQueue[1]) else UIUtils.SetActive(self.group_Info2.gameObject, false) end else UIUtils.SetActive(self.group_Info1.gameObject, false) UIUtils.SetActive(self.group_Info2.gameObject, false) end end function UIBattleShortcutMsg:SetShortcutInfo(comp, data) UIUtils.SetActive(comp.gameObject, true) UTL.Item.SetHeroIconByHeroId(comp.img_Hero, CTL.HeroAwaken.DecodeHeroId(data.heroId)) if data.isSelf then comp.state_Frame:SetState(0) comp.txt_Player.text = UTL.Color.FormatGreenColor(string.format("%s(S.%s)", data.senderName, data.serId)) else comp.state_Frame:SetState(1) comp.txt_Player.text = UTL.Color.FormatTextByColor(COLOR_BLUE, string.format("%s(S.%s)", data.senderName, data.serId)) end comp.txt_Word.text = data.content end function UIBattleShortcutMsg:OnButtonClicked(comp) if comp == self.btn_ATK then UIUtils.SetActive(self.loop_ShortcutMsg, true) UIUtils.SetActive(self.btn_Mask, true) self.loop_ShortcutMsg.transform:SetAnchoredPosition(nil, -250) self.loop_ShortcutMsg:ReloadAll(self.atkMsgList) elseif comp == self.btn_DEF then UIUtils.SetActive(self.loop_ShortcutMsg, true) UIUtils.SetActive(self.btn_Mask, true) self.loop_ShortcutMsg.transform:SetAnchoredPosition(nil, -386) self.loop_ShortcutMsg:ReloadAll(self.defMsgList) elseif comp == self.btn_Mask then self:CloseShortcut() end end function UIBattleShortcutMsg:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetLabelText(cellTable.txt_Words, Const_IDS[data.Name]) end function UIBattleShortcutMsg:OnCellClicked(scrollRect, index, cellTable, target, data) MDL.ChannelChat.SendMyCampShortcutMsg(data.Name) self:CloseShortcut() end function UIBattleShortcutMsg:CloseShortcut() UIUtils.SetActive(self.btn_Mask, false) UIUtils.SetActive(self.loop_ShortcutMsg, false) end return UIBattleShortcutMsg