const ItemBase = require( "cmp.item.base" ); const SVCItem = require( "nx.fx.sv.expand.item" ); const BridgeWindow = require( "bridge.window" ); const BackPackConst = require( "backpack_const" ); cc.Class( { extends: BridgeWindow, properties: { nodBase: { default: null, type: cc.Node, displayName: "基础栏" }, nodContent: { default: null, type: cc.Node, displayName: "详情栏" }, }, // 载入 onLoad: function() { }, // 重载:参数打开 onOpenConfigs: function( _params ) { this.setData( _params ); }, // 重置 setData: function( _data ) { // 置空 this.mdata = _data.data; this.item = BackPackConst.uniformData( _data.data ); if( !this.item ) { this.mdata = {}; return; } // 统一道具信息格式 // this.info = BridgeItem.data2Icon( _data ); this.config = this.item.config; // 刷新 this.freshAll(); }, // 刷新 freshAll: function() { // 空 if( nx.dt.objEmpty( this.item ) ) { return; } // 显隐藏 nx.gui.setOpacity( this.node, "", 255 ); nx.gui.hideAllChildren( this.nodBase, "" ); nx.gui.hideAllChildren( this.nodContent, "" ); // 后刷新 this.updHeader(); this.updDesc(); this.updSources(); }, // 基础信息刷新 updHeader: function() { let cmp = nx.gui.getComponent( this.nodBase, "", "cmp.item.detail.header" ); if( cmp ) { cmp.setData( this.item, this.config, this.fromBag ); } }, // 基础属性刷新 updBaseProps: function() { let cmp = nx.gui.getComponent( this.nodContent, "base/lst", "cmp.item.detail.prop.base" ); if( cmp && cmp.setData( this.item, this.config, this.fromBag ) ) { nx.gui.setActive( this.nodContent, "base", true ); } }, // 套装属性刷新 updSuitProps: function() { let cmp = nx.gui.getComponent( this.nodContent, "suit/lst", "cmp.item.detail.prop.suit" ); if( cmp && cmp.setData( this.item, this.config, this.fromBag ) ) { nx.gui.setActive( this.nodContent, "suit", true ); } }, upSkill: function() { let cmp = nx.gui.getComponent( this.nodContent, "skill/lst", "cmp.item.detail.prop.skill" ); if( cmp && cmp.setData( this.item, this.config, this.fromBag ) ) { nx.gui.setActive( this.nodContent, "skill", true ); } }, // 描述信息刷新 updDesc: function() { let node = nx.gui.setActive( this.nodContent, "desc", true ); if( !node || nx.dt.objEmpty( this.config ) || nx.dt.strEmpty( this.config.desc ) ) { return; } nx.gui.setStringRich( node, "txt", nx.text.getKey( this.config.desc ) ); }, // 来源刷新 updSources: function() { let cmp = nx.gui.getComponent( this.nodContent, "source/lst", "cmp.item.detail.source" ); if( cmp && cmp.setData( this.item, this.config, this.fromBag ) ) { nx.gui.setActive( this.nodContent, "source", true ); } }, } );