123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- // '所有更新事件处理类',
- cc.Class({
- extends: cc.Component,
- properties: {
- updateAlert: cc.Node,
- updateAwardAlert: cc.Node,
- updateBannerAlert: cc.Node,
- updateAwardBannerAlert: cc.Node,
- hotupdateProgressNode: cc.Node,
- hotupdateAlertNode: cc.Node,
- curUpdateAlert: cc.Node,
- curHotUpdateAlert: cc.Node
- },
- onLoad () {
- if (!G.UpdateCtrl) {
- G.UpdateCtrl = cc.game.addPersistRootNode(this.node);
- }
- this._updateCtr = this.getComponent('UpdateCtrl');
- this._bgMask = this.node.getChildByName('bgMask');
- this._bgUpdateProgressNode = this.node.getChildByName('bgUpdateProgress');
- this._bgUpdateProgress = this._bgUpdateProgressNode.getComponent('BgUpdateProgress');
- let y = cc.winSize.height / 2;
- let x = cc.winSize.width / 2;
- let newVec2 = this.node.convertToNodeSpaceAR(cc.v2(x, y));
- this._bgMask.y = newVec2.y;
- this._bgMask.x = newVec2.x;
- this._bgMask.width = cc.winSize.width;
- this._bgMask.height = cc.winSize.height;
- cc.game.on('e_launch_touch_update_node', this.handleTouch, this);
- cc.game.on('e_app_update_show_alert', this.handleShowAppUpdateAlert, this);
- cc.game.on('e_launch_update_show_alert', this.handleShowUpdateAlert, this);
- cc.game.on('e_launch_update_show_progress', this.handleShowUpdateProgress, this);
- cc.game.on('e_launch_hot_update_show_alert', this.handleShowHotUpdateAlert, this);
- },
- showCurUpdateAlert () {
- let remoteUpdateInfo = G.RemoteUpdateInfoMgr.remoteUpdateInfo;
- // 有无更新奖励判断
- this.haveAward = remoteUpdateInfo.newAppAward == '' ? false : true;
- // 有无banner判断
- this.haveBanner = remoteUpdateInfo.newAppBanner == '' ? false : true;
- // 是否强制更新判断
- this.isForceUpdate = remoteUpdateInfo.newAppForce == 0 ? false : true;
- // 是否静默更新判断
- this.isSilentUpdate = remoteUpdateInfo.newAppSilence == 0 ? false : true;
- let updateCtr = this;
- let updateType = 0;
- // 显示 无奖励 无banner 布局
- if (this.haveAward == false && this.haveBanner == false) {
- updateType = 1;
- }
- // 显示 有奖励 无banner 布局
- if (this.haveAward == true && this.haveBanner == false) {
- updateType = 2;
- }
- // 显示 无奖励 有banner 布局
- if (this.haveAward == false && this.haveBanner == true) {
- updateType = 3;
- }
- // 显示 有奖励 有banner 布局
- if (this.haveAward == true && this.haveBanner == true) {
- updateType = 4;
- }
- this.updateAlert.active = false;
- this.updateAwardAlert.active = false;
- this.updateBannerAlert.active = false;
- this.updateAwardBannerAlert.active = false;
- // 为了静默下载也获得bgUpdateProgress当前依赖弹窗
- switch (updateType) {
- case 1:
- updateCtr.curUpdateAlert = this.updateAlert;
- break;
- case 2:
- updateCtr.curUpdateAlert = this.updateAwardAlert;
- break;
- case 3:
- updateCtr.curUpdateAlert = this.updateBannerAlert;
- break;
- case 4:
- updateCtr.curUpdateAlert = this.updateAwardBannerAlert;
- break;
- default:
- break;
- }
- if (updateCtr.curUpdateAlert !== null) {
- updateCtr.curUpdateAlert.active = true;
- this._bgMask.active = true;
- }
- },
- updateProgress (isShow) {
- this._bgUpdateProgressNode.active = isShow;
- if (isShow)
- this._bgUpdateProgressNode.opacity = 255;
- },
- // 点击顶部更新按钮处理
- handleTouch () {
- this.updateProgress(false);
- if (this.curHotUpdateAlert !== null) {
- this._bgMask.active = true;
- this.curHotUpdateAlert.active = true;
- return;
- }
- if (this.curUpdateAlert !== null) {
- this._bgMask.active = true;
- this.curUpdateAlert.active = true;
- return;
- }
- },
- handleShowUpdateAlert () {
- if (this.curUpdateAlert) {
- this.curUpdateAlert.active = true;
- this._bgMask.active = true;
- return;
- } else {
- this.updateProgress(false);
- if (this.curHotUpdateAlert) {
- this.curHotUpdateAlert.active = false;
- } else {
- this.showCurUpdateAlert();
- }
- }
- },
- handleShowAppUpdateAlert () {
- if (this.curUpdateAlert) {
- this.curUpdateAlert.active = false;
- this.curUpdateAlert = null;
- }
- G.RemoteUpdateInfoMgr.remoteUpdateInfo.newAppSilence = 1;
- this.updateProgress(false);
- this.showCurUpdateAlert();
- },
- handleShowUpdateProgress () {
- this.updateProgress(true);
- this._bgMask.active = false;
- },
- handleShowHotUpdateAlert () {
- this.curHotUpdateAlert = this.hotupdateAlertNode;
- this.hotupdateAlertNode.active = true;
- this._bgMask.active = true;
- }
- });
|