d6853a5b-58c9-424e-aa25-3c72b4d58c87.js 1.86 KB
"use strict";
cc._RF.push(module, 'd6853pbWMlCTqolPHK01YyH', 'GameBasicSettings');
// script/common/gameplay/settings/GameBasicSettings.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GameBasicSettings = void 0;
const simba_localstorage_1 = require("simba-localstorage");
const simba_utils_1 = require("simba-utils");
const BaseEvents_1 = require("../../event/BaseEvents");
let musicVolume = simba_localstorage_1.LocalStorage.getFloat("_musicVolume", 1);
let soundVolume = simba_localstorage_1.LocalStorage.getFloat("_soundVolume", 1);
let enableVibration = simba_localstorage_1.LocalStorage.getBoolean("_enableVibration", true);
const saveMusicVolume = simba_utils_1.debounce(() => {
    simba_localstorage_1.LocalStorage.setFloat("_musicVolume", musicVolume);
}, 500);
const saveSoundVolume = simba_utils_1.debounce(() => {
    simba_localstorage_1.LocalStorage.setFloat("_soundVolume", soundVolume);
}, 500);
const saveEnableVibration = simba_utils_1.debounce(() => {
    simba_localstorage_1.LocalStorage.setBoolean("_enableVibration", enableVibration);
}, 500);
exports.GameBasicSettings = {
    get musicVolume() { return musicVolume; },
    set musicVolume(v) {
        v = Math.min(1, Math.max(0, v));
        if (v != musicVolume) {
            musicVolume = v;
            BaseEvents_1.SettingEvents.MusicVolumeChange.emit(musicVolume);
            saveMusicVolume();
        }
    },
    get soundVolume() { return soundVolume; },
    set soundVolume(v) {
        v = Math.min(1, Math.max(0, v));
        if (v != soundVolume) {
            soundVolume = v;
            BaseEvents_1.SettingEvents.SoundVolumeChange.emit(soundVolume);
            saveSoundVolume();
        }
    },
    get enableVibration() { return enableVibration; },
    set enableVibration(v) {
        enableVibration = v;
        saveEnableVibration();
    }
};

cc._RF.pop();