113 lines
2.7 KiB
JavaScript
113 lines
2.7 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '7811dh9y4ROFLaVas36ZPI6', 'cmp.login.start');
|
|
// Scripts/mod/login/cmp/cmp.login.start.js
|
|
|
|
"use strict";
|
|
|
|
var BridgeComponent = require("bridge.component");
|
|
var xButton = require("nx.fx.button");
|
|
var LoginMod = require("login.mod");
|
|
var WndLogin = require("scene.login");
|
|
cc.Class({
|
|
"extends": BridgeComponent,
|
|
properties: {
|
|
wndLogin: {
|
|
"default": null,
|
|
type: WndLogin
|
|
},
|
|
panInfo: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
btnStart: {
|
|
"default": null,
|
|
type: xButton
|
|
}
|
|
},
|
|
// 载入
|
|
onLoad: function onLoad() {
|
|
this._super();
|
|
|
|
// 视图监听
|
|
this.vbind([["curServer", this.updateCurServer.bind(this)]]);
|
|
},
|
|
// 销毁
|
|
onDestroy: function onDestroy() {
|
|
if (this.updateHandler) {
|
|
gcore.GlobalEvent.unbind(this.updateHandler);
|
|
this.updateHandler = null;
|
|
}
|
|
if (this.fast_start_event) {
|
|
gcore.GlobalEvent.unbind(this.fast_start_event);
|
|
this.fast_start_event = null;
|
|
}
|
|
this._super();
|
|
},
|
|
// 更新当前服务器
|
|
updateCurServer: function updateCurServer(_info) {
|
|
// 无效服务器
|
|
var node = nx.gui.find(this.panInfo, "server");
|
|
if (nx.dt.objEmpty(_info)) {
|
|
nx.gui.setString(node, "name", "");
|
|
nx.gui.setSpriteFrame(node, "state", null);
|
|
this.btnStart.lock(true);
|
|
return;
|
|
}
|
|
|
|
// 服务器名
|
|
var sname = nx.text.format("Zoom", _info.zone_id) + nx.text.getKey(_info.srv_name);
|
|
nx.gui.setString(node, "name", sname);
|
|
|
|
// 状态展示
|
|
var st = "state_2";
|
|
if (!_info.is_close) {
|
|
st = _info.is_new ? "state_0" : "state_1";
|
|
}
|
|
var icon = cc.path.join("prefab/login/images", st);
|
|
nx.gui.setSpriteFrame(node, "state", icon);
|
|
|
|
// 服务器关闭中
|
|
if (_info.is_close) {
|
|
this.btnStart.lock(true);
|
|
return;
|
|
}
|
|
this.btnStart.lock(false);
|
|
nx.tween.breatheForever(this.btnStart, "on", 5, 0.05);
|
|
},
|
|
// 账号
|
|
openAccount: function openAccount() {
|
|
this.wndLogin.changeSubPanel(1, {
|
|
swap: true
|
|
});
|
|
},
|
|
// 开始游戏
|
|
startGame: function startGame() {
|
|
var _this = this;
|
|
this.btnStart.lock(true);
|
|
LoginMod.getInstance().autoEnter(function (_ret, _data, _code) {
|
|
_this.btnStart.lock(false);
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
});
|
|
},
|
|
// 选区
|
|
switchServer: function switchServer() {
|
|
var _this2 = this;
|
|
// 空
|
|
var svrs = nx.bridge.vget("allServers");
|
|
if (nx.dt.objEmpty(svrs)) {
|
|
nx.tbox(nx.text.getKey("tip_loadServer"));
|
|
return;
|
|
}
|
|
this.panInfo.active = false;
|
|
nx.bridge.createPanel("WndServerList", {
|
|
cb: function cb() {
|
|
_this2.panInfo.active = true;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |