|
|
@ -103,9 +103,6 @@ export class SoundInterface {
|
|
|
|
|
|
|
|
|
|
|
|
this.pageIsVisible = true;
|
|
|
|
this.pageIsVisible = true;
|
|
|
|
|
|
|
|
|
|
|
|
this.musicMuted = false;
|
|
|
|
|
|
|
|
this.soundsMuted = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.musicVolume = 1.0;
|
|
|
|
this.musicVolume = 1.0;
|
|
|
|
this.soundVolume = 1.0;
|
|
|
|
this.soundVolume = 1.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,13 +124,11 @@ export class SoundInterface {
|
|
|
|
this.music[musicPath] = music;
|
|
|
|
this.music[musicPath] = music;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.musicMuted = this.app.settings.getAllSettings().musicMuted;
|
|
|
|
|
|
|
|
this.soundsMuted = this.app.settings.getAllSettings().soundsMuted;
|
|
|
|
|
|
|
|
this.musicVolume = this.app.settings.getAllSettings().musicVolume;
|
|
|
|
this.musicVolume = this.app.settings.getAllSettings().musicVolume;
|
|
|
|
this.soundVolume = this.app.settings.getAllSettings().soundVolume;
|
|
|
|
this.soundVolume = this.app.settings.getAllSettings().soundVolume;
|
|
|
|
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.disableMusic) {
|
|
|
|
if (G_IS_DEV && globalConfig.debug.disableMusic) {
|
|
|
|
this.musicMuted = true;
|
|
|
|
this.musicVolume = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Promise.resolve();
|
|
|
|
return Promise.resolve();
|
|
|
@ -170,47 +165,6 @@ export class SoundInterface {
|
|
|
|
return Promise.all(...promises);
|
|
|
|
return Promise.all(...promises);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns if the music is muted
|
|
|
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
getMusicMuted() {
|
|
|
|
|
|
|
|
return this.musicMuted;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns if sounds are muted
|
|
|
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
getSoundsMuted() {
|
|
|
|
|
|
|
|
return this.soundsMuted;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Sets if the music is muted
|
|
|
|
|
|
|
|
* @param {boolean} muted
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
setMusicMuted(muted) {
|
|
|
|
|
|
|
|
this.musicMuted = muted;
|
|
|
|
|
|
|
|
if (this.musicMuted) {
|
|
|
|
|
|
|
|
if (this.currentMusic) {
|
|
|
|
|
|
|
|
this.currentMusic.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (this.currentMusic) {
|
|
|
|
|
|
|
|
this.currentMusic.play(this.musicVolume);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Sets if the sounds are muted
|
|
|
|
|
|
|
|
* @param {boolean} muted
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
setSoundsMuted(muted) {
|
|
|
|
|
|
|
|
this.soundsMuted = muted;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the music volume
|
|
|
|
* Returns the music volume
|
|
|
|
* @returns {number}
|
|
|
|
* @returns {number}
|
|
|
@ -254,7 +208,7 @@ export class SoundInterface {
|
|
|
|
this.pageIsVisible = pageIsVisible;
|
|
|
|
this.pageIsVisible = pageIsVisible;
|
|
|
|
if (this.currentMusic) {
|
|
|
|
if (this.currentMusic) {
|
|
|
|
if (pageIsVisible) {
|
|
|
|
if (pageIsVisible) {
|
|
|
|
if (!this.currentMusic.isPlaying() && !this.musicMuted) {
|
|
|
|
if (!this.currentMusic.isPlaying()) {
|
|
|
|
this.currentMusic.play(this.musicVolume);
|
|
|
|
this.currentMusic.play(this.musicVolume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -267,9 +221,6 @@ export class SoundInterface {
|
|
|
|
* @param {string} key
|
|
|
|
* @param {string} key
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
playUiSound(key) {
|
|
|
|
playUiSound(key) {
|
|
|
|
if (this.soundsMuted) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.sounds[key]) {
|
|
|
|
if (!this.sounds[key]) {
|
|
|
|
logger.warn("Sound", key, "not found, probably not loaded yet");
|
|
|
|
logger.warn("Sound", key, "not found, probably not loaded yet");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -288,7 +239,7 @@ export class SoundInterface {
|
|
|
|
logger.warn("Music", key, "not found, probably not loaded yet");
|
|
|
|
logger.warn("Music", key, "not found, probably not loaded yet");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!this.pageIsVisible || this.soundsMuted) {
|
|
|
|
if (!this.pageIsVisible) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -319,7 +270,7 @@ export class SoundInterface {
|
|
|
|
this.currentMusic.stop();
|
|
|
|
this.currentMusic.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.currentMusic = music;
|
|
|
|
this.currentMusic = music;
|
|
|
|
if (music && this.pageIsVisible && !this.musicMuted) {
|
|
|
|
if (music && this.pageIsVisible) {
|
|
|
|
logger.log("Starting", this.currentMusic.key);
|
|
|
|
logger.log("Starting", this.currentMusic.key);
|
|
|
|
music.play(this.musicVolume);
|
|
|
|
music.play(this.musicVolume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|