87 lines
1.9 KiB
JavaScript
87 lines
1.9 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 头像选择项
|
|
*
|
|
******************************************************************/
|
|
|
|
const SVCItem = require( "nx.fx.sv.expand.item" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: SVCItem,
|
|
|
|
properties: {
|
|
nodBG: { default: null, type: cc.Node },
|
|
nodIcon: { default: null, type: cc.Node },
|
|
nodUsed: { default: null, type: cc.Node },
|
|
nodLocked: { default: null, type: cc.Node },
|
|
nodFocus: { default: null, type: cc.Node },
|
|
},
|
|
|
|
// 显示
|
|
onEnable: function() {
|
|
|
|
},
|
|
|
|
// 数据重置
|
|
rebind: function( _idx, _data, _key ) {
|
|
|
|
this._super( _idx, _data, _key );
|
|
|
|
this.nodFocus.active = false;
|
|
|
|
// 刷新
|
|
this.setData( _data );
|
|
|
|
},
|
|
|
|
// 聚焦获得
|
|
onFocus: function() {
|
|
this.nodFocus.active = true;
|
|
},
|
|
|
|
// 聚焦失去
|
|
outFocus: function() {
|
|
this.nodFocus.active = false;
|
|
},
|
|
|
|
// 置空
|
|
setEmpty: function() {
|
|
|
|
nx.gui.setActive( this.nodUsed, "", false );
|
|
nx.gui.setActive( this.nodLocked, "", false );
|
|
nx.gui.setSpriteFrame( this.nodIcon, "", null );
|
|
},
|
|
|
|
// 设置使用中
|
|
setUsed: function( _used ) {
|
|
this.nodUsed.active = _used;
|
|
},
|
|
|
|
// 重置
|
|
setData: function( _data ) {
|
|
|
|
this.mdata = _data;
|
|
|
|
// 无效
|
|
if( nx.dt.objEmpty( this.mdata ) ||
|
|
!nx.dt.numPositive( this.mdata.id, false ) ) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
this.setUsed( false );
|
|
nx.gui.setActive( this.nodLocked, "", this.mdata.lock );
|
|
|
|
nx.bridge.setIcon( this.nodIcon, "", this.mdata.icon );
|
|
|
|
// 未解锁
|
|
// if( !this.mdata.have ) {
|
|
// let tip = nx.text.getKey( this.mdata.cfgs.tips );
|
|
// nx.gui.setString( this.nodLocked, "txt", tip );
|
|
// }
|
|
|
|
},
|
|
|
|
} );
|