const SVCItem = require("nx.fx.sv.expand.item"); const RankController = require("rank_controller"); const RankConstant = require("rank_constant"); const ChatController = require("chat_controller"); const RoleController = require("role_controller"); /********** * * 各不同类型排行列表单个ui数据显示 */ cc.Class({ extends: SVCItem, properties: { rankBg: { default : null, type : cc.Node, }, rankIcon: { default : null, type : cc.Node, }, playerInfo: { default : null, type : cc.Node, }, player_name : { default : null, type : cc.Node, }, player_header : { default : null, type : cc.Node, }, floor : { default : null, type : cc.Node, }, fab_head: { default : null, type : cc.Prefab, } }, // 数据重置 rebind: function (_idx, _data, _key) { this._super(_idx, _data, _key); this.freshInfo(); }, // 刷新具体信息 freshInfo:function(){ if(!this.mdata){ return; } this.setRankicon( this.mdata.idx ); this.setLstHeadIcon( this.mdata ); nx.gui.setString( this.player_name, "", nx.text.getKey(this.mdata.name) ); // nx.gui.setString( this.playerInfo, "", nx.dt.fmtTimeFromSecs( this.mdata.val2 ) ); nx.gui.setString( this.floor, "", this.mdata.val1 ); }, // 设置前三名显示效果 setRankicon : function( _index ){ let index = _index; if( index < 4 ){ nx.gui.setActive( this, "rank_" + index, true ); nx.gui.setActive( this.rankIcon, "icon_" + index, true ); }else{ nx.gui.setActive( this, "rank_4", true ); nx.gui.setActive( this.rankIcon, "icon_4" , true ); nx.gui.setString( nx.gui.find( this.rankIcon, "txt" ), "", index ); } }, // 头像显示 公会没有头像显示 setLstHeadIcon : function( _faceid ){ nx.bridge.setIcon( this.player_header, "avatar/mask/img", _faceid.face_id, "resDB/empty/avatar" ); let cfg = game.configs.avatar_data.data_avatar[ _faceid.avatar_bid ]; let icon = cfg ? cfg.base_id : 1000; nx.bridge.setAvatarFrame( this.player_header, "avatar/frame", icon ); }, //打开玩家信息 openChatMessage: function() { let model = RankController.getInstance(); let type = model.getListType(); if( type == RankConstant.RankType.union ){ return; } let roleVo = RoleController.getInstance().getRoleVo(); let rid = this.mdata.rid || this.mdata.r_rid; var srv_id = this.mdata.srv_id || this.mdata.r_srvid; if( rid && srv_id && roleVo.rid == rid && roleVo.srv_id == srv_id ) { nx.tbox( nx.text.getKey( "lab_rank_item_tip_1" ) ); return } if( this.mdata.is_robot && this.mdata.is_robot == 1 ) { nx.tbox( nx.text.getKey( "lab_rank_item_tip_2" ) ); return } if( this.mdata ) { let model = ChatController.getInstance(); let vo = { rid: rid, srv_id: srv_id }; model.openFriendInfo( vo ); } }, });