Commit dda982cf authored by Senk Ju's avatar Senk Ju

improved

parent 61bb7405
{
"dest": "out/linux",
"icon": "src/html/img/logo_big.png",
"categories": [
"Game"
],
"lintianOverrides": [
"changelog-file-missing-in-native-package"
]
}
\ No newline at end of file
......@@ -9,7 +9,9 @@
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "eslint src --color"
"lint": "eslint src --color",
"package-linux": "electron-packager . liquidlauncher --overwrite --asar=true --platform=linux --arch=x64 --icon=src/html/img/logo_big.png --prune=true --out=out/linux",
"release-linux": "electron-installer-debian --src out/linux/liquidlauncher-linux-x64/ --arch amd64 --config debian.json"
},
"keywords": [],
"author": "CCBlueX",
......@@ -88,4 +90,4 @@
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.8.1"
}
}
}
\ No newline at end of file
import { app, BrowserWindow, globalShortcut } from 'electron';
const os = require("os");
const electron = require("electron");
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const globalShortcut = electron.globalShortcut;
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require("electron-squirrel-startup")) { // eslint-disable-line global-require
......
const https = require("https");
const { exec } = require("child_process");
const {
exec
} = require("child_process");
const fs = require("fs");
const remote = require("electron").remote;
const os = require("os");
const ygg = require("yggdrasil")();
const extract = require("extract-zip");
const path = require("path");
const { createWriteStream } = require("fs");
const {
createWriteStream
} = require("fs");
const request = require("request");
const progress = require("request-progress");
const mcFolderPath = require("minecraft-folder-path");
......@@ -272,23 +276,16 @@ function performLogin() {
}
}
function initializeRun() {
hideRunButton();
var runtimeFolder = path.join(inputMinecraftPath.value, "runtime");
if (!fs.existsSync(runtimeFolder) && inputJvmPath.value === "internal") {
mkdirp(inputMinecraftPath.value, (err) => {
if (err) console.error(err);
var filename = platform + ".zip";
var runtimeUrl = "https://ccbluex.github.io/FileCloud/LiquidLauncher/runtime/" + filename;
function downloadCore() {
return new Promise(resolve => {
var launcherCoreFolder = path.join(inputMinecraftPath.value, "liquidlauncher-core.jar");
var launcherCoreUrl = "https://ccbluex.github.io/FileCloud/LiquidLauncher/core/liquidlauncher-core-1-0.jar";
log('<span class="info">[LiquidLauncher-GUI] Java Runtime not found! Downloading... Please wait.</span><br>');
if (!fs.existsSync(launcherCoreFolder)) {
fs.mkdirSync(runtimeFolder);
progress(request(runtimeUrl), { throttle: 0 })
progress(request(launcherCoreUrl), {
throttle: 0
})
.on("progress", state => {
setProgressBarMax(state.size.total);
setProgressBarState(state.size.transferred);
......@@ -296,34 +293,76 @@ function initializeRun() {
var total = parseFloat(state.size.total / 1000000).toFixed(2);
var transferred = parseFloat(state.size.transferred / 1000000).toFixed(2);
setProgressBarLabel(`Downloading JRE... (${transferred}/${total})`);
setProgressBarLabel(`Downloading LiquidLauncher Core... (${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>');
setProgressBarLabel("Extracting...");
log('<span class="info">[LiquidLauncher-GUI] Finished downloading LiquidLauncher Core.</span><br>');
resolve();
})
.pipe(createWriteStream(launcherCoreFolder));
}
});
}
extract(path.join(tmpDir, filename), { dir: runtimeFolder }, (err) => {
if (err) console.error(err);
async function initializeRun() {
hideRunButton();
// Make downloaded JRE executeable
if (platform === "darwin" || platform === "linux")
fs.chmodSync(path.join(runtimeFolder, "bin", "java"), "777")
var runtimeFolder = path.join(inputMinecraftPath.value, "runtime");
setProgressBarLabel("Cleaning up...");
try {
fs.unlinkSync(path.join(tmpDir, filename))
} catch (err) {}
try {
fs.mkdirSync(inputMinecraftPath.value, { recursive: true });
} catch (err) {}
log('<span class="info">[LiquidLauncher-GUI] Done.</span><br>');
await downloadCore();
runGame();
setProgressBarLabel("Waiting...");
})
if (!fs.existsSync(runtimeFolder) && inputJvmPath.value === "internal") {
fs.mkdirSync(runtimeFolder);
var filename = platform + ".zip";
var runtimeUrl = "https://ccbluex.github.io/FileCloud/LiquidLauncher/runtime/" + filename;
log('<span class="info">[LiquidLauncher-GUI] Java Runtime not found! Downloading... Please wait.</span><br>');
progress(request(runtimeUrl), {
throttle: 0
})
.on("progress", state => {
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);
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>');
setProgressBarLabel("Extracting...");
extract(path.join(tmpDir, filename), {
dir: runtimeFolder
}, (err) => {
if (err) console.error(err);
// Make downloaded JRE executeable
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)));
});
})
.pipe(createWriteStream(path.join(tmpDir, filename)));
} else {
runGame();
}
......@@ -350,9 +389,9 @@ function runGame() {
console.log(startOptions)
var launcher = exec(`${jvmPath} -jar ${path.join(appPath, "liquidlauncher-core.jar")} ${startOptions}`, { maxBuffer: Infinity });
logContainer.innerHTML = "";
var launcher = exec(`${jvmPath} -jar ${path.join(inputMinecraftPath.value, "liquidlauncher-core.jar")} ${startOptions}`, {
maxBuffer: Infinity
});
launcher.stdout.pipe(require("split")(JSON.parse)).on("data", (data) => {
......@@ -424,7 +463,7 @@ function runGame() {
function openFolder(path) {
try {
shell.openItem(path);
} catch (err) { }
} catch (err) {}
}
https.get("https://ccbluex.github.io/FileCloud/LiquidLauncher/versions.json", (resp) => {
......@@ -536,5 +575,4 @@ closeViewLog.addEventListener("click", () => {
// Outdated Launcher View
closeViewOutdated.addEventListener("click", () => {
hideView(viewOutdated)
});
});
\ No newline at end of file
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