d6853a5b-58c9-424e-aa25-3c72b4d58c87.js
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"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();