217 lines
4.9 KiB
JavaScript
217 lines
4.9 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 技能图标
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
const SVCItem = require( "nx.fx.sv.expand.item" );
|
||
|
|
const TipsController = require( "tips_controller" );
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: SVCItem,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
nodBG: { default: null, type: cc.Node },
|
||
|
|
nodIcon: { default: null, type: cc.Node },
|
||
|
|
nodLevel: { default: null, type: cc.Node },
|
||
|
|
lenName: { default: 0, displayName: "名字长度(字节)" },
|
||
|
|
nodName: { default: null, type: cc.Node },
|
||
|
|
nodType: { default: null, type: cc.Node },
|
||
|
|
nodDesc: { default: null, type: cc.Node },
|
||
|
|
nodFocus: { default: null, type: cc.Node },
|
||
|
|
nodLock: { default: null, type: cc.Node },
|
||
|
|
tipSelf: { default: true, displayName: "点击提示" },
|
||
|
|
lockHideLevel: { default: true, displayName: "锁定不显示等级" },
|
||
|
|
},
|
||
|
|
|
||
|
|
// 显示
|
||
|
|
onEnable: function() {
|
||
|
|
|
||
|
|
this.openTip( this.tipSelf );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 数据重置
|
||
|
|
rebind: function( _idx, _data, _key ) {
|
||
|
|
|
||
|
|
this._super( _idx, _data, _key );
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
this.setData( _data );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 聚焦获得
|
||
|
|
onFocus: function() {
|
||
|
|
if( this.nodFocus && nx.dt.objNEmpty( this.info ) ) {
|
||
|
|
this.nodFocus.active = true;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 聚焦失去
|
||
|
|
outFocus: function() {
|
||
|
|
if( this.nodFocus ) {
|
||
|
|
this.nodFocus.active = false;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 置空
|
||
|
|
setEmpty: function() {
|
||
|
|
|
||
|
|
this.outFocus();
|
||
|
|
this.setIcon( 0 );
|
||
|
|
this.setLevel( 0 );
|
||
|
|
this.setName( "" );
|
||
|
|
this.setDescribe( "" );
|
||
|
|
this.setLocked( false );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 重置
|
||
|
|
setData: function( _data, _lock = false ) {
|
||
|
|
|
||
|
|
this.mdata = _data;
|
||
|
|
|
||
|
|
// 获取技能信息
|
||
|
|
this.info = _data;
|
||
|
|
if( nx.dt.numGood( _data ) ) {
|
||
|
|
this.info = gskilldata( 'data_get_skill', _data );
|
||
|
|
}
|
||
|
|
// console.log( "当前的技能信息" + JSON.stringify( this.info ) );
|
||
|
|
this.locked = _lock || false;
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
this.freshAll();
|
||
|
|
},
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
freshAll: function() {
|
||
|
|
|
||
|
|
// 置空
|
||
|
|
if( nx.dt.objEmpty( this.info ) ) {
|
||
|
|
this.setEmpty();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 基本信息
|
||
|
|
this.setLevel( this.info.level );
|
||
|
|
this.setIcon( this.info.icon );
|
||
|
|
this.setName( this.info.name );
|
||
|
|
this.setDescribe( this.info.des || this.info.desc );
|
||
|
|
this.setLocked( this.locked );
|
||
|
|
this.setType( this.info.type );
|
||
|
|
|
||
|
|
// 锁定不显示等级
|
||
|
|
if( this.locked && this.lockHideLevel ) {
|
||
|
|
nx.gui.setActive( this.nodLevel, "", false );
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 单设:图标
|
||
|
|
setIcon: function( _icon ) {
|
||
|
|
|
||
|
|
if( !this.nodIcon ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 置空
|
||
|
|
let icon = _icon + "";
|
||
|
|
if( nx.dt.strEmpty( icon ) || icon == "0" ) {
|
||
|
|
nx.gui.setSpriteFrame( this.nodIcon, "", null );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 图标设置
|
||
|
|
nx.bridge.setIcon( this.nodIcon, "", _icon );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 单设:数量
|
||
|
|
setLevel: function( _level ) {
|
||
|
|
|
||
|
|
if( !this.nodLevel ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if( nx.dt.numPositive( _level, false ) ) {
|
||
|
|
nx.gui.setActive( this.nodLevel, "", true );
|
||
|
|
nx.gui.setString( this.nodLevel, "txt", _level );
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
nx.gui.setActive( this.nodLevel, "", false );
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 单设:名字
|
||
|
|
setName: function( _name ) {
|
||
|
|
|
||
|
|
if( !this.nodName ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
let txt = nx.text.getKey( _name );
|
||
|
|
if( this.lenName > 0 ) {
|
||
|
|
txt = nx.dt.strCut( txt,this.lenName );
|
||
|
|
}
|
||
|
|
nx.gui.setString( this.nodName, "", txt );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
setType: function( _type ){
|
||
|
|
if( !this.nodType ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
let txt = nx.text.getKey( _type );
|
||
|
|
|
||
|
|
nx.gui.setString( this.nodType, "", txt );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 单设:描述
|
||
|
|
setDescribe: function( _desc ) {
|
||
|
|
|
||
|
|
if( !this.nodDesc ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setString( this.nodDesc, "", nx.text.getKey( _desc ) );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 单设:锁定
|
||
|
|
setLocked: function( _locked ) {
|
||
|
|
|
||
|
|
this.locked = !!_locked;
|
||
|
|
nx.gui.setActive( this.nodLock, "", this.locked );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 开启详情跳转
|
||
|
|
openTip: function( _open ) {
|
||
|
|
|
||
|
|
this.tipSelf = !!_open;
|
||
|
|
|
||
|
|
let btn = nx.gui.getComponent( this, "bg", "nx.fx.button" );
|
||
|
|
if( btn ) {
|
||
|
|
btn.lock( !this.tipSelf );
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 点击
|
||
|
|
onTouchTip: function() {
|
||
|
|
|
||
|
|
// if( this.locked ) {
|
||
|
|
// nx.tbox( "Locked" );
|
||
|
|
// return;
|
||
|
|
// }
|
||
|
|
|
||
|
|
const TC = TipsController.getInstance();
|
||
|
|
if( TC && this.info ) {
|
||
|
|
TC.showSkillTips( this.info, this.locked );
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|