"use strict"; cc._RF.push(module, '16c639GoXRGKrtoi8hZE2El', 'cmp.pve.rank.wnd'); // Scripts/mod/pve/cmp/cmp.pve.rank.wnd.js "use strict"; var BridgeWindow = require("bridge.window"); var ArenaEvent = require("arena_event"); var FxSVC = require("nx.fx.sv.expand"); var ArenaController = require("arena_controller"); var FxTogs = require("nx.fx.togs"); var RoleEvent = require("role_event"); var RKC = require("rank_controller"); var RKEVT = require("rank_event"); var RankConstant = require("rank_constant"); // 标签页对应关系 var TabPage = [{ key: "RankNow", "goto": 0 }, { key: "rank_reward", "goto": 1 }]; cc.Class({ "extends": BridgeWindow, properties: { nodOps: { "default": null, type: cc.Node }, nodToggle: { "default": null, type: FxTogs }, nodLst: { "default": null, type: FxSVC } }, onLoad: function onLoad() { this.bindGEvent(RoleEvent.WorshipOtherRole, this.freshOneWorship.bind(this)); this.bindGEvent(RKEVT.RankEvent_Get_Rank_data, this.freshOtherUI.bind(this)); // Tog监听 this.nodToggle.posTog = this.onTogMenu.bind(this); }, onOpenConfigs: function onOpenConfigs(_params) { var _this = this; this.dfg = _params.dfg; this.show = _params.show; var ops = _params.ops; this.fromOther = _params.type; var chd = this.nodOps.children; for (var i = 0; i < chd.length; i++) { var op = ops[i]; if (!op) { nx.gui.setActive(chd[i], "", false); continue; } nx.gui.setActive(chd[i], "", true); nx.gui.setString(chd[i], "on/txt", nx.text.getKey(op)); nx.gui.setString(chd[i], "off/txt", nx.text.getKey(op)); } var _goto = 0; TabPage.forEach(function (_tab) { if (_this.show == _tab.key) { _goto = _tab["goto"]; } }); this.nodToggle.togTo(_goto); this.activeMenu(_goto + 1); }, // 激活菜单 activeMenu: function activeMenu(_bagCode) { if (this.curType == _bagCode) { return; } this.curType = _bagCode; if (_bagCode == 1) { var ind = parseInt(this.fromOther); this.rank_type = ind; this.freshInfo(); if (ind == RankConstant.RankType.element || ind == RankConstant.RankType.heaven) { RKC.getInstance().send_12900(ind, null, null, false); } } if (_bagCode == 2) { var T = nx.gui.find(this.node, "templates/award"); this.nodLst.tmpItem = T; this.freshData(this.dfg); this.freshInfo(); } }, freshOtherUI: function freshOtherUI(_data) { nx.gui.setActive(this.nodLst, cc.js.formatStr("self_rank/item%s", this.rank_type), this.rank_type == _data.type); nx.gui.setActive(this.nodLst, "nod_rank", this.curType == 1); // 设置顶部 标题 var tnod = nx.gui.find(this.nodLst, "title"); nx.gui.setActive(tnod, "nod_rank", this.curType == 1); var T = nx.gui.find(this.node, cc.js.formatStr("templates/itemT%s", this.rank_type)); var nod = nx.gui.find(this.nodLst, "self_rank"); var rank_node = nx.gui.find(nod, cc.js.formatStr("item%s/rank", this.rank_type)); nx.gui.setActive(rank_node, "icon_" + _data.my_idx, _data.my_idx > 0 && _data.my_idx < 4); nx.gui.setActive(rank_node, "icon_4", _data.my_idx >= 4); if (_data.my_idx >= 4) { nx.gui.setString(rank_node, "txt", _data.my_idx); } if (_data.my_idx == 0) { nx.gui.setString(rank_node, "txt2", nx.text.getKey("Rank0")); } nx.gui.setString(nod, cc.js.formatStr("item%s/name", this.rank_type), _data.name); if (this.rank_type == 40) { nx.gui.setString(nod, cc.js.formatStr("item%s/info/score/txt", this.rank_type), nx.text.format("WeeklyCross", _data.my_val1)); nx.gui.setString(nod, cc.js.formatStr("item%s/lay/power", this.rank_type), _data.my_val2); } else if (this.rank_type == 42) { nx.gui.setSpriteFrame(nod, cc.js.formatStr("item%s/info/score/star", this.rank_type), "prefab/pve/RelicExploration/ui/star_01"); nx.gui.setString(nod, cc.js.formatStr("item%s/info/score/txt", this.rank_type), _data.my_val1); } this.nodLst.tmpItem = T; var lst = _data.rank_list; this.freshData(lst); }, // 切换 onTogMenu: function onTogMenu(_index) { this.activeMenu(parseInt(_index) + 1); }, freshData: function freshData(_data) { nx.gui.setActive(this.nodLst, "empty", nx.dt.arrEmpty(_data)); this.nodLst.rebuild(_data); }, freshOneWorship: function freshOneWorship(_data) { var chd = nx.gui.find(this.nodLst, "scv/view/content").children; for (var i = 0; i < chd.length; i++) { var item = chd[i]; var cmp = item.svItem; if (cmp) { if (cmp.mdata && cmp.mdata.rid == _data.rid) { var data = nx.dt.objClone(cmp.mdata); data.worship = cmp.mdata.worship + 1; data.worship_status = cmp.mdata.worship_status + 1; cmp.rebind(i, data); } } } }, freshInfo: function freshInfo() { // 设置相关的 底部显示信息 nx.gui.setActive(this.nodLst, "self_rank/item", this.curType == 2); nx.gui.setActive(this.nodLst, cc.js.formatStr("self_rank/item%s", this.rank_type), false); nx.gui.setActive(this.nodLst, "nod_rank", false); // 设置顶部 标题 nx.gui.setActive(this.nodLst, "empty", this.curType == 1); // 设置顶部 标题 var nod = nx.gui.find(this.nodLst, "title"); nx.gui.setActive(nod, "nod_rank", false); nx.gui.setActive(nod, "nod_reward/award", this.curType == 2); nx.gui.setActive(nod, "nod_reward", this.curType == 2); nx.gui.setActive(nod, "nod_rank/star", this.rank_type == 42); //遺跡探索顯示星星數量 nx.gui.setActive(nod, "nod_rank/score", this.rank_type == 40); //陣營秘境通關數 }, // 重载:关闭前 onPreClosed: function onPreClosed() {} }); cc._RF.pop();