e63cdc30-10ed-42f8-b5cf-cc34fb2da07b.js
6.44 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
"use strict";
cc._RF.push(module, 'e63cdwwEO1C+LXPzDT7LaB7', 'MessageViewPresenter');
// script/game/ui/presenter/MessageViewPresenter.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 MessageView_1 = require("../view/type/MessageView");
const GameModelManager_1 = require("../../model/GameModelManager");
const PlotModel_1 = require("../../../avg/model/PlotModel");
const RichTextUtils_1 = require("../../../avg/utils/RichTextUtils");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const ChatListViewPresenter_1 = require("./ChatListViewPresenter");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const PlotManager_1 = require("../../../avg/PlotManager");
const Enums_1 = require("../../Enums");
const PhoneCallViewPresenter_1 = require("./PhoneCallViewPresenter");
function getSentenceText(content) {
let text = "";
switch (content.type) {
case PlotModel_1.SentenceType.TEXT:
text = RichTextUtils_1.richNodesToCocosString(content.value);
break;
case PlotModel_1.SentenceType.AUDIO:
text = "[Voice]";
break;
case PlotModel_1.SentenceType.IMAGE:
text = "[Image]";
break;
case PlotModel_1.SentenceType.VIDEO:
text = "[Video]";
break;
}
return text;
}
function getPlotString(plot) {
if (plot) {
let text = "";
let sentence = plot.sentences[0];
if (sentence.content) {
if (sentence.content.type === PlotModel_1.SentenceType.SELECT) {
let select = PlotManager_1.PlotManager.getPlotSelection(plot.id);
if (select !== undefined) {
let option = sentence.content.value[select];
if (option.content) {
text = getSentenceText(option.content);
}
else {
text = option.summary;
}
}
}
else {
text = getSentenceText(sentence.content);
}
}
return text;
}
return "";
}
let MessageViewPresenter = /** @class */ (() => {
let MessageViewPresenter = class MessageViewPresenter extends PresenterBase_1.Presenter {
constructor() {
super(...arguments);
this._scenesActive = {};
this._currPlotHasMsg = false;
this.checkScenesActive = () => {
this._currPlotHasMsg = false;
this._scenesActive = GameModelManager_1.GameModelManager.getMessageScenesModel().reduce((pv, v) => (pv[v.id] = this.checkSceneActive(v), pv), {});
};
this.checkSceneActive = (model) => {
let ret = PlotManager_1.PlotManager.getCurrentPlots().findIndex(v => v.plotSceneType === Enums_1.PlotSceneType.Message && v.plotSceneTypeId === model.id) >= 0;
if (ret)
this._currPlotHasMsg = true;
return ret;
};
this.onItemClick = (key) => {
console.log("item click", key);
let sceneModel = GameModelManager_1.GameModelManager.getMessageSceneModel(parseInt(key));
if (!sceneModel) {
console.error("message scene model not found ", key);
return;
}
UIManager_1.UIManager.pushPresenter(ChatListViewPresenter_1.ChatListViewPresenter, sceneModel);
};
}
onOpen() {
super.onOpen(undefined);
this.checkScenesActive();
this.setViewProps();
this._disposable.add(GameModelManager_1.GameModelManager.MessageSceneChanged.on(() => {
if (!this._currPlotHasMsg && !this._view.isHidden && !this._isInBackground) {
this.checkScenesActive();
this.setViewProps();
}
}));
this._disposable.add(PlotManager_1.PlotManager.PlotStartEvent.on(() => {
if (this._currPlotHasMsg && !this._view.isHidden && !this._isInBackground) {
this.checkScenesActive();
this.setViewProps();
}
}));
this.checkPhoneCall();
}
onShow() {
super.onShow();
this.checkScenesActive();
this.setViewProps();
this.checkPhoneCall();
}
checkPhoneCall() {
if (PlotManager_1.PlotManager.getCurrentPlots()[0].plotSceneType === Enums_1.PlotSceneType.PhoneCall) {
UIManager_1.UIManager.pushPresenter(PhoneCallViewPresenter_1.PhoneCallViewPresenter, undefined);
}
}
onEnterForeground() {
super.onEnterForeground();
this.checkScenesActive();
this.setViewProps();
this.checkPhoneCall();
}
setViewProps() {
this._view.setProps({
items: GameModelManager_1.GameModelManager.getMessageScenesModel().map(v => {
return {
key: v.id + "",
icons: [GameModelManager_1.GameModelManager.getRoleData(v.config.roles[0]).getHeadIcon(true)],
title: GameModelManager_1.GameModelManager.getConfigLanguageTxt(v.config.title), lastMsg: getPlotString(v.lastPlot),
redDot: this._scenesActive[v.id]
};
}),
onItemClick: this.onItemClick
});
}
};
MessageViewPresenter.uuid = "MessageViewPresenter";
MessageViewPresenter = __decorate([
PresenterCCViewFactory_1.RegPresenter(MessageView_1.MessageViewType)
], MessageViewPresenter);
return MessageViewPresenter;
})();
exports.default = MessageViewPresenter;
cc._RF.pop();