Просмотр исходного кода

Merge branch '1473-ui-sounds-mod' of gitlab.com:Isleward/isleward into 1473-ui-sounds-mod

tags/v0.7.0^2
Vildravn 4 лет назад
Родитель
Сommit
e08f7c30f7
2 измененных файлов: 18 добавлений и 9 удалений
  1. +17
    -8
      src/client/js/sound/sound.js
  2. +1
    -1
      src/server/components/social.js

+ 17
- 8
src/client/js/sound/sound.js Просмотреть файл

@@ -14,13 +14,15 @@ define([
const globalScopes = ['ui'];
const minDistance = 10;
const globalVolume = 0.3;
const fadeDuration = 3000;
const fadeDuration = 1800;

return {
sounds: [],

muted: false,

currentMusic: null,

init: function () {
events.on('onToggleAudio', this.onToggleAudio.bind(this));
events.on('onPlaySound', this.playSound.bind(this));
@@ -85,7 +87,7 @@ define([

sound.volume(volume);
} else {
sound.volume(1);
sound.volume(volume);
sound.play();
}
},
@@ -101,12 +103,17 @@ define([
return;
}

if (sound.playing())
if (!sound.playing()) {
sound.volume(0);
sound.play();
}

if (this.currentMusic === soundEntry)
return;

sound.volume(0);
sound.play();
sound.fade(0, globalVolume, fadeDuration);
this.currentMusic = soundEntry;
sound.fade(sound.volume(), globalVolume, fadeDuration);
},

stopSoundHelper: function (soundEntry) {
@@ -117,8 +124,10 @@ define([

if (music)
sound.fade(sound.volume(), 0, fadeDuration);
else
else {
sound.stop();
sound.volume(0);
}
},

updateSounds: function (playerX, playerY) {
@@ -161,7 +170,7 @@ define([
if (defaultMusic)
this.playMusicHelper(defaultMusic);

const activeMusic = sounds.filter(s => s.music && s !== defaultMusic && s.sound && s.sound.playing());
const activeMusic = sounds.filter(s => s.music && s !== defaultMusic);
activeMusic.forEach(s => this.stopSoundHelper(s));
} else {
if (defaultMusic)


+ 1
- 1
src/server/components/social.js Просмотреть файл

@@ -421,7 +421,7 @@ module.exports = {
const { obj: { id, serverId, instance: { syncer } } } = this;

messages.forEach(m => {
const { className = 'color-redA', type = 'info ', subType } = m;
const { className = 'color-redA', type = 'info', subType } = m;
m.className = className;
m.type = type;
m.subType = subType;


Загрузка…
Отмена
Сохранить