Commit 99cb5180 authored by Senk Ju's avatar Senk Ju

slight code improvements

parent 7d3e27c2
{
"name": "liquidlauncher",
"productName": "LiquidLauncher",
"version": "1.1.2",
"version": "1.1.3",
"description": "Launcher for LiquidBounce",
"main": "src/index.js",
"scripts": {
......
......@@ -52,8 +52,9 @@ const createWindow = () => {
BrowserWindow.prototype.setDownloadSavePath = function (path) {
this.webContents.session.once("will-download", (event, item) => {
item.setSavePath(os.tmpdir() + "/liquidbounce.zip");
this.hide();
item.once("done", (event, state) => {
item.once("done", () => {
this.close();
})
});
......
......@@ -60,6 +60,18 @@ function _(el) {
return document.getElementById(el);
}
function setProgressBarMax(max) {
launchProgress.max = max;
}
function setProgressBarState(current) {
launchProgress.value = current;
}
function setProgressBarLabel(text) {
progressLabel.innerHTML = text;
}
function diagnose() {
var result = Buffer.from(JSON.stringify({
mcVersion: selectMcVersion[selectMcVersion.selectedIndex].value,
......@@ -278,19 +290,19 @@ function initializeRun() {
progress(request(runtimeUrl), { throttle: 0 })
.on("progress", state => {
launchProgress.max = state.size.total;
launchProgress.value = state.size.transferred;
setProgressBarMax(state.size.total);
setProgressBarState(state.size.transferred);
var total = parseFloat(state.size.total / 1000000).toFixed(2);
var transferred = parseFloat(state.size.transferred / 1000000).toFixed(2);
progressLabel.innerHTML = `Downloading JRE... (${transferred}/${total})`;
setProgressBarLabel(`Downloading JRE... (${transferred}/${total})`);
})
.on("error", err => console.error(err))
.on("end", () => {
log('<span class="info">[LiquidLauncher-GUI] Finished downloading Java Runtime.</span><br>');
log('<span class="info">[LiquidLauncher-GUI] Extracting...</span><br>');
progressLabel.innerHTML = "Extracting..."
setProgressBarLabel("Extracting...");
extract(path.join(tmpDir, filename), { dir: runtimeFolder }, (err) => {
if (err) console.error(err);
......@@ -299,10 +311,15 @@ function initializeRun() {
if (platform === "darwin" || platform === "linux")
fs.chmodSync(path.join(runtimeFolder, "bin", "java"), "777")
setProgressBarLabel("Cleaning up...");
try {
fs.unlinkSync(path.join(tmpDir, filename))
} catch (err) {}
log('<span class="info">[LiquidLauncher-GUI] Done.</span><br>');
runGame();
setProgressBarLabel("Waiting...");
})
})
.pipe(createWriteStream(path.join(tmpDir, filename)));
......@@ -359,13 +376,13 @@ function runGame() {
break;
case 1:
launchProgress.max = data.max;
setProgressBarMax(data.max);
break;
case 2:
launchProgress.value = data.progress;
progressLabel.innerHTML = data.text;
setProgressBarLabel(data.text);
setProgressBarState(data.progress);
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment