1a5035b8-0a2e-4bde-8bd5-11fcd16d2ec5.js 5.74 KB
"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();