e63cdc30-10ed-42f8-b5cf-cc34fb2da07b.js
15.6 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
315
316
317
318
319
320
321
322
323
324
325
"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 simba_config_manager_1 = require("simba-config-manager");
const AVG_1 = require("../../../avg/AVG");
const EditorEnums_1 = require("../../../avg/EditorEnums");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const GameTextData_1 = require("../../../common/gameplay/gamedata/GameTextData");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const RelationLevelConfig_1 = require("../../../config/RelationLevelConfig");
const Role_1 = require("../../../config/Role");
const Enums_1 = require("../../Enums");
const GameDotMgr_1 = require("../../GameDotMgr");
const GameModelManager_1 = require("../../model/GameModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const MessageView_1 = require("../view/type/MessageView");
const AlertDialogViewPresenter_1 = require("./AlertDialogViewPresenter");
const ChatListViewPresenter_1 = require("./ChatListViewPresenter");
const GuideViewPresenter_1 = require("./GuideViewPresenter");
const PhoneCallViewPresenter_1 = require("./PhoneCallViewPresenter");
const PlotStopViewPresenter_1 = require("./PlotStopViewPresenter");
function getSentenceText(content) {
let text = "";
switch (content.type) {
case AVG_1.SentenceType.TEXT:
text = AVG_1.richNodesToCocosString(content.value);
const CHAR_LIMIT = 15;
// text = '<color=#000000>亲,你说不说?</color>,<color=#000000>111</color>';
// text = '亲,你说不说?亲,你说不说?亲,你说不说?';
const regex = /<color=#[0-9A-Za-z]{6,6}>/g;
let str = text.replace(regex, '');
let textStr = str.replace(/<\/color>/g, '');
text = textStr.length > CHAR_LIMIT ? textStr.slice(0, CHAR_LIMIT - 3) + "..." : textStr;
break;
case AVG_1.SentenceType.AUDIO:
text = "[Voice]";
break;
case AVG_1.SentenceType.IMAGE:
text = "[Image]";
break;
case AVG_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 === AVG_1.SentenceType.SELECT) {
let select = AVG_1.PlotManager.getPlotSelection(plot.id);
if (select !== undefined) {
let option = sentence.content.value[select];
if (option.content) {
if (option.content.type === AVG_1.SentenceType.EMPTY) {
console.error("TODO handle empty plots in message");
}
else {
text = getSentenceText(option.content);
}
}
else {
text = option.summary;
}
}
}
else {
if (sentence.content.type === AVG_1.SentenceType.EMPTY) {
console.error("TODO handle empty plots in message");
}
else {
text = getSentenceText(sentence.content);
}
}
}
return text;
}
return GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.TEXT_NEW_CHAT_MSG_VALUE);
}
let MessageViewPresenter = /** @class */ (() => {
let MessageViewPresenter = class MessageViewPresenter extends PresenterBase_1.Presenter {
constructor() {
super(...arguments);
this._scenesActive = {};
this._currPlotHasMsg = false;
this._isCheckingPhoneCall = false;
this.onForceClickItem = (id) => {
console.log("MessageViewPresenter onForceClickItem id = ", id);
if (!this._viewProps.items || 0 === this._viewProps.items.length) {
return;
}
let c = id + "";
let i = this._viewProps.items.findIndex((v) => v.key === c);
if ((-1) !== i) {
this.onItemClick(c);
}
};
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 = AVG_1.PlotManager.getCurrentPlots().findIndex(v => v.plotSceneType === Enums_1.PlotSceneType.Message && v.plotSceneTypeId === model.id) >= 0;
if (ret)
this._currPlotHasMsg = true;
return ret;
};
this.PlotStopTipBtnCallback = () => {
UIManager_1.UIManager.pushPresenter(PlotStopViewPresenter_1.default, undefined);
};
this.addGraceClickCallBack = (roleId) => {
// GameDotMgr.getInstance().dotClickUI("click_grace");
let r = GameModelManager_1.GameModelManager.getRoleData(roleId);
if (!r || r.getConfig().RoleType !== EditorEnums_1.RoleType.Role_Major) {
return;
}
let l = r.getRoleLikeLevel();
let m = -1;
let t = simba_config_manager_1.ConfigManager.getAllConfig(RelationLevelConfig_1.relationLevelConfig);
for (let id in t) {
let c = t[id];
m = m < c.id ? c.id : m;
//暂时修改最大等级为10
m = 10;
}
if (m <= l.level) {
UIManager_1.UIManager.showToast(GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_GRACE_LEVEL_MAX_VALUE));
return;
}
else {
// UIManager.showToast(StringUtils.format(GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_GRACE_TIP_ROLE), r.getRoleName(), l.level));
let temp = {
dataptr: { roleId: roleId },
titlecontent: "提升好感度",
content: `当前与${r.getRoleName()}好感度等级为${l.level},观看视频提升好感度等级!`,
ishasad: true,
istwobtn: true,
adconfig: "inject_fruit",
// items: [],
hasBanner: false,
callback: (type, ret, param) => {
if (ret) {
if (type === "video") {
let rid = param.roleId;
let role = GameModelManager_1.GameModelManager.getRoleData(rid);
if (role) {
role.addRoleLike(1000);
this.setViewProps();
}
}
else {
UIManager_1.UIManager.showToast("只能通过观看视频提升好感度等级!");
}
}
}
};
UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
}
};
this.onItemClick = (key) => {
// console.log("item click", key);
GameModelManager_1.GameModelManager.setGuideMsgItemRecord(key, Enums_1.GuideState.Complete);
let sceneModel = GameModelManager_1.GameModelManager.getMessageSceneModel(parseInt(key));
if (!sceneModel) {
console.error("message scene model not found ", key);
return;
}
let isNew = AVG_1.PlotManager.getCurrentPlots().findIndex(v => v.plotSceneType === Enums_1.PlotSceneType.Message && v.plotSceneTypeId === sceneModel.id) !== (-1);
if (isNew || sceneModel.firstPlot.sentences[0].roleId == 3) {
GameDotMgr_1.default.getInstance().dotClickUI("click_chat_card" + sceneModel.id);
}
UIManager_1.UIManager.pushPresenter(ChatListViewPresenter_1.ChatListViewPresenter, sceneModel);
};
this.checkGuideItem = () => {
let k = GameModelManager_1.GameModelManager.getMsgItemGuideKey();
if (k && "" !== k) {
let node = this._view.getItemNode(k);
if (node) {
let wp = node.convertToWorldSpaceAR(cc.v2(0, 0));
let m = {
x: wp.x,
y: wp.y,
w: node.width,
h: node.height,
d: Enums_1.DirectionType.DOWM,
call: () => {
this.onItemClick(k);
}
};
UIManager_1.UIManager.pushPresenter(GuideViewPresenter_1.default, m);
GameDotMgr_1.default.getInstance().dotGuide(Enums_1.GuideOperationType.Show, Enums_1.GuideLocation.MsgItem);
}
}
};
this.onShowPlotBlocked = () => {
this._viewProps.isShowPlotStopTipBtn = GameModelManager_1.GameModelManager.checkIsPlotBlocked();
this.view.updateProps(this._viewProps);
};
this.onRefreshAllStatus = () => {
this.initViewProps();
this.checkScenesActive();
this.setViewProps();
this._isCheckingPhoneCall = false;
this.checkPhoneCall();
};
}
onOpen() {
super.onOpen(undefined);
this.initViewProps();
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(AVG_1.PlotManager.PlotStartEvent.on(() => {
if (this._currPlotHasMsg && !this._view.isHidden && !this._isInBackground) {
this.checkScenesActive();
this.setViewProps();
}
}));
// this._disposable.add(GameModelManager.CheckMsgGuide.on(this.checkGuideItem));
this._disposable.add(GameModelManager_1.GameModelManager.ShowPlotBlocked.on(this.onShowPlotBlocked));
this._disposable.add(GameModelManager_1.GameModelManager.PlotBlockedChanged.on(this.onShowPlotBlocked));
this._disposable.add(GameModelManager_1.GameModelManager.ForceClickMsgItem.on(this.onForceClickItem));
this._disposable.add(GameModelManager_1.GameModelManager.RefreshAllStatus.on(this.onRefreshAllStatus));
this._isCheckingPhoneCall = false;
this.checkPhoneCall();
}
onShow() {
super.onShow();
this.checkScenesActive();
this.setViewProps();
this.checkPhoneCall();
// this.checkGuideItem();
}
initViewProps() {
this._viewProps = {
items: [],
onItemClick: this.onItemClick,
PlotStopTipBtnCallback: this.PlotStopTipBtnCallback,
isShowPlotStopTipBtn: false,
};
}
async checkPhoneCall() {
if (this._isCheckingPhoneCall) {
return;
}
this._isCheckingPhoneCall = true;
if (AVG_1.PlotManager.getCurrentPlots()[0].plotSceneType === Enums_1.PlotSceneType.PhoneCall) {
await UIManager_1.UIManager.pushPresenter(PhoneCallViewPresenter_1.PhoneCallViewPresenter, undefined);
}
this._isCheckingPhoneCall = false;
}
onEnterForeground() {
super.onEnterForeground();
this.checkScenesActive();
this.setViewProps();
this.checkPhoneCall();
}
setViewProps() {
let items = GameModelManager_1.GameModelManager.getMessageScenesModel().map(v => {
let roleConfig = simba_config_manager_1.ConfigManager.getConfig(Role_1.role, v.config.roles[0]);
let isMajor = roleConfig.RoleType === EditorEnums_1.RoleType.Role_Major;
let roleData = GameModelManager_1.GameModelManager.getRoleData(v.config.roles[0]);
let data = roleData.getRoleLikeLevel();
let nameSpr = GameModelManager_1.GameModelManager.getRoleData(v.config.roles[0]).getNameIcon();
if (v.config.roles[0] === 3) {
nameSpr = "/textures/name_icon/laoda";
}
return {
key: v.id + "",
icons: [GameModelManager_1.GameModelManager.getRoleData(v.config.roles[0]).getHeadIcon()],
title: GameModelManager_1.GameModelManager.getConfigLanguageTxt(v.config.title),
lastMsg: getPlotString(v.lastPlot),
redDot: this._scenesActive[v.id],
isShowGrace: isMajor,
level: isMajor ? data.level : undefined,
roleId: v.config.roles[0],
addGraceClickCallBack: this.addGraceClickCallBack,
isShowAddGrace: isMajor && data.level !== data.maxLevel,
nameSpr: nameSpr
};
});
//对列表进行排序,有红点的(新对话消息)排在最前面,也就是置顶
items.sort((a, b) => {
if (a.redDot) {
return -1;
}
if (b.redDot) {
return 1;
}
return 0;
});
this._viewProps = {
items: items,
onItemClick: this.onItemClick,
isShowPlotStopTipBtn: GameModelManager_1.GameModelManager.checkIsPlotBlocked(),
PlotStopTipBtnCallback: this.PlotStopTipBtnCallback,
};
this.view.setProps(this._viewProps);
}
};
MessageViewPresenter.uuid = "MessageViewPresenter";
MessageViewPresenter = __decorate([
PresenterCCViewFactory_1.RegPresenter(MessageView_1.MessageViewType)
], MessageViewPresenter);
return MessageViewPresenter;
})();
exports.default = MessageViewPresenter;
cc._RF.pop();