未验证 提交 aad38f96 编写于 作者: G GitSquared

🔊 Add some more FX & 'extraAudio' setting

don't blow your ears fellas
上级 788a8453
...@@ -62,7 +62,8 @@ if (!fs.existsSync(settingsFile)) { ...@@ -62,7 +62,8 @@ if (!fs.existsSync(settingsFile)) {
cwd: electron.app.getPath("userData"), cwd: electron.app.getPath("userData"),
keyboard: "en-US", keyboard: "en-US",
theme: "tron", theme: "tron",
audio: false audio: true,
extraAudio: false
}, 4)); }, 4));
} }
......
...@@ -270,6 +270,7 @@ function initUI() { ...@@ -270,6 +270,7 @@ function initUI() {
</section>`; </section>`;
setTimeout(() => { setTimeout(() => {
window.audioManager.scan.play();
document.getElementById("main_shell").setAttribute("style", "height:0%;margin-bottom:30vh;"); document.getElementById("main_shell").setAttribute("style", "height:0%;margin-bottom:30vh;");
setTimeout(() => { setTimeout(() => {
document.getElementById("main_shell").setAttribute("style", "margin-bottom: 30vh;"); document.getElementById("main_shell").setAttribute("style", "margin-bottom: 30vh;");
...@@ -455,8 +456,8 @@ window.remakeKeyboard = (layout) => { ...@@ -455,8 +456,8 @@ window.remakeKeyboard = (layout) => {
}; };
window.focusShellTab = (number) => { window.focusShellTab = (number) => {
window.audioManager.beep3.play(); window.audioManager.beep2.play();
if (number !== window.currentTerm && window.term[number]) { if (number !== window.currentTerm && window.term[number]) {
window.currentTerm = number; window.currentTerm = number;
......
...@@ -3,32 +3,65 @@ class AudioManager { ...@@ -3,32 +3,65 @@ class AudioManager {
const path = require("path"); const path = require("path");
const {Howl, Howler} = require("howler"); const {Howl, Howler} = require("howler");
// Load sounds if (window.settings.audio === true) {
this.beep1 = new Howl({ this.beep1 = new Howl({
src: [path.join(__dirname, "assets", "audio", "beep1.wav")] src: [path.join(__dirname, "assets", "audio", "beep1.wav")]
}); });
this.beep2 = new Howl({ this.beep2 = new Howl({
src: [path.join(__dirname, "assets", "audio", "beep2.wav")] src: [path.join(__dirname, "assets", "audio", "beep2.wav")]
}); });
this.beep3 = new Howl({ this.beep3 = new Howl({
src: [path.join(__dirname, "assets", "audio", "beep3.wav")] src: [path.join(__dirname, "assets", "audio", "beep3.wav")],
}); volume: 0.6
this.beep4 = new Howl({ });
src: [path.join(__dirname, "assets", "audio", "beep4.wav")] this.beep4 = new Howl({
}); src: [path.join(__dirname, "assets", "audio", "beep4.wav")]
this.intro = new Howl({ });
src: [path.join(__dirname, "assets", "audio", "intro.wav")] this.dismiss = new Howl({
}); src: [path.join(__dirname, "assets", "audio", "dismiss.wav")]
this.dismiss = new Howl({ });
src: [path.join(__dirname, "assets", "audio", "dismiss.wav")] this.alarm = new Howl({
}); src: [path.join(__dirname, "assets", "audio", "alarm.wav")]
this.alarm = new Howl({ });
src: [path.join(__dirname, "assets", "audio", "alarm.wav")] this.info = new Howl({
}); src: [path.join(__dirname, "assets", "audio", "info.wav")]
});
if (window.settings.audio !== true) { } else {
Howler.volume(0.0); Howler.volume(0.0);
} }
if (window.settings.extraAudio === true) {
this.beep5 = new Howl({
src: [path.join(__dirname, "assets", "audio", "beep5.wav")]
});
this.intro = new Howl({
src: [path.join(__dirname, "assets", "audio", "intro.wav")]
});
this.scan = new Howl({
src: [path.join(__dirname, "assets", "audio", "scan.wav")]
});
this.ping = new Howl({
src: [path.join(__dirname, "assets", "audio", "ping.wav")],
volume: 0.02
});
this.pingFailed = new Howl({
src: [path.join(__dirname, "assets", "audio", "pingFailed.wav")],
volume: 0.02
});
}
// Return a proxy to avoid errors if sounds aren't loaded
return new Proxy(this, {
get: (target, sound) => {
if (sound in target) {
return target[sound];
} else {
return {
play: () => {return true;}
}
}
}
});
} }
} }
......
...@@ -8,6 +8,8 @@ class Clock { ...@@ -8,6 +8,8 @@ class Clock {
<h1 id="mod_clock_text"><span>?</span><span>?</span><span>:</span><span>?</span><span>?</span><span>:</span><span>?</span><span>?</span></h1> <h1 id="mod_clock_text"><span>?</span><span>?</span><span>:</span><span>?</span><span>?</span><span>:</span><span>?</span><span>?</span></h1>
</div>`; </div>`;
this.lastTime = new Date();
this.updateClock(); this.updateClock();
this.updater = setInterval(() => { this.updater = setInterval(() => {
this.updateClock(); this.updateClock();
...@@ -16,6 +18,11 @@ class Clock { ...@@ -16,6 +18,11 @@ class Clock {
updateClock() { updateClock() {
let time = new Date(); let time = new Date();
let array = [time.getHours(), time.getMinutes(), time.getSeconds()]; let array = [time.getHours(), time.getMinutes(), time.getSeconds()];
if (this.lastTime.getMinutes() !== array[1]) {
window.audioManager.beep5.play();
}
array.forEach((e, i) => { array.forEach((e, i) => {
if (e.toString().length !== 2) { if (e.toString().length !== 2) {
array[i] = "0"+e; array[i] = "0"+e;
...@@ -29,6 +36,7 @@ class Clock { ...@@ -29,6 +36,7 @@ class Clock {
else clockString += "<span>"+e+"</span>"; else clockString += "<span>"+e+"</span>";
}); });
document.getElementById("mod_clock_text").innerHTML = clockString; document.getElementById("mod_clock_text").innerHTML = clockString;
this.lastTime = time;
} }
} }
......
...@@ -919,6 +919,7 @@ class Keyboard { ...@@ -919,6 +919,7 @@ class Keyboard {
// Keep focus on the terminal // Keep focus on the terminal
window.term[window.currentTerm].term.focus(); window.term[window.currentTerm].term.focus();
window.audioManager.beep2.play();
e.preventDefault(); e.preventDefault();
}; };
key.onmouseup = () => { key.onmouseup = () => {
...@@ -959,6 +960,7 @@ class Keyboard { ...@@ -959,6 +960,7 @@ class Keyboard {
// Keep focus on the terminal // Keep focus on the terminal
window.term[window.currentTerm].term.focus(); window.term[window.currentTerm].term.focus();
window.audioManager.beep3.play();
e.preventDefault(); e.preventDefault();
}; };
key.onmouseup = (e) => { key.onmouseup = (e) => {
...@@ -1072,6 +1074,7 @@ class Keyboard { ...@@ -1072,6 +1074,7 @@ class Keyboard {
} else { } else {
key.setAttribute("class", "keyboard_key active"); key.setAttribute("class", "keyboard_key active");
} }
window.audioManager.beep3.play();
}; };
document.onkeyup = (e) => { document.onkeyup = (e) => {
...@@ -1092,6 +1095,10 @@ class Keyboard { ...@@ -1092,6 +1095,10 @@ class Keyboard {
key.setAttribute("class", "keyboard_key"); key.setAttribute("class", "keyboard_key");
}, 100); }, 100);
} }
if (e.key === "Enter") {
window.audioManager.beep2.play();
}
}; };
} }
} }
......
...@@ -67,7 +67,7 @@ class Modal { ...@@ -67,7 +67,7 @@ class Modal {
window.audioManager.alarm.play(); window.audioManager.alarm.play();
break; break;
default: default:
window.audioManager.beep2.play(); window.audioManager.info.play();
break; break;
} }
window.modals[this.id] = this; window.modals[this.id] = this;
......
...@@ -102,8 +102,10 @@ class Netstat { ...@@ -102,8 +102,10 @@ class Netstat {
if (data === -1) { if (data === -1) {
ping = "--ms"; ping = "--ms";
offline = true; offline = true;
window.audioManager.pingFailed.play();
} else { } else {
ping = Math.round(data)+"ms"; ping = Math.round(data)+"ms";
window.audioManager.ping.play();
} }
this.offline = offline; this.offline = offline;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册