f6da47ee-6dae-4b75-8329-44a46c55944b.js 4.7 KB
"use strict";
cc._RF.push(module, 'f6da4fuba5LdYMpRKRsVZRL', 'DiscoverSettingViewPresenter');
// script/game/ui/presenter/discover/DiscoverSettingViewPresenter.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.DiscoverSettingViewPresenter = void 0;
const PresenterCCViewFactory_1 = require("../../PresenterCCViewFactory");
const DiscoverSettingView_1 = require("../../view/type/discover/DiscoverSettingView");
const PresenterBase_1 = require("../../../../common/classbase/PresenterBase");
const GameBasicSettings_1 = require("../../../../common/gameplay/settings/GameBasicSettings");
const HttpRequests_1 = require("../../../network/HttpRequests");
const GameModelManager_1 = require("../../../model/GameModelManager");
const GameTextData_1 = require("../../../../common/gameplay/gamedata/GameTextData");
const UIManager_1 = require("../../../../common/gameplay/managers/UIManager");
const NoticeViewPresenter_1 = require("../NoticeViewPresenter");
const GameConfig_1 = require("../../../../GameConfig");
const ExchangeCodeViewPresenter_1 = require("../ExchangeCodeViewPresenter");
let DiscoverSettingViewPresenter = /** @class */ (() => {
    let DiscoverSettingViewPresenter = class DiscoverSettingViewPresenter extends PresenterBase_1.Presenter {
        constructor() {
            super(...arguments);
            this.toggleSound = () => {
                GameBasicSettings_1.GameBasicSettings.soundVolume = GameBasicSettings_1.GameBasicSettings.soundVolume > 0 ? 0 : 1;
                this.view.updateProps({
                    soundEnabled: GameBasicSettings_1.GameBasicSettings.soundVolume > 0
                });
            };
            this.toggleMusic = () => {
                GameBasicSettings_1.GameBasicSettings.musicVolume = GameBasicSettings_1.GameBasicSettings.musicVolume > 0 ? 0 : 1;
                this.view.updateProps({
                    musicEnabled: GameBasicSettings_1.GameBasicSettings.musicVolume > 0
                });
            };
            this.toggleNotice = () => {
                HttpRequests_1.HttpRequests.getNotice().then((ret) => {
                    if (ret != null && ret.length > 0) {
                        let titleTxt = GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.TEXT_NOTICETITLE_VALUE);
                        let contentTxt = ret[0].msg;
                        UIManager_1.UIManager.pushPresenter(NoticeViewPresenter_1.default, {
                            title: titleTxt,
                            content: contentTxt
                        });
                    }
                    else {
                        console.log("notice is not setting:" + `notice_${GameConfig_1.GameConfig.gameVersion}.json`);
                    }
                });
            };
            this.toggleExchangeCode = () => {
                let title = GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.TEXT_EXCHANGETITLE_VALUE);
                let content = "";
                UIManager_1.UIManager.pushPresenter(ExchangeCodeViewPresenter_1.default, {
                    titletxt: title,
                    contenttxt: content
                });
            };
        }
        onOpen() {
            super.onOpen(undefined);
            this.view.setProps({
                soundEnabled: GameBasicSettings_1.GameBasicSettings.soundVolume > 0,
                musicEnabled: GameBasicSettings_1.GameBasicSettings.musicVolume > 0,
                onToggleSound: this.toggleSound,
                onToggleMusic: this.toggleMusic,
                onToggleNotice: this.toggleNotice,
                onToggleExchangeCode: this.toggleExchangeCode
            });
        }
        onClose() {
            super.onClose();
            UIManager_1.UIManager.popToPresenter(this);
        }
    };
    DiscoverSettingViewPresenter.uuid = "DiscoverSettingViewPresenter";
    DiscoverSettingViewPresenter = __decorate([
        PresenterCCViewFactory_1.RegPresenter(DiscoverSettingView_1.DiscoverSettingViewType)
    ], DiscoverSettingViewPresenter);
    return DiscoverSettingViewPresenter;
})();
exports.DiscoverSettingViewPresenter = DiscoverSettingViewPresenter;

cc._RF.pop();