77 lines
2.1 KiB
JavaScript
77 lines
2.1 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'c639dG2Jn1K25lE+m4J9YaG', 'cmp.campfight.award.rank');
|
|
// Scripts/mod/pvp/campfight/cmp/cmp.campfight.award.rank.js
|
|
|
|
"use strict";
|
|
|
|
var CampfightConst = require("campfight.const");
|
|
var CampfightMod = require("campfight.mod");
|
|
var BridgeWindow = require("bridge.window");
|
|
var NxExpand = require("nx.fx.sv.expand");
|
|
var RCT = require("role_controller");
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
svcList: {
|
|
"default": null,
|
|
type: NxExpand
|
|
},
|
|
selfRank: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
fabHead: {
|
|
"default": null,
|
|
type: cc.Prefab
|
|
},
|
|
myHead: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// LIFE-CYCLE CALLBACKS:
|
|
onLoad: function onLoad() {
|
|
this.mod = CampfightMod.getInstance();
|
|
this.bindGEvent(CampfightConst.EVT_CAMP_UPDATE_RANK, this.freshRanks.bind(this));
|
|
},
|
|
freshRanks: function freshRanks(data) {
|
|
if (nx.dt.objEmpty(data)) return;
|
|
this.svcList.rebuild(data.rank_list);
|
|
var myRole = RCT.getInstance().getRoleVo();
|
|
if (!this.Head) {
|
|
this.Head = cc.instantiate(this.fabHead);
|
|
this.Head.parent = this.myHead;
|
|
}
|
|
nx.gui.setString(this.selfRank, "name", myRole.name);
|
|
var cmp = nx.gui.getComponent(this.Head, "", "cmp.common.header");
|
|
if (cmp) {
|
|
cmp.setData(myRole);
|
|
}
|
|
var rank_data = null;
|
|
for (var i in data.rank_list) {
|
|
var info = data.rank_list[i];
|
|
if (info && info.rid == myRole.rid && info.srv_id == myRole.srv_id) {
|
|
rank_data = info;
|
|
}
|
|
}
|
|
if (rank_data) {
|
|
if (rank_data.rank <= 3) {
|
|
nx.gui.setActive(this.selfRank, String(rank_data.rank), true);
|
|
} else {
|
|
nx.gui.setActive(this.selfRank, "rank", true);
|
|
nx.gui.setString(this.selfRank, "rank", rank_data.rank);
|
|
}
|
|
} else {
|
|
nx.gui.setActive(this.selfRank, "rank", true);
|
|
nx.gui.setString(this.selfRank, "rank", nx.text.getKey("Rank0"));
|
|
}
|
|
},
|
|
onOpenConfigs: function onOpenConfigs() {
|
|
this.mod.reqOldRank();
|
|
},
|
|
onPreClosed: function onPreClosed() {
|
|
this.svcList.rebuild([]);
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |