Files
fc/dev/project/assets/Scripts/mod/pve/cmp/cmp.pve.rank.wnd.js
T
2026-05-23 22:10:14 +08:00

176 lines
6.2 KiB
JavaScript

const BridgeWindow = require("bridge.window");
const ArenaEvent = require("arena_event");
const FxSVC = require("nx.fx.sv.expand");
const ArenaController = require( "arena_controller" );
const FxTogs = require( "nx.fx.togs" );
const RoleEvent = require( "role_event" );
const RKC = require("rank_controller");
const RKEVT = require("rank_event");
const RankConstant = require("rank_constant");
// 标签页对应关系
const TabPage = [
{ key: "RankNow", goto: 0 },
{ key: "rank_reward", goto: 1 },
];
cc.Class({
extends: BridgeWindow,
properties: {
nodOps : { default:null, type: cc.Node },
nodToggle: { default:null, type: FxTogs },
nodLst: { default:null, type: FxSVC },
},
onLoad: function () {
this.bindGEvent( RoleEvent.WorshipOtherRole, this.freshOneWorship.bind(this) );
this.bindGEvent( RKEVT.RankEvent_Get_Rank_data, this.freshOtherUI.bind(this) );
// Tog监听
this.nodToggle.posTog = this.onTogMenu.bind( this );
},
onOpenConfigs( _params ) {
this.dfg = _params.dfg;
this.show = _params.show;
let ops = _params.ops;
this.fromOther = _params.type;
let chd = this.nodOps.children;
for (let i = 0; i < chd.length; i++) {
let op = ops[i];
if( !op ){
nx.gui.setActive( chd[i], "", false );
continue;
}
nx.gui.setActive( chd[i], "", true );
nx.gui.setString( chd[i], "on/txt", nx.text.getKey( op ) );
nx.gui.setString( chd[i], "off/txt", nx.text.getKey( op ) );
}
let goto = 0;
TabPage.forEach( _tab => {
if( this.show == _tab.key ){
goto = _tab.goto;
}
} )
this.nodToggle.togTo( goto );
this.activeMenu( goto + 1 );
},
// 激活菜单
activeMenu: function( _bagCode ) {
if( this.curType == _bagCode ) {
return;
}
this.curType = _bagCode;
if( _bagCode == 1 ){
let ind = parseInt( this.fromOther );
this.rank_type = ind;
this.freshInfo();
if( ind == RankConstant.RankType.element || ind == RankConstant.RankType.heaven){
RKC.getInstance().send_12900( ind, null, null, false);
}
}
if( _bagCode == 2 ){
let T = nx.gui.find( this.node, "templates/award" );
this.nodLst.tmpItem = T;
this.freshData( this.dfg );
this.freshInfo();
}
},
freshOtherUI: function ( _data ){
nx.gui.setActive( this.nodLst, cc.js.formatStr("self_rank/item%s",this.rank_type), this.rank_type == _data.type );
nx.gui.setActive( this.nodLst,"nod_rank", this.curType == 1 );
// 设置顶部 标题
let tnod = nx.gui.find( this.nodLst, "title" );
nx.gui.setActive( tnod,"nod_rank", this.curType == 1 );
let T = nx.gui.find( this.node, cc.js.formatStr("templates/itemT%s",this.rank_type) );
let nod = nx.gui.find( this.nodLst, "self_rank" );
let rank_node = nx.gui.find( nod, cc.js.formatStr("item%s/rank",this.rank_type) );
nx.gui.setActive( rank_node, "icon_" + _data.my_idx, _data.my_idx > 0 && _data.my_idx < 4 );
nx.gui.setActive( rank_node, "icon_4" , _data.my_idx >= 4 );
if( _data.my_idx >= 4 ){
nx.gui.setString( rank_node, "txt" , _data.my_idx );
}
if( _data.my_idx == 0 ){
nx.gui.setString( rank_node, "txt2" , nx.text.getKey( "Rank0" ));
}
nx.gui.setString( nod, cc.js.formatStr("item%s/name",this.rank_type), _data.name );
if(this.rank_type == 40){
nx.gui.setString( nod, cc.js.formatStr("item%s/info/score/txt",this.rank_type), nx.text.format( "WeeklyCross", _data.my_val1 ) );
nx.gui.setString( nod, cc.js.formatStr("item%s/lay/power",this.rank_type), _data.my_val2 );
}else if(this.rank_type == 42){
nx.gui.setSpriteFrame( nod, cc.js.formatStr("item%s/info/score/star",this.rank_type), "prefab/pve/RelicExploration/ui/star_01");
nx.gui.setString( nod, cc.js.formatStr("item%s/info/score/txt",this.rank_type), _data.my_val1 );
}
this.nodLst.tmpItem = T;
let lst = _data.rank_list;
this.freshData( lst );
},
// 切换
onTogMenu: function( _index ) {
this.activeMenu( parseInt( _index ) + 1 );
},
freshData: function( _data ){
nx.gui.setActive( this.nodLst, "empty", nx.dt.arrEmpty( _data ) );
this.nodLst.rebuild( _data );
},
freshOneWorship: function( _data ){
let chd = nx.gui.find( this.nodLst, "scv/view/content" ).children;
for (let i = 0; i < chd.length; i++) {
let item = chd[i];
let cmp = item.svItem;
if( cmp ){
if( cmp.mdata && cmp.mdata.rid == _data.rid ){
let data = nx.dt.objClone( cmp.mdata );
data.worship = cmp.mdata.worship + 1;
data.worship_status = cmp.mdata.worship_status + 1;
cmp.rebind( i, data );
}
}
}
},
freshInfo: function(){
// 设置相关的 底部显示信息
nx.gui.setActive( this.nodLst, "self_rank/item", this.curType == 2 );
nx.gui.setActive( this.nodLst, cc.js.formatStr("self_rank/item%s",this.rank_type), false );
nx.gui.setActive( this.nodLst,"nod_rank", false );
// 设置顶部 标题
nx.gui.setActive( this.nodLst, "empty", this.curType == 1 );
// 设置顶部 标题
let nod = nx.gui.find( this.nodLst, "title" );
nx.gui.setActive( nod,"nod_rank", false );
nx.gui.setActive( nod,"nod_reward/award", this.curType == 2 );
nx.gui.setActive( nod,"nod_reward", this.curType == 2 );
nx.gui.setActive( nod,"nod_rank/star", this.rank_type == 42);//遺跡探索顯示星星數量
nx.gui.setActive( nod,"nod_rank/score", this.rank_type == 40);//陣營秘境通關數
},
// 重载:关闭前
onPreClosed: function () {
},
});