Files
fc/dev/project/library/imports/dc/dc8cb311-3df8-4d9a-b105-31e1af778284.js
T
2026-05-24 10:21:26 +08:00

143 lines
4.0 KiB
JavaScript

"use strict";
cc._RF.push(module, 'dc8cbMRPfhNmrEFMeGvd4KE', 'cmp.act.elite.select.wnd');
// Scripts/mod/acts/elite/cmps/cmp.act.elite.select.wnd.js
"use strict";
/******************************************************************
*
* 心愿伙伴选择
*
******************************************************************/
var BridgeWindow = require("bridge.window");
var HeroConst = require("hero_const");
var HCT = HeroConst.CampType;
cc.Class({
"extends": BridgeWindow,
properties: {
pageGroup: {
"default": null,
type: cc.Node
}
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {
var _this = this;
this.raw_bid = _params.cur || 0;
this.cur_bid = _params.cur || 0;
this.camp_id = _params.camp_id;
this.cbDone = _params.cb;
var DATA = game.configs.recruit_holiday_lucky_data.data_wish[this.camp_id];
if (nx.dt.objEmpty(DATA)) {
nx.error("精英召唤心愿配置无效:", this.camp_id);
this.scheduleOnce(function () {
_this.close();
}, 0.01);
}
this.partners = [];
for (var id in DATA) {
var cfgs = game.configs.partner_data.data_partner_base[id];
if (nx.dt.objEmpty(DATA[id]) || nx.dt.objEmpty(cfgs)) {
nx.error("精英召唤心愿伙伴无效:", id);
continue;
}
this.partners.push({
bid: id,
cfgs: cfgs,
sort: DATA[id].sort
});
this.partners.sort(function (_a, _b) {
return _a.sort - _b.sort;
});
}
// 伙伴重置
this.rebuildPartners();
},
// 伙伴重置
rebuildPartners: function rebuildPartners() {
// 单设
var reset = function reset(_node, _data) {
// 空缺
if (nx.dt.objEmpty(_data)) {
nx.gui.setActive(_node, "", false);
return;
}
_node.partner = _data;
nx.gui.setActive(_node, "", true);
nx.gui.setActive(_node, "focus", false);
var node = nx.gui.find(_node, "normal");
// 阵营标记
var cfgs = _data.cfgs;
var camp = cfgs ? cfgs.camp_type : HCT.eWater;
var path = cc.path.join("coms/images", "camps" + camp);
nx.gui.setSpriteFrame(node, "head/camp", path);
// 阵营背景
path = cc.path.join("coms/camps", "bg" + camp);
nx.gui.setSpriteFrame(node, "bg", path);
// 阵营边框
path = cc.path.join("coms/camps", "frame" + camp);
nx.gui.setSpriteFrame(node, "frame", path);
// 名字
nx.gui.setString(node, "dn/txt", nx.text.getKey(cfgs.name));
// 星级
path = cc.path.join("coms/images", "star" + cfgs.init_star);
nx.gui.setSpriteFrame(node, "dn/star", path);
// 角色
path = cc.path.join("resDB/models", cfgs.draw_res, "half_show2");
nx.gui.setSpriteFrame(node, "mask/img", path, function (_ret) {
if (!_ret) {
nx.gui.setSpriteFrame(node, "mask/img", "resDB/empty/half_show2");
}
});
};
// 遍历填充
var chds = this.pageGroup.children;
for (var i = 0; i < chds.length; ++i) {
reset(chds[i], this.partners[i]);
}
// 设置当前选中
this.setFocus(this.cur_bid || this.partners[0].bid);
},
// 设置当前选中
setFocus: function setFocus(_bid) {
this.cur_bid = _bid;
var chds = this.pageGroup.children;
for (var i = 0; i < chds.length; ++i) {
var node = chds[i];
nx.gui.setActive(node, "focus", this.cur_bid == node.partner.bid);
}
},
// 点击更换
onTouchChange: function onTouchChange(_order) {
var order = parseInt(_order);
if (!nx.dt.numPositive(order, false)) {
return;
}
var partner = this.partners[order - 1];
if (partner) {
this.setFocus(partner.bid);
}
},
// 点击确认
onTouchConfirm: function onTouchConfirm() {
var bid = parseInt(this.cur_bid);
if (!nx.dt.numPositive(bid, false) || this.raw_bid == bid) {
this.close();
return;
}
nx.dt.fnInvoke(this.cbDone, bid);
this.close();
}
});
cc._RF.pop();