73860035-95fb-42c3-a0c8-4a1754585f6c.js
25.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
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
"use strict";
cc._RF.push(module, '73860A1lftCw6DIShdUWF9s', 'MainViewPresenter');
// script/game/ui/presenter/MainViewPresenter.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 PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const GameTextData_1 = require("../../../common/gameplay/gamedata/GameTextData");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const DateSceneConfig_1 = require("../../../config/DateSceneConfig");
const Enums_1 = require("../../Enums");
const GameDotMgr_1 = require("../../GameDotMgr");
const DatingEventSceneModel_1 = require("../../model/DatingEventSceneModel");
const GameModelManager_1 = require("../../model/GameModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const VerbView_1 = require("../VerbView");
const AlertToBeContinueImpl_1 = require("../view/impl/AlertToBeContinueImpl");
const MainView_1 = require("../view/type/MainView");
const DatingEventViewPresenter_1 = require("./DatingEventViewPresenter");
const DatingScenePresenter_1 = require("./DatingScenePresenter");
const DebugViewPresenter_1 = require("./DebugViewPresenter");
const DiscoverViewPresenter_1 = require("./DiscoverViewPresenter");
const GuideViewPresenter_1 = require("./GuideViewPresenter");
const MessageViewPresenter_1 = require("./MessageViewPresenter");
const NoticeViewPresenter_1 = require("./NoticeViewPresenter");
const PlotStopViewPresenter_1 = require("./PlotStopViewPresenter");
const simba_cc_audio_manager_1 = require("simba-cc-audio-manager");
const simba_cc_resutils_1 = require("simba-cc-resutils");
const GameConstData_1 = require("../../../common/gameplay/gamedata/GameConstData");
const UnlockItemModelManager_1 = require("../../model/UnlockItemModelManager");
const ItemTbl_1 = require("../../../config/ItemTbl");
const GameConfig_1 = require("../../../GameConfig");
const simba_httpclient_1 = require("simba-httpclient");
const EditorEnums_1 = require("../../../avg/EditorEnums");
const NewNoticeViewPresenter_1 = require("./notice/NewNoticeViewPresenter");
const NewNoticeView_1 = require("../view/type/notice/NewNoticeView");
const ExtraPlotViewPresenter_1 = require("./ExtraPlotViewPresenter");
const simba_sdk_1 = require("simba-sdk");
const TabPresenterFactory = [
MessageViewPresenter_1.default,
DatingEventViewPresenter_1.default,
DiscoverViewPresenter_1.default
];
/**主线剧情的下标 */
const MAIN_PLOT_INDEX = 0;
let MainViewPresenter = /** @class */ (() => {
var MainViewPresenter_1;
let MainViewPresenter = MainViewPresenter_1 = class MainViewPresenter extends PresenterBase_1.Presenter {
constructor() {
super();
this._subPresenters = [];
this._currentTab = 0;
this._loadingTab = false;
this._tabToggleDelayTime = 618;
this._tabClickAble = false;
this._itemId = -1;
this._hasItem = false;
this.onDebugClickCallback = () => {
UIManager_1.UIManager.pushPresenter(DebugViewPresenter_1.default, undefined);
};
this.onGoToShopClickCallback = () => {
GameDotMgr_1.default.getInstance().dotClickUI("shop_btn_MainView");
if (GameConfig_1.channel == "wechat") {
// GameCenter.getInstance().openSubProgram(GameConfig.youZanShopAppId);
let link = GameModelManager_1.GameModelManager.getYouZanShopUrlByType(8);
if (link) {
simba_sdk_1.SDK.openProgramV2(GameConfig_1.GameConfig.youZanShopAppId, link);
}
}
else if (GameConfig_1.channel == "android") {
let link = GameModelManager_1.GameModelManager.getTaoBaoShopUrlByType(8);
if (link) {
GameModelManager_1.GameModelManager.jumpToTaobaoShop(link);
}
}
else {
UIManager_1.UIManager.showToast("该功能在当前平台不可使用");
}
};
this.onCommonProblemClickCallback = async () => {
try {
let resStr = await new simba_httpclient_1.HttpClient(GameConfig_1.GameConfig.commonProblemConfigUrl).get();
let res = JSON.parse(resStr);
if (res) {
UIManager_1.UIManager.pushPresenter(NoticeViewPresenter_1.default, {
title: res.title,
content: res.content
});
}
}
catch (error) {
console.error(error);
}
};
this.checkRedDot = (plots) => {
this._viewProps.messageRedDot = plots[MAIN_PLOT_INDEX].plotSceneType === Enums_1.PlotSceneType.Message || plots[MAIN_PLOT_INDEX].plotSceneType === Enums_1.PlotSceneType.PhoneCall;
this._viewProps.datingEventRedDot = false;
this._viewProps.datingEventRedDot = plots && (plots[0].plotSceneType === Enums_1.PlotSceneType.DatingEvent && (plots[0].id !== AVG_1.SpecialPlotId.ToBeContinued && plots[0].id !== AVG_1.SpecialPlotId.End));
this.view.setProps(this._viewProps);
if (plots[MAIN_PLOT_INDEX] && plots[MAIN_PLOT_INDEX].plotSceneType === Enums_1.PlotSceneType.BlockPlot) {
GameModelManager_1.GameModelManager.dealBlockedPlot();
}
else {
let change = GameModelManager_1.GameModelManager.isChangePlotSceneType();
if (change) {
let p = plots[MAIN_PLOT_INDEX];
let isSpecial = p.id === AVG_1.SpecialPlotId.End || p.id === AVG_1.SpecialPlotId.ToBeContinued;
if (!isSpecial) {
this.onMainPlotChanged(p.plotSceneType, p.plotSceneTypeId);
GameModelManager_1.GameModelManager.setIsChangePlotSceneType(false);
}
}
}
};
this.onMainTabForceClick = (param) => {
UIManager_1.UIManager.popToPresenter(this);
let index = param.index;
this.onTabClick(index);
};
this.onTabClick = async (index, callback, isDot) => {
if (!this._tabClickAble) {
return;
}
this.dealTabGuide(index);
let uuid = TabPresenterFactory[index].uuid;
if (!GameModelManager_1.GameModelManager.checkFuncUnloced(uuid)) {
UIManager_1.UIManager.showToast(GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_MAIN_FUNCTION_NOT_OPEN));
return;
}
if (this._loadingTab)
return;
if (this._currentTab !== index) {
if (this._subPresenters[this._currentTab])
this._subPresenters[this._currentTab].view.hide();
this._currentTab = index;
this._viewProps.selectedTab = index;
this._view.setProps(this._viewProps);
if (index !== 2) {
MainViewPresenter_1.tabIndex = index;
}
if (!this._subPresenters[this._currentTab]) {
this._loadingTab = true;
await PresenterBase_1.createPresenter(TabPresenterFactory[this._currentTab]).then((presenter) => {
this._subPresenters[this._currentTab] = presenter;
presenter.open(this.view.getTabContentContainer(), undefined);
setTimeout(() => {
this._loadingTab = false;
}, this._tabToggleDelayTime);
if (callback) {
callback();
}
});
}
else {
if (this._subPresenters[this._currentTab]) {
this._subPresenters[this._currentTab].view.show();
}
if (callback) {
callback();
}
}
}
else {
if (callback) {
callback();
}
}
};
this.checkTabGuide = () => {
let check = false;
if (!check) {
return;
}
let index = GameModelManager_1.GameModelManager.getMainTabGuideIndex();
if (index !== -1) {
//attention
let redDotArr = [this._viewProps.messageRedDot, this._viewProps.datingEventRedDot, this._viewProps.discoverRedDot];
if (!redDotArr[index] || this._currentTab === index) {
return;
}
UIManager_1.UIManager.popToPresenter(this);
let m = this.view.getGuideTabParam(index);
if (m) {
let location = index === Enums_1.MainTabs.datingEventTab ? Enums_1.GuideLocation.TabDate : Enums_1.GuideLocation.TabMsg;
m.call = () => {
this.onTabClick(index);
this.view.hideClickAniByIndex(index);
};
UIManager_1.UIManager.pushPresenter(GuideViewPresenter_1.default, m);
}
}
};
this.onAutoPopView = async (viewType) => {
switch (viewType) {
case Enums_1.AutoPopViewType.ToBeContinued:
{
await AlertToBeContinueImpl_1.showToBeContinue();
}
break;
case Enums_1.AutoPopViewType.Notice:
{
UIManager_1.UIManager.pushPresenter(NewNoticeViewPresenter_1.default, NewNoticeView_1.SourceView.MessageView);
}
break;
case Enums_1.AutoPopViewType.PlotStop:
{
UIManager_1.UIManager.pushPresenter(PlotStopViewPresenter_1.default, undefined);
}
break;
}
};
this.onShowPlotBlocked = () => {
GameModelManager_1.GameModelManager.registerAutoPopView(Enums_1.AutoPopViewType.PlotStop);
};
this.onMainPlotChanged = async (pType, pId) => {
if (!GameModelManager_1.GameModelManager.isMainPlotSceneType() || simba_config_manager_1.ConfigManager.getConfig(DateSceneConfig_1.dateSceneConfig, pId).DateType == EditorEnums_1.DateType.Date_Sp) {
return;
}
UIManager_1.UIManager.popToPresenter(this);
let comp = cc.director.getScene().getChildByName("Canvas").getChildByName("VerbRoot").getChildByName("VerbView").getComponent(VerbView_1.default);
if (this._hasItem && -1 !== this._itemId) {
//加载图和组织物品掉落数据
let showItemCfg = undefined;
let itemSpriteFrame = undefined;
showItemCfg = this.getShowItemCfg(this._itemId);
if (showItemCfg) {
let path = GameConstData_1.GameConstData.GAME_CONST_ITEM_BIG_SPR_DIR + showItemCfg.icon;
itemSpriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(path, cc.SpriteFrame);
comp.setItemDropData(itemSpriteFrame, showItemCfg);
this._itemId = -1;
this._hasItem = false;
}
}
switch (pType) {
case Enums_1.PlotSceneType.Message:
{
this.onTabClick(Enums_1.MainTabs.messageTab, () => {
this._subPresenters[this._currentTab].onShow();
comp.toChat({ title: "", desc: "来电了!!" });
setTimeout(() => {
GameModelManager_1.GameModelManager.ForceClickDataReady.emit();
GameModelManager_1.GameModelManager.ForceClickMsgItem.emit(pId);
}, 500);
});
}
break;
case Enums_1.PlotSceneType.DatingEvent:
{
let cfgs = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
let ids = [];
for (const id in cfgs) {
if (cfgs[id].DateType == EditorEnums_1.DateType.Date_Normal) {
ids.push(id);
}
}
let plotIds = [];
let models = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
for (let i = 0; i < models.length; i++) {
plotIds.push(models[i].id);
}
let index = plotIds.indexOf(pId);
let title = "第" + (plotIds.length) + "章:";
let cfg = simba_config_manager_1.ConfigManager.getConfig(DateSceneConfig_1.dateSceneConfig, pId);
let desc = cfg && cfg.name ? GameModelManager_1.GameModelManager.getConfigLanguageTxt(cfg.name) : "";
comp.toDating(() => {
simba_cc_audio_manager_1.AudioManager.playEffect('verb');
this.onTabClick(Enums_1.MainTabs.datingEventTab, () => {
GameModelManager_1.GameModelManager.ForceClickDataReady.emit();
GameModelManager_1.GameModelManager.ForceClickDatingItem.emit(pId);
});
this.view.hideClickAniByIndex(Enums_1.MainTabs.datingEventTab);
}, { title: title, desc: desc });
}
break;
}
};
this.onUnlockItem = (itemId) => {
let unlockItems = UnlockItemModelManager_1.UnlockItemModelManager.unlockItems;
let isNew = unlockItems.indexOf(itemId) == -1;
if (isNew) {
this._itemId = itemId;
this._hasItem = true;
//写存档+组织数据并派发
UnlockItemModelManager_1.UnlockItemModelManager.saveItemIdToGameRecord(itemId);
}
};
this.onRefreshAllStatus = async () => {
this.checkRedDot(AVG_1.PlotManager.getCurrentPlots());
GameConfig_1.GameConfig.showToBeContinue = false;
let needEnterSpecialDatingScene = this.checkIsNeedToEnterSpecialDatingScene();
// check tab guide
// this.checkTabGuide();
if (needEnterSpecialDatingScene) {
GameConfig_1.GameConfig.isVerb = true;
this.enterSpecialEventScene();
this._currentTab = Enums_1.MainTabs.datingEventTab;
this._viewProps.selectedTab = Enums_1.MainTabs.datingEventTab;
}
else {
GameModelManager_1.GameModelManager.checkAutoPopView();
}
this._tabClickAble = true;
};
/**
* 卧室返回点击UI事件
* @param index 返回具体tabIndex
*/
this.onJumpToViewInGame = (index) => {
let tab = Enums_1.MainTabs.messageTab;
switch (index) {
case EditorEnums_1.PageIndex.MessageView:
tab = Enums_1.MainTabs.messageTab;
this._view.onTabButtonClick(null, `${tab}`);
break;
case EditorEnums_1.PageIndex.DateEventView:
tab = Enums_1.MainTabs.datingEventTab;
this._view.onTabButtonClick(null, `${tab}`);
break;
case EditorEnums_1.PageIndex.ExtraPlotView:
tab = Enums_1.MainTabs.datingEventTab;
this._view.onTabButtonClick(null, `${tab}`);
UIManager_1.UIManager.pushPresenter(ExtraPlotViewPresenter_1.default, undefined);
break;
default:
console.error("The pageIndex is invalid.");
UIManager_1.UIManager.showToast("无效的页面跳转");
break;
}
};
this._viewProps = {
selectedTab: 0,
messageRedDot: false,
datingEventRedDot: false,
discoverRedDot: false,
onTabClick: this.onTabClick,
onDebugClick: this.onDebugClickCallback,
};
}
async start() {
this._subPresenters[0] = await PresenterBase_1.createPresenter(TabPresenterFactory[0]);
MainViewPresenter_1.tabIndex = 0;
let viewContainer = this._view.getTabContentContainer();
this._subPresenters[0].open(viewContainer, undefined);
this.dealTabGuide(Enums_1.MainTabs.messageTab);
this._viewProps.selectedTab = Enums_1.MainTabs.messageTab;
this._disposable.add(GameModelManager_1.GameModelManager.ShowPlotBlocked.on(this.onShowPlotBlocked));
this._disposable.add(GameModelManager_1.GameModelManager.AutoPopView.on(this.onAutoPopView));
this._disposable.add(GameModelManager_1.GameModelManager.UnlockItem.on(this.onUnlockItem));
this._disposable.add(GameModelManager_1.GameModelManager.RefreshAllStatus.on(this.onRefreshAllStatus));
this._disposable.add(GameModelManager_1.GameModelManager.JumpToViewInGame.on(this.onJumpToViewInGame));
this.checkRedDot(AVG_1.PlotManager.getCurrentPlots());
AVG_1.PlotManager.PlotStartEvent.on(this.checkRedDot);
let needEnterSpecialDatingScene = this.checkIsNeedToEnterSpecialDatingScene();
// check tab guide
// this.checkTabGuide();
if (needEnterSpecialDatingScene) {
GameConfig_1.GameConfig.isVerb = true;
this.enterSpecialEventScene();
this._currentTab = Enums_1.MainTabs.datingEventTab;
this._viewProps.selectedTab = Enums_1.MainTabs.datingEventTab;
}
this._tabClickAble = true;
//进入主界面更新红点状态
setTimeout(() => {
//关闭等待界面
this.view.showWaitingView(false);
//开始弹起自动窗口
if (AVG_1.PlotManager.getCurrentPlots()[MAIN_PLOT_INDEX].id === AVG_1.SpecialPlotId.ToBeContinued) {
GameModelManager_1.GameModelManager.registerAutoPopView(Enums_1.AutoPopViewType.ToBeContinued);
}
let autoShowNotice = GameModelManager_1.GameModelManager.getAutoShowNotice();
if (autoShowNotice) {
GameModelManager_1.GameModelManager.registerAutoPopView(Enums_1.AutoPopViewType.Notice);
}
let unlockItems = UnlockItemModelManager_1.UnlockItemModelManager.unlockItems;
if (unlockItems.indexOf(4) == -1) {
GameModelManager_1.GameModelManager.registerAutoPopView(Enums_1.AutoPopViewType.NoteBook);
}
if (!needEnterSpecialDatingScene) {
GameModelManager_1.GameModelManager.checkAutoPopView();
}
}, 2000);
}
/**
* 检查新手教程是否完成,当前新手教程完成的判定是完成第一章
* @returns
*/
checkNoviceTutorialOver() {
let models = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
for (let i = 0; i < models.length; i++) {
if (models[i].status == 4) {
return true;
}
}
return false;
}
async enterSpecialEventScene() {
let arr = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
UIManager_1.UIManager.pushPresenter(DatingScenePresenter_1.DatingScenePresenter, arr[0], true);
}
checkIsNeedToEnterSpecialDatingScene() {
let arr = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
let need = arr && arr.length === 1 && arr[0].status !== DatingEventSceneModel_1.DatingEventStatus.Completed;
return need;
}
onClose() {
super.onClose();
UIManager_1.UIManager.popToPresenter(this);
}
onOpen() {
super.onOpen(undefined);
// this.perloadPrefab();
// this.discoverInit();
}
discoverInit() {
AVG_1.GameRecord.onGlobalVariableChange("red_pot_" + DiscoverViewPresenter_1.default.uuid, () => {
this._viewProps.discoverRedDot = GameModelManager_1.GameModelManager.checkRedPot(DiscoverViewPresenter_1.default.uuid);
this.view.setProps(this._viewProps);
});
this._viewProps.discoverRedDot = GameModelManager_1.GameModelManager.checkRedPot(DiscoverViewPresenter_1.default.uuid);
this.view.setProps(this._viewProps);
}
perloadPrefab() {
let PFList = ["prefab/ui/DatingEventView"];
cc.resources.preload(PFList);
}
onEnterBackground() {
super.onEnterBackground();
if (this._subPresenters[this._currentTab])
this._subPresenters[this._currentTab].onEnterBackground();
}
/**presenter进入前景 */
async onEnterForeground() {
super.onEnterForeground();
if (this._subPresenters[this._currentTab]) {
this._subPresenters[this._currentTab].onEnterForeground();
this._subPresenters[this._currentTab].onEnterForeground();
}
if (AVG_1.PlotManager.getCurrentPlots()[MAIN_PLOT_INDEX].id === AVG_1.SpecialPlotId.ToBeContinued) {
GameModelManager_1.GameModelManager.registerAutoPopView(Enums_1.AutoPopViewType.ToBeContinued);
}
if (!GameConfig_1.GameConfig.isVerb) {
GameModelManager_1.GameModelManager.checkAutoPopView();
}
}
onShow() {
super.onShow();
// this.checkTabGuide();
}
dealTabGuide(index) {
let r = AVG_1.GameRecord.globalVariables["guide_main_tab" + index];
r = r === undefined ? Enums_1.GuideState.close : r;
if (r === Enums_1.GuideState.Open) {
GameModelManager_1.GameModelManager.setGuideMainTabRecord(index, Enums_1.GuideState.Complete);
}
}
switchTab(tabIndex) {
if (this._currentTab != tabIndex) {
let prevIndex = this._currentTab;
this._currentTab = tabIndex;
this._viewProps.selectedTab = this._currentTab;
this._view.setProps(this._viewProps);
}
}
getShowItemCfg(itemId) {
let cfg = undefined;
if (itemId) {
cfg = simba_config_manager_1.ConfigManager.getConfig(ItemTbl_1.itemTbl, itemId);
}
return cfg;
}
};
MainViewPresenter.uuid = "MainViewPresenter";
MainViewPresenter.tabIndex = -1;
MainViewPresenter = MainViewPresenter_1 = __decorate([
PresenterCCViewFactory_1.RegPresenter(MainView_1.MainViewType)
], MainViewPresenter);
return MainViewPresenter;
})();
exports.default = MainViewPresenter;
cc._RF.pop();