219 lines
6.2 KiB
JavaScript
219 lines
6.2 KiB
JavaScript
|
|
const 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() {
|
|
|
|
this.setEmpty();
|
|
},
|
|
|
|
// 重置
|
|
setData: function( _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() {
|
|
|
|
// 信息隐藏 处理当前节点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() {
|
|
|
|
// 空
|
|
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() {
|
|
let cmp = nx.gui.getComponent( this.nodBase, "", "cmp.item.detail.header" );
|
|
if( cmp ) {
|
|
cmp.setData( this.item, this.config, this.fromBag );
|
|
}
|
|
},
|
|
|
|
// 基础属性刷新
|
|
updBaseProps: function() {
|
|
|
|
let 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() {
|
|
// console.log( "套装属性" + JSON.stringify( this.config ) );
|
|
let 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() {
|
|
|
|
// console.log( "随机属性" + JSON.stringify( this.item.holy_eqm_attr ) );
|
|
let props = this.item.holy_eqm_attr;
|
|
if( props ){
|
|
let show_props = [];
|
|
for (let i = 0; i < props.length; i++) {
|
|
let prop = props[i];
|
|
if( prop.pos <= 2 ){
|
|
show_props.push( prop );
|
|
}
|
|
|
|
}
|
|
|
|
nx.gui.gocChildren( this.nodContent, "random/lst", show_props.length );
|
|
let chd = nx.gui.find( this.nodContent, "random/lst" ).children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
let attr = show_props[i];
|
|
if( attr ){
|
|
|
|
// let attr_name = game.configs.attr_data.data_id_to_name[attr.attr_id];
|
|
let 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() {
|
|
// console.log( "技能属性" + JSON.stringify( this.config ) );
|
|
let 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() {
|
|
|
|
let 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() {
|
|
|
|
let 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() {
|
|
|
|
let style = 0;
|
|
let 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 );
|
|
}
|
|
|
|
// 三中布局
|
|
let node = nx.gui.find( this, "detail" );
|
|
if( node ) {
|
|
const hts = [ 410, 360, 300, 250 ];
|
|
node.height = hts[ style ];
|
|
}
|
|
|
|
},
|
|
|
|
} );
|