e01b2ad0-0f6b-4985-b2f4-4241d95712a6.js
4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"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();