44fa1ecc-7d51-4cf6-8c85-6b51e158d85d.js 6 KB
"use strict";
cc._RF.push(module, '44fa17MfVFM9oyFa1HhWNhd', 'DiscoverViewPresenter');
// script/game/ui/presenter/DiscoverViewPresenter.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_sdk_1 = require("simba-sdk");
const AVG_1 = require("../../../avg/AVG");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const GameModelManager_1 = require("../../model/GameModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const DiscoverView_1 = require("../view/type/DiscoverView");
const DiscoverSettingViewPresenter_1 = require("./discover/DiscoverSettingViewPresenter");
const GameTextData_1 = require("../../../common/gameplay/gamedata/GameTextData");
const Enums_1 = require("../../Enums");
const QRCodeViewPresenter_1 = require("./QRCodeViewPresenter");
const GameDotMgr_1 = require("../../GameDotMgr");
const ProductionTeamViewPresenter_1 = require("./discover/ProductionTeamViewPresenter");
let DiscoverViewPresenter = /** @class */ (() => {
    let DiscoverViewPresenter = class DiscoverViewPresenter extends PresenterBase_1.Presenter {
        constructor() {
            super();
            this.itemClickCallBack = (itemType) => {
                switch (itemType) {
                    case Enums_1.DiscoverItemType.Settings:
                        this.hideGameClubBtn();
                        UIManager_1.UIManager.pushPresenter(DiscoverSettingViewPresenter_1.DiscoverSettingViewPresenter, undefined);
                        break;
                    case Enums_1.DiscoverItemType.Forum:
                        break;
                    case Enums_1.DiscoverItemType.CustomerService:
                        this.hideGameClubBtn();
                        //点击二维码打点
                        GameDotMgr_1.default.getInstance().dotClickUI("CustomerService");
                        UIManager_1.UIManager.pushPresenter(QRCodeViewPresenter_1.default, undefined);
                        break;
                    case Enums_1.DiscoverItemType.ProductionTeam:
                        this.hideGameClubBtn();
                        //点击二维码打点
                        UIManager_1.UIManager.pushPresenter(ProductionTeamViewPresenter_1.default, undefined);
                        break;
                    default:
                        UIManager_1.UIManager.showToast(GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_DEVELOPING_VALUE));
                        break;
                }
            };
            this.onCopyInfo = async () => {
                await simba_sdk_1.SDK.setClipboardData(this._viewProps.manId);
                UIManager_1.UIManager.showToast("用户ID:" + this._viewProps.manId);
            };
            this.onForceEnterDiscoverSubView = (itemType) => {
                this.itemClickCallBack(itemType);
            };
            this.onPlayerOptionSkin = () => {
                this.initViewProps();
                this.initItemConfig();
                this._view.updateProps(this._viewProps);
            };
        }
        static isShowRedDot() {
            return false;
        }
        initViewProps() {
            this._viewProps = {
                manName: "",
                manId: "",
                manIcon: "",
                onCopyInfo: this.onCopyInfo,
                onItemClick: this.itemClickCallBack
            };
        }
        initItemConfig() {
            var _a, _b;
            this._viewProps.manName = AVG_1.GameRecord.globalVariables.playerName;
            if ((_a = simba_sdk_1.SDK.getLoginInfo()) === null || _a === void 0 ? void 0 : _a.playerId) {
                this._viewProps.manId = (_b = simba_sdk_1.SDK.getLoginInfo()) === null || _b === void 0 ? void 0 : _b.playerId;
            }
            let player = GameModelManager_1.GameModelManager.getPlayerData();
            this._viewProps.manName = player.getConfig().name;
            this._viewProps.manIcon = player.getHeadIcon();
        }
        onOpen() {
            super.onOpen(undefined);
            this._disposable.add(GameModelManager_1.GameModelManager.PlayerOptionSkin.on(this.onPlayerOptionSkin));
            this._disposable.add(GameModelManager_1.GameModelManager.ForceEnterDiscoverSubView.on(this.onForceEnterDiscoverSubView));
            this.onShow();
        }
        onShow() {
            super.onShow();
            this.initViewProps();
            this.initItemConfig();
            this.view.setProps(this._viewProps);
            this.view.createGameClubBtn();
            this.showGameClubBtn();
        }
        onEnterBackground() {
            super.onEnterBackground();
            this.hideGameClubBtn();
        }
        onEnterForeground() {
            super.onEnterForeground();
            this.showGameClubBtn();
        }
        onHide() {
            super.onHide();
            simba_sdk_1.SDK.destroyGameClubButton();
        }
        showGameClubBtn() {
            simba_sdk_1.SDK.showGameClubButton();
        }
        hideGameClubBtn() {
            simba_sdk_1.SDK.hideGameClubButton();
        }
    };
    DiscoverViewPresenter.uuid = "DiscoverViewPresenter";
    DiscoverViewPresenter = __decorate([
        PresenterCCViewFactory_1.RegPresenter(DiscoverView_1.DiscoverViewType)
    ], DiscoverViewPresenter);
    return DiscoverViewPresenter;
})();
exports.default = DiscoverViewPresenter;

cc._RF.pop();