f2d00e7e-a889-4fad-a98c-7248c79456b3.js 5.25 KB
"use strict";
cc._RF.push(module, 'f2d005+qIlPramMckjHlFaz', 'PhoneCallViewPresenter');
// script/game/ui/presenter/PhoneCallViewPresenter.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 });
exports.PhoneCallViewPresenter = void 0;
const simba_config_manager_1 = require("simba-config-manager");
const AVG_1 = require("../../../avg/AVG");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const Role_1 = require("../../../config/Role");
const Enums_1 = require("../../Enums");
const GameModelManager_1 = require("../../model/GameModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const PhoneCallView_1 = require("../view/type/PhoneCallView");
const SentenceSelectorViewPresenter_1 = require("./SentenceSelectorViewPresenter");
let PhoneCallViewPresenter = /** @class */ (() => {
    let PhoneCallViewPresenter = class PhoneCallViewPresenter extends PresenterBase_1.Presenter {
        constructor() {
            super(...arguments);
            this._items = [];
            this.onSetContent = (content) => {
                let props = {
                    sentence: content,
                    backgroundpath: "",
                    clickcausehide: false,
                    onSelectIndexCallback: this.onSelectIndexCallback
                };
                UIManager_1.UIManager.pushPresenter(SentenceSelectorViewPresenter_1.default, props);
            };
            this.onSelectIndexCallback = (index) => {
                this.view.select(index);
            };
            this.isSentenceSelectVisible = () => {
                let preset = UIManager_1.UIManager.getTopPresenter();
                if (preset instanceof SentenceSelectorViewPresenter_1.default) {
                    let selectorPresenter = preset;
                    return !selectorPresenter.view.isHidden;
                }
                return false;
            };
            this.onGameChangedClickCallback = (ret) => {
                this.view.applicationChange(ret);
            };
        }
        async onOpen() {
            super.onOpen(undefined);
            this._disposable.add(GameModelManager_1.GameModelManager.ApplicaitonGameChanged.on(this.onGameChangedClickCallback));
            let plots = await GameModelManager_1.GameModelManager.rollbackPhoneCallIfNeeded();
            this.analysisPlots(plots);
        }
        analysisPlots(plots) {
            this._items = [];
            let plot = plots[0];
            if (plot.plotSceneType !== Enums_1.PlotSceneType.PhoneCall) {
                console.error("Phone call plot data error.");
            }
            else {
                let roleData = simba_config_manager_1.ConfigManager.getConfig(Role_1.role, plot.plotSceneTypeId);
                this._items = [{ key: plot.id + "", isSelf: plot.sentences[0].roleId === 2, sentence: plot.sentences[0] }];
                this._viewProps =
                    {
                        name: roleData.name,
                        icon: GameModelManager_1.GameModelManager.getRoleData(plot.plotSceneTypeId).getHeadIcon(),
                        items: this._items,
                        onCompletePlot: (index) => AVG_1.PlotManager.completePlot(plot, index),
                        onSetContent: this.onSetContent,
                        isSentenceSelectVisible: this.isSentenceSelectVisible
                    };
                this._view.setProps(this._viewProps);
                this._disposable.clear();
                this._disposable.add(AVG_1.PlotManager.PlotStartEvent.on((plots) => {
                    plot = plots[0];
                    if (plot.plotSceneType !== Enums_1.PlotSceneType.PhoneCall) {
                        GameModelManager_1.GameModelManager.dotMainLinePlotEnd();
                        this._view.close();
                    }
                    else {
                        let item = { key: plot.id + "", isSelf: plot.sentences[0].roleId === 2, sentence: plot.sentences[0] };
                        let index = this._items.findIndex((v) => v.key === item.key);
                        if (index === -1) {
                            this._items = [...this._items, item];
                        }
                        this._view.updateProps({ items: this._items });
                    }
                }));
            }
        }
    };
    PhoneCallViewPresenter.uuid = "PhoneCallViewPresenter";
    PhoneCallViewPresenter = __decorate([
        PresenterCCViewFactory_1.RegPresenter(PhoneCallView_1.PhoneCallViewType)
    ], PhoneCallViewPresenter);
    return PhoneCallViewPresenter;
})();
exports.PhoneCallViewPresenter = PhoneCallViewPresenter;

cc._RF.pop();