"use strict"; cc._RF.push(module, 'b6e1cg9UO9KNJp1fOS36aj/', 'tips_controller'); // Scripts/mod/tips/tips_controller.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 这里填写详细说明,主要填写该模块的功能简要 //
Create: 2018-12-28 09:23:39 // -------------------------------------------------------------------- var BridgeController = require("bridge.controller"); var TipsConst = require("tips_const"); var _require = require("define"), SCENE_TAG = _require.SCENE_TAG, SCREEN_WIDTH = _require.SCREEN_WIDTH, SCREEN_HEIGHT = _require.SCREEN_HEIGHT; // 桥接替换的界面 var TipsController = cc.Class({ "extends": BridgeController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { this.tips_list = {}; // tips列表对象 }, // 注册监听事件 registerEvents: function registerEvents() { if (this.re_link_game == null) { this.login_event_success = gcore.GlobalEvent.bind(EventId.EVT_RE_LINK_GAME, function () { this.closeAllTips(); }.bind(this)); } }, // 注册协议接受事件 registerProtocals: function registerProtocals() { // this.RegisterProtocal(1110, this.on1110); }, closeTIpsByType: function closeTIpsByType(type) { var tips = this.tips_list[type]; if (tips) { tips.close(); } this.tips_list[type] = null; }, // 关掉所有tips closeAllTips: function closeAllTips() { for (var key in this.tips_list) { var tips = this.tips_list[key]; if (tips && tips.close) { tips.close(); tips = null; } } this.tips_list = {}; }, /** * desc:购买 */ openBuyPanel: function openBuyPanel(status, data, _type, _cb) { if (status == false) { nx.bridge.closePanel("WndOtherItemBuy"); } else { nx.bridge.createPanel("WndOtherItemBuy", { data: data, type: _type, cb: _cb }); } }, // openHonorIconTips: function(status,setting){ // if(setting == null)return; // if(this.tips_list[TipsConst.type.HONOR_ICON] == null){ // if(status){ // var HonorIconTips = require("honor_icon_tips"); // var honor_icon_tips = new HonorIconTips(); // honor_icon_tips.open(setting); // this.tips_list[TipsConst.type.HONOR_ICON] = honor_icon_tips; // return honor_icon_tips; // } // } // }, // openTaskExpTips: function(status,setting){ // }, // openHonorLevelTips: function(status,setting){ // }, // 显示通用物品tips showItemTips: function showItemTips(data) { if (data == null) { nx.bridge.closePanel("WndTipItem"); return; } nx.bridge.createPanel("WndTipItem", { data: data }); }, // 显示通用物品tips showItemRandomTips: function showItemRandomTips(status, data) { if (status == true) { nx.bridge.createPanel("WndPopRandomProps", data); } else { nx.bridge.closePanel("WndPopRandomProps"); } }, // 显示通用物品tips showGoodsTips: function showGoodsTips(data, is_show_btn, is_special_source) { if (data == null) return; if (this.tips_list[TipsConst.type.GOODS] == null) { var BackPackTips = require("backpack_tips"); var tips = new BackPackTips(); tips.open({ data: data, show: is_show_btn, is_special_source: is_special_source }); this.tips_list[TipsConst.type.GOODS] = tips; } }, showEquipTips: function showEquipTips(data, type, partner, holy_data) { if (data == null) return; if (this.tips_list[TipsConst.type.EQUIP] == null) { var EquipTips = require("equip_tips"); var tips = new EquipTips(); tips.open({ data: data, type: type, partner: partner, holy_data: holy_data }); this.tips_list[TipsConst.type.EQUIP] = tips; } }, showHeadCircleTips: function showHeadCircleTips(data) { if (data == null) return; this.closeTIpsByType(TipsConst.type.HEAD_CIRCLE); var HeadCircleTips = require("head_circle_tips"); var tips = new HeadCircleTips(); tips.open(data); this.tips_list[TipsConst.type.HEAD_CIRCLE] = tips; }, showHalidomSkillTips: function showHalidomSkillTips(skill_id) { var halidom_skill_tips = require("halidom_skill_tips"); var tips = new halidom_skill_tips(); tips.open(skill_id); this.tips_list[TipsConst.type.HALIDOM_SKILL] = tips; return halidom_skill_tips; }, // 文本说明弹窗 showTextPanel: function showTextPanel(title, text) { var _nx$bridge$createPane; if (nx.dt.strEmpty(text)) { return; } nx.bridge.createPanel("WndTipText", (_nx$bridge$createPane = { title: title, text: text }, _nx$bridge$createPane["text"] = text, _nx$bridge$createPane)); }, // 规则详细说明弹窗 showDetailPanel: function showDetailPanel(explain) { nx.bridge.createPanel("WndPopRule", explain); }, //普通tips showCommonTips: function showCommonTips(tips, point, font_size, delay, width) { if (this.common_tips != null) { this.common_tips.close(); this.common_tips = null; } width = width || 400; var CommonTips = require("common_tips"); this.common_tips = new CommonTips(delay); this.common_tips.open(); this.common_tips.showTips(tips, width, font_size || 24); this.common_tips.addCallBack(function () { this.adjustTipsPosition(this.common_tips, point); }.bind(this)); this.tips_list[TipsConst.type.COMMON] = this.common_tips; return this.common_tips; }, // 神界冒险的tips showAdventureBuffTips: function showAdventureBuffTips(buff_list, point, holiday_buff_list) { if (this.adventure_buff_tips) { this.adventure_buff_tips.close(); this.adventure_buff_tips = null; } var AdventureBuffTips = require("adventure_buff_tips"); this.adventure_buff_tips = new AdventureBuffTips(buff_list, holiday_buff_list); this.adventure_buff_tips.open(); this.adventure_buff_tips.showTips(); this.adventure_buff_tips.addCallBack(function () { this.adjustTipsPosition(this.adventure_buff_tips, point); }.bind(this)); this.tips_list[TipsConst.type.ADVENTURE_BUFF] = this.adventure_buff_tips; return this.adventure_buff_tips; }, //显示碎片合成 showBackPackCompTips: function showBackPackCompTips(status, base_id) { if (status == true) { if (!this.comp_tips) { this.comp_tips = Utils.createClass("backpack_comp_tips_window", this); } this.comp_tips.open(base_id); } else { if (this.comp_tips) { this.comp_tips.close(); this.comp_tips = null; } } }, //显示碎片合成选择 showCompChooseTips: function showCompChooseTips(status, base_id) { if (status == true) { if (!this.choose_tips) { this.choose_tips = Utils.createClass("comp_choose_tips_window", this); } this.choose_tips.open(base_id); } else { if (this.choose_tips) { this.choose_tips.close(); this.choose_tips = null; } } }, //位置调整(现在默认为显示的tips的anchorPoint的为cc.v2(0.5, 0.5)) adjustTipsPosition: function adjustTipsPosition(target, point, view_size) { var win_size = cc.size(SCREEN_WIDTH, SCREEN_HEIGHT); //父节点的尺寸 var temp_size = view_size || target.getBgContentSize(); //获取内部背景随动的节点尺寸 var size = cc.size(temp_size.width, temp_size.height); var parent = nx.bridge.ui.getSceneNode(SCENE_TAG.msg); var local_pos = parent.convertToNodeSpaceAR(point); var start_x = local_pos.x; var start_y = local_pos.y - size.height / 2; cc.log("start_y:" + start_y + ",size.height:" + size.height + ",win_size.height:" + win_size.height); if (start_x + size.width / 2 > win_size.width / 2) { start_x = start_x - size.width / 2; } else if (start_x - size.width / 2 < -win_size.width / 2) { start_x = start_x + size.width / 2; } if (start_y > win_size.height / 2) { start_y = win_size.height / 2; } else if (start_y - size.height / 2 < -win_size.height / 2) { start_y = start_y + size.height; } target.setPosition(start_x, start_y); }, // --技能tips showSkillTips: function showSkillTips(skill_vo, is_lock, not_show_next, hide_flag) { nx.bridge.createPanel("WndTipSkill", { skill_vo: skill_vo, is_lock: is_lock, not_show_next: not_show_next, hide_flag: hide_flag }); }, // 伙伴提示 传入的是获取的伙伴数据{ } showPartnerTips: function showPartnerTips(data) { nx.bridge.createPanel("WndTipPartner", data); }, // 通用字符串输入框 showInputString: function showInputString(data) { nx.bridge.createPanel("WndInputString", data); }, // 多行字符串输入框 showInputWords: function showInputWords(data) { nx.bridge.createPanel("WndInputWords", data); }, getCompTipsRoot: function getCompTipsRoot() { if (this.comp_tips) return this.comp_tips.root_wnd; }, showWeekCardTips: function showWeekCardTips(status, data) { if (status == true) { if (!this.weekcard_tips) { var WeekCardTips = require("week_card_tips_window"); this.weekcard_tips = new WeekCardTips(this); } this.weekcard_tips.open(data); } else { if (this.weekcard_tips) { this.weekcard_tips.close(); this.weekcard_tips = null; } } } }); module.exports = TipsController; cc._RF.pop();