372 lines
13 KiB
JavaScript
372 lines
13 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 LadderEvent = require( "ladder_event" );
|
|
const RoleController = require("role_controller");
|
|
const defaultList = 3;
|
|
|
|
// 标签页对应关系
|
|
const TabPage = [
|
|
{ key: "RankNow", goto: 0 },
|
|
{ key: "DailyAwards" || "RankAwards", goto: 1 },
|
|
{ key: "SeasonAwards", goto: 2 },
|
|
];
|
|
|
|
|
|
cc.Class({
|
|
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
|
|
nodOps : { default:null, type: cc.Node },
|
|
nodToggle: { default:null, type: FxTogs },
|
|
nodLst: { default:null, type: FxSVC },
|
|
fabSelfAward : { default: null, type: cc.Prefab },
|
|
fabSelfArena : { default: null, type: cc.Prefab },
|
|
fabSelfLadder : { default: null, type: cc.Prefab },
|
|
fabSelfWeekChampion : { default: null, type: cc.Prefab },
|
|
fabItemArena : { default: null, type: cc.Prefab },
|
|
fabItemAward : { default: null, type: cc.Prefab },
|
|
fabItemLadder : { default: null, type: cc.Prefab },
|
|
fabItemFirst : { default: null, type: cc.Prefab },
|
|
fabItemWeekChampion : { default: null, type: cc.Prefab },
|
|
|
|
},
|
|
|
|
onLoad: function () {
|
|
|
|
this.bindGEvent( ArenaEvent.UpdateLoopChallengeRank,this.freshOtherUI.bind(this) );
|
|
this.bindGEvent( RoleEvent.WorshipOtherRole, this.freshOneWorship.bind(this) );
|
|
this.bindGEvent( LadderEvent.UpdateLadderRankData, this.freshLadderUI.bind( this ) );
|
|
this.bindGEvent( ArenaEvent.UpdateChampionRankEvent, this.freshWeeklyChampionUI.bind( this ) );
|
|
// Tog监听
|
|
this.nodToggle.posTog = this.onTogMenu.bind( this );
|
|
this.loadPrefab();
|
|
|
|
},
|
|
|
|
loadPrefab : function(){
|
|
|
|
if( nx.gui.find( this.nodLst, "self_rank" ).children.length == 0 ){
|
|
let itemnod = cc.instantiate( this.fabSelfAward );
|
|
itemnod.parent = nx.gui.find( this.nodLst, "self_rank" );
|
|
|
|
let item5nod = cc.instantiate( this.fabSelfArena );
|
|
item5nod.parent = nx.gui.find( this.nodLst, "self_rank" );
|
|
|
|
let itemlnod = cc.instantiate( this.fabSelfLadder );
|
|
itemlnod.parent = nx.gui.find( this.nodLst, "self_rank" );
|
|
|
|
let fabSelfWeekChampion = cc.instantiate( this.fabSelfWeekChampion );
|
|
fabSelfWeekChampion.parent = nx.gui.find( this.nodLst, "self_rank" );
|
|
|
|
nx.gui.hideAllChildren( this.nodLst, "self_rank" );
|
|
|
|
}
|
|
|
|
if( nx.gui.find( this, "templates" ).children.length == 0 ){
|
|
let fabItemArena = cc.instantiate( this.fabItemArena );
|
|
fabItemArena.parent = nx.gui.find( this, "templates" );
|
|
|
|
let fabItemAward = cc.instantiate( this.fabItemAward );
|
|
fabItemAward.parent = nx.gui.find( this, "templates" );
|
|
|
|
let fabItemLadder = cc.instantiate( this.fabItemLadder );
|
|
fabItemLadder.parent = nx.gui.find( this, "templates" );
|
|
|
|
let itemfnod = cc.instantiate( this.fabItemFirst );
|
|
itemfnod.parent = nx.gui.find( this, "templates" );
|
|
|
|
let fabItemWeekChampion = cc.instantiate( this.fabItemWeekChampion );
|
|
fabItemWeekChampion.parent = nx.gui.find( this, "templates" );
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
onOpenConfigs( _params ) {
|
|
|
|
this.dfg = _params.dfg;
|
|
this.sfg = _params.sfg;
|
|
this.cb = _params.cb;
|
|
this.show = _params.show;
|
|
let ops = _params.ops;
|
|
let chd = this.nodOps.children;
|
|
this.defaultDesc = _params.desc;
|
|
|
|
let len = _params.len ? _params.len : defaultList;
|
|
nx.gui.gocChildren( this.nodOps, "", len );
|
|
|
|
let tcmp = nx.gui.getComponent( this.nodOps, "", "nx.fx.togs" );
|
|
if( tcmp ){
|
|
// 重建标签结构
|
|
tcmp.rebuildTogs();
|
|
|
|
// 标签显示切换
|
|
tcmp._freshTogShow();
|
|
}
|
|
let goto = 0;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let op = ops[i];
|
|
if( !op || nx.dt.strEmpty( op ) ){
|
|
nx.gui.setActive( chd[i], "", false );
|
|
continue;
|
|
}
|
|
|
|
if( this.show == op ){
|
|
goto = i;
|
|
}
|
|
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 ) );
|
|
|
|
}
|
|
|
|
// TabPage.forEach( _tab => {
|
|
// if( this.show == _tab.key ){
|
|
// goto = _tab.goto;
|
|
// }
|
|
// } )
|
|
|
|
this.nodToggle.togTo( goto );
|
|
this.activeMenu( goto + 1 );
|
|
// this.freshData();
|
|
|
|
|
|
},
|
|
|
|
// 激活菜单
|
|
activeMenu: function( _bagCode ) {
|
|
|
|
// console.log( "背包切换:", _bagCode );
|
|
if( this.curType == _bagCode ) {
|
|
return;
|
|
}
|
|
this.curType = _bagCode;
|
|
if( _bagCode == 1 ){
|
|
this.freshInfo();
|
|
let T = nx.gui.find( this.node, "templates/itemT5" );
|
|
this.nodLst.tmpItem = T;
|
|
this.nodLst.rebuild( [] );
|
|
|
|
this.nodLst.tmpItem = null;
|
|
|
|
nx.dt.fnInvoke( this.cb );
|
|
}
|
|
if( _bagCode == 2 ){
|
|
let T = nx.gui.find( this.node, "templates/award" );
|
|
// widget.bottom = 20.70;
|
|
// widget.updateAlignment();
|
|
this.nodLst.tmpItem = T;
|
|
|
|
this.freshData( this.dfg );
|
|
this.freshInfo();
|
|
}
|
|
if( _bagCode == 3 ){
|
|
let T = nx.gui.find( this.node, "templates/award" );
|
|
// widget.bottom = 20.70;
|
|
// widget.updateAlignment();
|
|
this.nodLst.tmpItem = T;
|
|
this.freshData( this.sfg );
|
|
this.freshInfo();
|
|
}
|
|
if( _bagCode == 4 ){
|
|
let T = nx.gui.find( this.node, "templates/faward" );
|
|
// widget.bottom = 20.70;
|
|
// widget.updateAlignment();
|
|
this.nodLst.tmpItem = T;
|
|
this.freshData( this.dfg );
|
|
this.freshInfo();
|
|
}
|
|
if( _bagCode == 5 ){
|
|
let T = nx.gui.find( this.node, "templates/faward" );
|
|
// widget.bottom = 20.70;
|
|
// widget.updateAlignment();
|
|
this.nodLst.tmpItem = T;
|
|
this.freshData( this.sfg );
|
|
this.freshInfo();
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
dealSameCmp : function( _nod, _data, _desc ){
|
|
|
|
let tnod = nx.gui.find( this.nodLst, "title" );
|
|
nx.gui.setString( tnod,"nod_rank/score", _desc );
|
|
let rank_node = _nod;
|
|
nx.gui.setActive( rank_node, "icon_" + _data.rank, _data.rank > 0 && _data.rank < 4 );
|
|
nx.gui.setActive( rank_node, "icon_4" , _data.rank >= 4 );
|
|
if( _data.rank >= 4 ){
|
|
nx.gui.setString( rank_node, "txt" , _data.rank );
|
|
}
|
|
if( _data.rank == 0 ){
|
|
nx.gui.setString( rank_node, "txt2" , nx.text.getKey( "Rank0" ));
|
|
}
|
|
|
|
nx.gui.setActive( tnod,"nod_rank", true );
|
|
|
|
},
|
|
|
|
freshOtherUI: function ( _data ){
|
|
|
|
// 设置顶部 标题
|
|
|
|
let T = nx.gui.find( this.node, "templates/itemT5" );
|
|
let nod = nx.gui.find( this.nodLst, "self_rank" );
|
|
let rank_node = nx.gui.find( nod, "item5/rank" );
|
|
// _data.rank > 0 ? _data.rank < 4 ? nx.gui.setActive( rank_node, "icon_" + _data.rank, true ) : nx.gui.setActive( rank_node, "icon_4" , true ) :
|
|
// nx.gui.setString( rank_node, "txt2", nx.text.getKey( "Rank0" ) );
|
|
this.dealSameCmp( rank_node, _data, nx.text.getKey( "ArenaScore" ));
|
|
|
|
nx.gui.setString( nod, "item5/info/score/txt", _data.score );
|
|
nx.gui.setString( nod, "item5/info/power", _data.worship );
|
|
this.nodLst.tmpItem = T;
|
|
|
|
let lst = _data.rank_list;
|
|
this.freshData( lst );
|
|
|
|
},
|
|
|
|
freshLadderUI: function( _data ){
|
|
|
|
let T = nx.gui.find( this.node, "templates/itemTl" );
|
|
let nod = nx.gui.find( this.nodLst, "self_rank" );
|
|
let rank_node = nx.gui.find( nod, "iteml/rank" );
|
|
|
|
this.dealSameCmp( rank_node, _data, nx.text.getKey( "lab_rank_name_6" ) );
|
|
let role = RoleController.getInstance().getRoleVo();
|
|
nx.gui.setString( nod, "iteml/info/power", role.power );
|
|
nx.gui.setString( nod, "iteml/name", role.name );
|
|
nx.gui.setActive( this.nodLst, "self_rank/iteml", true );
|
|
this.nodLst.tmpItem = T;
|
|
|
|
let lst = _data.rank_list;
|
|
this.freshData( lst );
|
|
|
|
},
|
|
|
|
freshWeeklyChampionUI: function( _data ){
|
|
|
|
let T = nx.gui.find( this.node, "templates/itemTc" );
|
|
let nod = nx.gui.find( this.nodLst, "self_rank" );
|
|
let rank_node = nx.gui.find( nod, "itemc/rank" );
|
|
|
|
this.dealSameCmp( rank_node, _data, nx.text.getKey( "lab_rank_name_6" ) );
|
|
let role = RoleController.getInstance().getRoleVo();
|
|
nx.gui.setString( nod, "itemc/info/power/power", _data.power );
|
|
nx.gui.setString( nod, "itemc/info/score", _data.score );
|
|
nx.gui.setString( nod, "itemc/name", role.name );
|
|
nx.gui.setString( nod, "itemc/info/worship/num", _data.worship );
|
|
nx.gui.setActive( this.nodLst, "self_rank/itemc", true );
|
|
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;
|
|
// {"code":1,"msg":"","type":0,"rid":79,"srv_id":"dev_2","idx":7}
|
|
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 = !nx.dt.strEmpty( cmp.mdata.srv_id ) && cmp.mdata.srv_id != "robot" ? cmp.mdata.worship + 1 : cmp.mdata.worship ;
|
|
data.worship_status = cmp.mdata.worship_status + 1;
|
|
cmp.rebind( i, data );
|
|
}
|
|
}
|
|
}
|
|
|
|
},
|
|
|
|
freshInfo: function(){
|
|
|
|
// 设置相关的 底部显示信息
|
|
let nods = nx.gui.find( this.nodLst, "self_rank/item" );
|
|
let dfg = game.configs.arena_data.data_const.daily_reward_time;
|
|
let desc = "";
|
|
if( !this.defaultDesc ){
|
|
desc = this.curType == 2 ? dfg.desc : "";
|
|
}else{
|
|
desc = this.defaultDesc;
|
|
}
|
|
|
|
let model = ArenaController.getInstance().getModel();
|
|
let self_data = model.getMyLoopData();
|
|
|
|
nx.gui.setActive( this.nodLst, "self_rank/item/time", this.curType == 3 );
|
|
|
|
nx.gui.setActive( this.nodLst, "self_rank/item5", this.curType == 1 );
|
|
|
|
|
|
nx.gui.setString( nods, "desc", desc );
|
|
nx.gui.setString( nods, "time/txt", desc );
|
|
nx.gui.setActive( this.nodLst, "self_rank/item", this.curType == 2 || this.curType == 3 );
|
|
nx.gui.setActive( this.nodLst, "self_rank/iteml", false );
|
|
|
|
nx.gui.setActive( this.nodLst,"nod_rank", false );
|
|
// 设置顶部 标题
|
|
nx.gui.setActive( this.nodLst, "empty", this.curType == 1 );
|
|
nx.gui.setActive( this.nodLst, "self_rank/itemc", false );
|
|
|
|
// 设置顶部 标题
|
|
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/award_s", this.curType == 3 );
|
|
nx.gui.setActive( nod,"nod_reward", this.curType == 2 || this.curType == 3 );
|
|
|
|
nx.gui.setCdTxt( nods, "time/txt", ( self_data.end_time - Math.floor( cc.sys.now() / 1000 ) ), ()=>{
|
|
|
|
} );
|
|
// nx.gui.setActive( this.nodLst, "self_rank", _bagCode == 1 );
|
|
|
|
},
|
|
|
|
// 重载:关闭前
|
|
onPreClosed: function () {
|
|
|
|
let nod = nx.gui.find( this.nodLst, "self_rank" );
|
|
let tnod = nx.gui.find( this, "templates" );
|
|
for (let i = 0; i < nod.children.length; i++) {
|
|
let cnod = nod.children[i];
|
|
let ttnod = tnod.children[i];
|
|
if( cnod ){
|
|
cnod.destroy();
|
|
}
|
|
if( ttnod ){
|
|
ttnod.destroy();
|
|
}
|
|
}
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
});
|