2020-04-16 00:15:44 +00:00
|
|
|
|
|
|
|
var debug = true;
|
2020-04-22 21:15:14 +00:00
|
|
|
var clientSettings = {};
|
2020-04-16 00:15:44 +00:00
|
|
|
var clientSettingsPath = "./settings.json";
|
2020-04-24 03:05:54 +00:00
|
|
|
|
2020-04-16 00:15:44 +00:00
|
|
|
if (fs.existsSync(clientSettingsPath)) {
|
|
|
|
loadClientSettings();
|
|
|
|
} else {
|
2020-04-24 03:05:54 +00:00
|
|
|
initSettings();
|
2020-04-16 00:15:44 +00:00
|
|
|
}
|
|
|
|
function saveClientSettings() {
|
|
|
|
DB.save(clientSettingsPath, clientSettings);
|
|
|
|
}
|
2020-04-24 03:05:54 +00:00
|
|
|
function initSettings() {
|
|
|
|
if (!clientSettings.hasOwnProperty("debug")) {
|
2020-04-22 21:15:14 +00:00
|
|
|
clientSettings.debug = false;
|
|
|
|
}
|
2020-04-24 03:05:54 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("accentColor")) {
|
2020-04-22 21:15:14 +00:00
|
|
|
clientSettings.accentColor = {
|
|
|
|
"r": 50,
|
|
|
|
"g": 50,
|
|
|
|
"b": 50,
|
|
|
|
"a": 0.9
|
|
|
|
};
|
|
|
|
}
|
2020-04-24 03:05:54 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("rainbowEnabled")) {
|
2020-04-22 21:15:14 +00:00
|
|
|
clientSettings.rainbowEnabled = true;
|
|
|
|
}
|
2020-04-24 03:05:54 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("devToolsOnStartup")) {
|
2020-04-22 21:15:14 +00:00
|
|
|
clientSettings.devToolsOnStartup = false;
|
|
|
|
}
|
2020-04-24 03:05:54 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("ip")) {
|
2020-04-22 21:15:14 +00:00
|
|
|
clientSettings.ip = "0.0.0.0";
|
|
|
|
}
|
2020-04-24 03:05:54 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("quality")) {
|
2020-04-22 21:15:14 +00:00
|
|
|
clientSettings.quality = 5;
|
|
|
|
}
|
2020-04-24 05:31:28 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("disableVideo")) {
|
|
|
|
clientSettings.disableVideo = false;
|
|
|
|
}
|
2020-04-24 19:14:48 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("disableAudio")) {
|
|
|
|
clientSettings.disableAudio = false;
|
|
|
|
}
|
|
|
|
if (!clientSettings.hasOwnProperty("abxySwap")) {
|
|
|
|
clientSettings.abxySwap = false;
|
|
|
|
}
|
2020-04-27 00:24:33 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("limitFPS")) {
|
|
|
|
clientSettings.limitFPS = false;
|
|
|
|
}
|
2020-04-27 01:42:23 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("autoChangeResolution")) {
|
|
|
|
clientSettings.autoChangeResolution = true;
|
|
|
|
}
|
2020-04-26 22:56:40 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("encoding")) {
|
|
|
|
clientSettings.encoding = "CPU";
|
|
|
|
}
|
2020-04-27 03:48:45 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("mouseControl")) {
|
2020-04-28 23:34:52 +00:00
|
|
|
clientSettings.mouseControl = "ANALOG";
|
2020-04-27 03:48:45 +00:00
|
|
|
}
|
2020-04-24 03:05:54 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("firstInstall")) {
|
2020-04-22 21:15:14 +00:00
|
|
|
clientSettings.firstInstall = false;
|
|
|
|
}
|
2020-04-26 23:46:42 +00:00
|
|
|
if (!clientSettings.hasOwnProperty("autoStartup")) {
|
|
|
|
clientSettings.autoStartup = false;
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:15:14 +00:00
|
|
|
applyClientSettings();
|
|
|
|
}
|
2020-04-24 03:05:54 +00:00
|
|
|
function loadClientSettings() {
|
|
|
|
clientSettings = DB.load(clientSettingsPath);
|
|
|
|
initSettings();
|
|
|
|
saveClientSettings();
|
|
|
|
}
|
2020-04-22 21:15:14 +00:00
|
|
|
|
|
|
|
function applyClientSettings() {
|
2020-04-16 00:15:44 +00:00
|
|
|
$("#debugEnabled").prop("checked", clientSettings.debug);
|
|
|
|
$("#rainbowEnabled").prop("checked", clientSettings.rainbowEnabled);
|
|
|
|
$("#devToolsOnStartup").prop("checked", clientSettings.devToolsOnStartup);
|
2020-04-22 22:22:43 +00:00
|
|
|
$("#autoStart").prop("checked", clientSettings.autoStartStreamer);
|
2020-04-26 23:46:42 +00:00
|
|
|
$("#autoStartup").prop("checked", clientSettings.autoStartup);
|
2020-04-16 03:58:28 +00:00
|
|
|
$("#qualitySlider").val(clientSettings.quality);
|
2020-04-23 02:12:51 +00:00
|
|
|
$('#qualityLabel').html("Quality: " + clientSettings.quality + "Mbps");
|
2020-04-24 05:31:28 +00:00
|
|
|
$('#disableVideo').prop("checked", clientSettings.disableVideo);
|
2020-04-24 19:14:48 +00:00
|
|
|
$('#disableAudio').prop("checked", clientSettings.disableAudio);
|
|
|
|
$('#abxySwap').prop("checked", clientSettings.abxySwap);
|
2020-04-27 00:24:33 +00:00
|
|
|
$('#limitFPS').prop("checked", clientSettings.limitFPS);
|
2020-04-27 01:42:23 +00:00
|
|
|
$('#autoChangeResolution').prop("checked", clientSettings.autoChangeResolution);
|
|
|
|
if (clientSettings.autoChangeResolution) {
|
|
|
|
ipcRenderer.send("autoChangeResolutionOn");
|
|
|
|
} else {
|
|
|
|
ipcRenderer.send("autoChangeResolutionOff")
|
|
|
|
}
|
2020-04-16 03:58:28 +00:00
|
|
|
$("#ipInput").val(clientSettings.ip);
|
2020-04-26 22:56:40 +00:00
|
|
|
if (clientSettings.encoding == "NVENC") {
|
|
|
|
$("#encodingDrop").html("Encoding (Nvidia)");
|
2022-03-04 18:33:22 +00:00
|
|
|
} else if (clientSettings.encoding == "AMDVCE") {
|
2020-05-10 01:15:08 +00:00
|
|
|
$("#encodingDrop").html("Encoding (AMD)")
|
2022-03-04 18:33:22 +00:00
|
|
|
} else if (clientSettings.encoding == "QSV") {
|
2020-05-10 20:44:31 +00:00
|
|
|
$("#encodingDrop").html("Encoding (Intel)");
|
2020-04-26 22:56:40 +00:00
|
|
|
} else {
|
|
|
|
$("#encodingDrop").html("Encoding (CPU)");
|
2020-04-27 03:48:45 +00:00
|
|
|
clientSettings.encoding = "CPU";
|
|
|
|
}
|
|
|
|
if (clientSettings.mouseControl == "ANALOG") {
|
|
|
|
$("#mouseControlDrop").html("Mouse Control (Analog)");
|
|
|
|
} else if (clientSettings.mouseControl == "GYRO") {
|
|
|
|
$("#mouseControlDrop").html("Mouse Control (Gyro)");
|
|
|
|
} else {
|
2020-04-28 23:34:52 +00:00
|
|
|
$("#mouseControlDrop").html("Mouse Control (Analog)");
|
|
|
|
clientSettings.mouseControl = "ANALOG";
|
2020-04-26 22:56:40 +00:00
|
|
|
}
|
2020-04-16 00:15:44 +00:00
|
|
|
if (clientSettings.debug) {
|
|
|
|
$("#dev-btn").fadeIn(400);
|
|
|
|
$("#rld-btn").fadeIn(400);
|
|
|
|
} else {
|
|
|
|
$("#dev-btn").fadeOut(400);
|
|
|
|
$("#rld-btn").fadeOut(400);
|
|
|
|
}
|
|
|
|
if (clientSettings.rainbowEnabled) {
|
|
|
|
rainbowAccent();
|
|
|
|
} else {
|
|
|
|
setAccentColor(clientSettings.accentColor.r, clientSettings.accentColor.g, clientSettings.accentColor.b, clientSettings.accentColor.a);
|
|
|
|
}
|
2020-04-22 21:15:14 +00:00
|
|
|
if (clientSettings.devToolsOnStartup) {
|
|
|
|
openDevTools();
|
|
|
|
}
|
|
|
|
if (!clientSettings.firstInstall) {
|
|
|
|
ipcRenderer.send('installScpVBus');
|
|
|
|
ipcRenderer.send('installAudioDriver');
|
2022-03-03 14:14:33 +00:00
|
|
|
// $('#restartModal').modal('show');
|
2020-04-22 21:15:14 +00:00
|
|
|
clientSettings.firstInstall = true;
|
2020-04-24 03:05:54 +00:00
|
|
|
saveClientSettings();
|
2020-04-22 21:15:14 +00:00
|
|
|
}
|
2020-04-22 22:19:05 +00:00
|
|
|
if (clientSettings.autoStartStreamer) {
|
|
|
|
connect();
|
|
|
|
}
|
2020-04-26 23:46:42 +00:00
|
|
|
if (clientSettings.autoStartup) {
|
|
|
|
ipcRenderer.send('autoStartupOn');
|
|
|
|
} else {
|
|
|
|
ipcRenderer.send('autoStartupOff');
|
|
|
|
}
|
2020-04-16 00:15:44 +00:00
|
|
|
}
|
2020-04-22 22:19:05 +00:00
|
|
|
|
2020-04-16 00:15:44 +00:00
|
|
|
$("#rainbowEnabled").on('change', function () {
|
|
|
|
clientSettings.rainbowEnabled = $("#rainbowEnabled").prop("checked");
|
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
|
|
|
});
|
2020-04-16 23:01:29 +00:00
|
|
|
// $("#debugEnabled").on('change', function () {
|
|
|
|
// clientSettings.debug = $("#debugEnabled").prop("checked");
|
|
|
|
// saveClientSettings();
|
|
|
|
// applyClientSettings();
|
|
|
|
// });
|
|
|
|
// $("#devToolsOnStartup").on('change', function () {
|
|
|
|
// clientSettings.devToolsOnStartup = $("#devToolsOnStartup").prop("checked");
|
|
|
|
// saveClientSettings();
|
|
|
|
// applyClientSettings();
|
|
|
|
// });
|
|
|
|
|
2020-04-24 05:31:28 +00:00
|
|
|
$("#autoStart").on('change', function () {
|
|
|
|
clientSettings.autoStartStreamer = $("#autoStart").prop("checked");
|
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
2020-04-26 23:46:42 +00:00
|
|
|
}); $("#autoStartup").on('change', function () {
|
|
|
|
clientSettings.autoStartup = $("#autoStartup").prop("checked");
|
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
2020-04-24 05:31:28 +00:00
|
|
|
});
|
2020-04-26 23:46:42 +00:00
|
|
|
|
2020-04-16 23:01:29 +00:00
|
|
|
$('#installScpVBusBtn').click(function () {
|
|
|
|
ipcRenderer.send('installScpVBus');
|
2020-04-16 00:15:44 +00:00
|
|
|
});
|
2020-04-16 23:01:29 +00:00
|
|
|
$('#unInstallScpVBusBtn').click(function () {
|
|
|
|
ipcRenderer.send('unInstallScpVBus');
|
|
|
|
});
|
|
|
|
$('#installAudioDriverBtn').click(function () {
|
|
|
|
ipcRenderer.send('installAudioDriver');
|
2020-04-16 00:15:44 +00:00
|
|
|
});
|
2020-04-16 23:01:29 +00:00
|
|
|
$('#unInstallAudioDriverBtn').click(function () {
|
|
|
|
ipcRenderer.send('unInstallAudioDriver');
|
2020-04-24 03:05:54 +00:00
|
|
|
});
|
2020-04-24 05:31:28 +00:00
|
|
|
var qualityChangeTimeout;
|
|
|
|
$(document).on('input', '#qualitySlider', function () {
|
|
|
|
$('#qualityLabel').html("Quality: " + $(this).val() + "Mbps");
|
|
|
|
clientSettings.quality = $(this).val();
|
|
|
|
if (running) {
|
|
|
|
clearTimeout(qualityChangeTimeout);
|
|
|
|
qualityChangeTimeout = setTimeout(restart, 1000)
|
|
|
|
}
|
2020-04-24 19:14:48 +00:00
|
|
|
saveClientSettings();
|
2020-04-24 05:31:28 +00:00
|
|
|
});
|
2020-04-24 03:05:54 +00:00
|
|
|
|
2020-04-24 05:31:28 +00:00
|
|
|
$(document).on('input', '#ipInput', function () {
|
|
|
|
clientSettings.ip = $(this).val();
|
|
|
|
saveClientSettings();
|
|
|
|
});
|
|
|
|
$("#disableVideo").on('change', function () {
|
|
|
|
clientSettings.disableVideo = $("#disableVideo").prop("checked");
|
2020-04-24 19:14:48 +00:00
|
|
|
if (running) {
|
|
|
|
restart();
|
|
|
|
}
|
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
|
|
|
});
|
|
|
|
$("#disableAudio").on('change', function () {
|
|
|
|
clientSettings.disableAudio = $("#disableAudio").prop("checked");
|
|
|
|
if (running) {
|
|
|
|
restart();
|
|
|
|
}
|
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
|
|
|
});
|
|
|
|
$("#abxySwap").on('change', function () {
|
|
|
|
clientSettings.abxySwap = $("#abxySwap").prop("checked");
|
|
|
|
if (running) {
|
|
|
|
restart();
|
|
|
|
}
|
2020-04-24 05:31:28 +00:00
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
|
|
|
});
|
2020-04-27 00:24:33 +00:00
|
|
|
$("#limitFPS").on('change', function () {
|
|
|
|
clientSettings.limitFPS = $("#limitFPS").prop("checked");
|
|
|
|
if (running) {
|
|
|
|
restart();
|
|
|
|
}
|
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
|
|
|
});
|
2020-04-27 01:42:23 +00:00
|
|
|
$("#autoChangeResolution").on('change', function () {
|
|
|
|
clientSettings.autoChangeResolution = $("#autoChangeResolution").prop("checked");
|
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
|
|
|
});
|
2020-04-27 00:24:33 +00:00
|
|
|
|
2020-04-24 03:05:54 +00:00
|
|
|
$("#settings-btn").click(function () {
|
|
|
|
$(".contentArea").hide();
|
|
|
|
$("#settings").fadeIn(400);
|
|
|
|
$('#settings-btn').tooltip('hide');
|
|
|
|
});
|
2020-04-26 22:56:40 +00:00
|
|
|
|
|
|
|
function setEncoding(encoding) {
|
|
|
|
clientSettings.encoding = encoding;
|
|
|
|
if (running) {
|
|
|
|
restart();
|
|
|
|
}
|
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
|
|
|
}
|
2020-04-27 03:48:45 +00:00
|
|
|
function setMouseControl(mouseControl) {
|
|
|
|
clientSettings.mouseControl = mouseControl;
|
|
|
|
if (running) {
|
|
|
|
restart();
|
|
|
|
}
|
|
|
|
saveClientSettings();
|
|
|
|
applyClientSettings();
|
|
|
|
}
|
2020-04-27 00:07:31 +00:00
|
|
|
$("#restartBtn").click(function () {
|
|
|
|
ipcRenderer.send('restartComputer');
|
|
|
|
});
|