09017250-b1a4-4eb8-af03-3e292018a356.js
13.8 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
"use strict";
cc._RF.push(module, '09017JQsaROuK8DPikgGKNW', 'PhoneCallViewImpl');
// script/game/ui/view/impl/PhoneCallViewImpl.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 });
exports.PhoneCallViewImpl = void 0;
const CCViewBase_1 = require("../../../../common/classbase/CCViewBase");
const PhoneCallView_1 = require("../type/PhoneCallView");
const PresenterCCViewFactory_1 = require("../../PresenterCCViewFactory");
const CCDummyObjects_1 = require("../../../../common/CCDummyObjects");
const AVG_1 = require("../../../../avg/AVG");
const simba_cc_resutils_1 = require("simba-cc-resutils");
const simba_cc_audio_manager_1 = require("simba-cc-audio-manager");
const GameTextData_1 = require("../../../../common/gameplay/gamedata/GameTextData");
const GameModelManager_1 = require("../../../model/GameModelManager");
const Typewriter_1 = require("../../../../common/components/Typewriter");
const { ccclass, property } = cc._decorator;
let PhoneCallViewImpl = /** @class */ (() => {
let PhoneCallViewImpl = class PhoneCallViewImpl extends CCViewBase_1.CCPureView {
constructor() {
super(...arguments);
//#region editor bindings
this.scrollView = CCDummyObjects_1.DummyScrollView;
this.contentLayout = CCDummyObjects_1.DummyLayout;
this.callingNode = CCDummyObjects_1.DummyNode;
this.messageNode = CCDummyObjects_1.DummyNode;
this.nameLabel1 = CCDummyObjects_1.DummyLabel;
this.nameLabel2 = CCDummyObjects_1.DummyLabel;
this.headIcon1 = CCDummyObjects_1.DummySprite;
this.headIcon2 = CCDummyObjects_1.DummySprite;
this.rejectTipNode = CCDummyObjects_1.DummyNode;
this.nextPlotNode = CCDummyObjects_1.DummyNode;
this.statusLabel = CCDummyObjects_1.DummyLabel;
this.typewriter = undefined;
this._isPlayMusic = false;
this._excuting = false;
this.playPhoneMusic = async () => {
const PhoneBgmCallSound = "/audio/bgm/iPhoneXSCallSound";
await simba_cc_audio_manager_1.AudioManager.playMusic(PhoneBgmCallSound);
};
this.stopPhoneMusic = () => {
simba_cc_audio_manager_1.AudioManager.stopMusic();
};
//#endregion
this._newCall = true;
}
onRejectCall() {
this.node.children[1].active = true;
this.rejectTipNode.runAction(cc.sequence(cc.fadeIn(0.3), cc.delayTime(0.3), cc.callFunc(() => {
this.rejectTipNode.opacity = 0;
this.node.children[0].opacity = 0;
this.stopPhoneMusic();
this._isPlayMusic = false;
this.scheduleOnce(async () => {
this.node.children[0].opacity = 255;
this.node.children[1].active = false;
await this.playPhoneMusic();
this._isPlayMusic = true;
}, 0.8);
})));
// GameDotMgr.getInstance().dotClickUI("click_phone_reject");
}
onAcceptCall() {
this.callingNode.active = false;
this.messageNode.active = true;
this.stopPhoneMusic();
this._isPlayMusic = false;
GameModelManager_1.GameModelManager.dotMainLinePlotStart();
if (PhoneCallView_1.PhoneCallListAutoNextPlot) {
this.scheduleOnce(() => {
this._props.onCompletePlot();
}, 0.6);
}
}
onNextPlotBtnClick() {
if (this.typewriter.getShowingString() == "") {
if (!PhoneCallView_1.PhoneCallListAutoNextPlot) {
if (!this._excuting) {
this._excuting = true;
GameModelManager_1.GameModelManager.dotPlotProgress();
this._props.onCompletePlot(this._selectIndex);
this._selectIndex = undefined;
this.scheduleOnce(() => {
this._excuting = false;
}, 0.3);
}
}
}
else {
this.typewriter.stopTyperShowString();
}
}
applicationChange(force) {
}
onLoad() {
this.bindProp("name", this.nameLabel1, "string");
this.bindProp("name", this.nameLabel2, "string");
this.bindProp("icon", async (v) => {
if (v) {
let sf = await simba_cc_resutils_1.ResUtils.loadRes(v, cc.SpriteFrame, 2);
// if (v === this._props.icon) { // 理论上这里没必要
this.headIcon1.spriteFrame = sf;
this.headIcon2.spriteFrame = sf;
// }
}
});
// this.bindProp("select", (value) => {
// if (value >= 0) {
// let item = this._props.items[this._props.items.length - 1];
// item.select = value;
// this.processItem(item);
// }
// });
}
select(value) {
if (value >= 0) {
let item = this._props.items[this._props.items.length - 1];
item.select = value;
this.processItem(item);
}
}
scrollToTop() {
this.scrollView.scrollToTop();
}
scrollToBottom(animate = true) {
if (this.contentLayout.node.height > this.scrollView.node.height) {
this.scrollView.scrollToBottom(animate ? 0.3 : undefined);
}
}
async open(parent) {
super.open(parent);
this.node.children[0].opacity = 0;
this.node.children[1].active = true;
this.callingNode.active = true;
this.messageNode.active = false;
this.stopPhoneMusic();
this._isPlayMusic = false;
await this.playPhoneMusic();
this._isPlayMusic = true;
this.node.children[0].runAction(cc.sequence(cc.delayTime(0.2), cc.fadeIn(0.1), cc.callFunc(() => {
this.node.children[0].opacity = 255;
this.node.children[1].active = false;
})));
this.updateCallingStatusLabel(GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_CALLING_VALUE));
}
close(clean) {
this.nextPlotNode.active = false;
this.updateCallingStatusLabel(GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_CALLENDED_VALUE));
this.node.stopAllActions();
this.node.runAction(cc.sequence(cc.delayTime(1.2), cc.callFunc(() => {
super.close(clean);
// 清除内容,防止下次打开的时候先显示上次的内容
this.contentLayout.node.removeAllChildren();
this.headIcon1.spriteFrame = undefined;
this.nameLabel1.string = "";
if (this.node.active && this._isPlayMusic) {
this.stopPhoneMusic();
this._isPlayMusic = false;
}
delete this._props;
GameModelManager_1.GameModelManager.CheckMainTabGuide.emit();
})));
}
onPropsLoad(props) {
super.onPropsLoad(props);
for (let item of this._props.items) { // 应该只有一条
this.processItem(item);
}
}
onPropChange(propName) {
super.onPropChange(propName);
if (propName === "items") {
for (let i = this.contentLayout.node.children.length; i < this._props.items.length; i++) {
this.processItem(this._props.items[i]);
}
}
}
async processItem(item) {
let content = item.sentence.content;
if (item.isSelf && content.type === AVG_1.SentenceType.SELECT && item.select === undefined) { // show selector
this._props.onSetContent(content);
this.nextPlotNode.active = false;
}
else {
this.nextPlotNode.active = true;
if (content.type === AVG_1.SentenceType.SELECT && item.select === undefined) {
console.error("Something went wrong. ", item.sentence);
return;
}
let node = new cc.Node;
let richLabel = node.addComponent(cc.RichText);
richLabel.fontSize = 32;
richLabel.maxWidth = 585;
if (item.isSelf) {
node.anchorX = 1;
node.x = 300;
node.color = cc.color(44, 50, 98);
richLabel.horizontalAlign = cc.macro.TextAlignment.RIGHT;
}
else {
node.anchorX = 0;
node.x = -300;
richLabel.horizontalAlign = cc.macro.TextAlignment.LEFT;
}
let text = "";
if (content.type === AVG_1.SentenceType.SELECT) {
let option = content.value[item.select];
if (option.content) {
if (option.content.type === AVG_1.SentenceType.TEXT) {
// richLabel.string = richNodesToCocosString(option.content.value);
text = AVG_1.richNodesToCocosString(option.content.value);
}
else {
// richLabel.string = `SentenceType(${option.content.type}) not supported in phone call.`;
text = `SentenceType(${option.content.type}) not supported in phone call.`;
}
}
else {
// richLabel.string = option.summary;
text = option.summary;
}
}
else if (content.type === AVG_1.SentenceType.TEXT) {
// richLabel.string = richNodesToCocosString(content.value);
text = AVG_1.richNodesToCocosString(content.value);
}
else {
// richLabel.string = `SentenceType(${content.type}) not supported in phone call.`;
text = `SentenceType(${content.type}) not supported in phone call.`;
}
if (item.isSelf) {
richLabel.string = text;
}
else {
this.typewriter.showRichTextTyper(richLabel, text, () => {
this.contentLayout.updateLayout();
this.scrollToBottom();
}, () => {
this.contentLayout.updateLayout();
this.scrollToBottom();
});
}
node.parent = this.contentLayout.node;
}
if (item.sentence && item.sentence.actions) {
await AVG_1.ActionManager.executeActions(item.sentence.actions);
}
if (PhoneCallView_1.PhoneCallListAutoNextPlot && this.messageNode.active && !this._props.isSentenceSelectVisible()) {
this.scheduleOnce(() => {
this._props.onCompletePlot(item.select);
}, 1);
}
else {
this._selectIndex = item.select;
}
this.contentLayout.updateLayout();
this.scrollToBottom();
}
updateCallingStatusLabel(statusStr) {
this.statusLabel.string = statusStr;
}
};
__decorate([
property(cc.ScrollView)
], PhoneCallViewImpl.prototype, "scrollView", void 0);
__decorate([
property(cc.Layout)
], PhoneCallViewImpl.prototype, "contentLayout", void 0);
__decorate([
property(cc.Node)
], PhoneCallViewImpl.prototype, "callingNode", void 0);
__decorate([
property(cc.Node)
], PhoneCallViewImpl.prototype, "messageNode", void 0);
__decorate([
property(cc.Label)
], PhoneCallViewImpl.prototype, "nameLabel1", void 0);
__decorate([
property(cc.Label)
], PhoneCallViewImpl.prototype, "nameLabel2", void 0);
__decorate([
property(cc.Sprite)
], PhoneCallViewImpl.prototype, "headIcon1", void 0);
__decorate([
property(cc.Sprite)
], PhoneCallViewImpl.prototype, "headIcon2", void 0);
__decorate([
property(cc.Node)
], PhoneCallViewImpl.prototype, "rejectTipNode", void 0);
__decorate([
property(cc.Node)
], PhoneCallViewImpl.prototype, "nextPlotNode", void 0);
__decorate([
property(cc.Label)
], PhoneCallViewImpl.prototype, "statusLabel", void 0);
__decorate([
property(Typewriter_1.default)
], PhoneCallViewImpl.prototype, "typewriter", void 0);
PhoneCallViewImpl = __decorate([
ccclass,
PresenterCCViewFactory_1.RegView(PhoneCallView_1.PhoneCallViewType, "prefab/ui/PhoneCallView")
], PhoneCallViewImpl);
return PhoneCallViewImpl;
})();
exports.PhoneCallViewImpl = PhoneCallViewImpl;
cc._RF.pop();