var SDKManage = require('SDKManage'); var NetManage = require('NetManage'); var playerData = require('playerData'); var gameConfig = require('gameConfig'); var Utils = require('Utils'); const BaseNet = require('../BaseNet'); const { uimanger } = require('../UI/UIManger'); const { playerInfoUI } = require('../tips/PlayInfomationTips'); function etos() { return ''; } var colortb = { o1: '#2BD6D6', m1: '#2BD6D6', o2: '#FFFFFF', m2: '#FFFFFF', o3: '#FFFFFF', m3: '#FFFFFF', }; var battlecolor = '#00ffff'; let m_data = null; let m_roomID = null; cc.Class({ extends: cc.viewcell, properties: { ly_up: { default: null, type: cc.Layout, }, lb_name: { default: null, type: cc.Label, }, lb_talk: { default: null, type: cc.RichText, }, lb_zone: { default: null, type: cc.Label, }, lb_talkNode: { default: null, type: cc.Node, }, sp_head: { default: null, type: cc.Sprite, }, sp_head_back: { default: null, type: cc.Sprite, }, sp_sex: { default: null, type: cc.Sprite, }, sp_vip: { default: null, type: cc.Sprite, }, sp_rank: { default: null, type: cc.Sprite, }, sp_lv: { default: null, type: cc.Label, }, btn_join: { default: null, type: cc.Node, }, nd_talkbg: { default: null, type: cc.Node, }, m_item: { default: null, type: cc.Node, }, m_offsetX: { default: 0, type: cc.Integer, }, m_nameBg: { default: null, type: cc.Node, }, m_paddingH: { default: 30, type: cc.Integer, }, m_bgHeight: { default: 40, type: cc.Integer, }, m_itemBg: { default: null, type: cc.Node, }, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start() { this.iidex = 0; this.m_chatPopPanelPrefab = null; }, init: function (index, data, reload, group) { if (index >= data.array.length) { this.node.active = false; return; } //this.btn_join.active = false if (this.m_item) { this.m_item.active = false; } this.node.width = data.width; this.node.x = 0; var sdata = data.array[index]; this.cdata = sdata; this.m_data = sdata.sender.base_data; }, update(dt) { if (this.cdata) { this.setdata(this.cdata); this.cdata = null; } }, showsenderinfo(userdata) { var self = this; self.sp_vip.spriteFrame = null; this.lb_name.string = userdata.nickname; Utils.setitem(this, userdata.avatar_url, this.sp_head); Utils.setitem(this, userdata.head, this.sp_head_back); }, setdata(data) { let tmpState = 0; if (this.lb_talkNode) { this.lb_talkNode.active = false; } this.chat_channel = data.chat_channel; var userdata = data.sender.base_data; this.showsenderinfo(userdata); this.account_id = userdata.account_id; if (this.account_id == SDKManage.account_id) { this.setmode(true); } else { this.setmode(false); } this.lb_zone.string = ''; if (data.msg_type == 2) { var str = data.msg_body; var reg = /\(e\d+\)/gi; str = str.replace(reg, etos); this.lb_talk.string = '' + str + ''; } else if (data.msg_type == 1) { let leftNode = this.m_item.getChildByName('left'); let rightNode = this.m_item.getChildByName('right'); leftNode.active = false; rightNode.active = false; let tmpNode = null; if (this.account_id != SDKManage.account_id) { tmpNode = leftNode; } else { tmpNode = rightNode; // this.btn_join.active = false; } tmpNode.active = true; //this.btn_join.active = true var jdata = JSON.parse(data.msg_body); var tp = jdata.tp; var tex = jdata.text; let title = 'testTitle'; if (jdata.title) { title = jdata.title; } let titleNode = tmpNode.getChildByName('title'); let titleCom = titleNode.getComponent(cc.Label); let tmpTxtNode = tmpNode.getChildByName('txt'); let tmpTxtCom = tmpTxtNode.getComponent(cc.Label); titleCom.string = title; tmpState = 1; let roomID = jdata.roomid; this.m_roomID = roomID; this.m_item.active = true; if (tp == 1) { tmpTxtCom.string = '' + tex; this.lb_zone.string = BaseNet.getZViewName(userdata.zid); } } if (tmpState == 0) { if (this.lb_talkNode) { this.lb_talkNode.active = true; } this.nd_talkbg.width = this.lb_talk._linesWidth[0] + 30; let height = this.lb_talkNode.getContentSize().height; let hCnt = Math.ceil(height / this.lb_talk.lineHeight); if (hCnt >= 2) { this.nd_talkbg.height = this.m_bgHeight + (hCnt - 1) * this.m_paddingH; } } }, onTure() { if (playerData.teamuuid) { cc.uiHelper.showTips('Please leave the current team first'); return; } if (this.m_roomID) { cc.Notifier.emit('joinTeamRoom', '' + this.m_roomID); } }, onBtnShowInfo() { let accountID = SDKManage.account_id; if (this.account_id == accountID) { // cc.Notifier.emit("openSelfPlayerInfoUI"); return; } // cc.Notifier.emit('chat_playerInfo', this.m_data); uimanger.showUI(playerInfoUI,this.account_id); }, setmode(isself) { if (isself) { let offsteX01 = -2; this.ly_up.horizontalDirection = 1; this.ly_up.node.anchorX = 1; this.ly_up.node.x = 165 + offsteX01; this.lb_name.node.anchorX = 1; this.lb_talk.horizontalAlign = 2; this.lb_talk.node.anchorX = 1; this.lb_talk.node.x = this.ly_up.node.x - 20; this.strcolor = colortb['m' + this.chat_channel]; this.lb_name.node.x = -70 + offsteX01; this.sp_sex.node.x = -50 + offsteX01; this.sp_lv.node.x = -1260 + offsteX01; this.sp_rank.node.x = -1190 + offsteX01; if (this.m_nameBg) { this.m_nameBg.scaleX = -1; this.m_nameBg.x = -86 + offsteX01; } if (this.m_itemBg) { this.m_itemBg.scaleX = -0.5; this.m_itemBg.x = 44 + offsteX01; } //this.nd_talkbg.x = this.lb_talk.node.x+20; if (this.m_item) { this.m_item.x = this.m_offsetX; } } else { this.lb_name.node.x = 196; this.sp_sex.node.x = 174; this.ly_up.horizontalDirection = 0; this.ly_up.node.anchorX = 0; this.ly_up.node.x = -this.node.width / 2; this.lb_name.node.anchorX = 0; this.lb_talk.horizontalAlign = 0; this.lb_talk.node.anchorX = 0; this.lb_talk.node.x = this.ly_up.node.x + 80; this.strcolor = colortb['o' + this.chat_channel]; // rankLv this.sp_lv.node.x = -459; this.sp_rank.node.x = -532; if (this.m_itemBg) { this.m_itemBg.scaleX = 0.5; this.m_itemBg.x = -40; } if (this.m_nameBg) { this.m_nameBg.scaleX = 1; this.m_nameBg.x = 83; } if (this.m_item) { this.m_item.x = -(this.node.width / 2 + this.m_offsetX); } } }, });