1a5035b8-0a2e-4bde-8bd5-11fcd16d2ec5.js
5.74 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
"use strict";
cc._RF.push(module, '1a503W4Ci5L3ovVEfzRbS7F', 'ReviewPlotViewPresenter');
// script/game/ui/presenter/ReviewPlotViewPresenter.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_avg_core_1 = require("simba-avg-core");
const AVG_1 = require("../../../avg/AVG");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const GameModelManager_1 = require("../../model/GameModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const ReviewPlotView_1 = require("../view/type/ReviewPlotView");
let ReviewPlotViewPresenter = /** @class */ (() => {
let ReviewPlotViewPresenter = class ReviewPlotViewPresenter extends PresenterBase_1.Presenter {
constructor() {
super();
this.onCloseButtonClickCallback = async () => {
this.view.close();
};
this._viewProps = {
onCloseButtonClickCallback: this.onCloseButtonClickCallback,
};
}
onOpen(param) {
super.onOpen(param);
this._param = param;
this.view.setProps(this._viewProps);
this.onShow();
}
onShow() {
super.onShow();
this.initViewDate();
}
onEnterBackground() {
super.onEnterBackground();
}
onEnterForeground() {
super.onEnterForeground();
}
onClose() {
super.onClose();
}
initViewDate() {
this.view.getPlotRichText().string = "";
this.view.getLoadingNode().active = true;
this.view.getPlotRichText().scheduleOnce(async () => {
if (this._param.isReview) {
this.view.getPlotRichText().string = this._param.plotString;
}
else {
this.view.getPlotRichText().string = await this.getReviewPlotContent();
}
if (this.view.getPlotRichText().node.height >= this.view.getPlotScrollView().node.height) {
this.view.getPlotScrollView().scrollToBottom();
}
this.view.getLoadingNode().active = false;
});
}
async getReviewPlotContent() {
var _a;
let showWhileNotSelect = false; //未选择时是否展示选项列表
let showCurrentPlot = true; //是否展示当前剧情内容
let plotStr = "";
let startPlotId = this._param.startPlotId;
let currentPlotId = this._param.currentPlotId;
let currentRecordIndex = simba_avg_core_1.PlotManager.getCurrentRecordIndex();
let currentRecord = AVG_1.GameRecord.getRecords()[currentRecordIndex].d;
let startPlotIdIndex = 0;
let currentPlotIdIndex = 0;
for (let i = 0; i < currentRecord.length; i++) {
if (startPlotId == currentRecord[i].p[0]) {
startPlotIdIndex = i;
}
if (currentPlotId == currentRecord[i].p[0]) {
currentPlotIdIndex = i;
}
}
if (showCurrentPlot) {
currentPlotIdIndex += 1;
}
let newCurrentRecord = currentRecord.slice(startPlotIdIndex, currentPlotIdIndex);
for (let i = 0; i < newCurrentRecord.length; i++) {
let content = await GameModelManager_1.GameModelManager.getPlotContent(newCurrentRecord[i].p[0]);
if (content) {
let roleData = GameModelManager_1.GameModelManager.getRoleData(content.roleId);
let plotName = "";
let plotContent = "";
if (content.content.length === 0) {
continue;
}
if (content.content.length > 1) {
if (newCurrentRecord[i].s && ((_a = newCurrentRecord[i].s) === null || _a === void 0 ? void 0 : _a.length) !== 0) {
plotName = "<color=#D36777>" + "选项" + ":</c>\n";
plotContent = content.content[newCurrentRecord[i].s[0]] + "\n";
}
else {
if (showWhileNotSelect) {
for (let j = 0; j < content.content.length; j++) {
plotContent = content.content[j] + "\n";
}
}
}
}
else {
plotName = "<color=#EFDA91>" + roleData.getConfig().name + ":</c>\n";
plotContent = content.content[0] + "\n";
}
plotStr += plotName + plotContent;
}
}
return plotStr;
}
};
ReviewPlotViewPresenter.uuid = "ReviewPlotViewPresenter";
ReviewPlotViewPresenter = __decorate([
PresenterCCViewFactory_1.RegPresenter(ReviewPlotView_1.ReviewPlotViewType)
], ReviewPlotViewPresenter);
return ReviewPlotViewPresenter;
})();
exports.default = ReviewPlotViewPresenter;
cc._RF.pop();