b020f340-f6ad-428d-8769-c332b5e22752.js 8.4 KB
"use strict";
cc._RF.push(module, 'b020fNA9q1CjYdpwzK14idS', 'ExtraPlotViewPresenter');
// script/game/ui/presenter/ExtraPlotViewPresenter.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 simba_sdk_1 = require("simba-sdk");
const EditorEnums_1 = require("../../../avg/EditorEnums");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const DateSceneConfig_1 = require("../../../config/DateSceneConfig");
const GameConfig_1 = require("../../../GameConfig");
const DatingEventSceneModel_1 = require("../../model/DatingEventSceneModel");
const ExtraStoryModelManager_1 = require("../../model/ExtraStoryModelManager");
const GameModelManager_1 = require("../../model/GameModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const ExtraPlotView_1 = require("../view/type/ExtraPlotView");
let ExtraPlotViewPresenter = /** @class */ (() => {
    let ExtraPlotViewPresenter = class ExtraPlotViewPresenter extends PresenterBase_1.Presenter {
        constructor() {
            super();
            this._tabbarId = 0;
            this._markButtonsY = [];
            this.onMarkButtonClickCallback = (tabbarId) => {
                let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
                let index = [];
                for (const id in cfg) {
                    if (cfg[id].DateType == EditorEnums_1.DateType.Date_Sp) {
                        index.push(cfg[id].chapter_index);
                    }
                }
                if (index.indexOf(tabbarId) == -1) {
                    UIManager_1.UIManager.showToast("敬请期待");
                    return;
                }
                this._viewState = ExtraPlotView_1.ExtraPlotViewState.List;
                this._tabbarId = tabbarId;
                this.risingAction();
            };
            this.onGotoShopButtonClickCallback = () => {
                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.onCloseButtonClickCallback = async () => {
                if (this._viewState == ExtraPlotView_1.ExtraPlotViewState.List) {
                    this.initViewDate();
                }
                else {
                    GameModelManager_1.GameModelManager.CloseExtraSceneView.emit();
                    GameModelManager_1.GameModelManager.setIsMainPlotSceneType(false);
                    this.view.close();
                }
            };
            this._viewProps = {
                onMarkButtonClickCallback: this.onMarkButtonClickCallback,
                onCloseButtonClickCallback: this.onCloseButtonClickCallback,
                onGotoShopButtonClickCallback: this.onGotoShopButtonClickCallback,
            };
        }
        onOpen() {
            super.onOpen(undefined);
            this.view.setProps(this._viewProps);
            this.onShow();
        }
        onShow() {
            super.onShow();
            if (this._viewState == ExtraPlotView_1.ExtraPlotViewState.List) {
                GameModelManager_1.GameModelManager.RefreshExtraPlotByType.emit(this._tabbarId);
            }
            else {
                this.initViewDate();
            }
        }
        onEnterBackground() {
            super.onEnterBackground();
        }
        onEnterForeground() {
            super.onEnterForeground();
        }
        onClose() {
            super.onClose();
        }
        initViewDate() {
            this._viewState = ExtraPlotView_1.ExtraPlotViewState.Choose;
            this.setMarkButtonsPosition();
            this.dropAction();
            this.updateRedDot();
        }
        setMarkButtonsPosition() {
            for (let i = 0; i < this.view.getMarkButtonNodes().length; i++) {
                let y = this.view.getMarkButtonNodes()[i].y;
                if (!this._markButtonsY[i]) {
                    this._markButtonsY.push(y);
                }
                this.view.getMarkButtonNodes()[i].y = this._markButtonsY[i] + cc.winSize.height;
            }
        }
        dropAction() {
            this.view.getMaskNode().active = true;
            GameModelManager_1.GameModelManager.RefreshExtraPlotByType.emit(0);
            for (let i = 0; i < this.view.getMarkButtonNodes().length; i++) {
                let node = this.view.getMarkButtonNodes()[i];
                cc.tween(node)
                    .to(0.8 + i * 0.1, { y: this._markButtonsY[i] }, { easing: 'backOut' })
                    .call(() => {
                    if (i == (this.view.getMarkButtonNodes().length - 1)) {
                        this.view.getMaskNode().active = false;
                    }
                })
                    .start();
            }
        }
        risingAction() {
            this.view.getMaskNode().active = true;
            for (let i = 0; i < this.view.getMarkButtonNodes().length; i++) {
                let node = this.view.getMarkButtonNodes()[i];
                cc.tween(node)
                    .to(0.8 + i * 0.1, { y: this._markButtonsY[i] + cc.winSize.height }, { easing: 'backIn' })
                    .call(() => {
                    if (i == (this.view.getMarkButtonNodes().length - 1)) {
                        GameModelManager_1.GameModelManager.RefreshExtraPlotByType.emit(this._tabbarId);
                        this.view.getMaskNode().active = false;
                    }
                })
                    .start();
            }
        }
        async updateRedDot() {
            for (let i = 0; i < this.view.getMarkButtonNodes().length; i++) {
                let node = this.view.getMarkButtonNodes()[i].getChildByName("RedDotSprite");
                node.active = false;
            }
            let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
            for (const id in cfg) {
                for (let i = 0; i < this.view.getMarkButtonNodes().length; i++) {
                    if (cfg[id].DateType == EditorEnums_1.DateType.Date_Sp && cfg[id].chapter_index == (i + 1)) {
                        await ExtraStoryModelManager_1.ExtraStoryModelManager.startBranches([cfg[id].start_plot_id]);
                        let branchStatus = ExtraStoryModelManager_1.ExtraStoryModelManager.getBranchStatus(Number(id), cfg[id].start_plot_id);
                        if (branchStatus == DatingEventSceneModel_1.DatingEventStatus.New || branchStatus == DatingEventSceneModel_1.DatingEventStatus.InProgress) {
                            let node = this.view.getMarkButtonNodes()[i].getChildByName("RedDotSprite");
                            node.active = true;
                        }
                    }
                }
            }
        }
    };
    ExtraPlotViewPresenter.uuid = "ExtraPlotViewPresenter";
    ExtraPlotViewPresenter = __decorate([
        PresenterCCViewFactory_1.RegPresenter(ExtraPlotView_1.ExtraPlotViewType)
    ], ExtraPlotViewPresenter);
    return ExtraPlotViewPresenter;
})();
exports.default = ExtraPlotViewPresenter;

cc._RF.pop();