/****************************************************************** * * 秘书选择项 * ******************************************************************/ const SVCItem = require( "nx.fx.sv.expand.item" ); const HeroConst = require( "hero_const" ); const HCT = HeroConst.CampType; cc.Class( { extends: SVCItem, properties: {}, // 数据重置 rebind: function( _idx, _data, _key ) { this._super( _idx, _data, _key ); // 刷新 this.setData( _data ); nx.gui.setActive( this, "focus", false ); }, // 聚焦获得 onFocus: function() { nx.gui.setActive( this, "focus", true ); }, // 聚焦失去 outFocus: function() { nx.gui.setActive( this, "focus", false ); }, // 置空 setEmpty: function() { nx.gui.setActive( this, "focus", false ); nx.gui.setSpriteFrame( this, "head/camp", null ); nx.gui.setSpriteFrame( this, "mask/bg", null ); nx.gui.setSpriteFrame( this, "mask/img", null ); }, // 重置 setData: function( _data, _lock = false ) { this.mdata = _data; let clerk = _data; if( !clerk ) { this.setEmpty(); return; } // 阵营标记 let camp = clerk.partner.camp_type || HCT.eWater; let path = cc.path.join( "coms/images", "camps" + camp ); nx.gui.setSpriteFrame( this, "head/camp", path ); // 阵营背景 path = cc.path.join( "coms/camps", "bg" + camp ); nx.gui.setSpriteFrame( this, "mask/bg", path ); // 阵营边框 path = cc.path.join( "coms/camps", "frame" + camp ); nx.gui.setSpriteFrame( this, "frame", path ); // 角色 nx.gui.setSpriteFrame( this, "mask/img", clerk.cfg.img_half_small, ( _ret ) => { if( !_ret ) { nx.gui.setSpriteFrame( this, "mask/img", "resDB/empty/half_show3" ); } } ); }, } );