Files
fc/dev/project/library/imports/78/78c7a904-03c4-414f-bc84-95df46e233b9.js
T
2026-05-24 10:21:26 +08:00

98 lines
3.1 KiB
JavaScript

"use strict";
cc._RF.push(module, '78c7akEA8RBT7yEld9G4jO5', 'cmp.chat.wnd.float');
// Scripts/mod/chat/cmp/cmp.chat.wnd.float.js
"use strict";
var _CHANNEL_TXT, _CHANNEL_COL;
var BridgeComp = require("bridge.component");
var ChatEvent = require("chat_event");
var RoleController = require("role_controller");
var ChatItemController = require("chat_item_controller");
var ChatConst = require("chat_const");
var ChatCtrl = require("chat_controller");
var CHANNEL_TXT = (_CHANNEL_TXT = {}, _CHANNEL_TXT[1] = "MsgWorld", _CHANNEL_TXT[4] = "MsgGud", _CHANNEL_TXT[7] = "MsgPri", _CHANNEL_TXT[16] = "MsgSys", _CHANNEL_TXT[1024] = "MsgWorld", _CHANNEL_TXT);
var CHANNEL_COL = (_CHANNEL_COL = {}, _CHANNEL_COL[1] = new cc.Color().fromHEX("#00d8ff"), _CHANNEL_COL[4] = new cc.Color().fromHEX("#46db9a"), _CHANNEL_COL[7] = new cc.Color().fromHEX("#7c46db"), _CHANNEL_COL[16] = new cc.Color().fromHEX("#ffc700"), _CHANNEL_COL[1024] = new cc.Color().fromHEX("#00d8ff"), _CHANNEL_COL);
cc.Class({
"extends": BridgeComp,
properties: {
container: {
"default": null,
type: cc.Node
},
type_lb: {
"default": null,
type: cc.Label
},
pname: {
"default": null,
type: cc.Label
},
msg_rx: {
"default": null,
type: cc.RichText
}
},
// LIFE-CYCLE CALLBACKS:
onLoad: function onLoad() {
this._super();
this.chat_item_ctrl = ChatItemController.getInstance();
this.ctrl = ChatCtrl.getInstance();
this.role_vo = RoleController.getInstance().getRoleVo();
this.rx_math = 260; //超过最大长度旧省略
this.bindGEvent(ChatEvent.MessageUpdateOnWnd, this.onEditText.bind(this));
},
start: function start() {
// this.ctrl.sender12766();
this.ctrl.sender12731();
},
onEnable: function onEnable() {},
onDisable: function onDisable() {
// 监听事件释放
this.unbindGEvents();
},
onEditText: function onEditText(msgData) {
if (nx.dt.objEmpty(msgData)) {
return;
}
var self = this;
self.data = msgData;
if (self.data) {
if (msgData.channel == ChatConst.Channel.System) {
self.pname.string = "";
self.pname.node.active = false;
} else if (msgData.channel == ChatConst.Channel.Friend) {
self.pname.node.active = true;
if (msgData.msg_data.flag == 1) {
self.pname.string = self.role_vo.name + ":";
} else if (msgData.msg_data.flag == 2) {
self.pname.string = msgData.msg_data.name + ":";
}
} else {
self.pname.node.active = true;
self.pname.string = msgData.role_list[0].name + ":";
}
self.type_lb.string = nx.text.getKey(CHANNEL_TXT[msgData.channel]);
self.type_lb.node.color = CHANNEL_COL[msgData.channel];
// 设置Imag
var msg = msgData.msg || msgData.msg_data.msg;
self.msg_rx.string = msg;
self.container.getComponent(cc.Layout).updateLayout();
// if(this.container.width >320){
// }
} else {
this.type_lb.string = "";
this.pname.string = "";
this.msg_rx.string = "";
}
},
touchChat: function touchChat() {
this.ctrl.openChatPanel();
} // update (dt) {},
});
cc._RF.pop();