179 lines
5.5 KiB
JavaScript
179 lines
5.5 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'c866eEPeSRL46A/9cXSSrYU', 'cmp.item.detail');
|
||
|
|
// Scripts/mod/backpack/cmps/cmp.item.detail.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var BackPackConst = require("backpack_const");
|
||
|
|
// const BridgeItem = require( "bridge.utils.item" );
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
"extends": cc.Component,
|
||
|
|
properties: {
|
||
|
|
fromBag: {
|
||
|
|
"default": false,
|
||
|
|
displayName: "背包详情"
|
||
|
|
},
|
||
|
|
nodBase: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node,
|
||
|
|
displayName: "基础栏"
|
||
|
|
},
|
||
|
|
nodContent: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node,
|
||
|
|
displayName: "详情栏"
|
||
|
|
},
|
||
|
|
nodOps: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node,
|
||
|
|
displayName: "操作栏"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 载入
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
this.setEmpty();
|
||
|
|
},
|
||
|
|
// 重置
|
||
|
|
setData: function setData(_data, _fromBag) {
|
||
|
|
this.fromBag = _fromBag || true;
|
||
|
|
// 置空
|
||
|
|
this.mdata = _data;
|
||
|
|
this.item = _data ? BackPackConst.uniformData(_data) : null;
|
||
|
|
if (!this.item) {
|
||
|
|
this.mdata = {};
|
||
|
|
this.setEmpty();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 统一道具信息格式
|
||
|
|
// this.info = BridgeItem.data2Icon( _data );
|
||
|
|
this.config = this.item.config;
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
this.freshAll();
|
||
|
|
},
|
||
|
|
// 置空
|
||
|
|
setEmpty: function setEmpty() {
|
||
|
|
// 信息隐藏 处理当前节点ui问题 故将其透明化
|
||
|
|
// nx.gui.setOpacity( this.node, "", 0 );
|
||
|
|
nx.gui.setActive(this.nodBase, "empty", true);
|
||
|
|
nx.gui.setActive(this.nodBase, "content", false);
|
||
|
|
nx.gui.hideAllChildren(this.nodContent, "");
|
||
|
|
nx.gui.hideAllChildren(this.nodOps, "");
|
||
|
|
nx.gui.setActive(this, "empty", true);
|
||
|
|
},
|
||
|
|
// 刷新
|
||
|
|
freshAll: function freshAll() {
|
||
|
|
// 空
|
||
|
|
if (nx.dt.objEmpty(this.item)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 显隐藏
|
||
|
|
// nx.gui.setOpacity( this.node, "", 255 );
|
||
|
|
nx.gui.setActive(this.nodBase, "empty", true);
|
||
|
|
nx.gui.setActive(this.nodBase, "content", false);
|
||
|
|
nx.gui.setActive(this, "empty", false);
|
||
|
|
nx.gui.hideAllChildren(this.nodContent, "");
|
||
|
|
nx.gui.hideAllChildren(this.nodOps, "");
|
||
|
|
|
||
|
|
// 后刷新
|
||
|
|
this.updHeader();
|
||
|
|
this.updOps();
|
||
|
|
this.updBaseProps();
|
||
|
|
this.updSuitProps();
|
||
|
|
this.updRandomProps();
|
||
|
|
this.upSkill();
|
||
|
|
this.updDesc();
|
||
|
|
this.updSources();
|
||
|
|
},
|
||
|
|
// 基础信息刷新
|
||
|
|
updHeader: function updHeader() {
|
||
|
|
var cmp = nx.gui.getComponent(this.nodBase, "", "cmp.item.detail.header");
|
||
|
|
if (cmp) {
|
||
|
|
cmp.setData(this.item, this.config, this.fromBag);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 基础属性刷新
|
||
|
|
updBaseProps: function updBaseProps() {
|
||
|
|
var cmp = nx.gui.getComponent(this.nodContent, "base/lst", "cmp.item.detail.prop.base");
|
||
|
|
if (cmp && cmp.setData(this.item, this.config, this.fromBag)) {
|
||
|
|
nx.gui.setActive(this.nodContent, "base", true);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 套装属性刷新
|
||
|
|
updSuitProps: function updSuitProps() {
|
||
|
|
// console.log( "套装属性" + JSON.stringify( this.config ) );
|
||
|
|
var cmp = nx.gui.getComponent(this.nodContent, "suit/lst", "cmp.item.detail.prop.suit");
|
||
|
|
if (cmp && cmp.setData(this.item, this.config, this.fromBag)) {
|
||
|
|
nx.gui.setActive(this.nodContent, "suit", true);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 套装属性刷新
|
||
|
|
updRandomProps: function updRandomProps() {
|
||
|
|
// console.log( "随机属性" + JSON.stringify( this.item.holy_eqm_attr ) );
|
||
|
|
var props = this.item.holy_eqm_attr;
|
||
|
|
if (props) {
|
||
|
|
var show_props = [];
|
||
|
|
for (var i = 0; i < props.length; i++) {
|
||
|
|
var prop = props[i];
|
||
|
|
if (prop.pos <= 2) {
|
||
|
|
show_props.push(prop);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
nx.gui.gocChildren(this.nodContent, "random/lst", show_props.length);
|
||
|
|
var chd = nx.gui.find(this.nodContent, "random/lst").children;
|
||
|
|
for (var _i = 0; _i < chd.length; _i++) {
|
||
|
|
var nod = chd[_i];
|
||
|
|
var attr = show_props[_i];
|
||
|
|
if (attr) {
|
||
|
|
// let attr_name = game.configs.attr_data.data_id_to_name[attr.attr_id];
|
||
|
|
var icon = game.configs.attr_data.data_id_to_key[attr.attr_id];
|
||
|
|
typeof this.fromBag === 'string' ? nx.bridge.attrs.setAttribute(nx.gui.find(nod, "info"), [icon, attr.attr_val]) : nx.bridge.attrs.setAttribute(nx.gui.find(nod, "info"), [icon, attr.attr_val, _i + 1]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
nx.gui.setActive(this.nodContent, "random", !nx.dt.arrEmpty(props));
|
||
|
|
}
|
||
|
|
},
|
||
|
|
upSkill: function upSkill() {
|
||
|
|
// console.log( "技能属性" + JSON.stringify( this.config ) );
|
||
|
|
var cmp = nx.gui.getComponent(this.nodContent, "skill/lst", "cmp.item.detail.prop.skill");
|
||
|
|
if (cmp && cmp.setData(this.item, this.config, this.fromBag)) {
|
||
|
|
nx.gui.setActive(this.nodContent, "skill", true);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 描述信息刷新
|
||
|
|
updDesc: function updDesc() {
|
||
|
|
var node = nx.gui.setActive(this.nodContent, "desc", true);
|
||
|
|
if (!node || nx.dt.objEmpty(this.config) || nx.dt.strEmpty(this.config.desc)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.gui.setStringRich(node, "txt", nx.text.getKey(this.config.desc));
|
||
|
|
},
|
||
|
|
// 来源刷新
|
||
|
|
updSources: function updSources() {
|
||
|
|
var cmp = nx.gui.getComponent(this.nodContent, "source/lst", "cmp.item.detail.source");
|
||
|
|
if (cmp && cmp.setData(this.item, this.config, this.fromBag)) {
|
||
|
|
nx.gui.setActive(this.nodContent, "source", true);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 操作刷新
|
||
|
|
updOps: function updOps() {
|
||
|
|
var style = 0;
|
||
|
|
var cmp = nx.gui.getComponent(this.nodOps, "", "cmp.item.detail.ops");
|
||
|
|
if (cmp && cmp.setData(this.item, this.config, this.fromBag)) {
|
||
|
|
nx.gui.setActive(this.nodOps, "", true);
|
||
|
|
style = Math.min(Math.ceil(cmp.opCount / 2), 3);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 三中布局
|
||
|
|
var node = nx.gui.find(this, "detail");
|
||
|
|
if (node) {
|
||
|
|
var hts = [410, 360, 300, 250];
|
||
|
|
node.height = hts[style];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|