make music a sound set - closes #1928
This commit is contained in:
parent
092c54aec5
commit
e60b86b491
|
@ -9,7 +9,7 @@ net {
|
|||
ip = "5.196.91.160"
|
||||
asset {
|
||||
domain = ${net.domain}
|
||||
version = 936
|
||||
version = 939
|
||||
}
|
||||
}
|
||||
forcedev = false
|
||||
|
|
|
@ -35,5 +35,6 @@ object SoundSet extends SoundSetObject {
|
|||
new SoundSet("nes", "NES"),
|
||||
new SoundSet("sfx", "SFX"),
|
||||
new SoundSet("futuristic", "Futuristic"),
|
||||
new SoundSet("robot", "Robot"))
|
||||
new SoundSet("robot", "Robot"),
|
||||
new SoundSet("music", "Music"))
|
||||
}
|
||||
|
|
|
@ -902,9 +902,16 @@ lichess.notifyApp = (function() {
|
|||
confirmation: 0.5
|
||||
};
|
||||
var collection = new $.lazy(function(k) {
|
||||
var set = soundSet;
|
||||
if (set === 'music') {
|
||||
if (k === 'move' || k === 'capture' || k === 'check') return {
|
||||
play: $.noop
|
||||
};
|
||||
set = 'standard';
|
||||
}
|
||||
return new Howl({
|
||||
src: ['ogg', 'mp3'].map(function(ext) {
|
||||
return [baseUrl, soundSet, names[k] + '.' + ext + '?v=' + version].join('/');
|
||||
return [baseUrl, set, names[k] + '.' + ext + '?v=' + version].join('/');
|
||||
}),
|
||||
volume: volumes[k] || 1
|
||||
});
|
||||
|
@ -915,16 +922,7 @@ lichess.notifyApp = (function() {
|
|||
return soundSet !== 'silent';
|
||||
};
|
||||
$toggle.toggleClass('sound_state_on', enabled());
|
||||
var player = function(s) {
|
||||
return function() {
|
||||
if (enabled()) collection(s).play();
|
||||
};
|
||||
}
|
||||
var play = {
|
||||
disable: function() {
|
||||
soundSet = 'silent';
|
||||
}
|
||||
};
|
||||
var play = {};
|
||||
Object.keys(names).forEach(function(name) {
|
||||
play[name] = function() {
|
||||
if (enabled()) collection(name).play();
|
||||
|
@ -938,6 +936,10 @@ lichess.notifyApp = (function() {
|
|||
setVolume(v);
|
||||
play.move(true);
|
||||
}, 50);
|
||||
var publish = function() {
|
||||
$('body').trigger('lichess.sound_set', soundSet);
|
||||
};
|
||||
setTimeout(publish, 500);
|
||||
$toggle.one('mouseover', function() {
|
||||
lichess.slider().done(function() {
|
||||
$toggle.parent().find('.slider').slider({
|
||||
|
@ -961,10 +963,12 @@ lichess.notifyApp = (function() {
|
|||
set: soundSet
|
||||
});
|
||||
$toggle.toggleClass('sound_state_on', enabled());
|
||||
publish();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
return play;
|
||||
})();
|
||||
|
||||
|
|
|
@ -30,26 +30,28 @@ function lichessLobbyMusic() {
|
|||
orchestra.play(instrument, pitch);
|
||||
};
|
||||
|
||||
lichess.shepherd(function(theme) {
|
||||
var tour = new Shepherd.Tour({
|
||||
defaults: {
|
||||
classes: theme,
|
||||
scrollTo: false
|
||||
}
|
||||
lichess.once('lobby-music', function() {
|
||||
lichess.shepherd(function(theme) {
|
||||
var tour = new Shepherd.Tour({
|
||||
defaults: {
|
||||
classes: theme,
|
||||
scrollTo: false
|
||||
}
|
||||
});
|
||||
tour.addStep('music', {
|
||||
title: 'Music from lichess seeks',
|
||||
text: "Blitz seeks play the clavier.<br>" +
|
||||
"Classical and bullet play celesta.<br>" +
|
||||
"Variants play the swells.<br>" +
|
||||
"Rating determines the pitch.",
|
||||
attachTo: '#hooks_wrap left',
|
||||
buttons: [{
|
||||
text: 'OK',
|
||||
action: tour.next
|
||||
}],
|
||||
});
|
||||
tour.start();
|
||||
});
|
||||
tour.addStep('music', {
|
||||
title: 'Music from lichess seeks',
|
||||
text: "Blitz seeks play the clavier.<br>" +
|
||||
"Classical and bullet play celesta.<br>" +
|
||||
"Variants play the swells.<br>" +
|
||||
"Rating determines the pitch.",
|
||||
attachTo: '#hooks_wrap left',
|
||||
buttons: [{
|
||||
text: 'OK',
|
||||
action: tour.next
|
||||
}],
|
||||
});
|
||||
tour.start();
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
@ -4,7 +4,6 @@ function lichessPlayMusic() {
|
|||
|
||||
lichess.loadScript('/assets/javascripts/music/orchestra.js').then(function() {
|
||||
orchestra = lichessOrchestra();
|
||||
$.sound.disable();
|
||||
});
|
||||
|
||||
var isPawn = function(san) {
|
||||
|
|
|
@ -4,7 +4,6 @@ function lichessReplayMusic() {
|
|||
|
||||
lichess.loadScript('/assets/javascripts/music/orchestra.js').then(function() {
|
||||
orchestra = lichessOrchestra();
|
||||
$.sound.disable();
|
||||
});
|
||||
|
||||
var isPawn = function(san) {
|
||||
|
|
|
@ -1527,7 +1527,7 @@ body #themepicker div.is3d,
|
|||
#sound_control .slider {
|
||||
float: right;
|
||||
width: 10px;
|
||||
height: 153px;
|
||||
height: 168px;
|
||||
}
|
||||
#sound_control .slider .ui-slider-handle {
|
||||
margin: 0 0 -9px -3px;
|
||||
|
|
|
@ -466,11 +466,12 @@ module.exports = function(opts) {
|
|||
this.explorer.setNode();
|
||||
this.study = opts.study ? studyCtrl.init(opts.study, opts.chat, this) : null;
|
||||
|
||||
var startMusic = function() {
|
||||
if (!this.music) lichess.loadScript('/assets/javascripts/music/replay.js').then(function() {
|
||||
this.music = lichessReplayMusic();
|
||||
}.bind(this));
|
||||
}.bind(this);
|
||||
Mousetrap.bind(': m u s i c', startMusic);
|
||||
if (location.hash === '#music') startMusic();
|
||||
this.music = null;
|
||||
$('body').on('lichess.sound_set', function(e, set) {
|
||||
if (!this.music && set === 'music')
|
||||
lichess.loadScript('/assets/javascripts/music/replay.js').then(function() {
|
||||
this.music = lichessReplayMusic();
|
||||
}.bind(this));
|
||||
if (this.music && set !== 'music') this.music = null;
|
||||
}.bind(this));
|
||||
};
|
||||
|
|
|
@ -34,13 +34,13 @@ module.exports = function(send, ctrl) {
|
|||
return false;
|
||||
}.bind(this);
|
||||
|
||||
var startMusic = function() {
|
||||
if (!this.music) lichess.loadScript('/assets/javascripts/music/lobby.js').then(function() {
|
||||
this.music = lichessLobbyMusic();
|
||||
ctrl.setMode('chart');
|
||||
}.bind(this));
|
||||
}.bind(this);
|
||||
|
||||
Mousetrap.bind(': m u s i c', startMusic);
|
||||
if (location.hash === '#music') startMusic();
|
||||
this.music = null;
|
||||
$('body').on('lichess.sound_set', function(e, set) {
|
||||
if (!this.music && set === 'music')
|
||||
lichess.loadScript('/assets/javascripts/music/lobby.js').then(function() {
|
||||
this.music = lichessLobbyMusic();
|
||||
ctrl.setMode('chart');
|
||||
}.bind(this));
|
||||
if (this.music && set !== 'music') this.music = null;
|
||||
}.bind(this));
|
||||
};
|
||||
|
|
|
@ -471,11 +471,12 @@ module.exports = function(opts) {
|
|||
|
||||
onChange();
|
||||
|
||||
var startMusic = function() {
|
||||
if (!this.music) lichess.loadScript('/assets/javascripts/music/play.js').then(function() {
|
||||
this.music = lichessPlayMusic();
|
||||
}.bind(this));
|
||||
}.bind(this);
|
||||
Mousetrap.bind(': m u s i c', startMusic);
|
||||
if (location.hash === '#music') startMusic();
|
||||
this.music = null;
|
||||
$('body').on('lichess.sound_set', function(e, set) {
|
||||
if (!this.music && set === 'music')
|
||||
lichess.loadScript('/assets/javascripts/music/play.js').then(function() {
|
||||
this.music = lichessPlayMusic();
|
||||
}.bind(this));
|
||||
if (this.music && set !== 'music') this.music = null;
|
||||
}.bind(this));
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue