205 lines
5.6 KiB
JavaScript
205 lines
5.6 KiB
JavaScript
const BackPackConst = require( "backpack_const" );
|
|
const BackpackController = require( "backpack_controller" );
|
|
const BagWnd = require( "cmp.bag.wnd" );
|
|
const FID = require( "bridge.function.ids" );
|
|
const BBT = BackPackConst.tips_btn_type;
|
|
|
|
|
|
cc.Class( {
|
|
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
nodOps: { default: null, type: cc.Node, displayName: "操作栏" },
|
|
wndBag: { default: null, type: BagWnd, displayName: "归属窗体" },
|
|
},
|
|
|
|
// 载入
|
|
onLoad: function() {
|
|
|
|
this.BC = BackpackController.getInstance();
|
|
this.setEmpty();
|
|
},
|
|
|
|
// 置空
|
|
setEmpty: function() {
|
|
|
|
// 操作全隐藏
|
|
nx.gui.hideAllChildren( this.nodOps, "" );
|
|
|
|
this.opCount = 0;
|
|
},
|
|
|
|
// 设置道具
|
|
// @ 返回true:需要显示
|
|
setData: function( _item, _config, _fromBag ) {
|
|
|
|
// 全隐藏
|
|
if( !_item || !_config ) {
|
|
this.setEmpty();
|
|
return false;
|
|
}
|
|
|
|
// 获取配置
|
|
this.item = _item;
|
|
this.config = _config;
|
|
|
|
// 道具操作选项
|
|
let ops = _config.tips_btn;
|
|
if( nx.dt.arrEmpty( ops ) ) {
|
|
this.setEmpty();
|
|
return false;
|
|
}
|
|
|
|
// 列表创建
|
|
const chds = this.nodOps.children;
|
|
nx.gui.gocChildren( this.nodOps, "", ops.length, chds[ 0 ] );
|
|
for( let i = 0; i < ops.length; ++i ) {
|
|
let btn = chds[ i ];
|
|
btn.op = ops[ i ];
|
|
let txt = nx.text.getKey( "ItemOp" + btn.op[ 0 ] );
|
|
nx.gui.setString( btn, "on/txt", txt );
|
|
}
|
|
|
|
// 按钮数保存
|
|
this.opCount = ops.length;
|
|
|
|
// 居中特殊操作
|
|
this.node.width = ( this.opCount == 1 ) ? 120 : 266;
|
|
|
|
return true;
|
|
},
|
|
|
|
// 点击
|
|
onTouchButton: function( _btn ) {
|
|
|
|
// 无效道具
|
|
if( nx.dt.objEmpty( this.item ) ) {
|
|
nx.error( "[ItemOP]无效道具!" );
|
|
return;
|
|
}
|
|
|
|
// 道具操作跳转
|
|
this.doOp( _btn.op );
|
|
},
|
|
|
|
// 操作处理
|
|
doOp: function( _op ) {
|
|
|
|
if( nx.dt.arrEmpty( _op ) ) {
|
|
return;
|
|
}
|
|
|
|
nx.debug( "[OPS] %s, %s", _op[ 0 ], _op[ 1 ] );
|
|
|
|
// 第二参数:如果为sourceId(<10000),则直接统一进行功能跳转
|
|
// 比如:[1,245]
|
|
const OTS = BackPackConst.ItemOpSubType;
|
|
if( nx.dt.numPositive( _op[1], false ) &&
|
|
_op[1] < OTS.Begin ) {
|
|
nx.bridge.jumper.jump2Window( _op[1] );
|
|
return;
|
|
}
|
|
|
|
// 第二参数:如果为道具操作特殊子类型(>10000),则直接使用
|
|
// 比如:[1,10101]
|
|
if( nx.dt.numPositive( _op[1], false ) &&
|
|
_op[1] > OTS.Begin ) {
|
|
|
|
if(_op[1] == 10104){//自選禮包多種類批量操作
|
|
nx.bridge.jumper.jumpOpItem( BBT.SectMoreUse, {
|
|
config: this.config,
|
|
item: this.item,
|
|
} );
|
|
return;
|
|
}
|
|
|
|
nx.bridge.jumper.jumpOpItem( BBT.goods_use, {
|
|
config: this.config,
|
|
item: this.item,
|
|
} );
|
|
return;
|
|
}
|
|
|
|
// 否则为特殊子类型,区别处理
|
|
const OT = BackPackConst.ItemOps;
|
|
switch( _op[ 0 ] ) {
|
|
|
|
// 使用
|
|
case OT.Use: {
|
|
|
|
} break;
|
|
// 合成
|
|
case OT.Compound: {
|
|
nx.bridge.jumper.jumpOpItem( BBT.hecheng, {
|
|
config : this.config,
|
|
item: this.item,
|
|
} );
|
|
} break;
|
|
// 出售
|
|
case OT.Sell: {
|
|
nx.bridge.jumper.jumpOpItem( BBT.item_sell, {
|
|
config : this.config,
|
|
item: this.item,
|
|
|
|
} );
|
|
} break;
|
|
// 重铸
|
|
case OT.Recast: {
|
|
nx.bridge.jumper.jump2Window( FID.ArtifactReset, {
|
|
item: this.item,
|
|
config : this.config
|
|
} );
|
|
} break;
|
|
// 分解
|
|
case OT.Resolve: {
|
|
nx.bridge.jumper.jumpOpItem( BBT.RuneSell, {
|
|
config : this.config,
|
|
item: this.item,
|
|
|
|
} );
|
|
} break;
|
|
// 穿戴
|
|
case OT.Equip: {
|
|
nx.bridge.jumper.jumpOpItem( BBT.RuneEquip, {
|
|
config : this.config,
|
|
item: this.item,
|
|
|
|
} );
|
|
} break;
|
|
// 详情
|
|
case OT.Detail: {
|
|
|
|
} break;
|
|
// 查看
|
|
case OT.Lookup: {
|
|
nx.bridge.jumper.jumpOpItem( BBT.JumpToSingleHero, {
|
|
item: this.item,
|
|
config : this.config
|
|
} );
|
|
} break;
|
|
// 查看
|
|
case OT.Refine: {
|
|
nx.bridge.jumper.jumpOpItem( BBT.GodEquipmentReMake, {
|
|
config: this.item,
|
|
item : 0
|
|
} );
|
|
} break;
|
|
// 皮肤合成
|
|
case OT.SkinCompound: {
|
|
nx.bridge.jumper.jumpOpItem( BBT.SkinCompound, {
|
|
item: this.item,
|
|
config : this.config
|
|
} );
|
|
} break;
|
|
default: break;
|
|
}
|
|
// nx.bridge.jumper.jumpOpItem( _op, {
|
|
// config: this.config,
|
|
// item: this.item
|
|
// } );
|
|
|
|
},
|
|
|
|
} );
|