97 lines
2.9 KiB
JavaScript
97 lines
2.9 KiB
JavaScript
const PathTool = require( "pathtool" );
|
|
const BackPackConst = require( "backpack_const" );
|
|
const GoodsVo = require( "goods_vo" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
|
|
nodList: {
|
|
default: null,
|
|
type: cc.Node,
|
|
displayName: "列表容器"
|
|
},
|
|
|
|
},
|
|
|
|
// 载入
|
|
onLoad: function() {
|
|
},
|
|
|
|
// 置空
|
|
setEmpty: function() {
|
|
nx.gui.hideAllChildren( this.nodList, "" );
|
|
},
|
|
|
|
// 设置道具
|
|
// @ 返回true:需要显示
|
|
setData: function( _item, _config, _fromBag ) {
|
|
|
|
// 全隐藏
|
|
if( !_item || !_config ) {
|
|
this.setEmpty();
|
|
return false;
|
|
}
|
|
|
|
// 统计主属性信息
|
|
let props = [];
|
|
if( nx.dt.arrNEmpty( _item.main_attr ) ) {
|
|
// 优先服务器数据
|
|
_item.main_attr.forEach( _p => {
|
|
let key = game.configs.attr_data.data_id_to_key[ _p.attr_id ];
|
|
props.push( { key: key, id: _p.attr_id, val: _p.attr_val } );
|
|
} );
|
|
}
|
|
// 其次静态配置属性,固定位置config.ext[0][1]为main_attr
|
|
else if( nx.dt.arrNEmpty( _config.ext ) &&
|
|
nx.dt.arrNEmpty( _config.ext[ 0 ] ) ) {
|
|
let tmp = _config.ext[ 0 ][ 1 ];
|
|
if( nx.dt.arrNEmpty( tmp ) ) {
|
|
tmp.forEach( _p => {
|
|
let id = game.configs.attr_data.data_key_to_id[ _p[ 0 ] ];
|
|
props.push( { key: _p[ 0 ], id: id, val: _p[ 1 ] } );
|
|
} );
|
|
}
|
|
}
|
|
|
|
// 统计精炼属性
|
|
// *** 全体缩放1000倍后走正常流程
|
|
if( nx.dt.arrNEmpty( _item.attr ) ) {
|
|
_item.attr.forEach( _p => {
|
|
let key = game.configs.attr_data.data_id_to_key[ _p.attr_id ];
|
|
props.push( { key: key, id: _p.attr_id, val: _p.attr_val / 1000 } );
|
|
} );
|
|
}
|
|
|
|
// 统计附加属性
|
|
// *** 全体缩放1000倍后走正常流程
|
|
if( nx.dt.arrNEmpty( _item.extra_attr ) ) {
|
|
_item.extra_attr.forEach( _p => {
|
|
let key = game.configs.attr_data.data_id_to_key[ _p.attr_id ];
|
|
props.push( { key: key, id: _p.attr_id, val: _p.attr_val / 1000 } );
|
|
} );
|
|
}
|
|
|
|
// 空属性
|
|
if( nx.dt.arrEmpty( props ) ) {
|
|
this.setEmpty();
|
|
return false;
|
|
}
|
|
|
|
// 列表创建
|
|
const chds = this.nodList.children;
|
|
nx.gui.gocChildren( this.nodList, "", props.length, chds[ 0 ] );
|
|
for( let i = 0; i < props.length; ++i ) {
|
|
// setProp( chds[ i ], props[ i ] );
|
|
typeof( _fromBag ) === 'string' ? nx.bridge.attrs.setAttribute( nx.gui.find( chds[ i ], "info" ) , [ props[ i ].key, props[ i ].val ] )
|
|
: nx.bridge.attrs.setAttribute( nx.gui.find( chds[ i ], "info" ) , [ props[ i ].key, props[ i ].val, i+1 ] );
|
|
|
|
}
|
|
|
|
return true;
|
|
},
|
|
|
|
} );
|