e01b2ad0-0f6b-4985-b2f4-4241d95712a6.js 4.1 KB
"use strict";
cc._RF.push(module, 'e01b2rQD2tJhbL0QkHZVxKm', 'UrgentNoticeViewPresenter');
// script/game/ui/presenter/notice/UrgentNoticeViewPresenter.ts

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const PresenterBase_1 = require("../../../../common/classbase/PresenterBase");
const GameModelManager_1 = require("../../../model/GameModelManager");
const PresenterCCViewFactory_1 = require("../../PresenterCCViewFactory");
const UrgentNoticeView_1 = require("../../view/type/notice/UrgentNoticeView");
let UrgentNoticeViewPresenter = /** @class */ (() => {
    let UrgentNoticeViewPresenter = class UrgentNoticeViewPresenter extends PresenterBase_1.Presenter {
        constructor() {
            super();
            this._delayTime = 0;
            this._closeTimeTicker = -1;
            this._canClose = false;
            /**关闭界面按钮的点击事件 */
            this.onCloseButtonClickCalback = () => {
                if (this._canClose) {
                    this.checkTipsToggleState();
                    clearTimeout(this._closeTimeTicker);
                    this.view.close();
                }
            };
            this._viewProps = {
                onCloseButtonClickCalback: this.onCloseButtonClickCalback,
            };
        }
        onOpen() {
            super.onOpen(undefined);
            this.view.setProps(this._viewProps);
            this.onShow();
        }
        onShow() {
            super.onShow();
            this.initView();
        }
        onEnterBackground() {
            super.onEnterBackground();
        }
        onEnterForeground() {
            super.onEnterForeground();
        }
        onClose() {
            super.onClose();
        }
        initView() {
            //重置可关闭状态为false
            this._canClose = false;
            //根据是否是第一次弹起紧急公告判断延迟时间
            this._delayTime = GameModelManager_1.GameModelManager.getUrgentNoticeInfo().readed ? 0 : 3;
            //重置提示文本状态
            this.view.getCloseTipsLabel().string = "";
            //根据存档初始化“今日不再提示”的选择框
            let autoShow = GameModelManager_1.GameModelManager.getUrgentNoticeInfo().autoShow;
            this.view.getTipsToggle().isChecked = !autoShow;
            this.startTimeTicker();
        }
        /**
         * 开启可关闭定时器
         */
        startTimeTicker() {
            if (this._delayTime == 0) {
                this._canClose = true;
                this.view.getCloseTipsLabel().string = "点击空白区域可关闭";
            }
            else {
                this.view.getCloseTipsLabel().string = this._delayTime + "秒后可关闭";
                this._closeTimeTicker = window.setTimeout(() => {
                    this._delayTime -= 1;
                    this.startTimeTicker();
                }, 1000);
            }
        }
        /**
         * 检查“今日不再提示”单选框的选择状态
         */
        checkTipsToggleState() {
            let isChecked = this.view.getTipsToggle().isChecked;
            GameModelManager_1.GameModelManager.setUrgentNoticeInfo({ readed: true, autoShow: !isChecked });
        }
    };
    UrgentNoticeViewPresenter.uuid = "UrgentNoticeViewPresenter";
    UrgentNoticeViewPresenter = __decorate([
        PresenterCCViewFactory_1.RegPresenter(UrgentNoticeView_1.UrgentNoticeViewType)
    ], UrgentNoticeViewPresenter);
    return UrgentNoticeViewPresenter;
})();
exports.default = UrgentNoticeViewPresenter;

cc._RF.pop();