214 lines
4.7 KiB
JavaScript
214 lines
4.7 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '78a9eAxd4xNnIEWNuIN9nEQ', 'cmp.skill.base');
|
||
|
|
// Scripts/mod/partner/cmps/skill/cmp.skill.base.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 技能图标
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
var SVCItem = require("nx.fx.sv.expand.item");
|
||
|
|
var 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 onEnable() {
|
||
|
|
this.openTip(this.tipSelf);
|
||
|
|
},
|
||
|
|
// 数据重置
|
||
|
|
rebind: function rebind(_idx, _data, _key) {
|
||
|
|
this._super(_idx, _data, _key);
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
this.setData(_data);
|
||
|
|
},
|
||
|
|
// 聚焦获得
|
||
|
|
onFocus: function onFocus() {
|
||
|
|
if (this.nodFocus && nx.dt.objNEmpty(this.info)) {
|
||
|
|
this.nodFocus.active = true;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 聚焦失去
|
||
|
|
outFocus: function outFocus() {
|
||
|
|
if (this.nodFocus) {
|
||
|
|
this.nodFocus.active = false;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 置空
|
||
|
|
setEmpty: function setEmpty() {
|
||
|
|
this.outFocus();
|
||
|
|
this.setIcon(0);
|
||
|
|
this.setLevel(0);
|
||
|
|
this.setName("");
|
||
|
|
this.setDescribe("");
|
||
|
|
this.setLocked(false);
|
||
|
|
},
|
||
|
|
// 重置
|
||
|
|
setData: function setData(_data, _lock) {
|
||
|
|
if (_lock === void 0) {
|
||
|
|
_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 freshAll() {
|
||
|
|
// 置空
|
||
|
|
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 setIcon(_icon) {
|
||
|
|
if (!this.nodIcon) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 置空
|
||
|
|
var icon = _icon + "";
|
||
|
|
if (nx.dt.strEmpty(icon) || icon == "0") {
|
||
|
|
nx.gui.setSpriteFrame(this.nodIcon, "", null);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 图标设置
|
||
|
|
nx.bridge.setIcon(this.nodIcon, "", _icon);
|
||
|
|
},
|
||
|
|
// 单设:数量
|
||
|
|
setLevel: function setLevel(_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 setName(_name) {
|
||
|
|
if (!this.nodName) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var txt = nx.text.getKey(_name);
|
||
|
|
if (this.lenName > 0) {
|
||
|
|
txt = nx.dt.strCut(txt, this.lenName);
|
||
|
|
}
|
||
|
|
nx.gui.setString(this.nodName, "", txt);
|
||
|
|
},
|
||
|
|
setType: function setType(_type) {
|
||
|
|
if (!this.nodType) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var txt = nx.text.getKey(_type);
|
||
|
|
nx.gui.setString(this.nodType, "", txt);
|
||
|
|
},
|
||
|
|
// 单设:描述
|
||
|
|
setDescribe: function setDescribe(_desc) {
|
||
|
|
if (!this.nodDesc) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.gui.setString(this.nodDesc, "", nx.text.getKey(_desc));
|
||
|
|
},
|
||
|
|
// 单设:锁定
|
||
|
|
setLocked: function setLocked(_locked) {
|
||
|
|
this.locked = !!_locked;
|
||
|
|
nx.gui.setActive(this.nodLock, "", this.locked);
|
||
|
|
},
|
||
|
|
// 开启详情跳转
|
||
|
|
openTip: function openTip(_open) {
|
||
|
|
this.tipSelf = !!_open;
|
||
|
|
var btn = nx.gui.getComponent(this, "bg", "nx.fx.button");
|
||
|
|
if (btn) {
|
||
|
|
btn.lock(!this.tipSelf);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 点击
|
||
|
|
onTouchTip: function onTouchTip() {
|
||
|
|
// if( this.locked ) {
|
||
|
|
// nx.tbox( "Locked" );
|
||
|
|
// return;
|
||
|
|
// }
|
||
|
|
|
||
|
|
var TC = TipsController.getInstance();
|
||
|
|
if (TC && this.info) {
|
||
|
|
TC.showSkillTips(this.info, this.locked);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|