"use strict"; cc._RF.push(module, '374468Yt/RO0IxQP8ZAing0', 'cmp.chat.wnd.inputlist'); // Scripts/mod/chat/cmp/cmp.chat.wnd.inputlist.js "use strict"; var BridgeComp = require("bridge.component"); var FxSVC = require("nx.fx.sv.expand"); var FxTogs = require("nx.fx.togs"); var ChatItemController = require("chat_item_controller"); var ChatCtrl = require("chat_controller"); var BackPackConst = require("backpack_const"); var ChatEvent = require("chat_event"); var ItemEnum = { "1": { source: "face_item", width: 60, height: 60, col: 8 }, "2": { source: "goods_item", width: 90, height: 90, col: 5 }, "3": { source: "goods_item", width: 90, height: 90, col: 5 } }; cc.Class({ "extends": BridgeComp, properties: { togs: { "default": null, type: FxTogs }, goods_list: { "default": null, type: FxSVC }, face_list: { "default": null, type: FxSVC }, goods_nd: { "default": null, type: cc.Node }, face_nd: { "default": null, type: cc.Node } }, // LIFE-CYCLE CALLBACKS: onLoad: function onLoad() { this._super(); this.chat_item_ctrl = ChatItemController.getInstance(); this.ctrl = ChatCtrl.getInstance(); this.cur_tab = null; this.item_lists = {}; this.bindGEvent(ChatEvent.INPUT_SELECT_ITEM, this.selectOnce.bind(this)); this.togs.posTog = this.onTogMenu.bind(this); this.togs.togTo(0); }, selectOnce: function selectOnce(_key, _params) { if (_key == 1) { this.selectFaceCB(_params.face_text); } else if (_key == 2) { this.selectItemCB(_params.item_data); } else if (_key == 3) { this.selectEquipCB(_params); } }, start: function start() {}, onEnable: function onEnable() { this.togs.togTo(0); this.selectTab(1); }, onDisable: function onDisable() { this.face_list.rebuild([]); this.goods_list.rebuild([]); }, setSelectCB: function setSelectCB(select_cb) { this.select_cb = select_cb; }, onTogMenu: function onTogMenu(_type) { this.selectTab(_type + 1); }, selectTab: function selectTab(tab_index) { this.updateDataList(tab_index); this.cur_tab = tab_index; }, // updateCurPanel: function(list_index) { // if (list_index && this.item_lists[list_index]) { // this.updateDataList(list_index); // this.item_lists[list_index].setRootVisible(true); // } else { // this.createItemList(list_index); // } // }, updateDataList: function updateDataList(list_index) { var list_data = []; var select_cb = null; var extend = {}; var is_face = false; if (list_index === 1) { var face_cfgs = game.configs.face_data.data_biaoqing; for (var face_i in face_cfgs) { var v = face_cfgs[face_i]; list_data.push(v); } // select_cb = this.selectFaceCB.bind(this); is_face = true; } else if (list_index === 2) { var BackpackController = require("backpack_controller"); var bag_model = BackpackController.getInstance().getModel(); var bag_data = bag_model.getItemListForShare(); for (var i in bag_data) { var _v = {}; _v.info = bag_data[i]; list_data.push(_v); } // select_cb = this.selectItemCB.bind(this); } else if (list_index === 3) { extend.is_eqm = true; var HeroController = require("hero_controller"); var hero_mode = HeroController.getInstance().getModel(); var hero_list = hero_mode.getHeroList(); for (var hero_i in hero_list) { var hero_info = hero_list[hero_i]; for (var equip_i in hero_info.eqm_list) { hero_info.partner_data = hero_info; list_data.push({ item_data: hero_info.eqm_list[equip_i], hero_info: hero_info }); } } // select_cb = this.selectEquipCB.bind(this); } if (is_face) { this.goods_nd.active = false; this.face_nd.active = true; this.face_list.svcKey = list_index; this.face_list.rebuild(list_data); } else { this.goods_nd.active = true; this.face_nd.active = false; this.goods_list.svcKey = list_index; this.goods_list.rebuild(list_data); } }, selectFaceCB: function selectFaceCB(face_text) { if (face_text && this.select_cb) { this.select_cb(face_text); } }, selectItemCB: function selectItemCB(item_data) { if (item_data && item_data.config) { this.chat_item_ctrl.send10535(1, item_data.id, 0, 1); } ; }, selectEquipCB: function selectEquipCB(_params) { var equip_data = _params.item_data; var hero_info = _params.hero_info; // 区分装备和符文 if (equip_data && equip_data.config) { if (BackPackConst.checkIsEquip(equip_data.config.type)) { this.chat_item_ctrl.send10535(4, equip_data.id, hero_info.partner_id, 2); } else if (BackPackConst.checkIsArtifact(equip_data.config.type)) { this.chat_item_ctrl.send10535(2, equip_data.id, hero_info.partner_id, 2); } } }, // 选中切换 onFocusFace: function onFocusFace(_item) { // 空 if (nx.dt.objEmpty(_item) || nx.dt.objEmpty(_item.mdata)) { return; } // 聚焦 this.face_list.cleanFocus(); this.face_list.addFocus(_item.index); }, // 选中切换 onFocusGoods: function onFocusGoods(_item) { // 空 if (nx.dt.objEmpty(_item) || nx.dt.objEmpty(_item.mdata)) { return; } // 聚焦 this.goods_list.cleanFocus(); this.goods_list.addFocus(_item.index); } // update (dt) {}, }); cc._RF.pop();