103 lines
2.5 KiB
JavaScript
103 lines
2.5 KiB
JavaScript
|
|
|
|
const ItemBase = require( "cmp.item.base" );
|
|
const SVCItem = require( "nx.fx.sv.expand.item" );
|
|
const TipsController = require( "tips_controller" );
|
|
const BackPackConst = require( "backpack_const" );
|
|
const BIT = BackPackConst.item_type;
|
|
|
|
cc.Class( {
|
|
|
|
extends: SVCItem,
|
|
|
|
properties: {
|
|
|
|
cmpItem: {
|
|
default: null,
|
|
type: ItemBase,
|
|
displayName: "图标"
|
|
},
|
|
|
|
},
|
|
|
|
// 数据重置
|
|
rebind: function( _idx, _data, _key ) {
|
|
|
|
this._super( _idx, _data, _key );
|
|
|
|
// 刷新
|
|
this.setData( _data );
|
|
|
|
},
|
|
|
|
// 重置
|
|
setData: function( _data, _count ) {
|
|
|
|
|
|
this.mdata = _data;
|
|
if( _data ){
|
|
this.cmpItem.setData( _data , _count );
|
|
this.freshInfo();
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
freshInfo: function(){
|
|
|
|
|
|
|
|
let title = game.configs.attr_data.data_key_to_name[this.mdata.config.ext[0][1][0][0]];
|
|
let val = this.mdata.config.ext[0][1][0][1];
|
|
nx.gui.setString( this, "prop/key", title );
|
|
nx.gui.setString( this, "prop/txt", val );
|
|
let path = cc.path.join( "coms/images", "star" + this.mdata.config.eqm_star );
|
|
nx.gui.setSpriteFrame( this.cmpItem, "bg/star", path );
|
|
let holy_eqm_attr = [];
|
|
for (let i = 0; i < this.mdata.holy_eqm_attr.length; i++) {
|
|
let data = this.mdata.holy_eqm_attr[i];
|
|
if( data.pos <= 2 ){
|
|
holy_eqm_attr.push( data );
|
|
}
|
|
|
|
}
|
|
let nodes = nx.gui.find( this, "atts/nod" );
|
|
if( nx.dt.arrEmpty( holy_eqm_attr ) ){
|
|
nx.gui.setString( nodes, "info/txt", nx.text.getKey( "AttrNone" ) );
|
|
}else{
|
|
nx.gui.gocChildren( nodes,"", holy_eqm_attr.length );
|
|
for (let i = 0; i < holy_eqm_attr.length; i++) {
|
|
let item = holy_eqm_attr[i];
|
|
let node = nodes.children[i];
|
|
let atttitle = game.configs.attr_data.data_id_to_name[item.attr_id];
|
|
nx.gui.setString( node, "name", atttitle );
|
|
nx.gui.setString( node, "txt", item.attr_val );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
// 点击装备
|
|
onTouchEquip: function() {
|
|
|
|
let svc = this.node.svc;
|
|
if( svc && svc.binder && svc.binder.onEquip ) {
|
|
svc.binder.onEquip( this.mdata );
|
|
}
|
|
|
|
},
|
|
|
|
onTouchIcon: function(){
|
|
|
|
const TC = TipsController.getInstance();
|
|
if( TC && this.mdata ) {
|
|
TC.showItemTips( this.mdata );
|
|
}
|
|
|
|
},
|
|
|
|
} );
|