}
game.settings['keyboard']['tapmode'] = ui.querySelector('input[value="tapmode"]').checked;
window['localStorage'].setItem('upInTheAirGameSettings', JSON.stringify(game.settings));
+
for(let audioCategory of ['music', 'sounds']) {
game.settings['audio'][audioCategory] = parseInt(ui.querySelector('.audio input[type=range].' + audioCategory).value, 10) / 100;
let value = Math.round(100 * game.settings['audio'][audioCategory]);
elem.value = value;
elem.parentNode.nextElementSibling.innerText = value;
});
- if(audioCategory == 'music') {
+ if(audioCategory == 'music' && game.view) {
game.view.music.setVolume(game.settings['audio'][audioCategory]);
}
}
+ game.ui.root.classList.remove('font-atkinson', 'font-opendyslexic');
+ if(game.settings['font'] != 'standard') {
+ game.ui.root.classList.add('font-' + game.settings['font']);
+ }
}
window['game'] = {
game.view.camera.add(audioListener);
game.view.music = new THREE.Audio(audioListener);
game.view.music.setBuffer(game.assets.audio.music);
- game.view.music.setVolume(0.5);
+ game.view.music.setVolume(game.settings['audio']['music']);
}
let target = e.target.closest('button');
game.ui.moveToPage(Array.from(target.classList).filter(c => c != 'goto')[0]);
});
});
+game.ui.root.querySelectorAll('.options .controls input, .options .graphics input, .options .feather input, .options .accessibility input').forEach((radioOrCb) => {
+ radioOrCb.addEventListener('change', () => applySettings(game));
+});
game.ui.root.querySelectorAll('.ui-page .audio input[type=range]').forEach((elem) => {
elem.addEventListener('input', (e) => {
let audioCategory = Array.from(e.target.classList).filter(v => ['music', 'sounds'].includes(v))[0];
}
});
});
-function checkFontSelection() {
- const checked = document.querySelector('input[name=upInTheAirGame-font]:checked');
- if(!checked) {
- return;
- }
- const newFont = checked.value;
- game.ui.root.classList.remove('font-atkinson', 'font-opendyslexic');
- if(newFont != 'standard') {
- game.ui.root.classList.add('font-' + newFont);
- }
-}
-checkFontSelection();
-game.ui.root.querySelectorAll('.options input[name=upInTheAirGame-font]').forEach((radio) => {
- radio.addEventListener('change', e => checkFontSelection());
-});
game.ui.root.querySelectorAll('.options .controls input').forEach((radio) => {
- radio.addEventListener('change', (e) => {
- e.target.closest('.controls').querySelectorAll('span:not(.' + e.target.value + ')').forEach(span => span.style.display = 'none');
- e.target.closest('.controls').querySelector('span.' + e.target.value).style.display = 'block';
- });
+ radio.addEventListener('change', () => applySettings(game));
+});
+game.ui.root.querySelectorAll('.options input[name=upInTheAirGame-font]').forEach((radio) => {
+ radio.addEventListener('change', () => applySettings(game));
});
game.ui.root.querySelectorAll('.ui-page .areatabs button').forEach((btn) => {
btn.addEventListener('click', (e) => {